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
79e5ed25
authored
Oct 28, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add helper
parent
c725bd76
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
64 deletions
helper.py
vc.py
helper.py
View file @
79e5ed25
"""
helper.py 此文件主要创建临时脚本,用于数据迁移等等。
将redis中拓展数据更新到 mysql
"""
from
common
import
request_to_jd_vc
import
pymysql
import
redis
import
json
config_dev
=
{
"mysql"
:
{
...
...
@@ -36,62 +34,9 @@ config_prod = {
}
}
def
update_vc_ext_redis
(
conf
:
dict
):
"""
更新redis中的拓展参数
"""
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
()
class_attr_mapping
=
{}
"""
更新前预清空redis
"""
def
get_ext_attr_from_redis
(
conf
:
dict
):
redis_host
=
conf
[
"redis"
][
"host"
]
redis_port
=
conf
[
"redis"
][
"port"
]
redis_password
=
conf
[
"redis"
][
"password"
]
redis_db
=
redis
.
Redis
(
host
=
redis_host
,
port
=
redis_port
,
password
=
redis_password
)
redis_db
.
delete
(
"jd_ext_attr"
)
for
i
in
range
(
len
(
db_results
)):
class_id
=
db_results
[
i
][
0
]
class_attr_mapping
[
class_id
]
=
[]
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
(
"request to jd ...."
)
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
]
attr_id
=
result
[
"att_id"
]
class_attr_mapping
[
class_id
]
.
append
(
attr_id
)
for
class_id
in
class_attr_mapping
:
key
=
str
(
class_id
)
attr_ids
=
class_attr_mapping
[
class_id
]
if
len
(
attr_ids
)
==
0
:
continue
value
=
json
.
dumps
(
attr_ids
,
ensure_ascii
=
False
)
redis_db
.
hset
(
name
=
"jd_ext_attr"
,
key
=
key
,
value
=
value
)
print
(
"jd_ext_attr"
,
key
,
value
)
if
__name__
==
'__main__'
:
config
=
config_prod
update_vc_ext_redis
(
config
)
print
(
"======================> redis中拓展参数更新完毕!"
)
\ No newline at end of file
redis_db
.
hget
(
"jd_ext_attr"
,
""
)
vc.py
View file @
79e5ed25
...
...
@@ -395,7 +395,7 @@ def modify_jd_vc_market_price():
"skuPriceInfo"
:
{
"@type"
:
"com.jd.promotion.external.sdk.request.SkuPriceInfo"
,
"site"
:
301
,
# "marketPrice": ""
,
"marketPrice"
:
143.30
,
"salePrice"
:
131.18
,
"skuId"
:
100124748677
,
},
...
...
@@ -419,9 +419,9 @@ def modify_vc_purchase_price():
"basePriceChanges"
:
[
{
"@type"
:
"com.jd.pps.pub.dto.PpsBasePriceChangeDto"
,
"lineKey"
:
1
,
"lineKey"
:
"1"
,
"changeReason"
:
"修改采购价格内部测试"
,
"discount"
:
"13"
,
"discount"
:
13
,
"orgId"
:
-
1
,
"vendorCode"
:
"ichunt"
,
"price"
:
120.1550
,
...
...
@@ -434,4 +434,5 @@ def modify_vc_purchase_price():
print
(
json
.
dumps
(
ans
,
ensure_ascii
=
False
))
if
__name__
==
'__main__'
:
modify_jd_vc_market_price
()
# modify_jd_vc_market_price()
modify_vc_purchase_price
()
\ No newline at end of file
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