sc-common-interface 2.7.4__tar.gz → 2.7.6__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.4
3
+ Version: 2.7.6
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -200,10 +200,13 @@ def get_page_info(data):
200
200
  platform = info["data"]["relatedPostList"][i]["platform"]
201
201
  post_id = info["data"]["relatedPostList"][i]["post_id"]
202
202
  group_id = info["data"]["relatedPostList"][i]["group_id"]
203
+ permalink_url = info["data"]["relatedPostList"][i]["permalink_url"]
203
204
  page_info["page_id"] = page_id
204
205
  page_info["platform"] = platform
205
206
  page_info["post_id"] = post_id
206
207
  page_info["group_id"] = group_id
208
+ page_info["permalink_url"] = permalink_url
209
+
207
210
  elif sales_type.lower() == "post":
208
211
  platform_list = jsonpath(info, "$..related_post_list..platform")
209
212
  i = platform_list.index(platform.upper())
@@ -211,10 +214,12 @@ def get_page_info(data):
211
214
  platform = info["data"]["related_post_list"][i]["platform"]
212
215
  post_id = info["data"]["related_post_list"][i]["post_id"]
213
216
  group_id = info["data"]["related_post_list"][i]["group_id"]
217
+ permalink_url = info["data"]["related_post_list"][i]["permalink_url"]
214
218
  page_info["page_id"] = page_id
215
219
  page_info["platform"] = platform
216
220
  page_info["post_id"] = post_id
217
221
  page_info["group_id"] = group_id
222
+ page_info["permalink_url"] = permalink_url
218
223
  return page_info
219
224
 
220
225
 
@@ -229,19 +234,23 @@ def send__live_comment(data):
229
234
  num = random.randint(100000, 999999)
230
235
  user_id = "488864%d" % int(time.time())
231
236
  name = "test live%d" % int(time.time())
232
- comment_id = "%s_%d%d" % (page_id, stamp, num)
237
+
233
238
  keyword = "接口测试普通留言"
234
239
  user_id = data.get("user_id", user_id)
235
240
  name = data.get("name", name)
236
- comment_id = data.get("comment_id", comment_id)
237
241
  keyword = data.get("keyword", keyword)
238
242
  # sales_type = data.get("sales_type", "live")
243
+ relationUrl = data.get("relationUrl","")
239
244
  if page_id == "" or post_id == "key":
240
245
  page_info = get_page_info(data)
246
+ page_id = page_info["page_id"]
241
247
  platform = page_info["platform"]
242
248
  post_id = page_info["post_id"]
243
249
  group_id = page_info["group_id"]
244
-
250
+ relationUrl = page_info["permalink_url"]
251
+ #放到后面,需要等设置完page_id 后再设置
252
+ comment_id = "%s_%d%d" % (page_id, stamp, num)
253
+ comment_id = data.get("comment_id", comment_id)
245
254
  body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
246
255
  "from": {"id": user_id, "name": name},
247
256
  "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
@@ -259,12 +268,10 @@ def send__live_comment(data):
259
268
  "field": "comments"}]}], "object": "instagram"}
260
269
  elif platform.upper() == "FB_GROUP":
261
270
  t_time = stamp*1000
262
- if "-" in post_id:
271
+ if "_" in post_id:
263
272
  post_id = post_id.split("_")[-1]
264
- else:
265
- # print("----")
266
- relationUrl = data["relationUrl"]
267
- match = re.search(r'groups/(\d+)/posts/(\d+)/', relationUrl)
273
+ elif relationUrl!="":
274
+ match = re.search(r'groups/(\d+)/permalink/(\d+)/', relationUrl)
268
275
  group_id = match.group(1)
269
276
  post_id = match.group(2)
270
277
  comment_id = "%d%d" % ( stamp, num)
@@ -272,7 +279,7 @@ def send__live_comment(data):
272
279
  "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
273
280
  "verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
274
281
 
275
- # print(body)
282
+ print(body)
276
283
  url = "%s/facebook/webhook" % env
277
284
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
278
285
  signData = sign_text.hexdigest()
@@ -2013,10 +2020,10 @@ def handler_auto_reply(data):
2013
2020
 
2014
2021
 
2015
2022
  if __name__=="__main__":
2016
- data = {'headers': {'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en', 'Content-Type': 'application/json'}, 'auto_reply_id': '1883003621597597697', 'env': 'https://front-admin-preview.shoplineapp.com', 'sales_id': '95828', 'keyword': 'hello1737778021', 'post_id': '108513131786753_770459907444238', 'platform': 'facebook', 'page_id': '108513131786753', 'key': '5e3bba98882fc0fb22a0607238bc5b8f', 'user_id': '4888641737778025'}
2017
- data["keyword"] ="hhkfasfjasfjashfahfagagag"
2018
- user_id, name, comment_id = send__live_comment(data)
2019
- print(name)
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"
2025
+ send__live_comment(data)
2026
+
2020
2027
 
2021
2028
 
2022
2029
 
@@ -190,6 +190,34 @@ def search_oa_product(data):
190
190
  response = requests.get(url, headers=headers).json()
191
191
  return response
192
192
 
193
+ def get_has_stock_product(data):
194
+ """返回有库存商品的spu_id和sku_id"""
195
+ env = data["env"]
196
+ headers = data["headers"]
197
+ url = "%s/openApi/proxy/v1/products?page=1&per_page=20" % env
198
+ if "query" in data:
199
+ query = data["query"]
200
+ url = "%s/openApi/proxy/v1/products/search?page=1&per_page=20&%s" % (env,query)
201
+ response = requests.get(url, headers=headers).json()
202
+ product_item = response["data"]["items"]
203
+ sku_id = ""
204
+ for product in product_item:
205
+ variations = product["variations"]
206
+ status = product["status"]
207
+ if variations == [] and status != "draft":
208
+ total_orderable_quantity = product["total_orderable_quantity"]
209
+ if total_orderable_quantity > 0 or total_orderable_quantity == -1:
210
+ spu_id = product["id"]
211
+ return spu_id,sku_id
212
+ elif status != "draft":
213
+ for variation in variations:
214
+ total_orderable_quantity = variation["total_orderable_quantity"]
215
+ if total_orderable_quantity > 0 or total_orderable_quantity == -1:
216
+ spu_id = product["id"]
217
+ sku_id = variation["id"]
218
+ return spu_id,sku_id
219
+
220
+
193
221
  def create_post_lucky_draw(data):
194
222
  """
195
223
  创建抽奖活动
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.7.4
3
+ Version: 2.7.6
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.4',
5
+ version='2.7.6',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),
@@ -11,3 +11,4 @@ setup(
11
11
  "jsonpath>=0.82"
12
12
  ],
13
13
  )
14
+