diff --git a/mall-oms/oms-api/pom.xml b/mall-oms/oms-api/pom.xml
index e8cc7ed43..185f4f82f 100644
--- a/mall-oms/oms-api/pom.xml
+++ b/mall-oms/oms-api/pom.xml
@@ -29,6 +29,7 @@
ums-api
${youlai.version}
+
diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderStatusEnum.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderStatusEnum.java
new file mode 100644
index 000000000..77e72033a
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderStatusEnum.java
@@ -0,0 +1,33 @@
+package com.youlai.mall.oms.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+/**
+ * @author huawei
+ * @desc
+ * @email huawei_code@163.com
+ * @date 2021/1/16
+ */
+@ToString
+@AllArgsConstructor
+public enum OrderStatusEnum {
+
+ NEED_PAY(101, "待支付"),
+ USER_CANCEL(102, "用户取消"),
+ SYS_CANCEL(103, "系统自动取消"),
+ IS_PAY(201, "已支付"),
+ APPLY_REFUND(202, "申请退款"),
+ IS_REFUND(203, "已退款"),
+ NEED_DELIVER(301, "待发货"),
+ IS_DELIVER(402, "已发货"),
+ USER_RECEIVE(501, "用户收货"),
+ SYS_RECEIVE(502, "系统自动收货"),
+ FINISH(901, "已完成"),
+ ;
+ public final Integer code;
+
+ public final String desc;
+
+
+}
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
new file mode 100644
index 000000000..57a322c53
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/enums/OrderTypeEnum.java
@@ -0,0 +1,24 @@
+package com.youlai.mall.oms.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+/**
+ * @author huawei
+ * @desc 订单来源类型枚举
+ * @email huawei_code@163.com
+ * @date 2021/1/16
+ */
+@ToString
+@AllArgsConstructor
+public enum OrderTypeEnum {
+
+ WEB(0, "PC订单"),
+ APP(1, "APP订单"),
+ ;
+ public final Integer code;
+
+ public final String desc;
+
+
+}
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/entity/OrderDeliveryEntity.java
index 3d0ad0d51..1cb612436 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/entity/OrderDeliveryEntity.java
@@ -1,11 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
-import java.io.Serializable;
import java.util.Date;
/**
@@ -22,7 +22,7 @@ public class OrderDeliveryEntity extends BaseEntity {
/**
* id
*/
- @TableId
+ @TableId(type = IdType.AUTO)
private Long id;
/**
* 订单id
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/entity/OrderEntity.java
index f587e93c0..41699ee41 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/entity/OrderEntity.java
@@ -1,11 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
-import java.io.Serializable;
import java.util.Date;
/**
@@ -22,7 +22,7 @@ public class OrderEntity extends BaseEntity {
/**
* id
*/
- @TableId
+ @TableId(type = IdType.AUTO)
private Long id;
/**
* 订单号
@@ -51,7 +51,7 @@ public class OrderEntity extends BaseEntity {
/**
* 会员id
*/
- private Long userId;
+ private Long memberId;
/**
* 使用的优惠券
*/
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/entity/OrderGoodsEntity.java
index 25408bdfd..50514b0b8 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/entity/OrderGoodsEntity.java
@@ -1,12 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
-import java.util.Date;
-
/**
* 订单商品信息表
*
@@ -21,7 +20,7 @@ public class OrderGoodsEntity extends BaseEntity {
/**
* id
*/
- @TableId
+ @TableId(type = IdType.AUTO)
private Long id;
/**
* order_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/entity/OrderLogsEntity.java
index 8623cf4a9..f7630282a 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/entity/OrderLogsEntity.java
@@ -1,13 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
-import java.io.Serializable;
-import java.util.Date;
-
/**
* 订单操作历史记录
*
@@ -22,7 +20,7 @@ public class OrderLogsEntity extends BaseEntity {
/**
* id
*/
- @TableId
+ @TableId(type = IdType.AUTO)
private Long id;
/**
* 订单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/entity/OrderPayEntity.java
index 93b04ddc9..c94c889fb 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/entity/OrderPayEntity.java
@@ -1,11 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
-import java.io.Serializable;
import java.util.Date;
/**
@@ -22,7 +22,7 @@ public class OrderPayEntity extends BaseEntity {
/**
* id
*/
- @TableId
+ @TableId(type = IdType.AUTO)
private Long id;
/**
* 订单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/entity/OrderSettingEntity.java
index d56159410..5e65b2b28 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/entity/OrderSettingEntity.java
@@ -1,13 +1,11 @@
package com.youlai.mall.oms.pojo.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import lombok.Data;
-import java.io.Serializable;
-import java.util.Date;
-
/**
* 订单配置信息
*
@@ -22,7 +20,7 @@ public class OrderSettingEntity extends BaseEntity {
/**
* id
*/
- @TableId
+ @TableId(type = IdType.AUTO)
private Long id;
/**
* 秒杀订单超时关闭时间(分)
diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java
new file mode 100644
index 000000000..f11dfe6f8
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CouponVO.java
@@ -0,0 +1,18 @@
+package com.youlai.mall.oms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+/**
+ * @author huawei
+ * @desc 优惠券信息
+ * @email huawei_code@163.com
+ * @date 2021/1/13
+ */
+@Data
+public class CouponVO extends BaseVO {
+
+ private String title;
+
+ private Long price;
+}
diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/MemberAddressVO.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/MemberAddressVO.java
new file mode 100644
index 000000000..0b1d3be50
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/MemberAddressVO.java
@@ -0,0 +1,7 @@
+package com.youlai.mall.oms.pojo.vo;
+
+/**
+ * 会员收货地址列表
+ */
+public class MemberAddressVO {
+}
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
new file mode 100644
index 000000000..af404803a
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderConfirmVO.java
@@ -0,0 +1,64 @@
+package com.youlai.mall.oms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 订单确认页需要的数据
+ */
+
+public class OrderConfirmVO extends BaseVO {
+
+
+ /**
+ * 商品列表
+ */
+ @Getter
+ @Setter
+ private List items;
+
+ // 发票信息
+
+ // 优惠券信息
+ @Getter
+ @Setter
+ private List coupons;
+
+ // 积分信息
+ @Getter
+ @Setter
+ private Integer integration;
+
+
+
+ /**
+ * 订单总额
+ */
+ @Setter
+ private Long totalPrice;
+
+ /**
+ * 应付价格
+ */
+ @Setter
+ private Long payPrice;
+
+ public Long getTotalPrice() {
+ Long total = 0L;
+ if (items != null && items.size() > 0) {
+ total = items.stream().mapToLong(OrderItemVO::getSubTotal).sum();
+ }
+ return total;
+ }
+
+ public Long getPayPrice() {
+ Long total = 0L;
+ if (items != null && items.size() > 0) {
+ 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
new file mode 100644
index 000000000..2b836b265
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderItemVO.java
@@ -0,0 +1,66 @@
+package com.youlai.mall.oms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 订单商品
+ */
+@Builder
+public class OrderItemVO extends BaseVO {
+
+ /**
+ * 商品id
+ */
+ @Getter
+ @Setter
+ private Long skuId;
+
+ /**
+ * 商品图片
+ */
+ @Getter
+ @Setter
+ private String skuImg;
+
+ /**
+ * 商品名称
+ */
+ @Getter
+ @Setter
+ private String skuName;
+
+ /**
+ * 商品数量
+ */
+ @Getter
+ @Setter
+ private Integer number;
+
+ /**
+ * 商品单价
+ */
+ @Getter
+ @Setter
+ private Long price;
+
+ @Getter
+ @Setter
+ private Long coupon = 0L;
+
+ /**
+ * 小计
+ */
+ @Setter
+ private Long subTotal;
+
+ public Long getSubTotal() {
+ Long total = 0L;
+ if (price != null && number != null){
+ total = price * number;
+ }
+ return total;
+ }
+}
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
new file mode 100644
index 000000000..c32950898
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitResultVO.java
@@ -0,0 +1,24 @@
+package com.youlai.mall.oms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+/**
+ * @author huawei
+ * @desc 订单创建响应结果VO
+ * @email huawei_code@163.com
+ * @date 2021/1/21
+ */
+@Data
+public class OrderSubmitResultVO extends BaseVO {
+
+ /**
+ * 订单id
+ */
+ private Long id;
+
+ /**
+ * 订单号
+ */
+ private String orderSn;
+}
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/vo/OrderSubmitVO.java
new file mode 100644
index 000000000..c78f35d8c
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderSubmitVO.java
@@ -0,0 +1,46 @@
+package com.youlai.mall.oms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+/**
+ * @author huawei
+ * @desc 订单提交实体类
+ * @email huawei_code@163.com
+ * @date 2021/1/16
+ */
+@Data
+public class OrderSubmitVO extends BaseVO {
+
+ /**
+ * 用户选择地址id
+ */
+ @NotBlank(message = "请选择收货地址")
+ private String addressId;
+
+ /**
+ * 如果携带skuId则表示该订单通过直接下单方式生成
+ * 否则从购物车中生成 -- 清空购物车
+ */
+ private String skuId;
+
+ /**
+ * 直接下单时商品数量
+ */
+ private Integer skuNumber;
+
+ /**
+ * 优惠券id
+ */
+ private String couponId;
+
+ @Size(max = 500, message = "订单备注长度不能超过500")
+ private String remark;
+
+
+ private Long payAmount;
+
+}
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
new file mode 100644
index 000000000..8a8c1c521
--- /dev/null
+++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/OrderVO.java
@@ -0,0 +1,29 @@
+package com.youlai.mall.oms.pojo.vo;
+
+import com.youlai.common.core.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-pms/pms-api/src/main/java/com/youlai/mall/pms/api/ProductFeignService.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/ProductFeignService.java
index 7d2b7bf5b..a585bf774 100644
--- a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/ProductFeignService.java
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/api/ProductFeignService.java
@@ -2,17 +2,28 @@ package com.youlai.mall.pms.api;
import com.youlai.common.core.result.Result;
import com.youlai.mall.pms.pojo.dto.SkuDTO;
+import com.youlai.mall.pms.pojo.vo.SkuInfoVO;
+import com.youlai.mall.pms.pojo.vo.WareSkuStockVO;
import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
@FeignClient("mall-pms")
public interface ProductFeignService {
+ /**
+ * 批量获取商品详情
+ *
+ * @param skuIds
+ * @return
+ */
+ @GetMapping("/api.app/v1/sku/infos")
+ Result> infos(@RequestParam("skuId") List skuIds);
+
/**
* 获取商品信息
+ *
* @param id
* @return
*/
@@ -25,4 +36,13 @@ public interface ProductFeignService {
@PutMapping("/api.admin/v1/sku/{id}/stock")
Result updateStock(@PathVariable Long id, @RequestParam Integer num);
+ /**
+ * 订单下单锁定库存
+ *
+ * @param skuStockVO
+ * @return
+ */
+ @PostMapping("/api.app/v1/sku/stock/lock")
+ Result lockStock(@RequestBody WareSkuStockVO skuStockVO);
+
}
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuInfoDTO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuInfoDTO.java
new file mode 100644
index 000000000..08ee0c96c
--- /dev/null
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/dto/SkuInfoDTO.java
@@ -0,0 +1,77 @@
+package com.youlai.mall.pms.pojo.dto;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+/**
+ * @author huawei
+ * @desc
+ * @email huawei_code@163.com
+ * @date 2021/1/13
+ */
+@Data
+public class SkuInfoDTO extends BaseVO {
+
+ private Long id;
+
+ /**
+ * 商品sku id
+ */
+ private Long skuId;
+ /**
+ * 商品sku编号
+ */
+ private String skuCode;
+ /**
+ * 商品sku名字
+ */
+ private String skuName;
+ /**
+ * 商品sku图片
+ */
+ private String skuPic;
+
+ /**
+ * 商品原始价格
+ */
+ private Long skuOriginPrice;
+ /**
+ * 商品sku价格(分)
+ */
+ private Long skuPrice;
+
+ /**
+ * 商品库存
+ */
+ private Integer stock;
+
+ /**
+ * spu_id
+ */
+ private Long spuId;
+ /**
+ * spu_name
+ */
+ private String spuName;
+ /**
+ * spu_pic
+ */
+ private String spuPic;
+ /**
+ * 品牌id
+ */
+ private Long brandId;
+ /**
+ * 品牌名称
+ */
+ private String brandName;
+ /**
+ * 商品分类id
+ */
+ private Long categoryId;
+ /**
+ * 商品分类名称
+ */
+ private String categoryName;
+
+}
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/LockStockResultVO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/LockStockResultVO.java
new file mode 100644
index 000000000..5a0cded27
--- /dev/null
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/LockStockResultVO.java
@@ -0,0 +1,20 @@
+package com.youlai.mall.pms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+/**
+ * @author huawei
+ * @desc 订单锁定库存 VO
+ * @email huawei_code@163.com
+ * @date 2021/1/16
+ */
+@Data
+public class LockStockResultVO extends BaseVO {
+
+ private Long skuId;
+
+ private String skuName;
+
+ private boolean locked;
+}
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java
new file mode 100644
index 000000000..17fdf9a45
--- /dev/null
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/OrderItemVO.java
@@ -0,0 +1,66 @@
+package com.youlai.mall.pms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 订单商品
+ */
+@Builder
+public class OrderItemVO extends BaseVO {
+
+ /**
+ * 商品id
+ */
+ @Getter
+ @Setter
+ private Long skuId;
+
+ /**
+ * 商品图片
+ */
+ @Getter
+ @Setter
+ private String skuImg;
+
+ /**
+ * 商品名称
+ */
+ @Getter
+ @Setter
+ private String skuName;
+
+ /**
+ * 商品数量
+ */
+ @Getter
+ @Setter
+ private Integer number;
+
+ /**
+ * 商品单价
+ */
+ @Getter
+ @Setter
+ private Long price;
+
+ @Getter
+ @Setter
+ private Long coupon = 0L;
+
+ /**
+ * 小计
+ */
+ @Setter
+ private Long subTotal;
+
+ public Long getSubTotal() {
+ Long total = 0L;
+ if (price != null && number != null){
+ total = price * number;
+ }
+ return total;
+ }
+}
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/SkuInfoVO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/SkuInfoVO.java
new file mode 100644
index 000000000..b927d8c4d
--- /dev/null
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/SkuInfoVO.java
@@ -0,0 +1,77 @@
+package com.youlai.mall.pms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+/**
+ * @author huawei
+ * @desc
+ * @email huawei_code@163.com
+ * @date 2021/1/13
+ */
+@Data
+public class SkuInfoVO extends BaseVO {
+
+ private Long id;
+
+ /**
+ * 商品sku id
+ */
+ private Long skuId;
+ /**
+ * 商品sku编号
+ */
+ private String skuCode;
+ /**
+ * 商品sku名字
+ */
+ private String skuName;
+ /**
+ * 商品sku图片
+ */
+ private String skuPic;
+
+ /**
+ * 商品原始价格
+ */
+ private Long skuOriginPrice;
+ /**
+ * 商品sku价格(分)
+ */
+ private Long skuPrice;
+
+ /**
+ * 商品库存
+ */
+ private Integer stock;
+
+ /**
+ * spu_id
+ */
+ private Long spuId;
+ /**
+ * spu_name
+ */
+ private String spuName;
+ /**
+ * spu_pic
+ */
+ private String spuPic;
+ /**
+ * 品牌id
+ */
+ private Long brandId;
+ /**
+ * 品牌名称
+ */
+ private String brandName;
+ /**
+ * 商品分类id
+ */
+ private Long categoryId;
+ /**
+ * 商品分类名称
+ */
+ private String categoryName;
+
+}
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/SkuStockVO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/SkuStockVO.java
new file mode 100644
index 000000000..a17981485
--- /dev/null
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/SkuStockVO.java
@@ -0,0 +1,18 @@
+package com.youlai.mall.pms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+/**
+ * @author huawei
+ * @desc 商品库存信息
+ * @email huawei_code@163.com
+ * @date 2021/1/21
+ */
+@Data
+public class SkuStockVO extends BaseVO {
+
+ private Long skuId;
+
+ private Integer number;
+}
diff --git a/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/WareSkuStockVO.java b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/WareSkuStockVO.java
new file mode 100644
index 000000000..faf611eef
--- /dev/null
+++ b/mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/vo/WareSkuStockVO.java
@@ -0,0 +1,18 @@
+package com.youlai.mall.pms.pojo.vo;
+
+import com.youlai.common.core.base.BaseVO;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author huawei
+ * @desc 锁定库存VO
+ * @email huawei_code@163.com
+ * @date 2021/1/16
+ */
+@Data
+public class WareSkuStockVO extends BaseVO {
+
+ private List items;
+}
diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignService.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignService.java
index 615b0c46d..30368c046 100644
--- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignService.java
+++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignService.java
@@ -4,6 +4,7 @@ import com.youlai.common.core.result.Result;
import com.youlai.mall.ums.pojo.UmsUser;
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
import com.youlai.mall.ums.pojo.dto.MemberDTO;
+import com.youlai.mall.ums.pojo.dto.UmsAddressDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -33,6 +34,15 @@ public interface MemberFeignService {
@PutMapping("/api.admin/v1/users/{id}/point")
Result updatePoint(@PathVariable Long id, @RequestParam Integer num);
+ /**
+ * 获取地址详情
+ *
+ * @param id 地址id
+ * @return 地址详情
+ */
+ @GetMapping("/api.app/v1/addresses/{id}")
+ Result getAddressById(@PathVariable("id") String id);
+
}
diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsAddress.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsAddress.java
index c47d70602..5b076ab41 100644
--- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsAddress.java
+++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsAddress.java
@@ -25,7 +25,7 @@ public class UmsAddress extends BaseEntity {
private String city;
- private String area;
+ private String area;
private String address;
diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsUser.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsUser.java
index 8666cf5e9..b3262e695 100644
--- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsUser.java
+++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/UmsUser.java
@@ -49,6 +49,7 @@ public class UmsUser {
@TableField(exist = false)
private List addressList;
+ @TableField(exist = false)
private Integer balance;
}
diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java
new file mode 100644
index 000000000..75cbc2143
--- /dev/null
+++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/pojo/dto/UmsAddressDTO.java
@@ -0,0 +1,33 @@
+package com.youlai.mall.ums.pojo.dto;
+
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+
+@Data
+@Accessors(chain = true)
+public class UmsAddressDTO implements Serializable {
+
+ private Long id;
+
+ private Long userId;
+
+ private String name;
+
+ private String mobile;
+
+ private String province;
+
+ private String city;
+
+ private String area;
+
+ private String address;
+
+ private String zipCode;
+
+ private Integer defaulted;
+}
diff --git a/pom.xml b/pom.xml
index b19d329a8..95fdcd1a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,7 @@
mall-ums
mall-pms
mall-oms
+ common-rabbitmq
@@ -44,6 +45,7 @@
3.9.4.B
6.0.13.Final
1.4.0
+
@@ -123,6 +125,7 @@
${seata.version}
+
diff --git a/youlai-common/common-core/pom.xml b/youlai-common/common-core/pom.xml
index 7923cff99..1ffecfa1a 100644
--- a/youlai-common/common-core/pom.xml
+++ b/youlai-common/common-core/pom.xml
@@ -37,6 +37,13 @@
hibernate-validator
+
+ com.github.dozermapper
+ dozer-core
+ ${dozer.version}
+
+
+
diff --git a/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseEntity.java b/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseEntity.java
index 62407265c..a431689fd 100644
--- a/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseEntity.java
+++ b/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseEntity.java
@@ -17,6 +17,8 @@ import java.util.Date;
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
+
+
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间", example = "2020-01-01 00:00:00")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
diff --git a/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseVO.java b/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseVO.java
new file mode 100644
index 000000000..1d477daa5
--- /dev/null
+++ b/youlai-common/common-core/src/main/java/com/youlai/common/core/base/BaseVO.java
@@ -0,0 +1,19 @@
+package com.youlai.common.core.base;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * @author huawei
+ * @desc VO 基类
+ * @email huawei_code@163.com
+ * @date 2021/1/11
+ */
+@Data
+@ToString
+public class BaseVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+}
diff --git a/youlai-common/common-core/src/main/java/com/youlai/common/core/constant/RedisKeyConstants.java b/youlai-common/common-core/src/main/java/com/youlai/common/core/constant/RedisKeyConstants.java
deleted file mode 100644
index 086966fca..000000000
--- a/youlai-common/common-core/src/main/java/com/youlai/common/core/constant/RedisKeyConstants.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.youlai.common.core.constant;
-
-public interface RedisKeyConstants {
-
- String YOU_LAI = "youlai:";
-
- String MALL_CART_KEY = YOU_LAI + "cart:";
-}
diff --git a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/MetaHandler.java b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/MetaHandler.java
index b05a0aec7..782d605e2 100644
--- a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/MetaHandler.java
+++ b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/MetaHandler.java
@@ -17,7 +17,7 @@ public class MetaHandler implements MetaObjectHandler {
@Override
public void updateFill(MetaObject metaObject) {
- this.setFieldValByName("gmtCreate", new Date(), metaObject);
+ this.setFieldValByName("gmtModified", new Date(), metaObject);
}
}
diff --git a/youlai-common/common-rabbitmq/pom.xml b/youlai-common/common-rabbitmq/pom.xml
new file mode 100644
index 000000000..32cc141d0
--- /dev/null
+++ b/youlai-common/common-rabbitmq/pom.xml
@@ -0,0 +1,21 @@
+
+
+
+ youlai-common
+ com.youlai
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ common-rabbitmq
+
+
+
+ org.springframework.boot
+ spring-boot-starter-amqp
+
+
+
+
\ No newline at end of file
diff --git a/youlai-common/common-rabbitmq/src/main/java/com/youlai/common/rabbitmq/config/RabbitMqConfig.java b/youlai-common/common-rabbitmq/src/main/java/com/youlai/common/rabbitmq/config/RabbitMqConfig.java
new file mode 100644
index 000000000..009eb9de5
--- /dev/null
+++ b/youlai-common/common-rabbitmq/src/main/java/com/youlai/common/rabbitmq/config/RabbitMqConfig.java
@@ -0,0 +1,92 @@
+package com.youlai.common.rabbitmq.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.amqp.support.converter.MessageConverter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author huawei
+ * @desc
+ * @email huawei_code@163.com
+ * @date 2021/1/17
+ */
+@Configuration
+@EnableTransactionManagement
+@Slf4j
+public class RabbitMqConfig {
+
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
+ /**
+ * 使用json序列化机制,进行消息转换
+ *
+ * @return
+ */
+ @Bean
+ public MessageConverter messageConverter() {
+ return new Jackson2JsonMessageConverter();
+ }
+
+ /**
+ * 为容器创建号rabbitTemplate注册confirmCallback
+ * 消息由生产者投递到Broker/Exchange回调
+ */
+ @PostConstruct
+ public void setExchangeCallback() {
+
+ rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {
+
+ /**
+ * @param correlationData 发送消息时指定的唯一关联数据(消息id)
+ * @param ack 投递结果
+ * @param cause 失败原因
+ */
+ @Override
+ public void confirm(CorrelationData correlationData, boolean ack, String cause) {
+ if (ack) {
+ log.info("消息投递到交换机成功:[correlationData={}]", correlationData);
+ } else {
+ log.error("消息投递到交换机成功:[correlationData={},原因={}]", correlationData, cause);
+ }
+ }
+ });
+ }
+
+ /**
+ * 注意下面两项必须同时配置,可以尝试不配置第二项,通过测试能够发现当消息路由到Queue失败(比如路由件错误)时,returnCallback并未被回调。
+ * # 开启阶段二(消息从E->Q)的确认回调 Exchange --> Queue returnCallback
+ * spring.rabbitmq.publisher-returns=true
+ * # 官方文档说此时这一项必须设置为true
+ * # 实际上这一项的作用是:消息【未成功到达】队列时,能监听到到路由不可达的消息,以异步方式优先调用我们自己设置的returnCallback,默认情况下,这个消息会被直接丢弃,无法监听到
+ * spring.rabbitmq.template.mandatory=true
+ */
+ @PostConstruct
+ public void setQueueCallback() {
+ rabbitTemplate.setReturnCallback(new RabbitTemplate.ReturnCallback() {
+ /**
+ * 这个方法的参数并没有像 confirmCallback 那样提供boolean类型的ack,因此这个回调只能在【失败】情况下触发
+ * @param message 发送消息
+ * @param replyCode 回复错误码
+ * @param replyText 回复错误内容
+ * @param exchange 发送消息时指定的交换机
+ * @param routingKey 发送消息时使用的路由件
+ */
+ @Override
+ public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
+ log.error("路由到队列失败,[消息内容:{},交换机:{},路由件:{},回复码:{},回复文本:{}]", message, exchange, routingKey, replyCode, replyText);
+ }
+ });
+ }
+
+
+}
diff --git a/youlai-common/common-rabbitmq/src/main/resources/META-INF/spring.factories b/youlai-common/common-rabbitmq/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..68ab377f9
--- /dev/null
+++ b/youlai-common/common-rabbitmq/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+ com.youlai.common.rabbitmq.config.RabbitMqConfig
diff --git a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/RedisConfig.java b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/RedisConfig.java
index e3e83d1d8..e673497ff 100644
--- a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/RedisConfig.java
+++ b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/RedisConfig.java
@@ -14,17 +14,8 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
-
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
-// RedisTemplate redisTemplate = new RedisTemplate<>();
-// redisTemplate.setKeySerializer(new StringRedisSerializer());
-// redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
-// redisTemplate.setHashKeySerializer(new StringRedisSerializer());
-// redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
-// redisTemplate.setConnectionFactory(factory);
-// redisTemplate.afterPropertiesSet();
-// return redisTemplate;
RedisTemplate redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(factory);
diff --git a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/constant/RedisKeyConstants.java b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/constant/RedisKeyConstants.java
new file mode 100644
index 000000000..875ee5c9c
--- /dev/null
+++ b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/constant/RedisKeyConstants.java
@@ -0,0 +1,12 @@
+package com.youlai.common.redis.constant;
+
+public interface RedisKeyConstants {
+
+ Long REDIS_KEY_TIME_OUT = 3600 * 24L;
+
+ String YOU_LAI = "youlai:";
+
+ String MALL_CART_KEY = YOU_LAI + "cart:";
+
+ String TOKEN_VERIFY ="token_verify:";
+}
diff --git a/youlai-common/common-web/pom.xml b/youlai-common/common-web/pom.xml
index 360209ed1..6d5ff110c 100644
--- a/youlai-common/common-web/pom.xml
+++ b/youlai-common/common-web/pom.xml
@@ -22,11 +22,25 @@
${youlai.version}
+
+ com.youlai
+ common-redis
+ ${youlai.version}
+
+
org.springframework.boot
spring-boot-starter-web
true
+
+
+ com.github.dozermapper
+ dozer-core
+ 6.2.0
+
+
+
diff --git a/youlai-common/common-web/src/main/java/com/youlai/common/web/util/BeanMapperUtils.java b/youlai-common/common-web/src/main/java/com/youlai/common/web/util/BeanMapperUtils.java
new file mode 100644
index 000000000..2f7a49532
--- /dev/null
+++ b/youlai-common/common-web/src/main/java/com/youlai/common/web/util/BeanMapperUtils.java
@@ -0,0 +1,55 @@
+package com.youlai.common.web.util;
+
+import org.dozer.DozerBeanMapperBuilder;
+import org.dozer.Mapper;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class BeanMapperUtils {
+
+ private static Mapper mapper;
+
+ static {
+ mapper = DozerBeanMapperBuilder.buildDefault();
+ }
+
+ public static D map(S source, Class destinationClass) {
+ if (source == null) {
+ return null;
+ }
+ return mapper.map(source, destinationClass);
+ }
+
+ public static void copy(S source, D dest) {
+ if (source == null) {
+ return;
+ }
+ mapper.map(source, dest);
+ }
+
+ public static List mapList(final List source, final Class destType) {
+ final List dest = new ArrayList();
+ if (source == null || source.size() == 0) {
+ return dest;
+ }
+ for (S element : source) {
+ dest.add(mapper.map(element, destType));
+ }
+ return dest;
+ }
+
+ public static Collection mapCollection(final Collection source, final Class destType) {
+ final Collection dest = new ArrayList<>();
+ if (source == null || source.size() == 0) {
+ return dest;
+ }
+ for (S element : source) {
+ dest.add(mapper.map(element, destType));
+ }
+ return dest;
+ }
+
+}
+
diff --git a/youlai-common/pom.xml b/youlai-common/pom.xml
index 2e612db26..ede886d49 100644
--- a/youlai-common/pom.xml
+++ b/youlai-common/pom.xml
@@ -19,6 +19,7 @@
common-redis
common-web
common-mybatis
+ common-rabbitmq
@@ -31,6 +32,7 @@
3.12.5
2.8.0
1.0.0-SNAPSHOT
+ 6.2.0
@@ -122,6 +124,13 @@
${youlai.version}
+
+ com.github.dozermapper
+ dozer-core
+ ${dozer.version}
+
+
+