提交 f6f25a94 编写于 作者: H haoxr

refactor:订单模块测试和调整

上级 49854a4e
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;
}
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;
}
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<OmsOrderItem> orderItems;
private MemberDTO member;
}
......@@ -18,7 +18,7 @@ public enum OrderTypeEnum {
;
@Getter
public Integer code;
private Integer code;
public static OrderTypeEnum getValue(Integer code){
for (OrderTypeEnum value : values()) {
......
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;*/
}
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;
}
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<OmsOrderItem> orderItems;
private OmsOrderLog orderLog;
private OmsOrderDelivery orderDelivery;
}
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
......
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
......
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
......
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
......
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
......
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
......
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;
/**
* 直接下单时商品数量
......
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<String> 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<String> getSkuAttrs() {
return skuAttrs;
}
public void setSkuAttrs(List<String> skuAttrs) {
this.skuAttrs = skuAttrs;
}
}
......@@ -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;
}
......
......@@ -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<OrderItemVO> 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;
}
......
......@@ -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;
......
......@@ -11,7 +11,6 @@ import lombok.Data;
*/
@Data
public class OrderSubmitResultVO extends BaseVO {
/**
* 订单ID
*/
......
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<OrderGoodsEntity> orderGoods;
private OrderLogsEntity orderLogsEntity;
private OrderDeliveryEntity orderDeliveryEntity;
}
......@@ -13,6 +13,11 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
......@@ -50,10 +55,7 @@
<artifactId>common-rabbitmq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
......
......@@ -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:";
......
......@@ -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<OmsOrder> queryWrapper = new LambdaQueryWrapper<OmsOrder>()
.like(StrUtil.isNotBlank(orderSn), OmsOrder::getOrderSn, orderSn)
.eq(status != null, OmsOrder::getStatus, status)
LambdaQueryWrapper<OmsOrder1> queryWrapper = new LambdaQueryWrapper<OmsOrder1>()
.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<OmsOrder> result = iOmsOrderService.page(new Page<>(page, limit), queryWrapper);
.orderByDesc(OmsOrder1::getGmtModified)
.orderByDesc(OmsOrder1::getGmtCreate);
Page<OmsOrder1> 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<OmsOrder> updateWrapper = new LambdaUpdateWrapper<OmsOrder>().eq(OmsOrder::getId, id);
updateWrapper.set(status != null, OmsOrder::getStatus, status);
LambdaUpdateWrapper<OmsOrder1> updateWrapper = new LambdaUpdateWrapper<OmsOrder1>().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);
}
......
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<CartVO> 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<Object> 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<Object> 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<Object> 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<Object> 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<Boolean> delete(@RequestParam("skuIds") List<String> skuIds) {
cartService.deleteBatch(skuIds);
public Result deleteCart() {
cartService.deleteCart();
return Result.success();
}
@ApiOperation(value = "清空购物车", httpMethod = "GET")
@GetMapping("/clear")
public Result<Boolean> clear() {
cartService.clear();
return Result.success();
}
}
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<OrderConfirmVO> 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<OrderConfirmVO> 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<OrderSubmitResultVO> 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<OrderListVO>> list(@ApiParam(name = "status",value = "订单状态",required = true,defaultValue = "0")
@RequestParam(value = "status",required = true,defaultValue = "0") Integer status) {
List<OrderListVO> orderList = orderService.list(status);
public Result<List<OrderListVO>> list(@ApiParam(name = "status", value = "订单状态", required = true, defaultValue = "0")
@RequestParam(value = "status", required = true, defaultValue = "0") Integer status) {
List<OrderListVO> orderList = IOrderService.list(status);
return Result.success(orderList);
}
......
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<OrderEntity> {
public interface OrderDao extends BaseMapper<OmsOrder> {
}
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<OrderDeliveryEntity> {
public interface OrderDeliveryDao extends BaseMapper<OmsOrderDelivery> {
}
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<OrderGoodsEntity> {
public interface OrderItemDao extends BaseMapper<OmsOrderItem> {
}
......@@ -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<OrderLogsEntity> {
public interface OrderLogDao extends BaseMapper<OrderLogsEntity> {
}
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<OrderPayEntity> {
public interface OrderPayDao extends BaseMapper<OmsOrderPay> {
}
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<OrderSettingEntity> {
public interface OrderSettingDao extends BaseMapper<OmsOrderSetting> {
}
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<OmsOrderItem> {
public interface OmsOrderItemMapper extends BaseMapper<OmsOrderItem1> {
}
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<OmsOrder> {
public interface OmsOrderMapper extends BaseMapper<OmsOrder1> {
}
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<String> skuIds);
void deleteCartItem(Long skuId);
/**
* 查询购物车详情
* @return
*/
CartVO detail();
CartVO getCart();
/**
* 清空购物车
*/
void clear();
void deleteCart();
/**
* 清空购物车中已选择商品
......
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<OmsOrderItem> {
}
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<OmsOrder> {
boolean save(OrderBO orderBO);
OrderBO getByOrderId(Long id);
}
......@@ -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<OrderEntity> {
public interface IOrderService extends IService<OmsOrder> {
/**
* 订单确认页信息
*
* @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<OrderEntity> {
* @param id 订单ID
* @return 订单信息
*/
OrderEntity getByOrderId(String id);
OmsOrder getByOrderId(String id);
}
......@@ -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<OrderDeliveryEntity> {
public interface OrderDeliveryService extends IService<OmsOrderDelivery> {
}
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<OrderGoodsEntity> {
public interface OrderGoodsService extends IService<OmsOrderItem> {
List<OrderGoodsEntity> getByOrderId(Long orderId);
List<OmsOrderItem> getByOrderId(Long orderId);
Map<Long,List<OrderGoodsEntity>> getByOrderIds(List<Long> orderIds);
Map<Long,List<OmsOrderItem>> getByOrderIds(List<Long> orderIds);
}
......@@ -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<OrderLogsEntity> {
public interface OrderLogsService extends IService<OmsOrderLog> {
/**
* 添加订单操作日志记录
......
......@@ -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<OrderPayEntity> {
public interface OrderPayService extends IService<OmsOrderPay> {
/**
* 获取订单支付详情
* @param orderId 订单ID
......
......@@ -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<OrderSettingEntity> {
public interface OrderSettingService extends IService<OmsOrderSetting> {
}
......@@ -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<Void> skuInfoFuture = CompletableFuture.runAsync(() -> {
//1、远程查询商品详情
Result<SkuDTO> 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<Void> future = CompletableFuture.runAsync(() -> {
// 远程查询商品详情
Result<SkuDTO> 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<Void> allOf = CompletableFuture.allOf(skuInfoFuture);
CompletableFuture<Void> allOf = CompletableFuture.allOf(future);
allOf.get();
cartOps.put(skuId, 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;
}
cartItem.setNumber(cartItemBo.getNumber());
cartOps.put(cartItemBo.getSkuId().toString(), cartItem);
cartHashOpts.put(hKey, 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;
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.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<String> 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<CartItemVO> items = cartOps.values();
public CartVO getCart() {
BoundHashOperations cartHashOpts = getCartHashOpts();
List<CartItemVO> 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;
}
......
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<OmsOrderItemMapper, OmsOrderItem> implements IOmsOrderItemService {
public class OmsOrderItemServiceImpl extends ServiceImpl<OmsOrderItemMapper, OmsOrderItem1> implements IService<OmsOrderItem1> {
}
......@@ -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<OmsOrderMapper, OmsOrder> implements IOmsOrderService {
public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder1> implements IOmsOrderService {
private IOmsOrderItemService iOmsOrderItemService;
......@@ -40,13 +34,13 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> 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<OmsOrderItem> orderItems = orderBO.getOrderItems();
List<OmsOrderItem1> orderItems = orderBO.getOrderItems();
if (CollectionUtil.isEmpty(orderItems)) {
throw new BizException("订单明细不能为空");
}
......@@ -61,13 +55,13 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> 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<OmsOrderItem> orderItems = iOmsOrderItemService.list(
new LambdaQueryWrapper<OmsOrderItem>().eq(OmsOrderItem::getOrderId, orderId)
List<OmsOrderItem1> orderItems = iOmsOrderItemService.list(
new LambdaQueryWrapper<OmsOrderItem1>().eq(OmsOrderItem1::getOrderId, orderId)
);
orderItems = Optional.ofNullable(orderItems).orElse(new ArrayList<>());
......
......@@ -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<OrderDeliveryDao, OrderDeliveryEntity> implements OrderDeliveryService {
public class OrderDeliveryServiceImpl extends ServiceImpl<OrderDeliveryDao, OmsOrderDelivery> implements OrderDeliveryService {
}
......@@ -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<OrderGoodsDao, OrderGoodsEntity> implements OrderGoodsService {
public class OrderGoodsServiceImpl extends ServiceImpl<OrderItemDao, OmsOrderItem> implements OrderGoodsService {
@Override
public List<OrderGoodsEntity> getByOrderId(Long orderId) {
public List<OmsOrderItem> getByOrderId(Long orderId) {
log.info("根据订单ID,查询订单商品列表,orderId={}", orderId);
QueryWrapper<OrderGoodsEntity> queryWrapper = new QueryWrapper<>();
QueryWrapper<OmsOrderItem> queryWrapper = new QueryWrapper<>();
queryWrapper.ge("order_id", orderId);
return baseMapper.selectList(queryWrapper);
}
@Override
public Map<Long, List<OrderGoodsEntity>> getByOrderIds(List<Long> orderIds) {
QueryWrapper<OrderGoodsEntity> orderGoodsQuery = new QueryWrapper<>();
public Map<Long, List<OmsOrderItem>> getByOrderIds(List<Long> orderIds) {
QueryWrapper<OmsOrderItem> orderGoodsQuery = new QueryWrapper<>();
orderGoodsQuery.in("order_id", orderIds).orderByDesc("order_id", "id");
List<OrderGoodsEntity> orderGoods = this.list(orderGoodsQuery);
List<OmsOrderItem> orderGoods = this.list(orderGoodsQuery);
if (orderGoods == null || orderGoods.size() == 0) {
log.info("根据订单ID列表查询商品为空,orderIds={}", orderIds);
return new HashMap<>(8);
}
Map<Long, List<OrderGoodsEntity>> orderGoodsMap = orderGoods.stream()
.collect(Collectors.groupingBy(OrderGoodsEntity::getOrderId));
Map<Long, List<OmsOrderItem>> orderGoodsMap = orderGoods.stream()
.collect(Collectors.groupingBy(OmsOrderItem::getOrderId));
return orderGoodsMap;
}
......
......@@ -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<OrderLogsDao, OrderLogsEntity> implements OrderLogsService {
public class OrderLogsServiceImpl extends ServiceImpl<OrderLogDao, OmsOrderLog> 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);
......
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<OrderPayDao, OrderPayEntity> implements OrderPayService {
public class OrderPayServiceImpl extends ServiceImpl<OrderPayDao, OmsOrderPay> implements OrderPayService {
private OrderService orderService;
private IOrderService IOrderService;
private OrderLogsService orderLogsService;
......@@ -45,8 +42,8 @@ public class OrderPayServiceImpl extends ServiceImpl<OrderPayDao, OrderPayEntity
Long userId = RequestUtils.getUserId();
PayInfoVO payInfoVO = new PayInfoVO();
// 1、获取订单应支付金额
OrderEntity orderEntity = orderService.getByOrderId(orderId);
payInfoVO.setPayPrice(orderEntity.getPayAmount());
OmsOrder omsOrder = IOrderService.getByOrderId(orderId);
payInfoVO.setPayPrice(omsOrder.getPayAmount());
// 2、获取会员余额
try {
......@@ -71,7 +68,7 @@ public class OrderPayServiceImpl extends ServiceImpl<OrderPayDao, OrderPayEntity
public void balancePay(String orderId) {
// 1、查询订单详情,判断订单状态是否是待支付状态
log.info("订单进入支付流程,orderId:{}", orderId);
OrderEntity order = orderService.getByOrderId(orderId);
OmsOrder order = IOrderService.getByOrderId(orderId);
OrderStatusEnum orderStatusEnum = OrderStatusEnum.getValue(order.getStatus()) ;
if (orderStatusEnum != OrderStatusEnum.NEED_PAY) {
log.error("订单状态异常无法支付,orderStatus={}", orderStatusEnum.getText());
......@@ -98,13 +95,13 @@ public class OrderPayServiceImpl extends ServiceImpl<OrderPayDao, OrderPayEntity
order.setStatus(OrderStatusEnum.IS_PAY.getCode());
order.setPayTime(new Date());
order.setPayType(PayTypeEnum.BALANCE.getCode());
orderService.updateById(order);
IOrderService.updateById(order);
this.save(createOrderPay(order, PayTypeEnum.BALANCE.getCode()));
orderLogsService.addOrderLogs(order.getId(), OrderStatusEnum.IS_PAY.getCode(), userId.toString(), "支付订单");
}
private OrderPayEntity createOrderPay(OrderEntity order, Integer payType) {
OrderPayEntity payEntity = new OrderPayEntity();
private OmsOrderPay createOrderPay(OmsOrder order, Integer payType) {
OmsOrderPay payEntity = new OmsOrderPay();
payEntity.setOrderId(order.getId());
payEntity.setPayAmount(order.getPayAmount());
payEntity.setPayTime(new Date());
......
package com.youlai.mall.oms.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rabbitmq.client.Channel;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import com.youlai.common.web.exception.BizException;
import com.youlai.mall.oms.config.rabbitmq.OmsRabbitConstants;
import com.youlai.mall.oms.enums.OrderStatusEnum;
import com.youlai.mall.oms.pojo.entity.OrderEntity;
import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity;
import com.youlai.mall.oms.pojo.domain.OmsOrder;
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
import com.youlai.mall.oms.service.OrderGoodsService;
import com.youlai.mall.oms.service.OrderRabbitService;
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.InventoryDTO;
import io.seata.spring.annotation.GlobalTransactional;
......@@ -31,7 +32,7 @@ import java.util.stream.Collectors;
@Slf4j
public class OrderRabbitServiceImpl implements OrderRabbitService {
private OrderService orderService;
private IOrderService IOrderService;
private OrderGoodsService orderGoodsService;
......@@ -53,9 +54,9 @@ public class OrderRabbitServiceImpl implements OrderRabbitService {
log.info("获取到消息,msgTag={},message={},body={}", msgTag, message.toString(), orderSn);
try {
OrderEntity order = orderService.getByOrderSn(orderSn);
OmsOrder order = IOrderService.getOne(new LambdaQueryWrapper<OmsOrder>().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<OrderGoodsEntity> orderGoods = orderGoodsService.getByOrderId(orderId);
List<OmsOrderItem> orderGoods = orderGoodsService.getByOrderId(orderId);
List<InventoryDTO> items = orderGoods.stream().map(good -> {
InventoryDTO item = new InventoryDTO();
item.setInventoryId(good.getSkuId());
......
......@@ -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<OrderSettingDao, OrderSettingEntity> implements OrderSettingService {
public class OrderSettingServiceImpl extends ServiceImpl<OrderSettingDao, OmsOrderSetting> implements OrderSettingService {
}
......@@ -4,7 +4,7 @@
<mapper namespace="com.youlai.mall.oms.dao.OrderDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.youlai.mall.oms.pojo.entity.OrderEntity" id="orderMap">
<resultMap type="com.youlai.mall.oms.pojo.domain.OmsOrder" id="orderMap">
<result property="id" column="id"/>
<result property="orderSn" column="order_sn"/>
<result property="totalAmount" column="total_amount"/>
......@@ -28,4 +28,4 @@
</resultMap>
</mapper>
\ No newline at end of file
</mapper>
......@@ -4,7 +4,7 @@
<mapper namespace="com.youlai.mall.oms.dao.OrderDeliveryDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity" id="orderDeliveryMap">
<resultMap type="com.youlai.mall.oms.pojo.domain.OmsOrderDelivery" id="orderDeliveryMap">
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="deliveryCompany" column="delivery_company"/>
......@@ -26,4 +26,4 @@
</resultMap>
</mapper>
\ No newline at end of file
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.mall.oms.dao.OrderGoodsDao">
<mapper namespace="com.youlai.mall.oms.dao.OrderItemDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.youlai.mall.oms.pojo.entity.OrderGoodsEntity" id="orderGoodsMap">
<resultMap type="com.youlai.mall.oms.pojo.domain.OmsOrderItem" id="orderGoodsMap">
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="skuId" column="sku_id"/>
......@@ -27,4 +27,4 @@
</resultMap>
</mapper>
\ No newline at end of file
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.mall.oms.dao.OrderLogsDao">
<mapper namespace="com.youlai.mall.oms.dao.OrderLogDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.youlai.mall.oms.pojo.entity.OrderLogsEntity" id="orderLogsMap">
<resultMap type="com.youlai.mall.oms.pojo.domain.OmsOrderLog" id="orderLogsMap">
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="user" column="user"/>
......@@ -17,4 +17,4 @@
</resultMap>
</mapper>
\ No newline at end of file
</mapper>
......@@ -4,7 +4,7 @@
<mapper namespace="com.youlai.mall.oms.dao.OrderPayDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.youlai.mall.oms.pojo.entity.OrderPayEntity" id="orderPayMap">
<resultMap type="com.youlai.mall.oms.pojo.domain.OmsOrderPay" id="orderPayMap">
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="paySn" column="pay_sn"/>
......@@ -22,4 +22,4 @@
</resultMap>
</mapper>
\ No newline at end of file
</mapper>
......@@ -4,7 +4,7 @@
<mapper namespace="com.youlai.mall.oms.dao.OrderSettingDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.youlai.mall.oms.pojo.entity.OrderSettingEntity" id="orderSettingMap">
<resultMap type="com.youlai.mall.oms.pojo.domain.OmsOrderSetting" id="orderSettingMap">
<result property="id" column="id"/>
<result property="flashOrderOvertime" column="flash_order_overtime"/>
<result property="normalOrderOvertime" column="normal_order_overtime"/>
......@@ -18,4 +18,4 @@
</resultMap>
</mapper>
\ No newline at end of file
</mapper>
......@@ -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<OmsOrder>().eq(OmsOrder::getId, 1l).set(OmsOrder::getStatus, 901));
iOmsOrderService.update(new LambdaUpdateWrapper<OmsOrder1>().eq(OmsOrder1::getId, 1l).set(OmsOrder1::getStatus, 901));
}
}
......@@ -14,25 +14,25 @@ public interface InventoryFeignService {
/**
* 获取库存列表
*/
@GetMapping("/api.app/v1/skus/{ids}")
Result<List<SkuDTO>> listBySkuIds(@PathVariable String ids);
@GetMapping("/api.app/v1/skus")
Result<List<SkuDTO>> listBySkuIds(@RequestParam List<Long> ids);
/**
* 获取库存信息
*/
@GetMapping("/api.app/v1/skus/{id}")
Result<SkuDTO> getInventoryById(@PathVariable Long id);
Result<SkuDTO> getSkuById(@PathVariable Long id);
/**
* 锁定库存
*/
@PostMapping("/api.app/v1/skus/batch/lock_inventory")
@PatchMapping("/api.app/v1/skus/batch/lock_inventory")
Result lockInventory(@RequestBody List<InventoryDTO> list);
/**
* 解锁库存
*/
@PostMapping("/api.app/v1/skus/batch/unlock_inventory")
@PatchMapping("/api.app/v1/skus/batch/unlock_inventory")
Result<Boolean> unlockInventory(@RequestBody List<InventoryDTO> list);
......
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<PmsAttributeValue> attrValues;
private List<PmsSpuAttributeValue> attrs;
private List<PmsSpecificationValue> specValues;
private List<PmsSpuSpecValue> specs;
private List<PmsSku> skus;
......
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<PmsAttributeValue> attrValues;
private List<PmsSpuAttributeValue> attrs;
private List<PmsSpecification> specs;
......
......@@ -18,5 +18,5 @@ public class PmsSku extends BaseEntity {
private Long price;
private Integer inventory;
private Integer lockedInventory;
private String specificationValueIds;
private String specValueIds;
}
......@@ -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<PmsSpecificationValue> values = new ArrayList<>();
private List<PmsSpuSpecValue> values = new ArrayList<>();
}
......@@ -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;
......
......@@ -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;
}
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;
}
......@@ -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()));
});
......
......@@ -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<PmsSpecification> list = iPmsSpecificationService
List<PmsSpecification> list = iPmsSpecService
.list(new LambdaQueryWrapper<PmsSpecification>()
.eq(PmsSpecification::getCategoryId, categoryId));
return Result.success(list);
......@@ -51,7 +51,7 @@ public class SpecController {
List<Long> formIds = specCategories.stream().map(item -> item.getId()).collect(Collectors.toList());
List<Long> databaseIds = iPmsSpecificationService
List<Long> databaseIds = iPmsSpecService
.list(new LambdaQueryWrapper<PmsSpecification>()
.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);
}
}
package com.youlai.mall.pms.controller.app;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.ISpuService;
import com.youlai.mall.pms.service.IProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -14,42 +17,54 @@ 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/spus")
@RequestMapping("/api.app/v1/products")
@AllArgsConstructor
public class SpuController {
public class ProductController {
private IPmsSpuService iPmsSpuService;
private ISpuService iSpuService;
private IProductService iProductService;
@ApiOperation(value = "列表分页", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Long"),
@ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Long"),
@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,
@RequestParam(required = false, defaultValue = "10") Integer limit,
Integer limit,
String name,
Long categoryId
) {
IPage<PmsSpu> result = iPmsSpuService.list(
new Page<>(page, limit),
new PmsSpu().setName(name).setCategoryId(categoryId)
Page<PmsSpu> result = iPmsSpuService.page(new Page<>(page, limit), new LambdaQueryWrapper<PmsSpu>()
.eq(categoryId != null, PmsSpu::getCategoryId, categoryId)
.like(StrUtil.isNotBlank(name), PmsSpu::getName, name)
.select(PmsSpu::getId,
PmsSpu::getName,
PmsSpu::getPic,
PmsSpu::getPrice,
PmsSpu::getSales
)
);
return Result.success(result.getRecords(), result.getTotal());
List<ProductDTO> 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<ProductBO> detail(@PathVariable Long id) {
ProductBO product = iSpuService.getProductById(id);
public Result detail(@PathVariable Long id) {
ProductBO product = iProductService.getProductById(id);
return Result.success(product);
}
......
......@@ -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<Boolean> lockInventory(@RequestBody List<InventoryDTO> 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<Boolean> unlockInventory(@RequestBody List<InventoryDTO> 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<Long> ids) {
List<SkuDTO> list = iPmsSkuService.listBySkuIds(ids);
return Result.success(list);
}
......
......@@ -39,8 +39,11 @@ public interface PmsSkuMapper extends BaseMapper<PmsSku> {
" 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 ",
" <foreach collection='skuIds' item='skuId' open='(' separator=',' close=')'>",
" #{skuId}",
" </foreach>",
"</script>"
})
List<SkuDTO> listBySkuIds(String skuIds);
List<SkuDTO> listBySkuIds(List<Long> skuIds);
}
......@@ -7,20 +7,20 @@ import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface PmsSpecificationMapper extends BaseMapper<PmsSpecification> {
public interface PmsSpecMapper extends BaseMapper<PmsSpecification> {
@Select("<script>" +
" SELECT " +
" t1.id,t1.category_id,t1.name,t2.id AS spuId " +
" FROM " +
" pms_specification t1 " +
" pms_spec t1 " +
" LEFT JOIN pms_spu t2 ON t1.category_id = t2.category_id " +
" WHERE " +
" t2.id =#{spuId} " +
"</script>")
@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<PmsSpecification> listBySpuId(Long spuId);
}
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<PmsAttributeValue> {
public interface PmsSpuAttributeValueMapper extends BaseMapper<PmsSpuAttributeValue> {
}
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<PmsSpecificationValue> {
public interface PmsSpuSpecValueMapper extends BaseMapper<PmsSpuSpecValue> {
@Select("<script>" +
" SELECT " +
" id, " +
" spu_id, " +
" specification_id, " +
" spec_id, " +
" value" +
" FROM " +
" pms_spu_spec_value " +
" WHERE " +
" spu_id = #{spuId} " +
" AND specification_id = #{specificationId} " +
" AND spec_id = #{specId} " +
"</script>")
List<PmsSpecificationValue> listByCondition(Map<String, String> param);
List<PmsSpuSpecValue> listByCondition(Map<String, String> param);
}
......@@ -37,5 +37,5 @@ public interface IPmsSkuService extends IService<PmsSku> {
* @param ids
* @return
*/
List<SkuDTO> listBySkuIds(String ids);
List<SkuDTO> listBySkuIds(List<Long> ids);
}
......@@ -5,7 +5,7 @@ import com.youlai.mall.pms.pojo.domain.PmsSpecification;
import java.util.List;
public interface IPmsSpecificationService extends IService<PmsSpecification> {
public interface IPmsSpecService extends IService<PmsSpecification> {
List<PmsSpecification> listBySpuId(Long spuId);
......
package com.youlai.mall.pms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.pms.pojo.domain.PmsSpecificationValue;
import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue;
public interface IPmsSpecificationValueService extends IService<PmsSpecificationValue> {
public interface IPmsSpuAttributeValueService extends IService<PmsSpuAttributeValue> {
}
package com.youlai.mall.pms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.pms.pojo.domain.PmsAttributeValue;
import com.youlai.mall.pms.pojo.domain.PmsSpuSpecValue;
public interface IPmsAttributeValueService extends IService<PmsAttributeValue> {
public interface IPmsSpuSpecValueService extends IService<PmsSpuSpecValue> {
}
......@@ -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<PmsSpu> {
public interface IProductService extends IService<PmsSpu> {
ProductBO getProductById(Long id);
}
......@@ -97,7 +97,7 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
}
@Override
public List<SkuDTO> listBySkuIds(String ids) {
return this.listBySkuIds(ids);
public List<SkuDTO> listBySkuIds(List<Long> ids) {
return this.baseMapper.listBySkuIds(ids);
}
}
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<PmsSpecificationMapper, PmsSpecification> implements IPmsSpecificationService {
public class PmsSpecServiceImpl extends ServiceImpl<PmsSpecMapper, PmsSpecification> implements IPmsSpecService {
@Override
public List<PmsSpecification> listBySpuId(Long spuId) {
......
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 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;
/**
......@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
* @date 2020-12-12
*/
@Service
public class PmsAttributeValueServiceImpl extends ServiceImpl<PmsAttributeValueMapper, PmsAttributeValue> implements IPmsAttributeValueService {
public class PmsSpuAttributeValueServiceImpl extends ServiceImpl<PmsSpuAttributeValueMapper, PmsSpuAttributeValue> implements IPmsSpuAttributeValueService {
}
......@@ -29,9 +29,9 @@ import java.util.stream.Collectors;
public class PmsSpuServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> 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<PmsProductMapper, PmsSpu> imp
@Transactional
public boolean add(ProductBO spuBO) {
SpuDTO SpuDTO = spuBO.getSpu();
List<PmsAttributeValue> attrValues = spuBO.getAttrValues();
List<PmsSpecificationValue> specs = spuBO.getSpecValues();
List<PmsSpuAttributeValue> attrValues = spuBO.getAttrs();
List<PmsSpuSpecValue> specs = spuBO.getSpecs();
List<PmsSku> skuList = spuBO.getSkus();
// spu保存
......@@ -61,13 +61,13 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> 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<PmsProductMapper, PmsSpu> imp
}
// 属性
List<PmsAttributeValue> attrs = iPmsAttributeValueService.
list(new LambdaQueryWrapper<PmsAttributeValue>().eq(PmsAttributeValue::getSpuId, id));
List<PmsSpuAttributeValue> attrs = iPmsSpuAttributeValueService.
list(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getSpuId, id));
// 规格
List<PmsSpecificationValue> specs = iPmsSpecificationValueService.list(new LambdaQueryWrapper<PmsSpecificationValue>().eq(PmsSpecificationValue::getSpuId, id));
List<PmsSpuSpecValue> specs = iPmsSpuSpecValueService.list(new LambdaQueryWrapper<PmsSpuSpecValue>().eq(PmsSpuSpecValue::getSpuId, id));
// sku
List<PmsSku> skus = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, id));
......@@ -110,8 +110,8 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> imp
public boolean updateById(com.youlai.mall.pms.pojo.bo.admin.ProductBO spuBO) {
SpuDTO SpuDTO = spuBO.getSpu();
List<PmsAttributeValue> attrValues = spuBO.getAttrValues();
List<PmsSpecificationValue> specs = spuBO.getSpecValues();
List<PmsSpuAttributeValue> attrValues = spuBO.getAttrs();
List<PmsSpuSpecValue> specs = spuBO.getSpecs();
List<PmsSku> skuList = spuBO.getSkus();
// spu保存
......@@ -129,15 +129,15 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> imp
// 删除此次保存删除的
List<Long> ids = list.stream().map(item -> item.getId()).collect(Collectors.toList());
List<Long> dbIds = iPmsAttributeValueService.list(new LambdaQueryWrapper<PmsAttributeValue>().eq(PmsAttributeValue::getSpuId, spu.getId())
.select(PmsAttributeValue::getId))
List<Long> dbIds = iPmsSpuAttributeValueService.list(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getSpuId, spu.getId())
.select(PmsSpuAttributeValue::getId))
.stream()
.map(item -> item.getId())
.collect(Collectors.toList());
List<Long> 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<PmsProductMapper, PmsSpu> imp
// 删除此次保存删除的
List<Long> ids = list.stream().map(item -> item.getId()).collect(Collectors.toList());
List<Long> dbIds = iPmsSpecificationValueService.list(new LambdaQueryWrapper<PmsSpecificationValue>().eq(PmsSpecificationValue::getSpuId, spu.getId())
.select(PmsSpecificationValue::getId))
List<Long> dbIds = iPmsSpuSpecValueService.list(new LambdaQueryWrapper<PmsSpuSpecValue>().eq(PmsSpuSpecValue::getSpuId, spu.getId())
.select(PmsSpuSpecValue::getId))
.stream()
.map(item -> item.getId())
.collect(Collectors.toList());
List<Long> 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<PmsProductMapper, PmsSpu> imp
// sku
iPmsSkuService.remove(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
// 规格
iPmsSpecificationValueService.remove(new LambdaQueryWrapper<PmsSpecificationValue>().eq(PmsSpecificationValue::getId, spuId));
iPmsSpuSpecValueService.remove(new LambdaQueryWrapper<PmsSpuSpecValue>().eq(PmsSpuSpecValue::getId, spuId));
// 属性
iPmsAttributeValueService.remove(new LambdaQueryWrapper<PmsAttributeValue>().eq(PmsAttributeValue::getSpuId, spuId));
iPmsSpuAttributeValueService.remove(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getSpuId, spuId));
// spu
this.removeById(spuId);
})
......@@ -205,13 +205,13 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> imp
SpuDTO.setPics(pics);
}
// 属性
List<PmsAttributeValue> attrs = iPmsAttributeValueService.list(
new LambdaQueryWrapper<PmsAttributeValue>(
).eq(PmsAttributeValue::getSpuId, spuId)
List<PmsSpuAttributeValue> attrs = iPmsSpuAttributeValueService.list(
new LambdaQueryWrapper<PmsSpuAttributeValue>(
).eq(PmsSpuAttributeValue::getSpuId, spuId)
);
// 规格
List<PmsSpecification> specs = iPmsSpecificationService.listBySpuId(spuId);
List<PmsSpecification> specs = iPmsSpecService.listBySpuId(spuId);
// sku
List<PmsSku> skuList = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
......
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 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;
/**
......@@ -11,6 +11,6 @@ import org.springframework.stereotype.Service;
* @date 2020-11-06
*/
@Service
public class PmsSpecificationValueServiceImpl extends ServiceImpl<PmsSpecificationValueMapper, PmsSpecificationValue> implements IPmsSpecificationValueService {
public class PmsSpuSpecValueServiceImpl extends ServiceImpl<PmsSpuSpecValueMapper, PmsSpuSpecValue> implements IPmsSpuSpecValueService {
}
......@@ -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<PmsProductMapper, PmsSpu> implements ISpuService {
public class ProductServiceImpl extends ServiceImpl<PmsProductMapper, PmsSpu> 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<PmsProductMapper, PmsSpu> implem
SpuDTO.setPics(pics);
}
// 属性
List<PmsAttributeValue> attrs = iPmsAttributeValueService.list(
new LambdaQueryWrapper<PmsAttributeValue>(
).eq(PmsAttributeValue::getSpuId, spuId)
List<PmsSpuAttributeValue> attrs = iPmsSpuAttributeValueService.list(
new LambdaQueryWrapper<PmsSpuAttributeValue>(
).eq(PmsSpuAttributeValue::getSpuId, spuId)
);
// 规格
List<PmsSpecification> specs = iPmsSpecificationService.listBySpuId(spuId);
List<PmsSpecification> specs = iPmsSpecService.listBySpuId(spuId);
// sku
List<PmsSku> skuList = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
......
......@@ -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<PmsSpecification> specifications = iPmsSpecificationService.listBySpuId(1l);
List<PmsSpecification> specifications = iPmsSpecService.listBySpuId(1l);
log.info(specifications.toString());
}
@Autowired
public IPmsAttributeValueService iPmsAttributeValueService;
public IPmsSpuAttributeValueService iPmsSpuAttributeValueService;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册