mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:19:19 +08:00
feat: 优化内部订单管理页改用两栏布局
This commit is contained in:
+4
-11
@@ -1,6 +1,7 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.order.model.dto;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -9,7 +10,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 更新订单 DTO
|
||||
* 更新订单 DTO(主表字段 + 明细全量替换;不兼容扁平单行)
|
||||
*/
|
||||
@Data
|
||||
public class UpdateOrderDTO {
|
||||
@@ -45,19 +46,11 @@ public class UpdateOrderDTO {
|
||||
|
||||
private BigDecimal sellerDiscount;
|
||||
|
||||
/** 明细全量替换,至少一行 */
|
||||
@Valid
|
||||
@NotEmpty(message = "订单明细不能为空")
|
||||
private List<CreateOrderItemDTO> items;
|
||||
|
||||
/** 扁平字段(未传 items 时合成一行) */
|
||||
private Long productSkuId;
|
||||
private String skuCode;
|
||||
private String linkProductName;
|
||||
private String linkSkuName;
|
||||
private Integer quantity;
|
||||
private BigDecimal unitPrice;
|
||||
private BigDecimal productCost;
|
||||
private BigDecimal shippingCost;
|
||||
private BigDecimal otherCost;
|
||||
private String remark;
|
||||
private Integer confirm;
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-内部订单主表(一单一行)
|
||||
* 电商-内部订单主表(头表;明细在 ec_order_item)
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
+3
-5
@@ -135,7 +135,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderPO> implemen
|
||||
}
|
||||
|
||||
OrderPO order = new OrderPO();
|
||||
BeanCopyUtils.copyProperties(updateOrderDTO, order);
|
||||
BeanCopyUtils.copyProperties(updateOrderDTO, order, "items");
|
||||
order.setId(id);
|
||||
order.setCompanyId(companyId);
|
||||
order.setUpdateBy(userId);
|
||||
@@ -156,10 +156,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderPO> implemen
|
||||
this.updateById(order);
|
||||
|
||||
List<CreateOrderItemDTO> itemDtos = OrderDtoSupport.resolveItems(updateOrderDTO);
|
||||
if (itemDtos != null && !itemDtos.isEmpty()) {
|
||||
validateItems(itemDtos, companyId);
|
||||
replaceItems(existingOrder, itemDtos, userId);
|
||||
}
|
||||
validateItems(itemDtos, companyId);
|
||||
replaceItems(existingOrder, itemDtos, userId);
|
||||
|
||||
OrderPO after = this.getById(id);
|
||||
return convertToVO(after != null ? after : order);
|
||||
|
||||
+3
-17
@@ -42,24 +42,10 @@ public final class OrderDtoSupport {
|
||||
}
|
||||
|
||||
public static List<CreateOrderItemDTO> resolveItems(UpdateOrderDTO dto) {
|
||||
if (dto.getItems() != null && !dto.getItems().isEmpty()) {
|
||||
return dto.getItems();
|
||||
if (dto.getItems() == null || dto.getItems().isEmpty()) {
|
||||
throw new BusinessException("订单明细不能为空");
|
||||
}
|
||||
if (dto.getProductSkuId() == null && (dto.getLinkProductName() == null || dto.getLinkProductName().isBlank())) {
|
||||
return null;
|
||||
}
|
||||
CreateOrderItemDTO item = new CreateOrderItemDTO();
|
||||
item.setProductSkuId(dto.getProductSkuId());
|
||||
item.setSkuCode(dto.getSkuCode());
|
||||
item.setLinkProductName(dto.getLinkProductName());
|
||||
item.setLinkSkuName(dto.getLinkSkuName());
|
||||
item.setQuantity(dto.getQuantity());
|
||||
item.setUnitPrice(dto.getUnitPrice());
|
||||
item.setProductCost(dto.getProductCost());
|
||||
item.setShippingCost(dto.getShippingCost());
|
||||
item.setOtherCost(dto.getOtherCost());
|
||||
item.setRemark(dto.getRemark());
|
||||
return List.of(item);
|
||||
return dto.getItems();
|
||||
}
|
||||
|
||||
public static OrderItemPO toItemPO(CreateOrderItemDTO dto, OrderPO order, ProductSkuPO sku,
|
||||
|
||||
Reference in New Issue
Block a user