- 重要修改相关的函数新增trackInfo参数,追踪修改人.接口类型改变
This commit is contained in:
@@ -186,7 +186,7 @@ func (a *API) FullDiscountBatchSave(poiCode string, actInfo *FullDiscountActInfo
|
||||
if actInfo.ActType == ActTypeSkuFullDiscount {
|
||||
params["app_foods"] = string(utils.MustMarshal(actSkuList))
|
||||
}
|
||||
result, err := a.AccessAPI2("act/full/discount/batchsave", false, params, resultKeySuccessMsg)
|
||||
result, err := a.AccessAPI2("act/full/discount/batchsave", false, params, resultKeySuccessMsg, "")
|
||||
if err == nil {
|
||||
err = utils.UnmarshalUseNumber([]byte(result.(string)), &actIDList)
|
||||
}
|
||||
@@ -322,7 +322,7 @@ func (a *API) RetailDiscountBatchSave(poiCode string, actData []*RetailDiscountA
|
||||
result, err := a.AccessAPI2("act/retail/discount/batchsave", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"act_data": string(utils.MustMarshal(actData)),
|
||||
}, resultKeySuccessMsg)
|
||||
}, resultKeySuccessMsg, "")
|
||||
if err == nil {
|
||||
err = utils.UnmarshalUseNumber([]byte(result.(string)), &actResult)
|
||||
}
|
||||
@@ -394,7 +394,7 @@ func (a *API) InStoreCouponBatchSave(poiCode string, limitTime *LimitTime, coupo
|
||||
KeyAppPoiCode: poiCode,
|
||||
"limit_time": string(utils.MustMarshal(limitTime)),
|
||||
"act_data": string(utils.MustMarshal(couponInfoList)),
|
||||
}, resultKeySuccessMsg)
|
||||
}, resultKeySuccessMsg, "")
|
||||
if err == nil {
|
||||
err = utils.UnmarshalUseNumber([]byte(result.(string)), &couponResultList)
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (a *API) signParams(signURL string, params map[string]interface{}) string {
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(finalStr)))
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{}, resultKey string) (retVal interface{}, err error) {
|
||||
func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{}, resultKey, trackInfo string) (retVal interface{}, err error) {
|
||||
params := make(map[string]interface{})
|
||||
params["timestamp"] = time.Now().Unix()
|
||||
params["app_id"] = a.appID
|
||||
@@ -155,6 +155,9 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
}
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
}
|
||||
if trackInfo != "" {
|
||||
request.Header.Set(platformapi.KeyTrackInfo, trackInfo)
|
||||
}
|
||||
// request.Close = true //todo 为了性能考虑还是不要关闭
|
||||
return request
|
||||
},
|
||||
@@ -184,5 +187,5 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(cmd string, isGet bool, bizParams map[string]interface{}) (retVal interface{}, err error) {
|
||||
return a.AccessAPI2(cmd, isGet, bizParams, resultKeyData)
|
||||
return a.AccessAPI2(cmd, isGet, bizParams, resultKeyData, "")
|
||||
}
|
||||
|
||||
@@ -550,3 +550,14 @@ func (a *API) GetOrderIdByDaySeq(poiCode string, dateTime time.Time, seqStart, s
|
||||
}
|
||||
return vendorOrderIDs, err
|
||||
}
|
||||
|
||||
// 众包配送单追加小费
|
||||
// https://developer.waimai.meituan.com/home/docDetail/158
|
||||
func (a *API) OrderUpdateTip(orderID int64, tipAmount float64) (err error) {
|
||||
params := map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
"tip_amount": tipAmount,
|
||||
}
|
||||
_, err = a.AccessAPI("order/zhongbao/update/tip", true, params)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -154,16 +154,6 @@ func (a *API) RetailCatList(poiCode string) (retailCatList []*RetailCategoryInfo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 商品名最长30个字符(非字节)
|
||||
// 不能包含敏感词:特级
|
||||
func (a *API) RetailInitData(poiCode, foodCode string, params map[string]interface{}) (err error) {
|
||||
_, err = a.AccessAPI("retail/initdata", false, utils.MergeMaps(map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
KeyAppFoodCode: foodCode,
|
||||
}, params))
|
||||
return err
|
||||
}
|
||||
|
||||
// offset 从0开始,limit最大不能超过200
|
||||
// 返回的app_poi_code始终是空,手动建的商品app_food_code也为空(导致无法通过API删除)
|
||||
func (a *API) RetailList(poiCode string, offset, limit int) (foodList []*AppFood, err error) {
|
||||
@@ -209,33 +199,42 @@ func handleRetailBatchResultByRegexp(result interface{}) (failedFoodList []*AppF
|
||||
return failedFoodList, err
|
||||
}
|
||||
|
||||
func (a *API) RetailBatchInitData(poiCode string, foodDataList []map[string]interface{}) (failedFoodList []*AppFoodResult, err error) {
|
||||
// 商品名最长30个字符(非字节)
|
||||
func (a *API) RetailInitData(trackInfo, poiCode, foodCode string, params map[string]interface{}) (err error) {
|
||||
_, err = a.AccessAPI2("retail/initdata", false, utils.MergeMaps(map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
KeyAppFoodCode: foodCode,
|
||||
}, params), resultKeyData, trackInfo)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) RetailBatchInitData(trackInfo, poiCode string, foodDataList []map[string]interface{}) (failedFoodList []*AppFoodResult, err error) {
|
||||
result, err := a.AccessAPI2("retail/batchinitdata", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"food_data": string(utils.MustMarshal(foodDataList)),
|
||||
}, resultKeyMsg)
|
||||
}, resultKeyMsg, trackInfo)
|
||||
if err == nil {
|
||||
failedFoodList, err = handleRetailBatchResult(result)
|
||||
}
|
||||
return failedFoodList, err
|
||||
}
|
||||
|
||||
func (a *API) RetailSkuPrice(poiCode string, foodData []*BareStoreFoodInfo) (failedFoodList []*AppFoodResult, err error) {
|
||||
func (a *API) RetailSkuPrice(trackInfo, poiCode string, foodData []*BareStoreFoodInfo) (failedFoodList []*AppFoodResult, err error) {
|
||||
result, err := a.AccessAPI2("retail/sku/price", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"food_data": string(utils.MustMarshal(foodData)),
|
||||
}, resultKeyMsg)
|
||||
}, resultKeyMsg, trackInfo)
|
||||
if err == nil {
|
||||
failedFoodList, err = handleRetailBatchResult(result)
|
||||
}
|
||||
return failedFoodList, err
|
||||
}
|
||||
|
||||
func (a *API) RetailSkuStock(poiCode string, foodData []*BareStoreFoodInfo) (failedFoodList []*AppFoodResult, err error) {
|
||||
func (a *API) RetailSkuStock(trackInfo, poiCode string, foodData []*BareStoreFoodInfo) (failedFoodList []*AppFoodResult, err error) {
|
||||
result, err := a.AccessAPI2("retail/sku/stock", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"food_data": string(utils.MustMarshal(foodData)),
|
||||
}, resultKeyMsg)
|
||||
}, resultKeyMsg, trackInfo)
|
||||
if err == nil {
|
||||
failedFoodList, err = handleRetailBatchResult(result)
|
||||
}
|
||||
@@ -243,12 +242,12 @@ func (a *API) RetailSkuStock(poiCode string, foodData []*BareStoreFoodInfo) (fai
|
||||
}
|
||||
|
||||
// retail/sku/sellStatus在部分失败时会返回错误,其它相应的批处理函数则会返回成功
|
||||
func (a *API) RetailSkuSellStatus(poiCode string, foodData []*BareStoreFoodInfo, sellStatus int) (failedFoodList []*AppFoodResult, err error) {
|
||||
func (a *API) RetailSkuSellStatus(trackInfo, poiCode string, foodData []*BareStoreFoodInfo, sellStatus int) (failedFoodList []*AppFoodResult, err error) {
|
||||
_, err = a.AccessAPI2("retail/sku/sellStatus", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"food_data": string(utils.MustMarshal(foodData)),
|
||||
"sell_status": sellStatus,
|
||||
}, resultKeyMsg)
|
||||
}, resultKeyMsg, trackInfo)
|
||||
if err != nil {
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
failedFoodList, _ = handleRetailBatchResultByRegexp(errExt.ErrMsg())
|
||||
@@ -281,20 +280,20 @@ func (a *API) RetailSkuSave(poiCode, foodCode string, standardSkus, unstandardSk
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) RetailDelete(poiCode, foodCode string) (err error) {
|
||||
_, err = a.AccessAPI("retail/delete", false, map[string]interface{}{
|
||||
func (a *API) RetailDelete(trackInfo, poiCode, foodCode string) (err error) {
|
||||
_, err = a.AccessAPI2("retail/delete", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
KeyAppFoodCode: foodCode,
|
||||
})
|
||||
}, resultKeyData, trackInfo)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) RetailSkuDelete(poiCode, foodCode, skuID string) (err error) {
|
||||
_, err = a.AccessAPI("retail/sku/delete", false, map[string]interface{}{
|
||||
func (a *API) RetailSkuDelete(trackInfo, poiCode, foodCode, skuID string) (err error) {
|
||||
_, err = a.AccessAPI2("retail/sku/delete", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
KeyAppFoodCode: foodCode,
|
||||
"sku_id": skuID,
|
||||
})
|
||||
}, resultKeyData, trackInfo)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -310,7 +309,7 @@ func (a *API) RetailGetSpTagIds() (tagIds []*RetailTag, err error) {
|
||||
}
|
||||
|
||||
// 此接口将申请授权后方可接入
|
||||
func (a *API) RetailCatSkuBatchDelete(poiCode string, catNames []string, secondaryCatNames []string, foodCodes []string) (err error) {
|
||||
func (a *API) RetailCatSkuBatchDelete(trackInfo, poiCode string, catNames []string, secondaryCatNames []string, foodCodes []string) (err error) {
|
||||
params := map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
}
|
||||
@@ -323,7 +322,7 @@ func (a *API) RetailCatSkuBatchDelete(poiCode string, catNames []string, seconda
|
||||
if len(foodCodes) > 0 {
|
||||
params["app_food_codes"] = strings.Join(foodCodes, ",")
|
||||
}
|
||||
_, err = a.AccessAPI("retailCat/batchdelete/catandretail", false, params)
|
||||
_, err = a.AccessAPI2("retailCat/batchdelete/catandretail", false, params, resultKeyData, trackInfo)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -70,21 +70,21 @@ func TestRetailGetSpTagIds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailCatSkuBatchDelete(t *testing.T) {
|
||||
err := api.RetailCatSkuBatchDelete(testPoiCode, []string{"测试一级类别"}, nil, nil)
|
||||
err := api.RetailCatSkuBatchDelete(utils.GetUUID(), testPoiCode, []string{"测试一级类别"}, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetailDelete(t *testing.T) {
|
||||
err := api.RetailDelete(testPoiCode, "614")
|
||||
err := api.RetailDelete(utils.GetUUID(), testPoiCode, "614")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetailBatchInitData(t *testing.T) {
|
||||
failedFoods, err := api.RetailBatchInitData(testPoiCode, []map[string]interface{}{
|
||||
failedFoods, err := api.RetailBatchInitData(utils.GetUUID(), testPoiCode, []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"app_food_code": "23841",
|
||||
"box_num": 0,
|
||||
@@ -139,7 +139,7 @@ func TestRetailBatchInitData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailSkuPrice(t *testing.T) {
|
||||
result, err := api.RetailSkuPrice(testPoiCode, []*BareStoreFoodInfo{
|
||||
result, err := api.RetailSkuPrice(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{
|
||||
&BareStoreFoodInfo{
|
||||
AppFoodCode: "23841",
|
||||
Skus: []*BareStoreSkuInfo{
|
||||
@@ -166,7 +166,7 @@ func TestRetailSkuPrice(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailSkuStock(t *testing.T) {
|
||||
result, err := api.RetailSkuStock(testPoiCode, []*BareStoreFoodInfo{
|
||||
result, err := api.RetailSkuStock(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{
|
||||
&BareStoreFoodInfo{
|
||||
AppFoodCode: "23841",
|
||||
Skus: []*BareStoreSkuInfo{
|
||||
@@ -194,7 +194,7 @@ func TestRetailSkuStock(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailSkuSellStatus(t *testing.T) {
|
||||
result, err := api.RetailSkuSellStatus(testPoiCode, []*BareStoreFoodInfo{
|
||||
result, err := api.RetailSkuSellStatus(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{
|
||||
&BareStoreFoodInfo{
|
||||
AppFoodCode: "23841",
|
||||
Skus: []*BareStoreSkuInfo{
|
||||
|
||||
Reference in New Issue
Block a user