Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
jd_data_process
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
171d9ef1
authored
Oct 21, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
insert vc attr
parent
e584ae44
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
15 deletions
vc.py
vc_attr.json
vc.py
View file @
171d9ef1
...
@@ -52,17 +52,6 @@ def get_vc_audit(applyId: str):
...
@@ -52,17 +52,6 @@ def get_vc_audit(applyId: str):
return
ans
return
ans
def
get_vc_attr
(
class_id
:
int
):
"""获取vc分类的属性"""
def
get_vc_ext_attr
(
class_id
:
int
):
"""获取京东的拓展属性"""
def
insert_vc_class
(
conf
:
dict
):
def
insert_vc_class
(
conf
:
dict
):
method_name
=
"jingdong.vc.item.categories.find"
method_name
=
"jingdong.vc.item.categories.find"
token
=
"845ce8478b074103b9e78a769d5fa4831y2u"
token
=
"845ce8478b074103b9e78a769d5fa4831y2u"
...
@@ -92,12 +81,96 @@ def insert_vc_class(conf: dict):
...
@@ -92,12 +81,96 @@ def insert_vc_class(conf: dict):
print
(
insert_sql
%
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
print
(
insert_sql
%
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
def
insert_vc_attr
():
def
insert_vc_attr
(
conf
:
dict
):
"""lie_shop_class中拿vc class_id 插入属性"""
select_sql
=
"select class_id from lie_shop_class where platform = 1"
host
=
conf
[
"mysql"
][
"host"
]
port
=
conf
[
"mysql"
][
"port"
]
user
=
conf
[
"mysql"
][
"user"
]
password
=
conf
[
"mysql"
][
"password"
]
database
=
conf
[
"mysql"
][
"database"
]
method_name
=
"jingdong.vc.item.props.find"
token
=
"845ce8478b074103b9e78a769d5fa4831y2u"
app_key
=
"CA52430E90209F51D8F5D7B615DDE9AD"
app_secret
=
"c92691b2379c48de87e699c4c2f7fb32"
db
=
pymysql
.
connect
(
host
=
host
,
port
=
port
,
user
=
user
,
password
=
password
,
database
=
database
)
cursor
=
db
.
cursor
()
cursor
.
execute
(
query
=
select_sql
)
db_results
=
cursor
.
fetchall
()
for
i
in
range
(
len
(
db_results
)):
class_id
=
db_results
[
i
][
0
]
param
=
{
"category_leaf_id"
:
class_id
}
ans
=
request_to_jd_vc
(
method_name
=
method_name
,
token
=
token
,
app_key
=
app_key
,
app_secret
=
app_secret
,
param
=
param
)
print
(
json
.
dumps
(
ans
,
ensure_ascii
=
False
))
if
"result"
not
in
ans
[
"jingdong_vc_item_props_find_responce"
][
"jos_result_dto"
]:
continue
jd_results
=
ans
[
"jingdong_vc_item_props_find_responce"
][
"jos_result_dto"
][
"result"
]
for
j
in
range
(
len
(
jd_results
)):
result
=
jd_results
[
j
]
props
=
result
[
"props"
]
for
k
in
range
(
len
(
props
)):
prop
=
props
[
k
]
attr_id
=
prop
[
"id"
]
attr_name
=
prop
[
"name"
]
unit
=
prop
[
"val_unit"
]
input_type
=
prop
[
"input_type"
]
platform
=
1
status
=
1
if
not
prop
[
"required"
]:
is_required
=
0
else
:
is_required
=
1
enum_value
=
"[]"
if
input_type
==
1
or
input_type
==
2
:
# 单选或者多选 把选项取出来
tmp_value_list
=
[]
values
=
prop
[
"values"
]
for
index
in
range
(
len
(
values
)):
attr_value_id
=
values
[
index
][
"id"
]
attr_value_name
=
values
[
index
][
"name"
]
item_map
=
{
"attr_value_id"
:
attr_value_id
,
"attr_value_name"
:
attr_value_name
,
}
tmp_value_list
.
append
(
item_map
)
enum_value
=
json
.
dumps
(
tmp_value_list
,
ensure_ascii
=
False
)
elif
input_type
==
3
:
# 文本类型
# 文本类型没有可选值
pass
elif
input_type
==
7
:
# 数值类型
# 数值类型没有可选值
pass
pass
elif
input_type
==
10
:
# 多单位多解析的方式
# 多单位多解析 需要特殊处理单位字段
tmp_unit_list
=
[]
values
=
prop
[
"values"
]
for
index
in
range
(
len
(
values
)):
if
"units"
in
values
[
index
]:
unit_list
=
values
[
index
][
"units"
]
for
x
in
range
(
len
(
unit_list
)):
tmp_unit_list
.
append
(
unit_list
[
x
])
unit
=
json
.
dumps
(
tmp_unit_list
,
ensure_ascii
=
False
)
else
:
print
(
"此input_type类型暂未兼容处理!请单独处理!"
)
create_time
=
int
(
time
.
time
())
insert_sql
=
"insert into lie_shop_attr (class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time) values (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
cursor
.
execute
(
query
=
insert_sql
,
args
=
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
,))
db
.
commit
()
print
(
insert_sql
%
(
class_id
,
attr_id
,
attr_name
,
unit
,
enum_value
,
input_type
,
is_required
,
status
,
platform
,
create_time
))
if
__name__
==
'__main__'
:
def
insert_vc_ext_attr
(
conf
:
dict
):
conf
=
config_prod
pass
insert_vc_class
(
conf
)
if
__name__
==
'__main__'
:
conf
=
config_dev
insert_vc_attr
(
conf
)
vc_attr.json
0 → 100644
View file @
171d9ef1
File mode changed
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment