订单出库(手动出库)

20230922-ljl-fixBug
laixiongwei 1 year ago
parent feade0ede3
commit 3cf281f243

@ -53,5 +53,30 @@ public class OrderMultiPackageOutstorageDTO implements Serializable {
*
*/
private Integer shippedNum;
/**
*
*/
private List<ShippedOrderInfo> shippedOrderInfo;
// =========== 内部使用
private String companyCode;
private String company;
private String logisticsName;
private String logisticsCode;
}
@Data
public static class ShippedOrderInfo implements Serializable {
/**
* id
*/
private String shippedOrderId;
/**
*
*/
private Integer shippedNum;
}
}

@ -1,6 +1,8 @@
package com.ms.api.service;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
import com.ms.api.dto.order.OriginalAndCustomConsigneeInfoRequestDTO;
import com.ms.api.dto.order.OriginalAndCustomConsigneeInfoResponseDTO;
import com.ms.dal.entity.OpOrder;
@ -52,4 +54,12 @@ public interface OpOrderService {
* @param postContent
*/
Boolean updateOpOrderSellerRemarkToDb(Long shopId, String orderId, String remark, Integer flag, Boolean isCoverOriginal, String source, String postContent);
/**
*
* @param orderId
* @param packageList
* @param accessToken
*/
OrderLogisticsAddMultiPackData orderLogisticsAddMultiPackToDd(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList, String accessToken);
}

@ -5,6 +5,8 @@ import java.util.Map;
import java.util.Set;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
import com.ms.dal.bo.OpLogisticsPlatformBO;
import com.ms.dal.bo.OpOrderChildBO;
import com.ms.dal.entity.OpOrderChildLogistics;
@ -38,4 +40,14 @@ public interface OrderPrintService {
Map<String, Integer> getDdLogisticsCompanyCodeAndCompanyIdMap();
/**
*
* @param shopId
* @param orderId
* @param packageList
* @param accessToken
* @param outStorageSource
*/
OrderLogisticsAddMultiPackData orderMultiPackageOutstorage(Long shopId, String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList,
String accessToken, String outStorageSource);
}

@ -1,6 +1,7 @@
package com.ms.api.service;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.ms.api.common.ApiResult;
import com.ms.api.common.Pager;
import com.ms.api.dto.order.*;
@ -65,5 +66,5 @@ public interface PurchaseOrderService {
* @param orderId
* @param packageList
*/
void orderMultiPackageOutstorage(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList);
OrderLogisticsAddMultiPackData orderMultiPackageOutstorage(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList);
}

@ -1,13 +1,6 @@
package com.ms.api.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -28,6 +21,12 @@ import com.doudian.open.api.order_addOrderRemark.param.OrderAddOrderRemarkParam;
import com.doudian.open.api.order_batchSensitive.data.DecryptInfosItem;
import com.doudian.open.api.order_batchSensitive.param.CipherInfosItem;
import com.doudian.open.api.order_batchSensitive.param.OrderBatchSensitiveParam;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackRequest;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackResponse;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.doudian.open.api.order_logisticsAddMultiPack.param.OrderLogisticsAddMultiPackParam;
import com.doudian.open.api.order_logisticsAddMultiPack.param.PackListItem;
import com.doudian.open.api.order_logisticsAddMultiPack.param.ShippedOrderInfoItem;
import com.doudian.open.api.order_orderDetail.data.AfterSaleInfo;
import com.doudian.open.api.order_orderDetail.data.CouponInfoItem;
import com.doudian.open.api.order_orderDetail.data.CouponInfoItem_6_6;
@ -45,13 +44,9 @@ import com.doudian.open.api.order_searchList.OrderSearchListResponse;
import com.doudian.open.api.order_searchList.param.OrderSearchListParam;
import com.ms.api.common.ApiResult;
import com.ms.api.consts.AfterSaleConst;
import com.ms.api.consts.DsOrderConst;
import com.ms.api.consts.OrderChildTagConst;
import com.ms.api.consts.OrderConst;
import com.ms.api.consts.PurchaseOrderConst;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.consts.StatusConst;
import com.ms.api.consts.*;
import com.ms.api.dto.order.DsPurchaseSettingDTO;
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
import com.ms.api.dto.order.OriginalAndCustomConsigneeInfoRequestDTO;
import com.ms.api.dto.order.OriginalAndCustomConsigneeInfoResponseDTO;
import com.ms.api.service.*;
@ -186,6 +181,7 @@ public class OpOrderServiceImpl implements OpOrderService {
@Autowired
private ShopService shopService;
@Override
public int deleteByPrimaryKey(Long id) {
return opOrderMapper.deleteByPrimaryKey(id);
@ -1535,6 +1531,109 @@ public class OpOrderServiceImpl implements OpOrderService {
private Boolean updateOpOrderSellerRemark(Long shopId, String orderId, String remark, Boolean isAddStar, Integer star) {
return opOrderMapper.updateOrderRemark(shopId, orderId, remark, isAddStar ? star : null, new Date()) > 0;
}
@Override
public OrderLogisticsAddMultiPackData orderLogisticsAddMultiPackToDd(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList, String accessToken) {
if (StrUtil.isEmpty(orderId) || CollectionUtil.isEmpty(packageList)) {
throw new RuntimeException("参数错误");
}
Boolean check = checkCanOutStorage(Arrays.asList(orderId), packageList);
if (!check) {
throw new RuntimeException("检测失败");
}
List<PackListItem> itemList = new ArrayList<>();
packageList.stream().forEach(e->{
PackListItem item = new PackListItem();
BeanUtil.copyProperties(e, item);
List<ShippedOrderInfoItem> infoItems = new ArrayList<>();
item.setShippedOrderInfo(infoItems);
if (CollectionUtil.isNotEmpty(e.getShippedOrderInfo())) {
e.getShippedOrderInfo().stream().forEach(it->{
ShippedOrderInfoItem infoItem = new ShippedOrderInfoItem();
BeanUtil.copyProperties(it, infoItem);
infoItems.add(infoItem);
});
}
itemList.add(item);
});
OrderLogisticsAddMultiPackRequest request = new OrderLogisticsAddMultiPackRequest();
OrderLogisticsAddMultiPackParam param = new OrderLogisticsAddMultiPackParam();
param.setOrderId(orderId);
param.setRequestId(UUID.randomUUID().toString());
param.setPackList(itemList);
OrderLogisticsAddMultiPackResponse response = request.execute();
if (!response.isSuccess()) {
throw new RuntimeException(response.getSubMsg());
}
return response.getData();
}
private Boolean checkCanOutStorage(List<String> orderIds, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList) {
if (CollectionUtil.isEmpty(orderIds)) {
throw new RuntimeException("发货接口调用参数错误");
}
List<OpOrder> orderList = getListByOrderIds(orderIds);
if (CollectionUtil.isEmpty(orderList)) {
throw new RuntimeException("订单不存在");
}
List<String> invalidStatusOrderIds = orderList.stream()
.filter(e-> (OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS.equals(e.getOrderStatus())||OrderConst.ORDER_STATUS_PART_DELIVERY.equals(e.getOrderStatus())))
.map(e-> e.getOrderId()).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(invalidStatusOrderIds)) {
throw new RuntimeException(String.format("订单:%s 当前状态不能进行发货操作", invalidStatusOrderIds.toString()));
}
List<OpOrderChildAfterSale> afterSaleList = opOrderChildAfterSaleMapper.selectByOrderIds(orderIds);
List<Integer> statusList = AfterSaleConst.getAfterSaleCloseOrCancelStatusList();
statusList.add(Integer.valueOf(0));
List<String> goingOrderIdList = new ArrayList<>();
List<String> goingChildOrderIdList = new ArrayList<>();
for (OpOrderChildAfterSale afterSale : afterSaleList) {
if (!statusList.contains(afterSale.getAfterSaleStatus())) {
if (!StrUtil.isEmpty(afterSale.getOrderId())) {
goingOrderIdList.add(afterSale.getOrderId());
}
if (!StrUtil.isEmpty(afterSale.getChildOrderId())) {
goingChildOrderIdList.add(afterSale.getChildOrderId());
}
}
}
if (CollectionUtil.isEmpty(goingOrderIdList)) {
return true;
}
if (CollectionUtil.isNotEmpty(packageList)) {
List<String> childOrderIds = new ArrayList<>();
for (OrderMultiPackageOutstorageDTO.PackageInfoDTO packageInfoDTO : packageList) {
if (CollectionUtil.isNotEmpty(packageInfoDTO.getShippedOrderInfo())) {
packageInfoDTO.getShippedOrderInfo().stream().forEach(e->{
childOrderIds.add(e.getShippedOrderId());
});
}
}
if (CollectionUtil.isNotEmpty(goingChildOrderIdList)) {
goingChildOrderIdList.stream().forEach(e->{
if (!childOrderIds.contains(e)) {
childOrderIds.add(e);
}
});
}
throw new RuntimeException(String.format("子订单:%s 处于售后中不能进行发货操作", childOrderIds.toString()));
} else {
throw new RuntimeException(String.format("订单:%s 处于售后中不能进行发货操作", goingOrderIdList.toString()));
}
}
}

@ -9,35 +9,28 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.doudian.open.api.order_orderDetail.data.SpecItem;
import com.ms.api.consts.AppConst;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
import com.ms.api.service.OpOrderService;
import com.ms.api.service.OrderPrintService;
import com.ms.api.tool.CommonTool;
import com.ms.dal.bo.OpLogisticsBO;
import com.ms.dal.bo.OpLogisticsPlatformBO;
import com.ms.dal.bo.OpOrderChildBO;
import com.ms.dal.entity.OpOrderChild;
import com.ms.dal.entity.OpOrderChildAfterSale;
import com.ms.dal.entity.OpOrderChildLogistics;
import com.ms.dal.entity.OpOrderDs;
import com.ms.dal.entity.OpOrderExt;
import com.ms.dal.entity.OpOrderSensitive;
import com.ms.dal.entity.Product;
import com.ms.dal.entity.ProductToDsItem;
import com.ms.dal.entity.PurchaseOrderItem;
import com.ms.dal.mapper.OpLogisticsPlatformMapper;
import com.ms.dal.mapper.OpOrderChildAfterSaleMapper;
import com.ms.dal.mapper.OpOrderChildMapper;
import com.ms.dal.mapper.OpOrderDsMapper;
import com.ms.dal.mapper.OpOrderExtMapper;
import com.ms.dal.mapper.OpOrderSensitiveMapper;
import com.ms.dal.mapper.ProductMapper;
import com.ms.dal.entity.*;
import com.ms.dal.mapper.*;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -59,8 +52,14 @@ public class OrderPrintServiceImpl implements OrderPrintService {
private final OpLogisticsPlatformMapper opLogisticsPlatformMapper;
private final OpLogisticsMapper opLogisticsMapper;
private final RedisTemplate<String, String> redisTemplate;
@Lazy
@Autowired
private OpOrderService opOrderService;
@Override
public Map<String, List<OpOrderChildBO>> getOpOrderChildList(List<String> orderIds, String tag) {
if (ObjectUtil.isEmpty(orderIds)) {
@ -352,4 +351,40 @@ public class OrderPrintServiceImpl implements OrderPrintService {
return productList.stream().collect(Collectors.toMap(x -> x.getProductId().toString(), Product::getItemNum));
}
@Override
public OrderLogisticsAddMultiPackData orderMultiPackageOutstorage(Long shopId, String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList, String accessToken, String outStorageSource) {
List<String> logisticsIds = packageList.stream().map(e->e.getLogisticsId()).collect(Collectors.toList());
Map<Long, OpLogisticsBO> logisticsBOMap = getDdLogisticsListByLogisticsIds(logisticsIds);
for (OrderMultiPackageOutstorageDTO.PackageInfoDTO packageInfoDTO : packageList) {
OpLogisticsBO opLogisticsBO = logisticsBOMap.get(Long.valueOf(packageInfoDTO.getLogisticsId()));
if (BeanUtil.isEmpty(opLogisticsBO)) {
throw new RuntimeException("物流匹配错误");
}
packageInfoDTO.setLogisticsCode(opLogisticsBO.getLogisticsCode());
packageInfoDTO.setLogisticsName(opLogisticsBO.getLogisticsName());
packageInfoDTO.setCompanyCode(opLogisticsBO.getCompanyCode());
packageInfoDTO.setCompany(opLogisticsBO.getLogisticsName());
}
OrderLogisticsAddMultiPackData packData = opOrderService.orderLogisticsAddMultiPackToDd(orderId, packageList, accessToken);
// 保存操作数据,暂时不做
// saveOrderMultiPackageOutstorageResult(shopId, orderId, packageList, packData, outStorageSource);
return packData;
}
private Map<Long, OpLogisticsBO> getDdLogisticsListByLogisticsIds(List<String> logisticsIds) {
if (CollectionUtil.isEmpty(logisticsIds)) {
return new HashMap<>();
}
List<OpLogisticsBO> opLogisticsBOList = opLogisticsMapper.selectLogisticsBOList(logisticsIds, AppConst.appPlatformDd);
if (CollectionUtil.isEmpty(opLogisticsBOList)) {
return new HashMap<>();
}
return opLogisticsBOList.stream().collect(Collectors.toMap(OpLogisticsBO::getLogisticsId, x -> x));
}
}

@ -26,16 +26,10 @@ import com.doudian.open.api.order_BatchSearchIndex.data.OrderBatchSearchIndexDat
import com.doudian.open.api.order_BatchSearchIndex.data.PlainToEncryptIndexListItem;
import com.doudian.open.api.order_BatchSearchIndex.param.OrderBatchSearchIndexParam;
import com.doudian.open.api.order_BatchSearchIndex.param.PlainTextListItem;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.ms.api.common.ApiResult;
import com.ms.api.common.Pager;
import com.ms.api.consts.AfterSaleConst;
import com.ms.api.consts.DsOrderConst;
import com.ms.api.consts.OrderChildTagConst;
import com.ms.api.consts.OrderConst;
import com.ms.api.consts.PurchaseOrderConst;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.consts.StatusConst;
import com.ms.api.consts.TblConst;
import com.ms.api.consts.*;
import com.ms.api.dto.dsorder.AppendVenderRemarkTplItemDTO;
import com.ms.api.dto.order.*;
import com.ms.api.service.AfterSaleService;
@ -1781,13 +1775,15 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
}
@Override
public void orderMultiPackageOutstorage(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList) {
public OrderLogisticsAddMultiPackData orderMultiPackageOutstorage(String orderId, List<OrderMultiPackageOutstorageDTO.PackageInfoDTO> packageList) {
if (StrUtil.isEmpty(orderId) || CollectionUtil.isEmpty(packageList)) {
throw new RuntimeException("参数错误");
}
OpOrder order = opOrderMapper.selectByOrderId(orderId);
Long orderShopId = order.getShopId();
Shop shop = shopService.getDetailById(order.getShopId());
return orderPrintService.orderMultiPackageOutstorage(shop.getShopId(), orderId, packageList, shop.getAccessToken(), LogisticsConst.outstorageSourcePurchaseManualSend);
}
}

@ -6,6 +6,7 @@ package com.ms.api.spi.order;
*/
import cn.hutool.core.collection.CollectionUtil;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
@ -20,6 +21,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import java.util.HashMap;
import java.util.Map;
@ExtensionService("orderMultiPackageOutstorage")
@Slf4j
@AllArgsConstructor
@ -41,17 +45,20 @@ public class OrderMultiPackageOutstorageService extends SPIBaseService implement
// ----逻辑校验----
// ----业务处理----
OrderLogisticsAddMultiPackData packData = null;
try {
purchaseOrderService.orderMultiPackageOutstorage(fields.getOrderId(), fields.getPackageList());
packData = purchaseOrderService.orderMultiPackageOutstorage(fields.getOrderId(), fields.getPackageList());
} catch (RuntimeException exception) {
return R.fail(exception.getLocalizedMessage());
}
// ----结果返回----
Map retData = new HashMap();
retData.put("packList", packData.getPackList());
return BaseResponse.<Ret>builder()
.success(true)
.message("success")
.data(null)
.data(Ret.success(retData))
.code("10000")
.build();
}

@ -0,0 +1,38 @@
package com.ms.dal.bo;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: laixw
* @Date: 2023/9/1
*/
@Data
public class OpLogisticsBO implements Serializable {
/**
* id
*/
private Long logisticsId;
/**
*
*/
private String logisticsName;
/**
*
*/
private String logisticsCode;
/**
* id 1
*/
private Integer companyId;
/**
* sf
*/
private String companyCode;
}

@ -1,8 +1,11 @@
package com.ms.dal.mapper;
import com.ms.dal.bo.OpLogisticsBO;
import com.ms.dal.entity.OpLogistics;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Entity com.ms.dal.entity.OpLogistics
*/
@ -21,4 +24,6 @@ public interface OpLogisticsMapper {
int updateByPrimaryKey(OpLogistics record);
List<OpLogisticsBO> selectLogisticsBOList(List<String> logisticsIds, String platformDd);
}

@ -27,4 +27,6 @@ public interface OpOrderChildAfterSaleMapper {
List<OpOrderChildAfterSale> seteltByChildOrderIds(@Param("childOrderIds")List<String> childOrderIds);
List<OpOrderChildAfterSale> selectByOrderIds(@Param("orderIds")List<String> orderIds);
}

@ -96,4 +96,19 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where logistics_id = #{logisticsId,jdbcType=BIGINT}
</update>
<select id="selectLogisticsBOList" resultType="com.ms.dal.bo.OpLogisticsBO">
select
ol.logistics_id AS logisticsId,
ol.logistics_name AS logisticsName,
ol.logistics_code AS logisticsCode,
olp.company_id AS companyId,
olp.company_code AS companyCode
from op_logistics ol inner join op_logistics_platform olp on ol.logistics_id = olp.logistics_id
where ol.logistics_id in
<foreach collection="logisticsIds" item="logisticsId" index="index" open="(" close=")" separator=",">
#{logisticsId}
</foreach>
and olp.platform = #{platformDd,jdbcType=VARCHAR}
</select>
</mapper>

@ -113,4 +113,14 @@
</foreach>
</if>
</select>
<select id="selectByOrderIds" resultType="com.ms.dal.entity.OpOrderChildAfterSale">
SELECT * FROM op_order_child_after_sale
WHERE 1 =1
<if test="orderIds!=null and orderIds.size>0">
AND order_id IN
<foreach collection="orderIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>

Loading…
Cancel
Save