130 lines
5.0 KiB
Python
130 lines
5.0 KiB
Python
|
|
import pandas as pd
|
|||
|
|
import math
|
|||
|
|
express_price = pd.read_excel(r'D:\test\logistics\data\售价尾端价格.xlsx', sheet_name='Sheet1')
|
|||
|
|
key_column = express_price.iloc[:, 8] # 第 I 列
|
|||
|
|
value_column = express_price.iloc[:, 9] # 第 J 列
|
|||
|
|
small_column = express_price.iloc[:, 10] # 第 K 列
|
|||
|
|
big_column = express_price.iloc[:, 11] # 第 L 列
|
|||
|
|
air_small_dict = dict(zip(key_column, small_column))
|
|||
|
|
air_big_dict = dict(zip(key_column, big_column))
|
|||
|
|
# 转换成字典
|
|||
|
|
ocean_price_dict = dict(zip(key_column, value_column))
|
|||
|
|
def ocean_order_price(packages):
|
|||
|
|
express_fee = 0 # 快递基础费
|
|||
|
|
long_fee = 0 # 超长费
|
|||
|
|
weight_fee = 0 # 超重费
|
|||
|
|
big_fee = 0 # 大包裹费
|
|||
|
|
express_type = ''
|
|||
|
|
express_type_weight = ''
|
|||
|
|
express_type_length = ''
|
|||
|
|
for package in packages:
|
|||
|
|
for key, value in ocean_price_dict.items():
|
|||
|
|
if package.weight <=key:
|
|||
|
|
express_fee+=value
|
|||
|
|
break
|
|||
|
|
if package.fst_size>=116 or package.sed_size>=71 or package.girth>=251:
|
|||
|
|
long_fee += 16.3
|
|||
|
|
if express_type_length == '':
|
|||
|
|
express_type_length ="超长"
|
|||
|
|
if package.weight>=21000 and package.fst_size<238 and package.girth<315:
|
|||
|
|
weight_fee+=25.5
|
|||
|
|
express_type_weight ="超重"
|
|||
|
|
if package.fst_size>=238 or package.girth>=315:
|
|||
|
|
big_fee+=61.6
|
|||
|
|
express_type_length ="大包裹"
|
|||
|
|
express_fee = express_fee + long_fee + weight_fee + big_fee
|
|||
|
|
express_type = express_type_length + express_type_weight
|
|||
|
|
|
|||
|
|
# 卡派(步长为3)
|
|||
|
|
ltl_base = 0
|
|||
|
|
ltl_fee = 0
|
|||
|
|
count1 = 0
|
|||
|
|
count2 = 0
|
|||
|
|
count3 = 0
|
|||
|
|
count4 = 0
|
|||
|
|
ltl_type = '卡派'
|
|||
|
|
order_type_length=''
|
|||
|
|
order_type_weight=''
|
|||
|
|
order_ltl_oversize = 0
|
|||
|
|
order_ltl_overweight1 = 0
|
|||
|
|
order_ltl_overweight2 = 0
|
|||
|
|
order_ltl_overpackage = 0
|
|||
|
|
sku_total_cubic_feet = 0
|
|||
|
|
for package in packages:
|
|||
|
|
cubic_feet= package.length * package.width * package.height / 1000000 * 35.3
|
|||
|
|
sku_total_cubic_feet += cubic_feet
|
|||
|
|
# 卡派额外费用
|
|||
|
|
if package.fst_size>= 250:
|
|||
|
|
count1 += 1
|
|||
|
|
order_ltl_oversize = 118
|
|||
|
|
if order_type_length == '':
|
|||
|
|
order_type_length = '超长'
|
|||
|
|
if package.weight >= 111000:
|
|||
|
|
count2 += 1
|
|||
|
|
order_ltl_overweight1 = 78
|
|||
|
|
order_type_weight = '超重'
|
|||
|
|
if package.weight >= 130000:
|
|||
|
|
count3 += 1
|
|||
|
|
order_ltl_overweight2 = 30
|
|||
|
|
if package.fst_size >= 310:
|
|||
|
|
count4 += 1
|
|||
|
|
order_ltl_overpackage = 30
|
|||
|
|
order_type_length = '大包裹'
|
|||
|
|
order_type2 = ltl_type +order_type_length+ order_type_weight
|
|||
|
|
|
|||
|
|
# 卡派基础费用 体积/1000000 *35.3
|
|||
|
|
if sku_total_cubic_feet < 25:
|
|||
|
|
ltl_base = round(163 / 0.45 / 2, 2) # 181.11
|
|||
|
|
|
|||
|
|
elif sku_total_cubic_feet < 35:
|
|||
|
|
ltl_base = round(180 / 0.45 / 2, 2) # 200
|
|||
|
|
else:
|
|||
|
|
# 大于一个立方的(35立方英尺) 按照每立方英尺*5美金
|
|||
|
|
# 最低为190美金
|
|||
|
|
ltl_base = round(max(190, 5 * sku_total_cubic_feet) / 0.359 / 2)
|
|||
|
|
|
|||
|
|
|
|||
|
|
ltl_fee = math.ceil(count1 / 3) * order_ltl_oversize + math.ceil(count2 / 3) * order_ltl_overweight1 + math.ceil(
|
|||
|
|
count3 / 3) * order_ltl_overweight2 + math.ceil(count4 / 3) * order_ltl_overpackage + ltl_base
|
|||
|
|
|
|||
|
|
if ltl_fee < express_fee:
|
|||
|
|
ocean_fee = ltl_fee
|
|||
|
|
order_type = order_type2
|
|||
|
|
else:
|
|||
|
|
ocean_fee = express_fee
|
|||
|
|
order_type = express_type
|
|||
|
|
return ocean_fee, order_type
|
|||
|
|
|
|||
|
|
def air_order_price(packages):
|
|||
|
|
express_fee = 0
|
|||
|
|
express_type = ''
|
|||
|
|
for package in packages:
|
|||
|
|
price=0
|
|||
|
|
bill_weight = max(package.weight, package.get_volume_weight(8500))
|
|||
|
|
if package.weight<=420 and package.fst_size<=50 and package.sed_size<=40 and package.trd_size<=30:
|
|||
|
|
for key, value in air_small_dict.items():
|
|||
|
|
if package.weight <=key:
|
|||
|
|
price =value
|
|||
|
|
break
|
|||
|
|
elif package.weight<=2718 and package.fst_size<=50 and package.sed_size<=40 and package.trd_size<=30:
|
|||
|
|
for key, value in air_small_dict.items():
|
|||
|
|
if bill_weight <=key:
|
|||
|
|
price =value
|
|||
|
|
break
|
|||
|
|
else:
|
|||
|
|
for key, value in air_big_dict.items():
|
|||
|
|
if bill_weight <=key:
|
|||
|
|
price =value
|
|||
|
|
break
|
|||
|
|
if package.weight<=420:
|
|||
|
|
express_fee+=((((min(max(package.density,37),337)*0.093+27.7)/6+0.65)*package.get_volume_weight(6000))*0.3+price)/0.45
|
|||
|
|
if express_type == '':
|
|||
|
|
express_type='USPS'
|
|||
|
|
elif package.weight<=2718:
|
|||
|
|
express_fee+=(((min(max(package.density,37),337)*0.093+27.7)/6+0.65)*package.get_volume_weight(8500)*0.3+price)/0.45
|
|||
|
|
if express_type == '' or express_type == 'USPS':
|
|||
|
|
express_type='UandF'
|
|||
|
|
else:
|
|||
|
|
express_fee+=(((min(max(package.density,37),337)*0.093+27.7-1.08)/6+0.65-1.06)*package.get_volume_weight(8500))/0.45+price
|
|||
|
|
express_type='FEDEX'
|
|||
|
|
return express_fee, express_type
|