From 919368f70ecafeb773fa36d136dd366aa7240205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 15 May 2023 09:31:33 +0800 Subject: [PATCH 01/16] 1 --- platformapi/dadaapi/order.go | 2 ++ platformapi/fnpsapi/order.go | 6 ++++-- platformapi/mtpsapi/mtpsapi.go | 2 ++ platformapi/mtwmapi/mtwmapi_test.go | 4 ++-- platformapi/mtwmapi/retail_test.go | 4 ++-- platformapi/tiktok_shop/tiktok_api/afs_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/delete_test.go | 6 ++++++ platformapi/tiktok_shop/tiktok_api/sku_test.go | 2 +- platformapi/uuptapi/waybill.go | 1 + utils/typeconv.go | 5 +++-- 10 files changed, 24 insertions(+), 10 deletions(-) diff --git a/platformapi/dadaapi/order.go b/platformapi/dadaapi/order.go index 62acbb30..ead6b35f 100644 --- a/platformapi/dadaapi/order.go +++ b/platformapi/dadaapi/order.go @@ -136,6 +136,8 @@ func (a *API) QueryOrderInfo(orderID string) (order *OrderInfo, err error) { if err == nil { err = utils.Map2StructByJson(result.Result, &order, false) } + order.DeductFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) + order.ActualFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) return order, err } diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index d0c92686..3b5ee76d 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -60,8 +60,8 @@ func (a *API) PreCreateByShopFn(basicParams *PreCreateOrder) (deliveryFee, baseD if v.IsValid != 1 { continue } - deliveryFeeFn = v.ActualDeliveryAmountCent - baseDeliveryFeeFn = v.TotalDeliveryAmountCent + deliveryFeeFn = v.ActualDeliveryAmountCent // 优惠后 + baseDeliveryFeeFn = v.TotalDeliveryAmountCent // 原始配送费 } // 异常检测 @@ -206,6 +206,8 @@ func (a *API) QueryOrder(partnerOrderCode string) (result *GetOrderDetailRes, er if err := json.Unmarshal([]byte(data["business_data"].(string)), &fnResult); err != nil { return nil, err } + fnResult.OrderActualAmountCent += int64(utils.WayBillDeliveryMarkUp) + fnResult.OrderTotalAmountCent += int64(utils.WayBillDeliveryMarkUp) return fnResult, nil } diff --git a/platformapi/mtpsapi/mtpsapi.go b/platformapi/mtpsapi/mtpsapi.go index 4305d884..267f0e90 100644 --- a/platformapi/mtpsapi/mtpsapi.go +++ b/platformapi/mtpsapi/mtpsapi.go @@ -346,6 +346,8 @@ func (a *API) QueryOrderStatus(deliveryId int64, mtPeiSongId string) (retVal map if err != nil { return nil, err } + result.Data["delivery_fee"] = utils.MustInterface2Float64(result.Data["delivery_fee"]) + utils.MustInterface2Float64(utils.WayBillDeliveryMarkUp) + result.Data["pay_amount"] = utils.MustInterface2Float64(result.Data["pay_amount"]) + utils.MustInterface2Float64(utils.WayBillDeliveryMarkUp) return result.Data, nil } diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index baa13a44..a7a727d0 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -24,10 +24,10 @@ func init() { // 果园 // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") - api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") + //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nFTOat5DYhvqHIZbDZRJkQ") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index f82b6f48..8d53b70a 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -120,10 +120,10 @@ func TestRetailListAll(t *testing.T) { // 删除所有门店商品 func TestReloadStoreSku(t *testing.T) { - result, err := api.RetailListAll("17817296") + result, err := api.RetailListAll("17223201") if err == nil { for i := 0; i < len(result); i++ { - err := api.RetailDelete(utils.Int64ToStr(time.Now().Unix()), "17817296", result[i].AppFoodCode) + err := api.RetailDelete(utils.Int64ToStr(time.Now().Unix()), "17223201", result[i].AppFoodCode) if err != nil { fmt.Println(err) } diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index fb0d6331..a5271778 100644 --- a/platformapi/tiktok_shop/tiktok_api/afs_test.go +++ b/platformapi/tiktok_shop/tiktok_api/afs_test.go @@ -18,7 +18,7 @@ import ( // "authority_id": "" //}` -var token = `{"access_token":"71896365-cec7-4982-a686-0d8f3044cc1e","expires_in":1682872676,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"76d410d2-e869-4ddc-b8ad-0ae652114e13","authority_id":""}` +var token = `{"access_token":"09e5b626-418f-4780-ab33-857ba8f69b49","expires_in":1684077242,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"04a82701-a439-4dad-a20a-48299b0dffcd","authority_id":""}` //var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}` diff --git a/platformapi/tiktok_shop/tiktok_api/delete_test.go b/platformapi/tiktok_shop/tiktok_api/delete_test.go index 39ca56dd..207710a6 100644 --- a/platformapi/tiktok_shop/tiktok_api/delete_test.go +++ b/platformapi/tiktok_shop/tiktok_api/delete_test.go @@ -30,3 +30,9 @@ func tryCatName2Code(originName string) (catCodeStr string) { } return catCodeStr } + +func TestCa(t *testing.T) { + name := "四川省" + fmt.Println(len(name)) + fmt.Println(name[0:6]) +} diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index c3dcfd40..3d931aad 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -303,7 +303,7 @@ func TestDeleteSkuAndUploadSkuXiaJiaBiXu(t *testing.T) { CheckStatus: 1, // 1-未提交;2-待审核;3-审核通过;4-审核未通过;5-封禁;7-审核通过待上架 Page: int64(i), Size: 100, - StoreId: v, + StoreId: 63509510, }) if err != nil { globals.SugarLogger.Debugf("=index := %d ,err := %s", i, utils.Format4Output(err, false)) diff --git a/platformapi/uuptapi/waybill.go b/platformapi/uuptapi/waybill.go index 60a1c7e7..9db2873d 100644 --- a/platformapi/uuptapi/waybill.go +++ b/platformapi/uuptapi/waybill.go @@ -67,6 +67,7 @@ func (a *API) GetOrderDetail(orderCode string) (*GetOrderDetailResp, error) { } con := retVal != GetOrderDetailResp{} if con { + retVal.OrderPrice = utils.Float64ToStr(utils.Str2Float64(retVal.OrderPrice) + float64(utils.WayBillDeliveryMarkUp/100)) return &retVal, nil } else { return nil, fmt.Errorf("UU跑腿未返回运单详情") diff --git a/utils/typeconv.go b/utils/typeconv.go index 66da9b30..32e42cfd 100644 --- a/utils/typeconv.go +++ b/utils/typeconv.go @@ -23,8 +23,9 @@ var json1 = jsoniter.ConfigCompatibleWithStandardLibrary const MaxTimeSecond = 9573800254 // 正常最大的秒数 var ( - DefaultTimeValue = Str2Time("1970-01-01 00:00:00") - ZeroTimeValue = time.Time{} + DefaultTimeValue = Str2Time("1970-01-01 00:00:00") + WayBillDeliveryMarkUp = 20 // 运单加价两毛钱 + ZeroTimeValue = time.Time{} ) func UnmarshalUseNumber(data []byte, result interface{}) error { From 538a942595b55e1ff82dbacb03871c92588d7238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 15 May 2023 18:30:38 +0800 Subject: [PATCH 02/16] 1 --- platformapi/dadaapi/order_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/dadaapi/order_test.go b/platformapi/dadaapi/order_test.go index d3fef193..bcab2cbe 100644 --- a/platformapi/dadaapi/order_test.go +++ b/platformapi/dadaapi/order_test.go @@ -68,7 +68,7 @@ import ( // func TestQueryOrderInfo(t *testing.T) { dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true) - result, err := dadaapi.QueryOrderInfo("1100538083115517396") + result, err := dadaapi.QueryOrderInfo("88421859678001") if err != nil { t.Fatal(err) } From 2d798aab8977f7096146d09ef9f697a355b3d9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 16 May 2023 14:52:15 +0800 Subject: [PATCH 03/16] 1 --- platformapi/uuptapi/waybill.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/uuptapi/waybill.go b/platformapi/uuptapi/waybill.go index 9db2873d..0e10fc3e 100644 --- a/platformapi/uuptapi/waybill.go +++ b/platformapi/uuptapi/waybill.go @@ -67,7 +67,7 @@ func (a *API) GetOrderDetail(orderCode string) (*GetOrderDetailResp, error) { } con := retVal != GetOrderDetailResp{} if con { - retVal.OrderPrice = utils.Float64ToStr(utils.Str2Float64(retVal.OrderPrice) + float64(utils.WayBillDeliveryMarkUp/100)) + retVal.OrderPrice = utils.Float64ToStr(utils.Str2Float64(retVal.OrderPrice) + float64(utils.WayBillDeliveryMarkUp/100) + float64(0.2)) return &retVal, nil } else { return nil, fmt.Errorf("UU跑腿未返回运单详情") From 60274cc5e6b0fe451f4804bac5e2735eea7e8363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 18 May 2023 09:02:34 +0800 Subject: [PATCH 04/16] 1 --- platformapi/dadaapi/order.go | 4 ++-- platformapi/dadaapi/order_test.go | 14 ++++++-------- platformapi/fnpsapi/order.go | 2 +- platformapi/mtpsapi/mtpsapi.go | 9 +++++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/platformapi/dadaapi/order.go b/platformapi/dadaapi/order.go index ead6b35f..00d432d1 100644 --- a/platformapi/dadaapi/order.go +++ b/platformapi/dadaapi/order.go @@ -136,8 +136,8 @@ func (a *API) QueryOrderInfo(orderID string) (order *OrderInfo, err error) { if err == nil { err = utils.Map2StructByJson(result.Result, &order, false) } - order.DeductFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) - order.ActualFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) + order.DeliveryFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) + //order.ActualFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) return order, err } diff --git a/platformapi/dadaapi/order_test.go b/platformapi/dadaapi/order_test.go index bcab2cbe..7b841a94 100644 --- a/platformapi/dadaapi/order_test.go +++ b/platformapi/dadaapi/order_test.go @@ -2,9 +2,9 @@ package dadaapi // import ( + "fmt" //"fmt" "testing" - //"git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/utils" ) @@ -75,10 +75,8 @@ func TestQueryOrderInfo(t *testing.T) { t.Log(utils.Format4Output(result, false)) } -// -//func TestAddTip(t *testing.T) { -// err := dadaapi.AddTip("80704840263399812", 1.0, "530100", "") -// if err != nil { -// t.Fatal(err) -// } -//} +func TestAddTip(t *testing.T) { + payload := map[string]interface{}{"categoryID": 3095} + fmt.Println(payload["img"] != nil) + fmt.Println(payload["img"] != "") +} diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index 3b5ee76d..4c560736 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -60,7 +60,7 @@ func (a *API) PreCreateByShopFn(basicParams *PreCreateOrder) (deliveryFee, baseD if v.IsValid != 1 { continue } - deliveryFeeFn = v.ActualDeliveryAmountCent // 优惠后 + deliveryFeeFn = v.TotalDeliveryAmountCent // 优惠后 actual_delivery_amount_cent baseDeliveryFeeFn = v.TotalDeliveryAmountCent // 原始配送费 } diff --git a/platformapi/mtpsapi/mtpsapi.go b/platformapi/mtpsapi/mtpsapi.go index 267f0e90..cc2303ae 100644 --- a/platformapi/mtpsapi/mtpsapi.go +++ b/platformapi/mtpsapi/mtpsapi.go @@ -295,7 +295,7 @@ func (a *API) result2OrderResponse(result *ResponseResult) (order *OrderResponse order.MtPeisongID = result.Data["mt_peisong_id"].(string) order.DeliveryID = utils.MustInterface2Int64(result.Data["delivery_id"]) order.OrderID = result.Data["order_id"].(string) - order.DeliveryFee = utils.MustInterface2Float64(result.Data["delivery_fee"]) + order.DeliveryFee = utils.MustInterface2Float64(result.Data["delivery_fee"]) // 原价 return order } @@ -347,7 +347,7 @@ func (a *API) QueryOrderStatus(deliveryId int64, mtPeiSongId string) (retVal map return nil, err } result.Data["delivery_fee"] = utils.MustInterface2Float64(result.Data["delivery_fee"]) + utils.MustInterface2Float64(utils.WayBillDeliveryMarkUp) - result.Data["pay_amount"] = utils.MustInterface2Float64(result.Data["pay_amount"]) + utils.MustInterface2Float64(utils.WayBillDeliveryMarkUp) + result.Data["pay_amount"] = utils.MustInterface2Float64(result.Data["pay_amount"]) return result.Data, nil } @@ -467,8 +467,9 @@ func (a *API) PreCreateByShop(basicParams *PreCreateByShopParam) (deliveryFee, b return 0, 0, err } - deliveryFee = utils.Float64TwoInt64(utils.MustInterface2Float64(result.Data["delivery_fee"]) * 100) // 订单配送价格 - baseDeliveryFee = utils.Float64TwoInt64(utils.MustInterface2Float64(result.Data["base_delivery_fee"]) * 100) // 订单优惠价格 + deliveryFee = utils.Float64TwoInt64(utils.MustInterface2Float64(result.Data["delivery_fee"]) * 100) // 订单配送价格 + baseDeliveryFee = utils.Float64TwoInt64(utils.MustInterface2Float64(result.Data["delivery_fee"]) * 100) // 订单优惠价格 + //baseDeliveryFee = utils.Float64TwoInt64(utils.MustInterface2Float64(result.Data["base_delivery_fee"]) * 100) // 订单优惠价格 return deliveryFee, baseDeliveryFee, nil } From 8aae51b1ec8874f02c3afe35a184dc1d4ca41a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 18 May 2023 09:47:43 +0800 Subject: [PATCH 05/16] 1' --- platformapi/dadaapi/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/dadaapi/order.go b/platformapi/dadaapi/order.go index 00d432d1..680f0fbf 100644 --- a/platformapi/dadaapi/order.go +++ b/platformapi/dadaapi/order.go @@ -136,7 +136,7 @@ func (a *API) QueryOrderInfo(orderID string) (order *OrderInfo, err error) { if err == nil { err = utils.Map2StructByJson(result.Result, &order, false) } - order.DeliveryFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) + order.DeliveryFee += (utils.Int2Float64(utils.WayBillDeliveryMarkUp) / 100) //order.ActualFee += utils.Int2Float64(utils.WayBillDeliveryMarkUp) return order, err } From f48bd1996a35b6c765c7ceecdd925db630415f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 18 May 2023 11:34:45 +0800 Subject: [PATCH 06/16] 1 --- platformapi/fnpsapi/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index 4c560736..0ff45c85 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -84,7 +84,7 @@ func (a *API) CreateOrder(createOrderParam *CreateOrderReqParam) (result string, return "", err } if utils.Interface2String(resultData["code"]) != "200" || utils.Interface2String(resultData["apiCode"]) != "" { - return "", fmt.Errorf(fmt.Sprintf("其他异常错误信息:%s", utils.Interface2String(resultData["apiCode"]))) + return "", fmt.Errorf(fmt.Sprintf("其他异常错误信息:%s,%s", utils.Interface2String(resultData["apiCode"]), utils.Interface2StringList("msg"))) } if orderId, ok := resultData["business_data"]; ok { res := &CreateOrderRes{} From 0cc54463988ebbe8a5303452401c4bef9408c829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 18 May 2023 11:40:08 +0800 Subject: [PATCH 07/16] 1 --- platformapi/fnpsapi/order.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index 0ff45c85..fbd8f63e 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" "time" ) @@ -83,8 +84,10 @@ func (a *API) CreateOrder(createOrderParam *CreateOrderReqParam) (result string, if err != nil { return "", err } + + globals.SugarLogger.Debugf("CreateOrder =======resultData := %s", utils.Format4Output(resultData, false)) if utils.Interface2String(resultData["code"]) != "200" || utils.Interface2String(resultData["apiCode"]) != "" { - return "", fmt.Errorf(fmt.Sprintf("其他异常错误信息:%s,%s", utils.Interface2String(resultData["apiCode"]), utils.Interface2StringList("msg"))) + return "", fmt.Errorf(fmt.Sprintf("其他异常错误信息:%s", utils.Interface2String(resultData["apiCode"]))) } if orderId, ok := resultData["business_data"]; ok { res := &CreateOrderRes{} From aaaecabb9a08548e25e6eae5d7b9c6751fce20a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 18 May 2023 11:44:36 +0800 Subject: [PATCH 08/16] 1 --- platformapi/fnpsapi/order.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index fbd8f63e..06ddc21c 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" "time" ) @@ -85,8 +84,7 @@ func (a *API) CreateOrder(createOrderParam *CreateOrderReqParam) (result string, return "", err } - globals.SugarLogger.Debugf("CreateOrder =======resultData := %s", utils.Format4Output(resultData, false)) - if utils.Interface2String(resultData["code"]) != "200" || utils.Interface2String(resultData["apiCode"]) != "" { + if utils.Interface2String(resultData["code"]) != "200" { return "", fmt.Errorf(fmt.Sprintf("其他异常错误信息:%s", utils.Interface2String(resultData["apiCode"]))) } if orderId, ok := resultData["business_data"]; ok { From 2633288508123a27342d6066655be8f008c88019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 18 May 2023 17:33:23 +0800 Subject: [PATCH 09/16] 1 --- platformapi/fnpsapi/fn_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platformapi/fnpsapi/fn_test.go b/platformapi/fnpsapi/fn_test.go index 60300a5f..a9c0b00c 100644 --- a/platformapi/fnpsapi/fn_test.go +++ b/platformapi/fnpsapi/fn_test.go @@ -20,9 +20,9 @@ func init() { sugarLogger = logger.Sugar() baseapi.Init(sugarLogger) - api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "cabrXQf9eFMVWVYg4hNlwu") + api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "") //token, _ := api.GetAccessToken() - api.accessToken = "5638ebf7-e69e-498b-8b47-96336ca720bc" + api.accessToken = "c7ed10b7-3ecf-4def-adc1-9f43d5e9480c" } // 查询单个门店 @@ -180,7 +180,9 @@ func TestGetOrder(t *testing.T) { } func TestQueryOrder(t *testing.T) { - data, err := api.QueryOrder("1100536591119839487") // 1100537991119839487 1100536591119839487 + api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "") + api.accessToken = "c7ed10b7-3ecf-4def-adc1-9f43d5e9480c" + data, err := api.QueryOrder("88421859678001") // 1100537991119839487 1100536591119839487 globals.SugarLogger.Debug("data:= %s", utils.Format4Output(data, false)) globals.SugarLogger.Debug("err:= %s", utils.Format4Output(err, false)) } From d055493539320ec19eb2edb032c76543a0b9de9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 19 May 2023 10:54:56 +0800 Subject: [PATCH 10/16] 1 --- platformapi/fnpsapi/fn_test.go | 7 ------- platformapi/mtpsapi/mtpsapi.go | 4 +++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/platformapi/fnpsapi/fn_test.go b/platformapi/fnpsapi/fn_test.go index a9c0b00c..3ef845bc 100644 --- a/platformapi/fnpsapi/fn_test.go +++ b/platformapi/fnpsapi/fn_test.go @@ -7,7 +7,6 @@ import ( "git.rosy.net.cn/jx-callback/globals" "go.uber.org/zap" "testing" - "time" ) var ( @@ -186,9 +185,3 @@ func TestQueryOrder(t *testing.T) { globals.SugarLogger.Debug("data:= %s", utils.Format4Output(data, false)) globals.SugarLogger.Debug("err:= %s", utils.Format4Output(err, false)) } - -func TestTime(t *testing.T) { - fmt.Println(time.Now().UnixNano() / 1e6) - fmt.Println(1683530814777) - fmt.Println(time.Now().UnixNano()/1e6 - 1683530814777) -} diff --git a/platformapi/mtpsapi/mtpsapi.go b/platformapi/mtpsapi/mtpsapi.go index cc2303ae..b4f5b73c 100644 --- a/platformapi/mtpsapi/mtpsapi.go +++ b/platformapi/mtpsapi/mtpsapi.go @@ -5,6 +5,7 @@ import ( "fmt" "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" "net/http" "net/url" "sort" @@ -346,7 +347,8 @@ func (a *API) QueryOrderStatus(deliveryId int64, mtPeiSongId string) (retVal map if err != nil { return nil, err } - result.Data["delivery_fee"] = utils.MustInterface2Float64(result.Data["delivery_fee"]) + utils.MustInterface2Float64(utils.WayBillDeliveryMarkUp) + globals.SugarLogger.Debugf("QueryOrderStatus===========: %s", utils.Format4Output(result, false)) + result.Data["delivery_fee"] = utils.MustInterface2Float64(result.Data["delivery_fee"]) + (float64(utils.WayBillDeliveryMarkUp) / 100) result.Data["pay_amount"] = utils.MustInterface2Float64(result.Data["pay_amount"]) return result.Data, nil } From b0fa7ef79d1a295abba478b6e8d8408e3d006912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 19 May 2023 11:13:22 +0800 Subject: [PATCH 11/16] 1 --- platformapi/fnpsapi/order.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index 06ddc21c..0dbce9d8 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -171,9 +171,7 @@ func (a *API) CancelOrder(req *CancelOrderReq) (err error) { if req.PartnerOrderCode == "" && req.OrderId == "" { return errors.New("内部订单号或者外部订单号比填写一个") } - if req.OrderCancelCode == 0 && req.OrderCancelOtherReason == "" { - req.OrderCancelOtherReason = "暂时不想要了" - } + req.OrderCancelOtherReason = "暂时不想要了" orderHead := a.MakeFnRequestHead() business, err := json.Marshal(req) From d59f2895145be59c36c2d25d6a5f17a285250752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 19 May 2023 11:43:02 +0800 Subject: [PATCH 12/16] 1 --- platformapi/mtpsapi/mtpsapi.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/platformapi/mtpsapi/mtpsapi.go b/platformapi/mtpsapi/mtpsapi.go index b4f5b73c..48a598fb 100644 --- a/platformapi/mtpsapi/mtpsapi.go +++ b/platformapi/mtpsapi/mtpsapi.go @@ -5,7 +5,6 @@ import ( "fmt" "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" "net/http" "net/url" "sort" @@ -347,7 +346,6 @@ func (a *API) QueryOrderStatus(deliveryId int64, mtPeiSongId string) (retVal map if err != nil { return nil, err } - globals.SugarLogger.Debugf("QueryOrderStatus===========: %s", utils.Format4Output(result, false)) result.Data["delivery_fee"] = utils.MustInterface2Float64(result.Data["delivery_fee"]) + (float64(utils.WayBillDeliveryMarkUp) / 100) result.Data["pay_amount"] = utils.MustInterface2Float64(result.Data["pay_amount"]) return result.Data, nil From d6ea1e8bd7c9c8f31f9d0624c5ed7f7ca9deeec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 19 May 2023 14:15:07 +0800 Subject: [PATCH 13/16] 1 --- platformapi/fnpsapi/callback.go | 11 +++++----- platformapi/fnpsapi/fn_test.go | 8 +++---- platformapi/fnpsapi/store.go | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/platformapi/fnpsapi/callback.go b/platformapi/fnpsapi/callback.go index b596c06a..77a79456 100644 --- a/platformapi/fnpsapi/callback.go +++ b/platformapi/fnpsapi/callback.go @@ -138,25 +138,24 @@ func (a *API) GetChainstoreStatusNotify(request *http.Request) (shopStatusMsg *C } // 获取订单状态回调消息 -func (a *API) GetChainOrderStatusNotify(request *http.Request) (shopStatusMsg *OrderStatusNottify, callbackResponse *CallbackResponse) { +func (a *API) GetChainOrderStatusNotify(request *http.Request) (shopStatusMsg *OrderStatusNottify, result *ShortStatus, callbackResponse *CallbackResponse) { data, err := ioutil.ReadAll(request.Body) if err != nil { callbackResponse = &CallbackResponse{Code: -1} - return nil, callbackResponse + return nil, nil, callbackResponse } - result := &ShortStatus{} if err := json.Unmarshal(data, &result); err != nil { callbackResponse = &CallbackResponse{Code: -1} - return nil, callbackResponse + return nil, nil, callbackResponse } orderResult := &OrderStatusNottify{} if err := json.Unmarshal([]byte(result.BusinessData), orderResult); err != nil { callbackResponse = &CallbackResponse{Code: -1} - return nil, callbackResponse + return nil, nil, callbackResponse } - return orderResult, SuccessResponse + return orderResult, result, SuccessResponse } // 异常配送 diff --git a/platformapi/fnpsapi/fn_test.go b/platformapi/fnpsapi/fn_test.go index 3ef845bc..66251c84 100644 --- a/platformapi/fnpsapi/fn_test.go +++ b/platformapi/fnpsapi/fn_test.go @@ -26,10 +26,10 @@ func init() { // 查询单个门店 func TestQueryOneStore(t *testing.T) { - api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "5375691", "") - token, err := api.GetAccessToken() - api.accessToken = token.BusinessDataObj.AccessToken - data, err := api.GetStore("209476483") + api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "") + //token, err := api.GetAccessToken() + api.accessToken = "45c49b75-d47e-4145-b38d-fda8b5ebf3a9" + data, err := api.GetStore("800293") fmt.Println(data) fmt.Println(err) } diff --git a/platformapi/fnpsapi/store.go b/platformapi/fnpsapi/store.go index dd07f4f3..0d4b9122 100644 --- a/platformapi/fnpsapi/store.go +++ b/platformapi/fnpsapi/store.go @@ -3,6 +3,7 @@ package fnpsapi import ( "encoding/json" "fmt" + "net/http" "strings" "git.rosy.net.cn/baseapi/utils" @@ -130,3 +131,40 @@ func IsErrShopExist(err error) bool { } return false } + +// HttpToGuoYuanFN 订单消息推送果园 +func HttpToGuoYuanFN(param map[string]interface{}, requestType string) (*http.Response, error) { + var paramData []byte + var err error + if requestType == "order" || requestType == "waybill" { + param["data"] = utils.Format4Output(param["data"], false) + paramData, err = json.Marshal([]interface{}{param}) + if err != nil { + return nil, err + } + } else { + paramData, err = json.Marshal(param) + if err != nil { + return nil, err + } + } + body := strings.NewReader(string(paramData)) + url := "" + switch requestType { + case "store": // 订单相关 + url = "http://callback-jxgy.jxc4.com/fn/fnStore" + case "order": // 门店 + url = "http://callback-jxgy.jxc4.com/fn/fnOrder" + case "abnormal": // 异常 + url = "http://callback-jxgy.jxc4.com/fn/fnAbnormal" + } + httpReq, err := http.NewRequest(http.MethodPost, url, body) + if err != nil { + return nil, err + } + + httpReq.Header.Set("Content-Type", "application/json") + + httpRes, err := http.DefaultClient.Do(httpReq) + return httpRes, err +} From 0c024e20e09d646343016f34b9647ce02049ec96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 19 May 2023 17:21:17 +0800 Subject: [PATCH 14/16] 1 --- platformapi/dadaapi/dadaapi_test.go | 58 +++++++++++--------- platformapi/dadaapi/order_test.go | 20 +++---- platformapi/kuaishou_mini/kuaishou_model.go | 28 +++++----- platformapi/kuaishou_mini/kuaishou_test.go | 28 +++++----- platformapi/tonglianpayapi/tonglianpayapi.go | 3 + 5 files changed, 71 insertions(+), 66 deletions(-) diff --git a/platformapi/dadaapi/dadaapi_test.go b/platformapi/dadaapi/dadaapi_test.go index b1d34bc1..2999d900 100644 --- a/platformapi/dadaapi/dadaapi_test.go +++ b/platformapi/dadaapi/dadaapi_test.go @@ -1,6 +1,9 @@ package dadaapi -import "go.uber.org/zap" +import ( + "git.rosy.net.cn/baseapi" + "go.uber.org/zap" +) // //import ( @@ -24,32 +27,33 @@ var ( // testShopNo = "11047059" //) // -//func init() { -// logger, _ := zap.NewDevelopment() -// sugarLogger = logger.Sugar() -// baseapi.Init(sugarLogger) -// -// // sandbox -// // dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false) -// -// // prod -// dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true) -// -// // prod -// testOrder = &OperateOrderParams{ -// ShopNo: testShopNo, -// OriginID: "234242342", -// CityCode: "028", -// CargoPrice: 12.34, -// IsPrepay: 1, -// ReceiverName: "我是谁", -// ReceiverAddress: "九里堤", -// ReceiverLat: 30.74631, -// ReceiverLng: 103.99112, -// ReceiverPhone: "12812345678", -// } -// -//} +func init() { + logger, _ := zap.NewDevelopment() + sugarLogger = logger.Sugar() + baseapi.Init(sugarLogger) + + // sandbox + // dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false) + + // prod + dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true) + + // prod + //testOrder = &OperateOrderParams{ + // ShopNo: testShopNo, + // OriginID: "234242342", + // CityCode: "028", + // CargoPrice: 12.34, + // IsPrepay: 1, + // ReceiverName: "我是谁", + // ReceiverAddress: "九里堤", + // ReceiverLat: 30.74631, + // ReceiverLng: 103.99112, + // ReceiverPhone: "12812345678", + //} + +} + // //func TestTest(t *testing.T) { // sugarLogger.Debug(utils.GetCurTimeStr()) diff --git a/platformapi/dadaapi/order_test.go b/platformapi/dadaapi/order_test.go index 7b841a94..ab162640 100644 --- a/platformapi/dadaapi/order_test.go +++ b/platformapi/dadaapi/order_test.go @@ -2,7 +2,7 @@ package dadaapi // import ( - "fmt" + "git.rosy.net.cn/baseapi" //"fmt" "testing" //"git.rosy.net.cn/baseapi" @@ -43,13 +43,14 @@ import ( // // baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) //} // -//func TestCancel(t *testing.T) { -// cancelResponse, err := dadaapi.CancelOrder("126099099192000002", ReasonIDOther, "协商一致") -// if err != nil { -// t.Fatal(err) -// } -// baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) -//} +func TestCancel(t *testing.T) { + cancelResponse, err := dadaapi.CancelOrder("1100551162883899675", ReasonIDOther, "协商一致") + if err != nil { + t.Fatal(err) + } + baseapi.SugarLogger.Debug(utils.Format4Output(cancelResponse, false)) +} + // //func TestGetComplaintReasons(t *testing.T) { // complaintReason, err := dadaapi.GetComplaintReasons() @@ -76,7 +77,4 @@ func TestQueryOrderInfo(t *testing.T) { } func TestAddTip(t *testing.T) { - payload := map[string]interface{}{"categoryID": 3095} - fmt.Println(payload["img"] != nil) - fmt.Println(payload["img"] != "") } diff --git a/platformapi/kuaishou_mini/kuaishou_model.go b/platformapi/kuaishou_mini/kuaishou_model.go index 0078149f..f8b159fa 100644 --- a/platformapi/kuaishou_mini/kuaishou_model.go +++ b/platformapi/kuaishou_mini/kuaishou_model.go @@ -26,20 +26,20 @@ type GetAutoTokenRes struct { // PreCreateOrderReq 快手预发单 type PreCreateOrderReq struct { - OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一 - OpenId string `json:"open_id"` // 快手用户在当前小程序的open_id - TotalAmount int64 `json:"total_amount"` // 用户支付金额,单位为[分]。 - Subject string `json:"subject"` // 商品描述。注:1汉字=2字符。 - Detail string `json:"detail"` // 商品详情。注:1汉字=2字符。 - TypeDetail int `json:"type"` // 商品类型,不同商品类目的编号见 - ExpireTime int `json:"expire_time"` // 订单过期时间,单位秒 - Sign string `json:"sign"` // 签名 - Attach string `json:"attach"` // 开发者自定义字段,回调原样回传. - NotifyUrl string `json:"notify_url"` // 回调地址 - GoodsId string `json:"goods_id"` // 下单商品id,需与商品对接 (opens new window)时的product_id一致,长度限制256个英文字符,1个汉字=2个英文字符; - GoodsDetailUrl string `json:"goods_detail_url"` // 订单详情页跳转path。 - MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景 "[{"copies":2}]" - CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。 + OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一 + OpenId string `json:"open_id"` // 快手用户在当前小程序的open_id + TotalAmount int64 `json:"total_amount"` // 用户支付金额,单位为[分]。 + Subject string `json:"subject"` // 商品描述。注:1汉字=2字符。 + Detail string `json:"detail"` // 商品详情。注:1汉字=2字符。 + TypeDetail int `json:"type"` // 商品类型,不同商品类目的编号见 + ExpireTime int `json:"expire_time"` // 订单过期时间,单位秒 + Sign string `json:"sign"` // 签名 + //Attach string `json:"attach"` // 开发者自定义字段,回调原样回传. + NotifyUrl string `json:"notify_url"` // 回调地址 + //GoodsId string `json:"goods_id"` // 下单商品id,需与商品对接 (opens new window)时的product_id一致,长度限制256个英文字符,1个汉字=2个英文字符; + //GoodsDetailUrl string `json:"goods_detail_url"` // 订单详情页跳转path。 + //MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景 "[{"copies":2}]" + CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。 } // PreCreateOrderResponse 预下单返回参数 diff --git a/platformapi/kuaishou_mini/kuaishou_test.go b/platformapi/kuaishou_mini/kuaishou_test.go index a5401dca..766127e8 100644 --- a/platformapi/kuaishou_mini/kuaishou_test.go +++ b/platformapi/kuaishou_mini/kuaishou_test.go @@ -72,20 +72,20 @@ func TestCreateToken(t *testing.T) { // 快手预下单获取支付参数 func TestPreCreateOrder(t *testing.T) { param := &PreCreateOrderReq{ - OutOrderNo: "1024028220", - OpenId: "f198f59711c9785314bf5724f7ab9f47", - TotalAmount: 1, - Subject: "这是一个测试商品", - Detail: "大白菜,小白菜,中白菜", - TypeDetail: 1832, // 素菜 - ExpireTime: 10 * 60, - Sign: "", - Attach: "1111", - NotifyUrl: "https://callback.jxc4.com/tictoc/tiktokMsg", - GoodsId: "1122", - GoodsDetailUrl: "/page/index/anima", - MultiCopiesGoodsInfo: "[{\"copies\":2}]", - CancelOrder: 0, + OutOrderNo: "88422209072664", + OpenId: "f198f59711c9785314bf5724f7ab9f47", + TotalAmount: 501, + Subject: "蔬菜水果日用品", + Detail: "收藏门店 赠送随机小惊喜一份!1g/个 x 1件商品", + TypeDetail: 1832, // 素菜 + ExpireTime: 10 * 60, + Sign: "", + //Attach: "22", + NotifyUrl: "https://callback-jxgy.jxc4.com/kuaishou/kuaiShouCallback", + //GoodsId: "1122", + //GoodsDetailUrl: "/page/index/anima", + //MultiCopiesGoodsInfo: `[{"copies":2}]`, + CancelOrder: 1, } data, err := api.PreCreateOrder(param) globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false)) diff --git a/platformapi/tonglianpayapi/tonglianpayapi.go b/platformapi/tonglianpayapi/tonglianpayapi.go index 6d194fcc..2f4c9554 100644 --- a/platformapi/tonglianpayapi/tonglianpayapi.go +++ b/platformapi/tonglianpayapi/tonglianpayapi.go @@ -3,6 +3,7 @@ package tonglianpayapi import ( "crypto/md5" "fmt" + "git.rosy.net.cn/jx-callback/globals" "net/http" "sort" "strings" @@ -192,6 +193,8 @@ func (a *API) CreateUnitorderOrder(param *CreateUnitorderOrderParam) (result *Cr params["paytype"] = param.PayType params["sub_appid"] = param.SubAppID retVal, err := a.AccessAPI(sepcAction, params) + globals.SugarLogger.Debugf("===========err := %s", utils.Format4Output(retVal, false)) + globals.SugarLogger.Debugf("===========err := %s", utils.Format4Output(err, false)) if err == nil { utils.Map2StructByJson(retVal, &result, false) } From 8b6916952d75dfe46416e20b11c061c29b161200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 22 May 2023 09:21:40 +0800 Subject: [PATCH 15/16] 1 --- platformapi/fnpsapi/fn_test.go | 13 +++++++++++++ platformapi/fnpsapi/fnps_v3.go | 8 ++++---- platformapi/fnpsapi/order.go | 11 ++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/platformapi/fnpsapi/fn_test.go b/platformapi/fnpsapi/fn_test.go index 66251c84..113fe61d 100644 --- a/platformapi/fnpsapi/fn_test.go +++ b/platformapi/fnpsapi/fn_test.go @@ -185,3 +185,16 @@ func TestQueryOrder(t *testing.T) { globals.SugarLogger.Debug("data:= %s", utils.Format4Output(data, false)) globals.SugarLogger.Debug("err:= %s", utils.Format4Output(err, false)) } + +func TestCancelOrder(t *testing.T) { + api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "") + api.accessToken = "f5716fd7-f69b-491f-b63c-d0167c9097b6" + param := CancelOrderReq{ + GetOrderDetailReq: GetOrderDetailReq{PartnerOrderCode: "88421859678001"}, + OrderCancelCode: 9, + OrderCancelRole: 2, + OrderCancelOtherReason: "不想要了", + } + err := api.CancelOrder(¶m) // 1100537991119839487 1100536591119839487 + globals.SugarLogger.Debug("err:= %s", utils.Format4Output(err, false)) +} diff --git a/platformapi/fnpsapi/fnps_v3.go b/platformapi/fnpsapi/fnps_v3.go index 545d8527..6a6aa787 100644 --- a/platformapi/fnpsapi/fnps_v3.go +++ b/platformapi/fnpsapi/fnps_v3.go @@ -420,10 +420,10 @@ type PreCancelOrderReq struct { // cancelOrder 正式取消订单接口 type CancelOrderReq struct { GetOrderDetailReq - OrderCancelCode int64 `json:"order_cancel_code"` // 从可用取消原因列表接口返回结果选择(必填) - OrderCancelRole int `json:"order_cancel_role"` // 1商户取消, 2 用户取消(必填) - ActualCancelCostCent int64 `json:"actual_cancel_cost_cent"` // 单位分 取消实际需扣金额,从预取消接口拿(非必填) - OrderCancelOtherReason string `json:"order_cancel_other_reason"` // 取消原因补充 20字以内(非必填) + OrderCancelCode int64 `json:"order_cancel_code"` // 从可用取消原因列表接口返回结果选择(必填) + OrderCancelRole int `json:"order_cancel_role"` // 1商户取消, 2 用户取消(必填) + //ActualCancelCostCent int64 `json:"actual_cancel_cost_cent"` // 单位分 取消实际需扣金额,从预取消接口拿(非必填) + OrderCancelOtherReason string `json:"order_cancel_other_reason"` // 取消原因补充 20字以内(必填) } //#endregion diff --git a/platformapi/fnpsapi/order.go b/platformapi/fnpsapi/order.go index 0dbce9d8..7157352d 100644 --- a/platformapi/fnpsapi/order.go +++ b/platformapi/fnpsapi/order.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" "time" ) @@ -180,11 +181,15 @@ func (a *API) CancelOrder(req *CancelOrderReq) (err error) { } orderHead["business_data"] = string(business) - if _, err := a.AccessAPI(ApiURL, "cancelOrder", RequestPost, orderHead); err != nil { + data, err := a.AccessAPI(ApiURL, "cancelOrder", RequestPost, orderHead) + globals.SugarLogger.Debugf("======data : %s", utils.Format4Output(data, false)) + if err != nil { return err } - - return + if data["code"].(string) != "200" { + return errors.New(data["msg"].(string)) + } + return nil } // 查询订单详情接口 From 2297a5cc46dabf0bae8875185fc040af5f04bbd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 22 May 2023 13:42:22 +0800 Subject: [PATCH 16/16] 1 --- platformapi/kuaishou_mini/kuaishou_api.go | 1 + platformapi/kuaishou_mini/kuaishou_model.go | 28 ++++++++++----------- platformapi/kuaishou_mini/kuaishou_test.go | 24 +++++++++--------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/platformapi/kuaishou_mini/kuaishou_api.go b/platformapi/kuaishou_mini/kuaishou_api.go index d70df6f0..74368dd2 100644 --- a/platformapi/kuaishou_mini/kuaishou_api.go +++ b/platformapi/kuaishou_mini/kuaishou_api.go @@ -88,6 +88,7 @@ func (a *API) AccessAPI1(url string, params map[string]interface{}) (retVal map[ err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { globals.SugarLogger.Debugf("====param := %s", utils.Format4Output(params, false)) + globals.SugarLogger.Debugf("====url := %s", utils.Format4Output(url, false)) request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode())) request.Header.Set("Content-Type", "application/json;charset=UTF-8") return request diff --git a/platformapi/kuaishou_mini/kuaishou_model.go b/platformapi/kuaishou_mini/kuaishou_model.go index f8b159fa..0078149f 100644 --- a/platformapi/kuaishou_mini/kuaishou_model.go +++ b/platformapi/kuaishou_mini/kuaishou_model.go @@ -26,20 +26,20 @@ type GetAutoTokenRes struct { // PreCreateOrderReq 快手预发单 type PreCreateOrderReq struct { - OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一 - OpenId string `json:"open_id"` // 快手用户在当前小程序的open_id - TotalAmount int64 `json:"total_amount"` // 用户支付金额,单位为[分]。 - Subject string `json:"subject"` // 商品描述。注:1汉字=2字符。 - Detail string `json:"detail"` // 商品详情。注:1汉字=2字符。 - TypeDetail int `json:"type"` // 商品类型,不同商品类目的编号见 - ExpireTime int `json:"expire_time"` // 订单过期时间,单位秒 - Sign string `json:"sign"` // 签名 - //Attach string `json:"attach"` // 开发者自定义字段,回调原样回传. - NotifyUrl string `json:"notify_url"` // 回调地址 - //GoodsId string `json:"goods_id"` // 下单商品id,需与商品对接 (opens new window)时的product_id一致,长度限制256个英文字符,1个汉字=2个英文字符; - //GoodsDetailUrl string `json:"goods_detail_url"` // 订单详情页跳转path。 - //MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景 "[{"copies":2}]" - CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。 + OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一 + OpenId string `json:"open_id"` // 快手用户在当前小程序的open_id + TotalAmount int64 `json:"total_amount"` // 用户支付金额,单位为[分]。 + Subject string `json:"subject"` // 商品描述。注:1汉字=2字符。 + Detail string `json:"detail"` // 商品详情。注:1汉字=2字符。 + TypeDetail int `json:"type"` // 商品类型,不同商品类目的编号见 + ExpireTime int `json:"expire_time"` // 订单过期时间,单位秒 + Sign string `json:"sign"` // 签名 + Attach string `json:"attach"` // 开发者自定义字段,回调原样回传. + NotifyUrl string `json:"notify_url"` // 回调地址 + GoodsId string `json:"goods_id"` // 下单商品id,需与商品对接 (opens new window)时的product_id一致,长度限制256个英文字符,1个汉字=2个英文字符; + GoodsDetailUrl string `json:"goods_detail_url"` // 订单详情页跳转path。 + MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景 "[{"copies":2}]" + CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。 } // PreCreateOrderResponse 预下单返回参数 diff --git a/platformapi/kuaishou_mini/kuaishou_test.go b/platformapi/kuaishou_mini/kuaishou_test.go index 766127e8..4d507fb6 100644 --- a/platformapi/kuaishou_mini/kuaishou_test.go +++ b/platformapi/kuaishou_mini/kuaishou_test.go @@ -72,18 +72,18 @@ func TestCreateToken(t *testing.T) { // 快手预下单获取支付参数 func TestPreCreateOrder(t *testing.T) { param := &PreCreateOrderReq{ - OutOrderNo: "88422209072664", - OpenId: "f198f59711c9785314bf5724f7ab9f47", - TotalAmount: 501, - Subject: "蔬菜水果日用品", - Detail: "收藏门店 赠送随机小惊喜一份!1g/个 x 1件商品", - TypeDetail: 1832, // 素菜 - ExpireTime: 10 * 60, - Sign: "", - //Attach: "22", - NotifyUrl: "https://callback-jxgy.jxc4.com/kuaishou/kuaiShouCallback", - //GoodsId: "1122", - //GoodsDetailUrl: "/page/index/anima", + OutOrderNo: "88422209072664", + OpenId: "f198f59711c9785314bf5724f7ab9f47", + TotalAmount: 501, + Subject: "蔬菜水果日用品", + Detail: "好吃的素材水果", + TypeDetail: 1832, // 素菜 + ExpireTime: 10 * 60, + Sign: "", + Attach: "22", + NotifyUrl: "https://callback-jxgy.jxc4.com/kuaishou/kuaiShouCallback", + GoodsId: "1122", + GoodsDetailUrl: "/page/index/anima", //MultiCopiesGoodsInfo: `[{"copies":2}]`, CancelOrder: 1, }