diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java index 86191e013..3e8c40e81 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java @@ -2,7 +2,9 @@ package com.youlai.mall.oms.pojo.bo.app; import com.youlai.mall.oms.pojo.domain.OmsOrder; import com.youlai.mall.oms.pojo.domain.OmsOrderItem; +import com.youlai.mall.ums.pojo.dto.MemberDTO; import lombok.Data; +import lombok.experimental.Accessors; import java.util.List; @@ -13,10 +15,13 @@ import java.util.List; * @date 2021/1/19 */ @Data +@Accessors(chain = true) public class OrderBO { private OmsOrder order; private List orderItems; + private MemberDTO member; + } diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderItemDTO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderItemDTO.java index 2a507f099..53af08cb4 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderItemDTO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderItemDTO.java @@ -13,8 +13,9 @@ import lombok.*; public class OrderItemDTO extends BaseVO { private Long skuId; + private String skuName; + private String skuCode; private Integer count; private String pic; - private String title; private Long price; } diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartVO.java index 92d9b679e..a49fdfc6a 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartVO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartVO.java @@ -22,7 +22,9 @@ public class CartVO implements Serializable { private Long skuId; - private String title; // 标题 + private String skuName; // 标题 + + private String skuCode; private String pic; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/RabbitMQConfig.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/RabbitMQConfig.java index 23936996f..29cd54221 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/RabbitMQConfig.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/RabbitMQConfig.java @@ -42,7 +42,7 @@ public class RabbitMQConfig { Map args = new HashMap<>(); args.put("x-dead-letter-exchange", "order.exchange"); args.put("x-dead-letter-routing-key", "order:close"); // 死信路由Key - args.put("x-message-ttl", 10000); // 单位:毫秒,1分钟测试使用 + args.put("x-message-ttl", 60000); // 单位:毫秒,1分钟测试使用 return new Queue("order.delay.queue", true, false, false, args); } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java new file mode 100644 index 000000000..91d6af328 --- /dev/null +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java @@ -0,0 +1,96 @@ +package com.youlai.mall.oms.controller.admin; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.youlai.common.result.Result; +import com.youlai.mall.oms.pojo.bo.app.OrderBO; +import com.youlai.mall.oms.pojo.domain.OmsOrder; +import com.youlai.mall.oms.pojo.domain.OmsOrderItem; +import com.youlai.mall.oms.service.IOrderItemService; +import com.youlai.mall.oms.service.IOrderService; +import com.youlai.mall.ums.api.UmsMemberFeignService; +import com.youlai.mall.ums.pojo.dto.MemberDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + + +/** + * @author huawei + * @email huawei_code@163.com + * @date 2020-12-30 22:31:10 + */ +@Api(tags = "【系统管理】订单服务") +@RestController("AdminOrderController") +@RequestMapping("/api.admin/v1/orders") +@Slf4j +@AllArgsConstructor +public class OrderController { + + private IOrderService orderService; + private IOrderItemService orderItemService; + private UmsMemberFeignService memberFeignService; + + @ApiOperation("订单列表") + @GetMapping + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", defaultValue = "1", value = "页码", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "limit", defaultValue = "10", value = "每页数量", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "status", value = "订单状态", paramType = "query", dataType = "Integer"), + + }) + public Result list( + @RequestParam(defaultValue = "1") Long page, + @RequestParam(defaultValue = "10") Long limit, + Integer status, + String startDate, + String endDate, + String orderSn + ) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .like(StrUtil.isNotBlank(orderSn), OmsOrder::getOrderSn, orderSn) + .eq(status != null, OmsOrder::getStatus, status) + .apply(StrUtil.isNotBlank(startDate), + "date_format (gmt_crate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')") + .apply(StrUtil.isNotBlank(endDate), + "date_format (gmt_crate,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d')") + .orderByDesc(OmsOrder::getGmtModified) + .orderByDesc(OmsOrder::getGmtCreate); + + IPage result = orderService.list(new Page<>(page, limit), new OmsOrder().setStatus(status)); + return Result.success(result.getRecords(), result.getTotal()); + } + + + @ApiOperation(value = "订单详情", httpMethod = "GET") + @ApiImplicitParam(name = "id", value = "订单id", required = true, paramType = "path", dataType = "Long") + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + OrderBO orderBO = new OrderBO(); + // 订单 + OmsOrder order = orderService.getById(id); + + // 订单明细 + List orderItems = orderItemService.list( + new LambdaQueryWrapper().eq(OmsOrderItem::getOrderId, id) + ); + orderItems = Optional.ofNullable(orderItems).orElse(new ArrayList<>()); + + // 会员明细 + Result result = memberFeignService.getUserById(order.getMemberId()); + MemberDTO member = result.getData(); + orderBO.setOrder(order).setOrderItems(orderItems).setMember(member); + return Result.success(orderBO); + } + +} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/test/app/CartController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java similarity index 98% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/test/app/CartController.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java index 13d1005ec..35e19d2b9 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/test/app/CartController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.test.app; +package com.youlai.mall.oms.controller.app; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.youlai.common.result.Result; @@ -44,7 +44,6 @@ public class CartController { - @ApiOperation(value = "添加购物车商品") @ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long") @PostMapping diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/test/app/OrderController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java similarity index 98% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/test/app/OrderController.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java index 75eb98284..26e9902b5 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/test/app/OrderController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.test.app; +package com.youlai.mall.oms.controller.app; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java index 77b210e54..262ad9cd4 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java @@ -18,7 +18,7 @@ public interface OrderMapper extends BaseMapper { @Select("