From 905d21999c2644789deb4c0aa5bfc0b87ea676e7 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Wed, 17 Mar 2021 20:18:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=AE=A2=E5=8D=95=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/oms/pojo/domain/OmsOrderItem.java | 2 +- .../mall/oms/pojo/dto/OrderConfirmDTO.java | 21 ++ .../mall/oms/pojo/dto/OrderSubmitDTO.java | 9 +- .../mall/oms/pojo/dto/ResultPayDTO.java | 21 -- .../youlai/mall/oms/pojo/vo/CartItemVO.java | 42 ---- .../com/youlai/mall/oms/pojo/vo/CartVO.java | 40 +-- .../com/youlai/mall/oms/pojo/vo/CouponVO.java | 18 -- .../youlai/mall/oms/pojo/vo/OrderItemVO.java | 7 +- .../youlai/mall/oms/pojo/vo/OrderListVO.java | 2 +- ...SubmitResultVO.java => OrderSubmitVO.java} | 2 +- .../com/youlai/mall/oms/OmsApplication.java | 8 +- .../mall/oms/config/RabbitMQConfig.java | 18 +- .../mall/oms/config/ThreadPoolConfig.java | 21 ++ .../mall/oms/config/thread/AsyncConfig.java | 42 ---- .../config/thread/ThreadPoolProperties.java | 23 -- .../mall/oms/config/token/TokenVerify.java | 31 --- .../oms/config/token/TokenVerifyHandler.java | 45 ---- .../mall/oms/constant/OmsConstants.java | 5 +- .../oms/controller/app/CartController.java | 36 ++- .../oms/controller/app/OrderController.java | 47 ++-- ...mentController.java => PayController.java} | 4 +- .../mall/oms/listener/RabbitMQListener.java | 6 +- .../OrderDeliveryMapper.java} | 4 +- .../OrderItemMapper.java} | 4 +- .../OrderLogMapper.java} | 4 +- .../OrderDao.java => mapper/OrderMapper.java} | 4 +- .../OrderPayMapper.java} | 4 +- .../OrderSettingMapper.java} | 4 +- .../youlai/mall/oms/service/ICartService.java | 44 +--- .../mall/oms/service/IOrderService.java | 31 +-- .../youlai/mall/oms/service/TokenService.java | 25 -- .../oms/service/impl/CartServiceImpl.java | 230 ++++++++++-------- .../impl/OrderDeliveryServiceImpl.java | 4 +- .../service/impl/OrderItemServiceImpl.java | 4 +- .../oms/service/impl/OrderLogServiceImpl.java | 4 +- .../oms/service/impl/OrderPayServiceImpl.java | 14 +- .../oms/service/impl/OrderServiceImpl.java | 106 +++++--- .../service/impl/OrderSettingServiceImpl.java | 4 +- .../oms/service/impl/TokenServiceImpl.java | 74 ------ .../main/resources/mapper/oms/OrderDao.xml | 31 --- .../resources/mapper/oms/OrderDeliveryDao.xml | 29 --- .../resources/mapper/oms/OrderGoodsDao.xml | 30 --- .../resources/mapper/oms/OrderLogsDao.xml | 20 -- .../main/resources/mapper/oms/OrderPayDao.xml | 25 -- .../resources/mapper/oms/OrderSettingDao.xml | 21 -- ...gnService.java => PmsSkuFeignService.java} | 5 +- .../youlai/mall/pms/pojo/domain/PmsSku.java | 2 +- .../com/youlai/mall/pms/pojo/dto/SkuDTO.java | 16 +- .../youlai/mall/pms/pojo/vo/OrderItemVO.java | 2 +- .../pms/controller/app/SkuController.java | 6 +- .../ums/api/admin/MemberFeignService.java | 18 -- .../ums/api/app/UmsAddressFeignService.java | 28 +++ ...ervice.java => UmsMemberFeignService.java} | 30 +-- .../domain/{UmsUser.java => UmsMember.java} | 2 +- .../mall/ums/pojo/dto/UmsAddressDTO.java | 33 --- ...rController.java => MemberController.java} | 33 ++- .../controller/admin/RechargeController.java | 4 +- ...rController.java => MemberController.java} | 34 +-- .../youlai/mall/ums/mapper/UmsUserMapper.java | 6 +- .../mall/ums/service/IUmsUserService.java | 6 +- .../ums/service/impl/UmsUserServiceImpl.java | 8 +- .../java/com/youlai/auth/AuthApplication.java | 4 +- .../auth/controller/AuthController.java | 9 +- .../auth/service/UserDetailsServiceImpl.java | 4 +- 64 files changed, 452 insertions(+), 968 deletions(-) create mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderConfirmDTO.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/ResultPayDTO.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVO.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/{OrderSubmitResultVO.java => OrderSubmitVO.java} (86%) create mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/AsyncConfig.java delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/ThreadPoolProperties.java delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerify.java delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerifyHandler.java rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/{PaymentController.java => PayController.java} (97%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/{dao/OrderDeliveryDao.java => mapper/OrderDeliveryMapper.java} (71%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/{dao/OrderItemDao.java => mapper/OrderItemMapper.java} (72%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/{dao/OrderLogDao.java => mapper/OrderLogMapper.java} (73%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/{dao/OrderDao.java => mapper/OrderMapper.java} (73%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/{dao/OrderPayDao.java => mapper/OrderPayMapper.java} (72%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/{dao/OrderSettingDao.java => mapper/OrderSettingMapper.java} (71%) delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/TokenService.java delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/TokenServiceImpl.java delete mode 100644 mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDao.xml delete mode 100644 mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDeliveryDao.xml delete mode 100644 mall-oms/oms-boot/src/main/resources/mapper/oms/OrderGoodsDao.xml delete mode 100644 mall-oms/oms-boot/src/main/resources/mapper/oms/OrderLogsDao.xml delete mode 100644 mall-oms/oms-boot/src/main/resources/mapper/oms/OrderPayDao.xml delete mode 100644 mall-oms/oms-boot/src/main/resources/mapper/oms/OrderSettingDao.xml rename mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/{InventoryFeignService.java => PmsSkuFeignService.java} (88%) delete mode 100644 mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/admin/MemberFeignService.java create mode 100644 mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsAddressFeignService.java rename mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/{MemberFeignService.java => UmsMemberFeignService.java} (58%) rename mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/{UmsUser.java => UmsMember.java} (95%) delete mode 100644 mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java rename mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/{UserController.java => MemberController.java} (79%) rename mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/{UserController.java => MemberController.java} (82%) diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java index b81cd228e..744f4e6df 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java @@ -39,7 +39,7 @@ public class OmsOrderItem extends BaseEntity { /** * 商品sku名字 */ - private String skuName; + private String title; /** * 商品sku图片 */ diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderConfirmDTO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderConfirmDTO.java new file mode 100644 index 000000000..58b78cbe0 --- /dev/null +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderConfirmDTO.java @@ -0,0 +1,21 @@ +package com.youlai.mall.oms.pojo.dto; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * @author huawei + * @desc 订单提交实体类 + * @email huawei_code@163.com + * @date 2021/1/16 + */ +@Data +public class OrderConfirmDTO { + + private Long skuId; + + private Integer count; + +} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitDTO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitDTO.java index 2883dd9a9..8b529e4e2 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitDTO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitDTO.java @@ -1,22 +1,25 @@ package com.youlai.mall.oms.pojo.dto; +import com.youlai.mall.oms.pojo.vo.OrderItemVO; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; +import java.util.List; /** * @author huawei - * @desc 订单提交实体类 + * @desc 订单提交 * @email huawei_code@163.com * @date 2021/1/16 */ @Data public class OrderSubmitDTO { - private Long skuId; + // 提交订单确认页面签发的令牌 + private String orderToken; - private Integer skuNum; + private List orderItems; private Long payAmount; diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/ResultPayDTO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/ResultPayDTO.java deleted file mode 100644 index e7b6602a7..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/ResultPayDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.youlai.mall.oms.pojo.dto; - -import lombok.Data; - -/** - * 支付结果回调接收类 - */ -@Data -public class ResultPayDTO { - - private String code; - private String msg; - private String otherinfo; - private String orderId; - private String price; - private String name; - private String thirduid; - private String paytype; - private String remarks; - private String originalprice; -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVO.java deleted file mode 100644 index e45e4647d..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.youlai.mall.oms.pojo.vo; - - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 购物车项目项实体类 - */ -@NoArgsConstructor -@AllArgsConstructor -@ToString -@Data -@Accessors(chain = true) -public class CartItemVO implements Serializable { - - private Long skuId; - - private String skuPic; - - private String skuName; - - private Integer inventory; - - private Integer count; - - private Long price; - - private Long coupon; - - private Long subtotal; - - private boolean hasInventory; - - private boolean checked; - -} 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 3b7cf5b2f..2df868507 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 @@ -12,45 +12,27 @@ import java.util.List; @AllArgsConstructor @ToString @Builder +@Data public class CartVO implements Serializable { - private List items; + private List items; - private Integer totalNum; + @Data + public static class CartItem { - private Long totalPrice; + private Long skuId; - private Long totalCoupon; + private String title; // 标题 - public List getItems() { - return items; - } + private String pic; - public void setItems(List items) { - this.items = items; - } + private Integer count; - public Integer getTotalNum() { - int total = 0; - if (items != null && items.size() > 0) { - total = items.stream().filter(CartItemVO::isChecked).mapToInt(CartItemVO::getNum).sum(); - } - return total; - } + private Long price; - public void setTotalNum(Integer totalNum) { - this.totalNum = totalNum; - } + private Long coupon; - public Long getTotalPrice() { - long total = 0L; - if (items != null && items.size() > 0) { - total = items.stream().filter(CartItemVO::isChecked).mapToLong(CartItemVO::getSubtotal).sum(); - } - return total; - } + private boolean checked; - public void setTotalPrice(Long totalPrice) { - this.totalPrice = totalPrice; } } diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java deleted file mode 100644 index 59ef8c7ba..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.youlai.mall.oms.pojo.vo; - -import com.youlai.common.base.BaseVO; -import lombok.Data; - -/** - * @author huawei - * @desc 优惠券信息 - * @email huawei_code@163.com - * @date 2021/1/13 - */ -@Data -public class CouponVO extends BaseVO { - - private String title; - - private Long price; -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderItemVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderItemVO.java index 733acb86f..c8dad4db2 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderItemVO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderItemVO.java @@ -14,11 +14,8 @@ import lombok.Setter; public class OrderItemVO extends BaseVO { private Long skuId; - private String skuImg; - private String skuName; private Integer count; + private String skuPic; + private String title; private Long price; - private Long coupon; - - } diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderListVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderListVO.java index d8f086810..d7b737f96 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderListVO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderListVO.java @@ -53,7 +53,7 @@ public class OrderListVO extends BaseVO { private String skuPic; private Integer skuQuantity; private Long skuTotalPrice; - private String skuName; + private String title; private Long price; private String image; private Integer number; diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitResultVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java similarity index 86% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitResultVO.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java index bd63fce5f..0cf8f4a3a 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitResultVO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java @@ -10,7 +10,7 @@ import lombok.Data; * @date 2021/1/21 */ @Data -public class OrderSubmitResultVO extends BaseVO { +public class OrderSubmitVO extends BaseVO { /** * 订单ID */ diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java index 122ac2279..70a4cb821 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java @@ -1,9 +1,8 @@ package com.youlai.mall.oms; -import com.youlai.mall.pms.api.app.InventoryFeignService; -import com.youlai.mall.ums.api.app.MemberFeignService; -import org.mybatis.spring.annotation.MapperScan; +import com.youlai.mall.pms.api.app.PmsSkuFeignService; +import com.youlai.mall.ums.api.app.UmsMemberFeignService; import org.springframework.amqp.rabbit.annotation.EnableRabbit; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -13,8 +12,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) @EnableDiscoveryClient -@EnableFeignClients(basePackageClasses = { MemberFeignService.class, InventoryFeignService.class}) -@MapperScan({ "com.youlai.mall.oms.mapper","com.youlai.mall.oms.dao"}) +@EnableFeignClients(basePackageClasses = { UmsMemberFeignService.class, PmsSkuFeignService.class}) @EnableRabbit public class OmsApplication { 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 de183bcdf..7c0e70e8b 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 @@ -1,10 +1,8 @@ package com.youlai.mall.oms.config; -import com.youlai.mall.oms.constant.OmsConstants; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.*; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -15,8 +13,7 @@ import java.util.Map; * @author huawei * @email huawei_code@163.com * @date 2021/1/17 - * @desc rabbitmq 业务相关配置类 - * 订单相关业务统一使用 order-event-exchange 交换机 + * @desc 业务描述 * 1. 订单创建成功,发送消息到创建订单的路由 * 2. 创建订单的路由转发消息给延时队列,延时队列的延时时间就是订单从创建到支付过程,允许的最大等待时间。延时队列不能有消费者(即消息不能被消费) * 3. 延时时间一到,消息被转入DLX(死信路由) @@ -28,16 +25,13 @@ import java.util.Map; @AllArgsConstructor public class RabbitMQConfig { - private RabbitTemplate rabbitTemplate; - /** - * 定义交换机 + * 定义交换机,订单业务统一使用 order-exchange 交换机 */ @Bean public Exchange exchange() { - return new TopicExchange("order_event_exchange", true, false); + return new TopicExchange("order-exchange", true, false); } - /** * 延时队列 */ @@ -45,7 +39,7 @@ public class RabbitMQConfig { public Queue delayQueue() { // 延时队列的消息过期了,会自动触发消息的转发,根据routingKey发送到指定的exchange中,exchange路由到死信队列 Map args = new HashMap<>(); - args.put("x-dead-letter-exchange", "order_event_exchange"); + args.put("x-dead-letter-exchange", "order-exchange"); args.put("x-dead-letter-routing-key", "order:close"); // 死信路由Key args.put("x-message-ttl", 60000); // 单位:毫秒,配置1分钟测试使用 return new Queue("order.delay.queue", true, false, false, args); @@ -58,7 +52,7 @@ public class RabbitMQConfig { */ @Bean public Binding delayQueueBinding() { - return new Binding("order.delay.queue", Binding.DestinationType.QUEUE,"order_event_exchange","order.create",null); + return new Binding("order.delay.queue", Binding.DestinationType.QUEUE,"order-exchange","order.create",null); } /** @@ -75,7 +69,7 @@ public class RabbitMQConfig { */ @Bean public Binding closeOrderQueueBinding() { - return new Binding("order.close.queue", Binding.DestinationType.QUEUE,"order_event_exchange","order:close",null); + return new Binding("order.close.queue", Binding.DestinationType.QUEUE,"order-exchange","order:close",null); } } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java new file mode 100644 index 000000000..042c1b484 --- /dev/null +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java @@ -0,0 +1,21 @@ +package com.youlai.mall.oms.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + + +/** + * 线程池配置 + */ +@Configuration +public class ThreadPoolConfig { + + @Bean + public ThreadPoolExecutor threadPoolExecutor() { + return new ThreadPoolExecutor(50,500,30, TimeUnit.SECONDS,new ArrayBlockingQueue<>(10000)); + } +} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/AsyncConfig.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/AsyncConfig.java deleted file mode 100644 index 1f919a7f9..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/AsyncConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -//package com.youlai.mall.oms.config.thread; -// -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -//import org.springframework.core.task.AsyncTaskExecutor; -//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -// -//import java.util.concurrent.ThreadPoolExecutor; -// -///** -// * @author huawei -// * @desc 异步任务线程配置 -// * @email huawei_code@163.com -// * @date 2021/1/16 -// */ -//@Configuration -//@Slf4j -//public class AsyncConfig { -// -// @Bean("asyncTaskExecutor") -// public AsyncTaskExecutor asyncTaskExecutor(ThreadPoolProperties properties) { -// log.info("loading asyncTaskExecutor ..."); -// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); -// //配置核心线程数 -// executor.setCorePoolSize(properties.getCorePoolSize()); -// //配置最大线程数 -// executor.setMaxPoolSize(properties.getMaxPoolSize()); -// //配置队列大小 -// executor.setQueueCapacity(properties.getQueueCapacity()); -// executor.setKeepAliveSeconds(properties.getKeepAliveSeconds()); -// //配置线程池中的线程的名称前缀 -// executor.setThreadNamePrefix("async-service-"); -// -// // 设置拒绝策略:当pool已经达到max size的时候,如何处理新任务 -// // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行 -// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); -// //执行初始化 -// executor.initialize(); -// return executor; -// } -//} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/ThreadPoolProperties.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/ThreadPoolProperties.java deleted file mode 100644 index 8bd7fff92..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/thread/ThreadPoolProperties.java +++ /dev/null @@ -1,23 +0,0 @@ -//package com.youlai.mall.oms.config.thread; -// -//import lombok.Data; -//import org.springframework.boot.context.properties.ConfigurationProperties; -// -///** -// * @author huawei -// * @desc 线程池配置属性类 -// * @email huawei_code@163.com -// * @date 2021/1/16 -// */ -//@Data -//@ConfigurationProperties(prefix = "task.pool") -//public class ThreadPoolProperties { -// -// private Integer corePoolSize; -// -// private Integer maxPoolSize; -// -// private Integer queueCapacity; -// -// private Integer keepAliveSeconds; -//} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerify.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerify.java deleted file mode 100644 index 003c3b26d..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerify.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.youlai.mall.oms.config.token; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author huawei - * @desc Token 幂等性校验接口注解 - * 幂等性方案:注解 + 拦截器 - * 注解:@TokenVerify 注解,该注解有两个属性,generate 和 clean - * generate:属性为true是表示请求该方法会生成一个uuid token,同时放入redis中和用户请求中,用于用户下一次请求校验,默认为false - * clean:如果属性为true表示请求该方法需要校验token唯一性,并且在校验通过后清除redis中的token - * 拦截器:TokenVerifyHandler - * 实现原理:拦截所有的请求,如果该请求被 @TokenVerify 注解标识:首先判断该注解属性 generate 是否为true,然后校验属性 clean 是否为true - * 最后,在 WebMvcConfig 配置中配置拦截器 - * @email huawei_code@163.com - * @date 2021/1/21 - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface TokenVerify { - - // 是否生成校验token - boolean generate() default false; - - // 是否校验token - boolean verify() default false; - -} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerifyHandler.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerifyHandler.java deleted file mode 100644 index f9d5c5df5..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/token/TokenVerifyHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.youlai.mall.oms.config.token; - -import com.youlai.mall.oms.service.TokenService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author huawei - * @desc - * @email huawei_code@163.com - * @date 2021/1/21 - */ -@Component -@AllArgsConstructor -@Slf4j -public class TokenVerifyHandler extends HandlerInterceptorAdapter { - - @Autowired - private TokenService tokenService; - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - if (!(handler instanceof HandlerMethod)) { - return true; - } - - HandlerMethod method = (HandlerMethod) handler; - TokenVerify tokenVerify = method.getMethodAnnotation(TokenVerify.class); - if (tokenVerify != null) { - log.debug("请求:{} 使用 @TokenVerify 注解,被拦截器拦截", request.getRequestURI()); - // 校验token,判断是否重复提交 - tokenService.checkToken(request); - } - return true; - } - - -} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java index dc56fe4dd..8c72a4cb2 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java @@ -5,11 +5,10 @@ package com.youlai.mall.oms.constant; * @date 2021-03-16 */ public interface OmsConstants { - Long REDIS_KEY_TIME_OUT = 3600 * 24L; - String CART_KEY = "cart:"; + String CART_PREFIX = "mall:cart:"; - String TOKEN_VERIFY = "token_verify:"; + String ORDER_TOKEN_PREFIX = "mall:order:token:"; String BUSINESS_NO_PREFIX = "businessno:"; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java index 61e4de898..15bd6d404 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/CartController.java @@ -11,8 +11,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; /** - * 购物车 - * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 @@ -27,9 +25,9 @@ public class CartController { private ICartService cartService; - @ApiOperation(value = "查询购物车", httpMethod = "GET") + @ApiOperation(value = "查询用户购物车", httpMethod = "GET") @GetMapping - public Result getCart() { + public Result get() { CartVO cart = cartService.getCart(); return Result.success(cart); } @@ -42,37 +40,33 @@ public class CartController { return Result.success(); } - @ApiOperation(value = "局部更新购物车商品", httpMethod = "PUT") + @ApiOperation(value = "更新购物车商品", httpMethod = "PUT") @PutMapping("/skuId/{skuId}") - public Result updateCartItem( - @PathVariable Long skuId, - Integer num, - Boolean checked - ) { - cartService.updateCartItem(skuId, num, checked); - return Result.success(); + public Result updateCartItem(@RequestBody CartVO.CartItem cartItem) { + boolean result = cartService.updateCartItem(cartItem); + return Result.judge(result); } @ApiOperation(value = "全选/全不选择购物车商品", httpMethod = "PUT") @ApiImplicitParam(name = "checked", value = "全选/全不选", required = true, paramType = "param", dataType = "Boolean") @PatchMapping("/batch") - public Result checkAll(Boolean checked) { - cartService.checkAll(checked); - return Result.success(); + public Result checkAll(boolean checked) { + boolean result = cartService.checkAll(checked); + return Result.judge(result); } @ApiOperation(value = "删除购物车商品", httpMethod = "DELETE") - @ApiImplicitParam(name = "skuId", value = "SKU ID集合", required = true, paramType = "param", dataType = "Long") + @ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long") @DeleteMapping("/skuId/{skuId}") - public Result deleteCartItem(@PathVariable Long skuId) { - cartService.deleteCartItem(skuId); - return Result.success(); + public Result removeCartItem(@PathVariable Long skuId) { + boolean result = cartService.removeCartItem(skuId); + return Result.judge(result); } @ApiOperation(value = "清空购物车", httpMethod = "DELETE") @DeleteMapping public Result deleteCart() { - cartService.deleteCart(); - return Result.success(); + boolean result = cartService.deleteCart(); + return Result.judge(result); } } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java index 1ff28f6b4..a695936c9 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java @@ -1,9 +1,10 @@ package com.youlai.mall.oms.controller.app; import com.youlai.common.result.Result; +import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO; import com.youlai.mall.oms.pojo.vo.OrderConfirmVO; import com.youlai.mall.oms.pojo.vo.OrderListVO; -import com.youlai.mall.oms.pojo.vo.OrderSubmitResultVO; +import com.youlai.mall.oms.pojo.vo.OrderSubmitVO; import com.youlai.mall.oms.pojo.dto.OrderSubmitDTO; import com.youlai.mall.oms.service.IOrderService; import io.swagger.annotations.*; @@ -29,42 +30,22 @@ public class OrderController { private IOrderService orderService; - /** - * 订单确认信息,生成订单 - * 如果入参传了skuId,则以当前skuId为准,商品数量默认为1 - * 如果没有传,则从购物车中获取数据 - * 如果购物车中没有数据,则返回为空 - */ - @ApiOperation(value = "订单确认信息", httpMethod = "POST") - @ApiImplicitParams({ - @ApiImplicitParam(name = "skuId", value = "商品ID", required = true, paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "num", value = "商品数量", required = true, defaultValue = "1", paramType = "query", dataType = "Integer") - - }) + @ApiOperation(value = "确认订单", httpMethod = "POST") + @ApiImplicitParam(name = "orderConfirm",value = "确认订单信息",required = true, paramType = "body", dataType = "OrderConfirmDTO") @PostMapping("/_confirm") - public Result confirm( - Long skuId, - Integer num - ) { - OrderConfirmVO confirm = orderService.confirm(skuId, num); - return Result.success(confirm); - } - - @ApiOperation(value = "提交订单", httpMethod = "POST") - @ApiImplicitParam(name = "orderSubmitInfoDTO", value = "提交订单信息", required = true, paramType = "body", dataType = "OrderSubmitInfoDTO") - @PostMapping("/_submit") - public Result submit(@Valid @RequestBody OrderSubmitDTO orderSubmitDTO) { - OrderSubmitResultVO result = orderService.submit(orderSubmitDTO); + public Result confirm(@RequestBody OrderConfirmDTO orderConfirm) { + OrderConfirmVO result = orderService.confirm(orderConfirm); + return Result.success(result); + } + + @ApiOperation(value = "提交订单", httpMethod = "POST") + @ApiImplicitParam(name = "orderSubmitDTO", value = "提交订单信息", required = true, paramType = "body", dataType = "orderSubmitDTO") + @PostMapping("/_submit") + public Result submit(@Valid @RequestBody OrderSubmitDTO orderSubmitDTO) { + OrderSubmitVO result = orderService.submit(orderSubmitDTO); return Result.success(result); } - /** - * 根据订单状态查询订单列表 - * 步骤: - * 1、入参 status 表示订单状态 - * 2、status = 0 表示查询所有订单 - * 3、已删除订单无法查询 - */ @ApiOperation("订单列表查询") @GetMapping("/list") public Result> list( diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/PaymentController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/PayController.java similarity index 97% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/PaymentController.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/PayController.java index 6d0383a80..be4f62378 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/PaymentController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/PayController.java @@ -15,8 +15,6 @@ import org.springframework.web.bind.annotation.*; /** - * 订单支付服务 - * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 @@ -26,7 +24,7 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/api.app/v1/payments") @Slf4j @AllArgsConstructor -public class PaymentController { +public class PayController { private IOrderPayService orderPayService; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java index f8dc15f9d..45df3fb8f 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/listener/RabbitMQListener.java @@ -4,7 +4,7 @@ import com.rabbitmq.client.Channel; 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.pms.api.app.InventoryFeignService; +import com.youlai.mall.pms.api.app.PmsSkuFeignService; import com.youlai.mall.pms.pojo.dto.InventoryDTO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -23,7 +23,7 @@ import java.util.stream.Collectors; * @date 2021-03-16 */ -//@Component +@Component @AllArgsConstructor @Slf4j public class RabbitMQListener { @@ -32,7 +32,7 @@ public class RabbitMQListener { IOrderItemService orderItemService; - InventoryFeignService inventoryFeignService; + PmsSkuFeignService inventoryFeignService; RabbitTemplate rabbitTemplate; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderDeliveryDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderDeliveryMapper.java similarity index 71% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderDeliveryDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderDeliveryMapper.java index 965e221d2..f5b7e7c39 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderDeliveryDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderDeliveryMapper.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.dao; +package com.youlai.mall.oms.mapper; import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderDeliveryDao extends BaseMapper { +public interface OrderDeliveryMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderItemDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderItemMapper.java similarity index 72% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderItemDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderItemMapper.java index d0b894d2c..ac8d6182c 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderItemDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderItemMapper.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.dao; +package com.youlai.mall.oms.mapper; import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderItemDao extends BaseMapper { +public interface OrderItemMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderLogMapper.java similarity index 73% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderLogMapper.java index 16961e67a..a664dcc8f 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderLogMapper.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.dao; +package com.youlai.mall.oms.mapper; import com.youlai.mall.oms.pojo.domain.OmsOrderLog; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderLogDao extends BaseMapper { +public interface OrderLogMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java similarity index 73% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java index 4de966cd4..e65cfa092 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderMapper.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.dao; +package com.youlai.mall.oms.mapper; import com.youlai.mall.oms.pojo.domain.OmsOrder; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderDao extends BaseMapper { +public interface OrderMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderPayDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderPayMapper.java similarity index 72% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderPayDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderPayMapper.java index de19a1c86..c735da119 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderPayDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderPayMapper.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.dao; +package com.youlai.mall.oms.mapper; import com.youlai.mall.oms.pojo.domain.OmsOrderPay; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderPayDao extends BaseMapper { +public interface OrderPayMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderSettingDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderSettingMapper.java similarity index 71% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderSettingDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderSettingMapper.java index a7f2688c3..126aa604c 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderSettingDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OrderSettingMapper.java @@ -1,4 +1,4 @@ -package com.youlai.mall.oms.dao; +package com.youlai.mall.oms.mapper; import com.youlai.mall.oms.pojo.domain.OmsOrderSetting; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderSettingDao extends BaseMapper { +public interface OrderSettingMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/ICartService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/ICartService.java index 32939bdb2..d8d3731e9 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/ICartService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/ICartService.java @@ -2,46 +2,28 @@ package com.youlai.mall.oms.service; import com.youlai.mall.oms.pojo.vo.CartVO; +import java.util.List; + /** * 购物车业务接口 */ public interface ICartService { - /** - * 添加商品到购物车 - */ - void addCartItem(Long skuId); - /** - * 修改购物车商品数量 - */ - void updateCartItem(Long skuId,Integer num,Boolean checked); - - - /** - * 全选/全不选购物车 - */ - void checkAll(Boolean checked); - - /** - * 批量删除购物车中的商品 - */ - void deleteCartItem(Long skuId); - - /** - * 查询购物车详情 - */ CartVO getCart(); - /** - * 清空购物车 - */ - void deleteCart(); + List getCartItems(); - /** - * 清空购物车中已选择商品 - */ - void deleteSelectedItem(); + boolean deleteCart(); + boolean addCartItem(Long skuId); + + boolean updateCartItem(CartVO.CartItem cartItem); + + boolean removeCartItem(Long skuId); + + boolean removeCheckedItem(); + + boolean checkAll(boolean checked); } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java index 4bb85fa2a..009c52bc3 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java @@ -3,9 +3,10 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; import com.youlai.mall.oms.pojo.domain.OmsOrder; +import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO; import com.youlai.mall.oms.pojo.vo.OrderConfirmVO; import com.youlai.mall.oms.pojo.vo.OrderListVO; -import com.youlai.mall.oms.pojo.vo.OrderSubmitResultVO; +import com.youlai.mall.oms.pojo.vo.OrderSubmitVO; import com.youlai.mall.oms.pojo.dto.OrderSubmitDTO; import java.util.List; @@ -20,58 +21,40 @@ import java.util.List; public interface IOrderService extends IService { /** - * 订单确认页信息 - * - * @param skuId 商品id,非必填参数 - * @param num 商品数量 - * @return + * 订单确认 */ - OrderConfirmVO confirm(Long skuId, Integer num); + OrderConfirmVO confirm(OrderConfirmDTO orderConfirmDTO); /** * 提交订单 - * - * @param orderSubmitDTO 提交订单信息 */ - OrderSubmitResultVO submit(OrderSubmitDTO orderSubmitDTO) ; + OrderSubmitVO submit(OrderSubmitDTO orderSubmitDTO) ; + + /** * 系统关闭订单 - * - * @param orderSn 订单号 */ boolean closeOrder(Long orderId); /** * 取消订单接口 - * - * @param id 订单ID - * @return 是否取消成功 */ boolean cancelOrder(Long id); /** * 删除订单 - * - * @param id 订单ID - * @return 是否删除成功 */ boolean deleteOrder(Long id); /** * 订单列表查询 - * - * @param status 订单状态 - * @return 订单列表 */ List list(Integer status); /** * 根据订单ID获取订单信息 - * - * @param id 订单ID - * @return 订单信息 */ OmsOrder getByOrderId(Long id); } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/TokenService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/TokenService.java deleted file mode 100644 index e0e140dd5..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/TokenService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.youlai.mall.oms.service; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author huawei - * @desc - * @email huawei_code@163.com - * @date 2021/1/21 - */ -public interface TokenService { - - /** - * 为当前用户请求生成Token - * - * @return token - */ - String generateToken(); - - /** - * 校验 Token 是否正确 - * @param request 当前请求 - */ - void checkToken(HttpServletRequest request); -} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java index 74cdd9a0b..9f679332f 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java @@ -1,14 +1,12 @@ package com.youlai.mall.oms.service.impl; -import com.youlai.common.result.Result; import com.youlai.common.web.util.RequestUtils; -import com.youlai.mall.pms.api.app.InventoryFeignService; -import com.youlai.mall.pms.pojo.dto.SkuDTO; -import com.youlai.mall.oms.pojo.vo.CartItemVO; +import com.youlai.mall.oms.constant.OmsConstants; import com.youlai.mall.oms.pojo.vo.CartVO; import com.youlai.mall.oms.service.ICartService; +import com.youlai.mall.pms.api.app.PmsSkuFeignService; +import com.youlai.mall.pms.pojo.domain.PmsSku; import lombok.AllArgsConstructor; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.BoundHashOperations; import org.springframework.data.redis.core.RedisTemplate; @@ -17,133 +15,151 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.concurrent.CompletableFuture; -import static com.youlai.mall.oms.constant.OmsConstants.CART_KEY; - /** - * 购物车模块搭建步骤 - * 1、用户登录后才能操作购物车 - * *********添加购物车************* - * 1、获取当前登录用户 - * 2、添加商品到购物车 - * 2.1、如果购物车中已经有该商品的相关数据 - * 2.1.1、修改购物车商品数量 - * 2.2、如果购物车中没有该商品,新增该商品 - * 2.2.1、调用商品服务查询商品sku详情 - * 2.2.2、封装CartItem实体类 - * *********修改购物车************* - * *********删除购物车************* - * *********查询购物车************* + * 购物车模块 + *

+ * 技术点:BoundHashOperations + * 数据格式: + * -- key <----> 购物车 + * -- hKey:value <----> 购物车商品1 + * -- hKey:value <----> 购物车商品2 + * -- hKey:value <----> 购物车商品3 */ - @Service @Slf4j @AllArgsConstructor public class CartServiceImpl implements ICartService { private RedisTemplate redisTemplate; + private PmsSkuFeignService skuFeignService; - private InventoryFeignService inventoryFeignService; - - @Override - @SneakyThrows - public void addCartItem(Long skuId) { - BoundHashOperations cartHashOpts = getCartHashOpts(); - String hKey = skuId.toString(); // redis 的 hash key - if (cartHashOpts.get(hKey) != null) { - CartItemVO cartItem = (CartItemVO) cartHashOpts.get(hKey); - cartItem.setNum(cartItem.getNum() + 1); - cartItem.setSubtotal(cartItem.getPrice() * cartItem.getNum()); - cartHashOpts.put(hKey, cartItem); - return; - } - CartItemVO cartItem = new CartItemVO(); - CompletableFuture future = CompletableFuture.runAsync(() -> { - // 远程查询商品详情 - Result result = inventoryFeignService.getSkuById(skuId); - SkuDTO sku = result.getData(); - - cartItem.setSkuId(skuId) - .setChecked(true) - .setSkuName(sku.getName()) - .setSkuPic(sku.getPic()) - .setNum(1) - .setPrice(sku.getPrice()) - .setInventory(sku.getInventory()) - .setSubtotal(1 * sku.getPrice()); - }); - CompletableFuture allOf = CompletableFuture.allOf(future); - allOf.get(); - cartHashOpts.put(hKey, cartItem); - } - - @Override - public void updateCartItem(Long skuId, Integer num, Boolean checked) { - BoundHashOperations cartHashOpts = getCartHashOpts(); - String hKey = skuId + ""; - CartItemVO cartItem = (CartItemVO) cartHashOpts.get(hKey); - if (cartItem != null) { - if (num != null) { - cartItem.setNum(num); - cartItem.setSubtotal(num * cartItem.getPrice()); - } - if (checked != null) { - cartItem.setChecked(checked); - } - cartHashOpts.put(hKey, cartItem); - } - } - - @Override - public void checkAll(Boolean checked) { - BoundHashOperations cartHashOpts = getCartHashOpts(); - for (Object value : cartHashOpts.values()) { - CartItemVO cartItem = (CartItemVO) value; - cartItem.setChecked(checked); - String hKey = cartItem.getSkuId() + ""; - cartHashOpts.put(hKey, cartItem); - } - } - - @Override - public void deleteCartItem(Long skuId) { - BoundHashOperations cartHashOpts = getCartHashOpts(); - String hKey = skuId.toString(); - cartHashOpts.delete(hKey); - } - + /** + * 获取用户购物车 + */ @Override public CartVO getCart() { - BoundHashOperations cartHashOpts = getCartHashOpts(); - List items = cartHashOpts.values(); - CartVO cartVo = new CartVO(); - cartVo.setItems(items); - return cartVo; + CartVO cart = new CartVO(); + BoundHashOperations cartHashOperations = getCartHashOperations(); + List cartItems = cartHashOperations.values(); + cart.setItems(cartItems); + return cart; } @Override - public void deleteCart() { - Long userId = RequestUtils.getUserId(); - String key = CART_KEY + userId; + public List getCartItems() { + BoundHashOperations cartHashOperations = getCartHashOperations(); + List cartItems = cartHashOperations.values(); + return cartItems; + } + + + /** + * 删除用户购物车(清空购物车) + */ + @Override + public boolean deleteCart() { + String key = OmsConstants.CART_PREFIX + RequestUtils.getUserId(); redisTemplate.delete(key); + return true; } + /** + * 添加商品至购物车 + */ @Override - public void deleteSelectedItem() { - log.info("清空购物车中已选择商品"); - BoundHashOperations cartHashOpts = getCartHashOpts(); - for (Object value : cartHashOpts.values()) { - CartItemVO cartItem = (CartItemVO) value; + public boolean addCartItem(Long skuId) { + BoundHashOperations cartHashOperations = getCartHashOperations(); + String hKey = skuId + ""; + + CartVO.CartItem cartItem; + // 购物车已存在该商品,更新商品数量 + if (cartHashOperations.get(hKey) != null) { + cartItem = (CartVO.CartItem) cartHashOperations.get(hKey); + cartItem.setCount(cartItem.getCount() + 1); // 点击一次“加入购物车”,数量+1 + cartHashOperations.put(hKey, cartItem); + return true; + } + // 购物车不存在该商品,添加商品至购物车 + cartItem = new CartVO.CartItem(); + CompletableFuture cartItemCompletableFuture = CompletableFuture.runAsync(() -> { + PmsSku sku = skuFeignService.getSkuById(skuId).getData(); + if (sku != null) { + cartItem.setSkuId(sku.getId()); + cartItem.setCount(1); + cartItem.setPrice(sku.getPrice()); + cartItem.setPic(sku.getPic()); + cartItem.setSkuId(sku.getId()); + cartItem.setTitle(sku.getTitle()); + } + }); + CompletableFuture.allOf(cartItemCompletableFuture).join(); + return true; + } + + /** + * 更新购物车总商品数量、选中状态 + */ + @Override + public boolean updateCartItem(CartVO.CartItem cartItem) { + BoundHashOperations cartHashOperations = getCartHashOperations(); + String hKey = cartItem.getSkuId() + ""; + if (cartHashOperations.get(hKey) != null) { + cartHashOperations.put(hKey, cartItem); + } + return true; + } + + /** + * 移除购物车的商品 + */ + @Override + public boolean removeCartItem(Long skuId) { + BoundHashOperations cartHashOperations = getCartHashOperations(); + String hKey = skuId + ""; + cartHashOperations.delete(hKey); + return true; + } + + + /** + * 设置商品全选 + */ + @Override + public boolean checkAll(boolean checked) { + BoundHashOperations cartHashOperations = getCartHashOperations(); + for (Object value : cartHashOperations.values()) { + CartVO.CartItem cartItem = (CartVO.CartItem) value; + cartItem.setChecked(checked); + String hKey = cartItem.getSkuId() + ""; + cartHashOperations.put(hKey, cartItem); + } + return true; + } + + + /** + * 移除购物车选中的商品 + * — 场景:支付后删除购物车的商品 + */ + @Override + public boolean removeCheckedItem() { + BoundHashOperations cartHashOperations = getCartHashOperations(); + for (Object value : cartHashOperations.values()) { + CartVO.CartItem cartItem = (CartVO.CartItem) value; if (cartItem.isChecked()) { - log.info("清空购物车中商品,商品id:{} | 名称:{}", cartItem.getSkuId(), cartItem.getSkuName()); - cartHashOpts.delete(cartItem.getSkuId().toString()); + cartHashOperations.delete(cartItem.getSkuId()+""); } } + return true; } - private BoundHashOperations getCartHashOpts() { + /** + * 获取第一层,即某个用户的购物车 + */ + private BoundHashOperations getCartHashOperations() { Long userId = RequestUtils.getUserId(); - String cartKey = CART_KEY + userId; + String cartKey = OmsConstants.CART_PREFIX + userId; BoundHashOperations operations = redisTemplate.boundHashOps(cartKey); return operations; } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderDeliveryServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderDeliveryServiceImpl.java index 6f990eb81..a679fc830 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderDeliveryServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderDeliveryServiceImpl.java @@ -1,12 +1,12 @@ package com.youlai.mall.oms.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;; -import com.youlai.mall.oms.dao.OrderDeliveryDao; +import com.youlai.mall.oms.mapper.OrderDeliveryMapper; import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; import com.youlai.mall.oms.service.IOrderDeliveryService; import org.springframework.stereotype.Service; @Service("orderDeliveryService") -public class OrderDeliveryServiceImpl extends ServiceImpl implements IOrderDeliveryService { +public class OrderDeliveryServiceImpl extends ServiceImpl implements IOrderDeliveryService { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderItemServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderItemServiceImpl.java index 66d3a42a3..dcdc0faf6 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderItemServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderItemServiceImpl.java @@ -3,7 +3,7 @@ package com.youlai.mall.oms.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.oms.dao.OrderItemDao; +import com.youlai.mall.oms.mapper.OrderItemMapper; import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import com.youlai.mall.oms.service.IOrderItemService; import lombok.extern.slf4j.Slf4j; @@ -17,7 +17,7 @@ import java.util.stream.Collectors; @Slf4j @Service -public class OrderItemServiceImpl extends ServiceImpl implements IOrderItemService { +public class OrderItemServiceImpl extends ServiceImpl implements IOrderItemService { @Override diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogServiceImpl.java index ddae7dae5..4455c689a 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogServiceImpl.java @@ -2,7 +2,7 @@ package com.youlai.mall.oms.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.common.web.util.RequestUtils; -import com.youlai.mall.oms.dao.OrderLogDao; +import com.youlai.mall.oms.mapper.OrderLogMapper; import com.youlai.mall.oms.pojo.domain.OmsOrderLog; import com.youlai.mall.oms.service.IOrderLogService; import lombok.extern.slf4j.Slf4j; @@ -10,7 +10,7 @@ import org.springframework.stereotype.Service; @Slf4j @Service -public class OrderLogServiceImpl extends ServiceImpl implements IOrderLogService { +public class OrderLogServiceImpl extends ServiceImpl implements IOrderLogService { @Override public void addOrderLogs(Long orderId, Integer orderStatus, String user, String detail) { log.info("添加订单操作日志,orderId={},detail={}", orderId, detail); diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java index 417a39fa6..68845e4f3 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderPayServiceImpl.java @@ -3,7 +3,7 @@ package com.youlai.mall.oms.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.common.web.exception.BizException; import com.youlai.common.web.util.RequestUtils; -import com.youlai.mall.oms.dao.OrderPayDao; +import com.youlai.mall.oms.mapper.OrderPayMapper; import com.youlai.mall.oms.enums.OrderStatusEnum; import com.youlai.mall.oms.enums.PayTypeEnum; import com.youlai.mall.oms.pojo.domain.OmsOrder; @@ -11,16 +11,14 @@ import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import com.youlai.mall.oms.pojo.domain.OmsOrderPay; import com.youlai.mall.oms.pojo.vo.PayInfoVO; import com.youlai.mall.oms.service.IOrderItemService; -import com.youlai.mall.oms.service.IOrderLogService; import com.youlai.mall.oms.service.IOrderPayService; import com.youlai.mall.oms.service.IOrderService; -import com.youlai.mall.pms.api.app.InventoryFeignService; +import com.youlai.mall.pms.api.app.PmsSkuFeignService; import com.youlai.mall.pms.pojo.dto.InventoryDTO; -import com.youlai.mall.ums.api.app.MemberFeignService; +import com.youlai.mall.ums.api.app.UmsMemberFeignService; import io.seata.spring.annotation.GlobalTransactional; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; import java.util.Date; @@ -31,14 +29,14 @@ import java.util.stream.Collectors; @Slf4j @Service @AllArgsConstructor -public class OrderPayServiceImpl extends ServiceImpl implements IOrderPayService { +public class OrderPayServiceImpl extends ServiceImpl implements IOrderPayService { private IOrderService orderService; - private MemberFeignService memberFeignService; + private UmsMemberFeignService memberFeignService; private IOrderItemService orderItemService; - private InventoryFeignService inventoryFeignService; + private PmsSkuFeignService inventoryFeignService; @Override @GlobalTransactional(rollbackFor = Exception.class) diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderServiceImpl.java index f9ddc0af1..fc60050b9 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderServiceImpl.java @@ -2,6 +2,7 @@ package com.youlai.mall.oms.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -13,27 +14,34 @@ import com.youlai.common.result.ResultCode; import com.youlai.common.web.exception.BizException; import com.youlai.common.web.util.BeanMapperUtils; import com.youlai.common.web.util.RequestUtils; -import com.youlai.mall.oms.dao.OrderDao; +import com.youlai.mall.oms.constant.OmsConstants; +import com.youlai.mall.oms.mapper.OrderMapper; import com.youlai.mall.oms.enums.OrderStatusEnum; import com.youlai.mall.oms.enums.OrderTypeEnum; import com.youlai.mall.oms.pojo.bo.app.OrderBO; import com.youlai.mall.oms.pojo.domain.OmsOrder; import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; import com.youlai.mall.oms.pojo.domain.OmsOrderItem; +import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO; import com.youlai.mall.oms.pojo.dto.OrderSubmitDTO; import com.youlai.mall.oms.pojo.vo.*; import com.youlai.mall.oms.service.*; -import com.youlai.mall.pms.api.app.InventoryFeignService; +import com.youlai.mall.pms.api.app.PmsSkuFeignService; +import com.youlai.mall.pms.pojo.domain.PmsSku; import com.youlai.mall.pms.pojo.dto.InventoryDTO; import com.youlai.mall.pms.pojo.dto.SkuDTO; -import com.youlai.mall.ums.api.app.MemberFeignService; -import com.youlai.mall.ums.pojo.dto.UmsAddressDTO; +import com.youlai.mall.ums.api.app.UmsAddressFeignService; +import com.youlai.mall.ums.api.app.UmsMemberFeignService; +import com.youlai.mall.ums.pojo.domain.UmsAddress; +import io.netty.util.concurrent.CompleteFuture; import io.seata.spring.annotation.GlobalTransactional; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.task.AsyncTaskExecutor; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestAttributes; @@ -44,20 +52,23 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; @AllArgsConstructor @Slf4j @Service -public class OrderServiceImpl extends ServiceImpl implements IOrderService { +public class OrderServiceImpl extends ServiceImpl implements IOrderService { private static final ThreadLocal threadLocal = new ThreadLocal<>(); private ICartService cartService; - private InventoryFeignService inventoryFeignService; + private PmsSkuFeignService skuFeignService; - private MemberFeignService memberFeignService; + private UmsMemberFeignService memberFeignService; + + private UmsAddressFeignService addressFeignService; private AsyncTaskExecutor executor; @@ -69,38 +80,71 @@ public class OrderServiceImpl extends ServiceImpl implements private RabbitTemplate rabbitTemplate; + private RedisTemplate redisTemplate; + + private ThreadPoolExecutor threadPoolExecutor; + @Override - public OrderConfirmVO confirm(Long skuId, Integer count) { + public OrderConfirmVO confirm(OrderConfirmDTO orderConfirmDTO) { + OrderConfirmVO orderConfirmVO = new OrderConfirmVO(); + // 获取购买商品信息 + CompletableFuture orderItemsCompletableFuture = CompletableFuture.runAsync(() -> { + List orderItems = new ArrayList<>(); + if (orderConfirmDTO.getSkuId() != null) { // 直接购买商品结算 + OrderItemVO orderItemVO = OrderItemVO.builder() + .skuId(orderConfirmDTO.getSkuId()) + .count(orderConfirmDTO.getCount()) + .build(); + PmsSku sku = skuFeignService.getSkuById(orderConfirmDTO.getSkuId()).getData(); + orderItemVO.setPrice(sku.getPrice()); + orderItemVO.setSkuPic(sku.getPic()); + orderItemVO.setTitle(sku.getTitle()); + orderItems.add(orderItemVO); + } else { // 购物车中商品结算 + List cartItems = cartService.getCartItems(); + List items = cartItems.stream() + .filter(CartVO.CartItem::isChecked) + .map(cartItem -> OrderItemVO.builder() + .skuId(cartItem.getSkuId()) + .count(cartItem.getCount()) + .price(cartItem.getPrice()) + .title(cartItem.getTitle()) + .skuPic(cartItem.getPic()) + .build()) + .collect(Collectors.toList()); + orderItems.addAll(items); + } + orderConfirmVO.setOrderItems(orderItems); + }, threadPoolExecutor); - OrderConfirmVO orderConfirmVO=new OrderConfirmVO(); + // 获取会员地址列表 + CompletableFuture addressesCompletableFuture = CompletableFuture.runAsync(() -> { + List addresses = addressFeignService.list().getData(); + orderConfirmVO.setAddresses(addresses); + }, threadPoolExecutor); - List orderItems = getOrderItems(skuId, count); - if (CollectionUtil.isEmpty(orderItems)) { - return orderConfirmVO; - } - // 远程获取商品信息填充订单商品属性 - List skuIds = orderItems.stream().map(item -> item.getSkuId()).collect(Collectors.toList()); - List skus = inventoryFeignService.listBySkuIds(skuIds).getData(); - for (OrderItemVO orderItem : orderItems) { - skus.stream().filter(sku -> sku.getId().equals(orderItem.getSkuId())).findFirst() - .ifPresent(skuItem -> { - orderItem.setPrice(skuItem.getPrice()); - orderItem.setSkuImg(skuItem.getPic()); - orderItem.setSkuName(skuItem.getName()); - }); - } + // 生成唯一标识,防止订单重复提交 + CompletableFuture orderTokenCompletableFuture = CompletableFuture.runAsync(() -> { + String orderToken = IdUtil.randomUUID(); + orderConfirmVO.setOrderToken(orderToken); + redisTemplate.opsForValue().set(OmsConstants.ORDER_TOKEN_PREFIX + orderToken, orderToken); + }, threadPoolExecutor); - OrderConfirmVO confirmVO = new OrderConfirmVO(); - confirmVO.setOrderItems(orderItems); - return confirmVO; + CompletableFuture.allOf(orderItemsCompletableFuture, addressesCompletableFuture, orderTokenCompletableFuture); + return orderConfirmVO; } @Override @GlobalTransactional - @SneakyThrows - public OrderSubmitResultVO submit(OrderSubmitDTO submitInfoDTO) { + public OrderSubmitVO submit(OrderSubmitDTO submitDTO) { + + submitDTO. + + + + log.info("开始创建订单:{}", submitInfoDTO); threadLocal.set(submitInfoDTO); RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); @@ -262,9 +306,9 @@ public class OrderServiceImpl extends ServiceImpl implements } // 将订单放入延时队列,超时未支付系统自动关单 - rabbitTemplate.convertAndSend("order_event_exchange", "order:create", orderId); + rabbitTemplate.convertAndSend("order-exchange", "order:create", orderId); - OrderSubmitResultVO result = new OrderSubmitResultVO(); + OrderSubmitVO result = new OrderSubmitVO(); result.setId(orderId); result.setOrderSn(order.getOrderSn()); return result; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderSettingServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderSettingServiceImpl.java index 58c9b6eed..9c3ca4313 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderSettingServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderSettingServiceImpl.java @@ -1,13 +1,13 @@ package com.youlai.mall.oms.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.oms.dao.OrderSettingDao; +import com.youlai.mall.oms.mapper.OrderSettingMapper; import com.youlai.mall.oms.pojo.domain.OmsOrderSetting; import com.youlai.mall.oms.service.IOrderSettingService; import org.springframework.stereotype.Service; @Service -public class OrderSettingServiceImpl extends ServiceImpl implements IOrderSettingService { +public class OrderSettingServiceImpl extends ServiceImpl implements IOrderSettingService { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/TokenServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/TokenServiceImpl.java deleted file mode 100644 index 30768dd63..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/TokenServiceImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.youlai.mall.oms.service.impl; - -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.youlai.common.web.exception.BizException; -import com.youlai.common.web.util.RequestUtils; -import com.youlai.mall.oms.service.TokenService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletRequest; - -import static com.youlai.mall.oms.constant.OmsConstants.REDIS_KEY_TIME_OUT; -import static com.youlai.mall.oms.constant.OmsConstants.TOKEN_VERIFY; - - -/** - * @author huawei - * @desc Token 服务 - * @email huawei_code@163.com - * @date 2021/1/21 - */ -@Service -@AllArgsConstructor -@Slf4j -public class TokenServiceImpl implements TokenService { - - private static final String TOKEN = "token"; - - private RedisTemplate redisTemplate; - - @Override - public String generateToken() { - StringBuffer sb = new StringBuffer(); - String userId = RequestUtils.getUserId().toString(); - //生成UUID - String token = IdUtil.randomUUID(); - //前缀 + 用户ID + UUID组成 token - String key = sb.append(TOKEN_VERIFY).append(userId).append(':').append(token).toString(); - //将token写入redis并设置过期时间 - redisTemplate.opsForValue().set(key, key, REDIS_KEY_TIME_OUT); - //redis写入成功则设置token成功 - return token; - } - - @Override - public void checkToken(HttpServletRequest request) { - String token = request.getHeader(TOKEN); - if (StringUtils.isBlank(token)) { - token = request.getParameter(TOKEN); - if (StringUtils.isBlank(token)) { - throw new BizException("请勿重复提交"); - } - } - - StringBuilder sb = new StringBuilder(); - String userId = RequestUtils.getUserId().toString(); - String key = sb.append(TOKEN_VERIFY).append(userId).append(':').append(token).toString(); - - // 2、校验token是否存在 - if (!StrUtil.equals(redisTemplate.opsForValue().get(key).toString(), key)) { - log.debug("请求:{} 使用 token:{} 校验幂等性,缓存中不存在", request.getRequestURI(), token); - throw new BizException("请勿重复提交"); - } - // 3、校验token是否删除成功 - if (!redisTemplate.delete(key)) { - log.debug("请求:{} 使用 token:{} 校验幂等性,删除缓存数据失败", request.getRequestURI(), token); - throw new BizException("请勿重复提交"); - } - } -} diff --git a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDao.xml b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDao.xml deleted file mode 100644 index b22c8664c..000000000 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDao.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDeliveryDao.xml b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDeliveryDao.xml deleted file mode 100644 index 0acd7770a..000000000 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDeliveryDao.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderGoodsDao.xml b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderGoodsDao.xml deleted file mode 100644 index 70e3e9658..000000000 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderGoodsDao.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderLogsDao.xml b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderLogsDao.xml deleted file mode 100644 index 7e60b0892..000000000 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderLogsDao.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderPayDao.xml b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderPayDao.xml deleted file mode 100644 index 5e5423cb3..000000000 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderPayDao.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderSettingDao.xml b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderSettingDao.xml deleted file mode 100644 index 2cdec7eed..000000000 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderSettingDao.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/InventoryFeignService.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java similarity index 88% rename from mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/InventoryFeignService.java rename to mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java index 83c95284d..e53b4730d 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/InventoryFeignService.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/app/PmsSkuFeignService.java @@ -1,6 +1,7 @@ package com.youlai.mall.pms.api.app; import com.youlai.common.result.Result; +import com.youlai.mall.pms.pojo.domain.PmsSku; import com.youlai.mall.pms.pojo.dto.SkuDTO; import com.youlai.mall.pms.pojo.dto.InventoryDTO; import org.springframework.cloud.openfeign.FeignClient; @@ -9,7 +10,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @FeignClient(value = "mall-pms") -public interface InventoryFeignService { +public interface PmsSkuFeignService { /** * 获取库存列表 @@ -21,7 +22,7 @@ public interface InventoryFeignService { * 获取库存信息 */ @GetMapping("/api.app/v1/skus/{id}") - Result getSkuById(@PathVariable Long id); + Result getSkuById(@PathVariable Long id); /** * 锁定库存 diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java index 60c1fe4b3..cc9010fa6 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSku.java @@ -11,7 +11,7 @@ public class PmsSku extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; private Long spuId; - private String name; + private String title; private String code; private String pic; private Long originPrice; diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuDTO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuDTO.java index c8b707ad3..41fe7d33d 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuDTO.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuDTO.java @@ -15,28 +15,14 @@ public class SkuDTO { private String code; - private String name; + private String title; private String pic; - private Long originPrice; - private Long price; - private Integer inventory; - private Long spuId; - private String productName; - private String productPic; - - private Long brandId; - - private String brandName; - - private Long categoryId; - - private String categoryName; } diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java index aef0c8073..5e4b425dc 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java @@ -30,7 +30,7 @@ public class OrderItemVO extends BaseVO { */ @Getter @Setter - private String skuName; + private String title; /** * 商品数量 diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java index 2c16b2567..592ae8649 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java @@ -25,11 +25,9 @@ public class SkuController { @ApiOperation(value = "商品库存详情", httpMethod = "GET") @ApiImplicitParam(name = "id", value = "商品库存ID", required = true, paramType = "path", dataType = "Long") @GetMapping("/{id}") - public Result detail(@PathVariable Long id) { + public Result detail(@PathVariable Long id) { PmsSku sku = iPmsSkuService.getById(id); - SkuDTO SkuDTO = new SkuDTO(); - BeanUtil.copyProperties(sku, SkuDTO); - return Result.success(SkuDTO); + return Result.success(sku); } @ApiOperation("获取商品的库存数量") diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/admin/MemberFeignService.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/admin/MemberFeignService.java deleted file mode 100644 index 7765ddf06..000000000 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/admin/MemberFeignService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.youlai.mall.ums.api.admin; - -import com.youlai.common.result.Result; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.*; - -@FeignClient(value = "mall-ums",contextId = "AdminMemberFeignService") -public interface MemberFeignService { - - /** - * 扣减会员余额 - */ - @PatchMapping("/api.admin/v1/users/{id}/balance/_deduct") - Result deductBalance(@PathVariable Long id, @RequestParam Long amount); - -} - - diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsAddressFeignService.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsAddressFeignService.java new file mode 100644 index 000000000..b2b8f3e31 --- /dev/null +++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsAddressFeignService.java @@ -0,0 +1,28 @@ +package com.youlai.mall.ums.api.app; + +import com.youlai.common.result.Result; +import com.youlai.mall.ums.pojo.domain.UmsAddress; +import com.youlai.mall.ums.pojo.domain.UmsMember; +import com.youlai.mall.ums.pojo.dto.AuthMemberDTO; +import com.youlai.mall.ums.pojo.dto.MemberDTO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@FeignClient(value = "mall-ums") +public interface UmsAddressFeignService { + + /** + * 获取地址详情 + */ + @GetMapping("/api.app/v1/addresses/{id}") + Result getById(@PathVariable("id") Long id); + + + @GetMapping("/api.app/v1/addresses") + Result> list(); + +} + + diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/MemberFeignService.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java similarity index 58% rename from mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/MemberFeignService.java rename to mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java index 5686d4b2a..4be0fdc0c 100644 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/MemberFeignService.java +++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/app/UmsMemberFeignService.java @@ -1,62 +1,52 @@ package com.youlai.mall.ums.api.app; import com.youlai.common.result.Result; -import com.youlai.mall.ums.pojo.domain.UmsUser; +import com.youlai.mall.ums.pojo.domain.UmsMember; import com.youlai.mall.ums.pojo.dto.AuthMemberDTO; import com.youlai.mall.ums.pojo.dto.MemberDTO; -import com.youlai.mall.ums.pojo.dto.UmsAddressDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; @FeignClient(value = "mall-ums") -public interface MemberFeignService { +public interface UmsMemberFeignService { @PostMapping("/api.app/v1/users") - Result add(@RequestBody UmsUser user); + Result add(@RequestBody UmsMember user); /** * 获取会员信息 */ - @GetMapping("/api.app/v1/users/{id}") + @GetMapping("/api.app/v1/members/{id}") Result getUserById(@PathVariable Long id); /** * 获取认证会员信息 */ - @GetMapping("/api.app/v1/users/openid/{openid}") + @GetMapping("/api.app/v1/members/openid/{openid}") Result getUserByOpenid(@PathVariable String openid); - /** * 修改会员积分 */ - @PutMapping("/api.admin/v1/users/{id}/point") + @PutMapping("/api.admin/v1/members/{id}/point") Result updatePoint(@PathVariable Long id, @RequestParam Integer num); - /** - * 获取地址详情 - * - * @param id 地址id - * @return 地址详情 - */ - @GetMapping("/api.app/v1/addresses/{id}") - Result getAddressById(@PathVariable("id") String id); - - /** * 修改会员余额 */ - @PutMapping("/api.app/v1/users/{id}/balance") + @PutMapping("/api.app/v1/members/{id}/balances") Result updateBalance(@PathVariable Long id, @RequestParam Long balance); /** * 获取会员余额 */ - @GetMapping("/api.app/v1/users/{id}/balance") + @GetMapping("/api.app/v1/members/{id}/balances") Result getBalance(@PathVariable Long id); + + } diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/UmsUser.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/UmsMember.java similarity index 95% rename from mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/UmsUser.java rename to mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/UmsMember.java index ec5584198..911ba7c4d 100644 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/UmsUser.java +++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/domain/UmsMember.java @@ -13,7 +13,7 @@ import java.util.List; @Data @Accessors(chain = true) -public class UmsUser extends BaseEntity { +public class UmsMember extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java deleted file mode 100644 index 75cbc2143..000000000 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.youlai.mall.ums.pojo.dto; - - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - - -@Data -@Accessors(chain = true) -public class UmsAddressDTO implements Serializable { - - private Long id; - - private Long userId; - - private String name; - - private String mobile; - - private String province; - - private String city; - - private String area; - - private String address; - - private String zipCode; - - private Integer defaulted; -} diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UserController.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/MemberController.java similarity index 79% rename from mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UserController.java rename to mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/MemberController.java index 874d51aa7..782adb6ac 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UserController.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/MemberController.java @@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.youlai.common.constant.GlobalConstants; import com.youlai.common.enums.QueryModeEnum; import com.youlai.common.result.Result; -import com.youlai.mall.ums.pojo.domain.UmsUser; +import com.youlai.mall.ums.pojo.domain.UmsMember; import com.youlai.mall.ums.service.IUmsUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -16,7 +16,6 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Arrays; @@ -26,7 +25,7 @@ import java.util.Arrays; @RequestMapping("/api.admin/v1/users") @Slf4j @AllArgsConstructor -public class UserController { +public class MemberController { private IUmsUserService iUmsUserService; @@ -45,12 +44,12 @@ public class UserController { String nickname ) { QueryModeEnum queryModeEnum = QueryModeEnum.getValue(queryMode); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.ne(UmsUser::getDeleted, GlobalConstants.DELETED_VALUE); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.ne(UmsMember::getDeleted, GlobalConstants.DELETED_VALUE); switch (queryModeEnum) { default: // PAGE - queryWrapper.like(StrUtil.isNotBlank(nickname), UmsUser::getNickname, nickname); - IPage result = iUmsUserService.list(new Page<>(page, limit), new UmsUser().setNickname(nickname)); + queryWrapper.like(StrUtil.isNotBlank(nickname), UmsMember::getNickname, nickname); + IPage result = iUmsUserService.list(new Page<>(page, limit), new UmsMember().setNickname(nickname)); return Result.success(result.getRecords(), result.getTotal()); } } @@ -61,7 +60,7 @@ public class UserController { public Result getMemberById( @PathVariable Long id ) { - UmsUser user = iUmsUserService.getById(id); + UmsMember user = iUmsUserService.getById(id); return Result.success(user); } @@ -73,7 +72,7 @@ public class UserController { @PutMapping(value = "/{id}") public Result update( @PathVariable Integer id, - @RequestBody UmsUser user) { + @RequestBody UmsMember user) { boolean status = iUmsUserService.updateById(user); return Result.judge(status); } @@ -84,9 +83,9 @@ public class UserController { @ApiImplicitParam(name = "member", value = "实体JSON对象", required = true, paramType = "body", dataType = "UmsMember") }) @PatchMapping("/{id}") - public Result patch(@PathVariable Long id, @RequestBody UmsUser user) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(UmsUser::getId, id); - updateWrapper.set(user.getStatus() != null, UmsUser::getStatus, user.getStatus()); + public Result patch(@PathVariable Long id, @RequestBody UmsMember user) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(UmsMember::getId, id); + updateWrapper.set(user.getStatus() != null, UmsMember::getStatus, user.getStatus()); boolean status = iUmsUserService.update(updateWrapper); return Result.judge(status); } @@ -95,9 +94,9 @@ public class UserController { @ApiImplicitParam(name = "ids", value = "id集合", required = true, paramType = "query", dataType = "String") @DeleteMapping("/{ids}") public Result delete(@PathVariable String ids) { - boolean status = iUmsUserService.update(new LambdaUpdateWrapper() - .in(UmsUser::getId, Arrays.asList(ids.split(","))) - .set(UmsUser::getDeleted, GlobalConstants.DELETED_VALUE)); + boolean status = iUmsUserService.update(new LambdaUpdateWrapper() + .in(UmsMember::getId, Arrays.asList(ids.split(","))) + .set(UmsMember::getDeleted, GlobalConstants.DELETED_VALUE)); return Result.judge(status); } @@ -108,9 +107,9 @@ public class UserController { }) @PatchMapping("/{id}/balance/_deduct") public Result deductBalance(@PathVariable Long id, @RequestParam Long amount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(UmsUser::getId, id); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(UmsMember::getId, id); updateWrapper.setSql(" balance = balance - " + amount); - updateWrapper.gt(UmsUser::getBalance, amount); + updateWrapper.gt(UmsMember::getBalance, amount); boolean result = iUmsUserService.update(updateWrapper); return Result.judge(result); } diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/RechargeController.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/RechargeController.java index dc3fead83..2f3f45e73 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/RechargeController.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/RechargeController.java @@ -3,7 +3,7 @@ package com.youlai.mall.ums.controller.admin; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.youlai.common.result.Result; -import com.youlai.mall.ums.pojo.domain.UmsUser; +import com.youlai.mall.ums.pojo.domain.UmsMember; import com.youlai.mall.ums.pojo.dto.RechargeDTO; import com.youlai.mall.ums.pojo.dto.ResultPayDTO; import com.youlai.mall.ums.service.IUmsUserService; @@ -113,7 +113,7 @@ public class RechargeController { //处理自己的业务逻辑 //例如开通会员、用户充值等等。。。 String thirduid = resultPay.getThirduid(); - UmsUser user = iUmsUserService.getById(thirduid); + UmsMember user = iUmsUserService.getById(thirduid); if (user != null) { user.setBalance((long) (user.getBalance() + Float.valueOf(resultPay.getPrice()) * 100 * 10000)); } diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/UserController.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java similarity index 82% rename from mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/UserController.java rename to mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java index 1d3f41cbe..1f913b896 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/UserController.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.youlai.common.result.Result; import com.youlai.common.result.ResultCode; import com.youlai.common.web.util.RequestUtils; -import com.youlai.mall.ums.pojo.domain.UmsUser; +import com.youlai.mall.ums.pojo.domain.UmsMember; import com.youlai.mall.ums.pojo.dto.AuthMemberDTO; import com.youlai.mall.ums.pojo.dto.MemberDTO; import com.youlai.mall.ums.pojo.vo.MemberVO; @@ -20,10 +20,10 @@ import org.springframework.web.bind.annotation.*; @Api(tags = "【移动端】会员服务") @RestController -@RequestMapping("/api.app/v1/users") +@RequestMapping("/api.app/v1/members") @Slf4j @AllArgsConstructor -public class UserController { +public class MemberController { private IUmsUserService iUmsUserService; @@ -34,10 +34,10 @@ public class UserController { @PathVariable Long id ) { MemberDTO memberDTO = new MemberDTO(); - UmsUser user = iUmsUserService.getOne( - new LambdaQueryWrapper() - .select(UmsUser::getId, UmsUser::getNickname, UmsUser::getMobile, UmsUser::getBalance) - .eq(UmsUser::getId, id) + UmsMember user = iUmsUserService.getOne( + new LambdaQueryWrapper() + .select(UmsMember::getId, UmsMember::getNickname, UmsMember::getMobile, UmsMember::getBalance) + .eq(UmsMember::getId, id) ); if (user != null) { BeanUtil.copyProperties(user, memberDTO); @@ -51,8 +51,8 @@ public class UserController { public Result getMemberByOpenid( @PathVariable String openid ) { - UmsUser user = iUmsUserService.getOne(new LambdaQueryWrapper() - .eq(UmsUser::getOpenid, openid)); + UmsMember user = iUmsUserService.getOne(new LambdaQueryWrapper() + .eq(UmsMember::getOpenid, openid)); if (user == null) { return Result.failed(ResultCode.USER_NOT_EXIST); } @@ -64,7 +64,7 @@ public class UserController { @ApiOperation(value = "新增会员", httpMethod = "POST") @ApiImplicitParam(name = "member", value = "实体JSON对象", required = true, paramType = "body", dataType = "UmsMember") @PostMapping - public Result add(@RequestBody UmsUser user) { + public Result add(@RequestBody UmsMember user) { boolean status = iUmsUserService.save(user); return Result.judge(status); } @@ -73,7 +73,7 @@ public class UserController { @GetMapping("/me") public Result getMemberInfo() { Long userId = RequestUtils.getUserId(); - UmsUser user = iUmsUserService.getById(userId); + UmsMember user = iUmsUserService.getById(userId); if (user == null) { return Result.failed(ResultCode.USER_NOT_EXIST); } @@ -88,9 +88,9 @@ public class UserController { @ApiImplicitParam(name = "id", value = "会员ID", required = true, paramType = "path", dataType = "Long"), @ApiImplicitParam(name = "num", value = "积分数量", required = true, paramType = "query", dataType = "Integer") }) - @PutMapping("/{id}/point") + @PutMapping("/{id}/points") public Result updatePoint(@PathVariable Long id, @RequestParam Integer num) { - UmsUser user = iUmsUserService.getById(id); + UmsMember user = iUmsUserService.getById(id); user.setPoint(user.getPoint() + num); boolean result = iUmsUserService.updateById(user); return Result.judge(result); @@ -101,9 +101,9 @@ public class UserController { @ApiImplicitParam(name = "id", value = "会员ID", required = true, paramType = "path", dataType = "Long"), @ApiImplicitParam(name = "balance", value = "会员余额", required = true, paramType = "query", dataType = "Long") }) - @PutMapping("/{id}/balance") + @PutMapping("/{id}/balances") public Result updateBalance(@PathVariable Long id, @RequestParam Long balance) { - UmsUser user = iUmsUserService.getById(id); + UmsMember user = iUmsUserService.getById(id); user.setBalance(user.getBalance() - balance); boolean result = iUmsUserService.updateById(user); return Result.judge(result); @@ -111,10 +111,10 @@ public class UserController { @ApiOperation(value = "获取会员余额", httpMethod = "GET") @ApiImplicitParam(name = "id", value = "会员ID", required = true, paramType = "path", dataType = "Long") - @GetMapping("/{id}/balance") + @GetMapping("/{id}/balances") public Result updateBalance(@PathVariable Long id) { Long balance = 0l; - UmsUser user = iUmsUserService.getById(id); + UmsMember user = iUmsUserService.getById(id); if (user != null) { balance = user.getBalance(); } diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java index da81e75fa..591b435fc 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/mapper/UmsUserMapper.java @@ -2,7 +2,7 @@ package com.youlai.mall.ums.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.youlai.mall.ums.pojo.domain.UmsUser; +import com.youlai.mall.ums.pojo.domain.UmsMember; import org.apache.ibatis.annotations.Many; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; @@ -13,7 +13,7 @@ import java.util.List; @Mapper -public interface UmsUserMapper extends BaseMapper { +public interface UmsUserMapper extends BaseMapper { @Select("