|
|
|
@ -299,7 +299,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
List<String> orderIds = orderList.stream().map(OpOrder::getOrderId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
Map<String, List<PurchaseOrderBO>> orderIdAndPurchaseOrdersMap = getOrderIdAndPurchaseOrdersMap(shopIds, orderIds, filter, true, false);
|
|
|
|
|
Map<Long, Shop> shopIdAndShopInfoMap = shopService.getShopByIds(shopIds).stream().collect(Collectors.toMap(Shop::getShopId, x -> x,(v1,v2)->v1));
|
|
|
|
|
Map<Long, Shop> shopIdAndShopInfoMap = shopService.getShopByIds(shopIds).stream().collect(Collectors.toMap(Shop::getShopId, x -> x, (v1, v2) -> v1));
|
|
|
|
|
Map<String, String> orderIdAndSameOrderIdsMap = new HashMap<>();
|
|
|
|
|
// TODO: 2023/8/28 配置表已经没有相关字段 跳过
|
|
|
|
|
// if (ObjectUtil.isNotNull(filter.getIsShowSameReceiverOrder()) && filter.getIsShowSameReceiverOrder()) {
|
|
|
|
@ -331,7 +331,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
}
|
|
|
|
|
List<OpOrderOutstorageHistory> opOrderOutstorageHistoryRows = opOrderOutstorageHistoryService.getByIdList(opOrderOutstorageHistoryIds);
|
|
|
|
|
|
|
|
|
|
Map<String, OpOrderOutstorageHistory> orderIdAndOpOrderOutstrorageHistoryMap = opOrderOutstorageHistoryRows.stream().collect(Collectors.toMap(OpOrderOutstorageHistory::getOrderId, x -> x,(v1,v2)->v1));
|
|
|
|
|
Map<String, OpOrderOutstorageHistory> orderIdAndOpOrderOutstrorageHistoryMap = opOrderOutstorageHistoryRows.stream().collect(Collectors.toMap(OpOrderOutstorageHistory::getOrderId, x -> x, (v1, v2) -> v1));
|
|
|
|
|
|
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
|
if (isDs && !OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS.equals(order.get("orderStatus"))) {
|
|
|
|
@ -694,7 +694,8 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
|
|
|
|
|
if (needItems) {
|
|
|
|
|
List<String> purchaseOrderIds = purchaseOrders.stream().map(x -> x.getPurchaseOrderId().toString()).collect(Collectors.toList());
|
|
|
|
|
Map<Integer, PurchaseOrderItem> purchaseOrderItemsMap = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, StatusConst.normal).stream().collect(Collectors.toMap(PurchaseOrderItem::getPurchaseOrderId, x -> x,(v1,v2)->v1));
|
|
|
|
|
Map<Integer, List<PurchaseOrderItem>> purchaseOrderItemsMap = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, StatusConst.normal).stream()
|
|
|
|
|
.collect(Collectors.groupingBy(PurchaseOrderItem::getPurchaseOrderId));
|
|
|
|
|
for (PurchaseOrderBO purchaseOrder : purchaseOrders) {
|
|
|
|
|
if (purchaseOrderItemsMap.containsKey(purchaseOrder.getPurchaseOrderId().intValue())) {
|
|
|
|
|
purchaseOrder.setItem(purchaseOrderItemsMap.get(purchaseOrder.getPurchaseOrderId().intValue()));
|
|
|
|
@ -739,7 +740,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return rows.stream().collect(Collectors.toMap(PurchaseOrderSetting::getPurchaseOrderId, x -> x,(v1,v2)->v1));
|
|
|
|
|
return rows.stream().collect(Collectors.toMap(PurchaseOrderSetting::getPurchaseOrderId, x -> x, (v1, v2) -> v1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1296,7 +1297,9 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
for (Map.Entry<String, List<PurchaseOrderBO>> entry : orderIdAndPurchaseOrdersMap.entrySet()) {
|
|
|
|
|
purchaserOrderIds.addAll(entry.getValue().stream().map(PurchaseOrderBO::getPurchaseOrderId).collect(Collectors.toSet()));
|
|
|
|
|
for (PurchaseOrderBO orderBO : entry.getValue()) {
|
|
|
|
|
purchaserOrderItemIds.add(orderBO.getItem().getPurchaseOrderItemId());
|
|
|
|
|
for (PurchaseOrderItem purchasOrderItem : orderBO.getItem()) {
|
|
|
|
|
purchaserOrderItemIds.add(purchasOrderItem.getPurchaseOrderItemId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// TODO: 2023/8/29 跳过 purchase_use_fixed_mobile_log purchase_order_platform_info purchase_order_need_check_status purchase_order_custom purchase_order_item_relate_source
|
|
|
|
@ -1339,7 +1342,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
List<OpOrderChildBO> items = orderIdAndOpOrderChildMap.get(orderId);
|
|
|
|
|
Map<Long, OpOrderChildBO> skuIdAndOrderChildMap = this.mergeOpOrderChildSameSku(items);
|
|
|
|
|
List<AfterSale> currentOrderAfterSales = ObjectUtil.isNotEmpty(orderIdAndAftersalesMap.get(orderId)) ? orderIdAndAftersalesMap.get(orderId) : new ArrayList<>();
|
|
|
|
|
Map<String, AfterSale> childOrderIdAndAfterSaleMap = currentOrderAfterSales.stream().collect(Collectors.toMap(AfterSale::getOrderId, x -> x,(v1,v2)->v1));
|
|
|
|
|
Map<String, AfterSale> childOrderIdAndAfterSaleMap = currentOrderAfterSales.stream().collect(Collectors.toMap(AfterSale::getOrderId, x -> x, (v1, v2) -> v1));
|
|
|
|
|
attachSourceItemInfoToOpOrderChilds(skuIdAndOrderChildMap, productIdAndProductToDsItemMap, childOrderIdAndAfterSaleMap);
|
|
|
|
|
List<String> sourceItemIds = skuIdAndOrderChildMap.values().stream().map(OpOrderChildBO::getSourceItemId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
@ -1372,7 +1375,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
|
|
|
|
|
// orderAddressChangeApply = orderIdAndOrderAddressChangeApplyMap[orderId];
|
|
|
|
|
|
|
|
|
|
Map<String, JSONObject> purchasePlatforms = ObjectUtil.isEmpty(returnPurchaseOrders) ? new HashMap<>() : returnPurchaseOrders.values().stream().collect(Collectors.toMap(x -> x.getString("purchasePlatform"), x -> x,(v1,v2)->v1));
|
|
|
|
|
Map<String, JSONObject> purchasePlatforms = ObjectUtil.isEmpty(returnPurchaseOrders) ? new HashMap<>() : returnPurchaseOrders.values().stream().collect(Collectors.toMap(x -> x.getString("purchasePlatform"), x -> x, (v1, v2) -> v1));
|
|
|
|
|
if (ObjectUtil.isEmpty(sourceItemIds) && purchasePlatforms.containsKey(PurchaseOrderConst.PURCHASE_PLATFORM1688_D_S)) {
|
|
|
|
|
needDeleteOpOrderDsOrderIds.add(orderId);
|
|
|
|
|
}
|
|
|
|
@ -1566,7 +1569,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
private void rebuildNoPurchaseOrderItems(Map<Long, 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,(v1,v2)->v1));
|
|
|
|
|
Map<String, OpOrderPriceProtection> childOrderIdAndPriceProtectionMap = priceProtectionList.stream().collect(Collectors.toMap(OpOrderPriceProtection::getChildOrderId, x -> x, (v1, v2) -> v1));
|
|
|
|
|
for (Map.Entry<Long, OpOrderChildBO> entry : skuIdAndOrderChildMap.entrySet()) {
|
|
|
|
|
OpOrderChildBO item = entry.getValue();
|
|
|
|
|
String skuSubNames = item.getSkuSubName();
|
|
|
|
@ -1614,75 +1617,76 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(purchaseOrders)) {
|
|
|
|
|
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);
|
|
|
|
|
List<OpOrderChildLogistics> logisticsInfos = childOrderIdAndLogisticsMap.getOrDefault(item.getChildOrderId(), new ArrayList<>());
|
|
|
|
|
List<OpOrderPriceProtection> priceProtectionInfo = childOrderIdAndPriceProtectionMap.getOrDefault(item.getChildOrderId(), new ArrayList<>());
|
|
|
|
|
List<OpOrderGivenProduct> giveItems = childOrderIdAndGivenProductsMap.getOrDefault(Long.parseLong(item.getChildOrderId()), new ArrayList<>());
|
|
|
|
|
for (PurchaseOrderItem purchaseOrderItem : purchaseOrder.getItem()) {
|
|
|
|
|
hasPurchaseSkuIds.add(purchaseOrderItem.getSkuId());
|
|
|
|
|
Long skuId = purchaseOrderItem.getSkuId();
|
|
|
|
|
OpOrderChildBO item = skuIdAndOrderChildMap.get(skuId);
|
|
|
|
|
List<OpOrderChildLogistics> logisticsInfos = childOrderIdAndLogisticsMap.getOrDefault(item.getChildOrderId(), new ArrayList<>());
|
|
|
|
|
List<OpOrderPriceProtection> priceProtectionInfo = childOrderIdAndPriceProtectionMap.getOrDefault(item.getChildOrderId(), new ArrayList<>());
|
|
|
|
|
List<OpOrderGivenProduct> giveItems = childOrderIdAndGivenProductsMap.getOrDefault(Long.parseLong(item.getChildOrderId()), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
String skuSubNames = item.getSkuSubName();
|
|
|
|
|
String skuSubNames = item.getSkuSubName();
|
|
|
|
|
|
|
|
|
|
JSONObject returnPurchaseOrderItem = new JSONObject();
|
|
|
|
|
JSONObject returnPurchaseOrderItem = new JSONObject();
|
|
|
|
|
|
|
|
|
|
returnPurchaseOrderItem.put("purchaseOrderItemId", purchaseOrderItem.getPurchaseOrderItemId());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("purchaseOrderItemId", purchaseOrderItem.getPurchaseOrderItemId());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
// returnPurchaseOrderItem.put("purchaseItemCode", purchaseOrderItem.get("code"));
|
|
|
|
|
returnPurchaseOrderItem.put("childOrderId", item.getChildOrderId());
|
|
|
|
|
returnPurchaseOrderItem.put("orderId", item.getOrderId());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("childOrderId", item.getChildOrderId());
|
|
|
|
|
returnPurchaseOrderItem.put("orderId", item.getOrderId());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
// returnPurchaseOrderItem.put("shopId", item.get("shop_id"));
|
|
|
|
|
returnPurchaseOrderItem.put("code", item.getCode());
|
|
|
|
|
returnPurchaseOrderItem.put("itemNum", item.getItemNum());
|
|
|
|
|
returnPurchaseOrderItem.put("wareId", purchaseOrderItem.getWareId());
|
|
|
|
|
returnPurchaseOrderItem.put("skuId", purchaseOrderItem.getSkuId());
|
|
|
|
|
returnPurchaseOrderItem.put("purchaseUrl", purchaseOrderItem.getPurchaseUrl());
|
|
|
|
|
returnPurchaseOrderItem.put("purchasePrice", purchaseOrderItem.getPurchasePrice());
|
|
|
|
|
returnPurchaseOrderItem.put("purchaseNum", purchaseOrderItem.getPurchaseNum());
|
|
|
|
|
returnPurchaseOrderItem.put("outSkuId", item.getOutSkuId());
|
|
|
|
|
returnPurchaseOrderItem.put("title", item.getProductName());
|
|
|
|
|
returnPurchaseOrderItem.put("skuName", item.getProductName() + "_" + String.join(" ", skuSubNames));
|
|
|
|
|
returnPurchaseOrderItem.put("jdPrice", CommonTool.correctCentToYuan(item.getCouponAmount()));
|
|
|
|
|
returnPurchaseOrderItem.put("itemTotal", item.getComboNum());
|
|
|
|
|
returnPurchaseOrderItem.put("logo", item.getProductPic());
|
|
|
|
|
returnPurchaseOrderItem.put("totalPrice", item.getTotalAmount());
|
|
|
|
|
returnPurchaseOrderItem.put("orderStatus", item.getOrderStatus());
|
|
|
|
|
returnPurchaseOrderItem.put("skuSubName", String.join(" ", skuSubNames));
|
|
|
|
|
returnPurchaseOrderItem.put("couponPrice", CommonTool.correctCentToYuan(item.getCouponAmount()));
|
|
|
|
|
returnPurchaseOrderItem.put("totalAmount", CommonTool.correctCentToYuan(item.getTotalAmount()));
|
|
|
|
|
returnPurchaseOrderItem.put("shopCouponAmount", CommonTool.correctCentToYuan(item.getShopCouponAmount()));
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("url", CommonTool.buildDdProductUrl(item.getProductId()));
|
|
|
|
|
returnPurchaseOrderItem.put("sourceItemId", item.getSourceItemId());
|
|
|
|
|
returnPurchaseOrderItem.put("sourceSellerId", item.getSourceSellerId());
|
|
|
|
|
returnPurchaseOrderItem.put("sourcePlatform", item.getSource_platform());
|
|
|
|
|
returnPurchaseOrderItem.put("logisticsInfos", JSONArray.toJSONString(logisticsInfos));
|
|
|
|
|
returnPurchaseOrderItem.put("priceProtection", priceProtectionInfo);
|
|
|
|
|
returnPurchaseOrderItem.put("dsRefundStatus", item.getDsRefundStatus());
|
|
|
|
|
returnPurchaseOrderItem.put("dsRefundStatusName", item.getDsRefundStatusName());
|
|
|
|
|
returnPurchaseOrderItem.put("cBiz", item.getCBiz());
|
|
|
|
|
returnPurchaseOrderItem.put("isPurchase", hasPurchaseSkuIds.contains(item.getSkuId()) ? 1 : 0);
|
|
|
|
|
returnPurchaseOrderItem.put("sourceItem", item.getSourceItem());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("code", item.getCode());
|
|
|
|
|
returnPurchaseOrderItem.put("itemNum", item.getItemNum());
|
|
|
|
|
returnPurchaseOrderItem.put("wareId", purchaseOrderItem.getWareId());
|
|
|
|
|
returnPurchaseOrderItem.put("skuId", purchaseOrderItem.getSkuId());
|
|
|
|
|
returnPurchaseOrderItem.put("purchaseUrl", purchaseOrderItem.getPurchaseUrl());
|
|
|
|
|
returnPurchaseOrderItem.put("purchasePrice", purchaseOrderItem.getPurchasePrice());
|
|
|
|
|
returnPurchaseOrderItem.put("purchaseNum", purchaseOrderItem.getPurchaseNum());
|
|
|
|
|
returnPurchaseOrderItem.put("outSkuId", item.getOutSkuId());
|
|
|
|
|
returnPurchaseOrderItem.put("title", item.getProductName());
|
|
|
|
|
returnPurchaseOrderItem.put("skuName", item.getProductName() + "_" + String.join(" ", skuSubNames));
|
|
|
|
|
returnPurchaseOrderItem.put("jdPrice", CommonTool.correctCentToYuan(item.getCouponAmount()));
|
|
|
|
|
returnPurchaseOrderItem.put("itemTotal", item.getComboNum());
|
|
|
|
|
returnPurchaseOrderItem.put("logo", item.getProductPic());
|
|
|
|
|
returnPurchaseOrderItem.put("totalPrice", item.getTotalAmount());
|
|
|
|
|
returnPurchaseOrderItem.put("orderStatus", item.getOrderStatus());
|
|
|
|
|
returnPurchaseOrderItem.put("skuSubName", String.join(" ", skuSubNames));
|
|
|
|
|
returnPurchaseOrderItem.put("couponPrice", CommonTool.correctCentToYuan(item.getCouponAmount()));
|
|
|
|
|
returnPurchaseOrderItem.put("totalAmount", CommonTool.correctCentToYuan(item.getTotalAmount()));
|
|
|
|
|
returnPurchaseOrderItem.put("shopCouponAmount", CommonTool.correctCentToYuan(item.getShopCouponAmount()));
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("url", CommonTool.buildDdProductUrl(item.getProductId()));
|
|
|
|
|
returnPurchaseOrderItem.put("sourceItemId", item.getSourceItemId());
|
|
|
|
|
returnPurchaseOrderItem.put("sourceSellerId", item.getSourceSellerId());
|
|
|
|
|
returnPurchaseOrderItem.put("sourcePlatform", item.getSource_platform());
|
|
|
|
|
returnPurchaseOrderItem.put("logisticsInfos", JSONArray.toJSONString(logisticsInfos));
|
|
|
|
|
returnPurchaseOrderItem.put("priceProtection", priceProtectionInfo);
|
|
|
|
|
returnPurchaseOrderItem.put("dsRefundStatus", item.getDsRefundStatus());
|
|
|
|
|
returnPurchaseOrderItem.put("dsRefundStatusName", item.getDsRefundStatusName());
|
|
|
|
|
returnPurchaseOrderItem.put("cBiz", item.getCBiz());
|
|
|
|
|
returnPurchaseOrderItem.put("isPurchase", hasPurchaseSkuIds.contains(item.getSkuId()) ? 1 : 0);
|
|
|
|
|
returnPurchaseOrderItem.put("sourceItem", item.getSourceItem());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
// returnPurchaseOrderItem.put("estimatedCommission", item.get("estimated_commission"));
|
|
|
|
|
returnPurchaseOrderItem.put("givenProductItems", JSONArray.toJSONString(giveItems));
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("givenProductItems", JSONArray.toJSONString(giveItems));
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
// if (purchaseOrderItemRelateSourceMap.containsKey(purchaseOrderItem.get("purchase_order_id"))) {
|
|
|
|
|
// returnPurchaseOrderItem.put("isManual", purchaseOrderItemRelateSourceMap.get(purchaseOrderItem.get("purchase_order_id")).equals("manual"));
|
|
|
|
|
// } else {
|
|
|
|
|
// returnPurchaseOrderItem.put("isManual", purchaseOrderItem.get("purchase_url").isEmpty());
|
|
|
|
|
// }
|
|
|
|
|
returnPurchaseOrderItem.put("isManual", purchaseOrderItem.getPurchaseUrl().isEmpty());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
returnPurchaseOrderItem.put("isManual", purchaseOrderItem.getPurchaseUrl().isEmpty());
|
|
|
|
|
// TODO: 2023/8/29 跳过
|
|
|
|
|
// returnPurchaseOrderItem['purchaseClickTimes'] = 0;
|
|
|
|
|
// foreach(opItemPurchaseClicks as opItemPurchaseClick) {
|
|
|
|
|
// if (opItemPurchaseClick['sku_id'] == item['combo_id']) {
|
|
|
|
|
// returnPurchaseOrderItem['purchaseClickTimes'] += opItemPurchaseClick['click_times'];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
returnPurchaseOrderItems.add(returnPurchaseOrderItem);
|
|
|
|
|
skuIdAndPurchaseOrderIdMap.put(purchaseOrderItem.getSkuId(), purchaseOrder.getPurchaseOrderId());
|
|
|
|
|
returnPurchaseOrderItems.add(returnPurchaseOrderItem);
|
|
|
|
|
skuIdAndPurchaseOrderIdMap.put(purchaseOrderItem.getSkuId(), purchaseOrder.getPurchaseOrderId());
|
|
|
|
|
}
|
|
|
|
|
JSONObject returnPurchaseSetting = new JSONObject();
|
|
|
|
|
if (ObjectUtil.isNotNull(purchaseOrder.getPurchaseSetting())) {
|
|
|
|
|
returnPurchaseSetting.put("isAddConsigneeSuffix", purchaseOrder.getPurchaseSetting().getIsAddConsigneeSuffix());
|
|
|
|
|