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
fdf39291
authored
Oct 28, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add crontab pop
parent
adc1f5c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
crontab_pop.py
crontab_pop.py
View file @
fdf39291
...
@@ -5,6 +5,7 @@ from common import request_to_jd_pop
...
@@ -5,6 +5,7 @@ from common import request_to_jd_pop
import
pymysql
import
pymysql
import
time
import
time
import
sys
import
sys
import
json
config_dev
=
{
config_dev
=
{
...
@@ -73,6 +74,71 @@ def update_pop_class(conf: dict):
...
@@ -73,6 +74,71 @@ def update_pop_class(conf: dict):
db
.
commit
()
db
.
commit
()
print
(
sql
%
(
parent_id
,
class_id
,
class_name
,
depth
,
status
,
platform
,
create_time
))
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
)
...
@@ -89,3 +155,4 @@ if __name__ == '__main__':
...
@@ -89,3 +155,4 @@ if __name__ == '__main__':
elif
environment
==
"prod"
:
elif
environment
==
"prod"
:
config
=
config_prod
config
=
config_prod
update_pop_class
(
config
)
update_pop_class
(
config
)
print
(
"======================> pop分类已更新"
)
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