add pay
This commit is contained in:
@@ -6,12 +6,14 @@ import (
|
||||
bida "git.rosy.net.cn/baseapi/platformapi/q_bida"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -203,6 +205,7 @@ func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrd
|
||||
SuccessCode = 0
|
||||
tmp_orderNo = param.OrderNo
|
||||
db = dao.GetDB()
|
||||
txDB orm.TxOrmer
|
||||
)
|
||||
// 查询订单
|
||||
order, err := dao.GetUserVendorOrder(db, userId, param.OrderNo)
|
||||
@@ -248,17 +251,45 @@ func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrd
|
||||
if err != nil {
|
||||
return FailCode, err
|
||||
}
|
||||
if orderWay.PayMethod == 1 && orderWay.Status == 110 { // 余额支付且已支付
|
||||
// 支付方式为余额支付,则需要修改order/userVendorOrder,修改订单状态,给用户账户价钱,生成一个价钱数据
|
||||
} else if orderWay.PayMethod == 2 && orderWay.Status == 110 { // 微信支付且已支付
|
||||
// 微信支付原路退款,发起退款申请
|
||||
res, err := RefundOrderByTL(ctx, orderWay, order, order.OtherWayBill, int(order.ChannelFee*100), "申请退款")
|
||||
if len(res.VendorRefundID) > 0 {
|
||||
return SuccessCode, err
|
||||
} else {
|
||||
return FailCode, err
|
||||
if orderWay.Status == 110 {
|
||||
if orderWay.PayMethod == 1 { // 余额支付
|
||||
if err := financial.AddBillIncome(txDB, 0, model.BillTypePayByMixPay1, orderWay.PayPrice, 0); err != nil {
|
||||
return FailCode, err
|
||||
}
|
||||
order.OrderStatus = model.OrderStatusCancel
|
||||
if _, err := dao.UpdateEntityTx(txDB, order, "OrderStatus"); err != nil {
|
||||
return FailCode, err
|
||||
}
|
||||
// 支付方式为余额支付,则需要修改order/userVendorOrder,修改订单状态,给用户账户价钱,生成一个价钱数据
|
||||
} else if orderWay.PayMethod == 2 { // 微信支付
|
||||
// 微信支付原路退款,发起退款申请
|
||||
res, err := RefundOrderByTL(ctx, orderWay, order, order.OtherWayBill, int(order.ChannelFee*100), "申请退款")
|
||||
if len(res.VendorRefundID) > 0 {
|
||||
return SuccessCode, err
|
||||
} else {
|
||||
return FailCode, err
|
||||
}
|
||||
}
|
||||
if orderWay.PayMethod == 5 { //混合支付
|
||||
//余额增加相应金额
|
||||
mixPayInfo, err := dao.GetMixPayDetail(orderWay.OrderID)
|
||||
if err := financial.AddBillIncome(txDB, 0, model.BillTypePayByMixPay1, mixPayInfo[0].BalancePrice, 0); err != nil {
|
||||
return FailCode, err
|
||||
}
|
||||
//更新mixPay 状态
|
||||
mixPayInfo[0].Status = model.BillMixPayRefund1 //退款状态
|
||||
if _, err := dao.UpdateEntityTx(txDB, &mixPayInfo, "Status"); err != nil {
|
||||
return FailCode, err
|
||||
}
|
||||
res, err := RefundOrderByTL(ctx, orderWay, order, order.OtherWayBill, int(order.ChannelFee*100), "申请退款")
|
||||
if len(res.VendorRefundID) > 0 {
|
||||
return SuccessCode, err
|
||||
} else {
|
||||
return FailCode, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return SuccessCode, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user