sc-common-interface 2.7.6__tar.gz → 2.7.7__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.7.6
3
+ Version: 2.7.7
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -1,6 +1,5 @@
1
1
  import datetime
2
2
  import re
3
-
4
3
  import requests
5
4
  import json
6
5
  from jsonpath import jsonpath
@@ -9,6 +8,7 @@ import random
9
8
  import hmac
10
9
  from hashlib import sha1
11
10
  import random
11
+ from datetime import datetime
12
12
 
13
13
  def delete_post(data):
14
14
  env = data["env"]
@@ -150,7 +150,7 @@ def create_activity(data):
150
150
  headers = data["headers"]
151
151
  body = data["body"]
152
152
  sales_id = data["sales_id"]
153
- url = "%s/api/posts/activity/%s"%(env,sales_id)
153
+ url = "%s/admin/api/bff-web/live/activity/%s"%(env,sales_id)
154
154
  platform = "FACEBOOK"
155
155
  if "platform" in data:
156
156
  platform = data["platform"].upper()
@@ -650,7 +650,6 @@ def create_live(data):
650
650
  need_send_message = data.get("need_send_message", need_send_message)
651
651
  has_link = data.get("has_link", has_link)
652
652
 
653
-
654
653
  body = {}
655
654
  if platform.lower() in ("fb_group","facebook","instagram"):
656
655
  body = {
@@ -842,6 +841,83 @@ def create_live(data):
842
841
  },
843
842
  "postConfigMap":{}
844
843
  }
844
+ elif platform.lower in ("line&pl","line&obc","pl&line","obc&line"):
845
+ shopId, platformChannelId, platformChannelName, response = get_line_info(data)
846
+ if platform.lower in ("line&pl","pl&line"):
847
+ type = "PL"
848
+ else:
849
+ type = "OBC"
850
+ needArchive = data.get("needArchive",True)
851
+ visibleTime = data.get("visibleTime",get_stamp_time(**{"days":60}))
852
+ startTime = data.get("startTime",get_stamp_time(**{"minutes":1}))
853
+ endTime = data.get("startTime", get_stamp_time(**{"minutes": 2}))
854
+ body = {
855
+ "sales": {
856
+ "title": title,
857
+ "salesOwner": salesOwner,
858
+ "salesDescription": salesDescription,
859
+ "platforms": [
860
+ "LINE"
861
+ ],
862
+ "platformSubType": type,
863
+ "platformChannels": [
864
+ {
865
+ "platform": "LINE",
866
+ "platformChannelName": shopId,
867
+ "platformChannelId": shopId
868
+ }
869
+ ],
870
+ "coverImage": "https://img.shoplineapp.com/media/image_clips/67a5678419ad34003b97243c/original.jpeg?1738893188",
871
+ "startTime": startTime,
872
+ "endTime": endTime,
873
+ "archivedStreamVisibleTime": visibleTime,
874
+ "needArchive": needArchive
875
+ },
876
+ "salesConfig": {
877
+ "patternModel": {
878
+ "patternModel": patternModel,
879
+ "keywordValidInLive": keywordValidInLive,
880
+ "keywordValidAfterLive": keywordValidAfterLive
881
+ },
882
+ "autoNotifyPay": {
883
+ "enable": False
884
+ },
885
+ "stock": {
886
+ "lockStock": stockEnable,
887
+ "salesStockLockExpireTime": stockExpireTime
888
+ },
889
+ "lowOfQuantity": {
890
+ "enable": False,
891
+ "sound": False
892
+ }
893
+ },
894
+ "postConfigMap": {
895
+ "LINE": {
896
+ "message": {
897
+ "needSendMessage": False,
898
+ "hasInteractionMessage": {
899
+ "firstMessageTemplate": {
900
+ "topMessage": ""
901
+ },
902
+ "messageButton": ""
903
+ },
904
+ "hasLink": True,
905
+ "noInteractionMessage": {
906
+ "firstMessageTemplate": {
907
+ "topMessage": ""
908
+ },
909
+ "firstMessageButton": "",
910
+ "secondMessageTemplate": {
911
+ "topMessage": ""
912
+ },
913
+ "secondMessageButton": ""
914
+ },
915
+ "messageType": "MESSAGE"
916
+ }
917
+ }
918
+ }
919
+ }
920
+
845
921
  count = 0
846
922
  while True:
847
923
  response = requests.post(url,headers=headers,json=body)
@@ -864,6 +940,29 @@ def create_live(data):
864
940
  return sales_id
865
941
 
866
942
  # print(json.dumps(body))
943
+ def get_stamp_time(data):
944
+ #拿到指定时间的时间戳
945
+ num = data.get("num",2)
946
+ time_type = data.get("time_type","add")
947
+ unit = data.get("unit","minutes")
948
+ # 获取当前 UTC 时间
949
+ now = datetime.now()
950
+ if time_type not in {"add", "sub"}:
951
+ raise ValueError("Invalid time_type. Use 'add' or 'sub'.")
952
+ stamp_time = now + datetime.timedelta(**{unit:num if time_type == "add" else -num})
953
+ return int(stamp_time.timestamp()*1000)
954
+
955
+ def get_line_info(data):
956
+ env = data["env"]
957
+ headers = data["headers"]
958
+ url = "%s/api/posts/post/sales/lineConnectInfo"%env
959
+ response = requests.get(url,headers=headers).json()
960
+ shopId = response["data"]["shopInfo"]["shopId"]
961
+ platformChannelId = response["data"]["channel"]["platformChannelId"]
962
+ platformChannelName = response["data"]["channel"]["platformChannelName"]
963
+ return shopId,platformChannelId,platformChannelName,response
964
+
965
+
867
966
 
868
967
 
869
968
  def add_live(data):
@@ -2020,8 +2119,8 @@ def handler_auto_reply(data):
2020
2119
 
2021
2120
 
2022
2121
  if __name__=="__main__":
2023
- data = {'headers': {'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzMzRjNWViYzIwOGQ2ZTQyM2JmYzUwOWFjZjk4NThlYSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWIwOTZiZWI3YmVmMTAwMjQ1ZGJkOGIiLCJhcHBsaWNhdGlvbl9pZCI6IjYyN2M3NTBhMDYyMzcwMDAwYWZlNWVmZCJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMuc2hvcGxpbmVhcHAuY29tIiwiYXVkIjpbXSwic3ViIjoiNjFiMDk2YmViN2JlZjEwMDI0NWRiZDhiIn0.wDmFx92Wzy23KAFC-8BiQBmSlNozvR60VpXd_wAods4', 'lang': 'en', 'Content-Type': 'application/json'}, 'activity_id': 10295839, 'env': 'https://front-admin.shoplineapp.com', 'type': 'spu', 'body': {'duration': 600, 'reward': {'reward': {'spuId': '67a466094bb0a80011bf24f0', 'skuId': ''}, 'rewardType': 'PRODUCT_CUSTOM_PRICE'}, 'lotteryMethod': 'ACTIVITY_END', 'activityTitle': '接口创建竞标活动选择商品1738832709', 'businessId': '381157', 'activityType': 'BIDDING', 'totalWinner': '4', 'message': {'winMessage': '恭喜你在中得標!請至購物車確認你的得標商品!1738832706152', 'activityEndComment': '活動結束 ,謝謝大家的熱情參與!1738832706152', 'winComment': '恭喜 {winner} 得標!得標資訊請參考:{bidding-info}!1738832706152', 'activityStartComment': '{title} 活動開始商家截止前留言出價即可競標!起標價 {min-price},最高可喊到 {max-price},出價最高 {quota} 位可得標!1738832706152'}, 'activityInfo': {'minPrice': 1, 'maxPrice': 1000}}, 'keyword': '1000', 'sales_id': '381157', 'key': 'a2f4cae7b637eb42967ef5ab6a6a3ff7'}
2024
- data["keyword"] = "fasfdaf"
2122
+ data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'platform': 'FB_GROUP', 'sales_id': '514694', 'activity_id': '10296402', 'keyword': 'lyqyh1738918140786', 'post_id': '3592205981019493_3943831999190221', 'page_id': '106411048594439', 'group_id': '3592205981019493', 'key': '5e3bba98882fc0fb22a0607238bc5b8f'}
2123
+ data["keyword"] = "lyqyh1738918047653"
2025
2124
  send__live_comment(data)
2026
2125
 
2027
2126
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.7.6
3
+ Version: 2.7.7
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.7.6',
5
+ version='2.7.7',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),