sc-common-interface 2.4.3__tar.gz → 2.4.4__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.4
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -401,6 +401,17 @@ def end_live(data):
401
401
  response = requests.put(url, headers=headers).json()
402
402
  return response
403
403
 
404
+ def get_channel(data):
405
+ "查询粉丝页信息,用于创建帖文"
406
+ env = data["env"]
407
+ headers = data["headers"]
408
+ platform = data["platform"]
409
+ url = "%s/api/posts/post/sales/multiPlatformChannelList?platformList=%s"%(env,platform.upper())
410
+ response = requests.get(url,headers=headers).json()
411
+ return response
412
+
413
+
414
+
404
415
  def create_live(data):
405
416
  """创建直播,不套用通用配置"""
406
417
  env = data["env"]
@@ -411,6 +422,29 @@ def create_live(data):
411
422
  salesDescription = "接口创建的直播活动介绍%d"%stamp
412
423
  salesOwner = "接口创建的直播主%d"%stamp
413
424
  platform = "FB_GROUP"
425
+ patternModel = "INCLUDE_MATCH"
426
+ keywordValidInLive = True
427
+ keywordValidAfterLive =False
428
+ autoNotifyPayEnable = False
429
+ autoNotifyPayMessage = ""
430
+ autoNotifyPayButton = ""
431
+ autoNotifyPayTime = None
432
+ stockEnable = False
433
+ stockIime = None
434
+ lowOfQuantityEnable = False
435
+ lowOfQuantitySound = False
436
+ lowOfQuantityQuantity = "1"
437
+ has_interaction_message = ""
438
+ has_interaction_message_button = ""
439
+ no_interaction_message_first = ""
440
+ second_message = ""
441
+ first_message_button = ""
442
+ second_message_button = " ️"
443
+ need_send_message = True
444
+ has_link = True
445
+ startTime = None
446
+ # endTime = datetime.datetime.now()+datetime.timedelta(days=3)
447
+ endTime = None
414
448
  if "title" in data:
415
449
  title = data["title"]
416
450
  if "salesDescription" in data:
@@ -419,33 +453,29 @@ def create_live(data):
419
453
  title = data["salesOwner"]
420
454
  if "platform" in data:
421
455
  platform = data["platform"]
422
- patternModel = "INCLUDE_MATCH"
456
+
423
457
  if "patternModel" in data:
424
458
  patternModel = data["patternModel"]
425
- keywordValidInLive = True
426
- keywordValidAfterLive =False
459
+
427
460
  if "keywordValidInLive" in data:
428
461
  keywordValidInLive = data["keywordValidInLive"]
429
462
  if "keywordValidAfterLive" in data:
430
463
  keywordValidAfterLive = data["keywordValidAfterLive"]
431
- autoNotifyPayEnable = False
432
- autoNotifyPayMessage = ""
433
- autoNotifyPayButton = ""
464
+
434
465
  if "autoNotifyPayEnable" in data:
435
466
  autoNotifyPayEnable = data["autoNotifyPayEnable"]
436
467
  if "autoNotifyPayMessage" in data:
437
468
  autoNotifyPayMessage = data["autoNotifyPayMessage"]
438
469
  if "autoNotifyPayButton" in data:
439
470
  autoNotifyPayButton = data["autoNotifyPayButton"]
440
- stockEnable = False
441
- stockIime = None
471
+ if "autoNotifyPayTime" in data:
472
+ autoNotifyPayTime = data["autoNotifyPayTime"]
473
+
442
474
  if "stockEnable" in data:
443
475
  stockEnable = data["stockEnable"]
444
476
  if "stockIime" in data:
445
477
  stockIime = data["stockIime"]
446
- lowOfQuantityEnable = False
447
- lowOfQuantitySound = False
448
- lowOfQuantityQuantity = "1"
478
+
449
479
  if "lowOfQuantityEnable" in data:
450
480
  lowOfQuantityEnable = data["lowOfQuantityEnable"]
451
481
  if "lowOfQuantitySound" in data:
@@ -453,15 +483,6 @@ def create_live(data):
453
483
  if "lowOfQuantityQuantity" in data:
454
484
  lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
455
485
 
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
486
  if "has_interaction_message" in data:
466
487
  has_interaction_message = data["has_interaction_message"]
467
488
  if "has_interaction_message_button" in data:
@@ -480,16 +501,101 @@ def create_live(data):
480
501
  # message_button = data["message_button"]
481
502
  if "has_link" in data:
482
503
  has_link = data["has_link"]
483
- platform = platform.upper()
484
- body = {
504
+ # platform = platform.upper()
505
+ body = {}
506
+ if platform.lower() in ("fb_group","facebook","instagram"):
507
+ body = {
508
+ "sales": {
509
+ "title": title,
510
+ "salesOwner": salesOwner,
511
+ "salesDescription": salesDescription,
512
+ "platforms": [
513
+ platform
514
+ ],
515
+ "platformChannels": [],
516
+ "startTime": startTime,
517
+ "endTime": endTime
518
+ },
519
+ "salesConfig": {
520
+ "patternModel": {
521
+ "patternModel": patternModel,
522
+ "keywordValidInLive": keywordValidInLive,
523
+ "keywordValidAfterLive": keywordValidAfterLive
524
+ },
525
+ "autoNotifyPay": {
526
+ "enable": autoNotifyPayEnable,
527
+ "message": autoNotifyPayMessage,
528
+ "button": autoNotifyPayButton
529
+ },
530
+ "stock": {
531
+ "lockStock": stockEnable,
532
+ "salesStockLockExpireTime": stockIime
533
+ },
534
+ "lowOfQuantity": {
535
+ "enable": lowOfQuantityEnable,
536
+ "sound": lowOfQuantitySound,
537
+ "quantity": lowOfQuantityQuantity
538
+ }
539
+ },
540
+ "postConfigMap": {
541
+ platform: {
542
+ "message": {
543
+ "needSendMessage": need_send_message,
544
+ "hasInteractionMessage": {
545
+ "firstMessageTemplate": {
546
+ "topMessage": has_interaction_message
547
+ },
548
+ "messageButton": has_interaction_message_button
549
+ },
550
+ "hasLink": has_link,
551
+ "noInteractionMessage": {
552
+ "firstMessageTemplate": {
553
+ "topMessage": no_interaction_message_first
554
+ },
555
+ "firstMessageButton": first_message_button,
556
+ "secondMessageTemplate": {
557
+ "topMessage": second_message
558
+ },
559
+ "secondMessageButton": second_message_button
560
+ },
561
+ "messageType": "MESSAGE"
562
+ }
563
+ }
564
+ }
565
+ }
566
+ elif platform in ("pl&fb" ,"obc&fb") :
567
+ platformSubType = platform.split("&")[0].upper()
568
+ data["platform"] = "FACEBOOK"
569
+ res = get_channel(data)
570
+ # expireTime = res["data"][0]["expireTime"]
571
+ # expireTimeTimestamp = res["data"][0]["expireTimeTimestamp"]
572
+ # validToken = res["data"][0]["validToken"]
573
+ # validScope = res["data"][0]["validScope"]
574
+ # oneTimeNotifyStatus = res["data"][0]["oneTimeNotifyStatus"]
575
+ # mainChannel = res["data"][0]["mainChannel"]
576
+ # platformChannelAvatar = res["data"][0]["platformChannelAvatar"]
577
+ # platformChannelId = res["data"][0]["platformChannelId"]
578
+ # parentChannelId = res["data"][0]["parentChannelId"]
579
+ # groupId = res["data"][0]["groupId"]
580
+ # platformChannelName = res["data"][0]["platformChannelName"]
581
+ # privacy = res["data"][0]["privacy"]
582
+ # customerAuthLink = res["data"][0]["customerAuthLink"]
583
+ # subscribedStatus = res["data"][0]["subscribedStatus"]
584
+ body = {
485
585
  "sales": {
486
586
  "title": title,
487
587
  "salesOwner": salesOwner,
488
588
  "salesDescription": salesDescription,
489
589
  "platforms": [
490
- platform
590
+ "SHOPLINE",
591
+ "FACEBOOK"
491
592
  ],
492
- "platformChannels": []
593
+ "platformSubType": platformSubType,
594
+ "platformChannels": [
595
+ res["data"][0]
596
+ ],
597
+ "startTime":startTime ,
598
+ "endTime": endTime
493
599
  },
494
600
  "salesConfig": {
495
601
  "patternModel": {
@@ -500,7 +606,8 @@ def create_live(data):
500
606
  "autoNotifyPay": {
501
607
  "enable": autoNotifyPayEnable,
502
608
  "message": autoNotifyPayMessage,
503
- "button": autoNotifyPayButton
609
+ "button": autoNotifyPayButton,
610
+ "notifyTime": autoNotifyPayTime
504
611
  },
505
612
  "stock": {
506
613
  "lockStock": stockEnable,
@@ -511,34 +618,58 @@ def create_live(data):
511
618
  "sound": lowOfQuantitySound,
512
619
  "quantity": lowOfQuantityQuantity
513
620
  }
621
+ },
622
+ "postConfigMap": {
623
+ "FACEBOOK": {
624
+ "message": {
625
+ "needSendMessage": need_send_message,
626
+ "hasInteractionMessage": {
627
+ "firstMessageTemplate": {
628
+ "topMessage": has_interaction_message
629
+ },
630
+ "messageButton": has_interaction_message_button
631
+ },
632
+ "hasLink": has_link,
633
+ "noInteractionMessage": {
634
+ "firstMessageTemplate": {
635
+ "topMessage": no_interaction_message_first
636
+ },
637
+ "firstMessageButton": first_message_button,
638
+ "secondMessageButton": second_message_button,
639
+ "secondMessageTemplate": {
640
+ "topMessage": second_message
641
+ }
642
+ },
643
+ "messageType": "MESSAGE"
644
+ }
514
645
  },
515
- "postConfigMap": {
516
- platform: {
517
- "message": {
518
- "needSendMessage": need_send_message,
519
- "hasInteractionMessage": {
520
- "firstMessageTemplate": {
521
- "topMessage": has_interaction_message
522
- },
523
- "messageButton": has_interaction_message_button
646
+ "SHOPLINE": {
647
+ "message": {
648
+ "needSendMessage": need_send_message,
649
+ "hasInteractionMessage": {
650
+ "firstMessageTemplate": {
651
+ "topMessage": has_interaction_message
524
652
  },
525
- "hasLink": has_link,
526
- "noInteractionMessage": {
527
- "firstMessageTemplate": {
528
- "topMessage": no_interaction_message_first
529
- },
530
- "firstMessageButton": first_message_button,
531
- "secondMessageTemplate": {
532
- "topMessage": second_message
533
- },
534
- "secondMessageButton": second_message_button
653
+ "messageButton": has_interaction_message_button
654
+ },
655
+ "hasLink": has_link,
656
+ "noInteractionMessage": {
657
+ "firstMessageTemplate": {
658
+ "topMessage": no_interaction_message_first
535
659
  },
536
- "messageType": "MESSAGE"
660
+ "firstMessageButton": first_message_button,
661
+ "secondMessageButton": second_message_button,
662
+ "secondMessageTemplate": {
663
+ "topMessage": second_message
664
+ }
665
+ },
666
+ "messageType": "MESSAGE"
537
667
  }
538
668
  }
539
669
  }
540
670
  }
541
671
  response = requests.post(url,headers=headers,json=body).json()
672
+ print(json.dumps(body))
542
673
  print(response)
543
674
  sales_id = response["data"]["sales"]["id"]
544
675
  return sales_id
@@ -581,7 +712,41 @@ def edit_live_info(data):
581
712
  title = "接口编辑的直播活动名称%d" % stamp
582
713
  salesDescription = "接口编辑的直播活动介绍%d" % stamp
583
714
  salesOwner = "接口编辑的直播主%d" % stamp
715
+ patternModel = "INCLUDE_MATCH"
716
+ keywordValidInLive = True
717
+ keywordValidAfterLive = False
718
+ autoNotifyPayEnable = False
719
+ autoNotifyPayMessage = ""
720
+ autoNotifyPayButton = ""
721
+ autoNotifyPayTime = None
722
+ stockEnable = False
723
+ stockPreTime = None
724
+ stockExpireTime = None
725
+ lowOfQuantityEnable = False
726
+ lowOfQuantitySound = False
727
+ lowOfQuantityQuantity = "1"
728
+ has_interaction_message = ""
729
+ has_interaction_message_button = ""
730
+ no_interaction_message_first = ""
731
+ second_message = ""
732
+ first_message_button = ""
733
+ second_message_button = " ️"
734
+ need_send_message = True
735
+ has_link = True
736
+ commentIntent = True
737
+ #无库存讯息
738
+ allOutOfStockMessage = ""
739
+ allOutOfStockEnable = True
740
+ #欢迎讯息
741
+ welcomeMessage = ""
742
+ welcomeMessageEnable = True
743
+ # 欢迎comment
744
+ welcomeComment = ""
745
+ welcomeCommentEnable = True
746
+ productRecommendMessage = ""
747
+ productRecommendMessageEnable = True
584
748
  platform = "FB_GROUP"
749
+
585
750
  if "title" in data:
586
751
  title = data["title"]
587
752
  if "salesDescription" in data:
@@ -590,19 +755,13 @@ def edit_live_info(data):
590
755
  title = data["salesOwner"]
591
756
  if "platform" in data:
592
757
  platform = data["platform"]
593
- patternModel = "INCLUDE_MATCH"
594
758
  if "patternModel" in data:
595
759
  patternModel = data["patternModel"]
596
- keywordValidInLive = True
597
- keywordValidAfterLive = False
598
760
  if "keywordValidInLive" in data:
599
761
  keywordValidInLive = data["keywordValidInLive"]
600
762
  if "keywordValidAfterLive" in data:
601
763
  keywordValidAfterLive = data["keywordValidAfterLive"]
602
- autoNotifyPayEnable = False
603
- autoNotifyPayMessage = ""
604
- autoNotifyPayButton = ""
605
- autoNotifyPayTime = None
764
+
606
765
  if "autoNotifyPayEnable" in data:
607
766
  autoNotifyPayEnable = data["autoNotifyPayEnable"]
608
767
  if "autoNotifyPayMessage" in data:
@@ -612,17 +771,11 @@ def edit_live_info(data):
612
771
  if "autoNotifyPayTime" in data:
613
772
  autoNotifyPayTime = data["autoNotifyPayTime"]
614
773
 
615
- stockEnable = False
616
- stockPreTime = None
617
- stockExpireTime = None
618
774
  if "stockEnable" in data:
619
775
  stockEnable = data["stockEnable"]
620
776
  if "stockExpireTime" in data:
621
777
  stockExpireTime = data["stockExpireTime"]
622
778
 
623
- lowOfQuantityEnable = False
624
- lowOfQuantitySound = False
625
- lowOfQuantityQuantity = "1"
626
779
  if "lowOfQuantityEnable" in data:
627
780
  lowOfQuantityEnable = data["lowOfQuantityEnable"]
628
781
  if "lowOfQuantitySound" in data:
@@ -630,6 +783,188 @@ def edit_live_info(data):
630
783
  if "lowOfQuantityQuantity" in data:
631
784
  lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
632
785
 
786
+ if "has_interaction_message" in data:
787
+ has_interaction_message = data["has_interaction_message"]
788
+ if "has_interaction_message_button" in data:
789
+ has_interaction_message_button = data["has_interaction_message_button"]
790
+ if "no_interaction_message_first" in data:
791
+ no_interaction_message_first = data["no_interaction_message_first"]
792
+ if "first_message_button" in data:
793
+ first_message_button = data["first_message_button"]
794
+ if "second_message" in data:
795
+ second_message = data["second_message"]
796
+ if "second_message_button" in data:
797
+ second_message_button = data["second_message_button"]
798
+ if "need_send_message" in data:
799
+ need_send_message = data["need_send_message"]
800
+ # if "message_button" in data:
801
+ # message_button = data["message_button"]
802
+ if "has_link" in data:
803
+ has_link = data["has_link"]
804
+ if "commentIntent" in data:
805
+ commentIntent = data["commentIntent"]
806
+
807
+ if "allOutOfStockMessage" in data:
808
+ allOutOfStockMessage = data["allOutOfStockMessage"]
809
+ if "allOutOfStockEnable" in data:
810
+ allOutOfStockEnable = data["allOutOfStockEnable"]
811
+
812
+ if "welcomeMessage" in data:
813
+ welcomeMessage = data["welcomeMessage"]
814
+ if "welcomeMessageEnable" in data:
815
+ welcomeMessageEnable = data["welcomeMessageEnable"]
816
+
817
+ if "welcomeComment" in data:
818
+ welcomeComment = data["welcomeComment"]
819
+ if "welcomeCommentEnable" in data:
820
+ welcomeCommentEnable = data["welcomeCommentEnable"]
821
+
822
+ if "productRecommendMessage" in data:
823
+ productRecommendMessage = data["productRecommendMessage"]
824
+ if "productRecommendMessageEnable" in data:
825
+ productRecommendMessageEnable = data["productRecommendMessageEnable"]
826
+
827
+ body = {}
828
+ if platform.upper()=="FB_GROUP":
829
+ body = {
830
+ "sales": {
831
+ "title": title,
832
+ "salesOwner": salesOwner,
833
+ "salesDescription": salesDescription,
834
+ "platforms": [
835
+ platform
836
+ ],
837
+ "platformSubType": "",
838
+ "platformChannels": [],
839
+ "archivedStreamVisibleTime": None
840
+ },
841
+ "salesConfig": {
842
+ "patternModel": {
843
+ "patternModel": patternModel,
844
+ "keywordValidInLive": keywordValidInLive,
845
+ "keywordValidAfterLive": keywordValidAfterLive
846
+ },
847
+ "autoNotifyPay": {
848
+ "enable": autoNotifyPayEnable,
849
+ "notifyTime": autoNotifyPayTime,
850
+ "message": autoNotifyPayMessage,
851
+ "button": autoNotifyPayButton
852
+ },
853
+ "stock": {
854
+ "lockStock": stockEnable,
855
+ "salesStockLockExpireTime": stockExpireTime,
856
+ "salesStockLockPreTime": stockPreTime
857
+ },
858
+ "commentIntent": {
859
+ "enabled": commentIntent
860
+ },
861
+ "variationToggleOn": {
862
+ "enable": True
863
+ },
864
+ "productSort": {
865
+ "productSort": "NEW_TO_OLD"
866
+ },
867
+ "lowOfQuantity": {
868
+ "enable": lowOfQuantityEnable,
869
+ "sound": lowOfQuantitySound,
870
+ "quantity": lowOfQuantityQuantity
871
+ },
872
+ "notice": None,
873
+ "frontLive": None,
874
+ "liveViewSdk": None,
875
+ "runningLightsConfig": None,
876
+ "fbGroupSettingConfig": {
877
+ "scGroupPmCommentId": True,
878
+ "scGroupWebhook": True
879
+ },
880
+ "productPinningStyle": None
881
+ },
882
+ "postConfigMap": {
883
+ platform: {
884
+ "message": {
885
+ "needSendMessage": need_send_message,
886
+ "hasInteractionMessage": {
887
+ "firstMessageTemplate": {
888
+ "topMessage": has_interaction_message
889
+ },
890
+ "messageButton": has_interaction_message_button
891
+ },
892
+ "hasLink": has_link,
893
+ "noInteractionMessage": {
894
+ "firstMessageTemplate": {
895
+ "topMessage": no_interaction_message_first
896
+ },
897
+ "firstMessageButton": first_message_button,
898
+ "secondMessageTemplate": {
899
+ "topMessage": second_message
900
+ },
901
+ "secondMessageButton": second_message_button
902
+ },
903
+ "messageType": "MESSAGE"
904
+ },
905
+ "allOutOfStockMessage": {
906
+ "needSendMessage": allOutOfStockEnable,
907
+ "hasInteractionMessage": {
908
+ "firstMessageTemplate": {
909
+ "topMessage": allOutOfStockMessage
910
+ }
911
+ },
912
+ "messageType": "ALL_OUT_OF_STOCK"
913
+ },
914
+ "welcomeMessage": {
915
+ "needSendMessage": welcomeMessageEnable,
916
+ "hasInteractionMessage": {
917
+ "firstMessageTemplate": {
918
+ "topMessage": welcomeMessage
919
+ }
920
+ },
921
+ "messageType": "WELCOME_MESSAGE"
922
+ },
923
+ "productRecommendMessage": {
924
+ "needSendMessage": productRecommendMessageEnable,
925
+ "hasInteractionMessage": {
926
+ "firstMessageTemplate": {
927
+ "message": productRecommendMessage
928
+ }
929
+ },
930
+ "messageType": "PRODUCT_RECOMMEND_FB_MESSAGE"
931
+ },
932
+ "welcomeMessageComment": {
933
+ "needSendMessage": welcomeCommentEnable,
934
+ "hasInteractionMessage": {
935
+ "firstMessageTemplate": {
936
+ "topMessage": welcomeComment
937
+ }
938
+ },
939
+ "messageType": "WELCOME_MESSAGE_COMMENT"
940
+ },
941
+ "showNumberOfViewers": None,
942
+ "showShareButton": None
943
+ }
944
+ }
945
+ }
946
+
947
+ response = requests.put(url,headers=headers,json=body).json()
948
+ return response
949
+
950
+ def save_global_config(data):
951
+ "保存直播间通用配置"
952
+ env = data["env"]
953
+ headers = data["headers"]
954
+ url = "%s/api/posts/post/sales/global/LIVE"%env
955
+ patternModel = "INCLUDE_MATCH"
956
+ keywordValidInLive = True
957
+ keywordValidAfterLive = False
958
+ autoNotifyPayEnable = False
959
+ autoNotifyPayMessage = ""
960
+ autoNotifyPayButton = ""
961
+ autoNotifyPayTime = None
962
+ stockEnable = False
963
+ stockPreTime = None
964
+ stockExpireTime = None
965
+ lowOfQuantityEnable = False
966
+ lowOfQuantitySound = False
967
+ lowOfQuantityQuantity = "1"
633
968
  has_interaction_message = ""
634
969
  has_interaction_message_button = ""
635
970
  no_interaction_message_first = ""
@@ -637,8 +972,60 @@ def edit_live_info(data):
637
972
  first_message_button = ""
638
973
  second_message_button = " ️"
639
974
  need_send_message = True
640
- # message_button = "立即结帐️"
641
975
  has_link = True
976
+ commentIntent = True
977
+ # 无库存讯息
978
+ allOutOfStockMessage = ""
979
+ allOutOfStockEnable = True
980
+ # 欢迎讯息
981
+ welcomeMessage = ""
982
+ welcomeMessageEnable = True
983
+ # 欢迎comment
984
+ welcomeComment = ""
985
+ welcomeCommentEnable = True
986
+ fbProductRecommendMessage = ""
987
+ igProductRecommendMessage = ""
988
+ slProductRecommendMessage = ""
989
+ # productRecommendMessageEnable = True
990
+ show_number = True
991
+ show_share = True
992
+
993
+ if "title" in data:
994
+ title = data["title"]
995
+ if "salesDescription" in data:
996
+ title = data["salesDescription"]
997
+ if "salesOwner" in data:
998
+ title = data["salesOwner"]
999
+ if "platform" in data:
1000
+ platform = data["platform"]
1001
+ if "patternModel" in data:
1002
+ patternModel = data["patternModel"]
1003
+ if "keywordValidInLive" in data:
1004
+ keywordValidInLive = data["keywordValidInLive"]
1005
+ if "keywordValidAfterLive" in data:
1006
+ keywordValidAfterLive = data["keywordValidAfterLive"]
1007
+
1008
+ if "autoNotifyPayEnable" in data:
1009
+ autoNotifyPayEnable = data["autoNotifyPayEnable"]
1010
+ if "autoNotifyPayMessage" in data:
1011
+ autoNotifyPayMessage = data["autoNotifyPayMessage"]
1012
+ if "autoNotifyPayButton" in data:
1013
+ autoNotifyPayButton = data["autoNotifyPayButton"]
1014
+ if "autoNotifyPayTime" in data:
1015
+ autoNotifyPayTime = data["autoNotifyPayTime"]
1016
+
1017
+ if "stockEnable" in data:
1018
+ stockEnable = data["stockEnable"]
1019
+ if "stockExpireTime" in data:
1020
+ stockExpireTime = data["stockExpireTime"]
1021
+
1022
+ if "lowOfQuantityEnable" in data:
1023
+ lowOfQuantityEnable = data["lowOfQuantityEnable"]
1024
+ if "lowOfQuantitySound" in data:
1025
+ lowOfQuantitySound = data["lowOfQuantitySound"]
1026
+ if "lowOfQuantityQuantity" in data:
1027
+ lowOfQuantityQuantity = data["lowOfQuantityQuantity"]
1028
+
642
1029
  if "has_interaction_message" in data:
643
1030
  has_interaction_message = data["has_interaction_message"]
644
1031
  if "has_interaction_message_button" in data:
@@ -657,98 +1044,65 @@ def edit_live_info(data):
657
1044
  # message_button = data["message_button"]
658
1045
  if "has_link" in data:
659
1046
  has_link = data["has_link"]
660
-
661
- commentIntent = True
662
1047
  if "commentIntent" in data:
663
1048
  commentIntent = data["commentIntent"]
664
1049
 
665
- #无库存讯息
666
- allOutOfStockMessage = ""
667
- allOutOfStockEnable = True
668
1050
  if "allOutOfStockMessage" in data:
669
1051
  allOutOfStockMessage = data["allOutOfStockMessage"]
670
1052
  if "allOutOfStockEnable" in data:
671
1053
  allOutOfStockEnable = data["allOutOfStockEnable"]
672
- #欢迎讯息
673
- welcomeMessage = ""
674
- welcomeMessageEnable = True
1054
+
675
1055
  if "welcomeMessage" in data:
676
1056
  welcomeMessage = data["welcomeMessage"]
677
1057
  if "welcomeMessageEnable" in data:
678
1058
  welcomeMessageEnable = data["welcomeMessageEnable"]
679
- # 欢迎comment
680
- welcomeComment = ""
681
- welcomeCommentEnable = True
1059
+
682
1060
  if "welcomeComment" in data:
683
1061
  welcomeComment = data["welcomeComment"]
684
1062
  if "welcomeCommentEnable" in data:
685
1063
  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
1064
 
1065
+ if "show_number" in data:
1066
+ show_number = data["show_number"]
1067
+ if "show_share" in data:
1068
+ show_share = data["show_share"]
1069
+
1070
+ if "fbProductRecommendMessage" in data:
1071
+ fbProductRecommendMessage = data["fbProductRecommendMessage"]
1072
+ if "igProductRecommendMessage" in data:
1073
+ igProductRecommendMessage = data["igProductRecommendMessage"]
1074
+ if "slProductRecommendMessage" in data:
1075
+ slProductRecommendMessage = data["slProductRecommendMessage"]
693
1076
 
694
1077
 
695
- platform = platform.upper()
696
1078
  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"
1079
+ "saveList": [
1080
+ {
1081
+ "configKey": "PATTERN_MODEL",
1082
+ "configValue": {
1083
+ "patternModel": patternModel,
1084
+ "keywordValidInLive": keywordValidInLive,
1085
+ "keywordValidAfterLive": keywordValidAfterLive
1086
+ }
733
1087
  },
734
- "lowOfQuantity": {
735
- "enable": lowOfQuantityEnable,
736
- "sound": lowOfQuantitySound,
737
- "quantity": lowOfQuantityQuantity
1088
+ {
1089
+ "configKey": "STOCK",
1090
+ "configValue": {
1091
+ "lockStock": stockEnable,
1092
+ "salesStockLockExpireTime": stockExpireTime
1093
+ }
738
1094
  },
739
- "notice": None,
740
- "frontLive": None,
741
- "liveViewSdk": None,
742
- "runningLightsConfig": None,
743
- "fbGroupSettingConfig": {
744
- "scGroupPmCommentId": True,
745
- "scGroupWebhook": True
1095
+ {
1096
+ "configKey": "LOW_OF_QUANTITY",
1097
+ "configValue": {
1098
+ "enable": lowOfQuantityEnable,
1099
+ "sound": lowOfQuantitySound,
1100
+ "quantity": lowOfQuantityQuantity
1101
+ }
746
1102
  },
747
- "productPinningStyle": None
748
- },
749
- "postConfigMap": {
750
- platform: {
751
- "message": {
1103
+ {
1104
+ "configKey": "MESSAGE",
1105
+ "configValue": {
752
1106
  "needSendMessage": need_send_message,
753
1107
  "hasInteractionMessage": {
754
1108
  "firstMessageTemplate": {
@@ -768,51 +1122,124 @@ def edit_live_info(data):
768
1122
  "secondMessageButton": second_message_button
769
1123
  },
770
1124
  "messageType": "MESSAGE"
771
- },
772
- "allOutOfStockMessage": {
773
- "needSendMessage": allOutOfStockEnable,
1125
+ }
1126
+ },
1127
+ {
1128
+ "configKey": "WELCOME_MESSAGE",
1129
+ "configValue": {
774
1130
  "hasInteractionMessage": {
775
1131
  "firstMessageTemplate": {
776
- "topMessage": allOutOfStockMessage
1132
+ "topMessage": welcomeMessage
777
1133
  }
778
1134
  },
779
- "messageType": "ALL_OUT_OF_STOCK"
780
- },
781
- "welcomeMessage": {
782
1135
  "needSendMessage": welcomeMessageEnable,
1136
+ "messageType": "WELCOME_MESSAGE"
1137
+ }
1138
+ },
1139
+ {
1140
+ "configKey": "WELCOME_MESSAGE_COMMENT",
1141
+ "configValue": {
783
1142
  "hasInteractionMessage": {
784
1143
  "firstMessageTemplate": {
785
- "topMessage": welcomeMessage
1144
+ "topMessage": welcomeComment
786
1145
  }
787
1146
  },
788
- "messageType": "WELCOME_MESSAGE"
789
- },
790
- "productRecommendMessage": {
791
- "needSendMessage": productRecommendMessageEnable,
1147
+ "needSendMessage": welcomeCommentEnable,
1148
+ "messageType": "WELCOME_MESSAGE_COMMENT"
1149
+ }
1150
+ },
1151
+ {
1152
+ "configKey": "PRODUCT_RECOMMEND_FB_MESSAGE",
1153
+ "configValue": {
792
1154
  "hasInteractionMessage": {
793
1155
  "firstMessageTemplate": {
794
- "message": productRecommendMessage
1156
+ "message": fbProductRecommendMessage
795
1157
  }
796
1158
  },
797
1159
  "messageType": "PRODUCT_RECOMMEND_FB_MESSAGE"
798
- },
799
- "welcomeMessageComment": {
800
- "needSendMessage": welcomeCommentEnable,
1160
+ }
1161
+ },
1162
+ {
1163
+ "configKey": "PRODUCT_RECOMMEND_IG_MESSAGE",
1164
+ "configValue": {
801
1165
  "hasInteractionMessage": {
802
1166
  "firstMessageTemplate": {
803
- "topMessage": welcomeComment
1167
+ "message": igProductRecommendMessage
804
1168
  }
805
1169
  },
806
- "messageType": "WELCOME_MESSAGE_COMMENT"
807
- },
808
- "showNumberOfViewers": None,
809
- "showShareButton": None
810
- }
1170
+ "messageType": "PRODUCT_RECOMMEND_IG_MESSAGE"
1171
+ }
1172
+ },
1173
+ {
1174
+ "configKey": "PRODUCT_RECOMMEND_SHOP_LINE_MESSAGE",
1175
+ "configValue": {
1176
+ "hasInteractionMessage": {
1177
+ "firstMessageTemplate": {
1178
+ "message": slProductRecommendMessage
1179
+ }
1180
+ },
1181
+ "messageType": "PRODUCT_RECOMMEND_SHOP_LINE_MESSAGE"
1182
+ }
1183
+ },
1184
+ {
1185
+ "configKey": "ALL_OUT_OF_STOCK",
1186
+ "configValue": {
1187
+ "hasInteractionMessage": {
1188
+ "firstMessageTemplate": {
1189
+ "topMessage": allOutOfStockMessage
1190
+ }
1191
+ },
1192
+ "needSendMessage": allOutOfStockEnable,
1193
+ "messageType": "ALL_OUT_OF_STOCK"
1194
+ }
1195
+ },
1196
+ {
1197
+ "configKey": "AUTO_NOTIFY_PAY",
1198
+ "configValue": {
1199
+ "enable": autoNotifyPayEnable,
1200
+ "message": autoNotifyPayMessage,
1201
+ "button": autoNotifyPayButton
1202
+ }
1203
+ },
1204
+ {
1205
+ "configKey": "COMMENT_INTENT",
1206
+ "configValue": {
1207
+ "enabled": commentIntent
1208
+ }
1209
+ },
1210
+ {
1211
+ "configKey": "SHOW_NUMBER_OF_VIEWERS",
1212
+ "configValue": {
1213
+ "enabled": show_number
1214
+ }
1215
+ },
1216
+ {
1217
+ "configKey": "SHOW_SHARE_BUTTON",
1218
+ "configValue": {
1219
+ "enabled": show_share
1220
+ }
811
1221
  }
812
- }
813
- response = requests.put(url,headers=headers,json=body).json()
1222
+ ]
1223
+ }
1224
+ response = requests.post(url, headers=headers, json=body).json()
814
1225
  return response
815
1226
 
1227
+ def get_global_config(data):
1228
+ env = data["env"]
1229
+ headers = data["headers"]
1230
+ url = "%s/api/posts/post/sales/global/LIVE" % env
1231
+ response = requests.get(url,headers=headers).json()
1232
+ # print(response)
1233
+ return response
1234
+
1235
+
1236
+
1237
+
1238
+ outOfStock = {
1239
+ "en":"The following product(s) doesn't have enough stock, please select other products, thanks!\n❗️{products}".replace("️{products}","ffddd"),
1240
+ "zh-cn":"以下商品库存不足,请选购其他商品,谢谢!\n❗️{products}".replace("️{products}","ffddd"),
1241
+ "zh-hant":"以下商品庫存不足,請選購其他商品,謝謝!\n❗️{products}".replace("️{products}","ffddd")
1242
+ }
816
1243
 
817
1244
 
818
1245
 
@@ -822,4 +1249,4 @@ def edit_live_info(data):
822
1249
 
823
1250
 
824
1251
  if __name__=="__main__":
825
- pass
1252
+ 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.4
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.4',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),