pay
This commit is contained in:
@@ -82,13 +82,17 @@ func CreateOrder(ctx *jxcontext.Context, type1, orderType int, way string, price
|
||||
}
|
||||
|
||||
func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, appId string, payPrice int) (result *financial.WxPayParam, err error) {
|
||||
var (
|
||||
temp_PayPrice int
|
||||
temp_PayMethod int
|
||||
txDB orm.TxOrmer
|
||||
db = dao.GetDB()
|
||||
)
|
||||
orderInfo, err := dao.GetOrderByID(dao.GetDB(), orderID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
txDB orm.TxOrmer
|
||||
db = dao.GetDB()
|
||||
order = &model.Order{
|
||||
OrderID: orderID,
|
||||
PayPrice: orderInfo.PayPrice,
|
||||
@@ -101,25 +105,29 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, app
|
||||
}
|
||||
)
|
||||
globals.SugarLogger.Debug("payPrice before1111=========================", payPrice)
|
||||
|
||||
//支付金额<原金额
|
||||
globals.SugarLogger.Debug("order.PayPrice=========================", order.PayPrice)
|
||||
if payPrice < order.PayPrice {
|
||||
order = &model.Order{
|
||||
OrderID: orderID,
|
||||
PayPrice: payPrice,
|
||||
UserID: orderInfo.UserID,
|
||||
PayMethod: 5, //混合支付
|
||||
}
|
||||
temp_PayPrice = payPrice
|
||||
temp_PayMethod = 5
|
||||
//order = &model.Order{
|
||||
// OrderID: orderID,
|
||||
// PayPrice: payPrice,
|
||||
// UserID: orderInfo.UserID,
|
||||
// PayMethod: 5, //混合支付
|
||||
//}
|
||||
} else {
|
||||
order = &model.Order{
|
||||
OrderID: orderID,
|
||||
PayPrice: orderInfo.PayPrice,
|
||||
UserID: orderInfo.UserID,
|
||||
PayMethod: 2, //微信支付
|
||||
}
|
||||
temp_PayPrice = orderInfo.PayPrice
|
||||
temp_PayMethod = 2
|
||||
//order = &model.Order{
|
||||
// OrderID: orderID,
|
||||
// PayPrice: orderInfo.PayPrice,
|
||||
// UserID: orderInfo.UserID,
|
||||
// PayMethod: 2, //微信支付
|
||||
//}
|
||||
}
|
||||
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayPrice, order.PayMethod)
|
||||
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayMethod)
|
||||
globals.SugarLogger.Debug("检验初始数据情况", order.PayPrice)
|
||||
//txDB, _ := dao.Begin(db)
|
||||
//defer func() {
|
||||
// if r := recover(); r != nil {
|
||||
@@ -127,6 +135,9 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, app
|
||||
// }
|
||||
//}()
|
||||
//微信支付实际金额更新到数据库
|
||||
if _, err := dao.SetOrderStatus(db, temp_PayPrice, temp_PayMethod, orderID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := dao.UpdateEntityTx(txDB, &order); err != nil {
|
||||
//dao.Rollback(db, txDB)
|
||||
return nil, err
|
||||
@@ -137,6 +148,7 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, app
|
||||
//}
|
||||
//dao.Commit(db, txDB)
|
||||
globals.SugarLogger.Debug("经过更新操作后的数据after=========================", order.OrderID, order.PayPrice, order.PayMethod)
|
||||
globals.SugarLogger.Debug("经过更新操作后的数据after=========================", order.PayPrice)
|
||||
globals.SugarLogger.Debugf("pay begin……")
|
||||
err = dao.GetEntity(db, order, "OrderID")
|
||||
if order.OrderID == "" {
|
||||
|
||||
Reference in New Issue
Block a user