修改 orderCreateItemDTO ,改为内部 static

pull/1/head
sin 2019-04-25 18:51:12 +08:00
parent 2ddf0e30d1
commit cddffabeba
8 changed files with 49 additions and 39 deletions

View File

@ -38,7 +38,7 @@ public interface OrderConvertAPP {
OrderCreateDTO convert(OrderCreatePO orderCreatePO);
@Mappings({})
List<OrderCreateItemDTO> convert(List<CartItemBO> cartItems);
List<OrderCreateDTO.OrderItem> convert(List<CartItemBO> cartItems);
default OrderCreateDTO createOrderCreateDTO(Integer userId, Integer userAddressId, String remark, String ip,
List<CartItemBO> cartItems, Integer couponCardId) {

View File

@ -1,9 +1,9 @@
package cn.iocoder.mall.order.application.po.user;
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
@ -38,6 +38,22 @@ public class OrderCreatePO implements Serializable {
@NotNull()
@Size(max = 1000, min = 1, message = "用户订单中没有商品!")
private List<OrderCreateItemDTO> orderItems;
private List<OrderItem> orderItems;
@Data
@Accessors(chain = true)
public static class OrderItem {
/**
*
*/
@NotNull
private Integer skuId;
/**
*
*/
@NotNull
@Max(value = 1000)
private Integer quantity;
}
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@ -40,6 +42,23 @@ public class OrderCreateDTO implements Serializable {
///
/// order item
private List<OrderCreateItemDTO> orderItems;
private List<OrderItem> orderItems;
@Data
@Accessors(chain = true)
public static class OrderItem {
/**
*
*/
@NotNull
private Integer skuId;
/**
*
*/
@NotNull
@Max(value = 1000)
private Integer quantity;
}
}

View File

@ -1,29 +0,0 @@
package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
/**
* @author Sin
* @time 2019-03-17 09:37
*/
@Data
@Accessors(chain = true)
public class OrderCreateItemDTO {
/**
*
*/
@NotNull
private Integer skuId;
/**
*
*/
@NotNull
@Max(value = 1000)
private Integer quantity;
}

View File

@ -35,6 +35,11 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>promotion-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
import cn.iocoder.mall.order.api.bo.OrderItemBO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import org.mapstruct.Mapper;
@ -28,7 +28,7 @@ public interface OrderItemConvert {
List<OrderItemBO> convertOrderItemBO(List<OrderItemDO> orderItemDOList);
@Mappings({})
List<OrderItemDO> convert(List<OrderCreateItemDTO> orderCreateItemDTOList);
List<OrderItemDO> convert(List<OrderCreateDTO.OrderItem> orderCreateItemDTOList);
@Mappings({})
List<OrderItemBO> convertOrderItemDO(List<OrderItemDO> orderItemDOList);

View File

@ -194,7 +194,7 @@ public class OrderServiceImpl implements OrderService {
@Transactional // TODO 芋艿,先不考虑分布式事务的问题
public CommonResult<OrderCreateBO> createOrder(OrderCreateDTO orderCreateDTO) {
Integer userId = orderCreateDTO.getUserId();
List<OrderCreateItemDTO> orderItemDTOList = orderCreateDTO.getOrderItems();
List<OrderCreateDTO.OrderItem> orderItemDTOList = orderCreateDTO.getOrderItems();
List<OrderItemDO> orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList);
// 获取商品信息
@ -337,7 +337,7 @@ public class OrderServiceImpl implements OrderService {
.setUserId(orderCreateDTO.getUserId())
.setItems(new ArrayList<>(skus.size()))
.setCouponCardId(orderCreateDTO.getCouponCardId());
for (OrderCreateItemDTO item : orderCreateDTO.getOrderItems()) {
for (OrderCreateDTO.OrderItem item : orderCreateDTO.getOrderItems()) {
calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), true));
}
// 执行计算

View File

@ -5,7 +5,6 @@ import cn.iocoder.mall.order.OrderApplicationTest;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.OrderCreateBO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
import cn.iocoder.mall.order.biz.dao.OrderMapper;
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
import org.junit.Assert;