sc-common-interface 2.8.4__tar.gz → 2.8.6__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.8.4
3
+ Version: 2.8.6
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -1792,7 +1792,7 @@ def get_produnct_set_detail(data):
1792
1792
 
1793
1793
 
1794
1794
  def add_product_set_to_live(data):
1795
- "添加商品到直播间"
1795
+ "添加组合商品到直播间"
1796
1796
  env = data["env"]
1797
1797
  headers = data["headers"]
1798
1798
  sales_id = data["sales_id"]
@@ -2176,18 +2176,32 @@ def handler_bidding(data):
2176
2176
 
2177
2177
 
2178
2178
  def check_14_day(data):
2179
- response = get_live_info(data)
2180
- start_time_timestamp = response["data"]["sales"]["start_time_timestamp"]
2181
- # 将毫秒转换为秒
2182
- start_time_timestamp = start_time_timestamp / 1000
2183
- # 计算 14 天的秒数
2184
- fourteen_days_seconds = 13 * 24 * 60 * 60
2185
- # 获取当前时间戳(秒)
2186
- current_time_seconds = time.time()
2187
2179
  flag = False
2188
- if (current_time_seconds - start_time_timestamp) >= fourteen_days_seconds:
2189
- flag =True
2190
- return flag
2180
+ try:
2181
+ response = get_live_info(data)
2182
+ code = response["code"]
2183
+ if code!="SUCCESS":
2184
+ flag =True
2185
+ return flag
2186
+ else:
2187
+ start_time_timestamp = response["data"]["sales"]["start_time_timestamp"]
2188
+ # 将毫秒转换为秒
2189
+ start_time_timestamp = start_time_timestamp / 1000
2190
+ # 计算 14 天的秒数
2191
+ fourteen_days_seconds = 13 * 24 * 60 * 60
2192
+ # 获取当前时间戳(秒)
2193
+ current_time_seconds = time.time()
2194
+
2195
+ if (current_time_seconds - start_time_timestamp) >= fourteen_days_seconds:
2196
+ flag = True
2197
+ return flag
2198
+ except Exception:
2199
+ flag = True
2200
+ return flag
2201
+
2202
+
2203
+
2204
+
2191
2205
 
2192
2206
  def get_fb_sales_id(data):
2193
2207
  """"查询返回指定直播间的salse_id
@@ -2225,7 +2239,7 @@ def get_receipt_sales_id(data):
2225
2239
  sales_id = data["sales_id"]
2226
2240
  flag = check_14_day(data)
2227
2241
  if flag:
2228
- #先从列表查出一个最新结束的直播间,还是不返回要求再创建直播和链接直播
2242
+ #先从列表查出一个最新结束的直播间,还是不返回要再创建直播和链接直播
2229
2243
  sales_id = get_fb_sales_id(data)
2230
2244
  data["sales_id"] = sales_id
2231
2245
  flag2 = check_14_day(data)
@@ -2252,12 +2266,28 @@ def delete_keyword_product_set(data):
2252
2266
  headers = data["headers"]
2253
2267
  product_id = data["product_id"]
2254
2268
  url = "%s/admin/api/bff-web/keyword/product_set"%env
2269
+ if isinstance(product_id, str):
2270
+ product_id = [product_id]
2255
2271
  body = {
2256
2272
  "ids": product_id
2257
2273
  }
2258
2274
  response = requests.delete(url,headers=headers,json=body).json()
2259
2275
  return response
2260
2276
 
2277
+ def delete_keyword_product(data):
2278
+ "删除关键字组件里的组合商品"
2279
+ "product_id为:[]"
2280
+ env = data["env"]
2281
+ headers = data["headers"]
2282
+ product_id = data["product_id"]
2283
+ url = "%s/api/posts/common/product/key/spu"%env
2284
+ if isinstance(product_id,str):
2285
+ product_id = [product_id]
2286
+ body = {
2287
+ "ids": product_id
2288
+ }
2289
+ response = requests.delete(url,headers=headers,json=body).json()
2290
+ return response
2261
2291
 
2262
2292
  def get_keyword_product_set(data):
2263
2293
  "查询关键字组件里的组合商品"
@@ -2349,10 +2379,67 @@ def delete_product_by_keyword(data):
2349
2379
  data["product_id"] = set_spu_id
2350
2380
  delete_product_set(data)
2351
2381
 
2352
-
2353
-
2354
-
2355
-
2382
+ def add_product_to_live(data):
2383
+ "添加普通商品到直播间"
2384
+ env = data["env"]
2385
+ headers = data["headers"]
2386
+ sales_id = data["sales_id"]
2387
+ keyword = ["pythonaddkeyword%d"%int(time.time())]
2388
+ keyword = data.get("keyword",keyword)
2389
+ url = "%s/api/posts/post/sales/%s/products"%(env,sales_id)
2390
+ product_id = data["product_id"]
2391
+ missCommonKey = data.get("missCommonKey",True)
2392
+ customNumber = data.get("customNumber",[])
2393
+ type = data.get("type","spu")
2394
+ if isinstance(keyword,str):
2395
+ keyword = [keyword]
2396
+ if isinstance(customNumber, str):
2397
+ customNumber = [customNumber]
2398
+ body = {
2399
+ "spuList": [
2400
+ {
2401
+ "spuId": product_id,
2402
+ "missCommonKey": missCommonKey,
2403
+ "customNumbers": customNumber,
2404
+ "keyList":keyword
2405
+ }
2406
+ ]
2407
+ }
2408
+ if type=="sku":
2409
+ """
2410
+ skuList 格式:
2411
+ [
2412
+ {
2413
+ "skuId": "67b5739c05e4b200102ae7bf",
2414
+ "missCommonKey": false,
2415
+ "keyList": [
2416
+ "fb直播间新增的对规格关键字17399448600"
2417
+ ]
2418
+ },
2419
+ {
2420
+ "skuId": "67b5739c05e4b200102ae7c0",
2421
+ "missCommonKey": false,
2422
+ "keyList": [
2423
+ "fb直播间新增的对规格关键字17399448601"
2424
+ ]
2425
+ } ]
2426
+ """
2427
+ skuList = data["skuList"]
2428
+ body = {
2429
+ "spuList": [
2430
+ {
2431
+ "spuId": product_id,
2432
+ "missCommonKey": missCommonKey,
2433
+ "customNumbers": customNumber,
2434
+ "skuList": skuList
2435
+ }
2436
+ ]
2437
+ }
2438
+ #添加前先删除直播间的商品
2439
+ remove_live_product(data)
2440
+ print(body)
2441
+ response = requests.post(url,headers=headers,json=body).json()
2442
+ return response
2356
2443
 
2357
2444
 
2358
2445
 
@@ -2364,8 +2451,8 @@ def delete_product_by_keyword(data):
2364
2451
 
2365
2452
 
2366
2453
  if __name__=="__main__":
2367
- data = {'headers': {'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en', 'Content-Type': 'application/json'}, 'product_id': '6787314d323be4000e158d6a', 'env': 'https://front-admin-preview.shoplineapp.com', 'keyword': ['jfjsdjfdfhhdaewqeqe',"ndhsahdsd"], 'sales_id': '95828'}
2368
- __,__,keyword,res = add_product_set_to_live(data)
2454
+ data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'platform': 'FB_GROUP', 'sales_id': '95828', 'keyword': ['test关键字组件直播间新增的关键字1739955629'], 'product_id': '65bba57da79d260023ac30ff'}
2455
+ res = add_product_to_live(data)
2369
2456
  print(res)
2370
2457
 
2371
2458
 
@@ -2380,4 +2467,3 @@ if __name__=="__main__":
2380
2467
 
2381
2468
 
2382
2469
 
2383
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.8.4
3
+ Version: 2.8.6
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.8.4',
5
+ version='2.8.6',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),