sc-common-interface 2.2.3__tar.gz → 2.2.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.2.3
3
+ Version: 2.2.4
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -792,35 +792,35 @@ def merge_customer(data):
792
792
  user_id = data["user_id"]
793
793
  page_id = data["page_id"]
794
794
  platform = data["platform"]
795
+ customer_id = jsonpath(response,"$..customer_id")[0]
795
796
 
796
- response = search_customer(data)
797
- items = response["data"]["items"]
798
- # 创建会员
799
- customer_id = ""
800
- url = "%s/uc/customers/merge" % env
801
- body = {"email": "", "mobile_phone": phone, "mobile_phone_country_calling_code": "86",
802
- "name": name, "page_scoped_id": user_id, "locale_code": None, "country_code": "cn",
803
- "id": None, "party_channel_id": page_id, "platform": platform, "is_member": True}
804
- if items != []:
805
- id = jsonpath(response, "$..id")[0]
806
- customer_id = id
797
+ if customer_id==None:
798
+ response = search_customer(data)
799
+ items = response["data"]["items"]
800
+ # 创建会员
801
+ url = "%s/uc/customers/merge" % env
807
802
  body = {"email": "", "mobile_phone": phone, "mobile_phone_country_calling_code": "86",
808
803
  "name": name, "page_scoped_id": user_id, "locale_code": None, "country_code": "cn",
809
- "id": id, "party_channel_id": page_id, "platform": platform, "is_member": True}
810
- response = requests.put(url, headers=headers, json=body)
811
-
812
- # print("创建会员请求体",body)
813
- if response.raise_for_status():
814
- customer_id = response.json()["data"]["id"]
815
- elif response.json()["code"]=="UC0409":
816
- email = "%d@qq.com"%int(time.time())
817
- body = {"email": email, "mobile_phone": "", "mobile_phone_country_calling_code": "86",
818
- "name": name, "page_scoped_id": user_id, "locale_code": None, "country_code": "cn",
819
- "id": "", "party_channel_id": page_id, "platform": platform, "is_member": False}
804
+ "id": None, "party_channel_id": page_id, "platform": platform, "is_member": True}
805
+ if items != []:
806
+ id = jsonpath(response, "$..id")[0]
807
+ customer_id = id
808
+ body = {"email": "", "mobile_phone": phone, "mobile_phone_country_calling_code": "86",
809
+ "name": name, "page_scoped_id": user_id, "locale_code": None, "country_code": "cn",
810
+ "id": id, "party_channel_id": page_id, "platform": platform, "is_member": True}
820
811
  response = requests.put(url, headers=headers, json=body)
821
- else:
822
- customer_id = response.json()["data"]["id"]
823
-
812
+ print("合并会员返回",response.json())
813
+ # print("创建会员请求体",body)
814
+ if response.raise_for_status():
815
+ customer_id = response.json()["data"]["id"]
816
+ elif response.json()["code"]=="UC0409":
817
+ email = "%d@qq.com"%int(time.time())
818
+ body = {"email": email, "mobile_phone": "", "mobile_phone_country_calling_code": "86",
819
+ "name": name, "page_scoped_id": user_id, "locale_code": None, "country_code": "cn",
820
+ "id": "", "party_channel_id": page_id, "platform": platform, "is_member": False}
821
+ response = requests.put(url, headers=headers, json=body)
822
+ else:
823
+ customer_id = response.json()["data"]["id"]
824
824
  return response,customer_id
825
825
 
826
826
 
@@ -851,8 +851,8 @@ def manual_order(data):
851
851
  # 先查询号码或邮箱是否被占有
852
852
  #创建会员
853
853
  response,customer_id = merge_customer(data)
854
- print("会员ID",customer_id)
855
- print("创建会员返回,",response.text)
854
+ # print("会员ID",customer_id)
855
+ # print("创建会员返回,",response.text)
856
856
  #给会员新增物流地址
857
857
  url = "%s/uc/customers/%s" % (env,customer_id)
858
858
  postcode = "76653"
@@ -1436,11 +1436,13 @@ def set_delivery(data):
1436
1436
  response = requests.put(url, headers=headers, json=body).json()
1437
1437
  return response
1438
1438
 
1439
-
1440
-
1441
-
1442
-
1443
-
1439
+ def get_mc_order_link(url):
1440
+ response = requests.get(url)
1441
+ print(response.headers)
1442
+ location = response.headers.get("Location")
1443
+ # print(location)
1444
+ key = location.split("/")[-1].split("?")[0]
1445
+ return key
1444
1446
 
1445
1447
 
1446
1448
 
@@ -1448,13 +1450,6 @@ def set_delivery(data):
1448
1450
 
1449
1451
 
1450
1452
  if __name__=="__main__":
1451
- import re
1452
- url = "https://message-center-order.shoplinestg.com/orders/f79e29a466139ccf97cd2d759f5d4a5c?merchant_id=6229a7baea70642a8b65ebda&locale=zh-cn"
1453
- match = re.search(r"/orders/([^/?]+)", url)
1454
- if match:
1455
- order_id = match.group(1)
1456
- print(order_id)
1457
- else:
1458
- print("未找到订单 ID")
1453
+ data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhMjQ0ZTUwMmMyYzIwY2E5MWVhZDg0NWQ2YTk4YzVlNCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVmNTlmMTI4MzcyZWIzMDAwNmRjNDcwMSJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.8m_bKPfZJxan6M6hv_4byPROt_UtvHqnyWAT9Ox1CO0', 'lang': 'en'}, 'platform': 'INSTAGRAM', 'patternModel': 'INCLUDE_MATCH', 'sales_id': 423810, 'since': '1685030400', 'user_id': '4255666934537806', 'key': '5e3bba98882fc0fb22a0607238bc5b8f', 'keyword': '无规格商品关键字'}
1454
+ response = manual_order(data)
1459
1455
 
1460
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.2.3
3
+ Version: 2.2.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.2.3',
5
+ version='2.2.4',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),