Update Shouman remark generation with multiple regexes

pull/8040/head
Qiuyi LI 2024-08-01 17:35:12 +02:00
parent 983d86580e
commit 695b9be21f
2 changed files with 23 additions and 27 deletions

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.jeecg.modules.business.entity.Country;
import org.jeecg.modules.business.entity.ShoumanOrderContent;
import org.jeecg.modules.business.entity.ShoumanRegex;
import java.math.BigDecimal;
import java.util.Calendar;
@ -20,7 +21,6 @@ public class OrderCreationRequestBody implements RequestBody {
private final static String DEFAULT_SPLIT = ";";
private final static String LINE_BREAK = "\n";
private final static String CUSTOM = "定制";
private final static String QUOTE = ":";
private final static String WIA = "维亚智通";
private final static String TRANSACTION_NUMBER = "交易号";
@ -61,8 +61,7 @@ public class OrderCreationRequestBody implements RequestBody {
totalPrice = totalPrice.add(price);
putNonNull(contentJson, "theImagePath", content.getImageUrl());
putNonNull(contentJson, "comment", generateRemark(content.getRemark(), content.getCustomizationData(),
content.getContentRecRegex(), content.getContentExtRegex(), content.getShopErpCode(),
content.getPlatformOrderNumber()));
content.getRegexList(), content.getShopErpCode(), content.getPlatformOrderNumber()));
putNonNull(contentJson, "sku", content.getSku());
putNonNull(contentJson, "outboundNumder", content.getQuantity()); // Typo intended
outboundInfos.add(contentJson);
@ -72,7 +71,7 @@ public class OrderCreationRequestBody implements RequestBody {
return json;
}
private String generateRemark(String baseRemark, String customizationData, String contentRecRegex, String contentExtRegex,
private String generateRemark(String baseRemark, String customizationData, List<ShoumanRegex> regexList,
String shopErpCode, String platformOrderNumber) {
StringBuilder sb = new StringBuilder();
String[] baseRemarks = baseRemark.split(DEFAULT_SPLIT);
@ -81,19 +80,28 @@ public class OrderCreationRequestBody implements RequestBody {
.append(LINE_BREAK);
}
for (ShoumanRegex regex : regexList) {
String[] strings = customizationData.split(DEFAULT_SPLIT);
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
if (string.matches(contentRecRegex)) {
if (string.matches(regex.getContentRecRegex())) {
String trimmed = string.trim();
String content = trimmed.split(contentExtRegex)[1];
sb.append(CUSTOM)
String content = trimmed.split(regex.getContentExtRegex())[1];
if (regex.getIsSizeRegex().equalsIgnoreCase("1")) {
RingSize ringSize = RingSize.getBySize(Integer.valueOf(content));
if (ringSize != null) {
sb.append(ringSize.getText());
}
} else {
sb.append(regex.getPrefix())
.append(i + 1)
.append(QUOTE)
.append(content)
.append(LINE_BREAK);
}
}
}
}
sb.append(SHOP_CODE)
.append(shopErpCode)
.append(LINE_BREAK);

View File

@ -5,26 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.domain.api.shouman.JsonOrderCreationRequestBody;
import org.jeecg.modules.business.domain.api.shouman.OrderCreationRequest;
import org.jeecg.modules.business.domain.api.shouman.OrderCreationRequestBody;
import org.jeecg.modules.business.domain.api.shouman.Request;
import org.jeecg.modules.business.entity.Country;
import org.jeecg.modules.business.entity.Shouman.ShoumanOrder;
import org.jeecg.modules.business.entity.ShoumanOrderContent;
import org.jeecg.modules.business.mapper.CountryMapper;
import org.jeecg.modules.business.mapper.PlatformOrderContentMapper;
import org.jeecg.modules.business.service.IShoumanOrderService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toMap;
@Slf4j
public class ShoumanOrderSendJob implements Job {