导图社区 shippingfee2
这是一篇关于shippingfee2的思维导图。本篇思维导图是针对driver_shipping_fee,buyer_shipping_fee做不同层级的运费计。
编辑于2021-08-18 18:41:38shipping fee 2.0
需求
针对driver_shipping_fee,buyer_shipping_fee做不同层级的运费计算
driver部分
配置项获取
Driver Shipping Fee
Module_DriverShippingFee = 7
message DriverShippingFee { optional BaseShippingFee shipping_fee = 1; optional uint64 commission_rate = 2; // 乘1w后保存, 20%=0.2, 0.2*1w=2000 }
message BaseShippingFee { optional uint64 min_shipping_fee = 1; // 乘10w后保存 repeated ShippingFeeTier tiers = 2; }
message ShippingFeeTier { optional uint64 tier_start = 1; // 单位:m optional uint64 tier_end = 2; // 单位:m optional uint64 fixed_fee = 3; // 乘10w后保存 optional uint64 fare = 4; // 乘10w后保存 }
获取area逻辑回归
根据destination的city,district,state进行解析
district_id有对应配置,area_id有对应配置,global有对应配置
默认读district_id对应配置
district_id没有对应配置,area_id有对应配置,global有对应配置
默认读area_id对应配置
district_id没有对应配置,area_id没有对应配置,global有对应配置
默认读global对应配置
district_id没有对应配置,area_id没有对应配置,global没有对应配置
获取为空,读代码默认配置
解析异常使用兜底数据
解析异常要有日志打印
数据项缺失
ShippingFeeTier 层级
tier_start缺失
解析异常调用兜底逻辑
tier_end缺失
解析异常调用兜底逻辑
fixed_fee缺失
解析异常调用兜底逻辑
fare缺失
解析异常调用兜底逻辑
BaseShippingFee层级
min_shipping_fee 缺失
解析异常调用兜底逻辑
tiers 缺失
解析异常调用兜底逻辑
DriverShippingFee层级
shipping_fee缺失
解析异常调用兜底逻辑
commission_rate缺失
解析异常调用兜底逻辑
数据项不符合规范
ShippingFeeTier 层级
当只有一个层级
第一个tier要从0开始
tier_start=0
可以正常解析获取对应参数
tier_start>0
解析异常调用兜底逻辑
tier_start<0
解析异常调用兜底逻辑
tier_end需要>tier_start
tier_end>tier_start
可以正常解析获取对应参数
tier_end<tier_start
解析异常调用兜底逻辑
tier_end=tier_start
解析异常调用兜底逻辑
当有多个层级
第一个tier要从0开始
tier_start=0
可以正常解析获取对应参数
tier_start>0
解析异常调用兜底逻辑
tier_start<0
解析异常调用兜底逻辑
每个层级tier_end需要>tier_starttier_begin和tier_end为三位小数
检查第一个层级和最后一个层级
tier_end>tier_start
可以正常解析获取对应参数
tier_end=tier_start
解析异常调用兜底逻辑
tier_end<tier_start
解析异常调用兜底逻辑
tier层级连续性
second_tier_begin 与 first_tier_end要相等tier_begin和tier_end为三位小数
second_tier_begin = first_tier_end
可以正常解析获取对应参数
second_tier_begin > first_tier_end
解析异常调用兜底逻辑
second_tier_begin < first_tier_end
解析异常调用兜底逻辑
tier层级最多10个
tier_num>10
解析异常调用兜底逻辑
tier_num=10
可以正常解析获取对应参数
子主题
tier_start
范围校验
Min km: 0Max km: 100
小数校验
最多三位小数
tier_end
范围校验
Min km: 0Max km: 100
小数校验
最多三位小数
fixed_fee
范围校验
Min: 0Max: 10,000,000
小数校验
最多两位小数
fare
范围校验
Min: 0Max: 10,000,000
小数校验
最多两位小数
跟业务耦合性太强,以后业务调整需要联动调整
BaseShippingFee层级
min_shipping_fee
范围校验
Min: 0Max: 10,000,000
超过这个范围使用兜底参数
小数校验
最多两位小数
DriverShippingFee层级
commission_rate范围校验
范围校验
Min: 0Max: 10,000
超过这个范围使用兜底参数
小数校验
最多两位小数
Driver Surge Shipping Fee
DB获取
Surge Multiplier
Apply to TH/MY;ID写死为1
cid 部分代码是否有兜底
这部分是前端进行保证还是foody这块也要做代码层面的兜底
命中一个area时
小数校验
最多两位小数
范围校验
Min: 1Max: 3
<0使用兜底参数
>3使用兜底参数
命中多个area时
SM=(SM1 + SM2 + … + SMn) - (N-1)
范围校验
Min: 1Max: 3
<0使用兜底参数
>3使用兜底参数
验证叠加三个的情况是否正确
Surge Fixed Fee(原有的surge shipping fee)
Apply to ID;TH/MY写死为0
cid 部分代码是否有兜底
命中一个area时
小数校验
最多两位小数
范围校验
Min: 0Max: 10,000,000
<0使用兜底参数
>10,000,000使用兜底参数
命中多个area时
SF = SF1 + SF2 + … + SFn
范围校验
Min: 0Max: 10,000,000
<0使用兜底参数
>10,000,000使用兜底参数
验证叠加三个的情况是否正确
兜底参数值
driver运费计算
MY&THDriverEarn:(1 - c) * ( MAX { m , Σat + f(D, xT, bT) } * sm + sf先round up to integer, 再乘以(1-Driver Commission),抽佣后的值正常四舍五入DriverRisingFee:MAX*SM - MAX
配置一个tier
sm=1,sf=0闭合区间{"tier_start":0,"tier_end":1000,"fixed_fee":fixed_fee1,"fare":fare1}
当距离在区间内时0<distance≤1000fixed_fee=fixed_fee1distance_fare=distance/1000*fare1
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
当距离在区间外时1000<distancefixed_fee=fixed_fee1distance_fare=1000*fare1
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
sm=2.35,sf=0闭合区间{"tier_start":0,"tier_end":1000,"fixed_fee":fixed_fee1,"fare":fare1}
当距离在区间内时0<distance≤1000fixed_fee=fixed_fee1distance_fare=distance/1000*fare1
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
非闭合区间
如果前端是above x,这块数据同步过来是(x,100]区间,逻辑与上述闭合区间逻辑一致
配置四个tier
sm=3,sf=0{"tier_start":0,"tier_end":1000,"fixed_fee":fixed_fee1,"fare":fare1},{"tier_start":1000,"tier_end":2000,"fixed_fee":fixed_fee2,"fare":fare2},{"tier_start":2000,"tier_end":3000,"fixed_fee":fixed_fee3,"fare":fare3},{"tier_start":3000,"tier_end":4000,"fixed_fee":fixed_fee4,"fare":fare4}
当距离在第一层级时0<distance≤1000fixed_fee=fixed_fee1distance_fare=distance/1000*fare1
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
当距离在第二层级时1000<distance≤2000fixed_fee=fixed_fee1+fixed_fee2distance_fare=1000*fare1+(distance-1000)/1000*fare2
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
当距离在第三层级时2000<distance≤3000fixed_fee=fixed_fee1+fixed_fee2+fixed_fee3distance_fare=1000*fare1+1000*fare2+(distance-2000)/1000*fare3
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
当距离在第四层级时3000<distance≤4000fixed_fee=fixed_fee1+fixed_fee2+fixed_fee3+fixed_fee4distance_fare=1000*fare1+1000*fare2+1000*fare3+(distance-3000)/1000*fare4
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
当距离在第五层级时4000<distancefixed_fee=fixed_fee1+fixed_fee2+fixed_fee3+fixed_fee4distance_fare=1000*fare1+1000*fare2+1000*fare3+1000*fare4
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
配置十个tier
sm=2,sf=0{"tier_start":0,"tier_end":1000,"fixed_fee":fixed_fee1,"fare":fare1},{"tier_start":1000,"tier_end":2000,"fixed_fee":fixed_fee2,"fare":fare2},{"tier_start":2000,"tier_end":3000,"fixed_fee":fixed_fee3,"fare":fare3},{"tier_start":3000,"tier_end":4000,"fixed_fee":fixed_fee4,"fare":fare4},{"tier_start":4000,"tier_end":5000,"fixed_fee":fixed_fee5,"fare":fare5},{"tier_start":5000,"tier_end":6000,"fixed_fee":fixed_fee6,"fare":fare6},{"tier_start":6000,"tier_end":7000,"fixed_fee":fixed_fee7,"fare":fare7},{"tier_start":7000,"tier_end":8000,"fixed_fee":fixed_fee8,"fare":fare8},{"tier_start":8000,"tier_end":9000,"fixed_fee":fixed_fee9,"fare":fare9},{"tier_start":9000,"tier_end":10000,"fixed_fee":fixed_fee10,"fare":fare10}
当距离在第十层级时9000<distance≤10000fixed_fee=fixed_fee1+fixed_fee2+...+fixed_fee10distance_fare=1000*fare1+1000*fare2+...+1000*fare9+(distance-9000)/1000*fare10
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
当距离大于第十层级时4000<distancefixed_fee=fixed_fee1+fixed_fee2+...+fixed_fee10distance_fare=1000*fare1+1000*fare2+...+1000*fare10
fixed_fee+distance_fare> min shipping fee
DriverEarn:(fixed_fee+distance_fare)* sm*(1 - c)
DriverRisingFee:(fixed_fee+distance_fare)* sm *(1 - c) -(fixed_fee+distance_fare)
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * min shipping fee * sm
DriverRisingFee:min shipping fee * sm*(1 - c) - min shipping fee
IDDriverEarn:(1 - c) * ( MAX { m , Σat + f(D, xT, bT) } * sm + sf最终结果四舍五入到个位DriverRisingFee:SF
按最终配置{"tier_start":0,"tier_end":100,"fixed_fee":12,000,"fare":3,000}
当距离在区间内时0<distance≤100fixed_fee=12000distance_fare=3000if in.Distance / 1000 * fare > minShippingFee { buyerRisingFee = in.BuyerSurgeShippingFee driverRisingFee = in.DriverSurgeShippingFee * (1 - CommissionRate) } else { buyerRisingFee = out.BuyerPay - minShippingFee driverRisingFee = out.DriverEarn - minShippingFee*(1 - CommissionRate) }
未配置sf
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * (min shipping fee + sf)
DriverRisingFee:DriverEarn - minShippingFee*(1 - CommissionRate)
涉及向上取整,存在虽然未配置sf,但最终surgefee有值的情况
fixed_fee+distance_fare> min shipping fee
DriverEarn:(1 - c) *(fixed_fee+distance_fare+sf)
DriverRisingFee:sf * (1 - CommissionRate)
配置sf
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * (min shipping fee + sf)
DriverRisingFee:DriverEarn - minShippingFee*(1 - CommissionRate)
fixed_fee+distance_fare> min shipping fee
DriverEarn:(1 - c) *(fixed_fee+distance_fare+sf)
DriverRisingFee:sf * (1 - CommissionRate)
当距离在区间外时100<distancefixed_fee=12000distance_fare=1000*100
fixed_fee+distance_fare< min shipping fee
DriverEarn:(1 - c) * (min shipping fee + sf)
DriverRisingFee:DriverEarn - minShippingFee*(1 - CommissionRate)
涉及向上取整,存在虽然未配置sf,但最终surgefee有值的情况
fixed_fee+distance_fare> min shipping fee
DriverEarn:(1 - c) *(fixed_fee+distance_fare+sf)
DriverRisingFee:sf * (1 - CommissionRate)
buyer运费计算
功能回归
基础功能
自动化用例保障
读取sql功能
开关打开,根据order_id查询sql
地址修改,获取数据库结果
开关未打开,不查询sql
每次重新进行计算
配置项
buyer_pay: {fn: "roundUpInt", param: 1000} buyer_rising_fee: {fn: "roundDownInt", param: 1} # 表明我们是向下取整1 driver_earn: {fn: "roundUpInt", param: 1000} driver_rising_fee: {fn: "roundDownInt", param: 1}
# roundUpInt 对计算结果向上取整,这里"上"可以常规意义的整1(param=1), 也可以是整10,整1000,由param指定# roundDownInt 对计算结果向下取整,param意义同roundUpInt# roundUpFloat 对计算结果float64小数部分四舍五入保留指定位数的精度,param=2则表示保留两位小数# truncateFloat 对计算结果flaot64小数部分直接截取保留指定位数的精度,param=2则直接保留两位小数
配置项的生效
调整各配置项的生效
Apollo没有配置后读取代码默认配置
Buyer运费计算逻辑
parterner逻辑
接口传入partner_type=1
验证shippingfee 取的NonPartner对应配置项正确,shippingfee计算结果正确
接口传入partner_type=2
验证shippingfee 取的Partner对应配置项正确,shippingfee计算结果正确
接口不传partner_type
验证shippingfee 取的NonPartner对应配置项正确,shippingfee计算结果正确
新计算逻辑校验
主流程场景
各个计算字段均有合理值参与计算
验证结果符合预期
{ "buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 500000 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 100000, "fare": 400000 }, { "tier_start": 3000, "tier_end": 6000, "fixed_fee": 400000, "fare": 400000 }, { "tier_start": 6000, "tier_end": 9000, "fixed_fee": 100000, "fare": 300000 }, { "tier_start": 9000, "tier_end": 120000, "fixed_fee": 300000, "fare": 200000 }] }, "non_partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }] } }} { "order_id": 0, "fee_type_list": [ 0,1,2,3 ], "origin": { "city": "Hello", "district": "Hello", "longitude": 112.704876, "state": "Hello", "address": "Hello", "latitude": -7.155163 }, "destination": { "city": "Hello", "district": "Hello", "longitude": 112.60196, "state": "Hello", "address": "Hello", "latitude": -7.166 }, "store_option": { "partner_type": 2 }}
计算结果准确,但取整逻辑依然有争议
{ "fee_list": [ "5084000", "700000", "0", "0" ], "distance": 11418}手工计算的结果是50.836*100000
各阶段中间结果计算准确前提:buyer minmun<累计计算结果,surge multiplier=1,surge fee fixed=0
buyer fixed fee阶段计算结果
tier配置一层
样例
{ "order_id": 0, "fee_type_list": [ 0,1,2,3 ], "origin": { "city": "Hello", "district": "Hello", "longitude": 112.614876, "state": "Hello", "address": "Hello", "latitude": -7.155163 }, "destination": { "city": "Hello", "district": "Hello", "longitude": 112.60196, "state": "Hello", "address": "Hello", "latitude": -7.166 }, "store_option": { "partner_type": 2 }} { "buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }] }, "non_partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }] } }}
测试结果
{ "fee_list": [ "300000", "700000", "0", "0" ], "distance": 1866}
tier配置5层
样例
{ "buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 3000, "tier_end": 6000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 6000, "tier_end": 9000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 9000, "tier_end": 100000, "fixed_fee": 300000, "fare": 0 }] }, "non_partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }] } }}
测试结果
{ "fee_list": [ "800000", "700000", "0", "0" ], "distance": 11418}
tier配置10层
样例
{ "buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 220000, "fare": 0 }, { "tier_start": 3000, "tier_end": 4000, "fixed_fee": 230000, "fare": 0 }, { "tier_start": 4000, "tier_end": 5000, "fixed_fee": 240000, "fare": 0 }, { "tier_start": 5000, "tier_end": 6000, "fixed_fee": 200000, "fare": 0 }, { "tier_start": 6000, "tier_end": 7000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 7000, "tier_end": 10000, "fixed_fee": 300000, "fare": 0 }, { "tier_start": 10000, "tier_end": 20000, "fixed_fee": 300000, "fare": 0 }, { "tier_start": 20000, "tier_end": 50000, "fixed_fee": 110000, "fare": 0 }, { "tier_start": 50000, "tier_end": 100000, "fixed_fee": 210000, "fare": 0 }] },
fare/km 阶段计算结果
tier配置10层
子主题
{ "buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 0, "fare": 200000 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 0, "fare": 220000 }, { "tier_start": 3000, "tier_end": 4000, "fixed_fee": 0, "fare": 220000 }, { "tier_start": 4000, "tier_end": 5000, "fixed_fee": 0, "fare": 240000 }, { "tier_start": 5000, "tier_end": 6000, "fixed_fee": 0, "fare": 240000 }, { "tier_start": 6000, "tier_end": 7000, "fixed_fee": 0, "fare": 240000 }, { "tier_start": 7000, "tier_end": 10000, "fixed_fee": 0, "fare": 300000 }, { "tier_start": 10000, "tier_end": 20000, "fixed_fee": 0, "fare": 300000 }, { "tier_start": 20000, "tier_end": 50000, "fixed_fee": 0, "fare": 110000 }, { "tier_start": 50000, "tier_end": 100000, "fixed_fee": 0, "fare": 210000 }] },
tier配置5层
子主题
{"buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 0, "fare": 200000 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 0, "fare": 200000 }, { "tier_start": 3000, "tier_end": 6000, "fixed_fee": 0, "fare": 100000 }, { "tier_start": 6000, "tier_end": 9000, "fixed_fee": 0, "fare": 140000 }, { "tier_start": 9000, "tier_end": 100000, "fixed_fee": 0, "fare": 150000 }]}
tier配置一层
子主题
"tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 0, "fare": 100000 }
surge mutiplier
surge mutiplier 配置为默认值1
Rising Shipping Fee for buyer
=0
surge mutiplier (SM) 配置为3
Rising Shipping Fee for buyer
Max Value*(SM-1)
max valueMAX {Buyer Minimum Fee, CUMULATIVE [Buyer Fixed Fee + Distance * Buyer Fare/km]}
surge mutiplier 配置为2.5
buyer shipping fee 计算结果符合预期
buyer surge fixed fee
配置一条surgefee 规则
验证shipping fee 计算结果符合预期
配置多条surgefee规则
surgefee会进行累加,验证shipping fee 计算结果符合预期
取最大值逻辑
buyer minmum fee< 累计结果
buyer shippingfee=累计结果
子主题
buyer minmum fee= 累计结果
buyer shippingfee=累计结果
buyer minmun fee>累计结果
buyer shippingfee= buyer minmun fee
取整逻辑
构造buyershippingfee计算结果中包含小数的计算结果
例如: buyershippingfee计算结果为5.1
最终输出结果为5.1
例如: buyershippingfee计算结果为5.12
最终输出结果为5.12
例如: buyershippingfee计算结果为5.123
最终输出结果为5.13
例如: buyershippingfee计算结果为5.127
最终输出结果为5.13
例如: buyershippingfee计算结果为5.1236
最终输出结果为5.13
rising shipping fee
无取整逻辑
公式中的max value是取整之前的数据参与计算的
异常处理
异常配置
tier配置0层
tier配置11层
tier的配置上限不能涵盖多有的距离
tier的配置下限不能涵盖所有的距离
buyer配置中缺少non-parter
降级使用默认配置
shippingfee1.0计算逻辑回归
buyer业务逻辑梳理
配置区分partner/non-partner的纬度
计算公式
Buyer Shipping Fee = (MAX {Buyer Minimum Fee, CUMULATIVE [Buyer Fixed Fee + Distance * Buyer Fare/km]} * Buyer Surge Multiplier + Buyer Surge Fixed Fee
配置样例
{ "buyer_shipping_fee": { "partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 3000, "tier_end": 6000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 6000, "tier_end": 9000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 9000, "tier_end": 100000, "fixed_fee": 300000, "fare": 0 }] }, "non_partner_shipping_fee": { "min_shipping_fee": 200000, "tiers": [{ "tier_start": 0, "tier_end": 2000, "fixed_fee": 200000, "fare": 0 }, { "tier_start": 2000, "tier_end": 3000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 3000, "tier_end": 6000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 6000, "tier_end": 9000, "fixed_fee": 100000, "fare": 0 }, { "tier_start": 9000, "tier_end": 100000, "fixed_fee": 300000, "fare": 0 }] } }}
分梯度计算字段
fixed fee
fare/km
配置项
默认值
获取配置
格式,边界校验
待确认事项
surge fee的接口代码和数据库结构需变更,此次可以读默认配置,不影响,后续若想支持admin配置,algo需再做开发
distance
走降级逻辑时候,计算的distance会有小数,我们会丢这个结果做取整处理
运营配置缺失,比如没有non-parter的配置
风险自行承担
前端针对配置会乘以5个0保存
th/my的货币单位不一样,也需要乘以5个0?
我们现在的取整逻辑是先除以5个0,进行计算,取整,然后再乘以5个0