This commit is contained in:
邹宗楠
2024-04-08 14:24:03 +08:00
parent bb17cacb55
commit 2cdd35d0fc
3 changed files with 28 additions and 16 deletions

View File

@@ -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;
`

View File

@@ -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,

View File

@@ -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) {