代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
# @Project : pythonProject
# @File : kai_dan_ming_xi_mu_ban
# @Date : 2023/12/21 15:49
# @Author : 徐胜虎
# @Email : 1813366784@qq.com
# @Software : PyCharm
-------------------------------------------------
输入文件 : 开单明细模板.xlsx ==收货报表.xlsx
输出文件 : 当前时间日期的开单明细模板.xlsx
"""
import math
import pandas as pd
import requests
from pandas import DataFrame
from utils import headers, params_login
param_cal_stand_freight = {
'billDeptId': '005223', # 武汉总部收货部 005223
'discDeptId': '004793',
'destDeptId': '',
'serviceType': 10101,
'itemQty': 1,
'itemKgs': 5400,
'itemCbm': 22,
# 'orderDate': datetime.now().timestamp().__int__() * 1000,
# 'isMutant': 0,
# 'terminal': 'PC',
# 'module': 'orderEditApplyDetails'
}
def cal_stand_freight(row_: DataFrame, headers_=None, ref_data_: dict = None, url_: str = None,
param_cal_stand_freight_=None):
if row_['到达部门'] == '':
return None
param_cal_stand_freight_['discDeptId'] = ref_data_[row_['到达部门']]
param_cal_stand_freight_['itemKgs'] = row_['重量']
param_cal_stand_freight_['itemCbm'] = row_['体积']
response_ = requests.post(url_, data=param_cal_stand_freight_, headers=headers_).json()
if response_['code'] == '200':
return math.ceil(response_['rows']['standardFreight'])
else:
return None
def cal_ti_fu_amount(row_: DataFrame, insured_fee=1):
if row_['运费结算方式'] == '提付':
# 忽略转出费
return row_['费用合计'] - row_['送货费'] - insured_fee - row_['回单费']
else:
return None
if __name__ == '__main__':
url = "https://hdd.hddky.com/tms-hdd/token/login"
response = requests.post(url, data=params_login, headers=headers).json()
headers['Authorization'] = response['rows']['token']
ref_dept = pd.read_excel('resources/temp/json.xlsx', header=0, keep_default_na=False,
sheet_name='Sheet2', engine='openpyxl', dtype={'deptId': str})
ref_dept_dict = dict(zip(ref_dept['deptName'], ref_dept['deptId']))
yun_dan_info = pd.read_excel('resources/template/信息录入表.xlsx', header=0, keep_default_na=False,
sheet_name='郑州换单信息录入表', engine='openpyxl', dtype={'收货手机': str})
url = "https://hdd.hddky.com/tms-hdd/freightSchemeHdr/calculationStandardFreight"
response = requests.post(url, data=param_cal_stand_freight, headers=headers).json()
yun_dan_info['标准运费'] = yun_dan_info[['到达部门', '体积', '重量']].apply(cal_stand_freight, headers_=headers,
ref_data_=ref_dept_dict,
param_cal_stand_freight_=param_cal_stand_freight,
url_=url, axis=1).astype(
pd.UInt32Dtype(), errors='ignore')
yun_dan_info['提付金额'] = yun_dan_info[['运费结算方式', '费用合计', '送货费', '回单费']].apply(
cal_ti_fu_amount, axis=1).astype(
pd.UInt32Dtype(), errors='ignore')
yun_dan_info['现付金额'] = yun_dan_info[['运费结算方式', '标准运费']].apply(
lambda row_: row_['标准运费'] if row_['运费结算方式'] in ['现付'] else None, axis=1).astype(
pd.UInt32Dtype(), errors='ignore')
yun_dan_info['佣金'] = yun_dan_info[['运费结算方式', '提付金额', '标准运费']].apply(
lambda row_: row_['提付金额']-row_['标准运费'] if row_['运费结算方式'] in ['提付'] else None, axis=1).astype(
pd.UInt32Dtype(), errors='ignore')
yun_dan_info.to_excel(r'resources/temp/录单.xlsx', index=False, engine='openpyxl')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。