diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index 3828ef8ef..c5be696fc 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -591,7 +591,12 @@ func CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) if orderPay.Status == model.PayStatusYes { // refundID := utils.Int64ToStr(GenRefundID(order)) refundID := order.VendorOrderID - orderPayRefund, err2 := refundOrderByWX(ctx, orderPay, refundID, orderPay.TotalFee, reason) + var orderPayRefund *model.OrderPayRefund + if orderPay.PayType == model.PayTypeWX { + orderPayRefund, err = refundOrderByWX(ctx, orderPay, refundID, orderPay.TotalFee, reason) + } else if orderPay.PayType == model.PayTypeTL { + orderPayRefund, err = refundOrderByTL(ctx, orderPay, refundID, orderPay.TotalFee, reason) + } if err2 == nil { dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName()) errList.AddErr(dao.CreateEntity(dao.GetDB(), orderPayRefund)) diff --git a/business/partner/purchase/jx/localjx/tonglianpay.go b/business/partner/purchase/jx/localjx/tonglianpay.go index a4e9c81ee..d74dfdcde 100644 --- a/business/partner/purchase/jx/localjx/tonglianpay.go +++ b/business/partner/purchase/jx/localjx/tonglianpay.go @@ -15,6 +15,7 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" + "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" @@ -121,33 +122,33 @@ 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 msg.ResultCode == wxpayapi.ResponseCodeSuccess { - // orderPayRefund.Status = model.RefundStatusYes - // } else { - // orderPayRefund.Status = model.RefundStatusFailed - // } - // orderPayRefund.OriginalData = utils.Format4Output(msg, true) - // dao.UpdateEntity(db, orderPayRefund) - // } else if dao.IsNoRowsError(err) { - // globals.SugarLogger.Warnf("收到异常的退款事件, msg:%s", utils.Format4Output(msg, 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.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) + } return err }