|
|
@@ -534,94 +534,95 @@ class OnlineDataRequest(object):
|
|
|
)
|
|
|
if goods_no_dict == None:
|
|
|
return
|
|
|
- for goods_no in goods_no_dict.keys():
|
|
|
- goods_data = goods_no_dict[goods_no]
|
|
|
- detail_path = goods_data.get("detail_path", "")
|
|
|
- if detail_path == "":
|
|
|
- continue
|
|
|
- goods_title = goods_data.get("商品标题", "")
|
|
|
- if goods_title == "":
|
|
|
- continue
|
|
|
- goods_price = goods_data.get("商品价格", 0)
|
|
|
- if goods_title == 0:
|
|
|
- continue
|
|
|
- skuList = []
|
|
|
- itemImageInfoList = []
|
|
|
- itemSkuImageList = []
|
|
|
- sku_list_basic = goods_data.get("货号资料", [])
|
|
|
- quantity = 9999
|
|
|
- skuPropValueList = []
|
|
|
- for skuIdx, sku_data in enumerate(sku_list_basic):
|
|
|
- sku_goods_art_no = sku_data.get("货号", "")
|
|
|
- color_name = sku_data.get("颜色名称", "")
|
|
|
- mainImages = sku_data.get("800x800", [])
|
|
|
- if not mainImages:
|
|
|
+ for store in online_stores:
|
|
|
+ for goods_no in goods_no_dict.keys():
|
|
|
+ goods_data = goods_no_dict[goods_no]
|
|
|
+ detail_path = goods_data.get("detail_path", "")
|
|
|
+ if detail_path == "":
|
|
|
continue
|
|
|
- mainImagePath = mainImages[0]
|
|
|
- imageUrl = self.uploadImage(local_path=mainImagePath)
|
|
|
- skuItemData = {
|
|
|
- "skuNo": sku_goods_art_no,
|
|
|
- "originalPrice": float(goods_price),
|
|
|
- "newSkuWeight": int(1),
|
|
|
- "skuMainImageUrl": str(imageUrl),
|
|
|
- "skuName": f"颜色:{color_name}",
|
|
|
- "sellingPrice": float(goods_price),
|
|
|
- "quantity": int(quantity),
|
|
|
- "showOrder": int(skuIdx + 1),
|
|
|
- }
|
|
|
- skuList.append(skuItemData)
|
|
|
- itemImage = {
|
|
|
- "imageUrl": str(imageUrl),
|
|
|
- "imageType": 0,
|
|
|
- "imageItem": int(skuIdx),
|
|
|
- "imageIndex": 10,
|
|
|
- }
|
|
|
- itemImageInfoList.append(itemImage)
|
|
|
- imageJson = {
|
|
|
- "imageUrl": str(imageUrl),
|
|
|
- "imageType": 1,
|
|
|
- "showOrder": 1,
|
|
|
- }
|
|
|
- skuPropValueList.append(
|
|
|
- {
|
|
|
- "imageJson": imageJson,
|
|
|
- "propValue": str(color_name),
|
|
|
+ goods_title = goods_data.get("商品标题", "")
|
|
|
+ if goods_title == "":
|
|
|
+ continue
|
|
|
+ goods_price = goods_data.get("商品价格", 0)
|
|
|
+ if goods_title == 0:
|
|
|
+ continue
|
|
|
+ skuList = []
|
|
|
+ itemImageInfoList = []
|
|
|
+ itemSkuImageList = []
|
|
|
+ sku_list_basic = goods_data.get("货号资料", [])
|
|
|
+ quantity = 9999
|
|
|
+ skuPropValueList = []
|
|
|
+ for skuIdx, sku_data in enumerate(sku_list_basic):
|
|
|
+ sku_goods_art_no = sku_data.get("货号", "")
|
|
|
+ color_name = sku_data.get("颜色名称", "")
|
|
|
+ mainImages = sku_data.get("800x800", [])
|
|
|
+ if not mainImages:
|
|
|
+ continue
|
|
|
+ mainImagePath = mainImages[0]
|
|
|
+ imageUrl = self.uploadImage(local_path=mainImagePath)
|
|
|
+ skuItemData = {
|
|
|
+ "skuNo": sku_goods_art_no,
|
|
|
+ "originalPrice": float(goods_price),
|
|
|
+ "newSkuWeight": int(1),
|
|
|
+ "skuMainImageUrl": str(imageUrl),
|
|
|
+ "skuName": f"颜色:{color_name}",
|
|
|
+ "sellingPrice": float(goods_price),
|
|
|
+ "quantity": int(quantity),
|
|
|
+ "showOrder": int(skuIdx + 1),
|
|
|
+ }
|
|
|
+ skuList.append(skuItemData)
|
|
|
+ itemImage = {
|
|
|
+ "imageUrl": str(imageUrl),
|
|
|
+ "imageType": 0,
|
|
|
+ "imageItem": int(skuIdx),
|
|
|
+ "imageIndex": 10,
|
|
|
+ }
|
|
|
+ itemImageInfoList.append(itemImage)
|
|
|
+ imageJson = {
|
|
|
+ "imageUrl": str(imageUrl),
|
|
|
+ "imageType": 1,
|
|
|
"showOrder": 1,
|
|
|
}
|
|
|
+ skuPropValueList.append(
|
|
|
+ {
|
|
|
+ "imageJson": imageJson,
|
|
|
+ "propValue": str(color_name),
|
|
|
+ "showOrder": 1,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ itemSkuImageList.append(
|
|
|
+ {
|
|
|
+ "propName": "颜色",
|
|
|
+ "isImageProp": 1,
|
|
|
+ "propShowOrder": 1,
|
|
|
+ "skuPropValueList": skuPropValueList,
|
|
|
+ }
|
|
|
)
|
|
|
- itemSkuImageList.append(
|
|
|
- {
|
|
|
- "propName": "颜色",
|
|
|
- "isImageProp": 1,
|
|
|
- "propShowOrder": 1,
|
|
|
- "skuPropValueList": skuPropValueList,
|
|
|
+ detailImageUrl = self.uploadImage(local_path=detail_path)
|
|
|
+ category_info = "流行男鞋>>休闲鞋>>时尚休闲鞋"
|
|
|
+ itemData = {
|
|
|
+ "catePathName": category_info, # 分类
|
|
|
+ "itemName": str(goods_title), # 商品标题
|
|
|
+ "itemNo": str(goods_no),
|
|
|
+ "brandName": store, # 品牌名称
|
|
|
+ "sellingPrice": float(goods_price), # 售价(未划线价)
|
|
|
+ "originalPrice": float(goods_price), # 划线价
|
|
|
+ "quantity": int(quantity), # 库存数量
|
|
|
+ "propInfoList": [
|
|
|
+ {"propName": "品牌", "propIndex": 2, "propValue": "Vali"},
|
|
|
+ {
|
|
|
+ "propName": "平台类目",
|
|
|
+ "propIndex": 3,
|
|
|
+ "propValue": category_info,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ "skuList": skuList,
|
|
|
+ "itemImageInfoList": itemImageInfoList,
|
|
|
+ "itemSkuImageList": itemSkuImageList,
|
|
|
+ "wapDescription": f'<img src="{detailImageUrl}"/>',
|
|
|
+ "pcDescription": f'<img src="{detailImageUrl}"/>',
|
|
|
}
|
|
|
- )
|
|
|
- detailImageUrl = self.uploadImage(local_path=detail_path)
|
|
|
- category_info = "流行男鞋>>休闲鞋>>时尚休闲鞋"
|
|
|
- itemData = {
|
|
|
- "catePathName": category_info, # 分类
|
|
|
- "itemName": str(goods_title), # 商品标题
|
|
|
- "itemNo": str(goods_no),
|
|
|
- "brandName": "vali", # 品牌名称
|
|
|
- "sellingPrice": float(goods_price), # 售价(未划线价)
|
|
|
- "originalPrice": float(goods_price), # 划线价
|
|
|
- "quantity": int(quantity), # 库存数量
|
|
|
- "propInfoList": [
|
|
|
- {"propName": "品牌", "propIndex": 2, "propValue": "Vali"},
|
|
|
- {
|
|
|
- "propName": "平台类目",
|
|
|
- "propIndex": 3,
|
|
|
- "propValue": category_info,
|
|
|
- },
|
|
|
- ],
|
|
|
- "skuList": skuList,
|
|
|
- "itemImageInfoList": itemImageInfoList,
|
|
|
- "itemSkuImageList": itemSkuImageList,
|
|
|
- "wapDescription": f'<img src="{detailImageUrl}"/>',
|
|
|
- "pcDescription": f'<img src="{detailImageUrl}"/>',
|
|
|
- }
|
|
|
- params.append(itemData)
|
|
|
+ params.append(itemData)
|
|
|
json_params = str(params) # 直接转换为字符串表示
|
|
|
# 使用base64编码
|
|
|
encoded = base64.b64encode(json_params.encode("utf-8")).decode("utf-8")
|