Commit 4d3149db authored by 邱阿朋's avatar 邱阿朋

feat(vc): 实现回款功能并优化相关模块

- 新增回款功能模块,包括处理正常回款和争议回款
- 添加 PO Code 查询和缓存逻辑
- 实现回款数据导出和推送
- 优化导入信息读取和处理
-调整 ReturnGoods 和 Spa 类的初始化参数
parent a9ef054e
......@@ -38,3 +38,28 @@ def save_xls(data, output_file, sheet_name='Sheet1', adjusted=False):
ws.column_dimensions[column_letter].width = adjusted_width
wb.save(output_file)
def remove_last_comma(csv_file, skip_rows=2):
# 创建一个空列表用于存储处理后的行
cleaned_lines = []
# 读取原始 CSV 文件并处理行末的逗号
with open(csv_file, 'r', encoding='utf-8') as file:
# 跳过指定数量的行
for _ in range(skip_rows):
next(file) # 跳过每一行
for line in file:
# 使用正则表达式替换 空格 + 数字 + 引号
cleaned_line = re.sub(r'(\s\d+)"', r'\1 ', line) # 去掉空格 + 数字后面的引号
# 使用正则表达式替换每个逗号前的空格为引号
cleaned_line = re.sub(r'\s+,\s*"', r'", "', cleaned_line)
# 去掉末尾的逗号和换行符
cleaned_line = cleaned_line.rstrip(',\n')
# 不添加换行符,待会写入时统一处理
cleaned_lines.append(cleaned_line)
# 将处理后的数据逐行写回文件
with open(csv_file, 'w', encoding='utf-8', newline='') as cleaned_file:
for line in cleaned_lines:
cleaned_file.write(line + '\n') # 每一行单独写入,确保每行独立处理
# coding: utf-8
from app.helper import logger
from app.helper import logger, redisx, rabbitmq
log = logger.ConsoleLog()
\ No newline at end of file
log = logger.ConsoleLog()
rdb = redisx.RedisClient()
rabbit = rabbitmq.RabbitMQClient()
This diff is collapsed.
......@@ -2,19 +2,14 @@
# 回款明细
import pandas as pd
from DrissionPage import ChromiumPage as Page
from app.helper import rabbitmq
from app.vc import log
from app.vc import log, rabbit
from app.vc.interface import AutoInterface
class PaymentPush(AutoInterface):
def __init__(self, page: Page, country: str, payee_code: str, shop_code: str):
self.page = page
def __init__(self, country: str, shop_code: str):
self.country = country
self.payeeCode = payee_code
self.shop_code = shop_code
@staticmethod
......@@ -54,7 +49,6 @@ class PaymentPush(AutoInterface):
log.info(f"共计:{len(invoices)} 订单")
rabbit = rabbitmq.RabbitMQClient()
rabbit.connect(queue='refund_robot', routing_key='refund_robot', exchange='reports')
i = 0
......
......@@ -13,10 +13,9 @@ from DrissionPage import ChromiumPage as Page
class ReturnGoods(AutoInterface):
def __init__(self, page: Page, country: str, payee_code: str, shop_code: str):
def __init__(self, page: Page, country: str,shop_code: str):
self.page = page
self.country = country
self.payeeCode = payee_code
self.shop_code = shop_code
# 获取当前日期和时间并格式化
......
......@@ -14,10 +14,9 @@ from app.helper import domain, file, excel, rabbitmq, api
class Spa(AutoInterface):
def __init__(self, page: Page, country: str, payee_code: str, shop_code: str):
def __init__(self, page: Page, country: str, shop_code: str):
self.page = page
self.country = country
self.payeeCode = payee_code
self.shop_code = shop_code
# 获取当前日期和时间并格式化
......
......@@ -3,6 +3,7 @@ import os
from app.helper import file, domain, helper
from app.vc.payment import Payment
from app.vc.payment_push import PaymentPush
from app.vc.return_goods import ReturnGoods
from app.vc.spa import Spa
from DrissionPage import ChromiumPage
......@@ -24,29 +25,32 @@ if __name__ == '__main__':
try:
country = helper.get_input_with_default("国家: [ DE, FR, JP, CA, UK, US ]", "US")
shop_code = helper.get_input_with_default("店铺编码: [ DE-VC, FR-VC, JP-VC, CA-VC, UK-VC, VECELO ]", "VECELO")
payee_code = helper.get_input_with_default("回款Code: [ 详情页url参数 payeeCode ]", "VECET")
action = helper.get_input_with_default("功能:[ spa, return, payment ]", "")
file_name = helper.get_input_with_default("文件名 : [ 例如: ContraCogsInvoices.xls ]", "")
action = helper.get_input_with_default("功能:[ spa, return, payment, payment_erp ]", "")
if action == "":
raise Exception("请输入要执行的功能")
if action.lower() == "payment":
payee_code = helper.get_input_with_default("回款Code: [ 详情页url参数 payeeCode ]", "VECET")
object_instate = Payment(page, country, payee_code, shop_code)
if action.lower() == "payment_erp":
object_instate = PaymentPush(country, shop_code)
elif action.lower() == "return":
object_instate = ReturnGoods(page, country, payee_code, shop_code)
object_instate = ReturnGoods(page, country, shop_code)
elif action.lower() == "spa":
object_instate = Spa(page, country, payee_code, shop_code)
object_instate = Spa(page, country, shop_code)
else:
raise Exception("请输入正确的功能")
file_name = helper.get_input_with_default("文件名 : [ 例如: ContraCogsInvoices.xls ]", "")
if file_name == "":
raise Exception("请输入文件名")
# 切换域名
domain.domain_page(page, country)
# 执行功能
object_instate.run(file_name)
# 推送数据到队列中
object_instate.push_data_queue()
except KeyboardInterrupt:
pass
except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment