diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java index f0128115..23ac7fcd 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java @@ -324,11 +324,11 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { } HashMap> orderIdAndSkuIdAndSkuSubNameMap = opOrderChildService.getOrderIdAndSkuIdAndSkuSubNameMap(orderIds, skuIds); - System.out.println("orderIdAndSkuIdAndSkuSubNameMap" + orderIdAndSkuIdAndSkuSubNameMap); - System.out.println("platformOrders" + platformOrders); + log.info("orderIdAndSkuIdAndSkuSubNameMap:" + orderIdAndSkuIdAndSkuSubNameMap); + log.info("platformOrders:" + platformOrders); for (PlatformOrderDTO platformOrder: platformOrders) { for (PlatformOrderItemDTO item: platformOrder.getItems()) { - item.setPlatformSkuSubName(orderIdAndSkuIdAndSkuSubNameMap.get(platformOrder.getPlatformOrderId()).get(item.getSourceSkuId())); + item.setPlatformSkuSubName(orderIdAndSkuIdAndSkuSubNameMap.get(platformOrder.getPlatformOrderId()).get(item.getPlatformSkuId())); } } } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildServiceImpl.java index 9dcad93a..4441135d 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildServiceImpl.java @@ -76,14 +76,14 @@ public class OpOrderChildServiceImpl implements OpOrderChildService{ HashMap> map = new HashMap<>(); for (OpOrderChild child: children) { if (map.containsKey(child.getOrderId())) { - map.get(child.getOrderId()).put(child.getSkuId(), child.getSpecDesc()); + map.get(child.getOrderId()).put(child.getSkuId(), child.getSkuSubName()); } else { HashMap skuIdAndSkuSubNameMap = new HashMap<>(); - skuIdAndSkuSubNameMap.put(child.getSkuId(), child.getSpecDesc()); + skuIdAndSkuSubNameMap.put(child.getSkuId(), child.getSkuSubName()); map.put(child.getOrderId(), skuIdAndSkuSubNameMap); } } - return map; + return map; } public List getHistorySkuIdsByOrderId(String orderId) { diff --git a/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java b/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java index 982817f6..a5a02795 100644 --- a/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java +++ b/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java @@ -1023,4 +1023,34 @@ public class CommonTool { public static boolean isMatch(String regex, String str) { return Pattern.compile(regex).matcher(str).find(); } + + public static String mbSubString(String s, int length) throws Exception { + byte[] bytes = s.getBytes("Unicode"); + int n = 0; // 表示当前的字节数 + int i = 2; // 要截取的字节数,从第3个字节开始 + for (; i < bytes.length && n < length; i++) + { + // 奇数位置,如3、5、7等,为UCS2编码中两个字节的第二个字节 + if (i % 2 == 1) { + n++; // 在UCS2第二个字节时n加1 + } else { + // 当UCS2编码的第一个字节不等于0时,该UCS2字符为汉字,一个汉字算两个字节 + if (bytes[i] != 0) + { + n++; + } + } + } + // 如果i为奇数时,处理成偶数 + if (i % 2 == 1) { + // 该UCS2字符是汉字时,去掉这个截一半的汉字 + if (bytes[i - 1] != 0) { + i = i - 1; + } else { + // 该UCS2字符是字母或数字,则保留该字符 + i = i + 1; + } + } + return new String(bytes, 0, i, "Unicode"); + } } diff --git a/ms-dal/src/main/java/com/ms/dal/entity/OpOrderChild.java b/ms-dal/src/main/java/com/ms/dal/entity/OpOrderChild.java index 21cc203f..1397b07e 100644 --- a/ms-dal/src/main/java/com/ms/dal/entity/OpOrderChild.java +++ b/ms-dal/src/main/java/com/ms/dal/entity/OpOrderChild.java @@ -227,6 +227,33 @@ public class OpOrderChild implements Serializable { private String oldSkuSubName; private JSONObject afterSaleInfo; + + private List specList; + + public List getSpecList() { + if (specList == null) { + if (specDesc == null || specDesc.isEmpty()) { + specList = new ArrayList<>(); + } + specList = JSONObject.parseArray(specDesc, Spec.class); + } + return specList; + } + + public String getSkuSubName() { + List specs = getSpecList(); + List skuSubNames = new ArrayList<>(); + for (Spec spec: specs) { + skuSubNames.add(spec.getValue()); + } + return String.join(" ", skuSubNames); + } + + @Data + public static class Spec implements Serializable { + private String name; + private String value; + } } diff --git a/ms-web/src/main/java/com/ms/web/Test.java b/ms-web/src/main/java/com/ms/web/Test.java index 33076f72..b2c39649 100644 --- a/ms-web/src/main/java/com/ms/web/Test.java +++ b/ms-web/src/main/java/com/ms/web/Test.java @@ -71,6 +71,9 @@ public class Test { @Autowired private OutstorageService outstorageService; + @Autowired + private OpOrderChildService opOrderChildService; + @GetMapping("/hello") public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { return String.format("Hello %s!", name); @@ -110,10 +113,11 @@ public class Test { @GetMapping("/test-api") public String testApi() { + HashMap> data = opOrderChildService.getOrderIdAndSkuIdAndSkuSubNameMap(Arrays.asList("6921789682161751044"), Arrays.asList(1777095601448988L)); Map result = outstorageService.matchPurchaseLogisticsInfo("1688DS", "顺丰速运", "SF1610042925672", null); System.out.println(result); // opOrderDsService.updateOpOrderDsFilterStatus("6921789682161751044", "1688DS"); - return "haha"; + return data.toString(); } class Aes @@ -158,6 +162,12 @@ public class Test { } public static void main(String[] args) throws ParseException { + try { + System.out.println(CommonTool.mbSubString("你12324好是的3423423发生45345率的4353发生3453率胜453多负少", 10)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + Pattern p = Pattern.compile("^([T|W])(JT\\d+)$"); Matcher m = p.matcher("WJT23242342342342"); if (m.find()) {