sc-common-interface 2.3.7__tar.gz → 2.3.9__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.7
3
+ Version: 2.3.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -57,6 +57,7 @@ def send__live_comment(data):
57
57
  page_id = ""
58
58
  post_id = ""
59
59
  group_id = ""
60
+
60
61
  if "page_id" in data:
61
62
  page_id = data['page_id']
62
63
  if "platform" in data:
@@ -114,6 +115,7 @@ def send__live_comment(data):
114
115
  body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
115
116
  "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
116
117
  "verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
118
+
117
119
  print(body)
118
120
  url = "%s/facebook/webhook" % env
119
121
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
@@ -129,6 +131,12 @@ def send_mc_message(data):
129
131
  key = data["key"]
130
132
  stamp = int(time.time()*1000)
131
133
  user_id = "488864%d" % int(time.time())
134
+ type = "commment"
135
+ payload = "{}"
136
+ if "payload" in data:
137
+ payload = json.dumps(data["payload"])
138
+ if "type" in data:
139
+ type = data["type"]
132
140
  if "user_id" in data:
133
141
  user_id = data['user_id']
134
142
  name = "test live%d" % int(time.time())
@@ -164,6 +172,9 @@ def send_mc_message(data):
164
172
  if platform.upper()=="INSTAGRAM":
165
173
  body={"object":"instagram","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},
166
174
  "timestamp":stamp,"message":{"mid":"aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUwMzgwODgwNTMzOjM0MDI4MjM2Njg0MTcxMDMwMTI0NDI3NjAyNDExMzcwMDc2NTA5MDozMTgzODU0Mzg3NTY4MDYwMTE3ODUxOTE2MD%d"%stamp,"text":"%s"%message}}]}]}
175
+ elif type=="postback" and platform.upper() in ("FB_GROUP","FACEBOOK"):
176
+ t_time = stamp * 1000
177
+ body = {"object":"page","entry":[{"time":t_time,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},"timestamp":t_time,"postback":{"title":"继续 ➡️","payload":payload,"mid":"m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d"%stamp}}]}]}
167
178
  url = "%s/facebook/webhook" % env
168
179
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
169
180
  signData = sign_text.hexdigest()
@@ -723,6 +723,9 @@ def send_post_comment(data):
723
723
  """
724
724
  #获取关联的贴文信息-第一则贴文
725
725
  type = "post"
726
+ platform = "FACEBOOK"
727
+ if "platform" in data:
728
+ platform = data["platform"]
726
729
  if "type" in data:
727
730
  type = data["type"]
728
731
  response = {}
@@ -734,6 +737,7 @@ def send_post_comment(data):
734
737
  page_id = related_post_list["page_id"]
735
738
  post_id = related_post_list["post_id"]
736
739
  platform = related_post_list["platform"]
740
+ group_id = related_post_list["group_id"]
737
741
  # print("请求的平台是",platform)
738
742
  stamp = int(time.time())
739
743
  num = random.randint(100000, 999999)
@@ -764,6 +768,17 @@ def send_post_comment(data):
764
768
  body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id,
765
769
  "username": name}, "media": {"id": post_id, "media_product_type": "FEED"},
766
770
  "id": comment_id, "text": keyword}, "field": "comments"}]}], "object": "instagram"}
771
+ elif platform.upper() == "FB_GROUP":
772
+ t_time = stamp * 1000
773
+ post_id = post_id.split("_")[-1]
774
+ comment_id = "%d%d" % (stamp, num)
775
+ body = {"object": "page", "entry": [
776
+ {"id": page_id, "time": t_time, "messaging": [{"recipient": {"id": page_id}, "message": keyword,
777
+ "from": {"id": user_id, "name": name}, "group_id": group_id,
778
+ "post_id": post_id, "comment_id": comment_id,
779
+ "created_time": stamp, "item": "comment",
780
+ "verb": "add", "parent_id": post_id,
781
+ "field": "group_feed"}]}]}
767
782
 
768
783
  url = "%s/facebook/webhook"%env
769
784
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
@@ -1017,8 +1032,9 @@ def get_user_conversation_id(data):
1017
1032
  platform = data["platform"].lower()
1018
1033
  url = "%s/mc/conversation/id?type=%s&user_id=%s&party_channel_id=%s" % (env, platform, user_id, page_id)
1019
1034
  # param = {"type":"facebook","user_id":vars["user_id"],"party_channel_id":vars["platform_channel_id"]}
1035
+ print(url)
1020
1036
  response = requests.get(url, headers=headers).json()
1021
- # print(response)
1037
+
1022
1038
  conversation_id = jsonpath(response, "$.data.id")[0]
1023
1039
  return conversation_id,response
1024
1040
 
@@ -1564,10 +1580,75 @@ def get_mc_order_link(url):
1564
1580
  key = location.split("/")[-1].split("?")[0]
1565
1581
  return key
1566
1582
 
1583
+ def edit_message(data):
1584
+ env = data["env"]
1585
+ headers = data["headers"]
1586
+ sales_id = data["sales_id"]
1587
+ url = "%s/api/posts/post/sales/%s/keyword_message" % (env,sales_id)
1588
+ has_interaction_message = "您好,以下商品加单成功!购物车商品总金额: 请按以下按钮结账%d" % int(time.time())
1589
+ no_interaction_message_first = "您好,以下商品加单成功 !购物车商品总金额: 请按以下按钮继续」%d" % int(time.time())
1590
+ second_message = "您好,以下商品加单成功!{products} 购物车商品总金额: {total}请前往购物网站!%d" % int(time.time())
1591
+ first_message_button = "继续"
1592
+ second_message_button = "立即结帐 ️"
1593
+ need_send_message = True
1594
+ message_button = "立即结帐️"
1595
+ has_link = True
1596
+ #留言回复comment_reply
1597
+ comment_reply = True
1598
+ comment_reply_content = "testcopypost您好,谢谢你在贴文下留言订购以下商%d." % int(time.time())
1599
+ #无库存信息
1600
+ all_out_of_stock =True
1601
+ all_out_of_stock_content = "您好,{customerName},以下商品库存不足,请选购其他商品,谢谢!{products}%d" % int(time.time())
1602
+ if "has_interaction_message" in data:
1603
+ has_interaction_message = data["has_interaction_message"]
1604
+ if "no_interaction_message_first" in data:
1605
+ has_interaction_message = data["no_interaction_message_first"]
1606
+ if "first_message_button" in data:
1607
+ first_message_button = data["first_message_button"]
1608
+ if "second_message" in data:
1609
+ second_message = data["second_message"]
1610
+ if "second_message_button" in data:
1611
+ second_message_button = data["second_message_button"]
1612
+ if "need_send_message" in data:
1613
+ need_send_message = data["need_send_message"]
1614
+ if "message_button" in data:
1615
+ message_button = data["message_button"]
1616
+ if "has_link" in data:
1617
+ has_link = data["has_link"]
1618
+ if "comment_reply" in data:
1619
+ comment_reply = data["comment_reply"]
1620
+ if "comment_reply_content" in data:
1621
+ comment_reply_content = data["comment_reply_content"]
1622
+ if "all_out_of_stock" in data:
1623
+ all_out_of_stock = data["all_out_of_stock"]
1624
+ if "all_out_of_stock_content" in data:
1625
+ all_out_of_stock_content = data["all_out_of_stock_content"]
1626
+
1627
+ message = {"has_interaction_message":has_interaction_message,"no_interaction_message_first":no_interaction_message_first,
1628
+ "first_message_button":first_message_button,"second_message_button":second_message_button,"second_message":second_message,
1629
+ "comment_reply_content":comment_reply_content,"all_out_of_stock_content" :all_out_of_stock_content
1567
1630
 
1631
+ }
1632
+ body = {"message_config_req": {"need_send_message": need_send_message,
1633
+ "no_interaction_message": {"first_message": no_interaction_message_first,
1634
+ "first_message_button": first_message_button,
1635
+ "second_message":second_message ,
1636
+ "second_message_button": second_message_button},
1637
+ "has_interaction_message": {"first_message": has_interaction_message,
1638
+ "message_button": message_button}, "has_link": has_link},
1639
+ "comment_reply_req": {"need_reply": comment_reply, "content": comment_reply_content},
1640
+ "all_out_of_stock_req": {"need_reply": all_out_of_stock, "content": all_out_of_stock_content}}
1641
+ response = requests.post(url, headers=headers, json = body).json()
1642
+ return message,response
1568
1643
 
1569
1644
 
1570
1645
 
1571
1646
 
1572
1647
  if __name__=="__main__":
1573
- pass
1648
+ data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwNmUxNGU2NzAxMWY0ZDNhMGU0ZDgyNDk3ZDAxYmQwZSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVmNTlmMTI4MzcyZWIzMDAwNmRjNDcwMSJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.gUqa8FJs_vjRJ-kFMhOZx42QtCr7XxcN3gKSK6_4Zvs', 'lang': 'en'}, 'sales_id': 513416, 'platform': 'FB_GROUP'}
1649
+ sales_id,response = create_post_lucky_draw(data)
1650
+ data["sales_id"] = sales_id
1651
+ print(sales_id)
1652
+ data["prize_type"] = "discount"
1653
+ res2 = modify_lucky_draw(data)
1654
+ print(res2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.7
3
+ Version: 2.3.9
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.7',
5
+ version='2.3.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),