|
@@ -22,10 +22,13 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static com.alibaba.fastjson.JSON.parseArray;
|
|
|
|
|
@@ -326,13 +329,77 @@ public class ShipServiceImpl implements ShipService {
|
|
|
return ResponseJson.success(logisticsBatch.getId());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 供应商发货记录
|
|
|
+ *
|
|
|
+ * @param shopOrderId 子订单Id
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 每页数量
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> getDeliveryRecord(Integer shopOrderId, int pageNum, int pageSize) {
|
|
|
+ Integer orderId = shipMapper.getOrderIdByShopOrder(shopOrderId);
|
|
|
+ if (null == orderId) {
|
|
|
+ return ResponseJson.error("订单异常,shopOrderId:" + shopOrderId, null);
|
|
|
+ }
|
|
|
+ OrderUserinfoVo userInfo = addressMapper.getOrderUserinfo(orderId);
|
|
|
+ // 分页请求数据
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ // 获取物流批次列表
|
|
|
+ List<LogisticsBatchVo> batchList = orderCommonMapper.getLogisticsBatchList(orderId);
|
|
|
+ if (null != batchList && batchList.size() > 0) {
|
|
|
+ for (LogisticsBatchVo batchVo : batchList) {
|
|
|
+ batchVo.setShopOrderId(shopOrderId);
|
|
|
+ if (StringUtils.isNotBlank(batchVo.getRemarkImage())) {
|
|
|
+ String[] remarkImages = batchVo.getRemarkImage().split("##");
|
|
|
+ batchVo.setRemarkImages(remarkImages);
|
|
|
+ }
|
|
|
+ // 获取发货物流记录
|
|
|
+ List<LogisticsRecordVo> recordList = orderCommonMapper.getLogisticsRecord(shopOrderId, batchVo.getId());
|
|
|
+ if (null != recordList && recordList.size() > 0) {
|
|
|
+ for (LogisticsRecordVo recordVo : recordList) {
|
|
|
+ OrderProductVo orderProduct = shipMapper.getOrderProductById(recordVo.getOrderProductId());
|
|
|
+ recordVo.setBuyNum(orderProduct.getNum() + orderProduct.getPresentNum());
|
|
|
+ recordVo.setImage(orderProduct.getImage());
|
|
|
+ recordVo.setUnit(orderProduct.getProductUnit());
|
|
|
+ // 已发货数量
|
|
|
+ int shipmentsNum = orderProduct.getNum() + orderProduct.getPresentNum() - orderProduct.getNotOutStore();
|
|
|
+ recordVo.setShipmentsNum(shipmentsNum);
|
|
|
+ // 已退货数量
|
|
|
+ Integer returnedNum = orderCommonMapper.countReturnedNum(orderProduct.getShopOrderId(), orderProduct.getProductId());
|
|
|
+ returnedNum = null != returnedNum ? returnedNum : 0;
|
|
|
+ recordVo.setReturnedNum(returnedNum);
|
|
|
+ // 已取消发货数量
|
|
|
+ Integer actualCancelNum = orderCommonMapper.countActualCancelNum(orderProduct.getShopOrderId(), orderProduct.getProductId());
|
|
|
+ actualCancelNum = null != actualCancelNum ? actualCancelNum : 0;
|
|
|
+ // 未发货数量
|
|
|
+ recordVo.setNotShippedNum(orderProduct.getNotOutStore() - actualCancelNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ batchVo.setLogisticsRecordList(recordList);
|
|
|
+ // 获取物流信息
|
|
|
+ List<LogisticsInformationVo> logisticsInfoList = orderCommonMapper.getLogisticsInfoList(batchVo.getId());
|
|
|
+ logisticsInfoList.forEach(logisticsInfo -> {
|
|
|
+ List<LogisticsRouterVo> routers = JSONArray.parseArray(logisticsInfo.getInfo(), LogisticsRouterVo.class);
|
|
|
+ if (!CollectionUtils.isEmpty(routers)) {
|
|
|
+ routers.forEach(router -> {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isEmpty(router.getDesc())) {
|
|
|
+ router.setDesc(router.getContext());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ logisticsInfo.setRouterList(routers);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ batchVo.setLogisticsInformationList(logisticsInfoList);
|
|
|
+ }
|
|
|
+ batchList.removeIf(logisticsBatch -> null == logisticsBatch.getLogisticsRecordList() || 0 == logisticsBatch.getLogisticsRecordList().size());
|
|
|
+ }
|
|
|
+ PageInfo<ShopOrderVo> pageInfo = new PageInfo(batchList);
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
+ map.put("userInfo", userInfo);
|
|
|
+ map.put("logisticsBatchPage", pageInfo);
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|