Commit fdf39291 by 岳巧源

add crontab pop

parent adc1f5c8
Showing with 68 additions and 2 deletions
......@@ -5,6 +5,7 @@ from common import request_to_jd_pop
import pymysql
import time
import sys
import json
config_dev = {
......@@ -73,6 +74,71 @@ def update_pop_class(conf: dict):
db.commit()
print(sql % (parent_id, class_id, class_name, depth, status, platform, create_time))
def update_pop_attr(conf: dict):
select_sql = "select class_id from lie_shop_class where platform = 3"
db = pymysql.connect(host=conf["mysql"]["host"],
port=conf["mysql"]["port"],
user=conf["mysql"]["user"],
database=conf["mysql"]["database"],
password=conf["mysql"]["password"])
cursor = db.cursor()
cursor.execute(query=select_sql)
db_result = cursor.fetchall()
for i in range(len(db_result)):
class_id = db_result[i][0]
method_name = "jingdong.category.read.findAttrsByCategoryIdUnlimitCate"
token = "74ee3f2fa54d489da0d1b94ca83c9bc7lztn"
app_key = "CCE6563827D13EDF4769C01E7429378D"
app_secret = "98c72374c5b045529879786fc4e5c20e"
param = {
"cid": class_id,
"field": "attrValueList"
}
ans = request_to_jd_pop(method_name, token, app_key, app_secret, param)
result = ans["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"]
for j in range(len(result)):
input_type = result[j]["inputType"]
attr_id = result[j]["id"]
attr_name = result[j]["name"]
enum_value = ""
flag = result[j]["isRequired"]
status = 1
platform = 3
create_time = int(time.time())
unit = ""
if flag:
is_required = 1
else:
is_required = 0
if input_type == 1 or input_type == 2:
value_list = result[j]["attrValueList"]
tmp_list = []
for k in range(len(value_list)):
attr_value_id = value_list[k]["id"]
attr_value_name = value_list[k]["name"]
item = {
"attr_value_id": attr_value_id,
"attr_value_name": attr_value_name
}
tmp_list.append(item)
enum_value = json.dumps(tmp_list, ensure_ascii=False)
else:
enum_value = "[]"
if input_type == 10:
# 单独处理单位
features = result[j]["features"]
for k in range(len(features)):
item = features[k]
if item["key"] == "combinationValue":
unit_str = item["fvalue"]
unit_arr = json.loads(unit_str)
unit_item = unit_arr[0]
unit_list = unit_item["unit"]
unit = json.dumps(unit_list, ensure_ascii=False)
......@@ -88,4 +154,5 @@ if __name__ == '__main__':
config = config_dev
elif environment == "prod":
config = config_prod
update_pop_class(config)
\ No newline at end of file
update_pop_class(config)
print("======================> pop分类已更新")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment