Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amazon_reports
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
common
amazon_reports
Commits
32f102c2
Commit
32f102c2
authored
Nov 13, 2024
by
邱阿朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
payment 优化
parent
d9fc8998
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
payment.py
src/payment.py
+10
-10
No files found.
src/payment.py
View file @
32f102c2
...
@@ -93,9 +93,9 @@ def invoice_details(invoice_number):
...
@@ -93,9 +93,9 @@ def invoice_details(invoice_number):
page_get
(
full_url
)
page_get
(
full_url
)
def
export_details_read_data
(
origin_invoice_number
,
invoice_number
):
def
export_details_read_data
(
invoice_number
):
# # 读取详情内容
# # 读取详情内容
file_name
=
f
"payment
\\
{
origin_
invoice_number}.csv"
file_name
=
f
"payment
\\
{invoice_number}.csv"
if
os
.
path
.
isfile
(
file_name
):
if
os
.
path
.
isfile
(
file_name
):
return
pd
.
read_csv
(
file_name
)
return
pd
.
read_csv
(
file_name
)
...
@@ -198,7 +198,7 @@ def price_extract_data(html_content):
...
@@ -198,7 +198,7 @@ def price_extract_data(html_content):
def
click_get_price_data
(
invoice_number
):
def
click_get_price_data
(
invoice_number
):
cache_key
=
"price_data"
cache_key
=
"price_data"
cache_value
=
rdb
.
get_client
()
.
hget
(
cache_key
,
invoice_number
)
cache_value
=
rdb
.
get_client
()
.
hget
(
cache_key
,
invoice_number
)
if
cache_value
:
if
cache_value
:
return
json
.
loads
(
cache_value
)
return
json
.
loads
(
cache_value
)
...
@@ -219,10 +219,10 @@ def click_get_price_data(invoice_number):
...
@@ -219,10 +219,10 @@ def click_get_price_data(invoice_number):
log
.
warning
(
"未获取到表数据"
)
log
.
warning
(
"未获取到表数据"
)
break
break
def
handle_price_data
(
price_data_list
,
invoice_amount
):
def
handle_price_data
(
price_data_list
,
invoice_amount
):
result
=
{}
result
=
{}
invoice_amount
=
float
(
f
"{invoice_amount:.2f}"
)
invoice_amount
=
abs
(
float
(
f
"{invoice_amount:.2f}"
))
"""处理争议数据"""
"""处理争议数据"""
for
data_list
in
price_data_list
:
for
data_list
in
price_data_list
:
# 计算差异金额单价
# 计算差异金额单价
...
@@ -281,8 +281,6 @@ def main():
...
@@ -281,8 +281,6 @@ def main():
origin_invoice_number
=
data
.
get
(
"Invoice Number"
)
origin_invoice_number
=
data
.
get
(
"Invoice Number"
)
invoice_amount
=
data
.
get
(
"Invoice Amount"
)
invoice_amount
=
data
.
get
(
"Invoice Amount"
)
invoice_number
=
origin_invoice_number
invoice_number
=
origin_invoice_number
# 获取当前订单的Payee和优惠比例
# 获取当前订单的Payee和优惠比例
vendor_payment_terms
=
get_po_code
(
i
,
invoice_number
[:
8
])
vendor_payment_terms
=
get_po_code
(
i
,
invoice_number
[:
8
])
...
@@ -296,13 +294,15 @@ def main():
...
@@ -296,13 +294,15 @@ def main():
last_three
=
invoice_number
[
-
3
:]
# 取后三位
last_three
=
invoice_number
[
-
3
:]
# 取后三位
if
len
(
invoice_number
)
>
8
:
if
len
(
invoice_number
)
>
8
:
# 检查后两位是否在测试列表中
# 检查后两位是否在测试列表中
if
last_two
in
[
"
PC"
,
"MA"
,
"S
C"
]:
if
last_two
in
[
"
MA"
,
"P
C"
]:
invoice_number
=
invoice_number
[:
-
2
]
# 去掉后两位
invoice_number
=
invoice_number
[:
-
2
]
# 去掉后两位
if
last_three
in
[
"PCR"
,
"+SC"
,
"SC-"
]:
if
last_three
in
[
"PCR"
,
"+SC"
,
"SC-"
]:
invoice_number
=
invoice_number
[:
-
3
]
# 去掉最后三位
invoice_number
=
invoice_number
[:
-
3
]
# 去掉最后三位
if
last_two
==
"SC"
:
invoice_number
=
invoice_number
+
'R'
# 判断是否为争议订单
# 判断是否为争议订单
if
last_three
==
"PCR"
:
if
last_three
==
"PCR"
or
last_two
==
"PC"
:
# 获取争议数据
# 获取争议数据
all_price_data
=
click_get_price_data
(
invoice_number
)
all_price_data
=
click_get_price_data
(
invoice_number
)
# 争议回款
# 争议回款
...
@@ -311,7 +311,7 @@ def main():
...
@@ -311,7 +311,7 @@ def main():
all_price_pay_data
.
append
(
pd
.
DataFrame
(
price_data
,
index
=
[
0
]))
all_price_pay_data
.
append
(
pd
.
DataFrame
(
price_data
,
index
=
[
0
]))
else
:
else
:
# 下载excel文件并读取数据
# 下载excel文件并读取数据
detail_data
=
export_details_read_data
(
origin_invoice_number
,
invoice_number
)
detail_data
=
export_details_read_data
(
invoice_number
)
if
detail_data
is
None
:
if
detail_data
is
None
:
log
.
error
(
"数据存在问题,请手动处理"
)
log
.
error
(
"数据存在问题,请手动处理"
)
continue
continue
...
...
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