物流笑嘻嘻
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/q_bida"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -97,7 +98,6 @@ func (p *PayHandler) CreatePay(txDB orm.TxOrmer, subAppID string) (err error) {
|
||||
// TotalFee: int(order.ActualPayPrice),
|
||||
//}
|
||||
}
|
||||
|
||||
// 暂时不支持微信直接支付
|
||||
case model.PayTypeWX:
|
||||
param := &wxpayapi.CreateOrderParam{
|
||||
@@ -257,20 +257,26 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
||||
t1, _ := time.ParseInLocation("20060102150405", call.PayTime, loc)
|
||||
order.PayFinishedAt = t1
|
||||
order.OriginalData = utils.Format4Output(call, true)
|
||||
payStatus := 0
|
||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||
order.Status = model.OrderStatusFinished
|
||||
payStatus = model.OrderStatusSuccessPay
|
||||
} else {
|
||||
order.Status = model.OrderStatusCanceled
|
||||
payStatus = model.OrderStatusFailPay
|
||||
}
|
||||
|
||||
if _, err := dao.UpdateEntity(db, order); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := dao.UpdateEntity(db, &model.UserVendorOrder{LocalWayBill: order.OrderID, OrderStatus: payStatus}, "OrderStatus"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||
switch order.OrderType {
|
||||
case model.PayType4Express:
|
||||
|
||||
err = q_bida.CreateOrder2QBiDa(order.OrderID)
|
||||
case model.PayType4Member, model.PayType4Recharge:
|
||||
err = OnPayFinished(order)
|
||||
}
|
||||
@@ -282,70 +288,34 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
||||
}
|
||||
|
||||
func onTLpayRefund(call *tonglianpayapi.CallBackResult) (err error) {
|
||||
// orderPayRefund := &model.OrderPayRefund{
|
||||
// RefundID: call.CusorderID,
|
||||
// }
|
||||
// db := dao.GetDB()
|
||||
// if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
||||
// if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||
// orderPayRefund.Status = model.RefundStatusYes
|
||||
// } else {
|
||||
// orderPayRefund.Status = model.RefundStatusFailed
|
||||
// }
|
||||
// orderPayRefund.OriginalData = utils.Format4Output(call, true)
|
||||
// dao.UpdateEntity(db, orderPayRefund)
|
||||
// } else if dao.IsNoRowsError(err) {
|
||||
// globals.SugarLogger.Warnf("收到异常的退款事件, call:%s", utils.Format4Output(call, true))
|
||||
// }
|
||||
orderPayRefund := &model.OrderPayRefund{
|
||||
RefundID: call.CusorderID,
|
||||
}
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||
orderPayRefund.Status = model.RefundStatusYes
|
||||
} else {
|
||||
orderPayRefund.Status = model.RefundStatusFailed
|
||||
}
|
||||
orderPayRefund.OriginalData = utils.Format4Output(call, true)
|
||||
dao.UpdateEntity(db, orderPayRefund)
|
||||
} else if dao.IsNoRowsError(err) {
|
||||
globals.SugarLogger.Warnf("收到异常的退款事件, call:%s", utils.Format4Output(call, true))
|
||||
}
|
||||
|
||||
// orderPay := &model.OrderPay{
|
||||
// VendorOrderID: orderPayRefund.VendorOrderID,
|
||||
// VendorID: jxutils.GetPossibleVendorIDFromVendorOrderID(orderPayRefund.VendorOrderID),
|
||||
// PayType: model.PayTypeWX,
|
||||
// Status: model.PayStatusYes,
|
||||
// }
|
||||
// orderPay.DeletedAt = utils.DefaultTimeValue
|
||||
// if err = dao.GetEntity(db, orderPay, "VendorOrderID", "VendorID", "PayType", "Status", "DeletedAt"); err == nil {
|
||||
// orderPay.Status = model.PayStatusRefund
|
||||
// dao.UpdateEntity(db, orderPay)
|
||||
// }
|
||||
orderPay := &model.Order{
|
||||
OrderID: orderPayRefund.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, orderPay, "VendorOrderID"); err == nil {
|
||||
orderPay.Status = model.OrderStatusCancel
|
||||
dao.UpdateEntity(db, orderPay)
|
||||
}
|
||||
|
||||
dao.UpdateEntity(db, &model.UserVendorOrder{LocalWayBill: call.CusorderID, OrderStatus: model.OrderStatusCancel}, "OrderStatus")
|
||||
return err
|
||||
}
|
||||
|
||||
// func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
||||
// result, err := api.TLpayAPI.PayRefund(&tonglianpayapi.PayRefundParam{
|
||||
// Trxamt: refundFee,
|
||||
// Reqsn: utils.GetUUID(),
|
||||
// Remark: refundDesc,
|
||||
// OldTrxID: orderPay.TransactionID,
|
||||
// })
|
||||
// if err == nil {
|
||||
// orderPayRefund = &model.OrderPayRefund{
|
||||
// RefundID: refundID,
|
||||
// VendorRefundID: result.TrxID,
|
||||
// VendorOrderID: orderPay.VendorOrderID,
|
||||
// VendorID: orderPay.VendorID,
|
||||
// Status: model.RefundStatusNo,
|
||||
// TransactionID: orderPay.TransactionID,
|
||||
// RefundFee: refundFee,
|
||||
// RefundCreatedAt: time.Now(),
|
||||
// }
|
||||
// dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
||||
// db := dao.GetDB()
|
||||
// if result.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||
// orderPayRefund.Status = model.RefundStatusYes
|
||||
// } else {
|
||||
// orderPayRefund.Status = model.RefundStatusFailed
|
||||
// }
|
||||
// orderPayRefund.OriginalData = utils.Format4Output(result, true)
|
||||
// dao.CreateEntity(db, orderPayRefund)
|
||||
|
||||
// orderPay.Status = model.PayStatusRefund
|
||||
// dao.UpdateEntity(db, orderPay)
|
||||
// }
|
||||
// return orderPayRefund, err
|
||||
// }
|
||||
|
||||
func OnWxPayCallback(msg *wxpayapi.CallbackMsg) (err error) {
|
||||
globals.SugarLogger.Debugf("OnWxPayCallback msg:%s", utils.Format4Output(msg, true))
|
||||
switch msg.MsgType {
|
||||
|
||||
Reference in New Issue
Block a user