pay
This commit is contained in:
@@ -3,6 +3,7 @@ package cms
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/q_bida"
|
||||||
"github.com/astaxie/beego/client/orm"
|
"github.com/astaxie/beego/client/orm"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -117,7 +118,7 @@ func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType, app
|
|||||||
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayMethod)
|
globals.SugarLogger.Debug("检验初始数据情况", order.OrderID, order.PayMethod)
|
||||||
globals.SugarLogger.Debug("检验初始数据情况", order.PayPrice)
|
globals.SugarLogger.Debug("检验初始数据情况", order.PayPrice)
|
||||||
//微信支付实际金额更新到数据库
|
//微信支付实际金额更新到数据库
|
||||||
if _, err := dao.SetOrderStatus(temp_PayPrice, temp_PayMethod, orderInfo.Status, orderID); err != nil {
|
if _, err := dao.SetOrderStatus(txDB, temp_PayPrice, temp_PayMethod, orderInfo.Status, orderID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//if _, err := dao.UpdateEntityTx(txDB, order); err != nil {
|
//if _, err := dao.UpdateEntityTx(txDB, order); err != nil {
|
||||||
@@ -186,30 +187,52 @@ func PayByBalance(ctx *jxcontext.Context, orderID string, isChoose, payType int,
|
|||||||
// (3)使用余额且 余额大于支付金额
|
// (3)使用余额且 余额大于支付金额
|
||||||
if userBill.AccountBalance > 0 && userBill.AccountBalance > orderInfo.PayPrice && isChoose == Choose {
|
if userBill.AccountBalance > 0 && userBill.AccountBalance > orderInfo.PayPrice && isChoose == Choose {
|
||||||
globals.SugarLogger.Debug("进入余额支付部分")
|
globals.SugarLogger.Debug("进入余额支付部分")
|
||||||
//txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
//defer func() {
|
defer func() {
|
||||||
// if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
// panic(r)
|
panic(r)
|
||||||
// }
|
}
|
||||||
// dao.Commit(db, txDB)
|
}()
|
||||||
//}()
|
|
||||||
//增加账单 余额减去相应金额
|
//增加账单 余额减去相应金额
|
||||||
|
flag := -1
|
||||||
globals.SugarLogger.Debug("增加账单 余额减去相应金额")
|
globals.SugarLogger.Debug("增加账单 余额减去相应金额")
|
||||||
money := userBill.AccountBalance - orderInfo.PayPrice
|
money := userBill.AccountBalance - orderInfo.PayPrice
|
||||||
if err = dao.UpdateUserBill(userBill.UserID, money); err != nil {
|
if err = dao.UpdateUserBill(userBill.UserID, money); err != nil {
|
||||||
return nil, "余额支付失败", err
|
return nil, "余额支付失败", err
|
||||||
|
} else {
|
||||||
|
flag = 1 //支付成功
|
||||||
}
|
}
|
||||||
//更新订单状态
|
//更新订单状态
|
||||||
globals.SugarLogger.Debug("更新订单状态")
|
globals.SugarLogger.Debug("更新订单状态")
|
||||||
temp_method := 1
|
temp_method := 1
|
||||||
temp_status := 110
|
temp_status := 110
|
||||||
if _, err := dao.SetOrderStatus(orderInfo.PayPrice, temp_method, temp_status, orderID); err != nil {
|
if _, err := dao.SetOrderStatus(txDB, orderInfo.PayPrice, temp_method, temp_status, orderID); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
return nil, "更新order状态失败", err
|
return nil, "更新order状态失败", err
|
||||||
}
|
}
|
||||||
|
//todo 后续需增加其他订单类型
|
||||||
|
//(1)更新快递 订单状态
|
||||||
temp_vendor_status := 4
|
temp_vendor_status := 4
|
||||||
if _, err := dao.SetUserVendorOrderStatus(orderInfo.OrderID, temp_vendor_status); err != nil {
|
if _, err := dao.SetUserVendorOrderStatus(txDB, orderInfo.OrderID, temp_vendor_status); err != nil {
|
||||||
|
dao.Rollback(db, txDB)
|
||||||
return nil, "更新user_vendor_order状态失败", err
|
return nil, "更新user_vendor_order状态失败", err
|
||||||
}
|
}
|
||||||
|
//再次从数据库获取order、userOrder
|
||||||
|
orderNew, err := dao.GetOrderByID(db, orderID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "获取orderNew失败", err
|
||||||
|
}
|
||||||
|
userOrder, err := dao.GetUserVendorOrder(db, orderNew.UserID, orderNew.OrderID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "获取userOrder失败", err
|
||||||
|
}
|
||||||
|
//快递单 同步到qbd
|
||||||
|
if orderInfo.Status == 110 && flag == 1 {
|
||||||
|
if err := q_bida.CreateOrder2QBiDa(userOrder, orderInfo.OrderID); err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dao.Commit(db, txDB)
|
||||||
}
|
}
|
||||||
if isChoose == Choose {
|
if isChoose == Choose {
|
||||||
//(1)用户不使用余额或者余额=0 即直接微信支付
|
//(1)用户不使用余额或者余额=0 即直接微信支付
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/astaxie/beego/client/orm"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -669,7 +670,8 @@ func GetUnionOrdersPage(db *DaoDB, vendorIDs, statuss []int, beginTime, endTime
|
|||||||
return page, err
|
return page, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetUserVendorOrderStatus(localWayBillID string, status int) (msg string, err error) {
|
//更新user_vendor_order 支付状态
|
||||||
|
func SetUserVendorOrderStatus(tx orm.TxOrmer, localWayBillID string, status int) (msg string, err error) {
|
||||||
if _, err := ExecuteSQL(GetDB(), "UPDATE `user_vendor_order` SET order_status = ? WHERE local_way_bill = ? ", []interface{}{status, localWayBillID}...); err != nil {
|
if _, err := ExecuteSQL(GetDB(), "UPDATE `user_vendor_order` SET order_status = ? WHERE local_way_bill = ? ", []interface{}{status, localWayBillID}...); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -677,12 +679,10 @@ func SetUserVendorOrderStatus(localWayBillID string, status int) (msg string, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新order 价格和状态
|
//更新order 价格和状态
|
||||||
func SetOrderStatus(payPrice, payMethod, status int, orderID string) (string, error) {
|
func SetOrderStatus(tx orm.TxOrmer, payPrice, payMethod, status int, orderID string) (string, error) {
|
||||||
|
|
||||||
if _, err := ExecuteSQL(GetDB(), "UPDATE `order` SET pay_price = ?,pay_method= ?,status=? WHERE order_id = ? ", []interface{}{payPrice, payMethod, status, 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 "", err
|
||||||
}
|
}
|
||||||
return "更新Order状态成功", nil
|
return "更新Order状态成功", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新user_vendor_order 支付状态
|
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrd
|
|||||||
return FailCode, err
|
return FailCode, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debug("回调获取user_bill详情", userBill)
|
globals.SugarLogger.Debug("回调获取user_bill详情", userBill)
|
||||||
|
|
||||||
if orderWay.Status == 110 {
|
if orderWay.Status == 110 {
|
||||||
if orderWay.PayMethod == 1 { // 余额支付
|
if orderWay.PayMethod == 1 { // 余额支付
|
||||||
txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
@@ -298,24 +299,12 @@ func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrd
|
|||||||
if _, err := dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil {
|
if _, err := dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil {
|
||||||
return FailCode, err
|
return FailCode, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新mixPay 状态
|
//更新mixPay 状态
|
||||||
mixPayInfo.Status = -1 //model.BillMixPayRefund1 //退款状态
|
mixPayInfo.Status = -1 //model.BillMixPayRefund1 //退款状态
|
||||||
if _, err := dao.UpdateEntity(db, mixPayInfo, "Status"); err != nil {
|
if _, err := dao.UpdateEntity(db, mixPayInfo, "Status"); err != nil {
|
||||||
return FailCode, err
|
return FailCode, err
|
||||||
}
|
}
|
||||||
/////////////
|
|
||||||
//mixPayInfo1, err := dao.GetMixPayDetail(orderWay.OrderID)
|
|
||||||
//if err != nil {
|
|
||||||
// return 0, err
|
|
||||||
//}
|
|
||||||
//globals.SugarLogger.Debug("输出mixPayInfo1的status", mixPayInfo1.Status)
|
|
||||||
//userBill1, err := dao.GetUserBill(db, orderWay.UserID, "")
|
|
||||||
//if err != nil {
|
|
||||||
// return 0, err
|
|
||||||
//}
|
|
||||||
//globals.SugarLogger.Debug("输出userBill", userBill1.AccountBalance)
|
|
||||||
////////////////
|
|
||||||
globals.SugarLogger.Debug("回调进入微信退款")
|
globals.SugarLogger.Debug("回调进入微信退款")
|
||||||
globals.SugarLogger.Debug("orderWay==============", orderWay)
|
globals.SugarLogger.Debug("orderWay==============", orderWay)
|
||||||
globals.SugarLogger.Debug("order==============", order)
|
globals.SugarLogger.Debug("order==============", order)
|
||||||
@@ -483,6 +472,7 @@ func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.Order, order *model
|
|||||||
OldTrxID: orderPay.TransactionID,
|
OldTrxID: orderPay.TransactionID,
|
||||||
})
|
})
|
||||||
globals.SugarLogger.Debug("result===============", result)
|
globals.SugarLogger.Debug("result===============", result)
|
||||||
|
globals.SugarLogger.Debug("errerrerr===============", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
orderPayRefund = &model.OrderPayRefund{
|
orderPayRefund = &model.OrderPayRefund{
|
||||||
RefundID: refundID,
|
RefundID: refundID,
|
||||||
|
|||||||
Reference in New Issue
Block a user