sc-common-interface 2.4.3__tar.gz → 2.4.5__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.4.3
3
+ Version: 2.4.5
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -175,6 +175,12 @@ def send_mc_message(data):
175
175
  elif type=="postback" and platform.upper() in ("FB_GROUP","FACEBOOK"):
176
176
  # t_time = stamp * 1000
177
177
  body = {"object":"page","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},"timestamp":stamp,"postback":{"title":"继续 ➡️","payload":payload,"mid":"m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d"%stamp}}]}]}
178
+ elif type=="postback" and platform.lower()=="instagram":
179
+ body = {"object": "instagram", "entry": [{"time": stamp, "id": "%s" % page_id, "messaging": [
180
+ {"sender": {"id": "%s" % user_id}, "recipient": {"id": "%s" % page_id}, "timestamp": stamp,
181
+ "postback": {"title": "继续 ➡️", "payload": payload,
182
+ "mid": "m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d" % stamp}}]}]}
183
+
178
184
  url = "%s/facebook/webhook" % env
179
185
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
180
186
  signData = sign_text.hexdigest()
@@ -194,6 +200,15 @@ def get_live_info(data):
194
200
  response = requests.get(url,headers=headers).json()
195
201
  return response
196
202
 
203
+ def get_live_product(data):
204
+ env = data["env"]
205
+ headers = data["headers"]
206
+ sales_id = data["sales_id"]
207
+ url = "%s/api/posts/post/sales/%s/product/v2" % (env, sales_id)
208
+ params = {"salesId":sales_id,"pageIndex":1,"pageSize":25}
209
+ response = requests.get(url, headers=headers,params=params).json()
210
+ return response
211
+
197
212
  def get_activity_detail(data):
198
213
  """
199
214
  type:
@@ -328,6 +343,7 @@ def get_merchant_info(data):
328
343
  url = "%s/openApi/proxy/v1/merchants/%s" % (env,merchant_id)
329
344
  response = requests.get(url, headers=headers).json()
330
345
  base_country_code = response["data"]["base_country_code"]
346
+ default_language_code = response["data"]["default_language_code"]
331
347
  currency = ""
332
348
  if base_country_code=="TW":
333
349
  currency="NT$"
@@ -401,6 +417,17 @@ def end_live(data):
401
417
  response = requests.put(url, headers=headers).json()
402
418
  return response
403
419
 
420
+ def get_channel(data):
421
+ "查询粉丝页信息,用于创建帖文"
422
+ env = data["env"]
423
+ headers = data["headers"]
424
+ platform = data["platform"]
425
+ url = "%s/api/posts/post/sales/multiPlatformChannelList?platformList=%s"%(env,platform.upper())
426
+ response = requests.get(url,headers=headers).json()
427
+ return response
428
+
429
+
430
+
404
431
  def create_live(data):
405
432
  """创建直播,不套用通用配置"""
406
433
  env = data["env"]
@@ -411,41 +438,60 @@ def create_live(data):
411
438
  salesDescription = "接口创建的直播活动介绍%d"%stamp
412
439
  salesOwner = "接口创建的直播主%d"%stamp
413
440
  platform = "FB_GROUP"
441
+ patternModel = "INCLUDE_MATCH"
442
+ keywordValidInLive = True
443
+ keywordValidAfterLive =False
444
+ autoNotifyPayEnable = False
445
+ autoNotifyPayMessage = ""
446
+ autoNotifyPayButton = ""
447
+ autoNotifyPayTime = None
448
+ stockEnable = False
449
+ stockIime = None
450
+ lowOfQuantityEnable = False
451
+ lowOfQuantitySound = False
452
+ lowOfQuantityQuantity = "1"
453
+ has_interaction_message = ""
454
+ has_interaction_message_button = ""
455
+ no_interaction_message_first = ""
456
+ second_message = ""
457
+ first_message_button = ""
458
+ second_message_button = " ️"
459
+ need_send_message = True
460
+ has_link = True
461
+ startTime = None
462
+ # endTime = datetime.datetime.now()+datetime.timedelta(days=3)
463
+ endTime = None
414
464
  if "title" in data:
415
465
  title = data["title"]
416
466
  if "salesDescription" in data:
417
467
  title = data["salesDescription"]
418
468
  if "salesOwner" in data:
419
- title = data["salesOwner"]
469
+ salesOwner = data["salesOwner"]
420
470
  if "platform" in data:
421
471
  platform = data["platform"]
422
- patternModel = "INCLUDE_MATCH"
472
+
423
473
  if "patternModel" in data:
424
474
  patternModel = data["patternModel"]
425
- keywordValidInLive = True
426
- keywordValidAfterLive =False
475
+
427
476
  if "keywordValidInLive" in data:
428
477
  keywordValidInLive = data["keywordValidInLive"]
429
478
  if "keywordValidAfterLive" in data:
430
479
  keywordValidAfterLive = data["keywordValidAfterLive"]
431
- autoNotifyPayEnable = False
432
- autoNotifyPayMessage = ""
433
- autoNotifyPayButton = ""
480
+
434
481
  if "autoNotifyPayEnable" in data:
435
482
  autoNotifyPayEnable = data["autoNotifyPayEnable"]
436
483
  if "autoNotifyPayMessage" in data:
437
484
  autoNotifyPayMessage = data["autoNotifyPayMessage"]
438
485
  if "autoNotifyPayButton" in data:
439
486
  autoNotifyPayButton = data["autoNotifyPayButton"]
440
- stockEnable = False
441
- stockIime = None
487
+ if "autoNotifyPayTime" in data:
488
+ autoNotifyPayTime = data["autoNotifyPayTime"]
489
+
442
490
  if "stockEnable" in data:
443
491
  stockEnable = data["stockEnable"]
444
492
  if "stockIime" in data:
445
493
  stockIime = data["stockIime"]
446
- lowOfQuantityEnable = False
447
- lowOfQuantitySound = False
448
- lowOfQuantityQuantity = "1"
494
+
449
495
  if "lowOfQuantityEnable" in data:
450
496
  lowOfQuantityEnable = data["lowOfQuantityEnable"]
451
497
  if "lowOfQuantitySound" in data:
@@ -453,15 +499,6 @@ def create_live(data):
453
499
  if "lowOfQuantityQuantity" in data:
454
500
  lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
455
501
 
456
- has_interaction_message = ""
457
- has_interaction_message_button = ""
458
- no_interaction_message_first = ""
459
- second_message = ""
460
- first_message_button = ""
461
- second_message_button = " ️"
462
- need_send_message = True
463
- # message_button = "立即结帐️"
464
- has_link = True
465
502
  if "has_interaction_message" in data:
466
503
  has_interaction_message = data["has_interaction_message"]
467
504
  if "has_interaction_message_button" in data:
@@ -480,40 +517,126 @@ def create_live(data):
480
517
  # message_button = data["message_button"]
481
518
  if "has_link" in data:
482
519
  has_link = data["has_link"]
483
- platform = platform.upper()
484
- body = {
485
- "sales": {
486
- "title": title,
487
- "salesOwner": salesOwner,
488
- "salesDescription": salesDescription,
489
- "platforms": [
490
- platform
491
- ],
492
- "platformChannels": []
493
- },
494
- "salesConfig": {
495
- "patternModel": {
496
- "patternModel": patternModel,
497
- "keywordValidInLive": keywordValidInLive,
498
- "keywordValidAfterLive": keywordValidAfterLive
499
- },
500
- "autoNotifyPay": {
501
- "enable": autoNotifyPayEnable,
502
- "message": autoNotifyPayMessage,
503
- "button": autoNotifyPayButton
504
- },
505
- "stock": {
506
- "lockStock": stockEnable,
507
- "salesStockLockExpireTime": stockIime
520
+ # platform = platform.upper()
521
+ body = {}
522
+ if platform.lower() in ("fb_group","facebook","instagram"):
523
+ body = {
524
+ "sales": {
525
+ "title": title,
526
+ "salesOwner": salesOwner,
527
+ "salesDescription": salesDescription,
528
+ "platforms": [
529
+ platform
530
+ ],
531
+ "platformChannels": [],
532
+ "startTime": startTime,
533
+ "endTime": endTime
508
534
  },
509
- "lowOfQuantity": {
510
- "enable": lowOfQuantityEnable,
511
- "sound": lowOfQuantitySound,
512
- "quantity": lowOfQuantityQuantity
535
+ "salesConfig": {
536
+ "patternModel": {
537
+ "patternModel": patternModel,
538
+ "keywordValidInLive": keywordValidInLive,
539
+ "keywordValidAfterLive": keywordValidAfterLive
540
+ },
541
+ "autoNotifyPay": {
542
+ "enable": autoNotifyPayEnable,
543
+ "message": autoNotifyPayMessage,
544
+ "button": autoNotifyPayButton
545
+ },
546
+ "stock": {
547
+ "lockStock": stockEnable,
548
+ "salesStockLockExpireTime": stockIime
549
+ },
550
+ "lowOfQuantity": {
551
+ "enable": lowOfQuantityEnable,
552
+ "sound": lowOfQuantitySound,
553
+ "quantity": lowOfQuantityQuantity
554
+ }
555
+ },
556
+ "postConfigMap": {
557
+ platform: {
558
+ "message": {
559
+ "needSendMessage": need_send_message,
560
+ "hasInteractionMessage": {
561
+ "firstMessageTemplate": {
562
+ "topMessage": has_interaction_message
563
+ },
564
+ "messageButton": has_interaction_message_button
565
+ },
566
+ "hasLink": has_link,
567
+ "noInteractionMessage": {
568
+ "firstMessageTemplate": {
569
+ "topMessage": no_interaction_message_first
570
+ },
571
+ "firstMessageButton": first_message_button,
572
+ "secondMessageTemplate": {
573
+ "topMessage": second_message
574
+ },
575
+ "secondMessageButton": second_message_button
576
+ },
577
+ "messageType": "MESSAGE"
578
+ }
579
+ }
580
+ }
513
581
  }
582
+ elif platform in ("pl&fb" ,"obc&fb") :
583
+ platformSubType = platform.split("&")[0].upper()
584
+ data["platform"] = "FACEBOOK"
585
+ res = get_channel(data)
586
+ # expireTime = res["data"][0]["expireTime"]
587
+ # expireTimeTimestamp = res["data"][0]["expireTimeTimestamp"]
588
+ # validToken = res["data"][0]["validToken"]
589
+ # validScope = res["data"][0]["validScope"]
590
+ # oneTimeNotifyStatus = res["data"][0]["oneTimeNotifyStatus"]
591
+ # mainChannel = res["data"][0]["mainChannel"]
592
+ # platformChannelAvatar = res["data"][0]["platformChannelAvatar"]
593
+ # platformChannelId = res["data"][0]["platformChannelId"]
594
+ # parentChannelId = res["data"][0]["parentChannelId"]
595
+ # groupId = res["data"][0]["groupId"]
596
+ # platformChannelName = res["data"][0]["platformChannelName"]
597
+ # privacy = res["data"][0]["privacy"]
598
+ # customerAuthLink = res["data"][0]["customerAuthLink"]
599
+ # subscribedStatus = res["data"][0]["subscribedStatus"]
600
+ body = {
601
+ "sales": {
602
+ "title": title,
603
+ "salesOwner": salesOwner,
604
+ "salesDescription": salesDescription,
605
+ "platforms": [
606
+ "SHOPLINE",
607
+ "FACEBOOK"
608
+ ],
609
+ "platformSubType": platformSubType,
610
+ "platformChannels": [
611
+ res["data"][0]
612
+ ],
613
+ "startTime":startTime ,
614
+ "endTime": endTime
615
+ },
616
+ "salesConfig": {
617
+ "patternModel": {
618
+ "patternModel": patternModel,
619
+ "keywordValidInLive": keywordValidInLive,
620
+ "keywordValidAfterLive": keywordValidAfterLive
621
+ },
622
+ "autoNotifyPay": {
623
+ "enable": autoNotifyPayEnable,
624
+ "message": autoNotifyPayMessage,
625
+ "button": autoNotifyPayButton,
626
+ "notifyTime": autoNotifyPayTime
627
+ },
628
+ "stock": {
629
+ "lockStock": stockEnable,
630
+ "salesStockLockExpireTime": stockIime
631
+ },
632
+ "lowOfQuantity": {
633
+ "enable": lowOfQuantityEnable,
634
+ "sound": lowOfQuantitySound,
635
+ "quantity": lowOfQuantityQuantity
636
+ }
514
637
  },
515
638
  "postConfigMap": {
516
- platform: {
639
+ "FACEBOOK": {
517
640
  "message": {
518
641
  "needSendMessage": need_send_message,
519
642
  "hasInteractionMessage": {
@@ -528,17 +651,41 @@ def create_live(data):
528
651
  "topMessage": no_interaction_message_first
529
652
  },
530
653
  "firstMessageButton": first_message_button,
654
+ "secondMessageButton": second_message_button,
531
655
  "secondMessageTemplate": {
532
656
  "topMessage": second_message
657
+ }
658
+ },
659
+ "messageType": "MESSAGE"
660
+ }
661
+ },
662
+ "SHOPLINE": {
663
+ "message": {
664
+ "needSendMessage": need_send_message,
665
+ "hasInteractionMessage": {
666
+ "firstMessageTemplate": {
667
+ "topMessage": has_interaction_message
533
668
  },
534
- "secondMessageButton": second_message_button
669
+ "messageButton": has_interaction_message_button
670
+ },
671
+ "hasLink": has_link,
672
+ "noInteractionMessage": {
673
+ "firstMessageTemplate": {
674
+ "topMessage": no_interaction_message_first
675
+ },
676
+ "firstMessageButton": first_message_button,
677
+ "secondMessageButton": second_message_button,
678
+ "secondMessageTemplate": {
679
+ "topMessage": second_message
680
+ }
535
681
  },
536
682
  "messageType": "MESSAGE"
683
+ }
537
684
  }
538
685
  }
539
686
  }
540
- }
541
687
  response = requests.post(url,headers=headers,json=body).json()
688
+ print(json.dumps(body))
542
689
  print(response)
543
690
  sales_id = response["data"]["sales"]["id"]
544
691
  return sales_id
@@ -581,7 +728,41 @@ def edit_live_info(data):
581
728
  title = "接口编辑的直播活动名称%d" % stamp
582
729
  salesDescription = "接口编辑的直播活动介绍%d" % stamp
583
730
  salesOwner = "接口编辑的直播主%d" % stamp
731
+ patternModel = "INCLUDE_MATCH"
732
+ keywordValidInLive = True
733
+ keywordValidAfterLive = False
734
+ autoNotifyPayEnable = False
735
+ autoNotifyPayMessage = ""
736
+ autoNotifyPayButton = ""
737
+ autoNotifyPayTime = None
738
+ stockEnable = False
739
+ stockPreTime = None
740
+ stockExpireTime = None
741
+ lowOfQuantityEnable = False
742
+ lowOfQuantitySound = False
743
+ lowOfQuantityQuantity = "1"
744
+ has_interaction_message = ""
745
+ has_interaction_message_button = ""
746
+ no_interaction_message_first = ""
747
+ second_message = ""
748
+ first_message_button = ""
749
+ second_message_button = " ️"
750
+ need_send_message = True
751
+ has_link = True
752
+ commentIntent = True
753
+ #无库存讯息
754
+ allOutOfStockMessage = ""
755
+ allOutOfStockEnable = True
756
+ #欢迎讯息
757
+ welcomeMessage = ""
758
+ welcomeMessageEnable = True
759
+ # 欢迎comment
760
+ welcomeComment = ""
761
+ welcomeCommentEnable = True
762
+ productRecommendMessage = ""
763
+ productRecommendMessageEnable = True
584
764
  platform = "FB_GROUP"
765
+
585
766
  if "title" in data:
586
767
  title = data["title"]
587
768
  if "salesDescription" in data:
@@ -590,19 +771,13 @@ def edit_live_info(data):
590
771
  title = data["salesOwner"]
591
772
  if "platform" in data:
592
773
  platform = data["platform"]
593
- patternModel = "INCLUDE_MATCH"
594
774
  if "patternModel" in data:
595
775
  patternModel = data["patternModel"]
596
- keywordValidInLive = True
597
- keywordValidAfterLive = False
598
776
  if "keywordValidInLive" in data:
599
777
  keywordValidInLive = data["keywordValidInLive"]
600
778
  if "keywordValidAfterLive" in data:
601
779
  keywordValidAfterLive = data["keywordValidAfterLive"]
602
- autoNotifyPayEnable = False
603
- autoNotifyPayMessage = ""
604
- autoNotifyPayButton = ""
605
- autoNotifyPayTime = None
780
+
606
781
  if "autoNotifyPayEnable" in data:
607
782
  autoNotifyPayEnable = data["autoNotifyPayEnable"]
608
783
  if "autoNotifyPayMessage" in data:
@@ -612,17 +787,11 @@ def edit_live_info(data):
612
787
  if "autoNotifyPayTime" in data:
613
788
  autoNotifyPayTime = data["autoNotifyPayTime"]
614
789
 
615
- stockEnable = False
616
- stockPreTime = None
617
- stockExpireTime = None
618
790
  if "stockEnable" in data:
619
791
  stockEnable = data["stockEnable"]
620
792
  if "stockExpireTime" in data:
621
793
  stockExpireTime = data["stockExpireTime"]
622
794
 
623
- lowOfQuantityEnable = False
624
- lowOfQuantitySound = False
625
- lowOfQuantityQuantity = "1"
626
795
  if "lowOfQuantityEnable" in data:
627
796
  lowOfQuantityEnable = data["lowOfQuantityEnable"]
628
797
  if "lowOfQuantitySound" in data:
@@ -630,6 +799,188 @@ def edit_live_info(data):
630
799
  if "lowOfQuantityQuantity" in data:
631
800
  lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
632
801
 
802
+ if "has_interaction_message" in data:
803
+ has_interaction_message = data["has_interaction_message"]
804
+ if "has_interaction_message_button" in data:
805
+ has_interaction_message_button = data["has_interaction_message_button"]
806
+ if "no_interaction_message_first" in data:
807
+ no_interaction_message_first = data["no_interaction_message_first"]
808
+ if "first_message_button" in data:
809
+ first_message_button = data["first_message_button"]
810
+ if "second_message" in data:
811
+ second_message = data["second_message"]
812
+ if "second_message_button" in data:
813
+ second_message_button = data["second_message_button"]
814
+ if "need_send_message" in data:
815
+ need_send_message = data["need_send_message"]
816
+ # if "message_button" in data:
817
+ # message_button = data["message_button"]
818
+ if "has_link" in data:
819
+ has_link = data["has_link"]
820
+ if "commentIntent" in data:
821
+ commentIntent = data["commentIntent"]
822
+
823
+ if "allOutOfStockMessage" in data:
824
+ allOutOfStockMessage = data["allOutOfStockMessage"]
825
+ if "allOutOfStockEnable" in data:
826
+ allOutOfStockEnable = data["allOutOfStockEnable"]
827
+
828
+ if "welcomeMessage" in data:
829
+ welcomeMessage = data["welcomeMessage"]
830
+ if "welcomeMessageEnable" in data:
831
+ welcomeMessageEnable = data["welcomeMessageEnable"]
832
+
833
+ if "welcomeComment" in data:
834
+ welcomeComment = data["welcomeComment"]
835
+ if "welcomeCommentEnable" in data:
836
+ welcomeCommentEnable = data["welcomeCommentEnable"]
837
+
838
+ if "productRecommendMessage" in data:
839
+ productRecommendMessage = data["productRecommendMessage"]
840
+ if "productRecommendMessageEnable" in data:
841
+ productRecommendMessageEnable = data["productRecommendMessageEnable"]
842
+
843
+ body = {}
844
+ if platform.upper()=="FB_GROUP":
845
+ body = {
846
+ "sales": {
847
+ "title": title,
848
+ "salesOwner": salesOwner,
849
+ "salesDescription": salesDescription,
850
+ "platforms": [
851
+ platform
852
+ ],
853
+ "platformSubType": "",
854
+ "platformChannels": [],
855
+ "archivedStreamVisibleTime": None
856
+ },
857
+ "salesConfig": {
858
+ "patternModel": {
859
+ "patternModel": patternModel,
860
+ "keywordValidInLive": keywordValidInLive,
861
+ "keywordValidAfterLive": keywordValidAfterLive
862
+ },
863
+ "autoNotifyPay": {
864
+ "enable": autoNotifyPayEnable,
865
+ "notifyTime": autoNotifyPayTime,
866
+ "message": autoNotifyPayMessage,
867
+ "button": autoNotifyPayButton
868
+ },
869
+ "stock": {
870
+ "lockStock": stockEnable,
871
+ "salesStockLockExpireTime": stockExpireTime,
872
+ "salesStockLockPreTime": stockPreTime
873
+ },
874
+ "commentIntent": {
875
+ "enabled": commentIntent
876
+ },
877
+ "variationToggleOn": {
878
+ "enable": True
879
+ },
880
+ "productSort": {
881
+ "productSort": "NEW_TO_OLD"
882
+ },
883
+ "lowOfQuantity": {
884
+ "enable": lowOfQuantityEnable,
885
+ "sound": lowOfQuantitySound,
886
+ "quantity": lowOfQuantityQuantity
887
+ },
888
+ "notice": None,
889
+ "frontLive": None,
890
+ "liveViewSdk": None,
891
+ "runningLightsConfig": None,
892
+ "fbGroupSettingConfig": {
893
+ "scGroupPmCommentId": True,
894
+ "scGroupWebhook": True
895
+ },
896
+ "productPinningStyle": None
897
+ },
898
+ "postConfigMap": {
899
+ platform: {
900
+ "message": {
901
+ "needSendMessage": need_send_message,
902
+ "hasInteractionMessage": {
903
+ "firstMessageTemplate": {
904
+ "topMessage": has_interaction_message
905
+ },
906
+ "messageButton": has_interaction_message_button
907
+ },
908
+ "hasLink": has_link,
909
+ "noInteractionMessage": {
910
+ "firstMessageTemplate": {
911
+ "topMessage": no_interaction_message_first
912
+ },
913
+ "firstMessageButton": first_message_button,
914
+ "secondMessageTemplate": {
915
+ "topMessage": second_message
916
+ },
917
+ "secondMessageButton": second_message_button
918
+ },
919
+ "messageType": "MESSAGE"
920
+ },
921
+ "allOutOfStockMessage": {
922
+ "needSendMessage": allOutOfStockEnable,
923
+ "hasInteractionMessage": {
924
+ "firstMessageTemplate": {
925
+ "topMessage": allOutOfStockMessage
926
+ }
927
+ },
928
+ "messageType": "ALL_OUT_OF_STOCK"
929
+ },
930
+ "welcomeMessage": {
931
+ "needSendMessage": welcomeMessageEnable,
932
+ "hasInteractionMessage": {
933
+ "firstMessageTemplate": {
934
+ "topMessage": welcomeMessage
935
+ }
936
+ },
937
+ "messageType": "WELCOME_MESSAGE"
938
+ },
939
+ "productRecommendMessage": {
940
+ "needSendMessage": productRecommendMessageEnable,
941
+ "hasInteractionMessage": {
942
+ "firstMessageTemplate": {
943
+ "message": productRecommendMessage
944
+ }
945
+ },
946
+ "messageType": "PRODUCT_RECOMMEND_FB_MESSAGE"
947
+ },
948
+ "welcomeMessageComment": {
949
+ "needSendMessage": welcomeCommentEnable,
950
+ "hasInteractionMessage": {
951
+ "firstMessageTemplate": {
952
+ "topMessage": welcomeComment
953
+ }
954
+ },
955
+ "messageType": "WELCOME_MESSAGE_COMMENT"
956
+ },
957
+ "showNumberOfViewers": None,
958
+ "showShareButton": None
959
+ }
960
+ }
961
+ }
962
+
963
+ response = requests.put(url,headers=headers,json=body).json()
964
+ return response
965
+
966
+ def save_global_config(data):
967
+ "保存直播间通用配置"
968
+ env = data["env"]
969
+ headers = data["headers"]
970
+ url = "%s/api/posts/post/sales/global/LIVE"%env
971
+ patternModel = "INCLUDE_MATCH"
972
+ keywordValidInLive = True
973
+ keywordValidAfterLive = False
974
+ autoNotifyPayEnable = False
975
+ autoNotifyPayMessage = ""
976
+ autoNotifyPayButton = ""
977
+ autoNotifyPayTime = None
978
+ stockEnable = False
979
+ stockPreTime = None
980
+ stockExpireTime = None
981
+ lowOfQuantityEnable = False
982
+ lowOfQuantitySound = False
983
+ lowOfQuantityQuantity = "1"
633
984
  has_interaction_message = ""
634
985
  has_interaction_message_button = ""
635
986
  no_interaction_message_first = ""
@@ -637,8 +988,62 @@ def edit_live_info(data):
637
988
  first_message_button = ""
638
989
  second_message_button = " ️"
639
990
  need_send_message = True
640
- # message_button = "立即结帐️"
641
991
  has_link = True
992
+ commentIntent = True
993
+ # 无库存讯息
994
+ allOutOfStockMessage = ""
995
+ allOutOfStockEnable = True
996
+ # 欢迎讯息
997
+ welcomeMessage = ""
998
+ welcomeMessageEnable = True
999
+ # 欢迎comment
1000
+ welcomeComment = ""
1001
+ welcomeCommentEnable = True
1002
+ #推荐讯息
1003
+ fbProductRecommendMessage = ""
1004
+ igProductRecommendMessage = ""
1005
+ slProductRecommendMessage = ""
1006
+ # productRecommendMessageEnable = True
1007
+ #视频观看人数
1008
+ show_number = True
1009
+ show_share = True
1010
+
1011
+ if "title" in data:
1012
+ title = data["title"]
1013
+ if "salesDescription" in data:
1014
+ title = data["salesDescription"]
1015
+ if "salesOwner" in data:
1016
+ title = data["salesOwner"]
1017
+ if "platform" in data:
1018
+ platform = data["platform"]
1019
+ if "patternModel" in data:
1020
+ patternModel = data["patternModel"]
1021
+ if "keywordValidInLive" in data:
1022
+ keywordValidInLive = data["keywordValidInLive"]
1023
+ if "keywordValidAfterLive" in data:
1024
+ keywordValidAfterLive = data["keywordValidAfterLive"]
1025
+
1026
+ if "autoNotifyPayEnable" in data:
1027
+ autoNotifyPayEnable = data["autoNotifyPayEnable"]
1028
+ if "autoNotifyPayMessage" in data:
1029
+ autoNotifyPayMessage = data["autoNotifyPayMessage"]
1030
+ if "autoNotifyPayButton" in data:
1031
+ autoNotifyPayButton = data["autoNotifyPayButton"]
1032
+ if "autoNotifyPayTime" in data:
1033
+ autoNotifyPayTime = data["autoNotifyPayTime"]
1034
+
1035
+ if "stockEnable" in data:
1036
+ stockEnable = data["stockEnable"]
1037
+ if "stockExpireTime" in data:
1038
+ stockExpireTime = data["stockExpireTime"]
1039
+
1040
+ if "lowOfQuantityEnable" in data:
1041
+ lowOfQuantityEnable = data["lowOfQuantityEnable"]
1042
+ if "lowOfQuantitySound" in data:
1043
+ lowOfQuantitySound = data["lowOfQuantitySound"]
1044
+ if "lowOfQuantityQuantity" in data:
1045
+ lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
1046
+
642
1047
  if "has_interaction_message" in data:
643
1048
  has_interaction_message = data["has_interaction_message"]
644
1049
  if "has_interaction_message_button" in data:
@@ -657,98 +1062,65 @@ def edit_live_info(data):
657
1062
  # message_button = data["message_button"]
658
1063
  if "has_link" in data:
659
1064
  has_link = data["has_link"]
660
-
661
- commentIntent = True
662
1065
  if "commentIntent" in data:
663
1066
  commentIntent = data["commentIntent"]
664
1067
 
665
- #无库存讯息
666
- allOutOfStockMessage = ""
667
- allOutOfStockEnable = True
668
1068
  if "allOutOfStockMessage" in data:
669
1069
  allOutOfStockMessage = data["allOutOfStockMessage"]
670
1070
  if "allOutOfStockEnable" in data:
671
1071
  allOutOfStockEnable = data["allOutOfStockEnable"]
672
- #欢迎讯息
673
- welcomeMessage = ""
674
- welcomeMessageEnable = True
1072
+
675
1073
  if "welcomeMessage" in data:
676
1074
  welcomeMessage = data["welcomeMessage"]
677
1075
  if "welcomeMessageEnable" in data:
678
1076
  welcomeMessageEnable = data["welcomeMessageEnable"]
679
- # 欢迎comment
680
- welcomeComment = ""
681
- welcomeCommentEnable = True
1077
+
682
1078
  if "welcomeComment" in data:
683
1079
  welcomeComment = data["welcomeComment"]
684
1080
  if "welcomeCommentEnable" in data:
685
1081
  welcomeCommentEnable = data["welcomeCommentEnable"]
686
- productRecommendMessage = ""
687
- productRecommendMessageEnable = True
688
- if "productRecommendMessage" in data:
689
- productRecommendMessage = data["productRecommendMessage"]
690
- if "productRecommendMessageEnable" in data:
691
- productRecommendMessageEnable = data["productRecommendMessageEnable"]
692
1082
 
1083
+ if "show_number" in data:
1084
+ show_number = data["show_number"]
1085
+ if "show_share" in data:
1086
+ show_share = data["show_share"]
1087
+
1088
+ if "fbProductRecommendMessage" in data:
1089
+ fbProductRecommendMessage = data["fbProductRecommendMessage"]
1090
+ if "igProductRecommendMessage" in data:
1091
+ igProductRecommendMessage = data["igProductRecommendMessage"]
1092
+ if "slProductRecommendMessage" in data:
1093
+ slProductRecommendMessage = data["slProductRecommendMessage"]
693
1094
 
694
1095
 
695
- platform = platform.upper()
696
1096
  body = {
697
- "sales": {
698
- "title": title,
699
- "salesOwner": salesOwner,
700
- "salesDescription": salesDescription,
701
- "platforms": [
702
- platform
703
- ],
704
- "platformSubType": "",
705
- "platformChannels": [],
706
- "archivedStreamVisibleTime": None
707
- },
708
- "salesConfig": {
709
- "patternModel": {
710
- "patternModel": patternModel,
711
- "keywordValidInLive": keywordValidInLive,
712
- "keywordValidAfterLive": keywordValidAfterLive
713
- },
714
- "autoNotifyPay": {
715
- "enable": autoNotifyPayEnable,
716
- "notifyTime": autoNotifyPayTime,
717
- "message": autoNotifyPayMessage,
718
- "button": autoNotifyPayButton
719
- },
720
- "stock": {
721
- "lockStock": stockEnable,
722
- "salesStockLockExpireTime": stockExpireTime,
723
- "salesStockLockPreTime": stockPreTime
724
- },
725
- "commentIntent": {
726
- "enabled": commentIntent
727
- },
728
- "variationToggleOn": {
729
- "enable": True
730
- },
731
- "productSort": {
732
- "productSort": "NEW_TO_OLD"
1097
+ "saveList": [
1098
+ {
1099
+ "configKey": "PATTERN_MODEL",
1100
+ "configValue": {
1101
+ "patternModel": patternModel,
1102
+ "keywordValidInLive": keywordValidInLive,
1103
+ "keywordValidAfterLive": keywordValidAfterLive
1104
+ }
733
1105
  },
734
- "lowOfQuantity": {
735
- "enable": lowOfQuantityEnable,
736
- "sound": lowOfQuantitySound,
737
- "quantity": lowOfQuantityQuantity
1106
+ {
1107
+ "configKey": "STOCK",
1108
+ "configValue": {
1109
+ "lockStock": stockEnable,
1110
+ "salesStockLockExpireTime": stockExpireTime
1111
+ }
738
1112
  },
739
- "notice": None,
740
- "frontLive": None,
741
- "liveViewSdk": None,
742
- "runningLightsConfig": None,
743
- "fbGroupSettingConfig": {
744
- "scGroupPmCommentId": True,
745
- "scGroupWebhook": True
1113
+ {
1114
+ "configKey": "LOW_OF_QUANTITY",
1115
+ "configValue": {
1116
+ "enable": lowOfQuantityEnable,
1117
+ "sound": lowOfQuantitySound,
1118
+ "quantity": lowOfQuantityQuantity
1119
+ }
746
1120
  },
747
- "productPinningStyle": None
748
- },
749
- "postConfigMap": {
750
- platform: {
751
- "message": {
1121
+ {
1122
+ "configKey": "MESSAGE",
1123
+ "configValue": {
752
1124
  "needSendMessage": need_send_message,
753
1125
  "hasInteractionMessage": {
754
1126
  "firstMessageTemplate": {
@@ -768,58 +1140,140 @@ def edit_live_info(data):
768
1140
  "secondMessageButton": second_message_button
769
1141
  },
770
1142
  "messageType": "MESSAGE"
771
- },
772
- "allOutOfStockMessage": {
773
- "needSendMessage": allOutOfStockEnable,
1143
+ }
1144
+ },
1145
+ {
1146
+ "configKey": "WELCOME_MESSAGE",
1147
+ "configValue": {
774
1148
  "hasInteractionMessage": {
775
1149
  "firstMessageTemplate": {
776
- "topMessage": allOutOfStockMessage
1150
+ "topMessage": welcomeMessage
777
1151
  }
778
1152
  },
779
- "messageType": "ALL_OUT_OF_STOCK"
780
- },
781
- "welcomeMessage": {
782
1153
  "needSendMessage": welcomeMessageEnable,
1154
+ "messageType": "WELCOME_MESSAGE"
1155
+ }
1156
+ },
1157
+ {
1158
+ "configKey": "WELCOME_MESSAGE_COMMENT",
1159
+ "configValue": {
783
1160
  "hasInteractionMessage": {
784
1161
  "firstMessageTemplate": {
785
- "topMessage": welcomeMessage
1162
+ "topMessage": welcomeComment
786
1163
  }
787
1164
  },
788
- "messageType": "WELCOME_MESSAGE"
789
- },
790
- "productRecommendMessage": {
791
- "needSendMessage": productRecommendMessageEnable,
1165
+ "needSendMessage": welcomeCommentEnable,
1166
+ "messageType": "WELCOME_MESSAGE_COMMENT"
1167
+ }
1168
+ },
1169
+ {
1170
+ "configKey": "PRODUCT_RECOMMEND_FB_MESSAGE",
1171
+ "configValue": {
792
1172
  "hasInteractionMessage": {
793
1173
  "firstMessageTemplate": {
794
- "message": productRecommendMessage
1174
+ "message": fbProductRecommendMessage
795
1175
  }
796
1176
  },
797
1177
  "messageType": "PRODUCT_RECOMMEND_FB_MESSAGE"
798
- },
799
- "welcomeMessageComment": {
800
- "needSendMessage": welcomeCommentEnable,
1178
+ }
1179
+ },
1180
+ {
1181
+ "configKey": "PRODUCT_RECOMMEND_IG_MESSAGE",
1182
+ "configValue": {
801
1183
  "hasInteractionMessage": {
802
1184
  "firstMessageTemplate": {
803
- "topMessage": welcomeComment
1185
+ "message": igProductRecommendMessage
804
1186
  }
805
1187
  },
806
- "messageType": "WELCOME_MESSAGE_COMMENT"
807
- },
808
- "showNumberOfViewers": None,
809
- "showShareButton": None
810
- }
1188
+ "messageType": "PRODUCT_RECOMMEND_IG_MESSAGE"
1189
+ }
1190
+ },
1191
+ {
1192
+ "configKey": "PRODUCT_RECOMMEND_SHOP_LINE_MESSAGE",
1193
+ "configValue": {
1194
+ "hasInteractionMessage": {
1195
+ "firstMessageTemplate": {
1196
+ "message": slProductRecommendMessage
1197
+ }
1198
+ },
1199
+ "messageType": "PRODUCT_RECOMMEND_SHOP_LINE_MESSAGE"
1200
+ }
1201
+ },
1202
+ {
1203
+ "configKey": "ALL_OUT_OF_STOCK",
1204
+ "configValue": {
1205
+ "hasInteractionMessage": {
1206
+ "firstMessageTemplate": {
1207
+ "topMessage": allOutOfStockMessage
1208
+ }
1209
+ },
1210
+ "needSendMessage": allOutOfStockEnable,
1211
+ "messageType": "ALL_OUT_OF_STOCK"
1212
+ }
1213
+ },
1214
+ {
1215
+ "configKey": "AUTO_NOTIFY_PAY",
1216
+ "configValue": {
1217
+ "enable": autoNotifyPayEnable,
1218
+ "message": autoNotifyPayMessage,
1219
+ "button": autoNotifyPayButton
1220
+ }
1221
+ },
1222
+ {
1223
+ "configKey": "COMMENT_INTENT",
1224
+ "configValue": {
1225
+ "enabled": commentIntent
1226
+ }
1227
+ },
1228
+ {
1229
+ "configKey": "SHOW_NUMBER_OF_VIEWERS",
1230
+ "configValue": {
1231
+ "enabled": show_number
1232
+ }
1233
+ },
1234
+ {
1235
+ "configKey": "SHOW_SHARE_BUTTON",
1236
+ "configValue": {
1237
+ "enabled": show_share
1238
+ }
811
1239
  }
812
- }
813
- response = requests.put(url,headers=headers,json=body).json()
1240
+ ]
1241
+ }
1242
+ response = requests.post(url, headers=headers, json=body).json()
814
1243
  return response
815
1244
 
1245
+ def get_global_config(data):
1246
+ env = data["env"]
1247
+ headers = data["headers"]
1248
+ url = "%s/api/posts/post/sales/global/LIVE" % env
1249
+ response = requests.get(url,headers=headers).json()
1250
+ # print(response)
1251
+ return response
1252
+
1253
+
1254
+
1255
+
1256
+ outOfStock = {
1257
+ "en":"The following product(s) doesn't have enough stock, please select other products, thanks!\n❗️{products}".replace("️{products}","ffddd"),
1258
+ "zh-cn":"以下商品库存不足,请选购其他商品,谢谢!\n❗️{products}".replace("️{products}","ffddd"),
1259
+ "zh-hant":"以下商品庫存不足,請選購其他商品,謝謝!\n❗️{products}".replace("️{products}","ffddd")
1260
+ }
816
1261
 
817
1262
 
818
1263
 
1264
+ def remove_live_product(data):
1265
+ env = data["env"]
1266
+ headers = data["headers"]
1267
+ sales_id = data["sales_id"]
1268
+ product_id = data["product_id"]
1269
+ url = "%s/api/posts/post/sales/%s/product/%s"%(env,sales_id,product_id)
1270
+ response = requests.delete(url,headers=headers).json()
1271
+ return response
1272
+
819
1273
 
820
1274
 
821
1275
 
822
1276
 
823
1277
 
824
1278
  if __name__=="__main__":
825
- pass
1279
+ pass
@@ -1184,6 +1184,7 @@ def modelone_create_single_product(data):
1184
1184
  headers = data["headers"]
1185
1185
  sales_id = data["sales_id"]
1186
1186
  quantity = 1000
1187
+ price = 3
1187
1188
  if "quantity" in data:
1188
1189
  quantity = data["quantity"]
1189
1190
  url = "%s/api/posts/post/sales/%s/product/create" % (env, sales_id)
@@ -1193,8 +1194,10 @@ def modelone_create_single_product(data):
1193
1194
  keyword = "post接口新增商品多规格商品关键字%d" % int(time.time())
1194
1195
  if "keyword" in data:
1195
1196
  keyword = data["keyword"]
1197
+ if "price" in data:
1198
+ price = data["price"]
1196
1199
  body = {"customKey":keyword,"quantity":quantity,"unlimitedQuantity":False,"productName":product_name,
1197
- "imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":3}
1200
+ "imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":price}
1198
1201
  response = requests.post(url,headers=headers,json=body).json()
1199
1202
  # print(body)
1200
1203
  print(response)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.4.3
3
+ Version: 2.4.5
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.4.3',
5
+ version='2.4.5',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),