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
b3f0ea27
authored
Oct 21, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add insert ext attr
parent
171d9ef1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
vc.py
vc.py
View file @
b3f0ea27
...
...
@@ -167,7 +167,69 @@ def insert_vc_attr(conf: dict):
def
insert_vc_ext_attr
(
conf
:
dict
):
"""
基于lie_shop_attr中的class_id来更新 “拓展” 属性
"""
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.extProps.find"
token
=
"845ce8478b074103b9e78a769d5fa4831y2u"
app_key
=
"CA52430E90209F51D8F5D7B615DDE9AD"
app_secret
=
"c92691b2379c48de87e699c4c2f7fb32"
select_sql
=
"select class_id from lie_shop_class where platform = 1"
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
)
if
"result"
not
in
ans
[
"jingdong_vc_item_extProps_find_responce"
][
"jos_result_dto"
]:
continue
jd_results
=
ans
[
"jingdong_vc_item_extProps_find_responce"
][
"jos_result_dto"
][
"result"
]
for
j
in
range
(
len
(
jd_results
)):
result
=
jd_results
[
j
]
flag
=
result
[
"is_required"
]
is_required
=
flag
attr_id
=
result
[
"att_id"
]
attr_name
=
result
[
"name"
]
unit
=
result
[
"val_unit"
]
status
=
1
platform
=
1
create_time
=
int
(
time
.
time
())
input_type
=
result
[
"input_type"
]
enum_value
=
"[]"
# 根据 input_type 不同类型分别处理
if
input_type
==
1
or
input_type
==
2
:
# 单选或者多选,获取选项值
ext_prop_value
=
result
[
"ext_prop_value"
]
tmp_list_value
=
[]
for
k
in
range
(
len
(
ext_prop_value
)):
value
=
ext_prop_value
[
k
]
attr_value_id
=
value
[
"value_id"
]
attr_value_name
=
value
[
"value_name"
]
item
=
{
"attr_value_id"
:
attr_value_id
,
"attr_value_name"
:
attr_value_name
}
tmp_list_value
.
append
(
item
)
enum_value
=
json
.
dumps
(
tmp_list_value
,
ensure_ascii
=
False
)
elif
input_type
==
3
:
# 文本类型,无选项值
pass
else
:
print
(
"暂时未兼容此种类型的拓展属性 input_type: "
+
str
(
input_type
))
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
))
...
...
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