sc-common-interface 2.3.2__tar.gz → 2.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -88,16 +88,22 @@ def send__live_comment(data):
88
88
  keyword = "接口测试普通留言"
89
89
  if "keyword" in data:
90
90
  keyword = data['keyword']
91
- body = {}
92
- if platform == "FACEBOOK":
93
- body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
91
+ body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
94
92
  "from": {"id": user_id, "name": name},
95
93
  "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
96
94
  "permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
97
95
  "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
98
96
  "verb": "add", "post_id": post_id, "comment_id": comment_id,
99
97
  "created_time": stamp, "parent_id": post_id}}]}]}
100
- elif platform == "INSTAGRAM":
98
+ # if platform == "FACEBOOK":
99
+ # body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
100
+ # "from": {"id": user_id, "name": name},
101
+ # "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
102
+ # "permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
103
+ # "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
104
+ # "verb": "add", "post_id": post_id, "comment_id": comment_id,
105
+ # "created_time": stamp, "parent_id": post_id}}]}]}
106
+ if platform == "INSTAGRAM":
101
107
  body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id,
102
108
  "username": name},
103
109
  "media": {"id": post_id,
@@ -139,12 +145,18 @@ def send_mc_message(data):
139
145
  i = platform_list.index(platform)
140
146
  page_id = info["data"]["relatedPostList"][i]["page_id"]
141
147
  platform = info["data"]["relatedPostList"][i]["platform"]
142
- body = {}
143
- if platform.upper()=="FACEBOOK":
144
- body = {"entry":[{"id":"%s"%page_id,"messaging":[{"message":
145
- {"mid":"m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg"%stamp,"text":"%s"%message},
146
- "recipient":{"id":"%s"%page_id},"sender":{"id":"%s"%user_id},"timestamp":stamp}],"time":stamp}],"object":"page"}
147
- elif platform.upper()=="INSTAGRAM":
148
+ body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message":
149
+ {
150
+ "mid": "m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg" % stamp,
151
+ "text": "%s" % message},
152
+ "recipient": {"id": "%s" % page_id},
153
+ "sender": {"id": "%s" % user_id}, "timestamp": stamp}],
154
+ "time": stamp}], "object": "page"}
155
+ # if platform.upper()=="FACEBOOK":
156
+ # body = {"entry":[{"id":"%s"%page_id,"messaging":[{"message":
157
+ # {"mid":"m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg"%stamp,"text":"%s"%message},
158
+ # "recipient":{"id":"%s"%page_id},"sender":{"id":"%s"%user_id},"timestamp":stamp}],"time":stamp}],"object":"page"}
159
+ if platform.upper()=="INSTAGRAM":
148
160
  body={"object":"instagram","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},
149
161
  "timestamp":stamp,"message":{"mid":"aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUwMzgwODgwNTMzOjM0MDI4MjM2Njg0MTcxMDMwMTI0NDI3NjAyNDExMzcwMDc2NTA5MDozMTgzODU0Mzg3NTY4MDYwMTE3ODUxOTE2MD%d"%stamp,"text":"%s"%message}}]}]}
150
162
  url = "%s/facebook/webhook" % env
@@ -347,7 +359,7 @@ def get_broadcast_list(data):
347
359
  for i,value in enumerate(name_list):
348
360
  if value==name:
349
361
  broadcast_id =broadcast_id_list[i]
350
- return broadcast_id,name
362
+ return broadcast_id,reponse
351
363
 
352
364
  def get_broadcast_detail(data):
353
365
  env = data["env"]
@@ -480,15 +480,64 @@ def search_post_product(data):
480
480
  headers = data["headers"]
481
481
  url = "%s/api/posts/common/product/key/spu/list?page=1&searchType=ALL&pageSize=10"%env
482
482
  response = requests.get(url, headers=headers).json()
483
- productSpuKeyVos = response["data"]["productSpuKeyVos"][0]
484
- skuKeys = productSpuKeyVos["skuKeys"]
485
- spuId = productSpuKeyVos["spuId"]
486
- return skuKeys,spuId,response
483
+ items = response["data"]["openApiProductDetails"]
484
+ # productSpuKeyVos = response["data"]["productSpuKeyVos"][0]
485
+ # skuKeys = productSpuKeyVos["skuKeys"]
486
+ # spuId = productSpuKeyVos["spuId"]
487
+ # return skuKeys,spuId,response
488
+ type = "spu"
489
+ quantity = 100
490
+ if "type" in data:
491
+ type = data["type"]
492
+ if "quantity" in data:
493
+ quantity = data["quantity"]
494
+ if "query" in data:
495
+ query = data["query"]
496
+ variant_options_list = jsonpath(items, "$..variations")
497
+ product_info = ""
498
+ spu_id = ""
499
+ sku_id = ""
500
+ sku_id_quantity = []
501
+
502
+ for a, b in enumerate(variant_options_list):
503
+ if type == "spu" and b == [] and quantity != 0:
504
+ quantitys = items[a]["totalOrderableQuantity"]
505
+ unlimited_quantity = items[a]["unlimitedQuantity"]
506
+ if quantitys != 0 or unlimited_quantity == True:
507
+ product_info = items[a]
508
+ spu_id = items[a]["id"]
509
+ break
510
+ elif type == "sku" and b != [] and quantity != 0:
511
+ quantitys = items[a]["totalOrderableQuantity"]
512
+ unlimited_quantity = items[a]["unlimitedQuantity"]
513
+ if quantitys != 0 or unlimited_quantity == True:
514
+ product_info = items[a]
515
+ spu_id = items[a]["id"]
516
+ sku_id = jsonpath(items[a]["variations"], "$..id")
517
+ sku_id_quantity = jsonpath(items[a]["variations"], "$..totalOrderableQuantity")
518
+ break
519
+ elif type == "spu" and b == [] and quantity == 0:
520
+ quantitys = items[a]["totalOrderableQuantity"]
521
+ unlimited_quantity = items[a]["unlimitedQuantity"]
522
+ if quantitys != 0 or unlimited_quantity == True:
523
+ product_info = items[a]
524
+ spu_id = items[a]["id"]
525
+ break
526
+ elif type == "sku" and b != [] and quantity == 0:
527
+ quantitys = items[a]["totalOrderableQuantity"]
528
+ unlimited_quantity = items[a]["unlimited_quantity"]
529
+ if quantitys != 0 or unlimited_quantity == True:
530
+ product_info = items[a]
531
+ spu_id = items[a]["id"]
532
+ sku_id = jsonpath(items[a]["variations"], "$..id")
533
+ sku_id_quantity = jsonpath(items[a]["variations"], "$..totalOrderableQuantity")
534
+ break
535
+ return spu_id, sku_id, sku_id_quantity, product_info
487
536
 
488
537
 
489
538
  def model_one_add_product(data):
490
539
  """
491
- 贴文销售模式1-模式3添加商品,只添加第一个商品到贴文
540
+ 贴文销售模式1-模式3添加商品,只添加第一个有库存商品到贴文
492
541
  :param data:
493
542
  :return:
494
543
  """
@@ -496,25 +545,27 @@ def model_one_add_product(data):
496
545
  headers = data["headers"]
497
546
  sales_id = data["sales_id"]
498
547
  url = "%s/api/posts/post/sales/%s/products"%(env,sales_id)
499
- skuKeys, spuId, response = search_post_product(data)
548
+ spu_id, sku_id, sku_id_quantity, product_info = search_post_product(data)
549
+ # print("sku_id",sku_id)
500
550
  skuList = []
501
551
  body = {}
502
- if skuKeys != None:
503
- for index, sku in enumerate(skuKeys):
504
- skuId = sku["skuId"]
505
- spuId = sku["spuId"]
552
+ if len(sku_id) >1:
553
+ for index, sku in enumerate(sku_id):
554
+ # skuId = sku["skuId"]
555
+ # spuId = sku["spuId"]
506
556
  sku_data = {}
507
- sku_data["skuId"] = skuId
557
+ sku_data["skuId"] = sku
508
558
  sku_data["missCommonKey"] = False
509
559
  sku_data["keyList"] = ["模式1关键字%d" % index]
510
560
  skuList.append(sku_data)
511
561
  # print(skuList)
512
- if skuList == []:
562
+ if len(sku_id)<=1:
513
563
  body = {
514
- "spuList": [{"spuId": spuId, "missCommonKey": "false", "customNumbers": [], "keyList": ["无规格商品关键字"]}]}
564
+ "spuList": [{"spuId": spu_id, "missCommonKey": "false", "customNumbers": [], "keyList": ["无规格商品关键字"]}]}
515
565
  else:
516
566
  body = {
517
- "spuList": [{"spuId": spuId, "missCommonKey": "false", "customNumbers": [], "skuList": skuList}]}
567
+ "spuList": [{"spuId": spu_id, "missCommonKey": "false", "customNumbers": [], "skuList": skuList}]}
568
+ # print(body)
518
569
  response = requests.post(url, headers=headers, json=body).json()
519
570
  return response
520
571
 
@@ -528,25 +579,25 @@ def model_four_add_product(data):
528
579
  headers = data["headers"]
529
580
  sales_id = data["sales_id"]
530
581
  url = "%s/api/posts/post/sales/%s/products"%(env,sales_id)
531
- skuKeys, spuId, response = search_post_product(data)
582
+ spu_id, sku_id, sku_id_quantity, product_info = search_post_product(data)
532
583
  skuList = []
533
- if skuKeys != None:
534
- for index, sku in enumerate(skuKeys):
535
- skuId = sku["skuId"]
536
- spuId = sku["spuId"]
584
+ if len(sku_id) >1:
585
+ for index, sku in enumerate(sku_id):
586
+ # skuId = sku["skuId"]
587
+ # spuId = sku["spuId"]
537
588
  sku_data = {}
538
- sku_data["skuId"] = skuId
589
+ sku_data["skuId"] = sku
539
590
  sku_data["missCommonKey"] = False
540
591
  skuList.append(sku_data)
541
592
  # print(skuList)
542
593
  customNumbers = "模式4接口关键字下单"
543
594
  body = {}
544
- if skuList == []:
595
+ if len(sku_id) <= 1:
545
596
  body = {"spuList": [
546
- {"spuId": spuId, "missCommonKey": "true", "customNumbers": [customNumbers], "customNumber": customNumbers}]}
597
+ {"spuId": spu_id, "missCommonKey": "true", "customNumbers": [customNumbers], "customNumber": customNumbers}]}
547
598
  else:
548
599
  body = {"spuList": [
549
- {"spuId": spuId, "missCommonKey": "false", "customNumbers": [customNumbers], "customNumber": customNumbers,
600
+ {"spuId": spu_id, "missCommonKey": "false", "customNumbers": [customNumbers], "customNumber": customNumbers,
550
601
  "skuList": skuList}]}
551
602
  response = requests.post(url, headers=headers, json=body).json()
552
603
  return response
@@ -1467,11 +1518,4 @@ def get_mc_order_link(url):
1467
1518
 
1468
1519
  if __name__=="__main__":
1469
1520
  pass
1470
- # headers = {"content-type": "application/json",
1471
- # "authorization": "Bearer 11eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzN2Y2MjY2M2IyMTI1MjIzMWZlMTc4MTE2ODhkNDliYSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MjI5YTdiYWVhNzA2NDJhOGI2NWViZGEiLCJhcHBsaWNhdGlvbl9pZCI6IjYwZWVjNWViZjhkYzkyMDAwNjUyZTAwNiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMteXkuc2hvcGxpbmVzdGcuY29tIiwiYXVkIjpbXSwic3ViIjoiNjIyOWE3YmFlYTcwNjQyYThiNjVlYmRhIn0.FwtntG1dAYWNUcEZf6WSehXQveEw_rvTSGPEM3xV9FA"}
1472
- # data = {"env": "https://front-service.shoplinestg.com", "headers": headers, "platform": "FB_GROUP",
1473
- # "sales_id": "84031", "page_id": "110842575060695",
1474
- # "relationUrl": "https://www.facebook.com/groups/416632743936652/posts/823646243235298/"}
1475
- # res = relate_post(data)
1476
- # print(res)
1477
1521
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.3.2',
5
+ version='2.3.4',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),