From 5dd044c57d5cd5c90659018a697d262cf1a39b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 28 Jun 2023 14:41:05 +0800 Subject: [PATCH 1/5] 1 --- controllers/taobao_vegetable.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 5020c2a9f..9dd3a6530 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -71,6 +71,10 @@ func (c *TaoBaoVegetableController) GetCode() { // OrderStatus 订单状态变化 [post] func (c *TaoBaoVegetableController) OrderStatus() { + c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) + c.ServeJSON() + return + order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request) globals.SugarLogger.Debugf("OrderStatus := %s", utils.Format4Output(order, false)) if err != nil { @@ -88,6 +92,10 @@ func (c *TaoBaoVegetableController) OrderStatus() { // ApplyCancelOrder 用户发起售后申请 func (c *TaoBaoVegetableController) ApplyCancelOrder() { + c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) + c.ServeJSON() + return + afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request) globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false)) if err != nil { @@ -104,6 +112,10 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() { // UserCancelRefund 用户取消售后 func (c *TaoBaoVegetableController) UserCancelRefund() { + c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) + c.ServeJSON() + return + afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request) globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false)) if err != nil { @@ -120,6 +132,10 @@ func (c *TaoBaoVegetableController) UserCancelRefund() { // CancelOnSaleRefundOrder 用户售中取消(走订单取消流程) func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { + c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) + c.ServeJSON() + return + afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request) globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false)) if err != nil { @@ -136,6 +152,10 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { // RefundOrderSuccess 用户售后成功通知,只有退款成功了才会通知(商户拒绝退款,不会通知) func (c *TaoBaoVegetableController) RefundOrderSuccess() { + + c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) + c.ServeJSON() + return refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request) globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false)) if err != nil { From ab1dc2056487b4505e7ef2378f750a0b36c51427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 28 Jun 2023 18:03:14 +0800 Subject: [PATCH 2/5] 1 --- .../partner/purchase/tao_vegetable/order.go | 29 +++++++-------- controllers/taobao_vegetable.go | 36 ++++++++++++++++--- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/order.go b/business/partner/purchase/tao_vegetable/order.go index c33167d42..841b150a4 100644 --- a/business/partner/purchase/tao_vegetable/order.go +++ b/business/partner/purchase/tao_vegetable/order.go @@ -305,7 +305,7 @@ func (c *PurchaseHandler) onOrderMsg(orderStatus, orderId string, orderCallback msg := orderCallback.(*tao_vegetable.CallbackOrder) if orderStatus == tao_vegetable.OrderStatusOnSaleCancel { onSale := orderCallback.(*tao_vegetable.OnSaleCancel) - msg.PublicModel = onSale.PublicModel + //msg.PublicModel = onSale.PublicModel msg.MerchantCode = onSale.MerchantCode msg.StoreId = onSale.StoreId msg.BizOrderId = onSale.BizOrderId @@ -386,7 +386,8 @@ func (c *PurchaseHandler) callbackOrderMsg2Status(msg *tao_vegetable.CallbackOrd RefVendorOrderID: orderId, RefVendorID: model.VendorIDTaoVegetable, VendorStatus: msg.OrderStatus, - StatusTime: utils.Str2TimeWithDefault(msg.Timestamp, time.Now()), + //StatusTime: utils.Str2TimeWithDefault(msg.Timestamp, time.Now()), + StatusTime: time.Now(), } switch msg.OrderStatus { @@ -420,18 +421,18 @@ func (c *PurchaseHandler) callbackOrderMsg2Status(msg *tao_vegetable.CallbackOrd func (c *PurchaseHandler) postFakeMsg(vendorOrderID, cmd, vendorStatus string) { msg := &tao_vegetable.CallbackOrder{ - PublicModel: tao_vegetable.PublicModel{ - Method: "", - AppKey: "", - Session: "", - Timestamp: utils.Time2Str(time.Now()), - V: "", - SignMethod: "", - Sign: "", - Format: "", - Simplify: false, - CustomerId: false, - }, + //PublicModel: tao_vegetable.PublicModel{ + // Method: "", + // AppKey: "", + // Session: "", + // Timestamp: utils.Time2Str(time.Now()), + // V: "", + // SignMethod: "", + // Sign: "", + // Format: "", + // Simplify: false, + // CustomerId: false, + //}, MerchantCode: "", StoreId: "", BizOrderId: utils.Str2Int64(vendorOrderID), diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 9dd3a6530..58ef695b0 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -1,6 +1,8 @@ package controllers import ( + "crypto/md5" + "fmt" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable" "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" "git.rosy.net.cn/baseapi/utils" @@ -12,6 +14,9 @@ import ( "github.com/astaxie/beego/server/web" "io/ioutil" "net/http" + "net/url" + "sort" + "strings" ) type TaoBaoVegetableController struct { @@ -69,13 +74,36 @@ func (c *TaoBaoVegetableController) GetCode() { return } +func Sign(param url.Values, data, secret string) string { + var publicParam = make([]string, 0, 0) + for k, v := range param { + if k == "sign" { + continue + } + publicParam = append(publicParam, fmt.Sprintf("%s%s", k, v[0])) + } + + sort.Strings(publicParam) + cc := secret + strings.Join(publicParam, "") + strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", "") + secret + return fmt.Sprintf("%X", md5.Sum([]byte(cc))) +} + // OrderStatus 订单状态变化 [post] func (c *TaoBaoVegetableController) OrderStatus() { - c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) - c.ServeJSON() - return - + urlParam := c.Ctx.Request.URL.RawQuery + values, err := url.ParseQuery(urlParam) order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request) + sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret()) + if sign != values.Get("sign") { // 49C8CEEDC523CA387A677D08C8861ABC + c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) + c.ServeJSON() + return + } else { + c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) + c.ServeJSON() + return + } + globals.SugarLogger.Debugf("OrderStatus := %s", utils.Format4Output(order, false)) if err != nil { globals.SugarLogger.Debugf("订单状态变化:%s", err.Error()) From bba6bf0b722fd8171aa71d9c2ef6141e409d5737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 28 Jun 2023 18:24:31 +0800 Subject: [PATCH 3/5] 1 --- .../purchase/tao_vegetable/order_afs.go | 7 +- controllers/taobao_vegetable.go | 283 +++++++++++------- 2 files changed, 177 insertions(+), 113 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/order_afs.go b/business/partner/purchase/tao_vegetable/order_afs.go index 5c7bec82b..8164a5b5f 100644 --- a/business/partner/purchase/tao_vegetable/order_afs.go +++ b/business/partner/purchase/tao_vegetable/order_afs.go @@ -15,6 +15,7 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" + "time" ) var ( @@ -196,7 +197,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(status string, msg interface{}) orderStatus.RefVendorOrderID = refundData.OutOrderId orderStatus.VendorStatus = fmt.Sprintf("%s:%s", tao_vegetable.OrderStatusApplyAfs, "用户申请取消") orderStatus.Status = c.GetAfsStatusFromVendorStatus(tao_vegetable.OrderStatusApplyAfs) - orderStatus.StatusTime = utils.Str2Time(refundData.Timestamp) + orderStatus.StatusTime = time.Now() orderStatus.Remark = refundData.Remarks orderStatus.VendorOrderID = refundData.BizRefundId case tao_vegetable.OrderStatusCancelAfs: @@ -204,7 +205,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(status string, msg interface{}) orderStatus.RefVendorOrderID = refundData.OutOrderId orderStatus.VendorStatus = fmt.Sprintf("%s:%s", tao_vegetable.OrderStatusCancelAfs, "用户取消售后申请") orderStatus.Status = c.GetAfsStatusFromVendorStatus(tao_vegetable.OrderStatusCancelAfs) - orderStatus.StatusTime = utils.Str2Time(refundData.Timestamp) + orderStatus.StatusTime = time.Now() orderStatus.VendorOrderID = refundData.BizRefundId //case tao_vegetable.OrderStatusOnSaleCancel: // refundData := msg.(*tao_vegetable.OnSaleCancel) @@ -218,7 +219,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(status string, msg interface{}) orderStatus.RefVendorOrderID = refundData.OutMainRefundId orderStatus.VendorStatus = fmt.Sprintf("%s:%s", tao_vegetable.OrderStatusRefundSuccess, "用户售后退款成功") orderStatus.Status = c.GetAfsStatusFromVendorStatus(tao_vegetable.OrderStatusRefundSuccess) - orderStatus.StatusTime = utils.Str2Time(refundData.Timestamp) + orderStatus.StatusTime = time.Now() orderStatus.VendorOrderID = refundData.BizSubRefundId } diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 58ef695b0..92dea1ef5 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -74,6 +74,179 @@ func (c *TaoBaoVegetableController) GetCode() { return } +// OrderStatus 订单状态变化 [post] +func (c *TaoBaoVegetableController) OrderStatus() { + urlParam := c.Ctx.Request.URL.RawQuery + + // 获取url参数 + values, err := url.ParseQuery(urlParam) + if err != nil { + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + // 获取body参数 + order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request) + if err != nil { + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + // 验签 + sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret()) + if sign != values.Get("sign") { + c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) + c.ServeJSON() + return + } + + callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order) + c.Data["json"] = callbackResponse + c.ServeJSON() + return +} + +// ApplyCancelOrder 用户发起售后申请 +func (c *TaoBaoVegetableController) ApplyCancelOrder() { + urlParam := c.Ctx.Request.URL.RawQuery + + // 获取url参数 + values, err := url.ParseQuery(urlParam) + if err != nil { + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request) + globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false)) + if err != nil { + globals.SugarLogger.Debugf("用户发起售后:%s", err.Error()) + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + // 验签 + sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) + if sign != values.Get("sign") { + c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) + c.ServeJSON() + return + } + + callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder) + c.Data["json"] = callbackResponse + c.ServeJSON() + return +} + +// UserCancelRefund 用户取消售后 +func (c *TaoBaoVegetableController) UserCancelRefund() { + urlParam := c.Ctx.Request.URL.RawQuery + + // 获取url参数 + values, err := url.ParseQuery(urlParam) + if err != nil { + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request) + globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false)) + if err != nil { + globals.SugarLogger.Debugf("用户取消售后:%s", err.Error()) + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + // 验签 + sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) + if sign != values.Get("sign") { + c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) + c.ServeJSON() + return + } + + callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder) + c.Data["json"] = callbackResponse + c.ServeJSON() + return +} + +// CancelOnSaleRefundOrder 用户售中取消(走订单取消流程) +func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { + urlParam := c.Ctx.Request.URL.RawQuery + + // 获取url参数 + values, err := url.ParseQuery(urlParam) + if err != nil { + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request) + globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false)) + if err != nil { + globals.SugarLogger.Debugf("用户售中取消:%s", err.Error()) + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + // 验签 + sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) + if sign != values.Get("sign") { + c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) + c.ServeJSON() + return + } + + callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.BizOrderId), afsOrder) + c.Data["json"] = callbackResponse + c.ServeJSON() + return +} + +// RefundOrderSuccess 用户售后成功通知,只有退款成功了才会通知(商户拒绝退款,不会通知) +func (c *TaoBaoVegetableController) RefundOrderSuccess() { + urlParam := c.Ctx.Request.URL.RawQuery + + // 获取url参数 + values, err := url.ParseQuery(urlParam) + if err != nil { + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + + refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request) + globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false)) + if err != nil { + globals.SugarLogger.Debugf("用户售后成功消息通知:%s", err.Error()) + c.Data["json"] = tao_vegetable.CallBackResultInfo(err) + c.ServeJSON() + return + } + // 验签 + sign := Sign(values, utils.Format4Output(refundSuccess, false), api.TaoVegetableApi.GetAppSecret()) + if sign != values.Get("sign") { + c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) + c.ServeJSON() + return + } + + callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutSubOrderId, refundSuccess) + c.Data["json"] = callbackResponse + c.ServeJSON() + return +} + func Sign(param url.Values, data, secret string) string { var publicParam = make([]string, 0, 0) for k, v := range param { @@ -87,113 +260,3 @@ func Sign(param url.Values, data, secret string) string { cc := secret + strings.Join(publicParam, "") + strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", "") + secret return fmt.Sprintf("%X", md5.Sum([]byte(cc))) } - -// OrderStatus 订单状态变化 [post] -func (c *TaoBaoVegetableController) OrderStatus() { - urlParam := c.Ctx.Request.URL.RawQuery - values, err := url.ParseQuery(urlParam) - order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request) - sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret()) - if sign != values.Get("sign") { // 49C8CEEDC523CA387A677D08C8861ABC - c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) - c.ServeJSON() - return - } else { - c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) - c.ServeJSON() - return - } - - globals.SugarLogger.Debugf("OrderStatus := %s", utils.Format4Output(order, false)) - if err != nil { - globals.SugarLogger.Debugf("订单状态变化:%s", err.Error()) - c.Data["json"] = tao_vegetable.CallBackResultInfo(err) - c.ServeJSON() - return - } - - callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order) - c.Data["json"] = callbackResponse - c.ServeJSON() - return -} - -// ApplyCancelOrder 用户发起售后申请 -func (c *TaoBaoVegetableController) ApplyCancelOrder() { - c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) - c.ServeJSON() - return - - afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request) - globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false)) - if err != nil { - globals.SugarLogger.Debugf("用户发起售后:%s", err.Error()) - c.Data["json"] = tao_vegetable.CallBackResultInfo(err) - c.ServeJSON() - return - } - callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder) - c.Data["json"] = callbackResponse - c.ServeJSON() - return -} - -// UserCancelRefund 用户取消售后 -func (c *TaoBaoVegetableController) UserCancelRefund() { - c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) - c.ServeJSON() - return - - afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request) - globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false)) - if err != nil { - globals.SugarLogger.Debugf("用户取消售后:%s", err.Error()) - c.Data["json"] = tao_vegetable.CallBackResultInfo(err) - c.ServeJSON() - return - } - callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder) - c.Data["json"] = callbackResponse - c.ServeJSON() - return -} - -// CancelOnSaleRefundOrder 用户售中取消(走订单取消流程) -func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { - c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) - c.ServeJSON() - return - - afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request) - globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false)) - if err != nil { - globals.SugarLogger.Debugf("用户售中取消:%s", err.Error()) - c.Data["json"] = tao_vegetable.CallBackResultInfo(err) - c.ServeJSON() - return - } - callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.BizOrderId), afsOrder) - c.Data["json"] = callbackResponse - c.ServeJSON() - return -} - -// RefundOrderSuccess 用户售后成功通知,只有退款成功了才会通知(商户拒绝退款,不会通知) -func (c *TaoBaoVegetableController) RefundOrderSuccess() { - - c.Data["json"] = tao_vegetable.CallBackResultInfo(nil) - c.ServeJSON() - return - refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request) - globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false)) - if err != nil { - globals.SugarLogger.Debugf("用户售后成功消息通知:%s", err.Error()) - c.Data["json"] = tao_vegetable.CallBackResultInfo(err) - c.ServeJSON() - return - } - callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutSubOrderId, refundSuccess) - c.Data["json"] = callbackResponse - c.ServeJSON() - return -} From 0adf8e5a97573bd8f1cf55c9b788029a8b17fa80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 28 Jun 2023 18:41:59 +0800 Subject: [PATCH 4/5] 1 --- controllers/taobao_vegetable.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 92dea1ef5..96e4d491e 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -100,6 +100,10 @@ func (c *TaoBaoVegetableController) OrderStatus() { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return + } else { + c.Data["json"] = tao_vegetable.CallBackResultSign(nil) + c.ServeJSON() + return } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order) @@ -135,6 +139,10 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return + } else { + c.Data["json"] = tao_vegetable.CallBackResultSign(nil) + c.ServeJSON() + return } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder) @@ -170,6 +178,10 @@ func (c *TaoBaoVegetableController) UserCancelRefund() { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return + } else { + c.Data["json"] = tao_vegetable.CallBackResultSign(nil) + c.ServeJSON() + return } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder) @@ -205,6 +217,10 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return + } else { + c.Data["json"] = tao_vegetable.CallBackResultSign(nil) + c.ServeJSON() + return } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.BizOrderId), afsOrder) @@ -239,6 +255,10 @@ func (c *TaoBaoVegetableController) RefundOrderSuccess() { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return + } else { + c.Data["json"] = tao_vegetable.CallBackResultSign(nil) + c.ServeJSON() + return } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutSubOrderId, refundSuccess) From a43780ea7974eae085911618638e06dbafa33d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 29 Jun 2023 09:18:29 +0800 Subject: [PATCH 5/5] 1 --- controllers/taobao_vegetable.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 96e4d491e..1e57e22f5 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -96,7 +96,7 @@ func (c *TaoBaoVegetableController) OrderStatus() { // 验签 sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret()) - if sign != values.Get("sign") { + if sign != values.Get("sign") && order != nil { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return @@ -135,7 +135,7 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() { // 验签 sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) - if sign != values.Get("sign") { + if sign != values.Get("sign") && afsOrder != nil { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return @@ -174,7 +174,7 @@ func (c *TaoBaoVegetableController) UserCancelRefund() { // 验签 sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) - if sign != values.Get("sign") { + if sign != values.Get("sign") && afsOrder != nil { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return @@ -213,7 +213,7 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { // 验签 sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) - if sign != values.Get("sign") { + if sign != values.Get("sign") && afsOrder != nil { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return @@ -251,7 +251,7 @@ func (c *TaoBaoVegetableController) RefundOrderSuccess() { } // 验签 sign := Sign(values, utils.Format4Output(refundSuccess, false), api.TaoVegetableApi.GetAppSecret()) - if sign != values.Get("sign") { + if sign != values.Get("sign") && refundSuccess != nil { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return