sc-common-interface 2.2.8__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.8
3
+ Version: 2.2.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -167,6 +167,71 @@ def live_search_oa_gift(data):
167
167
  spu_id = gift_info["id"]
168
168
  return spu_id,gift_info,response
169
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
+
170
235
  def get_merchant_info(data):
171
236
  env = data["env"]
172
237
  headers = data["headers"]
@@ -188,4 +253,10 @@ def get_merchant_info(data):
188
253
 
189
254
 
190
255
  if __name__=="__main__":
191
- pass
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.2.8
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.8',
5
+ version='2.2.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),