From 811eaee723ad4f56deb85c18b2fbd3811473dfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 4 Jul 2023 13:49:55 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/sync_store_sku.go | 8 ++++- controllers/taobao_vegetable.go | 42 ++++++++++++-------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 5ce233747..b045953d2 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -698,7 +698,13 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag // api.JdShop2API.SetCookieWithStr(configs[0].Value) // } } - + globals.SugarLogger.Debugf("createList ==== := %s", utils.Format4Output(createList, false)) + globals.SugarLogger.Debugf("updateList ==== := %s", utils.Format4Output(updateList, false)) + globals.SugarLogger.Debugf("deleteList ==== := %s", utils.Format4Output(deleteList, false)) + globals.SugarLogger.Debugf("stockList ==== := %s", utils.Format4Output(stockList, false)) + globals.SugarLogger.Debugf("onlineList ==== := %s", utils.Format4Output(onlineList, false)) + globals.SugarLogger.Debugf("offlineList ==== := %s", utils.Format4Output(offlineList, false)) + globals.SugarLogger.Debugf("priceList ==== := %s", utils.Format4Output(priceList, false)) task := tasksch.NewParallelTask("syncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { step := batchItemList[0].(int) diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 4170e1f44..8f1be1ac5 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -89,7 +89,7 @@ func (c *TaoBaoVegetableController) OrderStatus() { } // 获取body参数 - order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request) + order, body, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request) globals.SugarLogger.Debugf("order_status ReaderOrderInfo:= %s", utils.Format4Output(order, false)) globals.SugarLogger.Debugf("order_status ReaderOrderInfo:= %s", utils.Format4Output(order, false)) if err != nil { @@ -99,16 +99,16 @@ func (c *TaoBaoVegetableController) OrderStatus() { } // 验签 - sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret()) + sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret()) if sign != values.Get("sign") { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return - } /*else { + } else { c.Data["json"] = tao_vegetable.CallBackResultSign(nil) c.ServeJSON() return - }*/ + } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order) c.Data["json"] = callbackResponse @@ -130,7 +130,7 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() { return } - afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request) + afsOrder, body, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request) globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false)) globals.SugarLogger.Debugf("ApplyCancelOrder err := %s", utils.Format4Output(err, false)) if err != nil { @@ -141,7 +141,7 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() { } // 验签 FFF779F16365992BD721C9C1A027F03C - sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) + sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret()) if sign != values.Get("sign") { // 76626F983F0F7E4A159AD64F9B13B332 c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() @@ -172,7 +172,7 @@ func (c *TaoBaoVegetableController) UserCancelRefund() { return } - afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request) + afsOrder, body, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request) globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false)) globals.SugarLogger.Debugf("UserCancelRefund err := %s", utils.Format4Output(err, false)) if err != nil { @@ -183,16 +183,16 @@ func (c *TaoBaoVegetableController) UserCancelRefund() { } // 验签 - sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) + sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret()) if sign != values.Get("sign") { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return - } /*else { + } else { c.Data["json"] = tao_vegetable.CallBackResultSign(nil) c.ServeJSON() return - }*/ + } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder) c.Data["json"] = callbackResponse @@ -214,7 +214,7 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { return } - afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request) + afsOrder, body, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request) globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false)) globals.SugarLogger.Debugf("CancelOnSaleRefundOrder err := %s", utils.Format4Output(err, false)) if err != nil { @@ -225,16 +225,16 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() { } // 验签 - sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret()) + sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret()) if sign != values.Get("sign") { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return - } /*else { + } else { c.Data["json"] = tao_vegetable.CallBackResultSign(nil) c.ServeJSON() return - }*/ + } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.PartCancelRequest.BizOrderId), afsOrder) c.Data["json"] = callbackResponse @@ -256,7 +256,7 @@ func (c *TaoBaoVegetableController) RefundOrderSuccess() { return } - refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request) + refundSuccess, body, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request) globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false)) globals.SugarLogger.Debugf("RefundOrderSuccess err := %s", utils.Format4Output(err, false)) if err != nil { @@ -266,16 +266,16 @@ func (c *TaoBaoVegetableController) RefundOrderSuccess() { return } // 验签 - sign := Sign(values, utils.Format4Output(refundSuccess, false), api.TaoVegetableApi.GetAppSecret()) + sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret()) if sign != values.Get("sign") { c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名")) c.ServeJSON() return - } /*else { + } else { c.Data["json"] = tao_vegetable.CallBackResultSign(nil) c.ServeJSON() return - }*/ + } callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutSubOrderId, refundSuccess) c.Data["json"] = callbackResponse @@ -293,10 +293,6 @@ func Sign(param url.Values, data, secret string) string { } sort.Strings(publicParam) - resultParam := strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", "") - if strings.Contains(resultParam, `\u0026`) { - resultParam = strings.ReplaceAll(resultParam, `\u0026`, "&") - } - cc := secret + strings.Join(publicParam, "") + resultParam + secret + cc := secret + strings.Join(publicParam, "") + data + secret return fmt.Sprintf("%X", md5.Sum([]byte(cc))) }