- 优化订单查询,和 convert 转换
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.order.convert;
|
||||
package cn.iocoder.mall.order.application.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderPageBO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.order.convert;
|
||||
package cn.iocoder.mall.order.application.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.order.convert;
|
||||
package cn.iocoder.mall.order.application.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO;
|
||||
@@ -55,5 +55,5 @@ public interface OrderMapper {
|
||||
* @param orderQueryDTO
|
||||
* @return
|
||||
*/
|
||||
List<OrderDO> selectPage(OrderQueryDTO orderQueryDTO, int offset, int pageSize);
|
||||
List<OrderDO> selectPage(OrderQueryDTO orderQueryDTO);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class OrderDO extends DeletableDO {
|
||||
/**
|
||||
* 交易金额
|
||||
*/
|
||||
private Integer money;
|
||||
private Integer price;
|
||||
|
||||
///
|
||||
/// 时间信息
|
||||
@@ -87,7 +87,7 @@ public class OrderDO extends DeletableDO {
|
||||
", userId=" + userId +
|
||||
", orderLogisticsId=" + orderLogisticsId +
|
||||
", orderNo='" + orderNo + '\'' +
|
||||
", money=" + money +
|
||||
", price=" + price +
|
||||
", paymentTime=" + paymentTime +
|
||||
", deliveryTime=" + deliveryTime +
|
||||
", receiverTime=" + receiverTime +
|
||||
@@ -134,12 +134,12 @@ public class OrderDO extends DeletableDO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getMoney() {
|
||||
return money;
|
||||
public Integer getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public OrderDO setMoney(Integer money) {
|
||||
this.money = money;
|
||||
public OrderDO setPrice(Integer price) {
|
||||
this.price = price;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.mall.order.mock;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.product.api.ProductSpuService;
|
||||
import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO;
|
||||
import cn.iocoder.mall.product.api.bo.ProductSpuPageBO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductSpuAddDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductSpuPageDTO;
|
||||
import cn.iocoder.mall.product.api.dto.ProductSpuUpdateDTO;
|
||||
|
||||
/**
|
||||
* @author Sin
|
||||
* @time 2019-03-24 15:24
|
||||
*/
|
||||
public class ProductSpuServiceMock implements ProductSpuService {
|
||||
@Override
|
||||
public CommonResult<ProductSpuDetailBO> getProductSpu(Integer id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<ProductSpuDetailBO> addProductSpu(Integer adminId, ProductSpuAddDTO productSpuAddDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateProductSpu(Integer adminId, ProductSpuUpdateDTO productSpuUpdateDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateProductSpuSort(Integer adminId, Integer spuId, Integer sort) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<ProductSpuPageBO> getProductSpuPage(ProductSpuPageDTO productSpuPageDTO) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@ import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
|
||||
import cn.iocoder.mall.order.api.constant.OrderHasReturnExchangeEnum;
|
||||
import cn.iocoder.mall.order.api.constant.OrderStatusEnum;
|
||||
import cn.iocoder.mall.order.api.dto.*;
|
||||
import cn.iocoder.mall.order.convert.OrderConvert;
|
||||
import cn.iocoder.mall.order.convert.OrderItemConvert;
|
||||
import cn.iocoder.mall.order.convert.OrderLogisticsConvert;
|
||||
import cn.iocoder.mall.order.application.convert.OrderConvert;
|
||||
import cn.iocoder.mall.order.application.convert.OrderItemConvert;
|
||||
import cn.iocoder.mall.order.application.convert.OrderLogisticsConvert;
|
||||
import cn.iocoder.mall.order.dao.OrderItemMapper;
|
||||
import cn.iocoder.mall.order.dao.OrderLogisticsMapper;
|
||||
import cn.iocoder.mall.order.dao.OrderMapper;
|
||||
@@ -49,15 +49,12 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Override
|
||||
public CommonResult<List<OrderPageBO>> getOrderPage(OrderQueryDTO orderQueryDTO) {
|
||||
|
||||
int offset = orderQueryDTO.getPageNo() * orderQueryDTO.getPageSize();
|
||||
int pageSize = orderQueryDTO.getPageSize();
|
||||
|
||||
int totalCount = orderMapper.selectPageCount(orderQueryDTO);
|
||||
if (totalCount == 0) {
|
||||
return CommonResult.success(Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
List<OrderDO> orderDOList = orderMapper.selectPage(orderQueryDTO, offset, pageSize);
|
||||
List<OrderDO> orderDOList = orderMapper.selectPage(orderQueryDTO);
|
||||
List<OrderPageBO> orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList);
|
||||
return CommonResult.success(orderPageBOList);
|
||||
}
|
||||
@@ -69,6 +66,23 @@ public class OrderServiceImpl implements OrderService {
|
||||
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderCreateDTO);
|
||||
List<OrderItemDO> orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList);
|
||||
|
||||
// TODO: 2019-03-24 sin 校验商品是否存在
|
||||
// for (OrderItemDO orderItemDO : orderItemDOList) {
|
||||
// CommonResult<ProductSpuDetailBO> result = productSpuService.getProductSpu(orderItemDO.getSkuId());
|
||||
//
|
||||
// // 有任何商品获取失败,或者为 null,都直接返回失败。
|
||||
// if (result.isError()) {
|
||||
// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_SKU_FAIL.getCode());
|
||||
// }
|
||||
//
|
||||
// if (result.getData() == null) {
|
||||
// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_SKU_NOT_EXISTENT.getCode());
|
||||
// }
|
||||
//
|
||||
// ProductSpuDetailBO spuDetailBO = result.getData();
|
||||
// orderItemDO.setPrice(1000);
|
||||
// }
|
||||
|
||||
// 物流信息
|
||||
orderLogisticsDO
|
||||
.setLogisticsNo("")
|
||||
@@ -81,7 +95,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
.setUserId(userId)
|
||||
.setOrderLogisticsId(orderLogisticsDO.getId())
|
||||
.setOrderNo(UUID.randomUUID().toString().replace("-", ""))
|
||||
.setMoney(-1) // 先设置一个默认值,金额在下面计算
|
||||
.setPrice(-1) // 先设置一个默认值,金额在下面计算
|
||||
.setClosingTime(null)
|
||||
.setDeliveryTime(null)
|
||||
.setPaymentTime(null)
|
||||
@@ -119,7 +133,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderMapper.updateById(
|
||||
new OrderDO()
|
||||
.setId(orderDO.getId())
|
||||
.setMoney(totalAmount)
|
||||
.setPrice(totalAmount)
|
||||
);
|
||||
|
||||
// TODO: 2019-03-17 Sin 需要发送 创建成果 MQ 消息
|
||||
@@ -128,7 +142,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
new OrderBO()
|
||||
.setId(orderDO.getId())
|
||||
.setOrderNo(orderDO.getOrderNo())
|
||||
.setMoney(orderDO.getMoney())
|
||||
.setMoney(orderDO.getPrice())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,6 +150,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
public CommonResult updateOrderItem(OrderItemUpdateDTO orderUpdateDTO) {
|
||||
OrderItemDO orderItemDO = OrderItemConvert.INSTANCE.convert(orderUpdateDTO);
|
||||
orderItemMapper.updateById(orderItemDO);
|
||||
|
||||
// TODO: 2019-03-24 sin 需要重新计算金额
|
||||
// TODO: 2019-03-24 sin 需要记录日志
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@@ -169,7 +186,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderMapper.updateById(
|
||||
new OrderDO()
|
||||
.setId(orderId)
|
||||
.setMoney(totalAmount)
|
||||
.setPrice(totalAmount)
|
||||
);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<mapper namespace="cn.iocoder.mall.order.dao.OrderMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, user_id, order_logistics_id, order_no, money, payment_time,
|
||||
id, user_id, order_logistics_id, order_no, price, payment_time,
|
||||
delivery_time, receiver_time, closing_time, has_return_exchange,
|
||||
status, remark, create_time, update_time, `deleted`
|
||||
</sql>
|
||||
@@ -13,12 +13,12 @@
|
||||
-->
|
||||
<insert id="insert" parameterType="OrderDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO `order` (
|
||||
user_id, order_logistics_id, order_no, money, payment_time,
|
||||
user_id, order_logistics_id, order_no, price, payment_time,
|
||||
delivery_time, receiver_time, closing_time,
|
||||
has_return_exchange, status, remark,
|
||||
create_time, update_time, `deleted`
|
||||
) VALUES (
|
||||
#{orderLogisticsId}, #{userId}, #{orderNo}, #{money}, #{paymentTime},
|
||||
#{orderLogisticsId}, #{userId}, #{orderNo}, #{price}, #{paymentTime},
|
||||
#{deliveryTime}, #{receiverTime}, #{closingTime},
|
||||
#{hasReturnExchange}, #{status}, #{remark},
|
||||
#{createTime}, #{updateTime}, #{deleted}
|
||||
@@ -36,8 +36,8 @@
|
||||
<if test="orderNo != null">
|
||||
, order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="money != null">
|
||||
, money = #{money}
|
||||
<if test="price != null">
|
||||
, price = #{price}
|
||||
</if>
|
||||
-- time
|
||||
<if test="paymentTime != null">
|
||||
@@ -97,22 +97,22 @@
|
||||
查询条件
|
||||
-->
|
||||
<sql id="selectWhere">
|
||||
<if test="id">
|
||||
<if test="id != null">
|
||||
AND `id` = #{id}
|
||||
</if>
|
||||
<if test="userId">
|
||||
<if test="userId != null">
|
||||
AND `user_id` = #{userId}
|
||||
</if>
|
||||
<if test="orderLogisticsId">
|
||||
<if test="orderLogisticsId != null">
|
||||
AND `order_logistics_id` = #{orderLogisticsId}
|
||||
</if>
|
||||
<if test="orderNo">
|
||||
<if test="orderNo != null">
|
||||
AND `order_no` = #{orderNo}
|
||||
</if>
|
||||
<if test="hasReturnExchange">
|
||||
<if test="hasReturnExchange != null">
|
||||
AND `has_return_exchange` = #{hasReturnExchange}
|
||||
</if>
|
||||
<if test="status">
|
||||
<if test="status != null">
|
||||
AND `status` = #{status}
|
||||
</if>
|
||||
</sql>
|
||||
@@ -124,7 +124,7 @@
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM `order`
|
||||
WHERE
|
||||
WHERE 1 = 1
|
||||
<include refid="selectWhere" />
|
||||
</select>
|
||||
|
||||
@@ -135,9 +135,9 @@
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM `order`
|
||||
WHERE
|
||||
WHERE 1 = 1
|
||||
<include refid="selectWhere" />
|
||||
LIMIT
|
||||
LIMIT ${pageNo * pageSize}, ${pageSize}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user