diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 81ea3bd3..e1c61254 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -26,7 +26,7 @@ func init() { //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_lFmVkpgE8Jevux4i9IdISA") //token_n4TwqCntWWuvQwAawzxC0w + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_rzfK3TvMXrIDIlIT3s5CSg") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 73d9d73e..a79523a2 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -434,6 +434,7 @@ func (a *API) RetailSkuSave(poiCode, foodCode string, standardSkus, unstandardSk return err } +// RetailDelete 根据APP方门店id和商品id,删除商品。 func (a *API) RetailDelete(trackInfo, poiCode, foodCode string) (err error) { _, err = a.AccessAPI2("retail/delete", false, map[string]interface{}{ KeyAppPoiCode: poiCode, diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index 9622ff26..b0370fb9 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -231,9 +231,10 @@ func TestBatchSetPrice(t *testing.T) { fmt.Println(err) } func TestRetailDelete(t *testing.T) { - poiCode := "18292160" + poiCode := "20978764" i := 0 + count := 0 for { // 同步商品 fromFoodList, err1 := api.RetailListAll(poiCode, i) @@ -241,25 +242,35 @@ func TestRetailDelete(t *testing.T) { fmt.Println(fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)) return } + count += len(fromFoodList) - stockList := make([]*BareStoreFoodInfo, 0, 100) - for _, fl := range fromFoodList { - stockList = append(stockList, &BareStoreFoodInfo{ - AppFoodCode: fl.AppFoodCode, - Skus: []*BareStoreSkuInfo{ - &BareStoreSkuInfo{ - SkuID: fl.AppFoodCode, - Stock: "99999", - }, - }, - }) + for k, v := range fromFoodList { + if err := api.RetailDelete(utils.Int2Str(k), poiCode, v.AppFoodCode); err != nil { + fmt.Println(err) + } } + //stockList := make([]*BareStoreFoodInfo, 0, 100) + //for _, fl := range fromFoodList { + // stockList = append(stockList, &BareStoreFoodInfo{ + // AppFoodCode: fl.AppFoodCode, + // Skus: []*BareStoreSkuInfo{ + // &BareStoreSkuInfo{ + // SkuID: fl.AppFoodCode, + // Stock: "99999", + // }, + // }, + // }) + //} i++ - result, err := api.RetailSkuStock(utils.GetUUID(), poiCode, stockList) - globals.SugarLogger.Debugf("===result :-%s", utils.Format4Output(result, false)) - globals.SugarLogger.Debugf("===result :-%v", err) + if len(fromFoodList) < 100 { + break + } + //result, err := api.RetailSkuStock(utils.GetUUID(), poiCode, stockList) + //globals.SugarLogger.Debugf("===result :-%s", utils.Format4Output(result, false)) + //globals.SugarLogger.Debugf("===result :-%v", err) } + fmt.Println(count) } func TestMap(t *testing.T) {