|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ms.api.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ms.api.consts.*;
|
|
|
|
|
import com.ms.api.dto.dsapi.request.*;
|
|
|
|
@ -570,7 +571,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
private HashMap<String, String> buildAndUpdateNewPurchaseOrderRemark(OpOrder opOrder) {
|
|
|
|
|
HashMap<String, String> result = new HashMap<>();
|
|
|
|
|
PurchaseSetting purchaseSetting = purchaseSettingService.getByShopId(opOrder.getShopId());
|
|
|
|
|
List<PurchaseOrder> purchaseOrders = purchaseOrderService.getListByOrderId(opOrder.getShopId(), opOrder.getOpOrderId().toString(), StatusConst.normal,true);
|
|
|
|
|
List<PurchaseOrder> purchaseOrders = purchaseOrderService.getListByOrderId(opOrder.getShopId(), opOrder.getOrderId(), StatusConst.normal,true);
|
|
|
|
|
System.out.println("purchaseOrders1" + purchaseOrders);
|
|
|
|
|
if (purchaseSetting.getIsAppendShopNote() == 0 && purchaseSetting.getIsAppendShopRemark() == 0 && purchaseSetting.getShopRemarkFlag() > 0) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
@ -584,24 +586,33 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
private String buildAndUpdateNewSellerWords(Long shopId, String orderId, String remarkTpl, List<PurchaseOrder> purchaseOrders, Integer shopRemarkFlag) {
|
|
|
|
|
OpOrder opOrder = opOrderService.selectByOrderId(orderId);
|
|
|
|
|
String oldSellerWords = opOrder.getSellerWords();
|
|
|
|
|
oldSellerWords = oldSellerWords == null ? "" : oldSellerWords;
|
|
|
|
|
String newSellerWords = "";
|
|
|
|
|
if (StringUtils.isBlank(remarkTpl)) {
|
|
|
|
|
return oldSellerWords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("sellerWordsRemarkTpl" + remarkTpl);
|
|
|
|
|
String purchaseOrderRemark = buildPurchaseOrderRemark(shopId, remarkTpl, purchaseOrders);
|
|
|
|
|
System.out.println("sellerWordsPurchaseOrderRemark" + purchaseOrderRemark);
|
|
|
|
|
|
|
|
|
|
String appChineseName = "";
|
|
|
|
|
Pattern p = Pattern.compile("【(" + appChineseName + "|0.0):[^】]*】");
|
|
|
|
|
Matcher m = p.matcher(oldSellerWords);
|
|
|
|
|
|
|
|
|
|
boolean hasMatch = false;
|
|
|
|
|
StringBuffer newShopNoteBuffer = new StringBuffer(oldSellerWords.length());
|
|
|
|
|
while (m.find()) {
|
|
|
|
|
hasMatch = true;
|
|
|
|
|
m.appendReplacement(newShopNoteBuffer, purchaseOrderRemark);
|
|
|
|
|
}
|
|
|
|
|
m.appendTail(newShopNoteBuffer);
|
|
|
|
|
newSellerWords = newShopNoteBuffer.toString();
|
|
|
|
|
|
|
|
|
|
if (!hasMatch) {
|
|
|
|
|
newSellerWords = oldSellerWords + purchaseOrderRemark;
|
|
|
|
|
}
|
|
|
|
|
System.out.println("newSellerWords" + newSellerWords);
|
|
|
|
|
System.out.println("oldSellerWords" + oldSellerWords);
|
|
|
|
|
if (newSellerWords.equals(oldSellerWords)) {
|
|
|
|
|
return newSellerWords;
|
|
|
|
|
}
|
|
|
|
@ -609,7 +620,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (newSellerWords.equals(oldSellerWords) && String.valueOf(shopRemarkFlag).equals(opOrder.getSellerRemarkStars())) {
|
|
|
|
|
return newSellerWords;
|
|
|
|
|
}
|
|
|
|
|
opOrderExtService.updateOpOrderShopNote(shopId, orderId, newSellerWords);
|
|
|
|
|
opOrderService.updateOpOrderSellerRemarkToDb(opOrder.getShopId(), opOrder.getOrderId(), newSellerWords, shopRemarkFlag, false, OrderPrintConst.UPDATE_SELLER_WORD_SOURCE_SINGLE, purchaseOrderRemark);
|
|
|
|
|
return newSellerWords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -617,26 +628,34 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
OpOrderExt opOrderExt = opOrderExtService.getByOrderId(orderId);
|
|
|
|
|
String oldShopNote = "";
|
|
|
|
|
String newShopNote = "";
|
|
|
|
|
if (opOrderExt != null) {
|
|
|
|
|
if (opOrderExt != null && StringUtils.isNotBlank(opOrderExt.getShopNote())) {
|
|
|
|
|
oldShopNote = opOrderExt.getShopNote();
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(remarkTpl)) {
|
|
|
|
|
return oldShopNote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("shopNoteRemarkTpl" + remarkTpl);
|
|
|
|
|
String purchaseOrderRemark = buildPurchaseOrderRemark(shopId, remarkTpl, purchaseOrders);
|
|
|
|
|
System.out.println("shopNotePurchaseOrderRemark" + purchaseOrderRemark);
|
|
|
|
|
|
|
|
|
|
String appChineseName = "";
|
|
|
|
|
String appChineseName = AppConst.appChineseName;
|
|
|
|
|
Pattern p = Pattern.compile("【(" + appChineseName + "|0.0):[^】]*】");
|
|
|
|
|
Matcher m = p.matcher(oldShopNote);
|
|
|
|
|
|
|
|
|
|
boolean hasMatch = false;
|
|
|
|
|
StringBuffer newShopNoteBuffer = new StringBuffer(oldShopNote.length());
|
|
|
|
|
while (m.find()) {
|
|
|
|
|
hasMatch = true;
|
|
|
|
|
m.appendReplacement(newShopNoteBuffer, purchaseOrderRemark);
|
|
|
|
|
}
|
|
|
|
|
m.appendTail(newShopNoteBuffer);
|
|
|
|
|
newShopNote = newShopNoteBuffer.toString();
|
|
|
|
|
if (!hasMatch) {
|
|
|
|
|
newShopNote = oldShopNote + purchaseOrderRemark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("newShopNote" + newShopNote);
|
|
|
|
|
System.out.println("oldShopNote" + oldShopNote);
|
|
|
|
|
if (newShopNote.equals(oldShopNote)) {
|
|
|
|
|
return newShopNote;
|
|
|
|
|
}
|
|
|
|
@ -646,6 +665,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String buildPurchaseOrderRemark(Long shopId, String appendRemarkTpl, List<PurchaseOrder> purchaseOrders) {
|
|
|
|
|
appendRemarkTpl = buildRemarkTplHtml(appendRemarkTpl);
|
|
|
|
|
Shop shop = shopService.getDetailById(shopId);
|
|
|
|
|
List<String> purchaseOrderRemarks = new ArrayList<>();
|
|
|
|
|
Pattern p = Pattern.compile(PurchaseTool.getRemarkTplRegPattern());
|
|
|
|
@ -689,8 +709,20 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
if (purchaseOrderRemarks.isEmpty()) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
String appChineseName = "";
|
|
|
|
|
return "【" + appChineseName + ":" + String.join(" / ", purchaseOrderRemarks) + "】";
|
|
|
|
|
return "【" + AppConst.appChineseName + ":" + String.join(" / ", purchaseOrderRemarks) + "】";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String buildRemarkTplHtml(String remarkTpl) {
|
|
|
|
|
List<RemarkTplTagDTO> remarkTplTags = JSON.parseArray(remarkTpl, RemarkTplTagDTO.class);
|
|
|
|
|
StringBuilder remarkTplHtml = new StringBuilder();
|
|
|
|
|
for (RemarkTplTagDTO tag: remarkTplTags) {
|
|
|
|
|
if ("field".equals(tag.getType())) {
|
|
|
|
|
remarkTplHtml.append("<span data-field=\"").append(tag.getName()).append("\">").append(tag.getContent()).append("</span>");
|
|
|
|
|
} else if("text".equals(tag.getType())) {
|
|
|
|
|
remarkTplHtml.append(tag.getContent());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return remarkTplHtml.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String generatePurchaseOrderRemark(MatchResult result , PurchaseOrder purchaseOrder, Shop shop, String profitText, String profitRatioText) {
|
|
|
|
@ -1306,7 +1338,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
throw new RuntimeException("店铺不存在");
|
|
|
|
|
}
|
|
|
|
|
CommonResponseDTO response = dsApiService.cancelPurchaseOrderRelate("dd", shopId, orderId, skuIds);
|
|
|
|
|
if (!response.isSuccess()) {
|
|
|
|
|
if (!response.isSuccess() && false) {
|
|
|
|
|
throw new RuntimeException(response.getReason());
|
|
|
|
|
}
|
|
|
|
|
if (!skuIds.isEmpty()) {
|
|
|
|
@ -1421,8 +1453,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommonResponseDTO response = dsApiService.cancelPurchaseOrder("dd", shopId, orderId, purchaseOrderSn);
|
|
|
|
|
if (!response.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response.getMessage());
|
|
|
|
|
if (!response.isSuccess() && false) {
|
|
|
|
|
throw new RuntimeException(response.getReason());
|
|
|
|
|
}
|
|
|
|
|
String cancelSource = PurchaseOrderConst.PURCHASE_ORDER_CANCEL_SOURCE_DS_CLOSE_CANCEL;
|
|
|
|
|
List<Long> skuIds = items.stream().map(PurchaseOrderItem::getSkuId).collect(Collectors.toList());
|
|
|
|
|