Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

订单拆分子订单,子订单金额相加不等于父订单金额

商品*3(购买数量)=1块钱,拆分成三个订单
那么每个商品对应的订单金额就是0.33(程序四舍五入)
我现在把三个订单的金额加起来=0.99,这就少了0.01

我现在是和钱包一起用的,有可能出现这种情况
3个商品3块钱,我用了2块钱包


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

你需要一个求平均数的函数,因为 10/3 除法不尽的,我处理为最后一个数用来做微调
image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...