1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"time"
|
||||
@@ -120,13 +121,59 @@ func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode strin
|
||||
return
|
||||
}
|
||||
|
||||
type Skus struct {
|
||||
AvailableTimes struct {
|
||||
Friday string `json:"friday"`
|
||||
Monday string `json:"monday"`
|
||||
Saturday string `json:"saturday"`
|
||||
Sunday string `json:"sunday"`
|
||||
Thursday string `json:"thursday"`
|
||||
Tuesday string `json:"tuesday"`
|
||||
Wednesday string `json:"wednesday"`
|
||||
} `json:"available_times"`
|
||||
BoxNum string `json:"box_num"`
|
||||
BoxPrice string `json:"box_price"`
|
||||
IsSellFlag int `json:"isSellFlag"`
|
||||
LadderBoxNum string `json:"ladder_box_num"`
|
||||
LadderBoxPrice string `json:"ladder_box_price"`
|
||||
LimitOpenSyncStockNow bool `json:"limit_open_sync_stock_now"`
|
||||
LocationCode string `json:"location_code"`
|
||||
MinOrderCount string `json:"min_order_count"`
|
||||
Price string `json:"price"`
|
||||
SkuId string `json:"sku_id"`
|
||||
Spec string `json:"spec"`
|
||||
Stock string `json:"stock"`
|
||||
Unit string `json:"unit"`
|
||||
Upc string `json:"upc"`
|
||||
Weight string `json:"weight"`
|
||||
WeightForUnit string `json:"weight_for_unit"`
|
||||
WeightUnit string `json:"weight_unit"`
|
||||
}
|
||||
|
||||
// BatchInitData 批量创建商品
|
||||
func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error {
|
||||
foodDataList := make([]map[string]interface{}, len(fromSku))
|
||||
for i, storeSku := range fromSku {
|
||||
foodData := make(map[string]interface{})
|
||||
foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode
|
||||
foodData["skus"] = storeSku.Skus
|
||||
//foodData["skus"] = storeSku.Skus
|
||||
skus := make([]*Skus, 0, 0)
|
||||
if err := json.Unmarshal([]byte(storeSku.Skus), &skus); err != nil {
|
||||
return err
|
||||
}
|
||||
skus2 := make([]*Skus, 0, 0)
|
||||
for i2 := 0; i2 < len(skus); i2++ {
|
||||
if skus[i].Weight != "" && skus[i].WeightForUnit != "" {
|
||||
skus[i].WeightForUnit = ""
|
||||
}
|
||||
skus2 = append(skus2, skus2[i2])
|
||||
}
|
||||
skusString, err := json.Marshal(skus2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
foodData["skus"] = string(skusString)
|
||||
|
||||
foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount)
|
||||
foodData["description"] = storeSku.Description
|
||||
foodData["price"] = storeSku.Price
|
||||
@@ -147,6 +194,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
||||
foodData["picture_contents"] = storeSku.PictureContents
|
||||
foodData["sequence"] = storeSku.Sequence
|
||||
foodData["tag_id"] = storeSku.TagID
|
||||
foodData["tag_id"] = storeSku.TagID
|
||||
foodDataList[i] = foodData
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user