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) {
|
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)
|
orderInfo, err := dao.GetOrderByID(dao.GetDB(), orderID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
txDB orm.TxOrmer
|
|
||||||
db = dao.GetDB()
|
|
||||||
order = &model.Order{
|
order = &model.Order{
|
||||||
OrderID: orderID,
|
OrderID: orderID,
|
||||||
PayPrice: orderInfo.PayPrice,
|
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("payPrice before1111=========================", payPrice)
|
||||||
|
|
||||||
//支付金额<原金额
|
//支付金额<原金额
|
||||||
globals.SugarLogger.Debug("order.PayPrice=========================", order.PayPrice)
|
globals.SugarLogger.Debug("order.PayPrice=========================", order.PayPrice)
|
||||||
if payPrice < order.PayPrice {
|
if payPrice < order.PayPrice {
|
||||||
order = &model.Order{
|
temp_PayPrice = payPrice
|
||||||
OrderID: orderID,
|
temp_PayMethod = 5
|
||||||
PayPrice: payPrice,
|
//order = &model.Order{
|
||||||
UserID: orderInfo.UserID,
|
// OrderID: orderID,
|
||||||
PayMethod: 5, //混合支付
|
// PayPrice: payPrice,
|
||||||
}
|
// UserID: orderInfo.UserID,
|
||||||
|
// PayMethod: 5, //混合支付
|
||||||
|
//}
|
||||||
} else {
|
} else {
|
||||||
order = &model.Order{
|
temp_PayPrice = orderInfo.PayPrice
|
||||||
OrderID: orderID,
|
temp_PayMethod = 2
|
||||||
PayPrice: orderInfo.PayPrice,
|
//order = &model.Order{
|
||||||
UserID: orderInfo.UserID,
|
// OrderID: orderID,
|
||||||
PayMethod: 2, //微信支付
|
// PayPrice: orderInfo.PayPrice,
|
||||||
|
// UserID: orderInfo.UserID,
|
||||||
|
// PayMethod: 2, //微信支付
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayMethod)
|
||||||
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayPrice, order.PayMethod)
|
globals.SugarLogger.Debug("检验初始数据情况", order.PayPrice)
|
||||||
//txDB, _ := dao.Begin(db)
|
//txDB, _ := dao.Begin(db)
|
||||||
//defer func() {
|
//defer func() {
|
||||||
// if r := recover(); r != nil {
|
// 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 {
|
if _, err := dao.UpdateEntityTx(txDB, &order); err != nil {
|
||||||
//dao.Rollback(db, txDB)
|
//dao.Rollback(db, txDB)
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -137,6 +148,7 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, app
|
|||||||
//}
|
//}
|
||||||
//dao.Commit(db, txDB)
|
//dao.Commit(db, txDB)
|
||||||
globals.SugarLogger.Debug("经过更新操作后的数据after=========================", order.OrderID, order.PayPrice, order.PayMethod)
|
globals.SugarLogger.Debug("经过更新操作后的数据after=========================", order.OrderID, order.PayPrice, order.PayMethod)
|
||||||
|
globals.SugarLogger.Debug("经过更新操作后的数据after=========================", order.PayPrice)
|
||||||
globals.SugarLogger.Debugf("pay begin……")
|
globals.SugarLogger.Debugf("pay begin……")
|
||||||
err = dao.GetEntity(db, order, "OrderID")
|
err = dao.GetEntity(db, order, "OrderID")
|
||||||
if order.OrderID == "" {
|
if order.OrderID == "" {
|
||||||
|
|||||||
@@ -668,22 +668,7 @@ func GetUnionOrdersPage(db *DaoDB, vendorIDs, statuss []int, beginTime, endTime
|
|||||||
}
|
}
|
||||||
return page, err
|
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) {
|
func SetUserVendorOrderStatus(db *DaoDB, localWayBillID string, status int) (msg string, err error) {
|
||||||
sqlParams := []interface{}{}
|
sqlParams := []interface{}{}
|
||||||
sql := `UPDATE user_vendor_order a SET a.order_status = ?`
|
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
|
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