diff --git a/business/jxstore/financial/pay.go b/business/jxstore/financial/pay.go index 69da0f50c..414ca707a 100644 --- a/business/jxstore/financial/pay.go +++ b/business/jxstore/financial/pay.go @@ -25,8 +25,7 @@ type PayHandlerInterface interface { func OnPayFinished(order *model.Order) (err error) { var ( - db = dao.GetDB() - billID int64 + db = dao.GetDB() ) globals.SugarLogger.Debugf("OnPayFinished begin modify account order: %v", utils.Format4Output(order, false)) dao.Begin(db) @@ -46,13 +45,8 @@ func OnPayFinished(order *model.Order) (err error) { switch order.Type { case model.OrderTypeAccount: //如果是账户充值(发布任务等) - //1、账户收入表明细 - if err = AddBillIncome(db, billID, model.BillTypeInvest, order.PayPrice); err != nil { - dao.Rollback(db) - } - //2、账户表账户余额增加相应值 - userBill.AccountBalance += order.PayPrice - if _, err = dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil { + //账户收入 + if err = AddIncomeUpdateAccount(db, userBill, model.BillTypeInvest, order.PayPrice); err != nil { dao.Rollback(db) } default: @@ -66,8 +60,7 @@ func OnPayFinished(order *model.Order) (err error) { func OnCashFinished(order *model.Order) (err error) { var ( - db = dao.GetDB() - billID int64 + db = dao.GetDB() ) globals.SugarLogger.Debugf("OnCashFinished begin modify account order: %v", utils.Format4Output(order, false)) dao.Begin(db) @@ -87,13 +80,8 @@ func OnCashFinished(order *model.Order) (err error) { switch order.Type { case model.OrderTypeAccount: //如果是账户提现 - //1、账户支出明细增加一条 - if err = AddBillExpend(db, billID, model.BillTypeCash, order.PayPrice); err != nil { - dao.Rollback(db) - } - //2、账户表账户余额减少相应值 - userBill.AccountBalance -= order.PayPrice - if _, err = dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil { + //账户支出 + if err = AddExpendUpdateAccount(db, userBill, model.BillTypeCash, order.PayPrice); err != nil { dao.Rollback(db) } default: