20230922-ljl-fixBug
elf 1 year ago
parent a7ccfd905a
commit 32c0c70f91

@ -0,0 +1,10 @@
package com.ms.api.dto.dsorder;
import lombok.Data;
@Data
public class RemarkTplTagDTO {
private String name;
private String content;
private String type;
}

@ -2,6 +2,7 @@ package com.ms.api.consts;
public class AppConst {
public static final String appChineseName = "抖店微应用";
public static final String appVersionCodeFree = "free";
public static final String appVersionCodePaid = "paid";
public static final int serviceMarketOrderCompete = 5;

@ -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());

@ -87,7 +87,7 @@ public class DsApiServiceImpl implements DsApiService {
OperateInfoDTO operateInfo = createOperateInfo(shopId);
Map<String, Object> params = new HashMap<>();
params.put("platform", platform);
params.put("userId", shopId);
params.put("userId", SecurityTool.encodeByAES(String.valueOf(shopId)));
params.put("platformOrderId", orderId);
params.put("sourceOrderId", purchaseOrderSn);
params.put("operateInfo", operateInfo);

@ -1537,8 +1537,9 @@ public class OpOrderServiceImpl implements OpOrderService {
param.setIsAddStar(isAddStar ? "true" : "false");
param.setStar("" + star);
}
System.out.println(param);
OrderAddOrderRemarkResponse response = request.execute();
System.out.println(response);
return response.isSuccess();
}

@ -73,8 +73,7 @@ public class PurchaseOrderItemServiceImpl implements PurchaseOrderItemService{
@Override
public List<PurchaseOrderItem> getRelatePurchaseOrderItemsByPurchaseOrderId(Long purchaseOrderId) {
// TODO
return null;
return purchaseOrderItemMapper.getRelatePurchaseOrderItemsByPurchaseOrderId(purchaseOrderId);
}
@Override

@ -30,6 +30,7 @@ public class CancelPurchaseOrderService extends SPIBaseService implements Extens
distributionOrderService.cancelPurchaseOrder(shopId, requestDTO.getOrderId(), requestDTO.getSkuIds(), source, false);
return R.ok(Ret.success());
} catch (Exception e) {
e.printStackTrace();
log.error("cancelPurchaseOrder fail" + e.getMessage());
return R.ok(Ret.fail(e.getMessage()));
}

@ -28,6 +28,7 @@ public class ClosePurchaseOrderService extends SPIBaseService implements Extensi
distributionOrderService.closeSourceOrderAndCancelRelatePurchaseOrder(shopId, requestDTO.getOrderId(), requestDTO.getPurchaseOrderSn());
return R.ok(Ret.success());
} catch (Exception e) {
e.printStackTrace();
log.error("closePurchaseOrder fail" + e.getMessage());
return R.ok(Ret.fail(e.getMessage()));
}

@ -39,4 +39,6 @@ public interface PurchaseOrderItemMapper {
int updateStatusByOrderId(@Param("shopId") Long shopId, @Param("orderId") String orderId, @Param("status") String status);
List<PurchaseOrderItem> getSkuIdsByOrderId(@Param("orderId") String orderId);
List<PurchaseOrderItem> getRelatePurchaseOrderItemsByPurchaseOrderId(@Param("purchaseOrderId") Long purchaseOrderId);
}

@ -212,7 +212,7 @@
<update id="updateFieldByOrderId">
update op_order_ext
set
{#fieldName} = #{fieldValue,jdbcType=BOOLEAN},
${fieldName} = #{fieldValue,jdbcType=BOOLEAN},
gmt_modified = now()
where order_id = #{orderId,jdbcType=VARCHAR}
and shop_id = #{shopId,jdbcType=BIGINT}

@ -221,4 +221,10 @@
where order_id = #{orderId,jdbcType=VARCHAR}
and shop_id = #{shopId,jdbcType=BIGINT}
</update>
<select id="getRelatePurchaseOrderItemsByPurchaseOrderId" resultMap="BaseResultMap">
select *
from purchase_order_item
where purchase_order_id = #{purchaseOrderId,jdbcType=BIGINT}
and status = 'normal'
</select>
</mapper>

@ -1,6 +1,8 @@
package com.ms.web;
import com.alibaba.fastjson.JSON;
import com.ms.api.dto.dsapi.response.GetPlatformShopPurchaseSettingResponseDTO;
import com.ms.api.dto.dsorder.RemarkTplTagDTO;
import com.ms.api.service.DsApiService;
import com.ms.api.service.OpOrderService;
import com.ms.api.service.PurchaseOrderItemService;
@ -133,14 +135,28 @@ public class Test {
public static void main(String[] args)
{
String str = "<span contenteditable=\"false\" data-field=\"order_id\">#抖店订单号#</span>d<span contenteditable=\"false\" data-field=\"platform_name\">#抖店平台#</span>";
Pattern p = Pattern.compile(PurchaseTool.getRemarkTplRegPattern());
Matcher m = p.matcher(str);
System.out.println(m.find());
System.out.println(m.group(2));
System.out.println(m.find());
System.out.println(m.group(2));
// String str = "<span contenteditable=\"false\" data-field=\"order_id\">#抖店订单号#</span>d<span contenteditable=\"false\" data-field=\"platform_name\">#抖店平台#</span>";
// Pattern p = Pattern.compile(PurchaseTool.getRemarkTplRegPattern());
// Matcher m = p.matcher(str);
// System.out.println(m.find());
// System.out.println(m.group(2));
// System.out.println(m.find());
// System.out.println(m.group(2));
System.out.println(buildRemarkTplHtml("[{\"content\":\"#采购平台#\",\"name\":\"purchase_platform_2\",\"type\":\"field\"},{\"content\":\"#\",\"type\":\"text\"},{\"content\":\"#采购单号#\",\"name\":\"purchase_order_sn\",\"type\":\"field\"},{\"content\":\"#\",\"type\":\"text\"},{\"content\":\"#快递及运单号#\",\"name\":\"logistics_info\",\"type\":\"field\"},{\"content\":\"#\",\"type\":\"text\"},{\"content\":\"#采购账号#\",\"name\":\"purchase_order_buyer\",\"type\":\"field\"}]\n"));
}
private static 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();
}
public void go()

Loading…
Cancel
Save