我的数据格式是这样的。
{
"as_date": "2023-12-28 20:39:05",
"as_id": 870174131,
"buyer_apply_refund": "579.0",
"buyer_receive_refund": "0.0",
"confirm_date": "2024-01-01 10:51:13",
"created": "2023-12-28 20:39:19",
"currency": "",
"free_amount": "0.0",
"freight": "0",
"good_status": "SELLER_RECEIVED",
"items": [
{
"amount": "579",
"as_id": 870174131,
"asi_id": 870185928,
"i_id": "T23WA37719",
"name": "NORNS LADY/诺恩 秋冬新款大衣 T23WA37719 驼色 M",
"outer_oi_id": "P718618651395344101_XHS-1UJO5VW57SAU",
"pic": "http://qimg.xiaohongshu.com/arkgoods/1040g0o030s89g6f82g005p0o2fl4c9krngbegn0?itemId=656d2a401d547d0001c08fc5&imageView2/1/w/320/h/320/q/90.jpeg",
"price": "579",
"properties_value": "驼色 M(90-110斤)",
"qty": 1,
"r_qty": 1,
"receive_date": "2024-01-01 10:51:13",
"shop_amount": "579",
"shop_sku_id": "df95c3c140a4a4b1e2c42587130954",
"sku_id": "T23WA37719C6M",
"sku_type": "normal",
"type": "退货"
}
],
"l_id": "SF1678324944379",
"labels": "ShopDown",
"logistics_company": "顺丰速运",
"modified": "2024-01-01 11:27:54",
"node": "问题类型不存在",
"o_id": 2631116,
"order_label": "发货后售后",
"order_status": "Sent",
"order_type": "普通订单",
"outer_as_id": "R9534410167144930",
"payment": "0",
"question_type": "多拍/拍错/不想要",
"refund": "579",
"refund_version": "0",
"remark": "",
"shop_buyer_id": "5b2be54d2720f8a01926f0960db956d9",
"shop_freight": "0.0",
"shop_id": "14793704",
"shop_name": "Right Thirty R30服饰的店",
"shop_status": "SUCCESS",
"shop_type": "普通退货",
"so_id": "P718618651395344101",
"status": "Confirmed",
"ts": "7417261917",
"type": "普通退货",
"urefund": "0.0",
"warehouse": "浙江濮院分仓销退仓",
"wh_id": 2,
"wms_co_id": 12851795,
"batchs": [
{
"amount": "579",
"as_id": 870174131,
"asi_id": 870185928,
"i_id": "T23WA37719",
"name": "NORNS LADY/诺恩 秋冬新款大衣 T23WA37719 驼色 M",
"outer_oi_id": "P718618651395344101_XHS-1UJO5VW57SAU",
"pic": "http://qimg.xiaohongshu.com/arkgoods/1040g0o030s89g6f82g005p0o2fl4c9krngbegn0?itemId=656d2a401d547d0001c08fc5&imageView2/1/w/320/h/320/q/90.jpeg",
"price": "579",
"properties_value": "驼色 M(90-110斤)",
"qty": 1,
"r_qty": 1,
"receive_date": "2024-01-01 10:51:13",
"shop_amount": "579",
"shop_sku_id": "df95c3c140a4a4b1e2c42587130954",
"sku_id": "T23WA37719C6M",
"sku_type": "normal",
"type": "退货"
}
]
}
我的规则如下:
1:账户折扣金额:bill_dis_amount是否大于0,如果折扣金额大于0,就用折扣金额-运费,如果折扣金额小于0,就用折扣金额
2:得到商品分录行(material_entity)税费总额 = 每行的tax_price * 每行的qty,取浮点数
3:如果退款金额大于折扣金额,就行折扣金额,否则就取0
4:如果存在退费(urefund),就减去运费
5:如果存在运费(freight),就加上运费
6:如果税费总额-折扣总额不存在0.001的尾差。税费就用当前行税费。如果存在尾差 则将第一个物料实体的tax_price字段设置为调整后的refund值,其他物料实体的tax_price字段设置为0