sc-common-interface 2.7.1__tar.gz → 2.7.3__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.1
3
+ Version: 2.7.3
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -114,9 +114,6 @@ def get_sales_id(data):
114
114
  search_word = data["search"]
115
115
  param["search_word"] = search_word
116
116
  response = requests.get(url,headers=headers,params=param).json()
117
- # print("url",url)
118
- # print("param", param)
119
- # print("response",response)
120
117
  sales_data = response["data"]["list"]
121
118
  if "status" in data:
122
119
  status = data["status"]
@@ -160,11 +157,12 @@ def create_activity(data):
160
157
  if "platform" in data:
161
158
  platform = data["platform"].upper()
162
159
  response = requests.post(url,headers=headers,json=body)
163
- print(response.json())
160
+ # print(response.json())
164
161
  if response.status_code==200:
165
162
  activity_id = response.json()["data"]
166
163
  return activity_id
167
164
  else:
165
+ print("创建活动失败",response)
168
166
  return response
169
167
 
170
168
  def delate_activity(data):
@@ -191,53 +189,61 @@ def end_activity(data):
191
189
  response = requests.post(url, headers=headers).json()
192
190
  return response
193
191
 
192
+ def get_page_info(data):
193
+ info = get_live_info(data)
194
+ platform = data.get("platform", "FACEBOOK")
195
+ sales_type = data.get("sales_type", "live")
196
+ global platform_list
197
+ page_info = {}
198
+ if sales_type.lower() == "live":
199
+ platform_list = jsonpath(info, "$..relatedPostList..platform")
200
+ i = platform_list.index(platform.upper())
201
+ page_id = info["data"]["relatedPostList"][i]["page_id"]
202
+ platform = info["data"]["relatedPostList"][i]["platform"]
203
+ post_id = info["data"]["relatedPostList"][i]["post_id"]
204
+ group_id = info["data"]["relatedPostList"][i]["group_id"]
205
+ page_info["page_id"] = page_id
206
+ page_info["platform"] = platform
207
+ page_info["post_id"] = post_id
208
+ page_info["group_id"] = group_id
209
+ elif sales_type.lower() == "post":
210
+ platform_list = jsonpath(info, "$..related_post_list..platform")
211
+ i = platform_list.index(platform.upper())
212
+ page_id = info["data"]["related_post_list"][i]["page_id"]
213
+ platform = info["data"]["related_post_list"][i]["platform"]
214
+ post_id = info["data"]["related_post_list"][i]["post_id"]
215
+ group_id = info["data"]["related_post_list"][i]["group_id"]
216
+ page_info["page_id"] = page_id
217
+ page_info["platform"] = platform
218
+ page_info["post_id"] = post_id
219
+ page_info["group_id"] = group_id
220
+ return page_info
221
+
222
+
194
223
  def send__live_comment(data):
195
224
  env = data["env"]
196
225
  key = data["key"]
197
-
198
226
  page_id = data.get("page_id", "")
199
227
  platform = data.get("platform", "FACEBOOK")
200
228
  post_id = data.get("post_id", "")
201
229
  group_id = data.get("group_id", "")
202
- sales_type = data.get("sales_type", "live")
230
+ # sales_type = data.get("sales_type", "live")
203
231
  if page_id == "" or post_id == "key":
204
- info = get_live_info(data)
205
- # print("info",info)
206
- global platform_list
207
- if sales_type.lower()=="live":
208
- platform_list = jsonpath(info, "$..relatedPostList..platform")
209
- i = platform_list.index(platform.upper())
210
- page_id = info["data"]["relatedPostList"][i]["page_id"]
211
- platform = info["data"]["relatedPostList"][i]["platform"]
212
- post_id = info["data"]["relatedPostList"][i]["post_id"]
213
- group_id = info["data"]["relatedPostList"][i]["group_id"]
214
- elif sales_type.lower()=="post":
215
- platform_list = jsonpath(info, "$..related_post_list..platform")
216
- i = platform_list.index(platform.upper())
217
- page_id = info["data"]["related_post_list"][i]["page_id"]
218
- platform = info["data"]["related_post_list"][i]["platform"]
219
- post_id = info["data"]["related_post_list"][i]["post_id"]
220
- group_id = info["data"]["related_post_list"][i]["group_id"]
221
-
222
- # info = get_live_info(data)
223
- # related_post_list = info["data"]["relatedPostList"][0]
224
- # page_id = related_post_list["page_id"]
225
- # post_id = related_post_list["post_id"]
226
- # platform = related_post_list["platform"]
232
+ page_info = get_page_info(data)
233
+ platform = page_info["platform"]
234
+ post_id = page_info["post_id"]
235
+ group_id = page_info["group_id"]
227
236
  stamp = int(time.time())
228
237
  num = random.randint(100000, 999999)
229
238
  user_id = "488864%d" % int(time.time())
230
- if "user_id" in data:
231
- user_id = data['user_id']
232
239
  name = "test live%d" % int(time.time())
233
- if "name" in data:
234
- name = data['name']
235
240
  comment_id = "%s_%d%d" % (page_id, stamp, num)
236
- if "comment_id" in data:
237
- comment_id = data['comment_id']
238
241
  keyword = "接口测试普通留言"
239
- if "keyword" in data:
240
- keyword = data['keyword']
242
+ user_id = data.get("user_id",user_id)
243
+ name = data.get("name", name)
244
+ comment_id = data.get("comment_id", comment_id)
245
+ keyword = data.get("keyword", keyword)
246
+
241
247
  body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
242
248
  "from": {"id": user_id, "name": name},
243
249
  "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
@@ -293,11 +299,10 @@ def send_mc_message(data):
293
299
  page_id = data.get("page_id", "")
294
300
  platform = data.get("platform", "FACEBOOK")
295
301
  if page_id=="":
296
- info = get_live_info(data)
297
- platform_list = jsonpath(info, "$..relatedPostList..platform")
298
- i = platform_list.index(platform)
299
- page_id = info["data"]["relatedPostList"][i]["page_id"]
300
- platform = info["data"]["relatedPostList"][i]["platform"]
302
+ page_info = get_page_info(data)
303
+ platform = page_info["platform"]
304
+ post_id = page_info["post_id"]
305
+ group_id = page_info["group_id"]
301
306
  mid = "m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg" % stamp
302
307
  body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message":
303
308
  {
@@ -431,10 +436,8 @@ def live_search_oa_product(data):
431
436
  url = "%s/openApi/proxy/v1/products?page=1&per_page=50" %env
432
437
  type = "spu"
433
438
  quantity = 100
434
- if "type" in data:
435
- type = data["type"]
436
- if "quantity" in data:
437
- quantity = data["quantity"]
439
+ type = data.get("type",type)
440
+ quantity = data.get("quantity",quantity)
438
441
  if "query" in data:
439
442
  query = data["query"]
440
443
  url = "%s/openApi/proxy/v1/products?page=1&per_page=4&query=%s" % (env,query)
@@ -521,10 +524,9 @@ def get_broadcast_list(data):
521
524
  broadcast_id = ""
522
525
  pageNum = 1
523
526
  pageSize = 12
524
- if "pageNum" in data:
525
- pageNum = data["pageNum"]
526
- if "pageSize" in data:
527
- pageSize = data["pageSize"]
527
+ pageNum =data.get("pageNum",pageNum)
528
+ pageNum = data.get("pageSize", pageSize)
529
+ name = data.get("name",name)
528
530
  if "name" in data:
529
531
  name= data["name"]
530
532
  url = "%s/admin/api/bff-web/live/broadcast/query"%env
@@ -609,63 +611,39 @@ def create_live(data):
609
611
  need_send_message = True
610
612
  has_link = True
611
613
  startTime = None
612
- # endTime = datetime.datetime.now()+datetime.timedelta(days=3)
613
614
  endTime = None
614
- if "title" in data:
615
- title = data["title"]
616
- if "salesDescription" in data:
617
- title = data["salesDescription"]
618
- if "salesOwner" in data:
619
- salesOwner = data["salesOwner"]
620
- if "platform" in data:
621
- platform = data["platform"]
622
- if "patternModel" in data:
623
- patternModel = data["patternModel"]
624
- if "keywordValidInLive" in data:
625
- keywordValidInLive = data["keywordValidInLive"]
626
- if "keywordValidAfterLive" in data:
627
- keywordValidAfterLive = data["keywordValidAfterLive"]
628
-
629
- if "autoNotifyPayEnable" in data:
630
- autoNotifyPayEnable = data["autoNotifyPayEnable"]
631
- if "autoNotifyPayMessage" in data:
632
- autoNotifyPayMessage = data["autoNotifyPayMessage"]
633
- if "autoNotifyPayButton" in data:
634
- autoNotifyPayButton = data["autoNotifyPayButton"]
635
- if "autoNotifyPayTime" in data:
636
- autoNotifyPayTime = data["autoNotifyPayTime"]
637
-
638
- if "stockEnable" in data:
639
- stockEnable = data["stockEnable"]
640
- if "stockIime" in data:
641
- stockIime = data["stockIime"]
642
-
643
- if "lowOfQuantityEnable" in data:
644
- lowOfQuantityEnable = data["lowOfQuantityEnable"]
645
- if "lowOfQuantitySound" in data:
646
- lowOfQuantitySound = data["lowOfQuantitySound"]
647
- if "lowOfQuantityQuantity" in data:
648
- lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
649
-
650
- if "has_interaction_message" in data:
651
- has_interaction_message = data["has_interaction_message"]
652
- if "has_interaction_message_button" in data:
653
- has_interaction_message_button = data["has_interaction_message_button"]
654
- if "no_interaction_message_first" in data:
655
- no_interaction_message_first = data["no_interaction_message_first"]
656
- if "first_message_button" in data:
657
- first_message_button = data["first_message_button"]
658
- if "second_message" in data:
659
- second_message = data["second_message"]
660
- if "second_message_button" in data:
661
- second_message_button = data["second_message_button"]
662
- if "need_send_message" in data:
663
- need_send_message = data["need_send_message"]
664
- # if "message_button" in data:
665
- # message_button = data["message_button"]
666
- if "has_link" in data:
667
- has_link = data["has_link"]
668
- # platform = platform.upper()
615
+ stamp = int(time.time())
616
+
617
+ title = data.get("title", title)
618
+ salesDescription = data.get("salesDescription", salesDescription)
619
+ salesOwner = data.get("salesOwner", salesOwner)
620
+ platform = data.get("platform", platform)
621
+ patternModel = data.get("patternModel", patternModel)
622
+ keywordValidInLive = data.get("keywordValidInLive", keywordValidInLive)
623
+ keywordValidAfterLive = data.get("keywordValidAfterLive", keywordValidAfterLive)
624
+
625
+ autoNotifyPayEnable = data.get("autoNotifyPayEnable", autoNotifyPayEnable)
626
+ autoNotifyPayMessage = data.get("autoNotifyPayMessage", autoNotifyPayMessage)
627
+ autoNotifyPayButton = data.get("autoNotifyPayButton", autoNotifyPayButton)
628
+ autoNotifyPayTime = data.get("autoNotifyPayTime", autoNotifyPayTime)
629
+
630
+ stockEnable = data.get("stockEnable", stockEnable)
631
+ stockExpireTime = data.get("stockExpireTime")
632
+
633
+ lowOfQuantityEnable = data.get("lowOfQuantityEnable", lowOfQuantityEnable)
634
+ lowOfQuantitySound = data.get("lowOfQuantitySound", lowOfQuantitySound)
635
+ lowOfQuantityQuantity = data.get("lowOfQuantityQuantity", lowOfQuantityQuantity)
636
+
637
+ has_interaction_message = data.get("has_interaction_message", has_interaction_message)
638
+ has_interaction_message_button = data.get("has_interaction_message_button", has_interaction_message_button)
639
+ no_interaction_message_first = data.get("no_interaction_message_first", no_interaction_message_first)
640
+ first_message_button = data.get("first_message_button", first_message_button)
641
+ second_message = data.get("second_message", second_message)
642
+ second_message_button = data.get("second_message_button", second_message_button)
643
+ need_send_message = data.get("need_send_message", need_send_message)
644
+ has_link = data.get("has_link", has_link)
645
+
646
+
669
647
  body = {}
670
648
  if platform.lower() in ("fb_group","facebook","instagram"):
671
649
  body = {
@@ -899,15 +877,6 @@ def add_live(data):
899
877
  return response
900
878
 
901
879
 
902
- # def get_live_info(data):
903
- # """查询直播间信息"""
904
- # env = data["env"]
905
- # headers = data["headers"]
906
- # sales_id = data["sales_id"]
907
- # url = "%s/api/posts/live/sales/%s" % (env, sales_id)
908
- # response = requests.get(url,headers=headers).json()
909
- # return response
910
-
911
880
  def edit_live_info(data):
912
881
  """
913
882
  直播前编辑直播间信息:prepare
@@ -956,76 +925,47 @@ def edit_live_info(data):
956
925
  productRecommendMessageEnable = True
957
926
  platform = "FB_GROUP"
958
927
  type = "prepare"
959
- if "type" in data:
960
- type = data["type"]
961
- if "title" in data:
962
- title = data["title"]
963
- if "salesDescription" in data:
964
- title = data["salesDescription"]
965
- if "salesOwner" in data:
966
- title = data["salesOwner"]
967
- if "platform" in data:
968
- platform = data["platform"]
969
- if "patternModel" in data:
970
- patternModel = data["patternModel"]
971
- if "keywordValidInLive" in data:
972
- keywordValidInLive = data["keywordValidInLive"]
973
- if "keywordValidAfterLive" in data:
974
- keywordValidAfterLive = data["keywordValidAfterLive"]
975
- if "autoNotifyPayEnable" in data:
976
- autoNotifyPayEnable = data["autoNotifyPayEnable"]
977
- if "autoNotifyPayMessage" in data:
978
- autoNotifyPayMessage = data["autoNotifyPayMessage"]
979
- if "autoNotifyPayButton" in data:
980
- autoNotifyPayButton = data["autoNotifyPayButton"]
981
- if "autoNotifyPayTime" in data:
982
- autoNotifyPayTime = data["autoNotifyPayTime"]
983
- if "stockEnable" in data:
984
- stockEnable = data["stockEnable"]
985
- if "stockExpireTime" in data:
986
- stockExpireTime = data["stockExpireTime"]
987
- if "lowOfQuantityEnable" in data:
988
- lowOfQuantityEnable = data["lowOfQuantityEnable"]
989
- if "lowOfQuantitySound" in data:
990
- lowOfQuantitySound = data["lowOfQuantitySound"]
991
- if "lowOfQuantityQuantity" in data:
992
- lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
993
- if "has_interaction_message" in data:
994
- has_interaction_message = data["has_interaction_message"]
995
- if "has_interaction_message_button" in data:
996
- has_interaction_message_button = data["has_interaction_message_button"]
997
- if "no_interaction_message_first" in data:
998
- no_interaction_message_first = data["no_interaction_message_first"]
999
- if "first_message_button" in data:
1000
- first_message_button = data["first_message_button"]
1001
- if "second_message" in data:
1002
- second_message = data["second_message"]
1003
- if "second_message_button" in data:
1004
- second_message_button = data["second_message_button"]
1005
- if "need_send_message" in data:
1006
- need_send_message = data["need_send_message"]
1007
- # if "message_button" in data:
1008
- # message_button = data["message_button"]
1009
- if "has_link" in data:
1010
- has_link = data["has_link"]
1011
- if "commentIntent" in data:
1012
- commentIntent = data["commentIntent"]
1013
- if "allOutOfStockMessage" in data:
1014
- allOutOfStockMessage = data["allOutOfStockMessage"]
1015
- if "allOutOfStockEnable" in data:
1016
- allOutOfStockEnable = data["allOutOfStockEnable"]
1017
- if "welcomeMessage" in data:
1018
- welcomeMessage = data["welcomeMessage"]
1019
- if "welcomeMessageEnable" in data:
1020
- welcomeMessageEnable = data["welcomeMessageEnable"]
1021
- if "welcomeComment" in data:
1022
- welcomeComment = data["welcomeComment"]
1023
- if "welcomeCommentEnable" in data:
1024
- welcomeCommentEnable = data["welcomeCommentEnable"]
1025
- if "productRecommendMessage" in data:
1026
- productRecommendMessage = data["productRecommendMessage"]
1027
- if "productRecommendMessageEnable" in data:
1028
- productRecommendMessageEnable = data["productRecommendMessageEnable"]
928
+ type = data.get("type",type)
929
+ title = data.get("title", title)
930
+ salesDescription = data.get("salesDescription", salesDescription)
931
+ salesOwner = data.get("salesOwner", salesOwner)
932
+ platform = data.get("platform", platform)
933
+ patternModel = data.get("patternModel", patternModel)
934
+ keywordValidAfterLive = data.get("keywordValidAfterLive", keywordValidAfterLive)
935
+ keywordValidInLive = data.get("keywordValidInLive", keywordValidInLive)
936
+
937
+ autoNotifyPayEnable = data.get("autoNotifyPayEnable", autoNotifyPayEnable)
938
+ autoNotifyPayMessage = data.get("autoNotifyPayMessage", autoNotifyPayMessage)
939
+ autoNotifyPayButton = data.get("autoNotifyPayButton", autoNotifyPayButton)
940
+ autoNotifyPayTime = data.get("autoNotifyPayTime", autoNotifyPayTime)
941
+
942
+ stockEnable = data.get("stockEnable", stockEnable)
943
+ stockExpireTime = data.get("stockExpireTime", stockExpireTime)
944
+
945
+ lowOfQuantityEnable = data.get("lowOfQuantityEnable", lowOfQuantityEnable)
946
+ lowOfQuantitySound = data.get("lowOfQuantitySound", lowOfQuantitySound)
947
+ lowOfQuantityQuantity = data.get("lowOfQuantityQuantity", lowOfQuantityQuantity)
948
+
949
+ has_interaction_message = data.get("has_interaction_message", has_interaction_message)
950
+ has_interaction_message_button = data.get("has_interaction_message_button", has_interaction_message_button)
951
+ no_interaction_message_first = data.get("no_interaction_message_first", no_interaction_message_first)
952
+ first_message_button = data.get("first_message_button", first_message_button)
953
+ second_message = data.get("second_message", second_message)
954
+ second_message_button = data.get("second_message_button", second_message_button)
955
+ need_send_message = data.get("need_send_message", need_send_message)
956
+ has_link = data.get("has_link", has_link)
957
+ commentIntent = data.get("commentIntent", commentIntent)
958
+
959
+ allOutOfStockMessage = data.get("allOutOfStockMessage", allOutOfStockMessage)
960
+ allOutOfStockEnable = data.get("allOutOfStockEnable", allOutOfStockEnable)
961
+ welcomeMessage = data.get("welcomeMessage", welcomeMessage)
962
+ welcomeMessageEnable = data.get("welcomeMessageEnable", welcomeMessageEnable)
963
+ welcomeComment = data.get("welcomeComment", welcomeComment)
964
+ welcomeCommentEnable = data.get("welcomeCommentEnable", welcomeCommentEnable)
965
+ productRecommendMessage = data.get("productRecommendMessage", productRecommendMessage)
966
+ productRecommendMessageEnable = data.get("productRecommendMessageEnable", productRecommendMessageEnable)
967
+
968
+
1029
969
  platformChannels = []
1030
970
  startTime = None
1031
971
  endTime = None
@@ -1337,90 +1277,57 @@ def save_global_config(data):
1337
1277
  #视频观看人数
1338
1278
  show_number = True
1339
1279
  show_share = True
1280
+ stamp = int(time.time())
1281
+ title = "直播间标题%d"%stamp
1282
+ salesDescription = "直播间描述%d" % stamp
1283
+ salesOwner = "直播间主%d" % stamp
1284
+ platform = "FACEBOOK"
1285
+ title = data.get("title",title)
1286
+ salesDescription = data.get("salesDescription", salesDescription)
1287
+ salesOwner = data.get("salesOwner", salesOwner)
1288
+ platform = data.get("platform", platform)
1289
+ patternModel = data.get("patternModel", patternModel)
1290
+ keywordValidInLive = data.get("keywordValidInLive", keywordValidInLive)
1291
+ keywordValidAfterLive = data.get("keywordValidAfterLive", keywordValidAfterLive)
1340
1292
 
1341
- if "title" in data:
1342
- title = data["title"]
1343
- if "salesDescription" in data:
1344
- title = data["salesDescription"]
1345
- if "salesOwner" in data:
1346
- title = data["salesOwner"]
1347
- if "platform" in data:
1348
- platform = data["platform"]
1349
- if "patternModel" in data:
1350
- patternModel = data["patternModel"]
1351
- if "keywordValidInLive" in data:
1352
- keywordValidInLive = data["keywordValidInLive"]
1353
- if "keywordValidAfterLive" in data:
1354
- keywordValidAfterLive = data["keywordValidAfterLive"]
1355
-
1356
- if "autoNotifyPayEnable" in data:
1357
- autoNotifyPayEnable = data["autoNotifyPayEnable"]
1358
- if "autoNotifyPayMessage" in data:
1359
- autoNotifyPayMessage = data["autoNotifyPayMessage"]
1360
- if "autoNotifyPayButton" in data:
1361
- autoNotifyPayButton = data["autoNotifyPayButton"]
1362
- if "autoNotifyPayTime" in data:
1363
- autoNotifyPayTime = data["autoNotifyPayTime"]
1364
-
1365
- if "stockEnable" in data:
1366
- stockEnable = data["stockEnable"]
1367
- if "stockExpireTime" in data:
1368
- stockExpireTime = data["stockExpireTime"]
1369
-
1370
- if "lowOfQuantityEnable" in data:
1371
- lowOfQuantityEnable = data["lowOfQuantityEnable"]
1372
- if "lowOfQuantitySound" in data:
1373
- lowOfQuantitySound = data["lowOfQuantitySound"]
1374
- if "lowOfQuantityQuantity" in data:
1375
- lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
1376
-
1377
- if "has_interaction_message" in data:
1378
- has_interaction_message = data["has_interaction_message"]
1379
- if "has_interaction_message_button" in data:
1380
- has_interaction_message_button = data["has_interaction_message_button"]
1381
- if "no_interaction_message_first" in data:
1382
- no_interaction_message_first = data["no_interaction_message_first"]
1383
- if "first_message_button" in data:
1384
- first_message_button = data["first_message_button"]
1385
- if "second_message" in data:
1386
- second_message = data["second_message"]
1387
- if "second_message_button" in data:
1388
- second_message_button = data["second_message_button"]
1389
- if "need_send_message" in data:
1390
- need_send_message = data["need_send_message"]
1391
- # if "message_button" in data:
1392
- # message_button = data["message_button"]
1393
- if "has_link" in data:
1394
- has_link = data["has_link"]
1395
- if "commentIntent" in data:
1396
- commentIntent = data["commentIntent"]
1397
-
1398
- if "allOutOfStockMessage" in data:
1399
- allOutOfStockMessage = data["allOutOfStockMessage"]
1400
- if "allOutOfStockEnable" in data:
1401
- allOutOfStockEnable = data["allOutOfStockEnable"]
1402
-
1403
- if "welcomeMessage" in data:
1404
- welcomeMessage = data["welcomeMessage"]
1405
- if "welcomeMessageEnable" in data:
1406
- welcomeMessageEnable = data["welcomeMessageEnable"]
1407
-
1408
- if "welcomeComment" in data:
1409
- welcomeComment = data["welcomeComment"]
1410
- if "welcomeCommentEnable" in data:
1411
- welcomeCommentEnable = data["welcomeCommentEnable"]
1412
-
1413
- if "show_number" in data:
1414
- show_number = data["show_number"]
1415
- if "show_share" in data:
1416
- show_share = data["show_share"]
1417
-
1418
- if "fbProductRecommendMessage" in data:
1419
- fbProductRecommendMessage = data["fbProductRecommendMessage"]
1420
- if "igProductRecommendMessage" in data:
1421
- igProductRecommendMessage = data["igProductRecommendMessage"]
1422
- if "slProductRecommendMessage" in data:
1423
- slProductRecommendMessage = data["slProductRecommendMessage"]
1293
+ autoNotifyPayEnable = data.get("autoNotifyPayEnable", autoNotifyPayEnable)
1294
+ autoNotifyPayMessage = data.get("autoNotifyPayMessage", autoNotifyPayMessage)
1295
+ autoNotifyPayButton = data.get("autoNotifyPayButton", autoNotifyPayButton)
1296
+ autoNotifyPayTime = data.get("autoNotifyPayTime", autoNotifyPayTime)
1297
+
1298
+ stockEnable = data.get("stockEnable", stockEnable)
1299
+ stockExpireTime = data.get("stockExpireTime", stockExpireTime)
1300
+
1301
+ lowOfQuantityEnable = data.get("lowOfQuantityEnable", lowOfQuantityEnable)
1302
+ lowOfQuantitySound = data.get("lowOfQuantitySound", lowOfQuantitySound)
1303
+ lowOfQuantityQuantity = data.get("lowOfQuantityQuantity", lowOfQuantityQuantity)
1304
+
1305
+
1306
+ has_interaction_message = data.get("has_interaction_message", has_interaction_message)
1307
+ has_interaction_message_button = data.get("has_interaction_message_button", has_interaction_message_button)
1308
+ no_interaction_message_first = data.get("no_interaction_message_first", no_interaction_message_first)
1309
+ first_message_button = data.get("first_message_button", first_message_button)
1310
+ second_message = data.get("second_message", second_message)
1311
+ second_message_button = data.get("second_message_button", second_message_button)
1312
+ need_send_message = data.get("need_send_message", need_send_message)
1313
+ has_link = data.get("has_link", has_link)
1314
+ commentIntent = data.get("commentIntent", commentIntent)
1315
+
1316
+ allOutOfStockMessage = data.get("allOutOfStockMessage", allOutOfStockMessage)
1317
+ allOutOfStockEnable = data.get("allOutOfStockEnable", allOutOfStockEnable)
1318
+
1319
+ welcomeMessage = data.get("welcomeMessage", welcomeMessage)
1320
+ welcomeMessageEnable = data.get("welcomeMessageEnable", welcomeMessageEnable)
1321
+
1322
+ welcomeComment = data.get("welcomeComment", welcomeComment)
1323
+ welcomeCommentEnable = data.get("welcomeCommentEnable", welcomeCommentEnable)
1324
+
1325
+ show_number = data.get("show_number", show_number)
1326
+ show_share = data.get("show_share", show_share)
1327
+
1328
+ fbProductRecommendMessage = data.get("fbProductRecommendMessage", fbProductRecommendMessage)
1329
+ igProductRecommendMessage = data.get("igProductRecommendMessage", igProductRecommendMessage)
1330
+ slProductRecommendMessage = data.get("slProductRecommendMessage", slProductRecommendMessage)
1424
1331
 
1425
1332
 
1426
1333
  body = {
@@ -1583,15 +1490,6 @@ def get_global_config(data):
1583
1490
 
1584
1491
 
1585
1492
 
1586
-
1587
- outOfStock = {
1588
- "en":"The following product(s) doesn't have enough stock, please select other products, thanks!\n❗️{products}".replace("️{products}","ffddd"),
1589
- "zh-cn":"以下商品库存不足,请选购其他商品,谢谢!\n❗️{products}".replace("️{products}","ffddd"),
1590
- "zh-hant":"以下商品庫存不足,請選購其他商品,謝謝!\n❗️{products}".replace("️{products}","ffddd")
1591
- }
1592
-
1593
-
1594
-
1595
1493
  def remove_live_product(data):
1596
1494
  env = data["env"]
1597
1495
  headers = data["headers"]
@@ -1656,10 +1554,8 @@ def search_product_set(data):
1656
1554
  sales_id = data["sales_id"]
1657
1555
  query = ""
1658
1556
  pageNum = 1
1659
- if "pageNum" in data:
1660
- pageNum = data["pageNum"]
1661
- if "query" in data:
1662
- query = data["query"]
1557
+ pageNum = data.get("pageNum", pageNum)
1558
+ query = data.get("query", query)
1663
1559
  url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set"%(env,sales_id)
1664
1560
  param = {"pageNum":pageNum,"pageSize":10,"query":query,"queryType":"PRODUCT_NAME"}
1665
1561
  # print(param)
@@ -1673,10 +1569,8 @@ def get_product_set(data):
1673
1569
  sales_id = data["sales_id"]
1674
1570
  query = ""
1675
1571
  pageNum = 1
1676
- if "pageNum" in data:
1677
- pageNum = data["pageNum"]
1678
- if "query" in data:
1679
- query = data["query"]
1572
+ pageNum = data.get("pageNum",pageNum)
1573
+ query = data.get("query", query)
1680
1574
  url = "%s/admin/api/bff-web/live/sale/%s/product/product_set/list"%(env,sales_id)
1681
1575
  param = {"pageNum":pageNum,"pageSize":10,"query":query}
1682
1576
  # print(param)
@@ -1692,6 +1586,7 @@ def get_product_set(data):
1692
1586
  return res
1693
1587
 
1694
1588
  def get_sales_keyword(data):
1589
+ """查询直播间关键字"""
1695
1590
  env = data["env"]
1696
1591
  headers = data["headers"]
1697
1592
  sales_id = data["sales_id"]
@@ -1840,10 +1735,6 @@ def add_specific_product_set_to_live(data):
1840
1735
  except Exception:
1841
1736
  print("出现异常")
1842
1737
 
1843
- def add_mutil_product_set_to_live(data):
1844
- """添加多规格商品的全部"""
1845
- pass
1846
-
1847
1738
 
1848
1739
  def add_all_product_set_to_live(data):
1849
1740
  env = data["env"]
@@ -1980,6 +1871,145 @@ def add_all_product_set_to_keyword(data):
1980
1871
  break
1981
1872
 
1982
1873
 
1874
+ def add_auto_reply(data):
1875
+ global response
1876
+ env = data["env"]
1877
+ headers = data["headers"]
1878
+ sales_id = data["sales_id"]
1879
+ url = "%s/api/posts/post/sales/%s/auto_reply"%(env,sales_id)
1880
+ stamp = int(time.time())
1881
+ name = "自动回复工具名称%d"%stamp
1882
+ keyword_type = "ANY"
1883
+ mode = "BASIC"
1884
+ keywords = ["自动回复关键字%d"%stamp]
1885
+ commentStatus = True
1886
+ messageStatus = True
1887
+ commentContent = "留言回复内容%d"%stamp
1888
+ messageContent = "私讯回复内容%d" % stamp
1889
+ name = data.get("name",name)
1890
+ keyword_type = data.get("keyword_type", keyword_type)
1891
+ mode = data.get("mode", mode)
1892
+ keywords = data.get("keywords", keywords)
1893
+ commentStatus = data.get("commentStatus", commentStatus)
1894
+ messageStatus = data.get("messageStatus", messageStatus)
1895
+ commentContent = data.get("commentContent", commentContent)
1896
+ messageContent = data.get("messageContent", messageContent)
1897
+ body = {
1898
+ "id": "",
1899
+ "name": name,
1900
+ "keywordMatchType": keyword_type,
1901
+ "mode": mode,
1902
+ "status": False,
1903
+ "keywords": [keywords],
1904
+ "answer": {
1905
+ "commentStatus": commentStatus,
1906
+ "messageStatus": messageStatus,
1907
+ "commentContent": commentContent,
1908
+ "messageContent": messageContent
1909
+ }
1910
+ }
1911
+ try:
1912
+ response = requests.post(url,headers=headers,json=body).json()
1913
+ auto_reply_id = response["data"]["id"]
1914
+ return auto_reply_id
1915
+ except Exception:
1916
+ print("创建自动回复失败:",response)
1917
+
1918
+ def enable_auto_reply(data):
1919
+ global response
1920
+ env = data["env"]
1921
+ headers = data["headers"]
1922
+ sales_id = data["sales_id"]
1923
+ auto_reply_id = data["auto_reply_id"]
1924
+ status = True
1925
+ status = data.get("status",status)
1926
+ url = "%s/api/posts/post/sales/%s/auto_reply/%s/switch"%(env,sales_id,auto_reply_id)
1927
+ body = {
1928
+ "status": status
1929
+ }
1930
+ try:
1931
+ response = requests.put(url,headers=headers,json=body).json()
1932
+ return response
1933
+ except Exception:
1934
+ print("更改自动回复状态失败:",response)
1935
+
1936
+
1937
+ def edit_auto_reply(data):
1938
+ global response
1939
+ env = data["env"]
1940
+ headers = data["headers"]
1941
+ sales_id = data["sales_id"]
1942
+ auto_reply_id = data["auto_reply_id"]
1943
+ url = "%s/api/posts/post/sales/%s/auto_reply"%(env,sales_id)
1944
+ stamp = int(time.time())
1945
+ name = "自动回复工具名称%d"%stamp
1946
+ keyword_type = "ANY"
1947
+ mode = "BASIC"
1948
+ keywords = ["自动回复关键字%d"%stamp]
1949
+ commentStatus = True
1950
+ messageStatus = True
1951
+ commentContent = "留言回复内容%d"%stamp
1952
+ messageContent = "私讯回复内容%d" % stamp
1953
+ name = data.get("name",name)
1954
+ keyword_type = data.get("keyword_type", keyword_type)
1955
+ mode = data.get("mode", mode)
1956
+ keywords = data.get("keywords", keywords)
1957
+ commentStatus = data.get("commentStatus", commentStatus)
1958
+ messageStatus = data.get("messageStatus", messageStatus)
1959
+ commentContent = data.get("commentContent", commentContent)
1960
+ messageContent = data.get("messageContent", messageContent)
1961
+ body = {
1962
+ "id": auto_reply_id,
1963
+ "name": name,
1964
+ "keywordMatchType": keyword_type,
1965
+ "mode": mode,
1966
+ "status": False,
1967
+ "keywords": [keywords],
1968
+ "answer": {
1969
+ "commentStatus": commentStatus,
1970
+ "messageStatus": messageStatus,
1971
+ "commentContent": commentContent,
1972
+ "messageContent": messageContent
1973
+ }
1974
+ }
1975
+ try:
1976
+ response = requests.put(url,headers=headers,json=body).json()
1977
+ return response
1978
+ except Exception:
1979
+ print("编辑自动回复失败:",response)
1980
+
1981
+
1982
+ def delete_auto_reply(data):
1983
+ global response
1984
+ env = data["env"]
1985
+ headers = data["headers"]
1986
+ sales_id = data["sales_id"]
1987
+ auto_reply_id = data["auto_reply_id"]
1988
+ url = "%s/api/posts/post/sales/%s/auto_reply"%(env,sales_id)
1989
+ body = {
1990
+ "id": auto_reply_id
1991
+ }
1992
+ try:
1993
+ response = requests.delete(url,headers=headers,json=body).json()
1994
+ return response
1995
+ except Exception:
1996
+ print("删除自动回复状态失败:",response)
1997
+
1998
+ def handler_auto_reply(data):
1999
+ """处理自动回复,避免超过10个,超过10个无法新增"""
2000
+ live_info = get_live_info(data)
2001
+ autoReplyCommentConfig = live_info["data"]["autoReplyCommentConfig"]["rules"]
2002
+ num = data.get("num",8)
2003
+ if len(autoReplyCommentConfig)>num:
2004
+ for info in autoReplyCommentConfig:
2005
+ auto_reply_id = info["id"]
2006
+ data["auto_reply_id"] = auto_reply_id
2007
+ delete_auto_reply(data)
2008
+
2009
+
2010
+
2011
+
2012
+
1983
2013
 
1984
2014
 
1985
2015
  if __name__=="__main__":
@@ -1995,3 +2025,4 @@ if __name__=="__main__":
1995
2025
 
1996
2026
 
1997
2027
 
2028
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.7.1
3
+ Version: 2.7.3
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.1',
5
+ version='2.7.3',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),