Remove useless country mapper from OrderCreationRequestBody

pull/8040/head
Qiuyi LI 2024-09-18 17:30:49 +02:00
parent 566368ec35
commit 431d2049bd
3 changed files with 13 additions and 22 deletions

View File

@ -7,7 +7,7 @@ public class JsonOrderCreationRequestBody extends OrderCreationRequestBody {
private final String jsonString;
public JsonOrderCreationRequestBody(String jsonString) {
super(null, null);
super(null);
this.jsonString = jsonString;
}

View File

@ -19,8 +19,6 @@ public class OrderCreationRequestBody implements RequestBody {
private List<ShoumanOrderContent> orderContents;
private Map<String, Country> countryMap;
private final static String DEFAULT_SPLIT = ";";
private final static String LINE_BREAK = "\n";
private final static String QUOTE = ":";
@ -30,9 +28,8 @@ public class OrderCreationRequestBody implements RequestBody {
private final static String PRODUCT_GROUP_KEY = "_gpo_product_group";
private final static String PARENT_PRODUCT_GROUP_KEY = "_gpo_parent_product_group";
public OrderCreationRequestBody(List<ShoumanOrderContent> orderContents, Map<String, Country> countryMap) {
public OrderCreationRequestBody(List<ShoumanOrderContent> orderContents) {
this.orderContents = orderContents;
this.countryMap = countryMap;
}
@Override
@ -48,8 +45,6 @@ public class OrderCreationRequestBody implements RequestBody {
putNonNull(json, "address", "收货人:王生 收货地址: 广东省东镇芦莞市寮步溪二路40号汇元佳科技园二栋10楼公司前台 手机17633551138");
putNonNull(json, "addressee", "王生");
putNonNull(json, "city", "东莞市");
String countryName = anyContent.getCountry();
Country country = countryMap.get(countryName);
putNonNull(json, "country", "CHINA");
putNonNull(json, "countryCode", "CN");
// TODO: 2023/11/29 Change to real address

View File

@ -28,14 +28,10 @@ public class ShoumanOrderCreationJob implements Job {
private PlatformOrderContentMapper platformOrderContentMapper;
@Autowired
private IShoumanOrderService shoumanOrderService;
@Autowired
private CountryMapper countryMapper;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
log.info("Started Shouman order creation job");
Map<String, Country> countryCodeMap = countryMapper.findAll().stream()
.collect(toMap(Country::getMabangName, Function.identity()));
List<ShoumanOrderContent> shoumanOrderContents = platformOrderContentMapper.searchShoumanOrderContent();
log.info("Fetched {} shouman order contents", shoumanOrderContents.size());
@ -47,7 +43,7 @@ public class ShoumanOrderCreationJob implements Job {
log.info("Started constructing Shouman request bodies");
List<ShoumanOrder> shoumanOrders = new ArrayList<>();
for (Map.Entry<String, List<ShoumanOrderContent>> entry : groupedByPlatformOrderId.entrySet()) {
OrderCreationRequestBody requestBody = new OrderCreationRequestBody(entry.getValue(), countryCodeMap);
OrderCreationRequestBody requestBody = new OrderCreationRequestBody(entry.getValue());
ShoumanOrder shoumanOrder = new ShoumanOrder();
shoumanOrder.setOrderJson(requestBody.parameters().toJSONString());
shoumanOrder.setPlatformOrderId(entry.getKey());