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 == "" {
|
||||
|
||||
@@ -668,22 +668,7 @@ func GetUnionOrdersPage(db *DaoDB, vendorIDs, statuss []int, beginTime, endTime
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
func SetOrderStatus(db *DaoDB, orderID string, status int) (msg string, err error) {
|
||||
sqlParams := []interface{}{}
|
||||
sql := `UPDATE order o SET o.status = ? `
|
||||
if status > 0 {
|
||||
sqlParams = append(sqlParams, status)
|
||||
}
|
||||
if orderID != "" {
|
||||
sql += `WHERE o.order_id = ?`
|
||||
sqlParams = append(sqlParams, orderID)
|
||||
}
|
||||
orderInfos := &model.Order{}
|
||||
if err := GetRow(db, orderInfos, sql, sqlParams); err != nil {
|
||||
return "更新order状态失败", err
|
||||
}
|
||||
return "更新order状态成功", err
|
||||
}
|
||||
|
||||
func SetUserVendorOrderStatus(db *DaoDB, localWayBillID string, status int) (msg string, err error) {
|
||||
sqlParams := []interface{}{}
|
||||
sql := `UPDATE user_vendor_order a SET a.order_status = ?`
|
||||
@@ -700,3 +685,11 @@ func SetUserVendorOrderStatus(db *DaoDB, localWayBillID string, status int) (msg
|
||||
}
|
||||
return "更新UserVendorOrder状态成功", err
|
||||
}
|
||||
|
||||
//更新order 价格和状态
|
||||
func SetOrderStatus(db *DaoDB, payPrice, payMethod 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 {
|
||||
return "", err
|
||||
}
|
||||
return "更新Order状态成功", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user