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

View File

@ -5,26 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.domain.api.shouman.JsonOrderCreationRequestBody; 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.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.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.jeecg.modules.business.service.IShoumanOrderService;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List; 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 @Slf4j
public class ShoumanOrderSendJob implements Job { public class ShoumanOrderSendJob implements Job {