Browse Source

Merge branch 'cloud_configs_dir_fix' into smart-shooter-clothing

rambo 3 weeks ago
parent
commit
c8cf35af7f

+ 4 - 3
python/api.py

@@ -258,6 +258,7 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
         goods_art_no_arrays = params.goods_art_no
         online_stores = params.online_stores
         is_detail = params.is_detail
+        temp_name = params.temp_name
         is_product_scene = params.is_product_scene
         is_upper_footer = params.is_upper_footer
         upper_footer_params = params.upper_footer_params
@@ -339,7 +340,7 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
             if online_stores:
                 await _upload_to_third_party(
                     onlineData, return_data_check_before_detail, 
-                    config_data, online_stores
+                    config_data, online_stores,temp_name
                 )
             await sendAsyncMessage(
                 msg="处理结束",
@@ -852,7 +853,7 @@ async def _process_detail_pages(run_main, return_data_check_before_detail, onlin
     return handler_result_folder,success_handler
 
 async def _upload_to_third_party(onlineData, return_data_check_before_detail, 
-                                config_data, online_stores):
+                                config_data, online_stores,temp_name):
     """上传到第三方平台"""
     result_goods_no_dict = return_data_check_before_detail["data"]["goods_no_dict"]
     
@@ -861,7 +862,7 @@ async def _upload_to_third_party(onlineData, return_data_check_before_detail,
         for detail_path in all_detail_path_list:
             if goods_no_dict in detail_path:
                 detail_path_replace = detail_path.replace("\\", "/")
-                result_goods_no_dict[goods_no_dict]["detail_path"] = f"{detail_path_replace}/详情页.jpg"
+                result_goods_no_dict[goods_no_dict]["detail_path"] = f"{detail_path_replace}/详情页-{temp_name}.jpg"
                 
     upload_total_progress = len(result_goods_no_dict.keys())
     upload_finish_progress = 0

+ 288 - 0
python/custom_plugins/plugins/detail_template/qingyangyizhan/detail_qingyangyizhan2.py

@@ -0,0 +1,288 @@
+"""
+步骤:
+1、整理需要处理的款号图-输出款号图文件夹
+2、整理所有相关的图片作为素材图
+3、按要求进行拼接
+"""
+
+from ast import mod
+import os
+import settings
+
+from PIL import ImageFont
+
+# from module.view_control.generate_goods_no_detail_pic.detail_generate_base import DetailBase
+# from module.view_control.generate_goods_no_detail_pic.pic_deal import PictureProcessing
+is_test_plugins = False
+try:
+    is_test_plugins = settings.is_test_plugins
+except:
+    is_test_plugins = False
+
+if is_test_plugins:
+    from custom_plugins.plugins_mode.detail_generate_base import DetailBase
+    from custom_plugins.plugins_mode.pic_deal import PictureProcessing
+else:
+    from plugins_mode.detail_generate_base import DetailBase
+    from plugins_mode.pic_deal import PictureProcessing
+
+plugins_name = "详情模板"
+company_name_list = ["轻氧驿站"]
+template_name = "qingyangyizhan-2"
+# "俯视", "侧视", "后跟", "鞋底", "内里" 组合,组合2
+
+class DetailPicGet(DetailBase):
+    need_view = ["俯视", "侧视", "后跟", "鞋底"]
+    root = r"{}\resources\detail_temp\qingyangyizhan\2".format(os.getcwd())
+
+    def __init__(
+        self,
+        goods_no,
+        goods_no_value: dict,
+        out_put_dir,
+        windows=None,
+        test=False,
+        excel_data=None,
+        assigned_page_list=None,
+    ):
+        super().__init__(
+            goods_no,
+            goods_no_value,
+            out_put_dir,
+            windows=windows,
+            excel_data=excel_data,
+            assigned_page_list=assigned_page_list,
+        )
+        self.template_name = template_name
+
+        self.root = r"{}\resources\detail_temp\qingyangyizhan\2".format(os.getcwd())
+        print(f"run {template_name} ")
+        self.base_bg_color = (255, 255, 255)
+        self.base_bg_color_2 = (244, 242, 243)
+        self.deal_pic_func_list = [
+            self.deal_pic_1,
+            self.deal_pic_2,
+            self.deal_pic_5,
+            self.deal_pic_6,
+            self.deal_pic_6_1,
+            self.deal_pic_7,
+        ]
+
+        if test:
+            # pp = self.generate_font_list_to_pic()
+            # pp.im.save(r"C:\Users\gymmc\Desktop\细节图示例/字号.png")
+            # for k, v in self.goods_no_value.items():
+            #     print(k, v)
+            self.run_test()
+        else:
+            self.run_all()
+
+    def run_test(self):
+        detailed_images = []
+        detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
+        detailed_images.append(self.deal_pic_5())
+        detailed_images.append(self.deal_pic_6())
+        detailed_images.append(self.deal_pic_6_1())
+        detailed_images.append(self.deal_pic_7())
+
+        img = self.add_pic(detailed_images)
+        img.save(r"{}/{}.jpg".format(self.out_put_dir, self.goods_no, format="JPEG"))
+        img.show()
+
+    # 直立-卷发棒
+    def deal_pic_1(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\1.jpg".format(self.root),1600)
+        pp_bg2 = PictureProcessing(r"{}\2.jpg".format(self.root),1600)
+        pp_bg2_1 = PictureProcessing(r"{}\3.jpg".format(self.root),1600)
+        pp_bg2_2 = PictureProcessing(r"{}\4.jpg".format(self.root),1600)
+        pp_bg3 = PictureProcessing(r"{}\5.jpg".format(self.root),1600)
+        detailed_images.append(pp_bg)
+        detailed_images.append(pp_bg2)
+        detailed_images.append(pp_bg2_1)
+        detailed_images.append(pp_bg2_2)
+        goods_art_no_list = list(self.data.keys())
+        _, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art_no_list[0],
+            name="鞋底",
+        )
+        pp_png_1 = pp_png_1.resize(value=pp_bg3.width/3)
+        pp_bg3 = pp_bg3.paste_img(top_img=pp_png_1, base="cc", value=(0, -30))
+        detailed_images.append(pp_bg3)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示鞋头和后跟
+    def deal_pic_2(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root), 1600)
+        pp_bg_1 = PictureProcessing(r"{}\7.jpg".format(self.root), 1600)
+        pp_bg_2 = PictureProcessing(r"{}\8.jpg".format(self.root), 1600)
+        pp_bg_special_bg = PictureProcessing(r"{}\special_bg.png".format(self.root), 1600)
+        pp_bg_special_text = PictureProcessing(r"{}\special_bottom.png".format(self.root), 1600)
+        goods_art_no_list = list(self.data.keys())
+        _, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art_no_list[0],
+            name="鞋底",
+        )
+        pp_bg5 = PictureProcessing(
+            "RGB", (pp_bg.width,pp_bg_special_bg.height), (255, 255, 255, 255)
+        )
+        pp_bg5 = pp_bg5.paste_img(top_img=pp_bg_special_bg, base="cc", value=(0, 0))
+        product_past_canvas = PictureProcessing(
+            "RGBA", (pp_bg.width, pp_png_1.height/2), (255, 255, 255, 0)
+        )
+        # pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
+        pp_png_1 = pp_png_1.crop(mode="min")
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width/2)
+        product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="nc", value=(0, -100))
+        # product_past_canvas = product_past_canvas.rotate(doge=-100)
+        pp_bg5 = pp_bg5.paste_img(top_img=product_past_canvas, base="nc", value=(0, 0))
+        pp_bg5 = pp_bg5.paste_img(top_img=pp_bg_special_text, base="cs", value=(0, 0))
+        detailed_images.append(pp_bg)
+        detailed_images.append(pp_bg_1)
+        detailed_images.append(pp_bg_2)
+        detailed_images.append(pp_bg5)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示鞋头放大图
+    def deal_pic_3(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\6.jpg".format(self.root), 1600)
+        detailed_images.append(pp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示后跟放大图
+    def deal_pic_4(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\10.jpg".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        _, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art_no_list[0],
+            name="俯视",
+        )
+        product_past_canvas = PictureProcessing(
+            "RGBA", (pp_bg.width*1.5, pp_png_1.height*1.5 + 350), (255, 255, 255, 0)
+        )
+        pp_png_1 = pp_png_1.crop(mode="min")
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width*3)
+        product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
+        product_past_canvas = product_past_canvas.rotate(doge=-105)
+        pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(100,50))
+        detailed_images.append(pp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 展示后跟细节卡片
+    def deal_pic_5(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\10.jpg".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        _, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art_no_list[0],
+            name="俯视",
+        )
+        product_past_canvas = PictureProcessing(
+            "RGBA", (pp_bg.width*2, pp_png_1.height*2 + 350), (255, 255, 255, 0)
+        )
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width*1.4)
+        product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
+        product_past_canvas =product_past_canvas.rotate(doge=-95)
+        pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(-130, 130))
+        detailed_images.append(pp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # "心动"设计亮点,展示旋转的侧视图
+    def deal_pic_6(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\11.jpg".format(self.root))
+        pp_bg1 = PictureProcessing(r"{}\12.jpg".format(self.root))
+        pp_bg2 = PictureProcessing(r"{}\13.jpg".format(self.root))
+        detailed_images.append(pp_bg)
+        detailed_images.append(pp_bg1)
+        detailed_images.append(pp_bg2)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+    def deal_pic_6_1(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\14.jpg".format(self.root))
+        pp_bg1 = PictureProcessing(r"{}\15.jpg".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        _, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art_no_list[0],
+            name="鞋底",
+        )
+        product_past_canvas = PictureProcessing(
+            "RGBA", (pp_bg.width*2, pp_png_1.height*2 + 350), (255, 255, 255, 0)
+        )
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width/3.8)
+        product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
+        product_past_canvas =product_past_canvas.rotate(doge=-8)
+        pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(0, 150))
+        detailed_images.append(pp_bg)
+        detailed_images.append(pp_bg1)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+    # 产品展示,帮面等等
+    def deal_pic_7(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\16.jpg".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        pp_jpg_1, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art_no_list[0],
+            name="俯视",
+        )
+        pp_png_1 = pp_png_1.resize(value=pp_bg.width*1.1)
+        # pp_jpg_1 = pp_jpg_1.resize(value=pp_bg.width)
+        # pp_bg = pp_bg.to_overlay_pic_advance(top_img=pp_jpg_1,top_png_img=pp_png_1, base="cc", value=(0, 0))
+        product_past_canvas = PictureProcessing(
+            "RGBA", (pp_bg.width*3, pp_png_1.height*3 + 350), (255, 255, 255, 0)
+        )
+        # pp_png_1 = pp_png_1.resize(value=pp_bg.width/3.8)
+        product_past_canvas = product_past_canvas.paste_img(top_img=pp_png_1, base="cc", value=(0, 0))
+        product_past_canvas =product_past_canvas.rotate(doge=-86)
+        pp_bg = pp_bg.paste_img(top_img=product_past_canvas, base="cc", value=(0, 70))
+        detailed_images.append(pp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 功能展示与卖点
+    def deal_pic_8(self):
+        detailed_images = []
+        pp_bg = PictureProcessing(r"{}\10.jpg".format(self.root))
+        goods_art_no_list = list(self.data.keys())
+        goods_art = goods_art_no_list[0]
+        _, pp_png_1 = self.image_one_pic(
+            return_orign=True,
+            goods_art_no=goods_art,
+            name="内里",
+        )
+        pp_png_1 = pp_png_1.crop(mode="min")
+        pp_png_1 = pp_png_1.resize(value=300)
+        desc_title_text_bg = PictureProcessing(
+            "RGB", (342, 268), (255, 255, 255, 0)
+        )
+        desc_title_text_bg = desc_title_text_bg.paste_img(
+            mode="pixel",
+            top_img=pp_png_1,
+            base="cc",
+            value=(0, 0),
+        )
+        # desc_title_text_bg = desc_title_text_bg.rotate(doge=150)
+        # desc_title_text_bg = desc_title_text_bg.crop(mode="min")
+        desc_title_text_bg = desc_title_text_bg.radius(value=30)
+        pp_bg.paste_img(
+            mode="pixel",
+            top_img=desc_title_text_bg,
+            base="en",
+            value=(62, 746),
+        )
+        detailed_images.append(pp_bg)
+        return PictureProcessing(im=self.add_pic(detailed_images))
+
+    # 添加尺码表
+    def deal_pic_9(self):
+        image_path = r"{}\11.jpg".format(self.root)
+        return PictureProcessing(image_path)

+ 3 - 4
python/detail_template_test.py

@@ -4,18 +4,17 @@ import settings
 settings.is_test_plugins = True
 
 
-from custom_plugins.plugins.detail_template.clothing.detail_clothing1 import (
+from custom_plugins.plugins.detail_template.qingyangyizhan.detail_qingyangyizhan2 import (
     DetailPicGet,
 )
 
 
-data = json.load(open("detail_template_test_clothing.json", mode="r", encoding="utf-8"))
+data = json.load(open("detail_template_test_qingyangyizhan.json", mode="r", encoding="utf-8"))
 for goods_no, value in data.items():
-    print("value", value)
     d = DetailPicGet(
         goods_no=goods_no,
         goods_no_value=value,
-        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\detail_huilima1",
+        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\detail_qingyangyizhan2",
         test=False,
     )
 print("生成成功")

+ 12 - 21
python/detail_template_test_qingyangyizhan.json

@@ -8,29 +8,20 @@
                 "编号": "AC51016112",
                 "颜色名称": "枪色",
                 "pics": {
-                    "俯视-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(1)_俯视_抠图.png",
-                    "俯视-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(1)_俯视_阴影.png",
-                    "侧视-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(2)_侧视_抠图.png",
-                    "侧视-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(2)_侧视_阴影.png",
-                    "后跟-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(3)_后跟_抠图.png",
-                    "后跟-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(3)_后跟_阴影.png",
-                    "鞋底-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(4)_鞋底_抠图.png",
-                    "鞋底-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(4)_鞋底_阴影.png",
-                    "内里-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(5)_内里_抠图.png",
-                    "内里-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(5)_内里_阴影.png",
-                    "组合-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(6)_其他1_抠图.png",
-                    "组合-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(6)_其他1_阴影.png",
-                    "组合2-抠图": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(7)_其他0_抠图.png",
-                    "组合2-阴影": "C:/Users/15001/Desktop/ningbogongmao/阴影图处理/A12345(7)_其他0_阴影.png"
+                    "俯视-抠图": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(1)_俯视_抠图.png",
+                    "俯视-阴影": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(1)_俯视_阴影.png",
+                    "侧视-抠图": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(2)_侧视_抠图.png",
+                    "侧视-阴影": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(2)_侧视_阴影.png",
+                    "后跟-抠图": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(3)_后跟_抠图.png",
+                    "后跟-阴影": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(3)_后跟_阴影.png",
+                    "鞋底-抠图": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(4)_鞋底_抠图.png",
+                    "鞋底-阴影": "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/阴影图处理/A596742(4)_鞋底_阴影.png"
                 },
                 "800x800": [
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(1)_1600.jpg",
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(2)_1600.jpg",
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(3)_1600.jpg",
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(4)_1600.jpg",
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(5)_1600.jpg",
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(6)_1600.jpg",
-                    "C:/Users/15001/Desktop/ningbogongmao/800x800/A12345(7)_1600.jpg"
+                    "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/800x800/A596742(1)_1600.png",
+                    "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/800x800/A596742(2)_1600.png",
+                    "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/800x800/A596742(3)_1600.png",
+                    "C:/Users/15001/Desktop/宁波工贸-卷发棒/A596742/800x800/A596742(4)_1600.png"
                 ]
             }
         ],

+ 15 - 3
python/service/online_request/module_online_data.py

@@ -720,7 +720,7 @@ class OnlineDataRequest(object):
                 for skuIdx, sku_data in enumerate(sku_list_basic):
                     sku_goods_art_no = sku_data.get("货号", "")
                     color_name = sku_data.get("颜色名称", "")
-                    size = sku_data.get("尺码", "")
+                    size = sku_data.get("尺码", 37)
                     # 尺码
                     mainImages = sku_data.get("800x800", [])
                     if not mainImages:
@@ -733,7 +733,7 @@ class OnlineDataRequest(object):
                         "originalPrice": float(goods_price),
                         "newSkuWeight": int(1),
                         "skuMainImageUrl": str(imageUrl),
-                        "skuName": f"颜色:{color_name};尺:{size}",
+                        "skuName": f"颜色:{color_name};尺:{size}",
                         "sellingPrice": float(goods_price),
                         "quantity": int(quantity),
                         "showOrder": int(skuIdx + 1),
@@ -753,7 +753,7 @@ class OnlineDataRequest(object):
                     }
                     skuPropValueList.append(
                         {
-                            "imageJson": imageJson,
+                            "imageJson": [imageJson],
                             "propValue": str(color_name),
                             "showOrder": 1,
                         }
@@ -766,6 +766,18 @@ class OnlineDataRequest(object):
                         "skuPropValueList": skuPropValueList,
                     }
                 )
+                itemSkuImageList.append({
+                        "propName": "尺寸",
+                        "value": None,
+                        "isImageProp": 0,
+                        "propShowOrder": 1,
+                        "showOrder": 0,
+                        "propValue": size,
+                        "skuPropValueList": [
+                            {"propValue": str(37),
+                            "showOrder": 1}
+                            ],
+                    })
                 detailImageUrl = self.uploadImage(local_path=detail_path)
                 category_info = "流行男鞋>>休闲鞋>>时尚休闲鞋"
                 itemData = {

+ 2 - 22
python/temp.py

@@ -2,25 +2,5 @@
 # from settings import recordDataPoint
 import time
 from service.online_request.module_online_data import OnlineDataRequest,AIGCDataRequest
-aigc = AIGCDataRequest("Bearer f99e72d818b504d23e0581ef1b1a2b4bb687c683")
-# status, result_image = aigc.searchProgress(1127984)
-# print(status,result_image)
-search_times = 60
-while search_times > 0:
-            print(f"模特图查询第{search_times}次")
-            # logger.info(f"模特图查询第{search_times}次")
-            status, result_image = aigc.searchProgress(1127989)
-            # status: -1=失败, 0=排队中, 1=进行中, 2=完成
-            if status == 2:  # 完成
-                break
-            if status == -1:  # 失败
-                break
-            # status为0(排队中)或1(进行中)时继续查询
-            time.sleep(1)
-            search_times -= 1
-        # 循环结束后检查最终状态
-if status == -1 or (status != 2 and search_times <= 0):
-    print("模特图生成失败")
-    exit()
-# save_image_path = download_image_with_pil(result_image, save_path)
-print("上脚图save_image_path",result_image)
+aigc = OnlineDataRequest("Bearer f99e72d818b504d23e0581ef1b1a2b4bb687c683")
+aigc.uploadGoods2ThirdParty("",["惠利玛@拼多多"])