bilifanxian

This commit is contained in:
苏尹岚
2020-12-10 14:02:46 +08:00
parent caf63a3869
commit d69c31b773
7 changed files with 100 additions and 48 deletions

View File

@@ -7,21 +7,23 @@ import (
"git.rosy.net.cn/jx-callback/business/model/dao"
)
func AddBillIncome(db *dao.DaoDB, billID int64, billType, incomePrice int) (err error) {
func AddBillIncome(db *dao.DaoDB, billID int64, billType, incomePrice, jobID int) (err error) {
billIncome := &model.BillIncome{
BillID: billID,
Type: billType,
IncomePrice: incomePrice,
JobID: jobID,
}
dao.WrapAddIDCULEntity(billIncome, jxcontext.AdminCtx.GetUserName())
return dao.CreateEntity(db, billIncome)
}
func AddBillExpend(db *dao.DaoDB, billID int64, billType, expendPrice int) (err error) {
func AddBillExpend(db *dao.DaoDB, billID int64, billType, expendPrice, jobID int) (err error) {
billExpend := &model.BillExpend{
BillID: billID,
Type: billType,
ExpendPrice: expendPrice,
JobID: jobID,
}
dao.WrapAddIDCULEntity(billExpend, jxcontext.AdminCtx.GetUserName())
return dao.CreateEntity(db, billExpend)
@@ -39,9 +41,9 @@ func GetUserBillDetail(ctx *jxcontext.Context, userID, fromTime, toTime string,
return dao.GetUserBillDetail(dao.GetDB(), userID, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
}
func AddExpendUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, price int) (err error) {
func AddExpendUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, price, jobID int) (err error) {
//1、账户支出增加一条记录
err = AddBillExpend(db, userBill.BillID, billType, price)
err = AddBillExpend(db, userBill.BillID, billType, price, jobID)
if err != nil {
return err
}
@@ -51,9 +53,9 @@ func AddExpendUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, p
return err
}
func AddIncomeUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, price int) (err error) {
func AddIncomeUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, price, jobID int) (err error) {
//2、账户收入增加一条记录
err = AddBillIncome(db, userBill.BillID, billType, price)
err = AddBillIncome(db, userBill.BillID, billType, price, jobID)
if err != nil {
return err
}

View File

@@ -58,7 +58,7 @@ func OnPayFinished(order *model.Order) (err error) {
case model.OrderTypePay:
//如果是账户充值(发布任务等)
//账户收入
if err = AddIncomeUpdateAccount(db, userBill, model.BillTypeInvest, order.PayPrice); err != nil {
if err = AddIncomeUpdateAccount(db, userBill, model.BillTypeInvest, order.PayPrice, 0); err != nil {
dao.Rollback(db)
}
default:
@@ -93,7 +93,7 @@ func OnCashFinished(order *model.Order) (err error) {
case model.OrderTypeCash:
//如果是账户提现
//账户支出
if err = AddExpendUpdateAccount(db, userBill, model.BillTypeCash, order.PayPrice); err != nil {
if err = AddExpendUpdateAccount(db, userBill, model.BillTypeCash, order.PayPrice, 0); err != nil {
dao.Rollback(db)
}
default: