交易分账 重构

This commit is contained in:
2023-08-29 14:54:41 +08:00
parent f836ddddd2
commit 1a40e284b7
6 changed files with 163 additions and 63 deletions

View File

@@ -212,6 +212,46 @@ public class SpringBootTestController {
@Autowired
private MemberAdapayRecordService memberAdapayRecordService;
/**
* 测试多笔支付情况,解冻部分金额
*/
@Test
public void calculateUnfreezeAmountTest() {
BigDecimal orderAmount = new BigDecimal("28");
List<OrderPayRecord> payRecordList = Lists.newArrayList();
// 第一笔支付记录
JSONObject jsonObject = new JSONObject();
jsonObject.put("paymentId", "1");
jsonObject.put("amount", "10");
OrderPayRecord build = OrderPayRecord.builder()
.payAmount(new BigDecimal("10"))
.deductionRecord(jsonObject.toJSONString())
.build();
payRecordList.add(build);
// 第二笔支付记录
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("paymentId", "2");
jsonObject2.put("amount", "10");
OrderPayRecord build2 = OrderPayRecord.builder()
.payAmount(new BigDecimal("10"))
.deductionRecord(jsonObject2.toJSONString())
.build();
payRecordList.add(build2);
// 第三笔支付记录
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("paymentId", "3");
jsonObject3.put("amount", "10");
OrderPayRecord build3 = OrderPayRecord.builder()
.payAmount(new BigDecimal("10"))
.deductionRecord(jsonObject3.toJSONString())
.build();
payRecordList.add(build3);
List<Map<String, Object>> maps = orderBasicInfoService.calculateUnfreezeAmount(orderAmount, payRecordList);
System.out.println(maps);
}
@Test
public void unfreezeAmountAndUpdateSpendAmountTest() {
String paymentId = "123";