sc-common-interface 2.2.7__tar.gz → 2.2.9__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.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -134,9 +134,129 @@ 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 live_search_oa_product(data):
171
+ """
172
+ 查询OA的商品,并返回响应,返回第一个有库存的商品
173
+ spu:返回无规格
174
+ sku:返回多规格
175
+ quantity:0 返回无库存商品
176
+ :param data:
177
+ :return:
178
+ """
179
+ env = data["env"]
180
+ headers = data["headers"]
181
+ url = "%s/openApi/proxy/v1/products?page=1&per_page=20" %env
182
+ type = "spu"
183
+ quantity = 100
184
+ if "type" in data:
185
+ type = data["type"]
186
+ if "quantity" in data:
187
+ quantity = data["quantity"]
188
+ if "query" in data:
189
+ query = data["query"]
190
+ url = "%s/openApi/proxy/v1/products?page=1&per_page=4&query=%s" % (env,query)
191
+ response = requests.get(url, headers=headers).json()
192
+ items = response["data"]["items"]
193
+ variant_options_list = jsonpath(items,"$..variations")
194
+ product_info = ""
195
+ spu_id = ""
196
+ sku_id = ""
197
+ sku_id_quantity =[]
198
+ for a, b in enumerate(variant_options_list):
199
+ if type=="spu" and b==[] and quantity!=0:
200
+ quantitys=items[a]["total_orderable_quantity"]
201
+ unlimited_quantity = items[a]["unlimited_quantity"]
202
+ if quantitys!=0 or unlimited_quantity==True:
203
+ product_info=items[a]
204
+ spu_id = items[a]["id"]
205
+ break
206
+ elif type=="sku" and b!=[] and quantity!=0:
207
+ quantitys = items[a]["total_orderable_quantity"]
208
+ unlimited_quantity = items[a]["unlimited_quantity"]
209
+ if quantitys!=0 or unlimited_quantity==True:
210
+ product_info = items[a]
211
+ spu_id = items[a]["id"]
212
+ sku_id = jsonpath(items[a]["variations"],"$..id")
213
+ sku_id_quantity = jsonpath(items[a]["variations"],"$..total_orderable_quantity")
214
+ break
215
+ elif type == "spu" and b == [] and quantity == 0:
216
+ quantitys = items[a]["total_orderable_quantity"]
217
+ unlimited_quantity = items[a]["unlimited_quantity"]
218
+ if quantitys != 0 or unlimited_quantity == True:
219
+ product_info = items[a]
220
+ spu_id = items[a]["id"]
221
+ break
222
+ elif type == "sku" and b != [] and quantity == 0:
223
+ quantitys = items[a]["total_orderable_quantity"]
224
+ unlimited_quantity = items[a]["unlimited_quantity"]
225
+ if quantitys != 0 or unlimited_quantity == True:
226
+ product_info = items[a]
227
+ spu_id = items[a]["id"]
228
+ sku_id = jsonpath(items[a]["variations"], "$..id")
229
+ sku_id_quantity = jsonpath(items[a]["variations"], "$..total_orderable_quantity")
230
+ break
231
+ return spu_id,sku_id,sku_id_quantity,product_info
232
+
233
+
234
+
235
+ def get_merchant_info(data):
236
+ env = data["env"]
237
+ headers = data["headers"]
238
+ merchant_id = data["merchant_id"]
239
+ url = "%s/openApi/proxy/v1/merchants/%s" % (env,merchant_id)
240
+ response = requests.get(url, headers=headers).json()
241
+ base_country_code = response["data"]["base_country_code"]
242
+ currency = ""
243
+ if base_country_code=="TW":
244
+ currency="NT$"
245
+ elif base_country_code=="TH":
246
+ currency = "฿"
247
+ elif base_country_code == "VN":
248
+ #放金额后面
249
+ currency = "₫"
250
+ return base_country_code,currency,response
137
251
 
138
252
 
139
253
 
140
254
 
141
255
  if __name__=="__main__":
142
256
  pass
257
+ # data["type"] = "sku"
258
+ # data['quantity'] = 0
259
+ # spu_id,sku_id,sku_id_quantity,product_info = live_search_oa_product(data)
260
+ # print(spu_id)
261
+ # print(sku_id)
262
+ # print(sku_id_quantity)
@@ -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.9
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.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),