This commit is contained in:
邹宗楠
2025-02-10 15:55:29 +08:00
parent 4bcb684bee
commit 07850d895e
6 changed files with 67 additions and 15 deletions

View File

@@ -218,7 +218,7 @@ func (a *API) CheckCallbackValidation(cmd string, params url.Values) (callbackRe
return nil
}
func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
func (a *API) GetCallbackMsg(request *http.Request, runModel string) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
err := request.ParseForm()
if err == nil {
params := make(url.Values)
@@ -228,9 +228,12 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
}
msg = new(CallbackMsg)
msg.Cmd = GetCmd(request)
if callbackResponse = a.CheckCallbackValidation(msg.Cmd, params); callbackResponse != nil {
return nil, callbackResponse
if runModel == "prod" {
if callbackResponse = a.CheckCallbackValidation(msg.Cmd, params); callbackResponse != nil {
return nil, callbackResponse
}
}
if callbackResponse = a.unmarshalData(msg.Cmd, []byte(params.Get("body")), &msg.Body); callbackResponse != nil {
return nil, callbackResponse
}

View File

@@ -31,3 +31,52 @@ func TestPictureUpload(t *testing.T) {
t.Log(utils.Format4Output(result, false))
}
}
//
//func TestEbaiSend(t *testing.T) {
// obj := map[string]interface{}{
// "ticket": "32F4FD45-3981-4092-98B7-94AEC67AC458",
// "encrypt": "",
// "sign": "417580BA8AED5C891F7629F5B37899E2",
// "cmd": "order.create",
// "source": "34665",
// "body": map[string]interface{}{
// "order_id": "4061626013391868494",
// "platform_shop_id": "1257061574",
// },
// "version": "3",
// "timestamp": 1739110519,
// }
// msgBody, _ := json.Marshal(obj["body"])
// obj["body"] = string(msgBody)
//
// EBaiMsgPush2FruitsOrPet("jxpet", obj)
//}
//
//func EBaiMsgPush2FruitsOrPet(serverType string, msg map[string]interface{}) *CallbackResponse {
// cl := http.Client{}
// var request *http.Request
// var err error
// switch serverType {
// case "":
// request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/ebai/msg", strings.NewReader(utils.Map2URLValues(msg).Encode()))
// case "jxpet":
// request, err = http.NewRequest(http.MethodPost, "http://localhost:8080/ebai/msg", strings.NewReader(utils.Map2URLValues(msg).Encode()))
// }
// if err != nil {
// return api.Err2CallbackResponse("status.push", err, nil)
// }
//
// request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// request.Header.Set("accept", "application/json, text/plain, */*")
// resp, err := cl.Do(request)
// if err != nil {
// return api.Err2CallbackResponse("status.push", err, nil)
// }
// defer resp.Body.Close()
// byteData, _ := ioutil.ReadAll(resp.Body)
// result := CallbackResponse{}
// json.Unmarshal(byteData, &result)
//
// return &result
//}

View File

@@ -20,13 +20,13 @@ func init() {
baseapi.Init(sugarLogger)
// 菜市
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
// 果园
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//商超
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_sinaAnZgfFZJkRIrdbJKBA")
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_sinaAnZgfFZJkRIrdbJKBA")
//cookieStr := `
// acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
//`

View File

@@ -31,7 +31,7 @@ func getTimeFromTimestamp(timeStamp int64) time.Time {
}
func TestOrderGetOrderDetail(t *testing.T) {
result, err := api.OrderGetOrderDetail(2801372882046324866, false)
result, err := api.OrderGetOrderDetail(4101460891740121194, false)
if err != nil {
t.Fatal(err)
}
@@ -462,6 +462,6 @@ func BatchInitSkuMT2MT(fromSku []*AppFood, toApi *API, vendorStoreID string, off
return errList, nil
}
func TestStr(t *testing.T) {
api.QuerySkuIsNeedUpc(200005466)
func TestEbaiSend(t *testing.T) {
}

View File

@@ -14,7 +14,7 @@ import (
//var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}`
// 京西到家
var token1 = `{"access_token":"3d290106-d462-4201-80cc-b7b7aa823ae5","expires_in":1723882281,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"d5ae3365-18f6-4c5f-883f-968830ec7bed","authority_id":""}`
var token1 = `{"access_token":"j9cjqyruu01j7t4nq1hehos00014hzcz-11","expires_in":1739587252,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"pi0v58amo61j7t4nq1hehos00014hzcz-12","authority_id":""}`
var a = New("7267745202649957900", "51998fcf-d521-4553-8c0c-fa662c8dbd6e", token1)

View File

@@ -402,22 +402,22 @@ func TestCreateFreightTemplate(t *testing.T) {
func TestUpdateFreightTemplate(t *testing.T) {
param := &freightTemplate_update_request.FreightTemplateUpdateParam{
Template: &freightTemplate_update_request.Template{
Id: 11332268,
TemplateName: "京西菜市(盐田一店)_668619的运费模板",
ProductProvince: 44,
ProductCity: 440300,
Id: 622913186,
TemplateName: "20002的固定运费模板",
ProductProvince: 51,
ProductCity: 510100,
CalculateType: 2, //计价方式-1.按重量 2.按数量
TransferType: 1,
RuleType: 1, //固定运费
FixedAmount: 500, //固定运费 单位:分
},
Columns: []freightTemplate_update_request.ColumnsItem{{
Columns: nil, /*[]freightTemplate_update_request.ColumnsItem{{
//RuleAddress: "{\"440000\":{\"440300\":{\"440306\":[0]}}}",
IsOverFree: true, //是否包邮
IsDefault: 0,
IsLimited: false,
OverAmount: 9900, //此字段在vendor_id=14时 存储满x包邮金额
}},
}}*/
}
templateID, err := a.FreightTemplateUpdate(param)
fmt.Println(templateID)