aa
This commit is contained in:
@@ -5,9 +5,10 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
)
|
||||
|
||||
func AddBillIncome(db *dao.DaoDB, billID int64, billType, incomePrice, jobID int) (err error) {
|
||||
func AddBillIncome(txDB orm.TxOrmer, billID int64, billType, incomePrice, jobID int) (err error) {
|
||||
billIncome := &model.BillIncome{
|
||||
BillID: billID,
|
||||
Type: billType,
|
||||
@@ -15,10 +16,10 @@ func AddBillIncome(db *dao.DaoDB, billID int64, billType, incomePrice, jobID int
|
||||
JobID: jobID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(billIncome, jxcontext.AdminCtx.GetUserName())
|
||||
return dao.CreateEntity(db, billIncome)
|
||||
return dao.CreateEntityTx(txDB, billIncome)
|
||||
}
|
||||
|
||||
func AddBillExpend(db *dao.DaoDB, billID int64, billType, expendPrice, jobID int) (err error) {
|
||||
func AddBillExpend(txDB orm.TxOrmer, billID int64, billType, expendPrice, jobID int) (err error) {
|
||||
billExpend := &model.BillExpend{
|
||||
BillID: billID,
|
||||
Type: billType,
|
||||
@@ -26,41 +27,41 @@ func AddBillExpend(db *dao.DaoDB, billID int64, billType, expendPrice, jobID int
|
||||
JobID: jobID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(billExpend, jxcontext.AdminCtx.GetUserName())
|
||||
return dao.CreateEntity(db, billExpend)
|
||||
return dao.CreateEntityTx(txDB, billExpend)
|
||||
}
|
||||
func AddUserBill(db *dao.DaoDB, billID int64, userID string) (err error) {
|
||||
func AddUserBill(txDB orm.TxOrmer, billID int64, userID string) (err error) {
|
||||
userBillInsert := &model.UserBill{
|
||||
BillID: billID,
|
||||
UserID: userID,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(userBillInsert, jxcontext.AdminCtx.GetUserName())
|
||||
return dao.CreateEntity(db, userBillInsert)
|
||||
return dao.CreateEntityTx(txDB, userBillInsert)
|
||||
}
|
||||
|
||||
func GetUserBillDetail(ctx *jxcontext.Context, userID, fromTime, toTime string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
return dao.GetUserBillDetail(dao.GetDB(), userID, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
||||
}
|
||||
|
||||
func AddExpendUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, price, jobID int) (err error) {
|
||||
func AddExpendUpdateAccount(txDB orm.TxOrmer, userBill *model.UserBill, billType, price, jobID int) (err error) {
|
||||
//1、账户支出增加一条记录
|
||||
err = AddBillExpend(db, userBill.BillID, billType, price, jobID)
|
||||
err = AddBillExpend(txDB, userBill.BillID, billType, price, jobID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//2、账户表余额减少相应值
|
||||
userBill.AccountBalance -= price
|
||||
_, err = dao.UpdateEntity(db, userBill, "AccountBalance")
|
||||
_, err = dao.UpdateEntityTx(txDB, userBill, "AccountBalance")
|
||||
return err
|
||||
}
|
||||
|
||||
func AddIncomeUpdateAccount(db *dao.DaoDB, userBill *model.UserBill, billType, price, jobID int) (err error) {
|
||||
func AddIncomeUpdateAccount(txDB orm.TxOrmer, userBill *model.UserBill, billType, price, jobID int) (err error) {
|
||||
//2、账户收入增加一条记录
|
||||
err = AddBillIncome(db, userBill.BillID, billType, price, jobID)
|
||||
err = AddBillIncome(txDB, userBill.BillID, billType, price, jobID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//1、根据任务剩余数量退钱到账户余额中
|
||||
userBill.AccountBalance += price
|
||||
_, err = dao.UpdateEntity(db, userBill, "AccountBalance")
|
||||
_, err = dao.UpdateEntityTx(txDB, userBill, "AccountBalance")
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user