@@ -23,6 +23,14 @@ func (masterDb *MasterDb) GetMaster(mid string) *model.Master { | |||||
} | } | ||||
return &data | return &data | ||||
} | } | ||||
func (masterDb *MasterDb) GetMasterId(id int) *model.Master { | |||||
var data model.Master | |||||
get, err := masterDb.Db.Where("id=?", id).Get(&data) | |||||
if get == false || err != nil { | |||||
return nil | |||||
} | |||||
return &data | |||||
} | |||||
func (masterDb *MasterDb) MasterUpdate(data *model.Master) bool { | func (masterDb *MasterDb) MasterUpdate(data *model.Master) bool { | ||||
get, err := masterDb.Db.Where("id=?", data.Id).Update(data) | get, err := masterDb.Db.Where("id=?", data.Id).Update(data) | ||||
@@ -17,4 +17,5 @@ type Master struct { | |||||
UpdateTime time.Time `json:"update_time" xorm:"DATETIME"` | UpdateTime time.Time `json:"update_time" xorm:"DATETIME"` | ||||
Alipay string `json:"alipay" xorm:"VARCHAR(255)"` | Alipay string `json:"alipay" xorm:"VARCHAR(255)"` | ||||
AlipayName string `json:"alipay_name" xorm:"VARCHAR(255)"` | AlipayName string `json:"alipay_name" xorm:"VARCHAR(255)"` | ||||
ExtendUid string `json:"extend_uid" xorm:"VARCHAR(255)"` | |||||
} | } |
@@ -16,4 +16,5 @@ type MasterAmountFlow struct { | |||||
Title string `json:"title" xorm:"VARCHAR(255)"` | Title string `json:"title" xorm:"VARCHAR(255)"` | ||||
FlowType string `json:"flow_type" xorm:"VARCHAR(255)"` | FlowType string `json:"flow_type" xorm:"VARCHAR(255)"` | ||||
IncomeType int `json:"income_type" xorm:"default 0 INT(1)"` | IncomeType int `json:"income_type" xorm:"default 0 INT(1)"` | ||||
ExtendUid string `json:"extend_uid" xorm:"VARCHAR(255)"` | |||||
} | } |
@@ -16,4 +16,5 @@ type MasterLastMonthAmountFlow struct { | |||||
Title string `json:"title" xorm:"VARCHAR(255)"` | Title string `json:"title" xorm:"VARCHAR(255)"` | ||||
FlowType string `json:"flow_type" xorm:"VARCHAR(255)"` | FlowType string `json:"flow_type" xorm:"VARCHAR(255)"` | ||||
IncomeType int `json:"income_type" xorm:"default 0 INT(1)"` | IncomeType int `json:"income_type" xorm:"default 0 INT(1)"` | ||||
ExtendUid string `json:"extend_uid" xorm:"VARCHAR(255)"` | |||||
} | } |
@@ -21,4 +21,5 @@ type MasterWithdrawalFlow struct { | |||||
RealAmount string `json:"real_amount" xorm:"default 0.00 DECIMAL(20,2)"` | RealAmount string `json:"real_amount" xorm:"default 0.00 DECIMAL(20,2)"` | ||||
HasInvoice int `json:"has_invoice" xorm:"default 0 comment('是否有发票') INT(1)"` | HasInvoice int `json:"has_invoice" xorm:"default 0 comment('是否有发票') INT(1)"` | ||||
InvoiceBili string `json:"invoice_bili" xorm:"comment('发票比例') VARCHAR(255)"` | InvoiceBili string `json:"invoice_bili" xorm:"comment('发票比例') VARCHAR(255)"` | ||||
ExtendUid string `json:"extend_uid" xorm:"VARCHAR(255)"` | |||||
} | } |
@@ -97,6 +97,13 @@ func WithdrawalDoing(c *gin.Context) { | |||||
e.OutErr(c, 400, e.NewErr(400, "金额不正确")) | e.OutErr(c, 400, e.NewErr(400, "金额不正确")) | ||||
return | return | ||||
} | } | ||||
masterdb := db.MasterDb{} | |||||
masterdb.Set() | |||||
master := masterdb.GetMaster(mid) | |||||
if master == nil { | |||||
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) | |||||
return | |||||
} | |||||
amountMap := masterAmount(mid, args["type"]) | amountMap := masterAmount(mid, args["type"]) | ||||
leaveAmount := utils.StrToFloat64(amountMap["amount"]) - utils.StrToFloat64(args["amount"]) | leaveAmount := utils.StrToFloat64(amountMap["amount"]) - utils.StrToFloat64(args["amount"]) | ||||
if leaveAmount < 0 { | if leaveAmount < 0 { | ||||
@@ -181,6 +188,7 @@ func WithdrawalDoing(c *gin.Context) { | |||||
Oid: "", | Oid: "", | ||||
Title: "提现", | Title: "提现", | ||||
FlowType: "withdrawal", | FlowType: "withdrawal", | ||||
ExtendUid: master.ExtendUid, | |||||
} | } | ||||
flowInsert := db.MasterAmountFlowInsertWithSess(sess, &tmpFlow) | flowInsert := db.MasterAmountFlowInsertWithSess(sess, &tmpFlow) | ||||
if flowInsert == false { | if flowInsert == false { | ||||
@@ -201,6 +209,7 @@ func WithdrawalDoing(c *gin.Context) { | |||||
Status: "提现审核", | Status: "提现审核", | ||||
HasInvoice: utils.StrToInt(args["has_invoice"]), | HasInvoice: utils.StrToInt(args["has_invoice"]), | ||||
InvoiceBili: args["invoice_bili"], | InvoiceBili: args["invoice_bili"], | ||||
ExtendUid: master.ExtendUid, | |||||
} | } | ||||
insert := db.MasterWithdrawalFlowInsertWithSess(sess, &tmp) | insert := db.MasterWithdrawalFlowInsertWithSess(sess, &tmp) | ||||
if insert == false { | if insert == false { | ||||
@@ -39,6 +39,12 @@ func MasterMonthSettle() { | |||||
if utils.StrToFloat64(v.LastMonthAmount) <= 0 { | if utils.StrToFloat64(v.LastMonthAmount) <= 0 { | ||||
continue | continue | ||||
} | } | ||||
masterDb := db.MasterDb{} | |||||
masterDb.Set() | |||||
master := masterDb.GetMasterId(v.Id) | |||||
if master == nil { | |||||
continue | |||||
} | |||||
oldAmount := v.Amount | oldAmount := v.Amount | ||||
oldLastMonthAmount := v.LastMonthAmount | oldLastMonthAmount := v.LastMonthAmount | ||||
v.Amount = utils.Float64ToStr(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(v.LastMonthAmount)) | v.Amount = utils.Float64ToStr(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(v.LastMonthAmount)) | ||||
@@ -58,6 +64,7 @@ func MasterMonthSettle() { | |||||
Title: "短剧上月结算佣金到账", | Title: "短剧上月结算佣金到账", | ||||
FlowType: "last_month_playlet_settle", | FlowType: "last_month_playlet_settle", | ||||
IncomeType: 0, | IncomeType: 0, | ||||
ExtendUid: master.ExtendUid, | |||||
} | } | ||||
masterAmountFlowDb := db.MasterAmountFlowDb{} | masterAmountFlowDb := db.MasterAmountFlowDb{} | ||||
masterAmountFlowDb.Set() | masterAmountFlowDb.Set() | ||||
@@ -74,6 +81,7 @@ func MasterMonthSettle() { | |||||
Title: "短剧上月结算佣金转到余额", | Title: "短剧上月结算佣金转到余额", | ||||
FlowType: "last_month_playlet_settle", | FlowType: "last_month_playlet_settle", | ||||
IncomeType: 1, | IncomeType: 1, | ||||
ExtendUid: master.ExtendUid, | |||||
} | } | ||||
masterLastMonthAmountFlowDb := db.MasterLastMonthAmountFlowDb{} | masterLastMonthAmountFlowDb := db.MasterLastMonthAmountFlowDb{} | ||||
masterLastMonthAmountFlowDb.Set() | masterLastMonthAmountFlowDb.Set() | ||||
@@ -81,6 +81,7 @@ func PlayletOrderSettle() { | |||||
Oid: v.Oid, | Oid: v.Oid, | ||||
Title: "短剧订单结算", | Title: "短剧订单结算", | ||||
FlowType: "playlet_settle", | FlowType: "playlet_settle", | ||||
ExtendUid: master.ExtendUid, | |||||
} | } | ||||
masterLastMonthAmountFlowDb := db.MasterLastMonthAmountFlowDb{} | masterLastMonthAmountFlowDb := db.MasterLastMonthAmountFlowDb{} | ||||
masterLastMonthAmountFlowDb.Set() | masterLastMonthAmountFlowDb.Set() | ||||