|
@@ -1,6 +1,8 @@
|
|
|
package com.sd.cainiao.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.sd.business.entity.express.po.ExpressDelivery;
|
|
@@ -26,10 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -58,10 +57,19 @@ public class IsticeServiceImpl implements IsticeService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public synchronized WaybillCloudPrintResponse takeNum(Long orderEncasementId) {
|
|
|
+ public synchronized JSONObject takeNum(Long orderEncasementId) {
|
|
|
OrderEncasement orderEncasement = orderEncasementService.getById(orderEncasementId);
|
|
|
- if (orderEncasement == null || StrUtil.isNotBlank(orderEncasement.getTrackingNumber())) {
|
|
|
- return null;
|
|
|
+
|
|
|
+ if (orderEncasement == null) {
|
|
|
+ throw new ServiceException("未知装箱订单id");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotBlank(orderEncasement.getTrackingContent())) {
|
|
|
+ return JSONObject.parseObject(orderEncasement.getTrackingContent());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotBlank(orderEncasement.getTrackingNumber())) {
|
|
|
+ throw new ServiceException("手动输入快递单号无法打印订单");
|
|
|
}
|
|
|
|
|
|
Long orderId = orderEncasement.getOrderId();
|
|
@@ -90,10 +98,15 @@ public class IsticeServiceImpl implements IsticeService {
|
|
|
takeNumParam.setReceiveDistrict(orderInfo.getCounty());
|
|
|
takeNumParam.setReceiveDetail(orderInfo.getDetailedAddress());
|
|
|
|
|
|
+ takeNumParam.setObjectId(IdWorker.getIdStr());
|
|
|
+ takeNumParam.setOrderNum(IdWorker.getIdStr());
|
|
|
+
|
|
|
+ StringJoiner joiner = new StringJoiner("\n");
|
|
|
List<ItemParamDto> itemParamList = orderEncasementDetailList.stream().map(item -> {
|
|
|
ItemParamDto itemParam = new ItemParamDto();
|
|
|
- itemParam.setItemName(skuSpecNameMap.get(item.getBomSpecId()));
|
|
|
+ itemParam.setItemName(skuSpecNameMap.get(item.getSkuSpecId()));
|
|
|
itemParam.setItemCount(item.getQuantity().intValue());
|
|
|
+ joiner.add(itemParam.getItemName() + "*" + itemParam.getItemCount());
|
|
|
return itemParam;
|
|
|
}).collect(Collectors.toList());
|
|
|
takeNumParam.setItems(itemParamList);
|
|
@@ -101,10 +114,16 @@ public class IsticeServiceImpl implements IsticeService {
|
|
|
List<WaybillCloudPrintResponse> waybillCloudPrintResponses = takeNum(takeNumParam);
|
|
|
WaybillCloudPrintResponse waybillCloudPrintResponse = waybillCloudPrintResponses.get(0);
|
|
|
|
|
|
+ //拼接模板
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(waybillCloudPrintResponse.getPrintData());
|
|
|
+ jsonObject.put("detail", joiner.toString());
|
|
|
+ jsonObject.put("customTemplateUrl", expressDelivery.getCustomTemplateUrl());
|
|
|
+
|
|
|
orderEncasement.setTrackingNumber(waybillCloudPrintResponse.getWaybillCode());
|
|
|
+ orderEncasement.setTrackingContent(jsonObject.toString());
|
|
|
orderEncasementService.updateById(orderEncasement);
|
|
|
|
|
|
- return waybillCloudPrintResponse;
|
|
|
+ return jsonObject;
|
|
|
}
|
|
|
|
|
|
public List<WaybillCloudPrintResponse> takeNum(TakeNumParamDto dto) {
|