This commit is contained in:
Guoqs
2025-04-16 13:12:03 +08:00
parent 21772ca796
commit a2348afae6
3 changed files with 61 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.huifu.adapay.core.exception.BaseAdaPayException;
@@ -25,8 +24,10 @@ import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.ykc.ScenarioEnum;
import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.AdapayMemberAccount;
import com.jsowell.pile.domain.OrderUnsplitRecord;
import com.jsowell.pile.service.OrderBasicInfoService;
import com.jsowell.pile.service.OrderUnsplitRecordService;
import org.apache.commons.collections4.CollectionUtils;
@@ -44,7 +45,10 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
@@ -149,19 +153,31 @@ public class PaymentTestController {
String path = "src/test/resources/paymentIdAndAmount";
FileReader fileReader = new FileReader(path);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String str = null;
String str;
while ((str = bufferedReader.readLine()) != null) {
if (str.trim().length() > 2) {
// str根据逗号切割
// str根据逗号切割 002212023102515344310563156645282902016,C88208113664,20.0,2.15,17.85,2023-10-25 15:34:49
String[] strArr = str.split(",");
String paymentId = strArr[0];
String settleAmount = strArr[1];
String orderCode = strArr[2];
String orderCode = strArr[1];
String payAmount = strArr[2];
String refundAmount = strArr[3];
String settleAmount = strArr[4];
String orderTime = strArr[5];
// 如果orderCode长度大于12并且有下划线, 则根据下划线切割只取第一部分
if (orderCode.length() > 12 && orderCode.contains("_")) {
orderCode = orderCode.substring(0, orderCode.indexOf("_"));
}
list.add(ImmutableMap.of("paymentId", paymentId, "settleAmount", settleAmount, "orderCode", orderCode));
Map<String, String> map = Maps.newHashMap();
map.put("paymentId", paymentId);
map.put("orderCode", orderCode);
map.put("payAmount", payAmount);
map.put("refundAmount", refundAmount);
map.put("settleAmount", settleAmount);
map.put("orderTime", orderTime);
list.add(map);
}
}
} catch (Exception e) {
@@ -171,6 +187,26 @@ public class PaymentTestController {
return list;
}
@Test
public void saveOrderUnsplitRecordTest() {
List<Map<String, String>> mapList = getPaymentIdListAndAmountForFile();
List<OrderUnsplitRecord> orderUnsplitRecordList = Lists.newArrayList();
for (Map<String, String> stringMap : mapList) {
OrderUnsplitRecord orderUnsplitRecord = new OrderUnsplitRecord();
orderUnsplitRecord.setPaymentId(stringMap.get("paymentId"));
orderUnsplitRecord.setStatus("");
orderUnsplitRecord.setOrderCode(stringMap.get("orderCode"));
orderUnsplitRecord.setPayAmount(new BigDecimal(stringMap.get("payAmount")));
orderUnsplitRecord.setRefundAmount(new BigDecimal(stringMap.get("refundAmount")));
orderUnsplitRecord.setSettleAmount(new BigDecimal(stringMap.get("settleAmount")));
orderUnsplitRecord.setOrderTime(DateUtils.parseDate(stringMap.get("orderTime")));
orderUnsplitRecordList.add(orderUnsplitRecord);
}
orderUnsplitRecordService.batchInsert(orderUnsplitRecordList);
}
/**
* 从文件获取分账参数
*/