Commit ef003a03 by 岳巧源

add insert vc class

parent 4b5626f4
Showing with 76 additions and 1 deletions
delete from lie_shop_class where platform = 1;
delete from lie_shop_attr where platform = 1;
\ No newline at end of file
# 请求vc店铺的所有接口 # 请求vc店铺的所有接口
import json import json
import time
import pymysql
from common import request_to_jd_vc from common import request_to_jd_vc
config_dev = {
"mysql": {
"host": "192.168.1.238",
"port": 3306,
"user": "liexin_data_distribution",
"password": "liexin_data_distribution#zsyM",
"database": "liexin_data_distribution"
},
"redis": {
"host": "192.168.1.235",
"port": 6379,
"password": "icDb29mLy2s"
}
}
config_prod = {
"mysql": {
"host": "bigdata2.ichunt.db",
"port": 3306,
"user": "DsbuUx",
"password": "sfj09JjsfpQx0",
"database": "liexin_data_distribution"
},
"redis": {
"host": "172.18.137.38",
"port": 6379,
"password": "icDb29mLy2s"
}
}
def get_vc_audit(applyId: str): def get_vc_audit(applyId: str):
"""根据应用id 查找审核状态(若审核成功可以获得京东sku_id)""" """根据应用id 查找审核状态(若审核成功可以获得京东sku_id)"""
method_name = "jingdong.vc.item.product.apply.get" method_name = "jingdong.vc.item.product.apply.get"
...@@ -21,11 +56,48 @@ def get_vc_attr(class_id: int): ...@@ -21,11 +56,48 @@ def get_vc_attr(class_id: int):
"""获取vc分类的属性""" """获取vc分类的属性"""
def get_vc_ext_attr(class_id: int): def get_vc_ext_attr(class_id: int):
"""获取京东的拓展属性""" """获取京东的拓展属性"""
def insert_vc_class(conf: dict):
method_name = "jingdong.vc.item.categories.find"
token = "845ce8478b074103b9e78a769d5fa4831y2u"
app_key = "CA52430E90209F51D8F5D7B615DDE9AD"
app_secret = "c92691b2379c48de87e699c4c2f7fb32"
param = {}
ans = request_to_jd_vc(method_name, token, app_key, app_secret, param)
results = ans["jingdong_vc_item_categories_find_responce"]["jos_result_dto"]["result"]
host = conf["mysql"]["host"]
port = conf["mysql"]["port"]
user = conf["mysql"]["user"]
password = conf["mysql"]["password"]
database = conf["mysql"]["database"]
db = pymysql.connect(host=host, port=port, user=user, password=password, database=database)
cursor = db.cursor()
for i in range(len(results)):
parent_id = results[i]["cid3"]
class_id = results[i]["id"]
class_name = results[i]["name"]
depth = results[i]["depth"]
status = 1
platform = 1
create_time = int(time.time())
insert_sql = "insert into lie_shop_class (parent_id, class_id, class_name, depth, status, platform, create_time) values (%s, %s, %s, %s, %s, %s, %s)"
cursor.execute(query=insert_sql, args=(parent_id, class_id, class_name, depth, status, platform, create_time,))
db.commit()
print(insert_sql % (parent_id, class_id, class_name, depth, status, platform, create_time))
def insert_vc_attr():
pass
if __name__ == '__main__': if __name__ == '__main__':
ans = get_vc_audit("0da56b0274c1415ebb415ec2164b408f") conf = config_dev
insert_vc_class(conf)
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