This commit is contained in:
richboo111
2022-08-03 17:00:54 +08:00
parent d7c472372e
commit 8cd0816719
3 changed files with 31 additions and 20 deletions

View File

@@ -117,7 +117,7 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, app
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayMethod)
globals.SugarLogger.Debug("检验初始数据情况", order.PayPrice)
//微信支付实际金额更新到数据库
if _, err := dao.SetOrderStatus(temp_PayPrice, temp_PayMethod, orderID); err != nil {
if _, err := dao.SetOrderStatus(temp_PayPrice, temp_PayMethod, orderInfo.Status, orderID); err != nil {
return nil, err
}
//if _, err := dao.UpdateEntityTx(txDB, order); err != nil {
@@ -189,27 +189,33 @@ func PayByBalance(ctx *jxcontext.Context, orderID string, isChoose, payType int,
PayPrice: orderInfo.PayPrice,
PayMethod: 1, //余额支付
}
txDB, _ := dao.Begin(db)
defer func() {
if r := recover(); r != nil {
panic(r)
}
dao.Commit(db, txDB)
}()
//txDB, _ := dao.Begin(db)
//defer func() {
// if r := recover(); r != nil {
// panic(r)
// }
// dao.Commit(db, txDB)
//}()
//增加账单 余额减去相应金额
if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypePayByAccountBalance, order.PayPrice, 0); err != nil {
dao.Rollback(db, txDB)
return nil, "使用余额支付失败", err
money := userBill.AccountBalance - orderInfo.PayPrice
if err = dao.UpdateUserBill(userBill.UserID, money); err != nil {
return nil, "余额支付失败", err
}
//if err = financial.AddExpendUpdateAccount(txDB, userBill, model.BillTypePayByAccountBalance, orderInfo.PayPrice, 0); err != nil {
// //dao.Rollback(db, txDB)
// return nil, "使用余额支付失败:", err
//}
//更新订单状态
order = &model.Order{
Status: 110, //支付成功
order.Status = 110
order.PayMethod = 1
if _, err := dao.SetOrderStatus(orderInfo.PayPrice, 1, 110, orderID); err != nil {
return nil, "更新order状态失败", err
}
if _, err := dao.UpdateEntityTx(txDB, order, "Status"); err != nil {
dao.Rollback(db, txDB)
return nil, "", err
}
dao.Commit(db, txDB)
//if _, err := dao.UpdateEntityTx(txDB, order); err != nil {
// dao.Rollback(db, txDB)
// return nil, "", err
//}
//dao.Commit(db, txDB)
}
if isChoose == Choose {
//1用户不使用余额或者余额=0 即直接微信支付

View File

@@ -7,6 +7,7 @@ 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"
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego/client/orm"
"time"
)
@@ -41,6 +42,7 @@ func AddBillExpend(txDB orm.TxOrmer, billID int64, billType, expendPrice, jobID
ExpendPrice: expendPrice,
JobID: jobID,
}
globals.SugarLogger.Debug("进入AddBillExpend")
dao.WrapAddIDCULEntity(billExpend, jxcontext.AdminCtx.GetUserName())
return dao.CreateEntityTx(txDB, billExpend)
}
@@ -68,6 +70,7 @@ func GetUserBillDetail(ctx *jxcontext.Context, userID, fromTime, toTime string,
func AddExpendUpdateAccount(txDB orm.TxOrmer, userBill *model.UserBill, billType, price, jobID int) (err error) {
//1、账户支出增加一条记录
globals.SugarLogger.Debug("进入AddExpendUpdateAccount")
err = AddBillExpend(txDB, userBill.BillID, billType, price, jobID)
if err != nil {
return err

View File

@@ -687,10 +687,12 @@ func SetUserVendorOrderStatus(db *DaoDB, localWayBillID string, status int) (msg
}
//更新order 价格和状态
func SetOrderStatus(payPrice, payMethod int, orderID string) (string, error) {
func SetOrderStatus(payPrice, payMethod, status int, orderID string) (string, error) {
if _, err := ExecuteSQL(GetDB(), "UPDATE `order` SET pay_price = ?,pay_method= ? WHERE order_id = ? ", []interface{}{payPrice, payMethod, orderID}...); err != nil {
if _, err := ExecuteSQL(GetDB(), "UPDATE `order` SET pay_price = ?,pay_method= ?,status=? WHERE order_id = ? ", []interface{}{payPrice, payMethod, status, orderID}...); err != nil {
return "", err
}
return "更新Order状态成功", nil
}
//更新order 支付状态和