20230922-ljl-fixBug
elf 2 years ago
parent 00f05d142c
commit 7c24869382

@ -1,7 +1,10 @@
package com.ms.api.dsorder;
import lombok.Data;
import java.util.List;
@Data
public class DsPurchaseOrderDto {
private String platformOrderId;
private String purchasePlatform;
@ -21,4 +24,8 @@ public class DsPurchaseOrderDto {
private String alibabaOrderStatus;
private Boolean isUseManualConsignee;
private List<PurchaseOrderItemDto> items;
private String checkReason;
private String checkStatus;
private Integer logisticsIsAccept;
private String purchaseOrderSendTime;
}

@ -2,6 +2,9 @@ package com.ms.api.service;
import com.ms.dal.entity.OpOrderChild;
import java.util.HashMap;
import java.util.List;
/**
*
*/
@ -18,4 +21,10 @@ public interface OpOrderChildService {
int updateByPrimaryKeySelective(OpOrderChild record);
int updateByPrimaryKey(OpOrderChild record);
List<OpOrderChild> getListByOrderIdsAndSkuIds(List<String> orderIds, List<Integer> skuIds);
HashMap<String, HashMap<Integer, String>> getOrderIdAndSkuIdAndSkuSubNameMap(List<String> orderIds, List<Integer> skuIds);
List<Integer> getHistorySkuIdsByOrderId(String orderId);
}

@ -2,6 +2,8 @@ package com.ms.api.service;
import com.ms.dal.entity.OpOrderEncrypt;
import java.util.List;
/**
*
*/
@ -18,4 +20,6 @@ public interface OpOrderEncryptService {
int updateByPrimaryKeySelective(OpOrderEncrypt record);
int updateByPrimaryKey(OpOrderEncrypt record);
List<OpOrderEncrypt> getListByOrderIds(List<String> orderIds);
}

@ -18,4 +18,6 @@ public interface OpOrderExtService {
int updateByPrimaryKeySelective(OpOrderExt record);
int updateByPrimaryKey(OpOrderExt record);
OpOrderExt getByOrderId(String orderId);
}

@ -2,6 +2,8 @@ package com.ms.api.service;
import com.ms.dal.entity.PurchaseOrderItem;
import java.util.List;
/**
*
*/
@ -18,4 +20,6 @@ public interface PurchaseOrderItemService {
int updateByPrimaryKeySelective(PurchaseOrderItem record);
int updateByPrimaryKey(PurchaseOrderItem record);
List<Integer> getSkuIdsByOrderId(String orderId);
}

@ -18,4 +18,6 @@ public interface PurchaseOrderService {
int updateByPrimaryKeySelective(PurchaseOrder record);
int updateByPrimaryKey(PurchaseOrder record);
PurchaseOrder getByPlatformAndPurchaseOrderSn(String platform, String purchaseOrderSn);
}

@ -1,20 +1,18 @@
package com.ms.api.service.impl;
import com.ms.api.consts.PurchaseOrderTagConst;
import com.ms.api.dsorder.*;
import com.ms.api.service.DistributionOrderService;
import com.ms.api.service.OpOrderChildService;
import com.ms.api.service.OpOrderEncryptService;
import com.ms.api.service.OpOrderService;
import com.ms.dal.entity.OpOrder;
import com.ms.dal.entity.OpOrderEncrypt;
import com.ms.api.service.*;
import com.ms.dal.entity.*;
import io.micrometer.core.lang.Nullable;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -29,6 +27,18 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
@Autowired
private OpOrderEncryptService opOrderEncryptService;
@Autowired
private PurchaseOrderService purchaseOrderService;
@Autowired
private PurchaseOrderUpdateLogService purchaseOrderUpdateLogService;
@Autowired
private OpOrderExtService opOrderExtService;
@Autowired
private PurchaseOrderItemService purchaseOrderItemService;
private DsRetDto batchCreateDistributionOrders(Integer shopId, BatchCreateDistributionOrdersDto batchCreateDistributionOrdersDto) {
checkPurchaseOrders(batchCreateDistributionOrdersDto.getPlatformOrders());
@ -144,7 +154,126 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
return platformOrders;
}
private void dsRelatePurchaseOrder(DsPurchaseOrderDto $purchaseOrder, OpOrder opOrder) {
private void dsRelatePurchaseOrder(DsPurchaseOrderDto purchaseOrder, OpOrder opOrder) {
PurchaseOrder basePurchaseOrder = purchaseOrderService.getByPlatformAndPurchaseOrderSn(purchaseOrder.getPurchasePlatform(), purchaseOrder.getPurchaseOrderSn());
}
private void updatePurchaseOrderInfo(DsPurchaseOrderDto purchaseOrder, PurchaseOrder dbPurchaseOrder, OpOrder opOrder) {
String orderId = purchaseOrder.getPlatformOrderId();
Date purchaseOrderSendTime = null;
Date purchaseOrderStartTime = null;
if (StringUtils.isNotBlank(purchaseOrder.getPurchaseOrderStartTime())) {
purchaseOrderStartTime = DateUtils.parseDate(purchaseOrder.getPurchaseOrderStartTime(),["yyyy-MM-dd HH:ii:ss"]);
}
if (StringUtils.isNotBlank(purchaseOrder.getPurchaseOrderSendTime())) {
purchaseOrderSendTime = DateUtils.parseDate(purchaseOrder.getPurchaseOrderSendTime(),["yyyy-MM-dd HH:ii:ss"]);
}
dbPurchaseOrder.setPurchasePlatform(purchaseOrder.getPurchasePlatform());
dbPurchaseOrder.setPurchaseOrderSn(purchaseOrder.getPurchaseOrderSn());
dbPurchaseOrder.setPurchaseOrderRefundMoney(new BigDecimal(0));
dbPurchaseOrder.setPurchaseOrderBuyer(purchaseOrder.getPurchaseOrderBuyer());
dbPurchaseOrder.setPurchaseOrderSeller(purchaseOrder.getPurchaseOrderSeller());
dbPurchaseOrder.setPurchaseOrderStatus(purchaseOrder.getPurchaseOrderStatus());
dbPurchaseOrder.setPurchaseOrderLogisticsName(purchaseOrder.getPurchaseOrderLogisticsName());
dbPurchaseOrder.setPurchaseOrderWaybillCode(purchaseOrder.getPurchaseOrderWaybillCode());
dbPurchaseOrder.setPurchaseOrderStartTime(purchaseOrderStartTime);
dbPurchaseOrder.setPurchaseOrderSendTime(purchaseOrderSendTime);
dbPurchaseOrder.setPurchaseOrderFullname(purchaseOrder.getPurchaseOrderFullname());
dbPurchaseOrder.setPurchaseOrderMobile(purchaseOrder.getPurchaseOrderMobile());
dbPurchaseOrder.setPurchaseOrderFullAddress(purchaseOrder.getPurchaseOrderFullAddress());
dbPurchaseOrder.setLogisticsIsAccept(purchaseOrder.getLogisticsIsAccept());
dbPurchaseOrder.setOperateShopId(opOrder.getShopId());
dbPurchaseOrder.setCheckReason(purchaseOrder.getCheckReason());
dbPurchaseOrder.setCheckStatus(purchaseOrder.getCheckStatus());
dbPurchaseOrder.setGmtLastCheckStatus(new Date());
dbPurchaseOrder.setGmtModified(new Date());
purchaseOrderService.updateByPrimaryKey(dbPurchaseOrder);
if (purchaseOrder.getPurchaseOrderPayment() != null) {
BigDecimal purchaseOrderPayment = new BigDecimal(purchaseOrder.getPurchaseOrderPayment());
dbPurchaseOrder.setPurchaseOrderPayment(purchaseOrderPayment);
}
OpOrderExt orderExt = opOrderExtService.getByOrderId(dbPurchaseOrder.getOrderId());
if (dbPurchaseOrder.getStatus().equals("normal") && orderExt != null && orderExt.getFilterPurchaseStatus() != null) {
updateOpOrderFilterPurchaseStatus(opOrder.getOrderId(), orderExt);
}
}
public void comparePurchaseOrderAndAddUpdateLog(DsPurchaseOrderDto purchaseOrder, Long shopId, String action) {
PurchaseOrderUpdateLog log = new PurchaseOrderUpdateLog();
log.setOrderId(purchaseOrder.getPlatformOrderId());
log.setAction(action);
log.setPurchasePlatform(purchaseOrder.getPurchasePlatform());
log.setPurchaseOrderSn(purchaseOrder.getPurchaseOrderSn());
log.setPurchaseOrderBuyer(purchaseOrder.getPurchaseOrderBuyer());
log.setPurchaseOrderSeller(purchaseOrder.getPurchaseOrderSeller());
log.setPurchaseOrderLogisticsName(purchaseOrder.getPurchaseOrderLogisticsName());
log.setPurchaseOrderWaybillCode(purchaseOrder.getPurchaseOrderWaybillCode());
log.setPurchaseOrderFullname(purchaseOrder.getPurchaseOrderFullname());
log.setPurchaseOrderMobile(purchaseOrder.getPurchaseOrderMobile());
log.setPurchaseOrderFullAddress(purchaseOrder.getPurchaseOrderFullAddress());
log.setOperateShopId(shopId);
log.setGmtModified(new Date());
log.setGmtCreate(new Date());
purchaseOrderUpdateLogService.insert(log);
}
private void checkPurchaseOrderLogisticsChangeAndAddTag(DsPurchaseOrderDto purchaseOrder, PurchaseOrder oldPurchaseOrderInfo) {
if (
StringUtils.isBlank(oldPurchaseOrderInfo.getPurchaseOrderLogisticsName()) ||
StringUtils.isBlank(oldPurchaseOrderInfo.getPurchaseOrderWaybillCode()) ||
StringUtils.isBlank(purchaseOrder.getPurchaseOrderLogisticsName()) ||
StringUtils.isBlank(purchaseOrder.getPurchaseOrderWaybillCode())
) {
return;
}
if (purchaseOrder.getPurchaseOrderLogisticsName().equals(oldPurchaseOrderInfo.getPurchaseOrderLogisticsName()) && purchaseOrder.getPurchaseOrderWaybillCode().equals(oldPurchaseOrderInfo.getPurchaseOrderWaybillCode())) {
return;
}
// PurchaseOrderTag tag = new PurchaseOrderTag();
// tag.setShopId(oldPurchaseOrderInfo.getShopId());
// tag.setOrderId(oldPurchaseOrderInfo.getOrderId());
// tag.setPurchaseOrderId(oldPurchaseOrderInfo.getPurchaseOrderId());
// tag.setTagField("hasChangedLogistics");
// tag.setTagValue("1");
// tag.setGmtModified(new Date());
// tag.setGmtCreate(new Date());
}
private void updateOpOrderFilterPurchaseStatus(String orderId, @Nullable OpOrderExt opOrderExt) {
if (opOrderExt == null) {
opOrderExt = opOrderExtService.getByOrderId(orderId);
}
List<Integer> historySkuIds = opOrderChildService.getHistorySkuIdsByOrderId(orderId);
List<Integer> purchaseSkuIds = purchaseOrderItemService.getSkuIdsByOrderId(orderId);
List<Integer> noPurchaseSkuIds = historySkuIds.stream().filter(i -> !purchaseSkuIds.contains(i)).collect(Collectors.toList());
Integer filterPurchaseStatus = null;
if (purchaseSkuIds.isEmpty()) {
filterPurchaseStatus = 0;
} else if (!noPurchaseSkuIds.isEmpty() && opOrderExt.getFilterPurchaseStatus() != 3) {
filterPurchaseStatus = 1;
} else if (noPurchaseSkuIds.isEmpty()) {
filterPurchaseStatus = 2;
}
if (filterPurchaseStatus == null) {
return;
}
opOrderExt.setFilterPurchaseStatus(filterPurchaseStatus);
opOrderExt.setGmtModified(new Date());
opOrderExtService.updateByPrimaryKey(opOrderExt);
}
public void updateOpOrderDsFilterStatus(String orderId, String purchasePlatform) {
}
private void savePurchaseOrderInfo(DsPurchaseOrderDto purchaseOrder, OpOrder opOrder, HashMap<Integer, OpOrderChild> skuIdAndOpOrderChildMap) {
}
}

@ -6,6 +6,11 @@ import com.ms.dal.mapper.OpOrderChildMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
/**
*
@ -46,6 +51,30 @@ public class OpOrderChildServiceImpl implements OpOrderChildService{
return opOrderChildMapper.updateByPrimaryKey(record);
}
@Override
public List<OpOrderChild> getListByOrderIdsAndSkuIds(List<String> orderIds, List<Integer> skuIds) {
return opOrderChildMapper.getListByOrderIdsAndSkuIds(orderIds, skuIds);
}
@Override
public HashMap<String, HashMap<Integer, String>> getOrderIdAndSkuIdAndSkuSubNameMap(List<String> orderIds, List<Integer> skuIds) {
List<OpOrderChild> children = getListByOrderIdsAndSkuIds(orderIds, skuIds);
HashMap<String, HashMap<Integer, String>> map = new HashMap<>();
for (OpOrderChild child: children) {
if (map.containsKey(child.getOrderId())) {
map.get(child.getOrderId()).put(child.getSkuId(), child.getSpecDesc());
} else {
HashMap<Integer, String> skuIdAndSkuSubNameMap = new HashMap<>();
skuIdAndSkuSubNameMap.put(child.getSkuId(), child.getSpecDesc());
map.put(child.getOrderId(), skuIdAndSkuSubNameMap);
}
}
return map;
}
public List<Integer> getHistorySkuIdsByOrderId(String orderId) {
// TODO
return new ArrayList<>();
}
}

@ -46,6 +46,10 @@ public class OpOrderExtServiceImpl implements OpOrderExtService{
return opOrderExtMapper.updateByPrimaryKey(record);
}
@Override
public OpOrderExt getByOrderId(String orderId) {
return opOrderExtMapper.getByOrderId(orderId);
}
}

@ -93,8 +93,9 @@ public class OpOrderServiceImpl implements OpOrderService {
}
public List<OpOrder> getListByOrderIds(List<String> orderIds) {
return opOrderMapper.getListByOrderIds(orderIds);
}
}

@ -6,6 +6,8 @@ import com.ms.dal.mapper.PurchaseOrderItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
@ -46,6 +48,10 @@ public class PurchaseOrderItemServiceImpl implements PurchaseOrderItemService{
return purchaseOrderItemMapper.updateByPrimaryKey(record);
}
@Override
public List<Integer> getSkuIdsByOrderId(String orderId) {
return null;
}
}

@ -101,6 +101,10 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
}
}
public PurchaseOrder getByPlatformAndPurchaseOrderSn(String platform, String purchaseOrderSn) {
return purchaseOrderMapper.getByPlatformAndPurchaseOrderSn(platform, purchaseOrderSn);
}
}

@ -1,7 +1,6 @@
package com.ms.common.util;
import com.alibaba.fastjson.JSON;
import com.ms.api.SaveItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@ -3,6 +3,8 @@ package com.ms.dal.mapper;
import com.ms.dal.entity.OpOrderChild;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Entity com.ms.dal.entity.OpOrderChild
*/
@ -21,4 +23,5 @@ public interface OpOrderChildMapper {
int updateByPrimaryKey(OpOrderChild record);
List<OpOrderChild> getListByOrderIdsAndSkuIds(List<String> orderIds, List<Integer> skuIds);
}

@ -3,6 +3,8 @@ package com.ms.dal.mapper;
import com.ms.dal.entity.OpOrderEncrypt;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Entity com.ms.dal.entity.OpOrderEncrypt
*/
@ -21,4 +23,5 @@ public interface OpOrderEncryptMapper {
int updateByPrimaryKey(OpOrderEncrypt record);
List<OpOrderEncrypt> getListByOrderIds(List<String> orderIds);
}

@ -21,4 +21,5 @@ public interface OpOrderExtMapper {
int updateByPrimaryKey(OpOrderExt record);
OpOrderExt getByOrderId(String orderId);
}

@ -3,6 +3,8 @@ package com.ms.dal.mapper;
import com.ms.dal.entity.OpOrder;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Entity com.ms.dal.entity.OpOrder
*/
@ -22,4 +24,6 @@ public interface OpOrderMapper {
int updateByPrimaryKey(OpOrder record);
OpOrder selectByOrderId(String orderId);
List<OpOrder> getListByOrderIds(List<String> orderIds);
}

@ -21,4 +21,5 @@ public interface PurchaseOrderMapper {
int updateByPrimaryKey(PurchaseOrder record);
PurchaseOrder getByPlatformAndPurchaseOrderSn(String platform, String purchaseOrderSn);
}

@ -103,4 +103,13 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where op_order_encrypt_id = #{opOrderEncryptId,jdbcType=BIGINT}
</update>
<select id="getListByOrderIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from op_order_encrypt
where order_id in
<foreach collection="list" item="orderId" index="index" open="(" close=")" separator=",">
#{orderId}
</foreach>
</select>
</mapper>

@ -136,4 +136,10 @@
has_free_product = #{hasFreeProduct,jdbcType=BOOLEAN}
where op_order_ext_id = #{opOrderExtId,jdbcType=BIGINT}
</update>
<select id="getByOrderId" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from op_order_ext
where order_id = #{orderId,jdbcType=VARCHAR}
</select>
</mapper>

@ -363,4 +363,13 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where op_order_id = #{opOrderId,jdbcType=BIGINT}
</update>
<select id="getListByOrderIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from op_order
where order_id in
<foreach collection="list" item="orderId" index="index" open="(" close=")" separator=",">
#{orderId}
</foreach>
</select>
</mapper>

@ -264,4 +264,10 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where purchase_order_id = #{purchaseOrderId,jdbcType=BIGINT}
</update>
<select id="getByPlatformAndPurchaseOrderSn" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from purchase_order
where platform = #{platform,jdbcType=VARCHAR} and purchase_order_sn = #{purchaseOrderSn,jdbcType=VARCHAR}
</select>
</mapper>

Loading…
Cancel
Save