|
@@ -6,9 +6,13 @@ import com.sd.business.entity.express.po.ExpressDelivery;
|
|
|
import com.sd.business.entity.order.enums.OrderStatusEnum;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
import com.sd.business.entity.order.vo.AssemblyDetailVo;
|
|
|
+import com.sd.business.entity.order.vo.OrderEncasementDetailVo;
|
|
|
+import com.sd.business.entity.order.vo.OrderEncasementVo;
|
|
|
import com.sd.business.service.express.ExpressDeliveryService;
|
|
|
-import com.sd.business.service.order.*;
|
|
|
+import com.sd.business.service.order.IssueBillService;
|
|
|
+import com.sd.business.service.order.OrderService;
|
|
|
import com.sd.cainiao.entity.bo.BasicKeyBo;
|
|
|
+import com.sd.cainiao.entity.dto.ItemParamDto;
|
|
|
import com.sd.cainiao.entity.dto.TakeNumParamDto;
|
|
|
import com.sd.cainiao.service.IsticeService;
|
|
|
import com.taobao.pac.sdk.cp.PacClient;
|
|
@@ -21,10 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -41,15 +42,6 @@ public class IsticeServiceImpl implements IsticeService {
|
|
|
private OrderService orderService;
|
|
|
|
|
|
@Autowired
|
|
|
- private OrderSkuService orderSkuService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OrderEncasementService orderEncasementService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OrderEncasementDetailService orderEncasementDetailService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private ExpressDeliveryService expressDeliveryService;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -62,14 +54,22 @@ public class IsticeServiceImpl implements IsticeService {
|
|
|
|
|
|
List<OrderInfo> orderInfoList = orderService.list(q -> q
|
|
|
.in(BaseIdPo::getId, orderIdList)
|
|
|
- .eq(OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey())
|
|
|
+ .in(OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey(), OrderStatusEnum.COMPLETION_PRODUCTION.getKey())
|
|
|
);
|
|
|
|
|
|
- List<String> expressDeliveryIdList = orderInfoList.stream().map(OrderInfo::getExpressDeliveryId).collect(Collectors.toList());
|
|
|
+ List<Long> expressDeliveryIdList = orderInfoList.stream().map(OrderInfo::getExpressDeliveryId).collect(Collectors.toList());
|
|
|
List<ExpressDelivery> expressDeliveries = expressDeliveryService.listByIds(expressDeliveryIdList);
|
|
|
- Map<Long, ExpressDelivery> collect = expressDeliveries.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+ Map<Long, ExpressDelivery> expressDeliveriesMap = expressDeliveries.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+
|
|
|
+ Map<Long, AssemblyDetailVo> map = new HashMap<>();
|
|
|
|
|
|
for (OrderInfo orderInfo : orderInfoList) {
|
|
|
+
|
|
|
+ ExpressDelivery expressDelivery = expressDeliveriesMap.get(orderInfo.getExpressDeliveryId());
|
|
|
+ if (expressDelivery == null) {
|
|
|
+ throw new ServiceException("订单 " + orderInfo.getCode() + " 没有找到快递网点信息,打印快递单失败");
|
|
|
+ }
|
|
|
+
|
|
|
AssemblyDetailVo assemblyDetailVo = issueBillService.assemblyDetail(orderInfo.getId());
|
|
|
|
|
|
for (AssemblyDetailVo.SkuInfo skuInfo : assemblyDetailVo.getSkuInfoList()) {
|
|
@@ -78,97 +78,48 @@ public class IsticeServiceImpl implements IsticeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ map.put(orderInfo.getId(), assemblyDetailVo);
|
|
|
|
|
|
}
|
|
|
|
|
|
+ for (OrderInfo orderInfo : orderInfoList) {
|
|
|
+ ExpressDelivery expressDelivery = expressDeliveriesMap.get(orderInfo.getExpressDeliveryId());
|
|
|
+
|
|
|
+ TakeNumParamDto takeNumParam = new TakeNumParamDto();
|
|
|
+ takeNumParam.setCpCode(expressDelivery.getExpressageCode());
|
|
|
+ takeNumParam.setName(expressDelivery.getName());
|
|
|
+ takeNumParam.setPhone(expressDelivery.getPhone());
|
|
|
+ takeNumParam.setMobile(expressDelivery.getPhone());
|
|
|
+ takeNumParam.setProvince(expressDelivery.getProvince());
|
|
|
+ takeNumParam.setCity(expressDelivery.getCity());
|
|
|
+ takeNumParam.setDistrict(expressDelivery.getDistrict());
|
|
|
+ takeNumParam.setDetail(expressDelivery.getAddress());
|
|
|
+ takeNumParam.setEmsTemplateUrl(expressDelivery.getTemplateUrl());
|
|
|
+
|
|
|
+ takeNumParam.setReceiveName(orderInfo.getConsignee());
|
|
|
+ takeNumParam.setReceiveMobile(orderInfo.getConsigneeNumber());
|
|
|
+ takeNumParam.setReceiveProvince(orderInfo.getProvince());
|
|
|
+ takeNumParam.setReceiveCity(orderInfo.getCity());
|
|
|
+ takeNumParam.setReceiveDistrict(orderInfo.getCounty());
|
|
|
+ takeNumParam.setReceiveDetail(orderInfo.getDetailedAddress());
|
|
|
+
|
|
|
+ AssemblyDetailVo assemblyDetailVo = map.get(orderInfo.getId());
|
|
|
+
|
|
|
+ for (OrderEncasementVo orderEncasementVo : assemblyDetailVo.getOrderEncasementList()) {
|
|
|
+ List<OrderEncasementDetailVo> orderEncasementDetailList = orderEncasementVo.getOrderEncasementDetailList();
|
|
|
+ List<ItemParamDto> itemParamList = orderEncasementDetailList.stream().map(item -> {
|
|
|
+ ItemParamDto itemParam = new ItemParamDto();
|
|
|
+ itemParam.setItemName(item.getSkuSpecName());
|
|
|
+ itemParam.setItemCount(item.getQuantity().intValue());
|
|
|
+ return itemParam;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ takeNumParam.setItems(itemParamList);
|
|
|
+ List<WaybillCloudPrintResponse> waybillCloudPrintResponses = takeNum(takeNumParam);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- // List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
- //
|
|
|
- // for (TakeNumParamDto takeNumParam : dto) {
|
|
|
- // if (StringUtils.isEmpty(takeNumParam.getId()) || StringUtils.isEmpty(takeNumParam.getAddressId())) {
|
|
|
- // throw new ServiceException("参数异常");
|
|
|
- // }
|
|
|
- //
|
|
|
- // // 根据快递ID去除所有包裹得运单号
|
|
|
- // UpdateWrapper<ExpressPacking> updateWrapper = new UpdateWrapper<>();
|
|
|
- // updateWrapper.set("waybill_no", null);
|
|
|
- // updateWrapper.eq("express_id", takeNumParam.getId());
|
|
|
- // iExpressPackingService.update(updateWrapper);
|
|
|
- //
|
|
|
- // Map<String, Object> result = new HashMap<>();
|
|
|
- //
|
|
|
- // // 查询发货模板
|
|
|
- // Address address = addressService.getById(takeNumParam.getAddressId());
|
|
|
- // takeNumParam.setCpCode(address.getExpressageCode());
|
|
|
- // takeNumParam.setPhone(address.getPhone());
|
|
|
- // takeNumParam.setMobile(address.getPhone());
|
|
|
- // takeNumParam.setProvince(address.getProvince());
|
|
|
- // takeNumParam.setName(address.getName());
|
|
|
- // takeNumParam.setCity(address.getCity());
|
|
|
- // takeNumParam.setDetail(address.getAddress());
|
|
|
- // takeNumParam.setDistrict(address.getDistrict());
|
|
|
- // takeNumParam.setEmsTemplateUrl(address.getTemplateUrl());
|
|
|
- // // 查询装箱数
|
|
|
- // List<ExpressPacking> expressPackingList = iExpressPackingService.list(Wrappers.<ExpressPacking>query().lambda().
|
|
|
- // eq(ExpressPacking::getExpressId, takeNumParam.getId()));
|
|
|
- // // 取出所有装箱ID
|
|
|
- // List<String> expressPackingIds = expressPackingList.stream().map(ExpressPacking::getId).collect(Collectors.toList());
|
|
|
- // // 查询装箱商品信息
|
|
|
- // List<ExpressPackingProduct> packingProductList = iExpressPackingProductService.getContractProductData(expressPackingIds);
|
|
|
- // Map<String, List<ExpressPackingProduct>> map = packingProductList.stream().collect(Collectors.groupingBy(ExpressPackingProduct::getExpressPackingId));
|
|
|
- // // 处理装箱数量.重新计算箱子数
|
|
|
- // List<ExpressPacking> newExpressPackingList = new ArrayList<>();
|
|
|
- // for (ExpressPacking packing : expressPackingList) {
|
|
|
- // for (int i = 0; i < packing.getTotal(); i++) {
|
|
|
- // newExpressPackingList.add(packing);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // // 批量取号
|
|
|
- // List<JSONObject> list = new ArrayList<>();
|
|
|
- // for (ExpressPacking e : newExpressPackingList) {
|
|
|
- //
|
|
|
- // takeNumParam.setOrderNum(IdUtils.dateUUID());
|
|
|
- // takeNumParam.setObjectId(IdUtils.dateUUID());
|
|
|
- // // 赋值产品信息
|
|
|
- // if (MapUtils.isNotEmpty(map)) {
|
|
|
- // List<ExpressPackingProduct> productList = map.get(e.getId());
|
|
|
- // StringBuilder builder = new StringBuilder();
|
|
|
- // for (ExpressPackingProduct p : productList) {
|
|
|
- // List<ItemParam> itemParamList = new ArrayList<>();
|
|
|
- // builder.append(p.getProductColorName()).append("*").append(p.getQuantity()).append("\n");
|
|
|
- // ItemParam itemParam = new ItemParam();
|
|
|
- // itemParam.setItemName(p.getContractProductName() + p.getProductColorName());
|
|
|
- // itemParam.setItemCount(p.getContractProductQuantity());
|
|
|
- // itemParamList.add(itemParam);
|
|
|
- // takeNumParam.setItems(itemParamList);
|
|
|
- // }
|
|
|
- //
|
|
|
- // TmsWaybillGetResponse response = this.takeNum(takeNumParam);
|
|
|
- // WaybillCloudPrintResponse printResponse = response.getWaybillCloudPrintResponseList().get(0);
|
|
|
- // String re = printResponse.getPrintData();
|
|
|
- // JSONObject jsonObject = JSONObject.parseObject(re);
|
|
|
- //
|
|
|
- // // 赋值订单号
|
|
|
- // List<String> stringList = new ArrayList<>();
|
|
|
- // ExpressPacking dataPack = iExpressPackingService.getById(e.getId());
|
|
|
- // if (StringUtils.isNotEmpty(dataPack.getWaybillNo())) {
|
|
|
- // stringList.add(dataPack.getWaybillNo());
|
|
|
- // }
|
|
|
- // stringList.add(printResponse.getWaybillCode());
|
|
|
- // ExpressPacking packing = new ExpressPacking();
|
|
|
- // packing.setWaybillNo(StringUtils.join(stringList, ","));
|
|
|
- // packing.setId(e.getId());
|
|
|
- // iExpressPackingService.updateById(packing);
|
|
|
- // // 拼接模板
|
|
|
- // jsonObject.put("detail", builder.toString());
|
|
|
- // jsonObject.put("customTemplateUrl", address.getCustomTemplateUrl());
|
|
|
- // list.add(jsonObject);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // result.put("packingList", list);
|
|
|
- // resultList.add(result);
|
|
|
- // }
|
|
|
- // return resultList;
|
|
|
return null;
|
|
|
}
|
|
|
|