sc-common-interface 2.2.7__tar.gz → 2.2.8__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.7
3
+ Version: 2.2.8
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -134,9 +134,58 @@ def get_activity_detail(data):
134
134
  response = requests.get(url,headers=headers).json()
135
135
  return response
136
136
 
137
+ def live_search_oa_gift(data):
138
+ """
139
+ 查询oa赠品,命名转为驼峰和返回第一个赠品的信息
140
+ :param data:
141
+ :return:
142
+ """
143
+ env = data["env"]
144
+ headers = data["headers"]
145
+ url = "%s/openApi/proxy/v1/gifts"%env
146
+ params = {"page":1}
147
+ response = requests.get(url,headers=headers,params=params).json()
148
+ items = response["data"]["items"]
149
+
150
+ if items == []:
151
+ # 新增赠品
152
+ body = {"unlimited_quantity": True, "title_translations": {"zh-cn": "接口自动化新增的赠品%s" % int(time.time())},
153
+ "media_ids": "610d2865ca92cf00264c563c"}
154
+ requests.post(url, headers=headers, json=body).json()
155
+ time.sleep(5)
156
+ #新增后去查询
157
+ response = requests.get(url, headers=headers, params=params).json()
158
+ items = response["data"]["items"]
159
+
160
+ # 返回数量不是0的赠品和spu_id
161
+ # print(json.dumps(items))
162
+ quantityList = jsonpath(items,"$..quantity")
163
+ gift_info = items[0]
164
+ for a,b in enumerate(quantityList):
165
+ if b!=0:
166
+ gift_info = items[a]
167
+ spu_id = gift_info["id"]
168
+ return spu_id,gift_info,response
169
+
170
+ def get_merchant_info(data):
171
+ env = data["env"]
172
+ headers = data["headers"]
173
+ merchant_id = data["merchant_id"]
174
+ url = "%s/openApi/proxy/v1/merchants/%s" % (env,merchant_id)
175
+ response = requests.get(url, headers=headers).json()
176
+ base_country_code = response["data"]["base_country_code"]
177
+ currency = ""
178
+ if base_country_code=="TW":
179
+ currency="NT$"
180
+ elif base_country_code=="TH":
181
+ currency = "฿"
182
+ elif base_country_code == "VN":
183
+ #放金额后面
184
+ currency = "₫"
185
+ return base_country_code,currency,response
137
186
 
138
187
 
139
188
 
140
189
 
141
190
  if __name__=="__main__":
142
- pass
191
+ pass
@@ -159,8 +159,13 @@ def search_oa_gift(data):
159
159
  response = requests.get(url, headers=headers, params=params).json()
160
160
  items = response["data"]["items"]
161
161
 
162
- # 返回第一个赠品
162
+ # 返回赠品数量不是0
163
+ # print(json.dumps(items))
164
+ quantityList = jsonpath(items,"$..quantity")
163
165
  gift_info = items[0]
166
+ for a,b in enumerate(quantityList):
167
+ if b!=0:
168
+ gift_info = items[a]
164
169
  # 下划线命名转变为驼峰命名
165
170
  change_dict_into_hump(gift_info)
166
171
 
@@ -938,7 +943,7 @@ def get_user_conversation_id(data):
938
943
  url = "%s/mc/conversation/id?type=%s&user_id=%s&party_channel_id=%s" % (env, platform, user_id, page_id)
939
944
  # param = {"type":"facebook","user_id":vars["user_id"],"party_channel_id":vars["platform_channel_id"]}
940
945
  response = requests.get(url, headers=headers).json()
941
- print(response)
946
+ # print(response)
942
947
  conversation_id = jsonpath(response, "$.data.id")[0]
943
948
  return conversation_id,response
944
949
 
@@ -1469,3 +1474,4 @@ if __name__=="__main__":
1469
1474
  # "relationUrl": "https://www.facebook.com/groups/416632743936652/posts/823646243235298/"}
1470
1475
  # res = relate_post(data)
1471
1476
  # print(res)
1477
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.2.7
3
+ Version: 2.2.8
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.7',
5
+ version='2.2.8',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),