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
cf70e9da
Commit
cf70e9da
authored
Nov 14, 2024
by
邱阿朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
payment 优化
parent
8bc14769
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
4 deletions
+55
-4
diff.py
cmd/diff.py
+34
-0
redisx.py
src/helper/redisx.py
+18
-0
payment.py
src/payment.py
+3
-4
No files found.
cmd/diff.py
0 → 100644
View file @
cf70e9da
import
pandas
as
pd
def
compare_po_and_amount
(
file1
,
file2
):
# 读取两个 Excel 文件
df1
=
pd
.
read_excel
(
file1
)
df2
=
pd
.
read_excel
(
file2
)
# 确保两个表格中都存在 'PO' 和 'Amount' 列
if
'PO'
not
in
df1
.
columns
or
'Amount'
not
in
df1
.
columns
:
raise
ValueError
(
"File 1 is missing required columns: 'PO' or 'Amount'"
)
if
'PO'
not
in
df2
.
columns
or
'Amount'
not
in
df2
.
columns
:
raise
ValueError
(
"File 2 is missing required columns: 'PO' or 'Amount'"
)
# 聚合数据,按照 'PO' 进行分组,并对 'Amount' 进行求和
df1_grouped
=
df1
.
groupby
(
'PO'
,
as_index
=
False
)[
'Amount'
]
.
sum
()
df2_grouped
=
df2
.
groupby
(
'PO'
,
as_index
=
False
)[
'Amount'
]
.
sum
()
# 合并两个数据框,使用 'PO' 列进行比较
merged_df
=
pd
.
merge
(
df1_grouped
,
df2_grouped
,
on
=
'PO'
,
how
=
'outer'
,
suffixes
=
(
'_file1'
,
'_file2'
))
# 找出两列 'Amount' 不相同的行
diff_df
=
merged_df
[
merged_df
[
'Amount_file1'
]
!=
merged_df
[
'Amount_file2'
]]
# 如果没有差异,输出消息
if
diff_df
.
empty
:
print
(
"The PO amounts are identical in both files."
)
else
:
print
(
"The following POs have different amounts:"
)
print
(
diff_df
)
# 使用示例
compare_po_and_amount
(
'file1.xlsx'
,
'file2.xlsx'
)
src/helper/redisx.py
0 → 100644
View file @
cf70e9da
# coding: utf-8
import
redis
class
RedisClient
:
_instance
=
None
def
__new__
(
cls
,
*
args
,
**
kwargs
):
if
not
cls
.
_instance
:
cls
.
_instance
=
super
(
RedisClient
,
cls
)
.
__new__
(
cls
)
cls
.
_instance
.
_initialize
(
*
args
,
**
kwargs
)
return
cls
.
_instance
def
_initialize
(
self
,
host
=
'39.108.185.244'
,
port
=
6379
,
db
=
12
,
password
=
"khd2022!"
,
decode_responses
=
True
):
self
.
client
=
redis
.
StrictRedis
(
host
=
host
,
port
=
port
,
db
=
db
,
password
=
password
,
decode_responses
=
decode_responses
)
def
get_client
(
self
):
return
self
.
client
\ No newline at end of file
src/payment.py
View file @
cf70e9da
...
...
@@ -304,16 +304,15 @@ def main():
if
last_three
==
"PCR"
or
last_two
==
"PC"
:
cache_key
=
"price_data"
price_data
=
rdb
.
get_client
()
.
hget
(
cache_key
,
invoice_number
)
if
price_data
is
None
:
if
price_data
:
price_data
=
json
.
loads
(
price_data
)
else
:
# 进入详情页
invoice_details
(
invoice_number
,
last_two
,
last_three
)
# 获取争议数据
price_data
=
click_get_price_data
()
# 缓存数据
rdb
.
get_client
()
.
hset
(
cache_key
,
invoice_number
,
json
.
dumps
(
price_data
))
else
:
price_data
=
json
.
loads
(
price_data
)
# 争议回款
handle_after_price_data
=
handle_price_data
(
price_data
,
invoice_amount
)
format_price_data
=
handle_data
(
handle_after_price_data
,
vendor
,
deduction_points
)
...
...
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