From f6f25a94cf49b3c2b2e461fad0ceaaf082bd456a Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Sun, 14 Mar 2021 23:51:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E8=AE=A2=E5=8D=95=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=92=8C=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/youlai/mall/oms/bo/CartItemBO.java | 26 -- .../youlai/mall/oms/bo/CartItemCheckBo.java | 23 -- .../java/com/youlai/mall/oms/bo/OrderBO.java | 22 -- .../youlai/mall/oms/enums/OrderTypeEnum.java | 2 +- .../com/youlai/mall/oms/pojo/OmsOrder.java | 67 ---- .../youlai/mall/oms/pojo/OmsOrderItem.java | 36 -- .../youlai/mall/oms/pojo/bo/app/OrderBO.java | 29 ++ .../OrderEntity.java => domain/OmsOrder.java} | 8 +- .../OmsOrderDelivery.java} | 8 +- .../OmsOrderItem.java} | 10 +- .../OmsOrderLog.java} | 6 +- .../OmsOrderPay.java} | 6 +- .../OmsOrderSetting.java} | 8 +- .../OrderSubmitInfoDTO.java} | 7 +- .../youlai/mall/oms/pojo/vo/CartItemVO.java | 138 +------ .../com/youlai/mall/oms/pojo/vo/CartVO.java | 4 +- .../mall/oms/pojo/vo/OrderConfirmVO.java | 9 +- .../youlai/mall/oms/pojo/vo/OrderItemVO.java | 4 +- .../mall/oms/pojo/vo/OrderSubmitResultVO.java | 1 - .../com/youlai/mall/oms/pojo/vo/OrderVO.java | 29 -- mall-oms/oms-boot/pom.xml | 10 +- .../mall/oms/common/RedisConstants.java | 4 +- .../oms/controller/admin/OrderController.java | 23 +- .../oms/controller/app/CartController.java | 65 ++-- .../oms/controller/app/OrderController.java | 44 ++- .../com/youlai/mall/oms/dao/OrderDao.java | 8 +- .../youlai/mall/oms/dao/OrderDeliveryDao.java | 8 +- .../{OrderGoodsDao.java => OrderItemDao.java} | 8 +- .../{OrderLogsDao.java => OrderLogDao.java} | 6 +- .../com/youlai/mall/oms/dao/OrderPayDao.java | 8 +- .../youlai/mall/oms/dao/OrderSettingDao.java | 8 +- .../mall/oms/mapper/OmsOrderItemMapper.java | 3 +- .../mall/oms/mapper/OmsOrderMapper.java | 3 +- .../youlai/mall/oms/service/CartService.java | 33 +- .../oms/service/IOmsOrderItemService.java | 8 - .../mall/oms/service/IOmsOrderService.java | 12 - .../{OrderService.java => IOrderService.java} | 24 +- .../oms/service/OrderDeliveryService.java | 6 +- .../mall/oms/service/OrderGoodsService.java | 8 +- .../mall/oms/service/OrderLogsService.java | 6 +- .../mall/oms/service/OrderPayService.java | 6 +- .../mall/oms/service/OrderSettingService.java | 4 +- .../oms/service/impl/CartServiceImpl.java | 144 +++----- .../service/impl/OmsOrderItemServiceImpl.java | 5 +- .../oms/service/impl/OmsOrderServiceImpl.java | 18 +- .../impl/OrderDeliveryServiceImpl.java | 4 +- .../service/impl/OrderGoodsServiceImpl.java | 20 +- .../service/impl/OrderLogsServiceImpl.java | 8 +- .../oms/service/impl/OrderPayServiceImpl.java | 25 +- .../service/impl/OrderRabbitServiceImpl.java | 15 +- .../oms/service/impl/OrderServiceImpl.java | 337 ++++++++---------- .../service/impl/OrderSettingServiceImpl.java | 4 +- .../main/resources/mapper/oms/OrderDao.xml | 4 +- .../resources/mapper/oms/OrderDeliveryDao.xml | 4 +- .../resources/mapper/oms/OrderGoodsDao.xml | 6 +- .../resources/mapper/oms/OrderLogsDao.xml | 6 +- .../main/resources/mapper/oms/OrderPayDao.xml | 4 +- .../resources/mapper/oms/OrderSettingDao.xml | 4 +- .../oms/controller/OrderControllerTest.java | 4 +- .../pms/api/app/InventoryFeignService.java | 10 +- .../mall/pms/pojo/bo/admin/ProductBO.java | 8 +- .../mall/pms/pojo/bo/app/ProductBO.java | 4 +- .../youlai/mall/pms/pojo/domain/PmsSku.java | 2 +- .../pms/pojo/domain/PmsSpecification.java | 5 +- ...teValue.java => PmsSpuAttributeValue.java} | 2 +- ...icationValue.java => PmsSpuSpecValue.java} | 4 +- .../mall/pms/pojo/dto/app/ProductDTO.java | 15 + .../controller/admin/CategoryController.java | 6 +- .../pms/controller/admin/SpecController.java | 12 +- .../pms/controller/app/ProductController.java | 71 ++++ .../pms/controller/app/SkuController.java | 11 +- .../pms/controller/app/SpuController.java | 56 --- .../youlai/mall/pms/mapper/PmsSkuMapper.java | 7 +- ...ficationMapper.java => PmsSpecMapper.java} | 6 +- ...r.java => PmsSpuAttributeValueMapper.java} | 4 +- ...Mapper.java => PmsSpuSpecValueMapper.java} | 11 +- .../service/IPmsAttributeValueService.java | 10 - .../mall/pms/service/IPmsSkuService.java | 2 +- ...ationService.java => IPmsSpecService.java} | 2 +- .../IPmsSpecificationValueService.java | 9 - .../service/IPmsSpuAttributeValueService.java | 10 + .../pms/service/IPmsSpuSpecValueService.java | 9 + ...{ISpuService.java => IProductService.java} | 2 +- .../impl/PmsAttributeValueServiceImpl.java | 17 - .../pms/service/impl/PmsSkuServiceImpl.java | 4 +- ...rviceImpl.java => PmsSpecServiceImpl.java} | 6 +- .../PmsSpecificationValueServiceImpl.java | 16 - .../impl/PmsSpuAttributeValueServiceImpl.java | 17 + .../pms/service/impl/PmsSpuServiceImpl.java | 52 +-- .../impl/PmsSpuSpecValueServiceImpl.java | 16 + ...rviceImpl.java => ProductServiceImpl.java} | 22 +- ...erTest.java => ProductControllerTest.java} | 12 +- .../auth/controller/AuthController.java | 1 + 93 files changed, 689 insertions(+), 1112 deletions(-) delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemBO.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemCheckBo.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/OrderBO.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrder.java delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrderItem.java create mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{entity/OrderEntity.java => domain/OmsOrder.java} (90%) rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{entity/OrderDeliveryEntity.java => domain/OmsOrderDelivery.java} (87%) rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{entity/OrderGoodsEntity.java => domain/OmsOrderItem.java} (88%) rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{entity/OrderLogsEntity.java => domain/OmsOrderLog.java} (80%) rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{entity/OrderPayEntity.java => domain/OmsOrderPay.java} (85%) rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{entity/OrderSettingEntity.java => domain/OmsOrderSetting.java} (84%) rename mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/{vo/OrderSubmitVO.java => dto/OrderSubmitInfoDTO.java} (84%) delete mode 100644 mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderVO.java rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/{OrderGoodsDao.java => OrderItemDao.java} (65%) rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/{OrderLogsDao.java => OrderLogDao.java} (80%) delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderItemService.java delete mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderService.java rename mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/{OrderService.java => IOrderService.java} (65%) rename mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/{PmsAttributeValue.java => PmsSpuAttributeValue.java} (88%) rename mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/{PmsSpecificationValue.java => PmsSpuSpecValue.java} (80%) create mode 100644 mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/app/ProductDTO.java create mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/ProductController.java delete mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/{PmsSpecificationMapper.java => PmsSpecMapper.java} (68%) rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/{PmsAttributeValueMapper.java => PmsSpuAttributeValueMapper.java} (56%) rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/{PmsSpecificationValueMapper.java => PmsSpuSpecValueMapper.java} (63%) delete mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsAttributeValueService.java rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/{IPmsSpecificationService.java => IPmsSpecService.java} (74%) delete mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationValueService.java create mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuAttributeValueService.java create mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuSpecValueService.java rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/{ISpuService.java => IProductService.java} (79%) delete mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeValueServiceImpl.java rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/{PmsSpecificationServiceImpl.java => PmsSpecServiceImpl.java} (64%) delete mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationValueServiceImpl.java create mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuAttributeValueServiceImpl.java create mode 100644 mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuSpecValueServiceImpl.java rename mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/{SpuServiceImpl.java => ProductServiceImpl.java} (68%) rename mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/{SpuControllerTest.java => ProductControllerTest.java} (93%) diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemBO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemBO.java deleted file mode 100644 index ffabe5958..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemBO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.youlai.mall.oms.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Data -@Accessors(chain = true) -public class CartItemBO { - - /** - * 商品sku id - */ - @NotNull(message = "商品id不能为空") - private Long skuId; - - /** - * 商品数量 - */ - @NotNull(message = "商品数量不能为空") - @Min(value = 0, message = "商品数量不能为负数") - private Integer number; - -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemCheckBo.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemCheckBo.java deleted file mode 100644 index 18b18a44f..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/CartItemCheckBo.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.youlai.mall.oms.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -@Data -@Accessors(chain = true) -public class CartItemCheckBo { - - /** - * 商品sku id - */ - @NotNull(message = "商品id不能为空") - private Long skuId; - - /** - * 商品数量 - */ - private Integer check = 1; - -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/OrderBO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/OrderBO.java deleted file mode 100644 index 68635f6a3..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/bo/OrderBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.youlai.mall.oms.bo; - - -import com.youlai.mall.oms.pojo.OmsOrder; -import com.youlai.mall.oms.pojo.OmsOrderItem; -import com.youlai.mall.ums.pojo.dto.MemberDTO; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@Data -@Accessors(chain = true) -public class OrderBO { - - private OmsOrder order; - - private List orderItems; - - private MemberDTO member; - -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderTypeEnum.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderTypeEnum.java index 8b6397e47..abb3435f8 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderTypeEnum.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderTypeEnum.java @@ -18,7 +18,7 @@ public enum OrderTypeEnum { ; @Getter - public Integer code; + private Integer code; public static OrderTypeEnum getValue(Integer code){ for (OrderTypeEnum value : values()) { diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrder.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrder.java deleted file mode 100644 index 1709e734d..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrder.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.youlai.mall.oms.pojo; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.youlai.common.base.BaseEntity; -import lombok.Data; - -@Data -public class OmsOrder extends BaseEntity { - - @TableId(type = IdType.AUTO) - private Long id; - - private String orderSn; - - private Long userId; - - private Integer status; - - - private Integer sourceType; - - /* private String consignee; - - private String mobile; - - private String postcode; - - private String address; - - private Long couponId; - - private Long orderPrice; - - private Long skuPrice; - - private Long freightPrice; - - private Long couponPrice; - - private Long integrationPrice; - - private String payId; - - private Long payPrice; - - private Integer payChannel; - - private Date gmtPay; - - private String logisticsChannel; - - private String logisticsNo; - - private Date gmtDelivery; - - private Long refundAmount; - - private Integer refundType; - - private String refundNote; - - private Date gmtRefund; - - private Date gmtConfirm;*/ - -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrderItem.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrderItem.java deleted file mode 100644 index bb40ed5d7..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/OmsOrderItem.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.youlai.mall.oms.pojo; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.youlai.common.base.BaseEntity; -import lombok.Data; - - -/** - * 订单明细 - */ -@Data -public class OmsOrderItem extends BaseEntity { - - @TableId(type= IdType.AUTO) - private Long id; - - private Long orderId; - - private Long spuId; - - private String spuName; - - private String skuId; - - private String skuBarCode; - - private String skuSpecifications; - - private Long skuPrice; - - private Integer skuQuantity; - - private String skuPic; - -} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java new file mode 100644 index 000000000..d27348821 --- /dev/null +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/bo/app/OrderBO.java @@ -0,0 +1,29 @@ +package com.youlai.mall.oms.pojo.bo.app; + +import com.youlai.common.base.BaseVO; +import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; +import com.youlai.mall.oms.pojo.domain.OmsOrder; +import com.youlai.mall.oms.pojo.domain.OmsOrderItem; +import com.youlai.mall.oms.pojo.domain.OmsOrderLog; +import lombok.Data; + +import java.util.List; + +/** + * @author huawei + * @desc + * @email huawei_code@163.com + * @date 2021/1/19 + */ +@Data +public class OrderBO { + + private OmsOrder order; + + private List orderItems; + + private OmsOrderLog orderLog; + + private OmsOrderDelivery orderDelivery; + +} diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderEntity.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrder.java similarity index 90% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderEntity.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrder.java index 826916664..cba61b1fc 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderEntity.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrder.java @@ -1,10 +1,10 @@ -package com.youlai.mall.oms.pojo.entity; +package com.youlai.mall.oms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.youlai.common.base.BaseEntity; import lombok.Data; +import lombok.experimental.Accessors; import java.util.Date; @@ -16,8 +16,8 @@ import java.util.Date; * @date 2020-12-30 22:31:10 */ @Data -@TableName("oms_order") -public class OrderEntity extends BaseEntity { +@Accessors(chain = true) +public class OmsOrder extends BaseEntity { /** * id diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderDeliveryEntity.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderDelivery.java similarity index 87% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderDeliveryEntity.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderDelivery.java index 5e6467dd4..62d94f058 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderDeliveryEntity.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderDelivery.java @@ -1,9 +1,9 @@ -package com.youlai.mall.oms.pojo.entity; +package com.youlai.mall.oms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.youlai.common.base.BaseEntity; +import lombok.Builder; import lombok.Data; import java.util.Date; @@ -16,8 +16,8 @@ import java.util.Date; * @date 2020-12-30 22:31:10 */ @Data -@TableName("oms_order_delivery") -public class OrderDeliveryEntity extends BaseEntity { +@Builder +public class OmsOrderDelivery extends BaseEntity { /** * id diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderGoodsEntity.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java similarity index 88% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderGoodsEntity.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java index e16c34a25..b81cd228e 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderGoodsEntity.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderItem.java @@ -1,10 +1,11 @@ -package com.youlai.mall.oms.pojo.entity; +package com.youlai.mall.oms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.youlai.common.base.BaseEntity; +import lombok.Builder; import lombok.Data; +import lombok.experimental.Accessors; /** * 订单商品信息表 @@ -14,8 +15,9 @@ import lombok.Data; * @date 2020-12-30 22:31:10 */ @Data -@TableName("oms_order_goods") -public class OrderGoodsEntity extends BaseEntity { +@Accessors(chain = true) +@Builder +public class OmsOrderItem extends BaseEntity { /** * id diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderLogsEntity.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderLog.java similarity index 80% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderLogsEntity.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderLog.java index dcc1fc9ff..99191e0ce 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderLogsEntity.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderLog.java @@ -1,8 +1,7 @@ -package com.youlai.mall.oms.pojo.entity; +package com.youlai.mall.oms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.youlai.common.base.BaseEntity; import lombok.Data; @@ -14,8 +13,7 @@ import lombok.Data; * @date 2020-12-30 22:31:10 */ @Data -@TableName("oms_order_logs") -public class OrderLogsEntity extends BaseEntity { +public class OmsOrderLog extends BaseEntity { /** * id diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderPayEntity.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderPay.java similarity index 85% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderPayEntity.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderPay.java index e1917ba1a..6d9bb289f 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderPayEntity.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderPay.java @@ -1,8 +1,7 @@ -package com.youlai.mall.oms.pojo.entity; +package com.youlai.mall.oms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.youlai.common.base.BaseEntity; import lombok.Data; @@ -16,8 +15,7 @@ import java.util.Date; * @date 2020-12-30 22:31:10 */ @Data -@TableName("oms_order_pay") -public class OrderPayEntity extends BaseEntity { +public class OmsOrderPay extends BaseEntity { /** * id diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderSettingEntity.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderSetting.java similarity index 84% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderSettingEntity.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderSetting.java index ee4759202..51f67008d 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/entity/OrderSettingEntity.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/domain/OmsOrderSetting.java @@ -1,21 +1,19 @@ -package com.youlai.mall.oms.pojo.entity; +package com.youlai.mall.oms.pojo.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.youlai.common.base.BaseEntity; import lombok.Data; /** * 订单配置信息 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Data -@TableName("oms_order_setting") -public class OrderSettingEntity extends BaseEntity { +public class OmsOrderSetting extends BaseEntity { /** * id diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitInfoDTO.java similarity index 84% rename from mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java rename to mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitInfoDTO.java index c7a61f2fd..9df04164d 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/dto/OrderSubmitInfoDTO.java @@ -1,6 +1,5 @@ -package com.youlai.mall.oms.pojo.vo; +package com.youlai.mall.oms.pojo.dto; -import com.youlai.common.base.BaseVO; import lombok.Data; import javax.validation.constraints.NotBlank; @@ -13,7 +12,7 @@ import javax.validation.constraints.Size; * @date 2021/1/16 */ @Data -public class OrderSubmitVO extends BaseVO { +public class OrderSubmitInfoDTO { /** * 用户选择地址id @@ -25,7 +24,7 @@ public class OrderSubmitVO extends BaseVO { * 如果携带skuId则表示该订单通过直接下单方式生成 * 否则从购物车中生成 -- 清空购物车 */ - private String skuId; + private Long skuId; /** * 直接下单时商品数量 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 index 10d5c4166..96c994eb7 100644 --- 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 @@ -1,12 +1,13 @@ package com.youlai.mall.oms.pojo.vo; + import lombok.AllArgsConstructor; -import lombok.Builder; +import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; +import lombok.experimental.Accessors; import java.io.Serializable; -import java.util.List; /** * 购物车项目项实体类 @@ -14,145 +15,28 @@ import java.util.List; @NoArgsConstructor @AllArgsConstructor @ToString -@Builder +@Data +@Accessors(chain = true) public class CartItemVO implements Serializable { - /** - * 商品id - */ private Long skuId; - /** - * 商品图片 - */ - private String skuImg; + private String skuPic; - /** - * 商品名称 - */ private String skuName; - private Integer stock; + private Integer inventory; - /** - * 商品数量 - */ - private Integer number; + private Integer num; - /** - * 商品单价 - */ private Long price; - private Long coupon = 0L; + private Long coupon; - /** - * 小计 - */ - private Long subTotal; + private Long subtotal; - /** - * 是否有库存 - */ - private boolean hasStock; + private boolean hasInventory; - /** - * 是否选择 - */ private boolean checked; - private List skuAttrs; - - public Long getSkuId() { - return skuId; - } - - public void setSkuId(Long skuId) { - this.skuId = skuId; - } - - public String getSkuImg() { - return skuImg; - } - - public void setSkuImg(String skuImg) { - this.skuImg = skuImg; - } - - public String getSkuName() { - return skuName; - } - - public void setSkuName(String skuName) { - this.skuName = skuName; - } - - public Integer getInventory() { - return stock; - } - - public void setInventory(Integer stock) { - this.stock = stock; - } - - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - this.number = number; - } - - public Long getPrice() { - return price; - } - - public void setPrice(Long price) { - this.price = price; - } - - public Long getCoupon() { - return coupon; - } - - public void setCoupon(Long coupon) { - this.coupon = coupon; - } - - public Long getSubTotal() { - long total = 0; - if (price != null && number != null) { - total = price * number; - } - return total; - } - - public void setSubTotal(Long subTotal) { - - this.subTotal = subTotal; - } - - public boolean isHasStock() { - return hasStock; - } - - public void setHasStock(boolean hasStock) { - this.hasStock = hasStock; - } - - public boolean isChecked() { - return checked; - } - - public void setChecked(boolean checked) { - this.checked = checked; - } - - public List getSkuAttrs() { - return skuAttrs; - } - - public void setSkuAttrs(List skuAttrs) { - this.skuAttrs = skuAttrs; - } } 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 e783c4209..b267432d9 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 @@ -33,7 +33,7 @@ public class CartVO implements Serializable { public Integer getTotalNum() { int total = 0; if (items != null && items.size() > 0) { - total = items.stream().filter(CartItemVO::isChecked).mapToInt(CartItemVO::getNumber).sum(); + total = items.stream().filter(CartItemVO::isChecked).mapToInt(CartItemVO::getNum).sum(); } return total; } @@ -45,7 +45,7 @@ public class CartVO implements Serializable { public Long getTotalPrice() { long total = 0L; if (items != null && items.size() > 0) { - total = items.stream().filter(CartItemVO::isChecked).mapToLong(CartItemVO::getSubTotal).sum(); + total = items.stream().filter(CartItemVO::isChecked).mapToLong(CartItemVO::getSubtotal).sum(); } return total; } diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderConfirmVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderConfirmVO.java index 614bb156b..1b7c7ce68 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderConfirmVO.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderConfirmVO.java @@ -12,7 +12,6 @@ import java.util.List; public class OrderConfirmVO extends BaseVO { - /** * 商品列表 */ @@ -20,8 +19,6 @@ public class OrderConfirmVO extends BaseVO { @Setter private List items; - // 发票信息 - // 优惠券信息 @Getter @Setter @@ -32,8 +29,6 @@ public class OrderConfirmVO extends BaseVO { @Setter private Integer integration; - - /** * 订单总额 */ @@ -49,7 +44,7 @@ public class OrderConfirmVO extends BaseVO { public Long getTotalPrice() { Long total = 0L; if (items != null && items.size() > 0) { - total = items.stream().mapToLong(OrderItemVO::getSubTotal).sum(); + total = items.stream().mapToLong(OrderItemVO::getSubtotal).sum(); } return total; } @@ -57,7 +52,7 @@ public class OrderConfirmVO extends BaseVO { public Long getPayPrice() { Long total = 0L; if (items != null && items.size() > 0) { - total = items.stream().mapToLong(OrderItemVO::getSubTotal).sum(); + total = items.stream().mapToLong(OrderItemVO::getSubtotal).sum(); } return total; } 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 b77cc9da7..c2fc17134 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 @@ -54,9 +54,9 @@ public class OrderItemVO extends BaseVO { * 小计 */ @Setter - private Long subTotal; + private Long subtotal; - public Long getSubTotal() { + public Long getSubtotal() { Long total = 0L; if (price != null && number != null){ total = price * 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/OrderSubmitResultVO.java index 2b53a249b..bd63fce5f 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/OrderSubmitResultVO.java @@ -11,7 +11,6 @@ import lombok.Data; */ @Data public class OrderSubmitResultVO extends BaseVO { - /** * 订单ID */ diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderVO.java deleted file mode 100644 index 2e75baf75..000000000 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.youlai.mall.oms.pojo.vo; - -import com.youlai.common.base.BaseVO; -import com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity; -import com.youlai.mall.oms.pojo.entity.OrderEntity; -import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity; -import com.youlai.mall.oms.pojo.entity.OrderLogsEntity; -import lombok.Data; - -import java.util.List; - -/** - * @author huawei - * @desc - * @email huawei_code@163.com - * @date 2021/1/19 - */ -@Data -public class OrderVO extends BaseVO { - - private OrderEntity orderEntity; - - private List orderGoods; - - private OrderLogsEntity orderLogsEntity; - - private OrderDeliveryEntity orderDeliveryEntity; - -} diff --git a/mall-oms/oms-boot/pom.xml b/mall-oms/oms-boot/pom.xml index d46b95b9f..40cb44708 100644 --- a/mall-oms/oms-boot/pom.xml +++ b/mall-oms/oms-boot/pom.xml @@ -13,6 +13,11 @@ + + org.springframework.boot + spring-boot-starter-web + + org.springframework.cloud spring-cloud-starter-bootstrap @@ -50,10 +55,7 @@ common-rabbitmq - - org.springframework.boot - spring-boot-starter-web - + com.alibaba.cloud diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/common/RedisConstants.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/common/RedisConstants.java index 243c23674..3e69d5cc5 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/common/RedisConstants.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/common/RedisConstants.java @@ -4,9 +4,7 @@ public interface RedisConstants { Long REDIS_KEY_TIME_OUT = 3600 * 24L; - String YOU_LAI = "youlai:"; - - String MALL_CART_KEY = YOU_LAI + "cart:"; + String CART_KEY = "cart:"; String TOKEN_VERIFY = "token_verify:"; diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java index 470e30430..d52240fbf 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OrderController.java @@ -9,9 +9,6 @@ import com.youlai.common.enums.QueryModeEnum; import com.youlai.common.redis.component.BusinessNoGenerator; import com.youlai.common.result.Result; import com.youlai.common.result.ResultCode; -import com.youlai.mall.oms.bo.OrderBO; -import com.youlai.mall.oms.service.IOmsOrderService; -import com.youlai.mall.oms.pojo.OmsOrder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -52,16 +49,16 @@ public class OrderController { QueryModeEnum queryModeEnum = QueryModeEnum.getValue(queryMode); switch (queryModeEnum) { case PAGE: - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .like(StrUtil.isNotBlank(orderSn), OmsOrder::getOrderSn, orderSn) - .eq(status != null, OmsOrder::getStatus, status) + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .like(StrUtil.isNotBlank(orderSn), OmsOrder1::getOrderSn, orderSn) + .eq(status != null, OmsOrder1::getStatus, status) .apply(StrUtil.isNotBlank(startDate), "date_format (gmt_crate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')") .apply(StrUtil.isNotBlank(endDate), "date_format (gmt_crate,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d')") - .orderByDesc(OmsOrder::getGmtModified) - .orderByDesc(OmsOrder::getGmtCreate); - Page result = iOmsOrderService.page(new Page<>(page, limit), queryWrapper); + .orderByDesc(OmsOrder1::getGmtModified) + .orderByDesc(OmsOrder1::getGmtCreate); + Page result = iOmsOrderService.page(new Page<>(page, limit), queryWrapper); return Result.success(result.getRecords(), result.getTotal()); default: return Result.failed(ResultCode.QUERY_MODE_IS_NULL); @@ -92,7 +89,7 @@ public class OrderController { @PutMapping(value = "/{id}") public Result update( @PathVariable Long id, - @RequestBody OmsOrder order) { + @RequestBody OmsOrder1 order) { boolean status = iOmsOrderService.updateById(order); return Result.judge(status); } @@ -105,8 +102,8 @@ public class OrderController { @PatchMapping(value = "/{id}") public Result patch(@PathVariable Long id, @RequestParam Integer status) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(OmsOrder::getId, id); - updateWrapper.set(status != null, OmsOrder::getStatus, status); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(OmsOrder1::getId, id); + updateWrapper.set(status != null, OmsOrder1::getStatus, status); boolean result = iOmsOrderService.update(updateWrapper); return Result.judge(result); } @@ -115,7 +112,7 @@ public class OrderController { @ApiImplicitParam(name = "id", value = "订单ID", required = true, paramType = "path", dataType = "Long") @GetMapping("/{id}/detail") public Result orderDetail(@PathVariable Long id) { - OmsOrder order = iOmsOrderService.getById(id); + OmsOrder1 order = iOmsOrderService.getById(id); return Result.success(order); } 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 00c741245..d16668a23 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 @@ -1,8 +1,6 @@ package com.youlai.mall.oms.controller.app; import com.youlai.common.result.Result; -import com.youlai.mall.oms.bo.CartItemBO; -import com.youlai.mall.oms.bo.CartItemCheckBo; import com.youlai.mall.oms.pojo.vo.CartVO; import com.youlai.mall.oms.service.CartService; import io.swagger.annotations.Api; @@ -10,10 +8,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.List; -import java.util.concurrent.ExecutionException; /** * 购物车 @@ -34,56 +29,50 @@ public class CartController { @ApiOperation(value = "查询购物车", httpMethod = "GET") @GetMapping - public Result detail() { - CartVO cart = cartService.detail(); + public Result getCart() { + CartVO cart = cartService.getCart(); return Result.success(cart); } - @ApiOperation(value = "添加购物车", httpMethod = "POST") - @ApiImplicitParam(name = "skuId", value = "商品SKU Id", required = true, paramType = "param", dataType = "String") + @ApiOperation(value = "添加购物车商品", httpMethod = "POST") + @ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long") @PostMapping - public Result save(@RequestParam("skuId") String skuId) throws ExecutionException, InterruptedException { - cartService.save(skuId); + public Result addCartItem(@RequestParam Long skuId) { + cartService.addCartItem(skuId); return Result.success(); } - @ApiOperation(value = "修改购物车商品数量", httpMethod = "PUT") - @ApiImplicitParam(name = "cartItemBo", value = "实体JSON对象", required = true, paramType = "body", dataType = "CartItemBo") - @PutMapping - public Result update(@Validated @RequestBody CartItemBO cartItemBo) { - cartService.update(cartItemBo); + @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(); } - @ApiOperation(value = "是否选择购物车中商品", httpMethod = "PUT") - @ApiImplicitParam(name = "cartItemChooseBo", value = "实体JSON对象", required = true, paramType = "body", dataType = "CartItemChooseBo") - @PutMapping("/check") - public Result check(@Validated @RequestBody CartItemCheckBo cartItemCheckBo) { - cartService.check(cartItemCheckBo); + @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(); } - @ApiOperation(value = "全选/全不选择购物车", httpMethod = "PUT") - @ApiImplicitParam(name = "check", value = "全选/全不选", required = true, paramType = "param", dataType = "Long") - @PutMapping("/checkAll") - public Result checkAll(@RequestParam("check") Integer check) { - cartService.checkAll(check); + @ApiOperation(value = "删除购物车商品", httpMethod = "DELETE") + @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(); } - @ApiOperation(value = "批量删除购物车", httpMethod = "DELETE") - @ApiImplicitParam(name = "skuIds", value = "商品sku id集合", required = true, paramType = "param", dataType = "List") + @ApiOperation(value = "清空购物车", httpMethod = "DELETE") @DeleteMapping - public Result delete(@RequestParam("skuIds") List skuIds) { - cartService.deleteBatch(skuIds); + public Result deleteCart() { + cartService.deleteCart(); return Result.success(); } - - @ApiOperation(value = "清空购物车", httpMethod = "GET") - @GetMapping("/clear") - public Result clear() { - cartService.clear(); - return Result.success(); - } - } 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 d9211b2c1..94ec5a1b7 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,13 +1,11 @@ package com.youlai.mall.oms.controller.app; import com.youlai.common.result.Result; -import com.youlai.mall.oms.pojo.entity.OrderEntity; 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.service.OrderService; -import io.seata.spring.annotation.GlobalTransactional; +import com.youlai.mall.oms.pojo.dto.OrderSubmitInfoDTO; +import com.youlai.mall.oms.service.IOrderService; import io.swagger.annotations.*; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -15,11 +13,9 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; -import java.util.concurrent.ExecutionException; /** - * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 @@ -31,37 +27,37 @@ import java.util.concurrent.ExecutionException; @AllArgsConstructor public class OrderController { - private OrderService orderService; + private IOrderService IOrderService; /** * 订单确认信息,生成订单 * 如果入参传了skuId,则以当前skuId为准,商品数量默认为1 * 如果没有传,则从购物车中获取数据 * 如果购物车中没有数据,则返回为空 - * - * @return */ @ApiOperation(value = "订单确认信息", httpMethod = "POST") @ApiImplicitParams({ - @ApiImplicitParam(name = "skuId", value = "商品ID", required = true, paramType = "param", dataType = "String"), - @ApiImplicitParam(name = "number", value = "商品数量", required = true, defaultValue = "1", paramType = "param", dataType = "Integer") + @ApiImplicitParam(name = "skuId", value = "商品ID", required = true, paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "num", value = "商品数量", required = true, defaultValue = "1", paramType = "query", dataType = "Integer") }) - @PostMapping("/confirm") - public Result confirm(@RequestParam(value = "skuId", required = false) String skuId, - @RequestParam(value = "number", defaultValue = "1") Integer number) { - return Result.success(orderService.confirm(skuId, number)); + @PostMapping("/_confirm") + public Result confirm( + Long skuId, + Integer num + ) { + OrderConfirmVO confirm = IOrderService.confirm(skuId, num); + return Result.success(confirm); } @ApiOperation(value = "提交订单", httpMethod = "POST") - @ApiImplicitParam(name = "submit", value = "提交订单参数", required = true, paramType = "body", dataType = "OrderSubmitVO") - @PostMapping("/submit") - public Result submit(@Valid @RequestBody OrderSubmitVO submit) throws ExecutionException, InterruptedException { - log.info("提交订单:{}", submit); - return Result.success(orderService.submit(submit)); + @ApiImplicitParam(name = "orderSubmitVO", value = "提交订单信息", required = true, paramType = "body", dataType = "OrderSubmitVO") + @PostMapping("/_submit") + public Result submit(@Valid @RequestBody OrderSubmitInfoDTO orderSubmitInfoDTO) { + OrderSubmitResultVO result = IOrderService.submit(orderSubmitInfoDTO); + return Result.success(result); } - /** * 根据订单状态查询订单列表 * 步骤: @@ -71,9 +67,9 @@ public class OrderController { */ @ApiOperation("订单列表查询") @GetMapping("/list") - public Result> list(@ApiParam(name = "status",value = "订单状态",required = true,defaultValue = "0") - @RequestParam(value = "status",required = true,defaultValue = "0") Integer status) { - List orderList = orderService.list(status); + public Result> list(@ApiParam(name = "status", value = "订单状态", required = true, defaultValue = "0") + @RequestParam(value = "status", required = true, defaultValue = "0") Integer status) { + List orderList = IOrderService.list(status); return Result.success(orderList); } 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/dao/OrderDao.java index bcb1583ea..4de966cd4 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/dao/OrderDao.java @@ -1,17 +1,17 @@ package com.youlai.mall.oms.dao; -import com.youlai.mall.oms.pojo.entity.OrderEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrder; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * 订单详情表 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderDao extends BaseMapper { - +public interface OrderDao extends BaseMapper { + } 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/dao/OrderDeliveryDao.java index d17ff53de..965e221d2 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/dao/OrderDeliveryDao.java @@ -1,17 +1,17 @@ package com.youlai.mall.oms.dao; -import com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * 订单物流记录表 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderDeliveryDao extends BaseMapper { - +public interface OrderDeliveryDao extends BaseMapper { + } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderGoodsDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderItemDao.java similarity index 65% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderGoodsDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderItemDao.java index a0013bfa5..d0b894d2c 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderGoodsDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderItemDao.java @@ -1,17 +1,17 @@ package com.youlai.mall.oms.dao; -import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * 订单商品信息表 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderGoodsDao extends BaseMapper { - +public interface OrderItemDao extends BaseMapper { + } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogsDao.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogDao.java similarity index 80% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogsDao.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogDao.java index ed1667b09..2f5738a2e 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogsDao.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/dao/OrderLogDao.java @@ -6,12 +6,12 @@ import org.apache.ibatis.annotations.Mapper; /** * 订单操作历史记录 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderLogsDao extends BaseMapper { - +public interface OrderLogDao 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/dao/OrderPayDao.java index 40d78bcf8..de19a1c86 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/dao/OrderPayDao.java @@ -1,17 +1,17 @@ package com.youlai.mall.oms.dao; -import com.youlai.mall.oms.pojo.entity.OrderPayEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderPay; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * 支付信息表 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderPayDao extends BaseMapper { - +public interface OrderPayDao 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/dao/OrderSettingDao.java index 86acd89fc..a7f2688c3 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/dao/OrderSettingDao.java @@ -1,17 +1,17 @@ package com.youlai.mall.oms.dao; -import com.youlai.mall.oms.pojo.entity.OrderSettingEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderSetting; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * 订单配置信息 - * + * * @author huawei * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ @Mapper -public interface OrderSettingDao extends BaseMapper { - +public interface OrderSettingDao extends BaseMapper { + } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderItemMapper.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderItemMapper.java index 9ac06dca1..5f0cb879e 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderItemMapper.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderItemMapper.java @@ -1,10 +1,9 @@ package com.youlai.mall.oms.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.youlai.mall.oms.pojo.OmsOrderItem; import org.apache.ibatis.annotations.Mapper; @Mapper -public interface OmsOrderItemMapper extends BaseMapper { +public interface OmsOrderItemMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderMapper.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderMapper.java index 6696b2a1c..b2aba4092 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderMapper.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/mapper/OmsOrderMapper.java @@ -1,10 +1,9 @@ package com.youlai.mall.oms.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.youlai.mall.oms.pojo.OmsOrder; import org.apache.ibatis.annotations.Mapper; @Mapper -public interface OmsOrderMapper extends BaseMapper { +public interface OmsOrderMapper extends BaseMapper { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/CartService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/CartService.java index 197e616af..7d739bc54 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/CartService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/CartService.java @@ -1,12 +1,7 @@ package com.youlai.mall.oms.service; -import com.youlai.mall.oms.bo.CartItemBO; -import com.youlai.mall.oms.bo.CartItemCheckBo; import com.youlai.mall.oms.pojo.vo.CartVO; -import java.util.List; -import java.util.concurrent.ExecutionException; - /** * 购物车业务接口 */ @@ -14,50 +9,34 @@ public interface CartService { /** * 添加商品到购物车 - * @param skuId 商品模型 */ - void save(String skuId) throws ExecutionException, InterruptedException; + void addCartItem(Long skuId); /** * 修改购物车商品数量 - * @param cartItemBo */ - void update(CartItemBO cartItemBo); + void updateCartItem(Long skuId,Integer num,Boolean checked); - /** - * 修改购物车中商品是否选中状态 - * @param cartItemCheckBo - */ - void check(CartItemCheckBo cartItemCheckBo); /** * 全选/全不选购物车 - * @param check */ - void checkAll(Integer check); - - /** - * 删除购物车中的商品 - * @param skuId 商品id - */ - void delete(Long skuId); + void checkAll(Boolean checked); /** * 批量删除购物车中的商品 - * @param skuIds 商品id集合 */ - void deleteBatch(List skuIds); + void deleteCartItem(Long skuId); /** * 查询购物车详情 - * @return */ - CartVO detail(); + CartVO getCart(); /** * 清空购物车 */ - void clear(); + void deleteCart(); /** * 清空购物车中已选择商品 diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderItemService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderItemService.java deleted file mode 100644 index e23a355d1..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderItemService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.youlai.mall.oms.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.OmsOrderItem; - -public interface IOmsOrderItemService extends IService { - -} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderService.java deleted file mode 100644 index a439ea791..000000000 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOmsOrderService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.youlai.mall.oms.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.bo.OrderBO; -import com.youlai.mall.oms.pojo.OmsOrder; - -public interface IOmsOrderService extends IService { - - boolean save(OrderBO orderBO); - - OrderBO getByOrderId(Long id); -} diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java similarity index 65% rename from mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderService.java rename to mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java index d566af16d..34939911e 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java @@ -2,14 +2,13 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.entity.OrderEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrder; 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.OrderSubmitInfoDTO; import java.util.List; -import java.util.concurrent.ExecutionException; /** * 订单详情表 @@ -18,31 +17,24 @@ import java.util.concurrent.ExecutionException; * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ -public interface OrderService extends IService { +public interface IOrderService extends IService { /** * 订单确认页信息 * * @param skuId 商品id,非必填参数 - * @param number 商品数量 + * @param num 商品数量 * @return */ - OrderConfirmVO confirm(String skuId, Integer number); + OrderConfirmVO confirm(Long skuId, Integer num); /** * 提交订单 * - * @param submit 订单提交参数 + * @param orderSubmitInfoDTO 提交订单信息 */ - OrderSubmitResultVO submit(OrderSubmitVO submit) throws ExecutionException, InterruptedException; + OrderSubmitResultVO submit(OrderSubmitInfoDTO orderSubmitInfoDTO) ; - /** - * 根据订单号查询订单详情 - * - * @param orderSn 订单号 - * @return - */ - OrderEntity getByOrderSn(String orderSn); /** * 系统关闭订单 @@ -81,6 +73,6 @@ public interface OrderService extends IService { * @param id 订单ID * @return 订单信息 */ - OrderEntity getByOrderId(String id); + OmsOrder getByOrderId(String id); } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderDeliveryService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderDeliveryService.java index f3b4730d6..9dca9fe5a 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderDeliveryService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderDeliveryService.java @@ -2,9 +2,7 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity; - -import java.util.Map; +import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; /** * 订单物流记录表 @@ -13,6 +11,6 @@ import java.util.Map; * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ -public interface OrderDeliveryService extends IService { +public interface OrderDeliveryService extends IService { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderGoodsService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderGoodsService.java index 88444c794..3ea81e8dd 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderGoodsService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderGoodsService.java @@ -1,7 +1,7 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import java.util.List; import java.util.Map; @@ -13,11 +13,11 @@ import java.util.Map; * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ -public interface OrderGoodsService extends IService { +public interface OrderGoodsService extends IService { - List getByOrderId(Long orderId); + List getByOrderId(Long orderId); - Map> getByOrderIds(List orderIds); + Map> getByOrderIds(List orderIds); } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderLogsService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderLogsService.java index a660dcfa8..26ff7d93b 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderLogsService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderLogsService.java @@ -2,9 +2,7 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.entity.OrderLogsEntity; - -import java.util.Map; +import com.youlai.mall.oms.pojo.domain.OmsOrderLog; /** * 订单操作历史记录 @@ -13,7 +11,7 @@ import java.util.Map; * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ -public interface OrderLogsService extends IService { +public interface OrderLogsService extends IService { /** * 添加订单操作日志记录 diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderPayService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderPayService.java index 9a3011225..315f1de94 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderPayService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderPayService.java @@ -2,11 +2,9 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.entity.OrderPayEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderPay; import com.youlai.mall.oms.pojo.vo.PayInfoVO; -import java.util.Map; - /** * 支付信息表 * @@ -14,7 +12,7 @@ import java.util.Map; * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ -public interface OrderPayService extends IService { +public interface OrderPayService extends IService { /** * 获取订单支付详情 * @param orderId 订单ID diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderSettingService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderSettingService.java index 0e8a7f8e7..133fbab6d 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderSettingService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/OrderSettingService.java @@ -2,7 +2,7 @@ package com.youlai.mall.oms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.oms.pojo.entity.OrderSettingEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderSetting; /** * 订单配置信息 @@ -11,6 +11,6 @@ import com.youlai.mall.oms.pojo.entity.OrderSettingEntity; * @email huawei_code@163.com * @date 2020-12-30 22:31:10 */ -public interface OrderSettingService extends IService { +public interface OrderSettingService extends IService { } 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 fb520089a..450fe62d6 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 @@ -3,13 +3,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.oms.bo.CartItemBO; -import com.youlai.mall.oms.bo.CartItemCheckBo; import com.youlai.mall.pms.pojo.dto.SkuDTO; import com.youlai.mall.oms.pojo.vo.CartItemVO; import com.youlai.mall.oms.pojo.vo.CartVO; import com.youlai.mall.oms.service.CartService; 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,9 +16,8 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import static com.youlai.mall.oms.common.RedisConstants.MALL_CART_KEY; +import static com.youlai.mall.oms.common.RedisConstants.CART_KEY; /** @@ -47,129 +45,105 @@ public class CartServiceImpl implements CartService { private InventoryFeignService inventoryFeignService; - @Override - public void save(String skuId) throws ExecutionException, InterruptedException { - log.info("添加商品到购物车,form:{}", skuId); - BoundHashOperations cartOps = getCartOps(); - if (cartOps.get(skuId) != null) { - CartItemVO cartItem = (CartItemVO) cartOps.get(skuId); - Integer number = cartItem.getNumber() + 1; - cartItem.setNumber(number); - cartOps.put(skuId, cartItem); + @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 skuInfoFuture = CompletableFuture.runAsync(() -> { - //1、远程查询商品详情 - Result skuInfo = inventoryFeignService.getInventoryById(Long.parseLong(skuId)); - SkuDTO data = skuInfo.getData(); - cartItem.setSkuId(Long.parseLong(skuId)); - cartItem.setChecked(true); - cartItem.setSkuName(data.getName()); - cartItem.setSkuImg(data.getPic()); - cartItem.setNumber(1); - cartItem.setPrice(data.getPrice()); - cartItem.setInventory(data.getInventory()); + 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()); }); - //2、远程查询商品属性 - //3、远程查询库存 - CompletableFuture allOf = CompletableFuture.allOf(skuInfoFuture); + CompletableFuture allOf = CompletableFuture.allOf(future); allOf.get(); - cartOps.put(skuId, cartItem); - - + cartHashOpts.put(hKey, cartItem); } @Override - public void update(CartItemBO cartItemBo) { - log.info("修改购物车商品数量,form:{}", cartItemBo); - BoundHashOperations cartOps = getCartOps(); - CartItemVO cartItem = (CartItemVO) cartOps.get(cartItemBo.getSkuId().toString()); - if (cartItem == null) { - return; + 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); } - cartItem.setNumber(cartItemBo.getNumber()); - cartOps.put(cartItemBo.getSkuId().toString(), cartItem); } @Override - public void check(CartItemCheckBo cartItemCheckBo) { - log.info("修改购物车商品选中状态,form:{}", cartItemCheckBo); - BoundHashOperations cartOps = getCartOps(); - CartItemVO cartItem = (CartItemVO) cartOps.get(cartItemCheckBo.getSkuId().toString()); - if (cartItem == null) { - return; - } - cartItem.setChecked(cartItemCheckBo.getCheck() == 1); - cartOps.put(cartItemCheckBo.getSkuId().toString(), cartItem); - } - - @Override - public void checkAll(Integer check) { - log.info("全选/全不选购物车商品状态,check:{}", check); - BoundHashOperations cartOps = getCartOps(); - for (Object value : cartOps.values()) { + public void checkAll(Boolean checked) { + BoundHashOperations cartHashOpts = getCartHashOpts(); + for (Object value : cartHashOpts.values()) { CartItemVO cartItem = (CartItemVO) value; - cartItem.setChecked(check == 1); - cartOps.put(cartItem.getSkuId().toString(), cartItem); + cartItem.setChecked(checked); + String hKey = cartItem.getSkuId() + ""; + cartHashOpts.put(hKey, cartItem); } } @Override - public void delete(Long skuId) { - log.info("删除购物车,商品id:{}", skuId); - BoundHashOperations cartOps = getCartOps(); - cartOps.delete(skuId); + public void deleteCartItem(Long skuId) { + BoundHashOperations cartHashOpts = getCartHashOpts(); + String hKey = skuId.toString(); + cartHashOpts.delete(hKey); } @Override - public void deleteBatch(List skuIds) { - log.info("批量删除购物车,商品id集合:{}", skuIds); - BoundHashOperations cartOps = getCartOps(); - for (String skuId : skuIds) { - cartOps.delete(skuId); - } - } - - @Override - public CartVO detail() { - log.info("查询购物车详情"); - BoundHashOperations cartOps = getCartOps(); - List items = cartOps.values(); + public CartVO getCart() { + BoundHashOperations cartHashOpts = getCartHashOpts(); + List items = cartHashOpts.values(); CartVO cartVo = new CartVO(); cartVo.setItems(items); return cartVo; } @Override - public void clear() { - log.info("清空购物车"); + public void deleteCart() { Long userId = RequestUtils.getUserId(); - String cartKey = MALL_CART_KEY + userId; - redisTemplate.delete(cartKey); - + String key = CART_KEY + userId; + redisTemplate.delete(key); } @Override public void cleanSelected() { log.info("清空购物车中已选择商品"); - BoundHashOperations cartOps = getCartOps(); - for (Object value : cartOps.values()) { + BoundHashOperations cartHashOpts = getCartHashOpts(); + for (Object value : cartHashOpts.values()) { CartItemVO cartItem = (CartItemVO) value; if (cartItem.isChecked()) { log.info("清空购物车中商品,商品id:{} | 名称:{}", cartItem.getSkuId(), cartItem.getSkuName()); - cartOps.delete(cartItem.getSkuId().toString()); + cartHashOpts.delete(cartItem.getSkuId().toString()); } } } - private BoundHashOperations getCartOps() { + private BoundHashOperations getCartHashOpts() { Long userId = RequestUtils.getUserId(); - String cartKey = MALL_CART_KEY + userId; + String cartKey = CART_KEY + userId; BoundHashOperations operations = redisTemplate.boundHashOps(cartKey); return operations; } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderItemServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderItemServiceImpl.java index fb1d9c2d1..281af67b1 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderItemServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderItemServiceImpl.java @@ -1,11 +1,10 @@ package com.youlai.mall.oms.service.impl; +import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.mall.oms.mapper.OmsOrderItemMapper; -import com.youlai.mall.oms.pojo.OmsOrderItem; -import com.youlai.mall.oms.service.IOmsOrderItemService; import org.springframework.stereotype.Service; @Service -public class OmsOrderItemServiceImpl extends ServiceImpl implements IOmsOrderItemService { +public class OmsOrderItemServiceImpl extends ServiceImpl implements IService { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderServiceImpl.java index b6d2b3ba6..adbb4418b 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OmsOrderServiceImpl.java @@ -6,13 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.common.result.Result; import com.youlai.common.web.exception.BizException; -import com.youlai.mall.oms.bo.OrderBO; import com.youlai.mall.oms.mapper.OmsOrderMapper; -import com.youlai.mall.oms.pojo.OmsOrder; -import com.youlai.mall.oms.pojo.OmsOrderItem; -import com.youlai.mall.oms.service.IOmsOrderItemService; -import com.youlai.mall.oms.service.IOmsOrderService; -import com.youlai.mall.pms.api.app.InventoryFeignService; import com.youlai.mall.ums.api.app.MemberFeignService; import com.youlai.mall.ums.pojo.dto.MemberDTO; import lombok.AllArgsConstructor; @@ -26,7 +20,7 @@ import java.util.Optional; @Service @AllArgsConstructor @Slf4j -public class OmsOrderServiceImpl extends ServiceImpl implements IOmsOrderService { +public class OmsOrderServiceImpl extends ServiceImpl implements IOmsOrderService { private IOmsOrderItemService iOmsOrderItemService; @@ -40,13 +34,13 @@ public class OmsOrderServiceImpl extends ServiceImpl i @Override public boolean save(OrderBO orderBO) { // 订单 - OmsOrder order = orderBO.getOrder(); + OmsOrder1 order = orderBO.getOrder(); String orderSn = IdUtil.createSnowflake(1, 1).nextIdStr(); order.setOrderSn(orderSn); this.save(order); // 订单明细 - List orderItems = orderBO.getOrderItems(); + List orderItems = orderBO.getOrderItems(); if (CollectionUtil.isEmpty(orderItems)) { throw new BizException("订单明细不能为空"); } @@ -61,13 +55,13 @@ public class OmsOrderServiceImpl extends ServiceImpl i public OrderBO getByOrderId(Long orderId) { OrderBO orderBO = new OrderBO(); // 订单 - OmsOrder order = this.getById(orderId); + OmsOrder1 order = this.getById(orderId); if (order == null) { throw new BizException("订单不存在"); } // 订单明细 - List orderItems = iOmsOrderItemService.list( - new LambdaQueryWrapper().eq(OmsOrderItem::getOrderId, orderId) + List orderItems = iOmsOrderItemService.list( + new LambdaQueryWrapper().eq(OmsOrderItem1::getOrderId, orderId) ); orderItems = Optional.ofNullable(orderItems).orElse(new ArrayList<>()); 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 19691c9ae..1194781d7 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 @@ -2,11 +2,11 @@ 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.pojo.entity.OrderDeliveryEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; import com.youlai.mall.oms.service.OrderDeliveryService; import org.springframework.stereotype.Service; @Service("orderDeliveryService") -public class OrderDeliveryServiceImpl extends ServiceImpl implements OrderDeliveryService { +public class OrderDeliveryServiceImpl extends ServiceImpl implements OrderDeliveryService { } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderGoodsServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderGoodsServiceImpl.java index f2fd6878c..81652e811 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderGoodsServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderGoodsServiceImpl.java @@ -3,8 +3,8 @@ package com.youlai.mall.oms.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.oms.dao.OrderGoodsDao; -import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity; +import com.youlai.mall.oms.dao.OrderItemDao; +import com.youlai.mall.oms.pojo.domain.OmsOrderItem; import com.youlai.mall.oms.service.OrderGoodsService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -17,28 +17,28 @@ import java.util.stream.Collectors; @Service("orderGoodsService") @Slf4j -public class OrderGoodsServiceImpl extends ServiceImpl implements OrderGoodsService { +public class OrderGoodsServiceImpl extends ServiceImpl implements OrderGoodsService { @Override - public List getByOrderId(Long orderId) { + public List getByOrderId(Long orderId) { log.info("根据订单ID,查询订单商品列表,orderId={}", orderId); - QueryWrapper queryWrapper = new QueryWrapper<>(); + QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ge("order_id", orderId); return baseMapper.selectList(queryWrapper); } @Override - public Map> getByOrderIds(List orderIds) { - QueryWrapper orderGoodsQuery = new QueryWrapper<>(); + public Map> getByOrderIds(List orderIds) { + QueryWrapper orderGoodsQuery = new QueryWrapper<>(); orderGoodsQuery.in("order_id", orderIds).orderByDesc("order_id", "id"); - List orderGoods = this.list(orderGoodsQuery); + List orderGoods = this.list(orderGoodsQuery); if (orderGoods == null || orderGoods.size() == 0) { log.info("根据订单ID列表查询商品为空,orderIds={}", orderIds); return new HashMap<>(8); } - Map> orderGoodsMap = orderGoods.stream() - .collect(Collectors.groupingBy(OrderGoodsEntity::getOrderId)); + Map> orderGoodsMap = orderGoods.stream() + .collect(Collectors.groupingBy(OmsOrderItem::getOrderId)); return orderGoodsMap; } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogsServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogsServiceImpl.java index eef184acb..9bf357d18 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogsServiceImpl.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderLogsServiceImpl.java @@ -2,20 +2,20 @@ 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.OrderLogsDao; -import com.youlai.mall.oms.pojo.entity.OrderLogsEntity; +import com.youlai.mall.oms.dao.OrderLogDao; +import com.youlai.mall.oms.pojo.domain.OmsOrderLog; import com.youlai.mall.oms.service.OrderLogsService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @Service("orderLogsService") @Slf4j -public class OrderLogsServiceImpl extends ServiceImpl implements OrderLogsService { +public class OrderLogsServiceImpl extends ServiceImpl implements OrderLogsService { @Override public void addOrderLogs(Long orderId, Integer orderStatus, String user, String detail) { try { log.info("添加订单操作日志,orderId={},detail={}", orderId, detail); - OrderLogsEntity orderLogs = new OrderLogsEntity(); + OmsOrderLog orderLogs = new OmsOrderLog(); orderLogs.setDetail(detail); orderLogs.setOrderId(orderId); orderLogs.setOrderStatus(orderStatus); 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 3a24f87ba..338758527 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 @@ -1,7 +1,5 @@ package com.youlai.mall.oms.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -12,12 +10,12 @@ import com.youlai.common.web.util.RequestUtils; import com.youlai.mall.oms.dao.OrderPayDao; import com.youlai.mall.oms.enums.PayTypeEnum; import com.youlai.mall.oms.enums.OrderStatusEnum; -import com.youlai.mall.oms.pojo.entity.OrderEntity; -import com.youlai.mall.oms.pojo.entity.OrderPayEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrder; +import com.youlai.mall.oms.pojo.domain.OmsOrderPay; import com.youlai.mall.oms.pojo.vo.PayInfoVO; import com.youlai.mall.oms.service.OrderLogsService; import com.youlai.mall.oms.service.OrderPayService; -import com.youlai.mall.oms.service.OrderService; +import com.youlai.mall.oms.service.IOrderService; import com.youlai.mall.ums.api.app.MemberFeignService; import com.youlai.mall.ums.pojo.dto.MemberDTO; import io.seata.spring.annotation.GlobalTransactional; @@ -26,15 +24,14 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.Date; -import java.util.Map; @Slf4j @AllArgsConstructor @Service("orderPayService") -public class OrderPayServiceImpl extends ServiceImpl implements OrderPayService { +public class OrderPayServiceImpl extends ServiceImpl implements OrderPayService { - private OrderService orderService; + private IOrderService IOrderService; private OrderLogsService orderLogsService; @@ -45,8 +42,8 @@ public class OrderPayServiceImpl extends ServiceImpl().eq(OmsOrder::getOrderSn,orderSn)); if (order.getStatus().equals(OrderStatusEnum.NEED_PAY.getCode())) { - if (orderService.closeOrderBySystem(orderSn)){ + if (IOrderService.closeOrderBySystem(orderSn)){ unlockInventory(order.getId()); } } @@ -67,7 +68,7 @@ public class OrderRabbitServiceImpl implements OrderRabbitService { } private void unlockInventory(Long orderId) { - List orderGoods = orderGoodsService.getByOrderId(orderId); + List orderGoods = orderGoodsService.getByOrderId(orderId); List items = orderGoods.stream().map(good -> { InventoryDTO item = new InventoryDTO(); item.setInventoryId(good.getSkuId()); 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 648d10afd..75a29c0d5 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 @@ -1,8 +1,10 @@ package com.youlai.mall.oms.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -16,17 +18,19 @@ import com.youlai.common.web.util.RequestUtils; import com.youlai.mall.oms.config.rabbitmq.OmsRabbitConstants; import com.youlai.mall.oms.dao.OrderDao; import com.youlai.mall.oms.dao.OrderDeliveryDao; -import com.youlai.mall.oms.dao.OrderGoodsDao; +import com.youlai.mall.oms.dao.OrderItemDao; import com.youlai.mall.oms.enums.OrderStatusEnum; import com.youlai.mall.oms.enums.OrderTypeEnum; -import com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity; -import com.youlai.mall.oms.pojo.entity.OrderEntity; -import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity; +import com.youlai.mall.oms.pojo.bo.app.OrderBO; +import com.youlai.mall.oms.pojo.domain.OmsOrderDelivery; +import com.youlai.mall.oms.pojo.domain.OmsOrder; +import com.youlai.mall.oms.pojo.domain.OmsOrderItem; +import com.youlai.mall.oms.pojo.dto.OrderSubmitInfoDTO; import com.youlai.mall.oms.pojo.vo.*; import com.youlai.mall.oms.service.CartService; import com.youlai.mall.oms.service.OrderGoodsService; import com.youlai.mall.oms.service.OrderLogsService; -import com.youlai.mall.oms.service.OrderService; +import com.youlai.mall.oms.service.IOrderService; import com.youlai.mall.pms.api.app.InventoryFeignService; import com.youlai.mall.pms.pojo.dto.SkuDTO; import com.youlai.mall.pms.pojo.dto.InventoryDTO; @@ -34,26 +38,23 @@ import com.youlai.mall.ums.api.app.MemberFeignService; import com.youlai.mall.ums.pojo.dto.UmsAddressDTO; 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.core.task.AsyncTaskExecutor; -import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import java.util.*; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.function.Function; import java.util.stream.Collectors; @AllArgsConstructor @Slf4j -@Service("orderService") -public class OrderServiceImpl extends ServiceImpl implements OrderService { +public class OrderServiceImpl extends ServiceImpl implements IOrderService { - private static final ThreadLocal threadOrderSubmit = new ThreadLocal<>(); + private static final ThreadLocal threadLocal = new ThreadLocal<>(); private CartService cartService; @@ -63,9 +64,7 @@ public class OrderServiceImpl extends ServiceImpl impleme private AsyncTaskExecutor executor; - private OrderDao orderDao; - - private OrderGoodsDao orderGoodsDao; + private OrderItemDao orderItemDao; private OrderDeliveryDao orderDeliveryDao; @@ -77,90 +76,142 @@ public class OrderServiceImpl extends ServiceImpl impleme @Override - public OrderConfirmVO confirm(String skuId, Integer number) { - List items = getOrderItemFromCart(skuId, number); - if (CollectionUtil.isEmpty(items)) { - log.info("订单商品列表为空,无法创建订单确认信息"); + public OrderConfirmVO confirm(Long skuId, Integer num) { + List orderItems = getOrderItem(skuId, num); + if (CollectionUtil.isEmpty(orderItems)) { // 订单中无商品,直接返回 return new OrderConfirmVO(); } - // feign调用商品接口,获取商品信息 - Map skuMap = new HashMap<>(items.size()); - List skuIds = items.stream().map(item -> item.getSkuId().toString()).collect(Collectors.toList()); - List skuInfos = inventoryFeignService.listBySkuIds(String.join(",", skuIds)).getData(); - if (!CollectionUtil.isEmpty(skuInfos)) { - skuMap = skuInfos.stream().collect(Collectors.toMap(SkuDTO::getId, Function.identity())); - } - - for (OrderItemVO item : items) { - SkuDTO info = skuMap.get(item.getSkuId()); - if (info != null) { - item.setPrice(info.getPrice()); - item.setSkuImg(info.getPic()); - item.setSkuName(info.getName()); - } + // 远程获取商品信息填充订单商品属性 + 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()); + }); } OrderConfirmVO confirm = new OrderConfirmVO(); - confirm.setItems(items); + confirm.setItems(orderItems); return confirm; } @Override @GlobalTransactional - public OrderSubmitResultVO submit(OrderSubmitVO submit) throws ExecutionException, InterruptedException { - log.info("开始创建订单:{}", submit); - threadOrderSubmit.set(submit); + @SneakyThrows + public OrderSubmitResultVO submit(OrderSubmitInfoDTO submitInfoDTO) { + log.info("开始创建订单:{}", submitInfoDTO); + threadLocal.set(submitInfoDTO); + RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); - OrderVO orderVO = new OrderVO(); + OrderBO orderBO = new OrderBO(); + + // 创建订单 CompletableFuture orderFuture = CompletableFuture.runAsync(() -> { RequestContextHolder.setRequestAttributes(attributes); - threadOrderSubmit.set(submit); - OrderEntity order = createOrder(); - orderVO.setOrderEntity(order); + threadLocal.set(submitInfoDTO); + + OrderSubmitInfoDTO submitInfo = threadLocal.get(); + log.info("创建订单实体类,submit:{}", submitInfo); + OmsOrder order = new OmsOrder(); + order.setOrderSn(IdWorker.getTimeId()) + .setRemark(submitInfo.getRemark()) + .setStatus(OrderStatusEnum.NEED_PAY.getCode()) + .setSourceType(OrderTypeEnum.APP.getCode()) + .setMemberId(RequestUtils.getUserId()); + orderBO.setOrder(order); + }, executor); - CompletableFuture orderGoodsFuture = CompletableFuture.runAsync(() -> { - // 生成订单商品信息 + // 创建订单商品 + CompletableFuture orderItemFuture = CompletableFuture.runAsync(() -> { RequestContextHolder.setRequestAttributes(attributes); - threadOrderSubmit.set(submit); - List orderGoods = createOrderGoods(); - orderVO.setOrderGoods(orderGoods); + threadLocal.set(submitInfoDTO); + + OrderSubmitInfoDTO submitInfo = threadLocal.get(); + log.info("创建订单商品,submitInfo:{}", submitInfo); + + List orderItems; + if (submitInfoDTO.getSkuId() != null) { // 直接下单 + orderItems = new ArrayList<>(); + orderItems.add(OmsOrderItem.builder().skuId(submitInfo.getSkuId()).skuQuantity(submitInfo.getSkuNumber()).build()); + } else { // 购物车下单 + CartVO cart = cartService.getCart(); + orderItems = cart.getItems().stream().map(cartItem -> OmsOrderItem.builder().skuId(cartItem.getSkuId()) + .skuQuantity(cartItem.getNum()) + .build() + ).collect(Collectors.toList()); + } + + List skuIds = orderItems.stream().map(item -> item.getSkuId()) + .collect(Collectors.toList()); + + List skus = inventoryFeignService.listBySkuIds(skuIds).getData(); + if (CollectionUtil.isEmpty(skus)) { + throw new BizException("订单商品库存为空"); + } + for (OmsOrderItem orderItem : orderItems) { + skus.stream().filter(sku -> sku.getId().equals(orderItem.getSkuId())).findFirst() + .ifPresent(skuItem -> { + BeanUtil.copyProperties(skuItem, orderItem); + orderItem.setSkuTotalPrice(orderItem.getSkuPrice() * orderItem.getSkuQuantity()); + }); + } + orderBO.setOrderItems(orderItems); }, executor); + // 生成发货信息 CompletableFuture orderDeliveryFuture = CompletableFuture.runAsync(() -> { - threadOrderSubmit.set(submit); RequestContextHolder.setRequestAttributes(attributes); - // 生成订单地址信息 - OrderDeliveryEntity orderDelivery = createOrderDelivery(); - if (orderDelivery == null) { + threadLocal.set(submitInfoDTO); + + String addressId = threadLocal.get().getAddressId(); + log.info("获取订单地址信息,addressId:{}", addressId); + UmsAddressDTO userAddress = memberFeignService.getAddressById(addressId).getData(); + if (userAddress == null) { throw new BizException("提交订单失败,无法获取用户地址信息"); } - orderVO.setOrderDeliveryEntity(orderDelivery); + OmsOrderDelivery orderDelivery = OmsOrderDelivery.builder() + .receiverName(userAddress.getName()) + .receiverPhone(userAddress.getMobile()) + .receiverPostCode(userAddress.getZipCode()) + .receiverProvince(userAddress.getProvince()) + .receiverCity(userAddress.getCity()) + .receiverRegion(userAddress.getArea()) + .receiverDetailAddress(userAddress.getAddress()) + .build(); + + orderBO.setOrderDelivery(orderDelivery); }, executor); - CompletableFuture future = CompletableFuture.allOf(orderFuture, orderGoodsFuture, orderDeliveryFuture); + CompletableFuture future = CompletableFuture.allOf(orderFuture, orderItemFuture, orderDeliveryFuture); future.get(); + + + // 订单验价 - computePrice(orderVO.getOrderEntity(), orderVO.getOrderGoods()); + computePrice(orderBO.getOmsOrder(), orderBO.getOrderGoods()); // 扣减库存 - lockStock(orderVO.getOrderGoods()); + lockStock(orderBO.getOrderGoods()); // 保存订单 - this.baseMapper.insert(orderVO.getOrderEntity()); - Long orderId = orderVO.getOrderEntity().getId(); + this.baseMapper.insert(orderBO.getOmsOrder()); + Long orderId = orderBO.getOmsOrder().getId(); // 保存订单商品 - for (OrderGoodsEntity orderGood : orderVO.getOrderGoods()) { + for (OmsOrderItem orderGood : orderBO.getOrderGoods()) { orderGood.setOrderId(orderId); - orderGoodsDao.insert(orderGood); + orderItemDao.insert(orderGood); } // 保存订单发货信息 - orderVO.getOrderDeliveryEntity().setOrderId(orderId); - orderDeliveryDao.insert(orderVO.getOrderDeliveryEntity()); + orderBO.getOmsOrderDelivery().setOrderId(orderId); + orderDeliveryDao.insert(orderBO.getOmsOrderDelivery()); // 保存订单日志 // 清空购物车 @@ -168,30 +219,23 @@ public class OrderServiceImpl extends ServiceImpl impleme cartService.cleanSelected(); } - // 将订单放入定时队列中,超时未支付系统自动关单,是否库存 + // 将订单放入定时队列中,超时未支付系统自动关单,释放库存 rabbitTemplate.convertAndSend(OmsRabbitConstants.ORDER_EVENT_EXCHANGE, - OmsRabbitConstants.ORDER_CREATE_ORDER_KEY, orderVO.getOrderEntity().getOrderSn()); + OmsRabbitConstants.ORDER_CREATE_ORDER_KEY, orderBO.getOmsOrder().getOrderSn()); - orderLogsService.addOrderLogs(orderVO.getOrderEntity().getId(), orderVO.getOrderEntity().getStatus(), RequestUtils.getUserId().toString(), "创建订单"); + orderLogsService.addOrderLogs(orderBO.getOmsOrder().getId(), orderBO.getOmsOrder().getStatus(), RequestUtils.getUserId().toString(), "创建订单"); OrderSubmitResultVO result = new OrderSubmitResultVO(); result.setId(orderId); - result.setOrderSn(orderVO.getOrderEntity().getOrderSn()); + result.setOrderSn(orderBO.getOmsOrder().getOrderSn()); return result; } - @Override - public OrderEntity getByOrderSn(String orderSn) { - log.info("根据订单号查询订单详情,orderSn={}", orderSn); - QueryWrapper query = new QueryWrapper<>(); - query.eq("order_sn", orderSn); - return baseMapper.selectOne(query); - } @Override public boolean closeOrderBySystem(String orderSn) { log.info("订单超时未支付,系统自动关闭,orderSn={}", orderSn); - OrderEntity order = getByOrderSn(orderSn); + OmsOrder order = this.getOne(new LambdaQueryWrapper().eq(OmsOrder::getOrderSn, orderSn)); if (!order.getStatus().equals(OrderStatusEnum.NEED_PAY.getCode())) { log.info("订单状态异常,系统无法自动关闭,orderSn={},orderStatus={}", orderSn, order.getStatus()); return false; @@ -208,7 +252,7 @@ public class OrderServiceImpl extends ServiceImpl impleme @Override public boolean cancelOrder(String id) { log.info("会员取消订单,orderId={}", id); - OrderEntity order = getByOrderId(id); + OmsOrder order = getByOrderId(id); if (!order.getStatus().equals(OrderStatusEnum.NEED_PAY.getCode())) { log.info("订单状态异常,会员无法取消,orderId={},orderStatus={}", id, order.getStatus()); return false; @@ -224,13 +268,13 @@ public class OrderServiceImpl extends ServiceImpl impleme @Transactional(rollbackFor = Exception.class) public boolean deleteOrder(String id) { // 查询订单,校验订单状态 - OrderEntity order = this.getByOrderId(id); + OmsOrder order = this.getByOrderId(id); if (!order.getStatus().equals(OrderStatusEnum.SYS_CANCEL.getCode()) && order.getStatus().equals(OrderStatusEnum.USER_CANCEL.getCode())) { throw new BizException(StrUtil.format("订单无法删除,订单状态【{}】", Objects.requireNonNull(OrderStatusEnum.getValue(order.getStatus())).getText())); } - orderDao.deleteById(id); + this.removeById(id); orderLogsService.addOrderLogs(order.getId(), order.getStatus(), "会员删除订单"); return true; } @@ -238,23 +282,23 @@ public class OrderServiceImpl extends ServiceImpl impleme @Override public List list(Integer status) { log.info("订单列表查询,status={}", status); - QueryWrapper orderQuery = new QueryWrapper<>(); + QueryWrapper orderQuery = new QueryWrapper<>(); if (status != 0) { orderQuery.eq("status", status); } orderQuery.orderByDesc("id"); - List orderList = this.list(orderQuery); + List orderList = this.list(orderQuery); if (orderList == null || orderList.size() <= 0) { log.info("订单列表查询结果为空,status={}", status); return null; } List orderIds = orderList.stream().map(orderEntity -> orderEntity.getId()).collect(Collectors.toList()); - Map> orderGoodsMap = orderGoodsService.getByOrderIds(orderIds); + Map> orderGoodsMap = orderGoodsService.getByOrderIds(orderIds); List result = orderList.stream().map(orderEntity -> { OrderListVO orderListVO = BeanMapperUtils.map(orderEntity, OrderListVO.class); orderListVO.setStatusDesc(OrderStatusEnum.getValue(orderListVO.getStatus()).getText()); - List orderGoodsEntities = orderGoodsMap.get(orderListVO.getId()); + List orderGoodsEntities = orderGoodsMap.get(orderListVO.getId()); if (orderGoodsEntities != null && orderGoodsEntities.size() > 0) { List goodsListBeans = orderGoodsEntities.stream().map(orderGoodsEntity -> BeanMapperUtils.map(orderGoodsEntity, OrderListVO.GoodsListBean.class)).collect(Collectors.toList()); orderListVO.setGoodsList(goodsListBeans); @@ -265,18 +309,18 @@ public class OrderServiceImpl extends ServiceImpl impleme } @Override - public OrderEntity getByOrderId(String id) { + public OmsOrder getByOrderId(String id) { Long userId = RequestUtils.getUserId(); - QueryWrapper queryWrapper = new QueryWrapper<>(); + QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("member_id", userId).eq("id", id); - OrderEntity orderEntity = this.getOne(queryWrapper); - if (orderEntity == null) { + OmsOrder omsOrder = this.getOne(queryWrapper); + if (omsOrder == null) { throw new BizException("订单不存在,订单ID非法"); } - return orderEntity; + return omsOrder; } - private void lockStock(List orderGoods) { + private void lockStock(List orderGoods) { List items = orderGoods.stream().map(good -> { InventoryDTO item = new InventoryDTO(); item.setInventoryId(good.getSkuId()); @@ -298,13 +342,13 @@ public class OrderServiceImpl extends ServiceImpl impleme * @param orderGoods * @return */ - private Long computePrice(OrderEntity order, List orderGoods) { + private Long computePrice(OmsOrder order, List orderGoods) { log.info("计算订单价格:order:{},orderGoods:{}", order, orderGoods); if (order == null || CollectionUtil.isEmpty(orderGoods)) { throw new BizException("订单或订单商品列表为空,订单创建失败"); } - Long totalAmount = orderGoods.stream().mapToLong(OrderGoodsEntity::getSkuTotalPrice).sum(); - int totalQuantity = orderGoods.stream().mapToInt(OrderGoodsEntity::getSkuQuantity).sum(); + Long totalAmount = orderGoods.stream().mapToLong(OmsOrderItem::getSkuTotalPrice).sum(); + int totalQuantity = orderGoods.stream().mapToInt(OmsOrderItem::getSkuQuantity).sum(); Long payAmount = totalAmount; if (order.getCouponAmount() != null) { payAmount -= order.getCouponAmount(); @@ -316,121 +360,32 @@ public class OrderServiceImpl extends ServiceImpl impleme order.setTotalQuantity(totalQuantity); order.setPayAmount(payAmount); - OrderSubmitVO submit = threadOrderSubmit.get(); + OrderSubmitInfoDTO submit = threadLocal.get(); if (!StrUtil.equals(submit.getPayAmount().toString(), payAmount.toString())) { throw new BizException("订单价格变化,请重新提交"); } return payAmount; - } /** - * 创建订单商品集合 + * 获取订单商品 1. 直接购买 2. 购物车结算 * * @return */ - private List createOrderGoods() { - OrderSubmitVO submit = threadOrderSubmit.get(); - log.info("创建订单商品实体类,submit:{}", submit); - List orderGoods = null; - if (ObjectUtil.isNull(submit.getSkuId())) { - CartVO detail = cartService.detail(); - log.info("从购物车中获取已选择商品信息:{}", detail); - orderGoods = detail.getItems().stream().map(item -> { - OrderGoodsEntity good = new OrderGoodsEntity(); - good.setSkuId(item.getSkuId()); - good.setSkuQuantity(item.getNumber()); - return good; - }).collect(Collectors.toList()); - } else { - log.info("会员选择商品直接下单,商品id:{}", submit.getSkuId()); - orderGoods = new ArrayList<>(); - OrderGoodsEntity good = new OrderGoodsEntity(); - good.setSkuId(Long.valueOf(submit.getSkuId())); - good.setSkuQuantity(submit.getSkuNumber()); - orderGoods.add(good); - } - - List skuIds = orderGoods.stream().map(vo -> vo.getSkuId().toString()).collect(Collectors.toList()); - Result> response = inventoryFeignService.listBySkuIds(String.join(",", skuIds)); - List skuInfos = response.getData(); - if (skuInfos == null) { - return null; - } - Map skuMap = skuInfos.stream().collect(Collectors.toMap(SkuDTO::getId, Function.identity(), (o1, o2) -> o2)); - for (OrderGoodsEntity good : orderGoods) { - SkuDTO skuInfo = skuMap.get(good.getSkuId()); - if (skuInfo == null) { - throw new BizException("订单商品库存为空"); - } - BeanMapperUtils.copy(skuInfo, good); - Long goodTotalPrice = good.getSkuPrice() * good.getSkuQuantity(); - good.setSkuTotalPrice(goodTotalPrice); - } - return orderGoods; - - } - - /** - * 生成订单数据 - * - * @return - */ - private OrderEntity createOrder() { - OrderSubmitVO submit = threadOrderSubmit.get(); - log.info("创建订单实体类,submit:{}", submit); - OrderEntity order = new OrderEntity(); - order.setOrderSn(IdWorker.getTimeId()); - order.setRemark(submit.getRemark()); - order.setStatus(OrderStatusEnum.NEED_PAY.getCode()); - order.setSourceType(OrderTypeEnum.APP.code); - order.setMemberId(RequestUtils.getUserId()); - return order; - - } - - /** - * 获取订单地址信息 - * - * @return - */ - private OrderDeliveryEntity createOrderDelivery() { - String addressId = threadOrderSubmit.get().getAddressId(); - log.info("获取订单地址信息,addressId:{}", addressId); - try { - Result response = memberFeignService.getAddressById(addressId); - UmsAddressDTO addressInfo = response.getData(); - if (addressInfo != null) { - OrderDeliveryEntity delivery = new OrderDeliveryEntity(); - delivery.setReceiverProvince(addressInfo.getProvince()); - delivery.setReceiverCity(addressInfo.getCity()); - delivery.setReceiverRegion(addressInfo.getArea()); - delivery.setReceiverDetailAddress(addressInfo.getAddress()); - delivery.setReceiverName(addressInfo.getName()); - delivery.setReceiverPostCode(addressInfo.getZipCode()); - delivery.setReceiverPhone(addressInfo.getMobile()); - return delivery; - } - } catch (Exception e) { - log.error("获取订单地址信息失败,addressId:{}", addressId, e); - } - return null; - } - - /** - * 从购物车中获取订单商品列表 - * - * @return - */ - private List getOrderItemFromCart(String skuId, Integer number) { - if (!StrUtil.isEmpty(skuId)) { - log.info("请求携带商品id:{},数量:{},订单类型为用户直接购买", skuId, number); - OrderItemVO itemVO = OrderItemVO.builder().skuId(Long.parseLong(skuId)).number(number).build(); + private List getOrderItem(Long skuId, Integer num) { + if (skuId != null) { // 直接购买 + OrderItemVO itemVO = OrderItemVO.builder() + .skuId(skuId) + .number(num) + .build(); return Arrays.asList(itemVO); - } - CartVO cartVo = cartService.detail(); - List items = cartVo.getItems().stream().filter(CartItemVO::isChecked).map(cart -> OrderItemVO.builder().skuId(cart.getSkuId()).number(cart.getNumber()).build()).collect(Collectors.toList()); + // 购物车结算,从购物车获取商品 + CartVO cart = cartService.getCart(); + List items = cart.getItems().stream() + .filter(CartItemVO::isChecked) + .map(item -> OrderItemVO.builder().skuId(item.getSkuId()).number(item.getNum()).build()) + .collect(Collectors.toList()); return items; } 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 cc789b955..b1e87d159 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 @@ -2,12 +2,12 @@ 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.pojo.entity.OrderSettingEntity; +import com.youlai.mall.oms.pojo.domain.OmsOrderSetting; import com.youlai.mall.oms.service.OrderSettingService; import org.springframework.stereotype.Service; @Service("orderSettingService") -public class OrderSettingServiceImpl extends ServiceImpl implements OrderSettingService { +public class OrderSettingServiceImpl extends ServiceImpl implements OrderSettingService { } 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 index 9c9d82fe2..b22c8664c 100644 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDao.xml +++ b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDao.xml @@ -4,7 +4,7 @@ - + @@ -28,4 +28,4 @@ - \ No newline at end of file + 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 index c93bd7a91..0acd7770a 100644 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDeliveryDao.xml +++ b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderDeliveryDao.xml @@ -4,7 +4,7 @@ - + @@ -26,4 +26,4 @@ - \ No newline at end of file + 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 index 8e9897dba..70e3e9658 100644 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderGoodsDao.xml +++ b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderGoodsDao.xml @@ -1,10 +1,10 @@ - + - + @@ -27,4 +27,4 @@ - \ No newline at end of file + 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 index e0816328e..7e60b0892 100644 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderLogsDao.xml +++ b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderLogsDao.xml @@ -1,10 +1,10 @@ - + - + @@ -17,4 +17,4 @@ - \ No newline at end of file + 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 index 171beafe0..5e5423cb3 100644 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderPayDao.xml +++ b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderPayDao.xml @@ -4,7 +4,7 @@ - + @@ -22,4 +22,4 @@ - \ No newline at end of file + 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 index 39bd7f518..2cdec7eed 100644 --- a/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderSettingDao.xml +++ b/mall-oms/oms-boot/src/main/resources/mapper/oms/OrderSettingDao.xml @@ -4,7 +4,7 @@ - + @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/mall-oms/oms-boot/src/test/java/com/youlai/mall/oms/controller/OrderControllerTest.java b/mall-oms/oms-boot/src/test/java/com/youlai/mall/oms/controller/OrderControllerTest.java index d0728042f..9bb18699d 100644 --- a/mall-oms/oms-boot/src/test/java/com/youlai/mall/oms/controller/OrderControllerTest.java +++ b/mall-oms/oms-boot/src/test/java/com/youlai/mall/oms/controller/OrderControllerTest.java @@ -3,8 +3,6 @@ package com.youlai.mall.oms.controller; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.youlai.common.result.ResultCode; import com.youlai.mall.oms.controller.admin.OrderController; -import com.youlai.mall.oms.pojo.OmsOrder; -import com.youlai.mall.oms.service.IOmsOrderService; import com.youlai.mall.pms.api.app.InventoryFeignService; import com.youlai.mall.ums.api.app.MemberFeignService; import io.seata.spring.annotation.GlobalTransactional; @@ -73,6 +71,6 @@ public class OrderControllerTest { // 增加积分 memberFeignService.updatePoint(1l, 10); // 修改订单状态 - iOmsOrderService.update(new LambdaUpdateWrapper().eq(OmsOrder::getId, 1l).set(OmsOrder::getStatus, 901)); + iOmsOrderService.update(new LambdaUpdateWrapper().eq(OmsOrder1::getId, 1l).set(OmsOrder1::getStatus, 901)); } } 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/InventoryFeignService.java index bf9e25146..06d2bcade 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/InventoryFeignService.java @@ -14,25 +14,25 @@ public interface InventoryFeignService { /** * 获取库存列表 */ - @GetMapping("/api.app/v1/skus/{ids}") - Result> listBySkuIds(@PathVariable String ids); + @GetMapping("/api.app/v1/skus") + Result> listBySkuIds(@RequestParam List ids); /** * 获取库存信息 */ @GetMapping("/api.app/v1/skus/{id}") - Result getInventoryById(@PathVariable Long id); + Result getSkuById(@PathVariable Long id); /** * 锁定库存 */ - @PostMapping("/api.app/v1/skus/batch/lock_inventory") + @PatchMapping("/api.app/v1/skus/batch/lock_inventory") Result lockInventory(@RequestBody List list); /** * 解锁库存 */ - @PostMapping("/api.app/v1/skus/batch/unlock_inventory") + @PatchMapping("/api.app/v1/skus/batch/unlock_inventory") Result unlockInventory(@RequestBody List list); diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/admin/ProductBO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/admin/ProductBO.java index 8f0476c8a..daf9c2697 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/admin/ProductBO.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/admin/ProductBO.java @@ -1,8 +1,8 @@ package com.youlai.mall.pms.pojo.bo.admin; import com.youlai.mall.pms.pojo.domain.PmsSku; -import com.youlai.mall.pms.pojo.domain.PmsAttributeValue; -import com.youlai.mall.pms.pojo.domain.PmsSpecificationValue; +import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue; +import com.youlai.mall.pms.pojo.domain.PmsSpuSpecValue; import com.youlai.mall.pms.pojo.dto.SpuDTO; import lombok.AllArgsConstructor; import lombok.Data; @@ -17,9 +17,9 @@ public class ProductBO { private SpuDTO spu; - private List attrValues; + private List attrs; - private List specValues; + private List specs; private List skus; diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/app/ProductBO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/app/ProductBO.java index 4c82f4824..0ad98885b 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/app/ProductBO.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/bo/app/ProductBO.java @@ -1,7 +1,7 @@ package com.youlai.mall.pms.pojo.bo.app; import com.youlai.mall.pms.pojo.domain.PmsSku; -import com.youlai.mall.pms.pojo.domain.PmsAttributeValue; +import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue; import com.youlai.mall.pms.pojo.domain.PmsSpecification; import com.youlai.mall.pms.pojo.dto.SpuDTO; import lombok.AllArgsConstructor; @@ -17,7 +17,7 @@ public class ProductBO { private SpuDTO spu; - private List attrValues; + private List attrs; private List specs; 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 2c9752c3b..60c1fe4b3 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 @@ -18,5 +18,5 @@ public class PmsSku extends BaseEntity { private Long price; private Integer inventory; private Integer lockedInventory; - private String specificationValueIds; + private String specValueIds; } diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecification.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecification.java index 60025e89e..4ccf4c6c1 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecification.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecification.java @@ -12,12 +12,15 @@ import java.util.List; @Data public class PmsSpecification extends BaseEntity { + /** + * 全面屏手机 颜色 版本 + */ @TableId(type = IdType.AUTO) private Long id; private Long categoryId; private String name; @TableField(exist = false) - private List values = new ArrayList<>(); + private List values = new ArrayList<>(); } diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsAttributeValue.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpuAttributeValue.java similarity index 88% rename from mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsAttributeValue.java rename to mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpuAttributeValue.java index a38f136e1..9e74549ff 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsAttributeValue.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpuAttributeValue.java @@ -10,7 +10,7 @@ import lombok.Data; * @date 2020-11-06 */ @Data -public class PmsAttributeValue extends BaseEntity { +public class PmsSpuAttributeValue extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecificationValue.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpuSpecValue.java similarity index 80% rename from mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecificationValue.java rename to mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpuSpecValue.java index 2ad5f4771..db767d4c4 100644 --- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpecificationValue.java +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsSpuSpecValue.java @@ -10,11 +10,11 @@ import lombok.Data; * @date 2020-11-06 */ @Data -public class PmsSpecificationValue extends BaseEntity { +public class PmsSpuSpecValue extends BaseEntity { @TableId(type = IdType.INPUT) private Long id; private Long spuId; - private Long specificationId; + private Long specId; private String value; } diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/app/ProductDTO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/app/ProductDTO.java new file mode 100644 index 000000000..2824ca4dd --- /dev/null +++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/app/ProductDTO.java @@ -0,0 +1,15 @@ +package com.youlai.mall.pms.pojo.dto.app; + +import lombok.Data; + +import java.util.List; + +@Data +public class ProductDTO { + + private Long id; + private String name; + private Long price; + private Integer sales; + private String pic; +} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java index 332f26811..835217975 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/CategoryController.java @@ -8,7 +8,7 @@ import com.youlai.mall.pms.pojo.domain.PmsCategory; import com.youlai.mall.pms.pojo.vo.CategoryVO; import com.youlai.mall.pms.service.IPmsAttributeService; import com.youlai.mall.pms.service.IPmsCategoryService; -import com.youlai.mall.pms.service.IPmsSpecificationService; +import com.youlai.mall.pms.service.IPmsSpecService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -31,7 +31,7 @@ public class CategoryController { private IPmsCategoryService iPmsCategoryService; private IPmsAttributeService iPmsAttributeService; - private IPmsSpecificationService iPmsSpecificationService; + private IPmsSpecService iPmsSpecService; @ApiOperation(value = "分类列表", httpMethod = "GET") @ApiImplicitParams({ @@ -91,7 +91,7 @@ public class CategoryController { Optional.ofNullable(idList).ifPresent(list -> { list.forEach(id -> { iPmsAttributeService.removeById(id); - iPmsSpecificationService.removeById(id); + iPmsSpecService.removeById(id); }); iPmsCategoryService.removeByIds(idList.stream().map(id -> Long.parseLong(id)).collect(Collectors.toList())); }); diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecController.java index 84ab805d3..397327113 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/SpecController.java @@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.youlai.common.result.Result; import com.youlai.mall.pms.pojo.domain.PmsSpecification; -import com.youlai.mall.pms.service.IPmsSpecificationService; +import com.youlai.mall.pms.service.IPmsSpecService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -23,7 +23,7 @@ import java.util.stream.Collectors; @AllArgsConstructor public class SpecController { - private IPmsSpecificationService iPmsSpecificationService; + private IPmsSpecService iPmsSpecService; @ApiOperation(value = "分类规格列表", httpMethod = "GET") @ApiImplicitParams({ @@ -31,7 +31,7 @@ public class SpecController { }) @GetMapping public Result list(Long categoryId) { - List list = iPmsSpecificationService + List list = iPmsSpecService .list(new LambdaQueryWrapper() .eq(PmsSpecification::getCategoryId, categoryId)); return Result.success(list); @@ -51,7 +51,7 @@ public class SpecController { List formIds = specCategories.stream().map(item -> item.getId()).collect(Collectors.toList()); - List databaseIds = iPmsSpecificationService + List databaseIds = iPmsSpecService .list(new LambdaQueryWrapper() .eq(PmsSpecification::getCategoryId, categoryId) .select(PmsSpecification::getId) @@ -65,10 +65,10 @@ public class SpecController { .filter(id -> CollectionUtil.isEmpty(formIds) || !formIds.contains(id)) .collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(removeIds)) { - iPmsSpecificationService.removeByIds(removeIds); + iPmsSpecService.removeByIds(removeIds); } } - boolean result = iPmsSpecificationService.saveOrUpdateBatch(specCategories); + boolean result = iPmsSpecService.saveOrUpdateBatch(specCategories); return Result.judge(result); } } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/ProductController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/ProductController.java new file mode 100644 index 000000000..9c0301325 --- /dev/null +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/ProductController.java @@ -0,0 +1,71 @@ +package com.youlai.mall.pms.controller.app; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.youlai.common.result.Result; +import com.youlai.mall.pms.pojo.bo.app.ProductBO; +import com.youlai.mall.pms.pojo.domain.PmsSpu; +import com.youlai.mall.pms.pojo.dto.app.ProductDTO; +import com.youlai.mall.pms.service.IPmsSpuService; +import com.youlai.mall.pms.service.IProductService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.stream.Collectors; + +@Api(tags = "【移动端】商品信息") +@RestController("AppSpuController") +@RequestMapping("/api.app/v1/products") +@AllArgsConstructor +public class ProductController { + + private IPmsSpuService iPmsSpuService; + + private IProductService iProductService; + + @ApiOperation(value = "列表分页", httpMethod = "GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "limit", value = "每页数量", defaultValue = "10", paramType = "query", dataType = "Long"), + @ApiImplicitParam(name = "name", value = "商品名称", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "categoryId", value = "商品类目", paramType = "query", dataType = "Long") + }) + @GetMapping + public Result list( + Integer page, + Integer limit, + String name, + Long categoryId + ) { + Page result = iPmsSpuService.page(new Page<>(page, limit), new LambdaQueryWrapper() + .eq(categoryId != null, PmsSpu::getCategoryId, categoryId) + .like(StrUtil.isNotBlank(name), PmsSpu::getName, name) + .select(PmsSpu::getId, + PmsSpu::getName, + PmsSpu::getPic, + PmsSpu::getPrice, + PmsSpu::getSales + ) + ); + List list = result.getRecords().stream() + .map(item -> JSONUtil.toBean(JSONUtil.toJsonStr(item), ProductDTO.class)) + .collect(Collectors.toList()); + return Result.success(list, result.getTotal()); + } + + @ApiOperation(value = "商品详情", httpMethod = "GET") + @ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path", dataType = "Long") + @GetMapping("/{id}") + public Result detail(@PathVariable Long id) { + ProductBO product = iProductService.getProductById(id); + return Result.success(product); + } + +} 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 923a2faa3..cecc81dd2 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 @@ -22,7 +22,6 @@ public class SkuController { private IPmsSkuService iPmsSkuService; - @ApiOperation(value = "商品库存详情", httpMethod = "GET") @ApiImplicitParam(name = "id", value = "商品库存ID", required = true, paramType = "path", dataType = "Long") @GetMapping("/{id}") @@ -44,7 +43,7 @@ public class SkuController { @ApiOperation(value = "锁定库存", httpMethod = "PUT") @ApiImplicitParam(name = "list", value = "锁定库存", required = true, paramType = "body", dataType = "InventoryNumDTO") - @PostMapping("/batch/_lock") + @PatchMapping("/batch/_lock") public Result lockInventory(@RequestBody List list) { boolean result = iPmsSkuService.lockInventory(list); return Result.judge(result); @@ -53,7 +52,7 @@ public class SkuController { @ApiOperation(value = "解锁库存", httpMethod = "PUT") @ApiImplicitParam(name = "list", value = "释放库存", required = true, paramType = "body", dataType = "InventoryNumDTO") - @PostMapping("/batch/_unlock") + @PatchMapping("/batch/_unlock") public Result unlockInventory(@RequestBody List list) { boolean result = iPmsSkuService.unlockInventory(list); return Result.judge(result); @@ -61,9 +60,9 @@ public class SkuController { @ApiOperation(value = "库存列表", httpMethod = "GET") - @ApiImplicitParam(name = "skuIds", value = "库存ID集合字符串,英文逗号,分割", required = true, paramType = "param", dataType = "String") - @GetMapping("/{ids}") - public Result list(@PathVariable String ids) { + @ApiImplicitParam(name = "skuIds", value = "库存ID集合", required = true, paramType = "body", dataType = "String") + @GetMapping + public Result list(@RequestParam List ids) { List list = iPmsSkuService.listBySkuIds(ids); return Result.success(list); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java deleted file mode 100644 index 25553b2eb..000000000 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.youlai.mall.pms.controller.app; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.youlai.common.result.Result; -import com.youlai.mall.pms.pojo.bo.app.ProductBO; -import com.youlai.mall.pms.pojo.domain.PmsSpu; -import com.youlai.mall.pms.service.IPmsSpuService; -import com.youlai.mall.pms.service.ISpuService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.*; - -@Api(tags = "【移动端】商品信息") -@RestController("AppSpuController") -@RequestMapping("/api.app/v1/spus") -@AllArgsConstructor -public class SpuController { - - private IPmsSpuService iPmsSpuService; - - private ISpuService iSpuService; - - @ApiOperation(value = "列表分页", httpMethod = "GET") - @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "name", value = "商品名称", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "categoryId", value = "商品类目", paramType = "query", dataType = "Long") - }) - @GetMapping - public Result list( - Integer page, - @RequestParam(required = false, defaultValue = "10") Integer limit, - String name, - Long categoryId - ) { - IPage result = iPmsSpuService.list( - new Page<>(page, limit), - new PmsSpu().setName(name).setCategoryId(categoryId) - ); - return Result.success(result.getRecords(), result.getTotal()); - } - - @ApiOperation(value = "商品详情", httpMethod = "GET") - @ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path", dataType = "Long") - @GetMapping("/{id}") - public Result detail(@PathVariable Long id) { - ProductBO product = iSpuService.getProductById(id); - return Result.success(product); - } - -} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java index eeac25de2..967ef702a 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSkuMapper.java @@ -39,8 +39,11 @@ public interface PmsSkuMapper extends BaseMapper { " LEFT JOIN pms_spu t2 ON t1.spu_id = t2.id", " LEFT JOIN pms_category t3 ON t2.category_id = t3.id", " LEFT JOIN pms_brand t4 ON t2.brand_id = t4.id", - " WHERE t1.id in (#{skuIds})", + " WHERE t1.id in ", + " ", + " #{skuId}", + " ", "" }) - List listBySkuIds(String skuIds); + List listBySkuIds(List skuIds); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecificationMapper.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecMapper.java similarity index 68% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecificationMapper.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecMapper.java index 76ded4493..159b1e2a3 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecificationMapper.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecMapper.java @@ -7,20 +7,20 @@ import org.apache.ibatis.annotations.*; import java.util.List; @Mapper -public interface PmsSpecificationMapper extends BaseMapper { +public interface PmsSpecMapper extends BaseMapper { @Select("") @Results({ @Result(id = true, column = "id", property = "id"), - @Result(property = "values", column = "{specificationId= t1.id,spuId=spuId}", many = @Many(select = "com.youlai.mall.pms.mapper.PmsSpecificationValueMapper.listByCondition")) + @Result(property = "values", column = "{specId= t1.id,spuId=spuId}", many = @Many(select = "com.youlai.mall.pms.mapper.PmsSpuSpecValueMapper.listByCondition")) }) List listBySpuId(Long spuId); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsAttributeValueMapper.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpuAttributeValueMapper.java similarity index 56% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsAttributeValueMapper.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpuAttributeValueMapper.java index 1387c6dd5..1ad100b7f 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsAttributeValueMapper.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpuAttributeValueMapper.java @@ -1,7 +1,7 @@ package com.youlai.mall.pms.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.youlai.mall.pms.pojo.domain.PmsAttributeValue; +import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue; import org.apache.ibatis.annotations.Mapper; /** @@ -9,6 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @date 2020-11-06 */ @Mapper -public interface PmsAttributeValueMapper extends BaseMapper { +public interface PmsSpuAttributeValueMapper extends BaseMapper { } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecificationValueMapper.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpuSpecValueMapper.java similarity index 63% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecificationValueMapper.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpuSpecValueMapper.java index 016f7396e..63346c362 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpecificationValueMapper.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsSpuSpecValueMapper.java @@ -1,7 +1,7 @@ package com.youlai.mall.pms.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.youlai.mall.pms.pojo.domain.PmsSpecificationValue; +import com.youlai.mall.pms.pojo.domain.PmsSpuSpecValue; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Mapper; @@ -13,21 +13,20 @@ import java.util.Map; * @date 2020-11-06 */ @Mapper -public interface PmsSpecificationValueMapper extends BaseMapper { - +public interface PmsSpuSpecValueMapper extends BaseMapper { @Select("") - List listByCondition(Map param); + List listByCondition(Map param); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsAttributeValueService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsAttributeValueService.java deleted file mode 100644 index b75c4029b..000000000 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsAttributeValueService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.youlai.mall.pms.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.pms.pojo.domain.PmsAttributeValue; - - -public interface IPmsAttributeValueService extends IService { - - -} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java index b07c1d7dc..e3f4d7b6d 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSkuService.java @@ -37,5 +37,5 @@ public interface IPmsSkuService extends IService { * @param ids * @return */ - List listBySkuIds(String ids); + List listBySkuIds(List ids); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecService.java similarity index 74% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationService.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecService.java index c2f7eac90..20ec0f783 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationService.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecService.java @@ -5,7 +5,7 @@ import com.youlai.mall.pms.pojo.domain.PmsSpecification; import java.util.List; -public interface IPmsSpecificationService extends IService { +public interface IPmsSpecService extends IService { List listBySpuId(Long spuId); diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationValueService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationValueService.java deleted file mode 100644 index ea8fce062..000000000 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpecificationValueService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.youlai.mall.pms.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.mall.pms.pojo.domain.PmsSpecificationValue; - - -public interface IPmsSpecificationValueService extends IService { - -} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuAttributeValueService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuAttributeValueService.java new file mode 100644 index 000000000..8a7f58711 --- /dev/null +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuAttributeValueService.java @@ -0,0 +1,10 @@ +package com.youlai.mall.pms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue; + + +public interface IPmsSpuAttributeValueService extends IService { + + +} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuSpecValueService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuSpecValueService.java new file mode 100644 index 000000000..e06b64980 --- /dev/null +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsSpuSpecValueService.java @@ -0,0 +1,9 @@ +package com.youlai.mall.pms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.youlai.mall.pms.pojo.domain.PmsSpuSpecValue; + + +public interface IPmsSpuSpecValueService extends IService { + +} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/ISpuService.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IProductService.java similarity index 79% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/ISpuService.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IProductService.java index 81f47f363..ba9684392 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/ISpuService.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IProductService.java @@ -5,7 +5,7 @@ import com.youlai.mall.pms.pojo.bo.app.ProductBO; import com.youlai.mall.pms.pojo.domain.PmsSpu; -public interface ISpuService extends IService { +public interface IProductService extends IService { ProductBO getProductById(Long id); } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeValueServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeValueServiceImpl.java deleted file mode 100644 index 6df033154..000000000 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsAttributeValueServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.youlai.mall.pms.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.pms.pojo.domain.PmsAttributeValue; -import com.youlai.mall.pms.mapper.PmsAttributeValueMapper; -import com.youlai.mall.pms.service.IPmsAttributeValueService; -import org.springframework.stereotype.Service; - -/** - * @author haoxr - * @date 2020-12-12 - */ -@Service -public class PmsAttributeValueServiceImpl extends ServiceImpl implements IPmsAttributeValueService { - - -} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java index 20b0720f0..f8a18267e 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSkuServiceImpl.java @@ -97,7 +97,7 @@ public class PmsSkuServiceImpl extends ServiceImpl impleme } @Override - public List listBySkuIds(String ids) { - return this.listBySkuIds(ids); + public List listBySkuIds(List ids) { + return this.baseMapper.listBySkuIds(ids); } } diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecServiceImpl.java similarity index 64% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationServiceImpl.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecServiceImpl.java index 0606ecd8e..fa9852002 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecServiceImpl.java @@ -1,9 +1,9 @@ package com.youlai.mall.pms.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.pms.mapper.PmsSpecificationMapper; +import com.youlai.mall.pms.mapper.PmsSpecMapper; import com.youlai.mall.pms.pojo.domain.PmsSpecification; -import com.youlai.mall.pms.service.IPmsSpecificationService; +import com.youlai.mall.pms.service.IPmsSpecService; import org.springframework.stereotype.Service; import java.util.List; @@ -13,7 +13,7 @@ import java.util.List; * @date 2020-11-06 */ @Service -public class PmsSpecificationServiceImpl extends ServiceImpl implements IPmsSpecificationService { +public class PmsSpecServiceImpl extends ServiceImpl implements IPmsSpecService { @Override public List listBySpuId(Long spuId) { diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationValueServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationValueServiceImpl.java deleted file mode 100644 index a4cfba795..000000000 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpecificationValueServiceImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.youlai.mall.pms.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.pms.pojo.domain.PmsSpecificationValue; -import com.youlai.mall.pms.mapper.PmsSpecificationValueMapper; -import com.youlai.mall.pms.service.IPmsSpecificationValueService; -import org.springframework.stereotype.Service; - -/** - * @author haoxr - * @date 2020-11-06 - */ -@Service -public class PmsSpecificationValueServiceImpl extends ServiceImpl implements IPmsSpecificationValueService { - -} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuAttributeValueServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuAttributeValueServiceImpl.java new file mode 100644 index 000000000..13c9ec195 --- /dev/null +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuAttributeValueServiceImpl.java @@ -0,0 +1,17 @@ +package com.youlai.mall.pms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue; +import com.youlai.mall.pms.mapper.PmsSpuAttributeValueMapper; +import com.youlai.mall.pms.service.IPmsSpuAttributeValueService; +import org.springframework.stereotype.Service; + +/** + * @author haoxr + * @date 2020-12-12 + */ +@Service +public class PmsSpuAttributeValueServiceImpl extends ServiceImpl implements IPmsSpuAttributeValueService { + + +} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java index cf66515a4..398478716 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java @@ -29,9 +29,9 @@ import java.util.stream.Collectors; public class PmsSpuServiceImpl extends ServiceImpl implements IPmsSpuService { private IPmsSkuService iPmsSkuService; - private IPmsAttributeValueService iPmsAttributeValueService; - private IPmsSpecificationValueService iPmsSpecificationValueService; - private IPmsSpecificationService iPmsSpecificationService; + private IPmsSpuAttributeValueService iPmsSpuAttributeValueService; + private IPmsSpuSpecValueService iPmsSpuSpecValueService; + private IPmsSpecService iPmsSpecService; @Override @@ -45,8 +45,8 @@ public class PmsSpuServiceImpl extends ServiceImpl imp @Transactional public boolean add(ProductBO spuBO) { SpuDTO SpuDTO = spuBO.getSpu(); - List attrValues = spuBO.getAttrValues(); - List specs = spuBO.getSpecValues(); + List attrValues = spuBO.getAttrs(); + List specs = spuBO.getSpecs(); List skuList = spuBO.getSkus(); // spu保存 @@ -61,13 +61,13 @@ public class PmsSpuServiceImpl extends ServiceImpl imp // 属性保存 Optional.ofNullable(attrValues).ifPresent(list -> { list.forEach(item -> item.setSpuId(spu.getId())); - iPmsAttributeValueService.saveBatch(list); + iPmsSpuAttributeValueService.saveBatch(list); }); // 规格保存 Optional.ofNullable(specs).ifPresent(list -> { list.forEach(item -> item.setSpuId(spu.getId())); - iPmsSpecificationValueService.saveBatch(list); + iPmsSpuSpecValueService.saveBatch(list); }); // sku保存 @@ -93,10 +93,10 @@ public class PmsSpuServiceImpl extends ServiceImpl imp } // 属性 - List attrs = iPmsAttributeValueService. - list(new LambdaQueryWrapper().eq(PmsAttributeValue::getSpuId, id)); + List attrs = iPmsSpuAttributeValueService. + list(new LambdaQueryWrapper().eq(PmsSpuAttributeValue::getSpuId, id)); // 规格 - List specs = iPmsSpecificationValueService.list(new LambdaQueryWrapper().eq(PmsSpecificationValue::getSpuId, id)); + List specs = iPmsSpuSpecValueService.list(new LambdaQueryWrapper().eq(PmsSpuSpecValue::getSpuId, id)); // sku List skus = iPmsSkuService.list(new LambdaQueryWrapper().eq(PmsSku::getSpuId, id)); @@ -110,8 +110,8 @@ public class PmsSpuServiceImpl extends ServiceImpl imp public boolean updateById(com.youlai.mall.pms.pojo.bo.admin.ProductBO spuBO) { SpuDTO SpuDTO = spuBO.getSpu(); - List attrValues = spuBO.getAttrValues(); - List specs = spuBO.getSpecValues(); + List attrValues = spuBO.getAttrs(); + List specs = spuBO.getSpecs(); List skuList = spuBO.getSkus(); // spu保存 @@ -129,15 +129,15 @@ public class PmsSpuServiceImpl extends ServiceImpl imp // 删除此次保存删除的 List ids = list.stream().map(item -> item.getId()).collect(Collectors.toList()); - List dbIds = iPmsAttributeValueService.list(new LambdaQueryWrapper().eq(PmsAttributeValue::getSpuId, spu.getId()) - .select(PmsAttributeValue::getId)) + List dbIds = iPmsSpuAttributeValueService.list(new LambdaQueryWrapper().eq(PmsSpuAttributeValue::getSpuId, spu.getId()) + .select(PmsSpuAttributeValue::getId)) .stream() .map(item -> item.getId()) .collect(Collectors.toList()); List removeIds = dbIds.stream().filter(id -> !ids.contains(id)).collect(Collectors.toList()); - iPmsAttributeValueService.removeByIds(removeIds); + iPmsSpuAttributeValueService.removeByIds(removeIds); - iPmsAttributeValueService.saveOrUpdateBatch(list); + iPmsSpuAttributeValueService.saveOrUpdateBatch(list); }); // 规格保存 @@ -146,15 +146,15 @@ public class PmsSpuServiceImpl extends ServiceImpl imp // 删除此次保存删除的 List ids = list.stream().map(item -> item.getId()).collect(Collectors.toList()); - List dbIds = iPmsSpecificationValueService.list(new LambdaQueryWrapper().eq(PmsSpecificationValue::getSpuId, spu.getId()) - .select(PmsSpecificationValue::getId)) + List dbIds = iPmsSpuSpecValueService.list(new LambdaQueryWrapper().eq(PmsSpuSpecValue::getSpuId, spu.getId()) + .select(PmsSpuSpecValue::getId)) .stream() .map(item -> item.getId()) .collect(Collectors.toList()); List removeIds = dbIds.stream().filter(id -> !ids.contains(id)).collect(Collectors.toList()); - iPmsSpecificationValueService.removeByIds(removeIds); + iPmsSpuSpecValueService.removeByIds(removeIds); - iPmsSpecificationValueService.saveOrUpdateBatch(list); + iPmsSpuSpecValueService.saveOrUpdateBatch(list); }); // sku保存 @@ -183,9 +183,9 @@ public class PmsSpuServiceImpl extends ServiceImpl imp // sku iPmsSkuService.remove(new LambdaQueryWrapper().eq(PmsSku::getSpuId, spuId)); // 规格 - iPmsSpecificationValueService.remove(new LambdaQueryWrapper().eq(PmsSpecificationValue::getId, spuId)); + iPmsSpuSpecValueService.remove(new LambdaQueryWrapper().eq(PmsSpuSpecValue::getId, spuId)); // 属性 - iPmsAttributeValueService.remove(new LambdaQueryWrapper().eq(PmsAttributeValue::getSpuId, spuId)); + iPmsSpuAttributeValueService.remove(new LambdaQueryWrapper().eq(PmsSpuAttributeValue::getSpuId, spuId)); // spu this.removeById(spuId); }) @@ -205,13 +205,13 @@ public class PmsSpuServiceImpl extends ServiceImpl imp SpuDTO.setPics(pics); } // 属性 - List attrs = iPmsAttributeValueService.list( - new LambdaQueryWrapper( - ).eq(PmsAttributeValue::getSpuId, spuId) + List attrs = iPmsSpuAttributeValueService.list( + new LambdaQueryWrapper( + ).eq(PmsSpuAttributeValue::getSpuId, spuId) ); // 规格 - List specs = iPmsSpecificationService.listBySpuId(spuId); + List specs = iPmsSpecService.listBySpuId(spuId); // sku List skuList = iPmsSkuService.list(new LambdaQueryWrapper().eq(PmsSku::getSpuId, spuId)); diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuSpecValueServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuSpecValueServiceImpl.java new file mode 100644 index 000000000..fb268c399 --- /dev/null +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuSpecValueServiceImpl.java @@ -0,0 +1,16 @@ +package com.youlai.mall.pms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.mall.pms.pojo.domain.PmsSpuSpecValue; +import com.youlai.mall.pms.mapper.PmsSpuSpecValueMapper; +import com.youlai.mall.pms.service.IPmsSpuSpecValueService; +import org.springframework.stereotype.Service; + +/** + * @author haoxr + * @date 2020-11-06 + */ +@Service +public class PmsSpuSpecValueServiceImpl extends ServiceImpl implements IPmsSpuSpecValueService { + +} diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/SpuServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/ProductServiceImpl.java similarity index 68% rename from mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/SpuServiceImpl.java rename to mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/ProductServiceImpl.java index 9a801aa3c..4bcccd84e 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/SpuServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/ProductServiceImpl.java @@ -7,15 +7,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.mall.pms.mapper.PmsProductMapper; import com.youlai.mall.pms.pojo.bo.app.ProductBO; -import com.youlai.mall.pms.pojo.domain.PmsAttributeValue; +import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue; import com.youlai.mall.pms.pojo.domain.PmsSku; import com.youlai.mall.pms.pojo.domain.PmsSpecification; import com.youlai.mall.pms.pojo.domain.PmsSpu; import com.youlai.mall.pms.pojo.dto.SpuDTO; -import com.youlai.mall.pms.service.IPmsAttributeValueService; +import com.youlai.mall.pms.service.IPmsSpuAttributeValueService; import com.youlai.mall.pms.service.IPmsSkuService; -import com.youlai.mall.pms.service.IPmsSpecificationService; -import com.youlai.mall.pms.service.ISpuService; +import com.youlai.mall.pms.service.IPmsSpecService; +import com.youlai.mall.pms.service.IProductService; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @@ -27,11 +27,11 @@ import java.util.List; */ @Service @AllArgsConstructor -public class SpuServiceImpl extends ServiceImpl implements ISpuService { +public class ProductServiceImpl extends ServiceImpl implements IProductService { private IPmsSkuService iPmsSkuService; - private IPmsAttributeValueService iPmsAttributeValueService; - private IPmsSpecificationService iPmsSpecificationService; + private IPmsSpuAttributeValueService iPmsSpuAttributeValueService; + private IPmsSpecService iPmsSpecService; @Override public ProductBO getProductById(Long spuId) { @@ -45,13 +45,13 @@ public class SpuServiceImpl extends ServiceImpl implem SpuDTO.setPics(pics); } // 属性 - List attrs = iPmsAttributeValueService.list( - new LambdaQueryWrapper( - ).eq(PmsAttributeValue::getSpuId, spuId) + List attrs = iPmsSpuAttributeValueService.list( + new LambdaQueryWrapper( + ).eq(PmsSpuAttributeValue::getSpuId, spuId) ); // 规格 - List specs = iPmsSpecificationService.listBySpuId(spuId); + List specs = iPmsSpecService.listBySpuId(spuId); // sku List skuList = iPmsSkuService.list(new LambdaQueryWrapper().eq(PmsSku::getSpuId, spuId)); diff --git a/mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/SpuControllerTest.java b/mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/ProductControllerTest.java similarity index 93% rename from mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/SpuControllerTest.java rename to mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/ProductControllerTest.java index b21b52729..b20125952 100644 --- a/mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/SpuControllerTest.java +++ b/mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/ProductControllerTest.java @@ -4,8 +4,8 @@ import com.youlai.common.result.ResultCode; import com.youlai.mall.pms.pojo.bo.app.ProductBO; import com.youlai.mall.pms.controller.admin.SpuController; import com.youlai.mall.pms.pojo.domain.PmsSpecification; -import com.youlai.mall.pms.service.IPmsAttributeValueService; -import com.youlai.mall.pms.service.IPmsSpecificationService; +import com.youlai.mall.pms.service.IPmsSpuAttributeValueService; +import com.youlai.mall.pms.service.IPmsSpecService; import com.youlai.mall.pms.service.IPmsSpuService; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -26,7 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers. @AutoConfigureMockMvc @SpringBootTest @Slf4j -public class SpuControllerTest { +public class ProductControllerTest { @Autowired public MockMvc mockMvc; @@ -51,16 +51,16 @@ public class SpuControllerTest { } @Autowired - public IPmsSpecificationService iPmsSpecificationService; + public IPmsSpecService iPmsSpecService; @Test public void getProductSpecList() { - List specifications = iPmsSpecificationService.listBySpuId(1l); + List specifications = iPmsSpecService.listBySpuId(1l); log.info(specifications.toString()); } @Autowired - public IPmsAttributeValueService iPmsAttributeValueService; + public IPmsSpuAttributeValueService iPmsSpuAttributeValueService; diff --git a/youlai-auth/src/main/java/com/youlai/auth/controller/AuthController.java b/youlai-auth/src/main/java/com/youlai/auth/controller/AuthController.java index 353989795..0c34796c9 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/controller/AuthController.java +++ b/youlai-auth/src/main/java/com/youlai/auth/controller/AuthController.java @@ -23,6 +23,7 @@ import me.chanjar.weixin.common.error.WxErrorException; import org.apache.logging.log4j.util.Strings; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.PostMapping;