8月新需求修改组合订单

This commit is contained in:
dev 2025-08-11 18:04:18 +08:00
parent 4bff366471
commit 5710ef1c0e
24 changed files with 621 additions and 100 deletions

View File

@ -8,6 +8,8 @@ import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.asinkj.amz.domain.BizShipmentPlan;
import org.asinkj.amz.domain.vo.BizShipmentPlanVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.asinkj.common.idempotent.annotation.RepeatSubmit;
@ -48,6 +50,13 @@ public class BizSendOrderController extends BaseController {
return bizSendOrderService.queryPageList(bo, pageQuery);
}
@SaCheckRole(value = {"gongying", "gengdan", "superadmin", "yunying"}, mode = SaMode.OR)
@PostMapping("/cover/list")
public TableDataInfo<BizSendOrderVo> coverSendOrder(@RequestBody BizSendOrderBo bo, PageQuery pageQuery) {
return bizSendOrderService.coverSendOrder(bo, pageQuery);
}
/**
* 导出供应商创建的发货单列表
*/
@ -124,4 +133,14 @@ public class BizSendOrderController extends BaseController {
@PathVariable Long[] ids) {
return toAjax(bizSendOrderService.deleteWithValidByIds(List.of(ids), true));
}
@SaCheckRole(value = {"gongying", "gengdan", "superadmin", "yunying"}, mode = SaMode.OR)
@Log(title = "供应商创建的发货单", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PostMapping("/transfer")
public R<Void> transfor(@Validated(EditGroup.class) @RequestBody BizSendOrderVo bo) {
bizSendOrderService.transfer(bo);
return R.ok();
}
}

View File

@ -69,6 +69,13 @@ public class BizShipmentPlanController extends BaseController {
ExcelUtil.exportExcel(list, "货件计划", BizShipmentPlanVo.class, response);
}
@SaCheckPermission("amz:shipmentPlan:list")
@PostMapping("/list/order/export")
public void listOrderExport(BizShipmentPlanBo bo, HttpServletResponse response) {
bizShipmentPlanService.queryPageListOrderExport(bo, response);
}
/**
* 获取货件计划详细信息
*

View File

@ -4,6 +4,8 @@ import org.asinkj.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -97,7 +99,7 @@ public class BizLogisticsOrderDetail extends TenantEntity {
/**
* 物流单价单位/KG由合同或报价确定
*/
private Long pricePerKg;
private BigDecimal pricePerKg;
/**
* 物流计价重量应用层根据业务规则计算
@ -107,12 +109,12 @@ public class BizLogisticsOrderDetail extends TenantEntity {
/**
* 其他物流费用如报关费保险费等
*/
private Long otherFee;
private BigDecimal otherFee;
/**
* 费用合计应用层计算物流计价 + 其他费用
*/
private Long totalFee;
private BigDecimal totalFee;
/**
* 物流状态pending:待发运/in_transit:运输中/delivered:已签收

View File

@ -86,6 +86,8 @@ public class BizSendOrder extends TenantEntity {
*/
private Long weightPerBox;
private String sku;
/**
* 实际采购店铺
*/

View File

@ -4,6 +4,8 @@ import org.asinkj.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -59,8 +61,11 @@ public class BizSendOrderItem extends TenantEntity {
/**
* 发货日期
*/
private Long quantitySend;
private BigDecimal quantitySend;
private Long mainOrderSn;
@TableField(exist = false)
private BigDecimal ratio;
}

View File

@ -8,6 +8,8 @@ import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -112,7 +114,7 @@ public class BizLogisticsOrderDetailBo extends BaseEntity {
* 物流单价单位/KG由合同或报价确定
*/
@NotNull(message = "物流单价(单位:元/KG由合同或报价确定不能为空", groups = { AddGroup.class, EditGroup.class })
private Long pricePerKg;
private BigDecimal pricePerKg;
/**
* 物流计价重量应用层根据业务规则计算
@ -124,13 +126,13 @@ public class BizLogisticsOrderDetailBo extends BaseEntity {
* 其他物流费用如报关费保险费等
*/
@NotNull(message = "其他物流费用(如报关费、保险费等)不能为空", groups = { AddGroup.class, EditGroup.class })
private Long otherFee;
private BigDecimal otherFee;
/**
* 费用合计应用层计算物流计价 + 其他费用
*/
@NotNull(message = "费用合计(应用层计算:物流计价 + 其他费用)不能为空", groups = { AddGroup.class, EditGroup.class })
private Long totalFee;
private BigDecimal totalFee;
/**
* 物流状态pending:待发运/in_transit:运输中/delivered:已签收

View File

@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.io.Serial;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -54,7 +55,7 @@ public class BizLogisticsQuoteBo extends BaseEntity {
* 基础价格
*/
@NotNull(message = "基础价格不能为空", groups = { AddGroup.class, EditGroup.class })
private Long price;
private BigDecimal price;
/**
* 时效单位
@ -69,7 +70,7 @@ public class BizLogisticsQuoteBo extends BaseEntity {
* 附加费
*/
@NotNull(message = "附加费不能为空", groups = { AddGroup.class, EditGroup.class })
private Long surcharge;
private BigDecimal surcharge;
/**
* 报价生效日期

View File

@ -9,6 +9,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@ -65,7 +66,7 @@ public class BizSendOrderBo extends BaseEntity {
* 发货数量
*/
// @NotNull(message = "发货数量不能为空", groups = {AddGroup.class, EditGroup.class})
private Long quantitySend;
private BigDecimal quantitySend;
/**
* 单箱产品数量
@ -73,6 +74,8 @@ public class BizSendOrderBo extends BaseEntity {
// @NotNull(message = "单箱产品数量不能为空", groups = {AddGroup.class, EditGroup.class})
private Long quantityPerBox;
/**
* 箱数
*/
@ -121,4 +124,7 @@ public class BizSendOrderBo extends BaseEntity {
private String createName;
private List<String> skus;
}

View File

@ -1,5 +1,6 @@
package org.asinkj.amz.domain.vo;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -65,7 +66,7 @@ public class BizLogisticsQuoteVo implements Serializable {
* 基础价格
*/
@ExcelProperty(value = "基础价格")
private Long price;
private BigDecimal price;
/**
* 时效单位
@ -81,7 +82,7 @@ public class BizLogisticsQuoteVo implements Serializable {
* 附加费
*/
@ExcelProperty(value = "附加费")
private Long surcharge;
private BigDecimal surcharge;
/**
* 报价生效日期

View File

@ -105,7 +105,7 @@ public class BizOrderOutItemVo implements Serializable {
* 实际到货数量
*/
@ExcelProperty(value = "实际到货数量")
private Long quantityReal;
private BigDecimal quantityReal;
/**
* 已入库数量
@ -116,12 +116,12 @@ public class BizOrderOutItemVo implements Serializable {
/**
* 已发货数量
*/
private Long quantityShipped;
private BigDecimal quantityShipped;
/**
* 剩余数量
*/
private Long quantityLeft;
private BigDecimal quantityLeft;
private BizPurchaseOrder order;

View File

@ -1,5 +1,6 @@
package org.asinkj.amz.domain.vo;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
@ -121,7 +122,7 @@ public class BizPurchaseOrderItemVo implements Serializable {
* 实际采购量
*/
@ExcelProperty(value = "实际采购量")
private Long quantityReal;
private BigDecimal quantityReal;
/**
* 到货入库量
@ -216,9 +217,9 @@ public class BizPurchaseOrderItemVo implements Serializable {
private String orderStatus;
private Long quantityLeft;
private BigDecimal quantityLeft;
private Long quantityShipped;
private BigDecimal quantityShipped;
@TableField(exist = false)

View File

@ -104,6 +104,8 @@ public class BizSendOrderVo implements Serializable {
@ExcelProperty(value = "实际采购店铺")
private String realStoreName;
private String sku;
/**
* 发货状态pending=未发货confirm=确认发货, processing=发货中completed=发货完成
*/

View File

@ -0,0 +1,142 @@
package org.asinkj.amz.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableField;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.asinkj.amz.domain.*;
import org.asinkj.amz.hanlder.AddressTypeHandler;
import org.asinkj.asinking.entity.FbaShipmentApiResponse;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 货件计划视图对象 biz_shipment_plan
*
* @author shuo hu
* @date 2025-03-19
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = BizShipmentPlan.class)
public class BizShipmentPlanOrderExportVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "计划发货日期")
private Date staShipmentDate;
@ExcelProperty(value = "店铺名称")
private String sellerName;
@ExcelProperty(value = "货件编号")
private String shipmentId;
@ExcelProperty(value = "产品名称")
private String productName;
@ColumnWidth(20)
@ExcelProperty(value = "msku")
private String msku;
@ExcelProperty(value = "仓储编码")
private String fnsku;
@ColumnWidth(20)
@ExcelProperty(value = "sku")
private String sku;
@ColumnWidth(20)
@ExcelProperty(value = "asin")
private String asin;
@ExcelProperty(value = "申报量")
private Long quantityShipped;
@ExcelProperty(value = "物流中心编码")
private String destination;
@ExcelProperty(value = "供应商称重")
private Long vendorWeight;
@ExcelProperty(value = "物流商称重")
private Long logisticWeight;
@ExcelProperty(value = "称重差异")
private Long weightDiff;
@ExcelProperty(value = "物流商名称")
private String logisticsName;
@ExcelProperty(value = "物流渠道")
private String channelName;
//单价
@ExcelProperty(value = "单价")
private BigDecimal price;
// 时效单位
@ExcelProperty(value = "时效")
private BigDecimal leadTime;
@ExcelProperty(value = "总价")
private BigDecimal totalPrice;
//附加费
@ExcelProperty(value = "附加费")
private BigDecimal surcharge;
//结算金额
@ExcelProperty(value = "结算金额")
private BigDecimal amountPrice;
@ExcelProperty(value = "订单编号")
private String orderSn;
//供应商名称
@ExcelProperty(value = "供应商名称")
private String sendName;
@ExcelProperty(value = "供应商发货数量")
private Long quantitySend;
@ExcelProperty(value = "供应商发货明细")
private String sendDetail;
/**
* 关联的采购单信息
*/
/**
* 货件计划明细
*/
// private BizLogisticsOrder order;
//
//
// private BizLogisticsQuote quote;
//
//
// private List<BizSendOrder> sendOrders;
//
// /**
// * 供应商发货单id
// */
// private Long sendOrderId;
}

View File

@ -13,6 +13,7 @@ import org.asinkj.common.excel.convert.ExcelDictConvert;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@ -228,8 +229,16 @@ public class BizShipmentPlanOrderVo implements Serializable {
private BizLogisticsQuote quote;
private BigDecimal amountPrice;
private BizSendOrder sendOrder;
private List<BizSendOrder> sendOrders;
@ExcelProperty(value = "发货数量")
private Long quantityShipped;
/**
* 供应商发货单id
*/

View File

@ -7,12 +7,9 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMappers;
import org.asinkj.amz.domain.BizSendOrder;
import org.asinkj.amz.domain.BizShipmentItem;
import org.asinkj.amz.domain.BizShipmentPlan;
import org.asinkj.amz.domain.*;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import org.asinkj.amz.domain.BizShipmentTracking;
import org.asinkj.amz.hanlder.AddressTypeHandler;
import org.asinkj.asinking.entity.FbaShipmentApiResponse;
import org.asinkj.common.excel.annotation.ExcelDictFormat;
@ -181,6 +178,12 @@ public class BizShipmentPlanVo implements Serializable {
@ExcelProperty(value = "总箱子数量")
private Long boxQuantity;
/**
* 发货数量
*/
@ExcelProperty(value = "发货数量")
private Long quantityShipped;
/**
* 箱子尺寸
*/
@ -225,6 +228,8 @@ public class BizShipmentPlanVo implements Serializable {
private BizSendOrder sendOrder;
private List<BizSendOrder> sendOrders;
private BizLogisticsQuote quote;
private List<BizShipmentItem> itemVoList;

View File

@ -75,4 +75,8 @@ public interface IBizSendOrderService {
void updateStatus(Long sendOrderId, String completed,String shipmentId);
int updateDataByBo(BizSendOrderBo bo);
TableDataInfo<BizSendOrderVo> coverSendOrder(BizSendOrderBo bo, PageQuery pageQuery);
void transfer(BizSendOrderVo bo);
}

View File

@ -1,5 +1,6 @@
package org.asinkj.amz.service;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import org.asinkj.amz.domain.BizSendOrder;
import org.asinkj.amz.domain.BizShipmentPlan;
@ -96,4 +97,8 @@ public interface IBizShipmentPlanService {
Map<Long, List<BizSendOrder>> batchGetSendOrdersByRequestIds(List<String> requestIds);
List<BizSendOrder> batchGetSendOrdersByShipmentIds(List<String> shipmentIds);
void updateQuoteIdData(String shipmentId, String logicQuoteId);
void queryPageListOrderExport(BizShipmentPlanBo bo, HttpServletResponse response);
}

View File

@ -224,7 +224,7 @@ public class BizLogisticsOrderServiceImpl implements IBizLogisticsOrderService {
lambdaQueryWrapper.eq(BizLogisticsOrderQuotation::getFbaShipmentId, fbaShipmentId);
Long l2 = bizLogisticsOrderQuotationMapper.selectCount(lambdaQueryWrapper);
if (l2 > 0) {
throw new ServiceException("订单确认订单已存在");
throw new ServiceException("订单已存在");
}
@ -292,6 +292,8 @@ public class BizLogisticsOrderServiceImpl implements IBizLogisticsOrderService {
// boolean b = bizLogisticsOrderDetailMapper.insertBatch(orderDetailList);
log.info("物流订单确认创建成功");
// bizShipmentPlanService.updateQuoteIdData(planVo.getShipmentId(),logicQuoteId);
}

View File

@ -139,13 +139,13 @@ public class BizPurchaseOrderServiceImpl implements IBizPurchaseOrderService {
LambdaQueryWrapper<BizSendOrderItem> sendOrderItemWrapper = new LambdaQueryWrapper<>();
sendOrderItemWrapper.in(BizSendOrderItem::getOrderSn, orderSnSet);
List<BizSendOrderItem> bizSendOrderItems = bizSendOrderItemMapper.selectList(sendOrderItemWrapper);
Map<String, Long> collect2 = bizSendOrderItems.stream()
Map<String, BigDecimal> collect2 = bizSendOrderItems.stream()
.collect(Collectors.groupingBy(
// 使用分隔符"_"拼接orderId和sku作为分组键
item -> item.getOrderSn() + "_" + item.getSku(),
// 对每个分组计算quality的总和
Collectors.reducing(0L, BizSendOrderItem::getQuantitySend, Long::sum)
Collectors.reducing(BigDecimal.ZERO, BizSendOrderItem::getQuantitySend, BigDecimal::add)
));
for (BizPurchaseOrderVo record : records) {
@ -164,9 +164,9 @@ public class BizPurchaseOrderServiceImpl implements IBizPurchaseOrderService {
if (CollectionUtil.isNotEmpty(bizSendOrders)) {
item.setHasSendOrder("Y");
}
Long l = collect2.get(item.getOrderSn() + "_" + item.getSku());
BigDecimal l = collect2.get(item.getOrderSn() + "_" + item.getSku());
item.setQuantityShipped(l);
item.setQuantityLeft(item.getQuantityReal() - Optional.ofNullable(item.getQuantityShipped()).orElse(0L));
item.setQuantityLeft(item.getQuantityReal().subtract(Optional.ofNullable(item.getQuantityShipped()).orElse(BigDecimal.ZERO)));
});
record.setItems(convert);
}
@ -265,7 +265,7 @@ public class BizPurchaseOrderServiceImpl implements IBizPurchaseOrderService {
lqw.eq(BizPurchaseOrder::getSupplierName, Objects.requireNonNull(LoginHelper.getLoginUser()).getNickname());
}
if (!LoginHelper.isSuperAdmin()) {
if (!LoginHelper.isSuperAdmin() && !StpUtil.hasRole("gengdan")) {
lqw.in(BizPurchaseOrder::getStatus, 1, 2, 9);
}
if (StrUtil.isNotBlank(bo.getSku())) {

View File

@ -134,13 +134,13 @@ public class BizPurchaseOutOrderServiceImpl implements IBizPurchaseOutOrderServi
bizShipForwardMap = bizShipForwards1.stream().collect(Collectors.groupingBy(BizShipForward::getOrderSn));
}
Map<String, Long> collect2 = bizSendOrderItems.stream()
Map<String, BigDecimal> collect2 = bizSendOrderItems.stream()
.collect(Collectors.groupingBy(
// 使用分隔符"_"拼接orderId和sku作为分组键
item -> item.getOrderSn() + "_" + item.getSku(),
// 对每个分组计算quality的总和
Collectors.reducing(0L, BizSendOrderItem::getQuantitySend, Long::sum)
Collectors.reducing(BigDecimal.ZERO, BizSendOrderItem::getQuantitySend, BigDecimal::add)
));
for (BizPurchaseOutOrderVo record : records) {
List<BizOrderOutItem> bizOrderOutItems1 = itemMap.get(record.getOrderSn());
@ -157,9 +157,9 @@ public class BizPurchaseOutOrderServiceImpl implements IBizPurchaseOutOrderServi
if (CollectionUtil.isNotEmpty(bizShipForwards)) {
item.setForwards(bizShipForwards);
}
item.setQuantityShipped(Optional.ofNullable(collect2.get(item.getPurchaseOrderSn() + "_" + item.getSku())).orElse(0L));
item.setQuantityLeft(item.getQuantityReal() - Optional.ofNullable(item.getQuantityShipped()).orElse(0L));
BigDecimal ratio = new BigDecimal(item.getQuantityReal()).divide(new BigDecimal(record.getOutsourceQuantity()), 2, RoundingMode.HALF_UP);
item.setQuantityShipped(Optional.ofNullable(collect2.get(item.getPurchaseOrderSn() + "_" + item.getSku())).orElse(BigDecimal.ZERO));
item.setQuantityLeft(item.getQuantityReal().subtract(Optional.ofNullable(item.getQuantityShipped()).orElse(BigDecimal.ZERO)));
BigDecimal ratio = item.getQuantityReal().divide(new BigDecimal(record.getOutsourceQuantity()), 2, RoundingMode.HALF_UP);
item.setRatio(ratio);
}
record.setItems(convert);
@ -273,7 +273,7 @@ public class BizPurchaseOutOrderServiceImpl implements IBizPurchaseOutOrderServi
bizSendOrder.setCreateName(LoginHelper.getLoginUser().getNickname());
bizSendOrder.setQuantitySend(bo.getOutsourceQuantity());
bizSendOrder.setSendName(bo.getSupplierName());
bizSendOrder.setSku(bo.getSku());
bizSendOrder.setSendId(sysUser.getUserId());
bizSendOrder.setType("com");
// LambdaUpdateWrapper<BizPurchaseOutOrder> updateWrapper = Wrappers.lambdaUpdate(BizPurchaseOutOrder.class)
@ -287,7 +287,7 @@ public class BizPurchaseOutOrderServiceImpl implements IBizPurchaseOutOrderServi
for (BizOrderOutItemVo item : bo.getItems()) {
BizSendOrderItem bizSendOrderItem = new BizSendOrderItem();
bizSendOrderItem.setQuantitySend(item.getOrder().getQuantityReal());
bizSendOrderItem.setQuantitySend(BigDecimal.valueOf(item.getOrder().getQuantityReal()));
bizSendOrderItem.setOrderSn(item.getPurchaseOrderSn());
bizSendOrderItem.setMainOrderSn(bizSendOrder.getId());
bizSendOrderItem.setProductName(item.getProductName());

View File

@ -30,6 +30,8 @@ import org.asinkj.amz.domain.vo.BizSendOrderVo;
import org.asinkj.amz.service.IBizSendOrderService;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -63,6 +65,9 @@ public class BizSendOrderServiceImpl implements IBizSendOrderService {
@Resource
private BizShipmentPlanMapper bizShipmentPlanMapper;
@Resource
private BizShipmentItemMapper bizShipmentItemMapper;
@Resource
private BizSendOrderItemMapper bizSendOrderItemMapper;
@ -89,26 +94,43 @@ public class BizSendOrderServiceImpl implements IBizSendOrderService {
LambdaQueryWrapper<BizSendOrder> lqw = buildQueryWrapper(bo);
Page<BizSendOrderVo> result = baseMapper.selectCustomPage(pageQuery.build(), lqw);
List<BizSendOrderVo> records = result.getRecords();
Set<String> shipmentIds = records.stream().map(BizSendOrderVo::getShipmentId).collect(Collectors.toSet());
// Set<String> shipmentIds = records.stream().map(BizSendOrderVo::getShipmentId).collect(Collectors.toSet());
Set<Long> ids = records.stream().map(BizSendOrderVo::getId).collect(Collectors.toSet());
LambdaQueryWrapper<BizLogisticsOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollectionUtil.isNotEmpty(shipmentIds), BizLogisticsOrder::getFbaShipmentId, shipmentIds);
List<BizLogisticsOrder> bizLogisticsOrders = bizLogisticsOrderMapper.selectList(lambdaQueryWrapper);
Set<String> collect = bizLogisticsOrders.stream().map(BizLogisticsOrder::getOrderId).collect(Collectors.toSet());
// LambdaQueryWrapper<BizLogisticsOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper.in(CollectionUtil.isNotEmpty(shipmentIds), BizLogisticsOrder::getFbaShipmentId, shipmentIds);
// List<BizLogisticsOrder> bizLogisticsOrders = bizLogisticsOrderMapper.selectList(lambdaQueryWrapper);
// Set<String> collect = bizLogisticsOrders.stream().map(BizLogisticsOrder::getOrderId).collect(Collectors.toSet());
LambdaQueryWrapper<BizLogisticsOrderDetail> orderDetailLambdaQueryWrapper = new LambdaQueryWrapper<>();
orderDetailLambdaQueryWrapper.in(CollectionUtil.isNotEmpty(collect), BizLogisticsOrderDetail::getOrderId, collect);
List<BizLogisticsOrderDetail> bizLogisticsOrderDetails = bizLogisticsOrderDetailMapper.selectList(orderDetailLambdaQueryWrapper);
Map<String, List<BizLogisticsOrderDetail>> detailMap = bizLogisticsOrderDetails.stream().collect(Collectors.groupingBy(BizLogisticsOrderDetail::getOrderId));
// LambdaQueryWrapper<BizLogisticsOrderDetail> orderDetailLambdaQueryWrapper = new LambdaQueryWrapper<>();
// orderDetailLambdaQueryWrapper.in(CollectionUtil.isNotEmpty(collect), BizLogisticsOrderDetail::getOrderId, collect);
// List<BizLogisticsOrderDetail> bizLogisticsOrderDetails = bizLogisticsOrderDetailMapper.selectList(orderDetailLambdaQueryWrapper);
// Map<String, List<BizLogisticsOrderDetail>> detailMap = bizLogisticsOrderDetails.stream().collect(Collectors.groupingBy(BizLogisticsOrderDetail::getOrderId));
for (BizLogisticsOrder bizLogisticsOrder : bizLogisticsOrders) {
bizLogisticsOrder.setDetails(detailMap.get(bizLogisticsOrder.getOrderId()));
}
Map<String, BizLogisticsOrder> logisticsOrderMap = bizLogisticsOrders.stream().collect(Collectors.toMap(BizLogisticsOrder::getFbaShipmentId, Function.identity()));
// LambdaQueryWrapper<BizShipmentItem> bizShipmentItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
// bizShipmentItemLambdaQueryWrapper.in(BizShipmentItem::getShipmentId, shipmentIds);
// List<BizShipmentItem> bizShipmentItems = bizShipmentItemMapper.selectList(bizShipmentItemLambdaQueryWrapper);
// Map<String, List<BizShipmentItem>> collect1 = bizShipmentItems.stream().collect(Collectors.groupingBy(BizShipmentItem::getShipmentId, Collectors.toList()));
// for (BizLogisticsOrder bizLogisticsOrder : bizLogisticsOrders) {
// bizLogisticsOrder.setDetails(detailMap.get(bizLogisticsOrder.getOrderId()));
// }
// Map<String, BizLogisticsOrder> logisticsOrderMap = bizLogisticsOrders.stream().collect(Collectors.toMap(BizLogisticsOrder::getFbaShipmentId, Function.identity()));
Map<Long, List<BizShipmentPlan>> shipmentsByOrderIdsMap = getShipmentsByOrderIds(ids);
List<BizShipmentPlan> collect = shipmentsByOrderIdsMap.values().stream().flatMap(Collection::stream).toList();
Set<String> shipmentIds = collect.stream().map(BizShipmentPlan::getShipmentId).collect(Collectors.toSet());
Map<String, List<BizShipmentItem>> shipmentItemsMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(shipmentIds)) {
LambdaQueryWrapper<BizShipmentItem> bizShipmentItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
bizShipmentItemLambdaQueryWrapper.in(BizShipmentItem::getShipmentId, shipmentIds);
List<BizShipmentItem> bizShipmentItems = bizShipmentItemMapper.selectList(bizShipmentItemLambdaQueryWrapper);
shipmentItemsMap = bizShipmentItems.stream().collect(Collectors.groupingBy(BizShipmentItem::getShipmentId, Collectors.toList()));
}
List<Long> logicIds = records.stream().map(BizSendOrderVo::getLogisticsProviderId).distinct().toList();
Map<Long, RemoteUserVo> remoteUserVoMap = remoteUserService.selectListByIds(logicIds).stream().collect(Collectors.toMap(RemoteUserVo::getUserId, Function.identity()));
Set<Long> recordIds = records.stream().map(BizSendOrderVo::getId).collect(Collectors.toSet());
@ -125,17 +147,34 @@ public class BizSendOrderServiceImpl implements IBizSendOrderService {
if (remoteUserVo != null) {
record.setAddress(remoteUserVo.getAddress());
}
BizLogisticsOrder bizLogisticsOrder = logisticsOrderMap.get(record.getShipmentId());
if (bizLogisticsOrder != null) {
record.setBizLogisticsOrder(bizLogisticsOrder);
}
// BizLogisticsOrder bizLogisticsOrder = logisticsOrderMap.get(record.getShipmentId());
// if (bizLogisticsOrder != null) {
// record.setBizLogisticsOrder(bizLogisticsOrder);
// }
List<BizShipmentPlan> bizShipmentPlans = shipmentsByOrderIdsMap.get(record.getId());
record.setBizShipmentPlans(bizShipmentPlans);
// if (record.getType().equals("com")) {
if (CollectionUtil.isNotEmpty(bizShipmentPlans)) {
for (BizShipmentPlan bizShipmentPlan : bizShipmentPlans) {
List<BizShipmentItem> bizShipmentItems1 = shipmentItemsMap.get(bizShipmentPlan.getShipmentId());
if (CollectionUtil.isNotEmpty(bizShipmentItems1)) {
long sum = bizShipmentItems1.stream().mapToLong(BizShipmentItem::getQuantityShipped).sum();
bizShipmentPlan.setSetTotal(sum);
}
}
}
List<BizSendOrderItem> bizSendOrderItems1 = sendOrderItemMap.get(record.getId());
if (CollectionUtil.isNotEmpty(bizSendOrderItems1)) {
for (BizSendOrderItem item : bizSendOrderItems1) {
BigDecimal ratio = item.getQuantitySend().divide(new BigDecimal(record.getQuantitySend()), 2, RoundingMode.HALF_UP);
item.setRatio(ratio);
}
}
record.setItems(bizSendOrderItems1);
// }
}
@ -210,6 +249,10 @@ public class BizSendOrderServiceImpl implements IBizSendOrderService {
lqw.eq(BizSendOrder::getSendId, LoginHelper.getUserId());
}
if (CollectionUtil.isNotEmpty(bo.getSkus())) {
lqw.in(BizSendOrder::getSku, bo.getSkus());
}
return lqw;
}
@ -329,4 +372,123 @@ public class BizSendOrderServiceImpl implements IBizSendOrderService {
validEntityBeforeSave(update);
return baseMapper.updateById(update);
}
@Override
public TableDataInfo<BizSendOrderVo> coverSendOrder(BizSendOrderBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<BizSendOrder> lqw = buildQueryWrapper(bo);
Page<BizSendOrderVo> result = baseMapper.selectCustomPage(pageQuery.build(), lqw);
List<BizSendOrderVo> records = result.getRecords();
Set<String> shipmentIds = records.stream().map(BizSendOrderVo::getShipmentId).collect(Collectors.toSet());
Set<Long> ids = records.stream().map(BizSendOrderVo::getId).collect(Collectors.toSet());
LambdaQueryWrapper<BizLogisticsOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollectionUtil.isNotEmpty(shipmentIds), BizLogisticsOrder::getFbaShipmentId, shipmentIds);
List<BizLogisticsOrder> bizLogisticsOrders = bizLogisticsOrderMapper.selectList(lambdaQueryWrapper);
Set<String> collect = bizLogisticsOrders.stream().map(BizLogisticsOrder::getOrderId).collect(Collectors.toSet());
LambdaQueryWrapper<BizLogisticsOrderDetail> orderDetailLambdaQueryWrapper = new LambdaQueryWrapper<>();
orderDetailLambdaQueryWrapper.in(CollectionUtil.isNotEmpty(collect), BizLogisticsOrderDetail::getOrderId, collect);
List<BizLogisticsOrderDetail> bizLogisticsOrderDetails = bizLogisticsOrderDetailMapper.selectList(orderDetailLambdaQueryWrapper);
Map<String, List<BizLogisticsOrderDetail>> detailMap = bizLogisticsOrderDetails.stream().collect(Collectors.groupingBy(BizLogisticsOrderDetail::getOrderId));
for (BizLogisticsOrder bizLogisticsOrder : bizLogisticsOrders) {
bizLogisticsOrder.setDetails(detailMap.get(bizLogisticsOrder.getOrderId()));
}
Map<String, BizLogisticsOrder> logisticsOrderMap = bizLogisticsOrders.stream().collect(Collectors.toMap(BizLogisticsOrder::getFbaShipmentId, Function.identity()));
Map<Long, List<BizShipmentPlan>> shipmentsByOrderIdsMap = getShipmentsByOrderIds(ids);
List<Long> logicIds = records.stream().map(BizSendOrderVo::getLogisticsProviderId).distinct().toList();
Map<Long, RemoteUserVo> remoteUserVoMap = remoteUserService.selectListByIds(logicIds).stream().collect(Collectors.toMap(RemoteUserVo::getUserId, Function.identity()));
Set<Long> recordIds = records.stream().map(BizSendOrderVo::getId).collect(Collectors.toSet());
Map<Long, List<BizSendOrderItem>> sendOrderItemMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(recordIds)) {
LambdaQueryWrapper<BizSendOrderItem> sendOrderItemWrapper = new LambdaQueryWrapper<>();
sendOrderItemWrapper.in(BizSendOrderItem::getMainOrderSn, recordIds);
List<BizSendOrderItem> bizSendOrderItems = bizSendOrderItemMapper.selectList(sendOrderItemWrapper);
sendOrderItemMap = bizSendOrderItems.stream().collect(Collectors.groupingBy(BizSendOrderItem::getMainOrderSn));
}
for (BizSendOrderVo record : records) {
RemoteUserVo remoteUserVo = remoteUserVoMap.get(record.getLogisticsProviderId());
if (remoteUserVo != null) {
record.setAddress(remoteUserVo.getAddress());
}
BizLogisticsOrder bizLogisticsOrder = logisticsOrderMap.get(record.getShipmentId());
if (bizLogisticsOrder != null) {
record.setBizLogisticsOrder(bizLogisticsOrder);
}
List<BizShipmentPlan> bizShipmentPlans = shipmentsByOrderIdsMap.get(record.getId());
record.setBizShipmentPlans(bizShipmentPlans);
// if (record.getType().equals("com")) {
List<BizSendOrderItem> bizSendOrderItems1 = sendOrderItemMap.get(record.getId());
record.setItems(bizSendOrderItems1);
// }
}
return TableDataInfo.build(result);
}
@Override
public void transfer(BizSendOrderVo bo) {
//调拨
// BizSendOrder add = MapstructUtils.convert(bo, BizSendOrder.class);
// validEntityBeforeSave(add);
BizSendOrder add = new BizSendOrder();
add.setSku(bo.getSku());
add.setOrderSn(bo.getOrderSn());
add.setOrderDetailId(bo.getOrderDetailId());
add.setSendDate(bo.getSendDate());
add.setStoreName(bo.getStoreName());
add.setProductName(bo.getProductName());
add.setQuantitySend(bo.getQuantitySend());
add.setQuantityPerBox(bo.getQuantityPerBox());
add.setBoxCount(bo.getBoxCount());
add.setBoxDimensions(bo.getBoxDimensions());
add.setWeightPerBox(bo.getWeightPerBox());
add.setRealStoreName(bo.getRealStoreName());
add.setSendStatus(bo.getSendStatus());
add.setSendDetail(bo.getSendDetail());
add.setLogisticsProviderName(bo.getLogisticsProviderName());
add.setLogisticsProviderId(bo.getLogisticsProviderId());
// LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(SysUser::getNickName, bo.getSendName());
// List<SysUser> sysUsers = sysUserMapper.selectList(queryWrapper);
// if (CollectionUtil.isEmpty(sysUsers)) {
// throw new RuntimeException("供应商不存在");
// }
// SysUser sysUser = sysUsers.get(0);
//
// add.setSendId(sysUser.getUserId());
// add.setSendName(sysUser.getNickName());
add.setCreateName(LoginHelper.getLoginUser().getNickname());
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
List<BizSendOrderItem> bizSendOrderItems = new ArrayList<>();
if (CollectionUtil.isNotEmpty(bo.getItems())) {
for (BizSendOrderItem item : bo.getItems()) {
BizSendOrderItem bizSendOrderItem = new BizSendOrderItem();
bizSendOrderItem.setQuantitySend(item.getQuantitySend());
bizSendOrderItem.setOrderSn(item.getOrderSn());
bizSendOrderItem.setMainOrderSn(add.getId());
bizSendOrderItem.setProductName(item.getProductName());
bizSendOrderItem.setSku(item.getSku());
bizSendOrderItem.setQuantitySend(item.getQuantitySend().multiply(item.getRatio()));
bizSendOrderItems.add(bizSendOrderItem);
}
bizSendOrderItemMapper.insertBatch(bizSendOrderItems);
}
}
}

View File

@ -5,8 +5,10 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.ibatis.annotations.MapKey;
@ -34,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -83,6 +86,9 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
@Resource
private BizLogisticsOrderDetailMapper bizLogisticsOrderDetailMapper;
@Resource
private BizLogisticsQuoteMapper bizLogisticsQuoteMapper;
/**
* 查询货件计划
*
@ -142,6 +148,17 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
BizShipmentTracking::getShipmentId,
Collectors.counting()
));
LambdaQueryWrapper<BizLogisticsQuote> quoteQueryWrapper = new LambdaQueryWrapper<>();
quoteQueryWrapper.in(BizLogisticsQuote::getShipmentId, shipmentIds);
List<BizLogisticsQuote> bizLogisticsQuotes = bizLogisticsQuoteMapper.selectList(quoteQueryWrapper);
Map<String, BizLogisticsQuote> quoteMap = new HashMap<>();
// if (CollectionUtil.isNotEmpty(bizLogisticsQuotes)) {
// quoteMap = bizLogisticsQuotes.stream()
// .collect(Collectors.toMap(
// BizLogisticsQuote::getShipmentId,
// Function.identity()
// ));
// }
LambdaQueryWrapper<BizShipmentItem> bizShipmentItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
bizShipmentItemLambdaQueryWrapper.in(BizShipmentItem::getShipmentId, shipmentIds);
@ -158,15 +175,22 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
List<BizSendOrder> bizSendOrders = resultOrderMap.get(bizShipmentPlanVo.getId());
bizShipmentPlanVo.setSendOrders(bizSendOrders);
Long count = collect.get(bizShipmentPlanVo.getShipmentId());
bizShipmentPlanVo.setBoxQuantity(count);
bizShipmentPlanVo.setItemVoList(collect1.get(bizShipmentPlanVo.getShipmentId()));
// bizShipmentPlanVo.setBoxQuantity(count);
List<BizShipmentItem> bizShipmentItems1 = collect1.get(bizShipmentPlanVo.getShipmentId());
long sum = bizShipmentItems1.stream().mapToLong(BizShipmentItem::getQuantityShipped).sum();
bizShipmentPlanVo.setQuantityShipped(sum);
bizShipmentPlanVo.setItemVoList(bizShipmentItems1);
if (CollectionUtil.isNotEmpty(sids)) {
String storeName = storeNameMap.get(bizShipmentPlanVo.getSid());
bizShipmentPlanVo.setSellerName(storeName);
}
BizLogisticsQuote bizLogisticsQuote = quoteMap.get(bizShipmentPlanVo.getShipmentId());
if (bizLogisticsQuote != null) {
bizShipmentPlanVo.setQuote(bizLogisticsQuote);
}
}
}
@ -193,9 +217,6 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
}
/**
* 查询符合条件的货件计划列表
*
@ -385,11 +406,15 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
}
Set<Long> senOrderIds = result.getRecords().stream().map(BizShipmentPlanVo::getSendOrderId).collect(Collectors.toSet());
Map<Long, BizSendOrder> sendOrderMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(senOrderIds)) {
sendOrderMap = iSendOrderService.queryBySidList(senOrderIds).stream().collect(Collectors.toMap(BizSendOrder::getId, Function.identity()));
}
// Set<Long> senOrderIds = result.getRecords().stream().map(BizShipmentPlanVo::getSendOrderId).collect(Collectors.toSet());
// Map<Long, BizSendOrder> sendOrderMap = new HashMap<>();
// if (CollectionUtil.isNotEmpty(senOrderIds)) {
// sendOrderMap = iSendOrderService.queryBySidList(senOrderIds).stream().collect(Collectors.toMap(BizSendOrder::getId, Function.identity()));
// }
Set<Long> ids = result.getRecords().stream().map(BizShipmentPlanVo::getId).collect(Collectors.toSet());
Map<Long, List<BizSendOrder>> resultOrderMap = getOrdersGroupedByShipmentId(ids);
if (CollectionUtil.isNotEmpty(shipmentIds)) {
LambdaQueryWrapper<BizShipmentTracking> queryWrapper = new LambdaQueryWrapper<>();
@ -429,19 +454,27 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
Long count = collect.get(bizShipmentPlanVo.getShipmentId());
BizLogisticsOrder bizLogisticsOrder = orderMap.get(bizShipmentPlanVo.getShipmentId());
List<BizLogisticsOrderDetail> bizLogisticsOrderDetails1 = detailMap.get(bizShipmentPlanVo.getShipmentId());
bizShipmentPlanVo.setItemVoList(collect1.get(bizShipmentPlanVo.getShipmentId()));
BizSendOrder bizSendOrder = sendOrderMap.get(bizShipmentPlanVo.getSendOrderId());
if (bizSendOrder != null) {
bizShipmentPlanVo.setSendOrder(sendOrderMap.get(bizShipmentPlanVo.getSendOrderId()));
}
List<BizShipmentItem> bizShipmentItems1 = collect1.get(bizShipmentPlanVo.getShipmentId());
bizShipmentPlanVo.setItemVoList(bizShipmentItems1);
long sum = bizShipmentItems1.stream().mapToLong(BizShipmentItem::getQuantityShipped).sum();
bizShipmentPlanVo.setQuantityShipped(sum);
// BizSendOrder bizSendOrder = sendOrderMap.get(bizShipmentPlanVo.getSendOrderId());
// if (bizSendOrder != null) {
// bizShipmentPlanVo.setSendOrder(sendOrderMap.get(bizShipmentPlanVo.getSendOrderId()));
// }
List<BizSendOrder> bizSendOrders = resultOrderMap.get(bizShipmentPlanVo.getId());
bizShipmentPlanVo.setSendOrders(bizSendOrders);
bizShipmentPlanVo.setDetailList(bizLogisticsOrderDetails1);
if (CollectionUtil.isNotEmpty(bizLogisticsOrderDetails1)) {
BizLogisticsOrderDetail bizLogisticsOrderDetail = bizLogisticsOrderDetails1.get(0);
bizShipmentPlanVo.setTrackingNumber(bizLogisticsOrderDetail.getTrackingNumber());
long sum = bizLogisticsOrderDetails1.stream().filter(item -> item.getLogisticsWeight() != null).mapToLong(BizLogisticsOrderDetail::getLogisticsWeight).sum();
bizShipmentPlanVo.setLogisticWeight(sum);
long sum2 = bizLogisticsOrderDetails1.stream().filter(item -> item.getLogisticsWeight() != null).mapToLong(BizLogisticsOrderDetail::getLogisticsWeight).sum();
bizShipmentPlanVo.setLogisticWeight(sum2);
long l = Optional.ofNullable(bizShipmentPlanVo.getLogisticWeight()).orElse(0L) - Optional.ofNullable(bizShipmentPlanVo.getVendorWeight()).orElse(0L);
bizShipmentPlanVo.setWeightDiff(l);
@ -451,6 +484,7 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
if (bizLogisticsOrder != null) {
BizLogisticsQuote bizLogisticsQuote = quoteMap.get(bizLogisticsOrder.getQuoteOrderId());
bizShipmentPlanVo.setQuote(bizLogisticsQuote);
bizShipmentPlanVo.setAmountPrice(bizLogisticsQuote.getPrice().multiply(new BigDecimal(Optional.ofNullable(bizShipmentPlanVo.getLogisticWeight()).orElse(0L))).add(BigDecimal.valueOf(bizLogisticsQuote.getSurcharge())));
}
if (CollectionUtil.isNotEmpty(sids)) {
@ -527,6 +561,132 @@ public class BizShipmentPlanServiceImpl implements IBizShipmentPlanService {
return baseMapper.batchGetSendOrdersByShipmentIds(shipmentIds);
}
@Override
public void updateQuoteIdData(String shipmentId, String logicQuoteId) {
LambdaUpdateWrapper<BizShipmentPlan> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(BizShipmentPlan::getShipmentId, shipmentId)
.set(BizShipmentPlan::getFbaStatus, "send");
baseMapper.update(null, lambdaUpdateWrapper);
}
@Override
public void queryPageListOrderExport(BizShipmentPlanBo bo, HttpServletResponse response) {
PageQuery pageQuery1 = new PageQuery();
pageQuery1.setPageNum(1);
pageQuery1.setPageSize(5000);
TableDataInfo<BizShipmentPlanOrderVo> dataInfo = queryPageListOrder(bo, pageQuery1);
List<BizShipmentPlanOrderVo> rows = dataInfo.getRows();
List<BizShipmentPlanOrderExportVo> exportVos = new ArrayList<>();
Map<String, BizShipmentItem> itemMap = rows.stream().flatMap(row -> row.getItemVoList().stream()).collect(Collectors.toMap(c -> c.getShipmentId() + c.getSku(), Function.identity()));
for (BizShipmentPlanOrderVo row : rows) {
BizShipmentPlanOrderExportVo exportVo = new BizShipmentPlanOrderExportVo();
/**
* @ExcelProperty(value = "计划发货日期")
* private Date staShipmentDate;
*
* @ExcelProperty(value = "店铺名称")
* private String sellerName;
*
*
* @ExcelProperty(value = "货件编号")
* private String shipmentId;
*
* private String productName;
* private String msku;
* private String fnsku;
*
*
* private String sku;
*
* private String asin;
*
* @ExcelProperty(value = "申报量")
* private Long quantityShipped;
*
* @ExcelProperty(value = "物流中心编码")
* private String destination;
*
*
* @ExcelProperty(value = "供应商称重")
* private Long vendorWeight;
*
*
* @ExcelProperty(value = "物流商称重")
* private Long logisticWeight;
*
* private Long weightDiff;
*
*
* private String logisticsName;
*
* @ExcelProperty(value = "物流渠道")
* private String channelName;
*
* //单价
* private BigDecimal price;
*
* // 时效单位
* private BigDecimal leadTime;
*
* private BigDecimal totalPrice;
*
* //附加费
* private BigDecimal surcharge;
* //结算金额
* private BigDecimal amountPrice;
*
* private String orderSn;
*
* //供应商名称
* private String sendName;
*
* private Long quantitySend;
*
* private String sendDetail;
*/
for (BizSendOrder sendOrder : row.getSendOrders()) {
exportVo.setShipmentId(row.getShipmentId());
exportVo.setSellerName(row.getSellerName());
exportVo.setDestination(row.getDestination());
exportVo.setVendorWeight(row.getVendorWeight());
exportVo.setLogisticWeight(row.getLogisticWeight());
exportVo.setWeightDiff(row.getWeightDiff());
BizLogisticsQuote quote = row.getQuote();
if (quote != null) {
exportVo.setLogisticsName(row.getQuote().getLogisticsName());
exportVo.setChannelName(row.getChannelName());
exportVo.setPrice(row.getQuote().getPrice());
exportVo.setLeadTime(BigDecimal.valueOf(row.getQuote().getLeadTime()));
exportVo.setTotalPrice(row.getQuote().getTotalPrice());
exportVo.setSurcharge(BigDecimal.valueOf(row.getQuote().getSurcharge()));
}
exportVo.setProductName(sendOrder.getProductName());
exportVo.setSku(sendOrder.getSku());
exportVo.setSendName(sendOrder.getSendName());
exportVo.setQuantitySend(sendOrder.getQuantitySend());
exportVo.setSendDetail(sendOrder.getSendDetail());
BizShipmentItem bizShipmentItem = itemMap.get(row.getShipmentId() + sendOrder.getSku());
if (bizShipmentItem != null) {
exportVo.setMsku(bizShipmentItem.getMsku());
exportVo.setFnsku(bizShipmentItem.getFnsku());
exportVo.setAsin(bizShipmentItem.getAsin());
exportVo.setQuantityShipped(bizShipmentItem.getQuantityShipped());
}
exportVos.add(exportVo);
}
}
ExcelUtil.exportExcel(exportVos, "导出", BizShipmentPlanOrderExportVo.class, response);
}
private void checkData(List<BizShipmentPlanFileData> bizShipmentPlanFileDataList) {
boolean isAllSame = bizShipmentPlanFileDataList.stream()
.map(BizShipmentPlanFileData::getShipmentId)

View File

@ -558,8 +558,6 @@ public class SysAmazonStoreServiceImpl implements ISysAmazonStoreService {
List<PurchaseOutOrder> list = data.toList(PurchaseOutOrder.class);
log.info("purchaseOutOrder:{}", list);
//
List<String> collect = list.stream().map(PurchaseOutOrder::getOrderSn).collect(Collectors.toList());
// 删除collect 里面已经存在表里的数据
List<BizPurchaseOutOrder> bizPurchaseOutOrders = bizPurchaseOutOrderMapper.selectList(new LambdaQueryWrapper<BizPurchaseOutOrder>().in(BizPurchaseOutOrder::getOrderSn, collect));
@ -583,7 +581,7 @@ public class SysAmazonStoreServiceImpl implements ISysAmazonStoreService {
bizOrderOutItem.setUpdateBy(1L);
bizOrderOutItem.setUpdateTime(new Date());
}
items.removeIf(bizOrderOutItem -> ObjectUtil.isEmpty(bizOrderOutItem.getPurchaseOrderSn()));
bizOrderOutItems.addAll(items);
}
if (CollectionUtil.isNotEmpty(insertList)) {
@ -989,6 +987,13 @@ public class SysAmazonStoreServiceImpl implements ISysAmazonStoreService {
if (CollectionUtil.isNotEmpty(bizShipmentPlans)) {
Set<BizShipmentPlan> readyToShip = new HashSet<>(bizShipmentPlans);
if (CollectionUtil.isNotEmpty(readyToShip)) {
Map<String, Long> collect = bizTrackingList.stream().collect(Collectors.groupingBy(BizShipmentTracking::getShipmentId,
Collectors.counting()));
for (BizShipmentPlan bizShipmentPlan : readyToShip) {
bizShipmentPlan.setBoxQuantity(collect.get(bizShipmentPlan.getShipmentId()));
}
bizShipmentPlanMapper.insertBatch(readyToShip);
shipmentIdList.addAll(readyToShip.stream().map(BizShipmentPlan::getShipmentId).toList());
}

View File

@ -36,7 +36,6 @@ public class HttpUtil {
// 防止实例化
private HttpUtil() {}
/**
@ -54,14 +53,12 @@ public class HttpUtil {
}
}
// GET 请求
public static void get(String url, Map<String, String> customParams, Callback callback) {
Map<String, Object> allParams = mergeParams(customParams);
Map<String, String> queryParams = convertToStringMap(allParams);
buildAndSendRequest(url, queryParams, "GET", null, callback);
}
// POST 表单
public static void postForm(String url, Map<String, String> customParams, Callback callback) {
Map<String, Object> allParams = mergeParams(customParams);
Map<String, String> formParams = convertToStringMap(allParams);
@ -69,7 +66,6 @@ public class HttpUtil {
buildAndSendRequest(url, null, "POST", formBody, callback);
}
// POST 请求参数在URL无请求体
public static void postWithUrlParams(String url, Map<String, String> customParams, Callback callback) {
Map<String, Object> allParams = mergeParams(customParams);
Map<String, String> queryParams = convertToStringMap(allParams);
@ -89,7 +85,6 @@ public class HttpUtil {
Map<String, Object> allParams = new HashMap<>();
if (customParams != null) allParams.putAll(customParams);
// 动态获取最新access_token
allParams.put("app_key", appId);
allParams.put("access_token", RedisUtils.getCacheObject(ACCESS_TOKEN));
long l = System.currentTimeMillis() / 1000;
@ -106,7 +101,6 @@ public class HttpUtil {
Map<String, Object> allParams = new HashMap<>();
if (customParams != null) allParams.putAll(customParams);
// 动态获取最新access_token
allParams.put("app_key", appId);
allParams.put("access_token", RedisUtils.getCacheObject(ACCESS_TOKEN));
long l = System.currentTimeMillis() / 1000;
@ -119,12 +113,10 @@ public class HttpUtil {
public static void getAmzStoreTokenData() throws Exception {
// 如果用postman等其他工具调试时需要将appSecret用urlencode.encode()进行转义
if (ObjectUtil.isNull(RedisUtils.getCacheObject(REFRESH_TOKEN))) {
Result result = AKRestClientBuild.builder().endpoint(baseurl).getAccessToken(appId, appSecret);
Object data = result.getData();
if (data instanceof LinkedHashMap) {
// 将LinkedHashMap转为TokenInfo
ObjectMapper mapper = new ObjectMapper();
TokenInfo tokenInfo = mapper.convertValue(data, TokenInfo.class); // 关键点
log.info("token:{}", tokenInfo.getRefreshToken());
@ -168,7 +160,6 @@ public class HttpUtil {
}
}
// 其余工具方法保持不变...
private static Map<String, String> convertToStringMap(Map<String, Object> sourceMap) {
Map<String, String> stringMap = new HashMap<>();
for (Map.Entry<String, Object> entry : sourceMap.entrySet()) {
@ -201,7 +192,6 @@ public class HttpUtil {
Map<String, Object> signParams = new HashMap<>();
Map<String, String> baseParams = new HashMap<>();
// 动态获取最新access_token
baseParams.put("app_key", appId);
baseParams.put("access_token", RedisUtils.getCacheObject(ACCESS_TOKEN));
long l = System.currentTimeMillis() / 1000;
@ -214,10 +204,8 @@ public class HttpUtil {
baseParams.put("sign", sign);
// Map<String, String> queryParams = convertToStringMap(allParams);
String json = JSON.toJSONString(queryParams);
// 3. 创建 RequestBody指定 MediaType JSON
RequestBody requestBody = RequestBody.create(
json,
MediaType.parse("application/json; charset=utf-8")
@ -251,7 +239,6 @@ public class HttpUtil {
Map<String, Object> signParams = new HashMap<>();
Map<String, String> baseParams = new HashMap<>();
// 动态获取最新 access_token
baseParams.put("app_key", appId);
baseParams.put("access_token", RedisUtils.getCacheObject(ACCESS_TOKEN));
long l = System.currentTimeMillis() / 1000;
@ -263,24 +250,20 @@ public class HttpUtil {
String sign = ApiSign.sign(signParams, appId);
baseParams.put("sign", sign);
// queryParams 转换为 JSON 字符串
String json = JSON.toJSONString(queryParams);
// 创建 RequestBody
RequestBody requestBody = RequestBody.create(
json,
MediaType.parse("application/json; charset=utf-8")
);
// 发送同步请求并获取响应
Response response = buildAndSendSyncRequest(url, baseParams, "POST", requestBody);
// 解析响应根据业务需求调整
if (!response.isSuccessful()) {
throw new IOException("请求失败,状态码: " + response.code());
}
String responseData = response.body().string();
response.close(); // 确保关闭资源
response.close();
return responseData;
}
@ -291,24 +274,20 @@ public class HttpUtil {
String method,
RequestBody body
) throws IOException {
// 构建完整 URL
HttpUrl.Builder urlBuilder = HttpUrl.parse(baseurl + url).newBuilder();
if (queryParams != null) {
queryParams.forEach(urlBuilder::addQueryParameter);
}
// 创建 Request
Request.Builder requestBuilder = new Request.Builder()
.url(urlBuilder.build());
// 设置请求方法
if ("POST".equalsIgnoreCase(method)) {
requestBuilder.post(body);
} else {
requestBuilder.get();
}
// 同步执行请求
return client.newCall(requestBuilder.build()).execute();
}
}