|
|
|
@ -29,9 +29,23 @@ 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.*;
|
|
|
|
|
import com.ms.api.consts.AfterSaleConst;
|
|
|
|
|
import com.ms.api.consts.DsOrderConst;
|
|
|
|
|
import com.ms.api.consts.LogisticsConst;
|
|
|
|
|
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.dto.dsorder.AppendVenderRemarkTplItemDTO;
|
|
|
|
|
import com.ms.api.dto.order.*;
|
|
|
|
|
import com.ms.api.dto.order.AllowAutoPurchaseProductDTO;
|
|
|
|
|
import com.ms.api.dto.order.DsPurchaseSettingDTO;
|
|
|
|
|
import com.ms.api.dto.order.FilterAutoPurchaseProductDTO;
|
|
|
|
|
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
|
|
|
|
|
import com.ms.api.dto.order.PurchaseSettingDTO;
|
|
|
|
|
import com.ms.api.dto.order.SearchDsOrderFilterDTO;
|
|
|
|
|
import com.ms.api.dto.order.SearchProductToDsItemConditionDTO;
|
|
|
|
|
import com.ms.api.service.AfterSaleService;
|
|
|
|
|
import com.ms.api.service.OpLogisticsPlatformService;
|
|
|
|
|
import com.ms.api.service.OpOrderAddressHistoryService;
|
|
|
|
@ -87,9 +101,24 @@ import com.ms.dal.entity.PurchaseSetting;
|
|
|
|
|
import com.ms.dal.entity.PurchaseSettingLog;
|
|
|
|
|
import com.ms.dal.entity.Shop;
|
|
|
|
|
import com.ms.dal.entity.ShopTo1688DsMember;
|
|
|
|
|
import com.ms.dal.mapper.*;
|
|
|
|
|
import com.ms.dal.mapper.DsAllowAutoPurchaseProductMapper;
|
|
|
|
|
import com.ms.dal.mapper.DsAutoPurchaseAgreementMapper;
|
|
|
|
|
import com.ms.dal.mapper.DsAutoPurchaseLogMapper;
|
|
|
|
|
import com.ms.dal.mapper.DsAutoPurchaseSwitchLogMapper;
|
|
|
|
|
import com.ms.dal.mapper.DsFilterAutoPurchaseProductMapper;
|
|
|
|
|
import com.ms.dal.mapper.DsPurchaseSettingLogMapper;
|
|
|
|
|
import com.ms.dal.mapper.DsPurchaseSettingMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderChildMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderEncryptIndexMapper;
|
|
|
|
|
import com.ms.dal.mapper.OpOrderMapper;
|
|
|
|
|
import com.ms.dal.mapper.ProductToDsItemMapper;
|
|
|
|
|
import com.ms.dal.mapper.PurchaseOrderItemMapper;
|
|
|
|
|
import com.ms.dal.mapper.PurchaseOrderMapper;
|
|
|
|
|
import com.ms.dal.mapper.PurchaseOrderSettingMapper;
|
|
|
|
|
import com.ms.dal.mapper.PurchaseSettingLogMapper;
|
|
|
|
|
import com.ms.dal.mapper.PurchaseSettingMapper;
|
|
|
|
|
import com.ms.dal.mapper.ShopTo1688DsMemberMapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections.OrderedMap;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
@ -570,7 +599,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
List<String> purchaseOrderIds = purchaseOrders.stream().map(x -> x.getPurchaseOrderId().toString()).collect(Collectors.toList());
|
|
|
|
|
List<PurchaseOrderItem> allItems = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, status);
|
|
|
|
|
Map<Long, List<PurchaseOrderItem>> purchaseOrderIdAndItemMap = new HashMap<>();
|
|
|
|
|
for (PurchaseOrderItem item: allItems) {
|
|
|
|
|
for (PurchaseOrderItem item : allItems) {
|
|
|
|
|
List<PurchaseOrderItem> subItems = new ArrayList<>();
|
|
|
|
|
Long purchaseOrderId = Long.valueOf(item.getPurchaseOrderId());
|
|
|
|
|
if (purchaseOrderIdAndItemMap.containsKey(purchaseOrderId)) {
|
|
|
|
@ -777,10 +806,14 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
autoFillOrderMemoTplStr = purchaseSetting.getAutoFillOrderMemoTpl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> appendShopRemarkTpl = JSON.parseObject(appendShopRemarkTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> appendShopNoteTpl = JSON.parseObject(appendShopNoteTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> autoFillRemarkTpl = JSON.parseObject(autoFillRemarkTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> autoFillOrderMemoTpl = JSON.parseObject(autoFillOrderMemoTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> appendShopRemarkTpl = JSON.parseObject(appendShopRemarkTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {
|
|
|
|
|
});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> appendShopNoteTpl = JSON.parseObject(appendShopNoteTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {
|
|
|
|
|
});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> autoFillRemarkTpl = JSON.parseObject(autoFillRemarkTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {
|
|
|
|
|
});
|
|
|
|
|
List<AppendVenderRemarkTplItemDTO> autoFillOrderMemoTpl = JSON.parseObject(autoFillOrderMemoTplStr, new TypeReference<List<AppendVenderRemarkTplItemDTO>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
PurchaseSettingDTO purchaseSettingDTO = new PurchaseSettingDTO();
|
|
|
|
|
purchaseSettingDTO.setIsAppendShopRemark(isAppendShopRemark);
|
|
|
|
@ -1309,7 +1342,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
}
|
|
|
|
|
Map<Long, Long> skuIdAndPurchaseOrderIdMap = new HashMap<>();
|
|
|
|
|
Map<String, JSONObject> returnPurchaseOrders = new HashMap<>();
|
|
|
|
|
Map<String, Object> hasPurchaseSkuIds = new HashMap<>();
|
|
|
|
|
List<Long> hasPurchaseSkuIds = new ArrayList<>();
|
|
|
|
|
BigDecimal purchaseAmount = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
this.rebuildPurchaseOrderInfo(order, orderIdAndPurchaseOrdersMap.getOrDefault(orderId, new ArrayList<>()), skuIdAndOrderChildMap,
|
|
|
|
@ -1506,7 +1539,6 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
return orderPhaseInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<JSONObject> appendItemsIsUseManualConsignee(List<JSONObject> returnOrderItems, Map<String, JSONObject> returnPurchaseOrders, Map<Long, Long> skuIdAndPurchaseOrderIdMap) {
|
|
|
|
|
for (JSONObject item : returnOrderItems) {
|
|
|
|
|
String skuId = item.getString("skuId");
|
|
|
|
@ -1523,7 +1555,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
return returnOrderItems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rebuildNoPurchaseOrderItems(Map<Integer, OpOrderChildBO> skuIdAndOrderChildMap, Map<String, Object> hasPurchaseSkuIds, List<OpOrderChildLogistics> childOrderLogistics, List<OpOrderPriceProtection> priceProtectionList,
|
|
|
|
|
private void rebuildNoPurchaseOrderItems(Map<Integer, OpOrderChildBO> skuIdAndOrderChildMap, List<Long> hasPurchaseSkuIds, List<OpOrderChildLogistics> childOrderLogistics, List<OpOrderPriceProtection> priceProtectionList,
|
|
|
|
|
Map<Long, List<OpOrderGivenProduct>> childOrderIdAndGivenProductsMap, List<JSONObject> returnOrderItems, List<JSONObject> noPurchaseOrderItems, BigDecimal orderTotalAmount) {
|
|
|
|
|
Map<String, List<OpOrderChildLogistics>> childOrderIdAndLogisticsMap = childOrderLogistics.stream().collect(Collectors.groupingBy(OpOrderChildLogistics::getChildOrderId));
|
|
|
|
|
Map<String, OpOrderPriceProtection> childOrderIdAndPriceProtectionMap = priceProtectionList.stream().collect(Collectors.toMap(OpOrderPriceProtection::getChildOrderId, x -> x));
|
|
|
|
@ -1553,6 +1585,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
returnItem.put("isCanPrint", (ObjectUtil.isEmpty(item.getDsRefundStatus()) || item.getDsRefundStatus().equals(DsOrderConst.REFUND_STATUS_CLOSE)));
|
|
|
|
|
returnItem.put("givenProductItems", giveItems);
|
|
|
|
|
returnItem.put("purchaseClickTimes", 0);
|
|
|
|
|
returnItem.put("isPurchase", 0);
|
|
|
|
|
// foreach ($opItemPurchaseClicks as $opItemPurchaseClick) {
|
|
|
|
|
// if ($opItemPurchaseClick['sku_id'] == $item['combo_id']) {
|
|
|
|
|
// $returnItem['purchaseClickTimes'] += $opItemPurchaseClick['click_times'];
|
|
|
|
@ -1560,7 +1593,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
// }
|
|
|
|
|
orderTotalAmount = orderTotalAmount.add(BigDecimal.valueOf(CommonTool.correctCentToYuan(item.getCouponAmount()) * item.getComboNum()));
|
|
|
|
|
returnOrderItems.add(returnItem);
|
|
|
|
|
if (hasPurchaseSkuIds.containsKey(item.getSkuId().toString())) {
|
|
|
|
|
if (hasPurchaseSkuIds.contains(Long.valueOf(item.getSkuId()))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
noPurchaseOrderItems.add(returnItem);
|
|
|
|
@ -1569,7 +1602,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
|
|
|
|
|
private void rebuildPurchaseOrderInfo(OpOrder order, List<PurchaseOrderBO> purchaseOrders, Map<Integer, OpOrderChildBO> skuIdAndOrderChildMap, List<OpOrderChildLogistics> childOrderLogistics,
|
|
|
|
|
List<OpOrderPriceProtection> priceProtectionList, Map<Long, List<OpOrderGivenProduct>> childOrderIdAndGivenProductsMap
|
|
|
|
|
, Map<Long, Long> skuIdAndPurchaseOrderIdMap, Map<String, JSONObject> returnPurchaseOrders, Map<String, Object> hasPurchaseSkuIds, BigDecimal purchaseAmount
|
|
|
|
|
, Map<Long, Long> skuIdAndPurchaseOrderIdMap, Map<String, JSONObject> returnPurchaseOrders, List<Long> hasPurchaseSkuIds, BigDecimal purchaseAmount
|
|
|
|
|
) {
|
|
|
|
|
String orderId = order.getOrderId();
|
|
|
|
|
Map<String, List<OpOrderChildLogistics>> childOrderIdAndLogisticsMap = childOrderLogistics.stream().collect(Collectors.groupingBy(OpOrderChildLogistics::getOrderId));
|
|
|
|
@ -1579,6 +1612,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
List<JSONObject> returnPurchaseOrderItems = new ArrayList<>();
|
|
|
|
|
for (PurchaseOrderBO purchaseOrder : purchaseOrders) {
|
|
|
|
|
PurchaseOrderItem purchaseOrderItem = purchaseOrder.getItem();
|
|
|
|
|
hasPurchaseSkuIds.add(purchaseOrderItem.getSkuId());
|
|
|
|
|
Long skuId = purchaseOrderItem.getSkuId();
|
|
|
|
|
OpOrderChildBO item = skuIdAndOrderChildMap.get(skuId.intValue());
|
|
|
|
|
List<OpOrderChildLogistics> logisticsInfos = childOrderIdAndLogisticsMap.getOrDefault(item.getChildOrderId(), new ArrayList<>());
|
|
|
|
@ -1626,6 +1660,8 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
returnPurchaseOrderItem.put("dsRefundStatus", item.getDsRefundStatus());
|
|
|
|
|
returnPurchaseOrderItem.put("dsRefundStatusName", item.getDsRefundStatusName());
|
|
|
|
|
returnPurchaseOrderItem.put("cBiz", item.getCBiz());
|
|
|
|
|
returnPurchaseOrderItem.put("isPurchase", 0);
|
|
|
|
|
returnPurchaseOrderItem.put("sourceItem", item.getSourceItem());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
// returnPurchaseOrderItem.put("estimatedCommission", item.get("estimated_commission"));
|
|
|
|
|
returnPurchaseOrderItem.put("givenProductItems", JSONArray.toJSONString(giveItems));
|
|
|
|
@ -1703,7 +1739,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
// $returnPurchaseOrders[$purchaseOrder['purchase_order_id']]['wsyOrderType'] = $purchaseOrderPlatformInfoItem['wsy_order_type'];
|
|
|
|
|
// $returnPurchaseOrders[$purchaseOrder['purchase_order_id']]['platformOrderDetailId'] = $purchaseOrderPlatformInfoItem['platform_order_detail_id'];
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
returnPurchaseOrders.put(purchaseOrder.getPurchaseOrderId().toString(), returnPurchaseOrder);
|
|
|
|
|
purchaseAmount = purchaseAmount.add(purchaseOrder.getPurchaseOrderPayment());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1725,6 +1761,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
opOrderChild.setSourceSellerId(productToDsItem.getSourceSellerId());
|
|
|
|
|
opOrderChild.setSource_platform(productToDsItem.getSource_platform());
|
|
|
|
|
opOrderChild.setSourceItemId(productToDsItem.getSourceItemId());
|
|
|
|
|
opOrderChild.setSourceItem(productToDsItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AfterSale afterSale = childOrderIdAndAfterSaleMap.get(childOrderId);
|
|
|
|
@ -1819,17 +1856,17 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Integer getDsOrderCount(Integer authShopIds, SearchDsOrderFilterDTO filter) {
|
|
|
|
|
List<String> shopIds = Collections.singletonList(ObjectUtil.isNotEmpty(filter.getAuthShopIds()) ? filter.getAuthShopIds() :authShopIds.toString());
|
|
|
|
|
List<String> shopIds = Collections.singletonList(ObjectUtil.isNotEmpty(filter.getAuthShopIds()) ? filter.getAuthShopIds() : authShopIds.toString());
|
|
|
|
|
JSONObject searchDsOrderListCondition = getSearchDsOrderListCondition(filter, TblConst.op_order_ds, shopIds);
|
|
|
|
|
|
|
|
|
|
String masterTbl = searchDsOrderListCondition.getString("masterTbl");
|
|
|
|
|
String masterTblAlias = searchDsOrderListCondition.getString("masterTblAlias");
|
|
|
|
|
String whereStr = searchDsOrderListCondition.getString("whereConditions");
|
|
|
|
|
String countFieldStr = String.format("distinct %s.order_id",masterTblAlias);
|
|
|
|
|
String countFieldStr = String.format("distinct %s.order_id", masterTblAlias);
|
|
|
|
|
String joinStr = searchDsOrderListCondition.getString("joinTables");
|
|
|
|
|
log.info("=================filter:{}====",JSON.toJSONString(filter));
|
|
|
|
|
log.info("=================filter:{}====", JSON.toJSONString(filter));
|
|
|
|
|
Integer total = purchaseOrderMapper.getDsOrderCount(countFieldStr, masterTblAlias, masterTbl, joinStr, shopIds, whereStr);
|
|
|
|
|
log.info("===========dsDebugCount:{}==========",total);
|
|
|
|
|
log.info("===========dsDebugCount:{}==========", total);
|
|
|
|
|
return total;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|