ClownHe il y a 1 an
Parent
commit
adaa2cc487
1 fichiers modifiés avec 84 ajouts et 49 suppressions
  1. 84 49
      cppc_python脚本/服务器脚本/demo_20221026.py

+ 84 - 49
cppc_python脚本/服务器脚本/demo_20221026.py

@@ -493,22 +493,24 @@ def updateGoodsAreaSupplierPrice(app_id, token, uploadFile):
             for area_price in area_prices:
                 supply_price_list = []
                 if area_price['副单位'] is not None:
-                    a = {'is_min_unit': True,
-                         'unit': area_price['最小单位'],
-                         'suggested_order_price': area_price['最小单位售价'] * 100,
-                         'supply_price': area_price['最小单位采购价'] * 100}
                     b = {'is_min_unit': False,
                          'unit': area_price['副单位'],
                          'suggested_order_price': area_price['副单位售价'] * 100,
                          'supply_price': area_price['副单位采购价'] * 100}
-                    supply_price_list.append ( a )
                     supply_price_list.append ( b )
-                else:
-                    a = {'is_min_unit': True,
-                         'unit': area_price['最小单位'],
-                         'suggested_order_price': area_price['最小单位售价'] * 100,
-                         'supply_price': area_price['最小单位采购价'] * 100}
-                    supply_price_list.append ( a )
+
+                if area_price['副单位1'] is not None:
+                    c = {'is_min_unit': False,
+                         'unit': area_price['副单位1'],
+                         'suggested_order_price': area_price['副单位1售价'] * 100,
+                         'supply_price': area_price['副单位1采购价'] * 100}
+                    supply_price_list.append(c)
+
+                a = {'is_min_unit': True,
+                     'unit': area_price['最小单位'],
+                     'suggested_order_price': area_price['最小单位售价'] * 100,
+                     'supply_price': area_price['最小单位采购价'] * 100}
+                supply_price_list.append ( a )
                 area_prices_dict[str ( area_price['供货区域'] )] = supply_price_list
             # print(area_prices_dict)
             headers = {
@@ -641,20 +643,22 @@ def updateSingleGoodsPriceInGoodsInfoCentre(app_id, token, uploadFile, mode):
             sup_info = sup_ids_l[0]
             unit_price_list = []
             if str ( sup_info['副单位'] ) != 'nan':
-                a = {'is_min_unit': True,
-                     'unit': sup_info['最小单位'],
-                     'actual_amount': int ( sup_info['最小单位售价'] * 100 )}
                 b = {'is_min_unit': False,
                      'unit': sup_info['副单位'],
                      'actual_amount': int ( sup_info['副单位售价'] * 100 )}
-                unit_price_list.append ( a )
                 unit_price_list.append ( b )
 
-            else:
-                a = {'is_min_unit': True,
-                     'unit': sup_info['最小单位'],
-                     'actual_amount': int ( sup_info['最小单位售价'] * 100 )}
-                unit_price_list.append ( a )
+            if str ( sup_info['副单位1'] ) != 'nan':
+                c = {'is_min_unit': False,
+                     'unit': sup_info['副单位1'],
+                     'actual_amount': int ( sup_info['副单位1售价'] * 100 )}
+                unit_price_list.append ( c )
+
+            a = {'is_min_unit': True,
+                 'unit': sup_info['最小单位'],
+                 'actual_amount': int ( sup_info['最小单位售价'] * 100 )}
+            unit_price_list.append ( a )
+
             if str ( sup_info['限订量'] ) != 'nan':
                 buy_limit_max = sup_info['限订量']
             else:
@@ -955,20 +959,22 @@ def updateGoodsPriceInGoodsInfoCentre(app_id, token, uploadFile):
             sup_info = sup_ids_l[0]
             unit_price_list = []
             if str ( sup_info['副单位'] ) != 'nan':
-                a = {'is_min_unit': True,
-                     'unit': sup_info['最小单位'],
-                     'actual_amount': int ( sup_info['最小单位售价'] * 100 )}
                 b = {'is_min_unit': False,
                      'unit': sup_info['副单位'],
                      'actual_amount': int ( sup_info['副单位售价'] * 100 )}
-                unit_price_list.append ( a )
                 unit_price_list.append ( b )
 
-            else:
-                a = {'is_min_unit': True,
-                     'unit': sup_info['最小单位'],
-                     'actual_amount': int ( sup_info['最小单位售价'] * 100 )}
-                unit_price_list.append ( a )
+            if str ( sup_info['副单位1'] ) != 'nan':
+                c = {'is_min_unit': False,
+                     'unit': sup_info['副单位1'],
+                     'actual_amount': int ( sup_info['副单位1售价'] * 100 )}
+                unit_price_list.append ( c )
+
+
+            a = {'is_min_unit': True,
+                 'unit': sup_info['最小单位'],
+                 'actual_amount': int ( sup_info['最小单位售价'] * 100 )}
+            unit_price_list.append ( a )
             if str ( sup_info['限订量'] ) != 'nan':
                 buy_limit_max = sup_info['限订量']
             else:
@@ -1305,6 +1311,7 @@ def selectGoodInGoodsCentreSUPshops(app_id, token, goods_id, shop_window_id):
                    "shop_window_id": shop_window_id,
                    "app_id": app_id}
     resp = requests.post ( url, headers = headers, json = json_params ).json ()
+    print(resp)
     return resp
 
 
@@ -1327,6 +1334,7 @@ def updateGoodsInGoodsCentreSUPshops(app_id, token, uploadFile):
             apply_types = list (
                 set ( shop_window_ids_df[shop_window_ids_df['橱窗id'] == shop_window_id]['适用类型'] ) )  # 适用类型
             for apply_type in apply_types:
+                time.sleep(random.uniform(2,4))
                 brand_id = list ( set ( shop_window_ids_df[shop_window_ids_df['橱窗id'] == shop_window_id]['品牌id'] ) )[0]
                 apply_store_ids = list ( set ( apply_store_ids_df[apply_store_ids_df['适用类型'] == apply_type]['门店编号'] ) )
                 apply_store_ids1 = selectStoreIdByStoreNo ( app_id, token, apply_store_ids, brand_id )  # 门店编码转门店id
@@ -1911,16 +1919,34 @@ def runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode = 'p
     print(task_id)
     df_path = invoiceDownload(app_id, token, task_id, save_path, start_date, end_date, mode)
     print(df_path)
+    if 1==1:
+        dfFormatting(df_path)
     return df_path
 
+def dfFormatting(df_in_path):
+    df_in = pd.read_excel(df_in_path)
+    df_in['一级区域'] = df_in['一级区域'].fillna('')
+    df_in['二级区域'] = df_in['二级区域'].fillna('')
+    df_in['三级区域'] = df_in['三级区域'].fillna('')
+    df_in['所属省市区'] = df_in['一级区域'] + df_in['二级区域'] + df_in['三级区域']
+    df_in['商品分类'] = df_in['二级分类'].fillna(df_in['一级分类'])
+    df_in['发货单号'] = df_in['发货单号'].astype(str)
+    df_in['订货单号'] = df_in['订货单号'].astype(str)
+    # print(df_in.info())
+    df_out = df_in[
+        ['订货门店编号', '订货门店名称', '品牌', '所属省市区', '发货单号', '订货单号', '发货方', '发货单金额', '结算金额', '服务费', '交易手续费', '通道手续费', '发货单状态',
+         '创建时间', '下单时间', '发货时间', '签收时间', '商品分类', '商品编号', '商品名称', '商品厂商', '货号', '规格', '数量', '订货单价', '订货小计', '采购单价',
+         '采购小计', '单位', '收货人', '收货人电话', '收货地址']]
+    df_out.to_excel(df_in_path,index = False)
 
 if __name__ == '__main__':
-    app_id, token = getToken ()
-    print ( app_id, token )
-    # app_id = '7005337094168150016'
-    # token ='20230207-bff9c872aa2842d2b03f75e25bfb37a0'
-    goods_no = 'P4464051565'
-    io_path = 'C:/Users/ClownHe/Desktop/店务通数据'
+    if 1==1:
+        app_id, token = getToken ()
+        print ( app_id, token )
+        # app_id = '7005337094168150016'
+        # token ='20230207-bff9c872aa2842d2b03f75e25bfb37a0'
+        goods_no = 'P4464051565'
+        io_path = 'C:/Users/ClownHe/Desktop/店务通数据'
     if 1 == 0:
         # 获取商品上下架状态及商品id
         publish_state, goods_id = selectGoodsInfoPubAndId ( app_id, token, goods_no )
@@ -1994,34 +2020,37 @@ if __name__ == '__main__':
     if 1==0:
         goodsInGoodsCentre(app_id, token, io_path)
 
+    if 1==0:
+        updateGoodsInGoodsCentreSUPshops(app_id, token, io_path + '/updateGoodsInGoodsCentreSUPshops.xlsx')
+
     if 1==1:
         # 操作区
         # 运行发货单下载 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间
         start_date = '2024-03-01'
-        end_date = '2024-03-08'
+        end_date = '2024-03-31'
         mode = 'supplier_split'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间
         save_path = io_path
         runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
-        # start_date = '2024-03-01'
-        # end_date = '2024-03-01'
-        # mode = 'supplier_split'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间  11
-        # save_path = io_path
-        # runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
-        start_date = '2024-03-02'
-        end_date = '2024-03-08'
+        start_date = '2024-04-01'
+        end_date = '2024-04-05'
+        mode = 'supplier_split'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间  11
+        save_path = io_path
+        runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
+        start_date = '2024-03-30'
+        end_date = '2024-04-05'
         mode = 'supplier_split'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间
         save_path = io_path
         runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
         start_date = '2024-03-01'
-        end_date = '2024-03-08'
+        end_date = '2024-03-31'
+        mode = 'pay'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间
+        save_path = io_path
+        runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
+        start_date = '2024-04-01'
+        end_date = '2024-04-05'
         mode = 'pay'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间
         save_path = io_path
         runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
-        # start_date = '2023-12-01'
-        # end_date = '2023-12-01'
-        # mode = 'pay'  # 'pay'指定为下单时间 'supplier_split'指定为供应商预结算时间
-        # save_path = io_path
-        # runInvoiceDownload(app_id, token, save_path, start_date, end_date, mode)
 
         # upLoadFile_goods = '/selectAllGoodsInfoInDetailPrice(20231012.16.50).xlsx'
         # upLoadFile_orderids = '/活动赠送产品订单查询10.12v1.xlsx'
@@ -2043,3 +2072,9 @@ if __name__ == '__main__':
         for goods_id in goods_id_list:
             result = updatePublishState ( app_id, token, 0, goods_id )
             print ( goods_id, result )
+
+    if 1==0:
+        df_path = r'C:\Users\ClownHe\Desktop\店务通数据\2024-03-01至2024-03-31发货单(pay).xlsx'
+        df_in = pd.read_excel(df_path)
+        col = list(df_in.columns)
+        print(col)