mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
feat:订单重构
This commit is contained in:
parent
8f74ae5bd0
commit
e85e49b96e
@ -2,7 +2,9 @@ package com.youlai.mall.oms.pojo.bo.app;
|
||||
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrder;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
|
||||
import com.youlai.mall.ums.pojo.dto.MemberDTO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -13,10 +15,13 @@ import java.util.List;
|
||||
* @date 2021/1/19
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrderBO {
|
||||
|
||||
private OmsOrder order;
|
||||
|
||||
private List<OmsOrderItem> orderItems;
|
||||
|
||||
private MemberDTO member;
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ import lombok.*;
|
||||
public class OrderItemDTO extends BaseVO {
|
||||
|
||||
private Long skuId;
|
||||
private String skuName;
|
||||
private String skuCode;
|
||||
private Integer count;
|
||||
private String pic;
|
||||
private String title;
|
||||
private Long price;
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ public class CartVO implements Serializable {
|
||||
|
||||
private Long skuId;
|
||||
|
||||
private String title; // 标题
|
||||
private String skuName; // 标题
|
||||
|
||||
private String skuCode;
|
||||
|
||||
private String pic;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class RabbitMQConfig {
|
||||
Map<String, Object> args = new HashMap<>();
|
||||
args.put("x-dead-letter-exchange", "order.exchange");
|
||||
args.put("x-dead-letter-routing-key", "order:close"); // 死信路由Key
|
||||
args.put("x-message-ttl", 10000); // 单位:毫秒,1分钟测试使用
|
||||
args.put("x-message-ttl", 60000); // 单位:毫秒,1分钟测试使用
|
||||
return new Queue("order.delay.queue", true, false, false, args);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,96 @@
|
||||
package com.youlai.mall.oms.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.mall.oms.pojo.bo.app.OrderBO;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrder;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
|
||||
import com.youlai.mall.oms.service.IOrderItemService;
|
||||
import com.youlai.mall.oms.service.IOrderService;
|
||||
import com.youlai.mall.ums.api.UmsMemberFeignService;
|
||||
import com.youlai.mall.ums.pojo.dto.MemberDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* @author huawei
|
||||
* @email huawei_code@163.com
|
||||
* @date 2020-12-30 22:31:10
|
||||
*/
|
||||
@Api(tags = "【系统管理】订单服务")
|
||||
@RestController("AdminOrderController")
|
||||
@RequestMapping("/api.admin/v1/orders")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class OrderController {
|
||||
|
||||
private IOrderService orderService;
|
||||
private IOrderItemService orderItemService;
|
||||
private UmsMemberFeignService memberFeignService;
|
||||
|
||||
@ApiOperation("订单列表")
|
||||
@GetMapping
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", defaultValue = "1", value = "页码", paramType = "query", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "limit", defaultValue = "10", value = "每页数量", paramType = "query", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "status", value = "订单状态", paramType = "query", dataType = "Integer"),
|
||||
|
||||
})
|
||||
public Result list(
|
||||
@RequestParam(defaultValue = "1") Long page,
|
||||
@RequestParam(defaultValue = "10") Long limit,
|
||||
Integer status,
|
||||
String startDate,
|
||||
String endDate,
|
||||
String orderSn
|
||||
) {
|
||||
LambdaQueryWrapper<OmsOrder> queryWrapper = new LambdaQueryWrapper<OmsOrder>()
|
||||
.like(StrUtil.isNotBlank(orderSn), OmsOrder::getOrderSn, orderSn)
|
||||
.eq(status != null, OmsOrder::getStatus, status)
|
||||
.apply(StrUtil.isNotBlank(startDate),
|
||||
"date_format (gmt_crate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')")
|
||||
.apply(StrUtil.isNotBlank(endDate),
|
||||
"date_format (gmt_crate,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d')")
|
||||
.orderByDesc(OmsOrder::getGmtModified)
|
||||
.orderByDesc(OmsOrder::getGmtCreate);
|
||||
|
||||
IPage<OmsOrder> result = orderService.list(new Page<>(page, limit), new OmsOrder().setStatus(status));
|
||||
return Result.success(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "订单详情", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "订单id", required = true, paramType = "path", dataType = "Long")
|
||||
@GetMapping("/{id}")
|
||||
public Result detail(@PathVariable Long id) {
|
||||
OrderBO orderBO = new OrderBO();
|
||||
// 订单
|
||||
OmsOrder order = orderService.getById(id);
|
||||
|
||||
// 订单明细
|
||||
List<OmsOrderItem> orderItems = orderItemService.list(
|
||||
new LambdaQueryWrapper<OmsOrderItem>().eq(OmsOrderItem::getOrderId, id)
|
||||
);
|
||||
orderItems = Optional.ofNullable(orderItems).orElse(new ArrayList<>());
|
||||
|
||||
// 会员明细
|
||||
Result<MemberDTO> result = memberFeignService.getUserById(order.getMemberId());
|
||||
MemberDTO member = result.getData();
|
||||
orderBO.setOrder(order).setOrderItems(orderItems).setMember(member);
|
||||
return Result.success(orderBO);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.mall.oms.test.app;
|
||||
package com.youlai.mall.oms.controller.app;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.youlai.common.result.Result;
|
||||
@ -44,7 +44,6 @@ public class CartController {
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "添加购物车商品")
|
||||
@ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long")
|
||||
@PostMapping
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.mall.oms.test.app;
|
||||
package com.youlai.mall.oms.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
@ -18,7 +18,7 @@ public interface OrderMapper extends BaseMapper<OmsOrder> {
|
||||
|
||||
|
||||
@Select("<script>" +
|
||||
" select id,order_sn,total_amount,pay_amount,status,total_amount,total_quantity,gmt_create from oms_order" +
|
||||
" select id,order_sn,total_amount,pay_amount,status,total_amount,total_quantity,gmt_create,member_id,source_type from oms_order" +
|
||||
" where 1=1 " +
|
||||
" <if test ='order.status !=null ' >" +
|
||||
" AND status= #{order.status} " +
|
||||
|
@ -3,8 +3,6 @@ package com.youlai.mall.oms.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单商品信息表
|
||||
@ -15,9 +13,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IOrderItemService extends IService<OmsOrderItem> {
|
||||
|
||||
List<OmsOrderItem> getByOrderId(Long orderId);
|
||||
|
||||
Map<Long,List<OmsOrderItem>> getByOrderIds(List<Long> orderIds);
|
||||
|
||||
}
|
||||
|
||||
|
@ -93,8 +93,9 @@ public class CartServiceImpl implements ICartService {
|
||||
cartItem.setPrice(sku.getPrice());
|
||||
cartItem.setPic(sku.getPic());
|
||||
cartItem.setSkuId(sku.getId());
|
||||
cartItem.setTitle(sku.getName());
|
||||
cartItem.setSkuName(sku.getName());
|
||||
cartItem.setStock(sku.getStock());
|
||||
cartItem.setSkuCode(sku.getCode());
|
||||
cartItem.setChecked(true);
|
||||
}
|
||||
});
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.youlai.mall.oms.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.mall.oms.mapper.OrderItemMapper;
|
||||
import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
|
||||
@ -9,36 +7,10 @@ import com.youlai.mall.oms.service.IOrderItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OmsOrderItem> implements IOrderItemService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<OmsOrderItem> getByOrderId(Long orderId) {
|
||||
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<OmsOrderItem>().eq(OmsOrderItem::getOrderId, orderId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, List<OmsOrderItem>> getByOrderIds(List<Long> orderIds) {
|
||||
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<OmsOrderItem>().in(OmsOrderItem::getOrderId, orderIds)
|
||||
.orderByDesc(OmsOrderItem::getOrderId)
|
||||
.orderByDesc(OmsOrderItem::getId);
|
||||
|
||||
List<OmsOrderItem> orderItems = this.list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(orderItems)) {
|
||||
return new HashMap<>(8);
|
||||
}
|
||||
Map<Long, List<OmsOrderItem>> orderItemsMap = orderItems.stream()
|
||||
.collect(Collectors.groupingBy(OmsOrderItem::getOrderId));
|
||||
return orderItemsMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.youlai.mall.oms.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.common.enums.BusinessTypeEnum;
|
||||
import com.youlai.common.redis.component.BusinessNoGenerator;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.common.web.exception.BizException;
|
||||
import com.youlai.common.web.util.BeanMapperUtils;
|
||||
import com.youlai.common.web.util.RequestUtils;
|
||||
import com.youlai.mall.oms.enums.OrderStatusEnum;
|
||||
import com.youlai.mall.oms.enums.OrderTypeEnum;
|
||||
@ -21,13 +20,14 @@ import com.youlai.mall.oms.pojo.domain.OmsOrderItem;
|
||||
import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO;
|
||||
import com.youlai.mall.oms.pojo.dto.OrderItemDTO;
|
||||
import com.youlai.mall.oms.pojo.dto.OrderSubmitDTO;
|
||||
import com.youlai.mall.oms.pojo.vo.*;
|
||||
import com.youlai.mall.oms.pojo.vo.CartVO;
|
||||
import com.youlai.mall.oms.pojo.vo.OrderConfirmVO;
|
||||
import com.youlai.mall.oms.pojo.vo.OrderSubmitVO;
|
||||
import com.youlai.mall.oms.service.ICartService;
|
||||
import com.youlai.mall.oms.service.IOrderItemService;
|
||||
import com.youlai.mall.oms.service.IOrderService;
|
||||
import com.youlai.mall.pms.api.app.PmsSkuFeignService;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSku;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpu;
|
||||
import com.youlai.mall.pms.pojo.dto.SkuLockDTO;
|
||||
import com.youlai.mall.ums.api.UmsAddressFeignService;
|
||||
import com.youlai.mall.ums.api.UmsMemberFeignService;
|
||||
@ -41,7 +41,10 @@ import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.stream.Collectors;
|
||||
@ -62,6 +65,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
private ThreadPoolExecutor threadPoolExecutor;
|
||||
private UmsMemberFeignService memberFeignService;
|
||||
|
||||
private BusinessNoGenerator businessNoGenerator;
|
||||
|
||||
/**
|
||||
* 订单确认
|
||||
*/
|
||||
@ -81,7 +86,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
PmsSku sku = skuFeignService.getSkuById(orderConfirmDTO.getSkuId()).getData();
|
||||
orderItemDTO.setPrice(sku.getPrice());
|
||||
orderItemDTO.setPic(sku.getPic());
|
||||
orderItemDTO.setTitle(sku.getName());
|
||||
orderItemDTO.setSkuName(sku.getName());
|
||||
orderItemDTO.setSkuCode(sku.getCode());
|
||||
orderItems.add(orderItemDTO);
|
||||
} else { // 购物车中商品结算
|
||||
List<CartVO.CartItem> cartItems = cartService.getCartItems(memberId);
|
||||
@ -91,7 +97,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
.skuId(cartItem.getSkuId())
|
||||
.count(cartItem.getCount())
|
||||
.price(cartItem.getPrice())
|
||||
.title(cartItem.getTitle())
|
||||
.skuName(cartItem.getSkuName())
|
||||
.skuCode(cartItem.getSkuCode())
|
||||
.pic(cartItem.getPic())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
@ -109,7 +116,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
|
||||
// 生成唯一标识,防止订单重复提交
|
||||
CompletableFuture<Void> orderTokenCompletableFuture = CompletableFuture.runAsync(() -> {
|
||||
String orderToken = IdUtil.randomUUID();
|
||||
String orderToken = businessNoGenerator.generate(BusinessTypeEnum.ORDER);
|
||||
orderConfirmVO.setOrderToken(orderToken);
|
||||
redisTemplate.opsForValue().set(ORDER_TOKEN_PREFIX + orderToken, orderToken);
|
||||
}, threadPoolExecutor);
|
||||
@ -184,15 +191,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
List<OmsOrderItem> orderItemList = orderItems.stream().map(item -> OmsOrderItem.builder()
|
||||
.orderId(order.getId())
|
||||
.skuId(item.getSkuId())
|
||||
.skuName(item.getTitle())
|
||||
.skuName(item.getSkuName())
|
||||
.skuPrice(item.getPrice())
|
||||
.skuPic(item.getPic())
|
||||
.skuQuantity(item.getCount())
|
||||
.skuCode(item.getSkuCode())
|
||||
.build()).collect(Collectors.toList());
|
||||
orderItemService.saveBatch(orderItemList);
|
||||
|
||||
// 将订单放入延时队列,超时未支付由交换机order.exchange切换到死信队列完成系统自动关单
|
||||
log.info("订单超时取消RabbitMQ消息发送,订单SN:{}",orderToken);
|
||||
log.info("订单超时取消RabbitMQ消息发送,订单SN:{}", orderToken);
|
||||
rabbitTemplate.convertAndSend("order.exchange", "order.create", orderToken);
|
||||
|
||||
OrderSubmitVO submitVO = new OrderSubmitVO();
|
||||
@ -205,6 +213,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@ -248,7 +257,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
||||
log.info("=======================订单关闭,订单SN:{}=======================", orderToken);
|
||||
OmsOrder order = this.getOne(new LambdaQueryWrapper<OmsOrder>()
|
||||
.eq(OmsOrder::getOrderSn, orderToken));
|
||||
if (order==null||!OrderStatusEnum.PENDING_PAYMENT.getCode().equals(order.getStatus())) {
|
||||
if (order == null || !OrderStatusEnum.PENDING_PAYMENT.getCode().equals(order.getStatus())) {
|
||||
return false;
|
||||
}
|
||||
order.setStatus(OrderStatusEnum.AUTO_CANCEL.getCode());
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.mall.oms.test;
|
||||
package com.youlai.mall.oms.controller;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
@ -1,6 +1,7 @@
|
||||
package com.youlai.mall.pms.pojo.bo.admin;
|
||||
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSku;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpec;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpuSpecValue;
|
||||
import com.youlai.mall.pms.pojo.dto.SpuDTO;
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.mall.pms.pojo.bo.app;
|
||||
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSku;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpuAttributeValue;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpecification;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpec;
|
||||
import com.youlai.mall.pms.pojo.dto.SpuDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -19,7 +19,7 @@ public class ProductBO {
|
||||
|
||||
private List<PmsSpuAttributeValue> attrs;
|
||||
|
||||
private List<PmsSpecification> specs;
|
||||
private List<PmsSpec> specs;
|
||||
|
||||
private List<PmsSku> skus;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PmsSpecification extends BaseEntity {
|
||||
public class PmsSpec extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 全面屏手机 颜色 版本
|
@ -3,7 +3,7 @@ package com.youlai.mall.pms.controller.admin;
|
||||
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.pojo.domain.PmsSpec;
|
||||
import com.youlai.mall.pms.service.IPmsSpecService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -12,7 +12,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -31,16 +30,16 @@ public class SpecController {
|
||||
})
|
||||
@GetMapping
|
||||
public Result list(Long categoryId) {
|
||||
List<PmsSpecification> list = iPmsSpecService
|
||||
.list(new LambdaQueryWrapper<PmsSpecification>()
|
||||
.eq(PmsSpecification::getCategoryId, categoryId));
|
||||
List<PmsSpec> list = iPmsSpecService
|
||||
.list(new LambdaQueryWrapper<PmsSpec>()
|
||||
.eq(PmsSpec::getCategoryId, categoryId));
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增规格")
|
||||
@ApiImplicitParam(name = "specCategories", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsSpecCategory")
|
||||
@PostMapping
|
||||
public Result save(@RequestBody List<PmsSpecification> specCategories) {
|
||||
public Result save(@RequestBody List<PmsSpec> specCategories) {
|
||||
|
||||
if (CollectionUtil.isEmpty(specCategories)) {
|
||||
return Result.failed("至少提交一条规格");
|
||||
@ -52,9 +51,9 @@ public class SpecController {
|
||||
List<Long> formIds = specCategories.stream().map(item -> item.getId()).collect(Collectors.toList());
|
||||
|
||||
List<Long> databaseIds = iPmsSpecService
|
||||
.list(new LambdaQueryWrapper<PmsSpecification>()
|
||||
.eq(PmsSpecification::getCategoryId, categoryId)
|
||||
.select(PmsSpecification::getId)
|
||||
.list(new LambdaQueryWrapper<PmsSpec>()
|
||||
.eq(PmsSpec::getCategoryId, categoryId)
|
||||
.select(PmsSpec::getId)
|
||||
).stream()
|
||||
.map(item -> item.getId())
|
||||
.collect(Collectors.toList());
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.youlai.mall.pms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpecification;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpec;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PmsSpecMapper extends BaseMapper<PmsSpecification> {
|
||||
public interface PmsSpecMapper extends BaseMapper<PmsSpec> {
|
||||
|
||||
@Select("<script>" +
|
||||
" SELECT " +
|
||||
@ -22,5 +22,5 @@ public interface PmsSpecMapper extends BaseMapper<PmsSpecification> {
|
||||
@Result(id = true, column = "id", property = "id"),
|
||||
@Result(property = "values", column = "{specId= t1.id,spuId=spuId}", many = @Many(select = "com.youlai.mall.pms.mapper.PmsSpuSpecValueMapper.listByCondition"))
|
||||
})
|
||||
List<PmsSpecification> listBySpuId(Long spuId);
|
||||
List<PmsSpec> listBySpuId(Long spuId);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.youlai.mall.pms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpecification;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpec;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IPmsSpecService extends IService<PmsSpecification> {
|
||||
public interface IPmsSpecService extends IService<PmsSpec> {
|
||||
|
||||
List<PmsSpecification> listBySpuId(Long spuId);
|
||||
List<PmsSpec> listBySpuId(Long spuId);
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.mall.pms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.mall.pms.mapper.PmsSpecMapper;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpecification;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpec;
|
||||
import com.youlai.mall.pms.service.IPmsSpecService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -13,11 +13,11 @@ import java.util.List;
|
||||
* @date 2020-11-06
|
||||
*/
|
||||
@Service
|
||||
public class PmsSpecServiceImpl extends ServiceImpl<PmsSpecMapper, PmsSpecification> implements IPmsSpecService {
|
||||
public class PmsSpecServiceImpl extends ServiceImpl<PmsSpecMapper, PmsSpec> implements IPmsSpecService {
|
||||
|
||||
@Override
|
||||
public List<PmsSpecification> listBySpuId(Long spuId) {
|
||||
List<PmsSpecification> list = this.baseMapper.listBySpuId(spuId);
|
||||
public List<PmsSpec> listBySpuId(Long spuId) {
|
||||
List<PmsSpec> list = this.baseMapper.listBySpuId(spuId);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
iPmsSpuAttributeValueService.saveOrUpdateBatch(list);
|
||||
});
|
||||
|
||||
// 规格保存
|
||||
// 规格值保存
|
||||
Optional.ofNullable(specs).ifPresent(list -> {
|
||||
list.forEach(item -> item.setSpuId(spu.getId()));
|
||||
|
||||
@ -211,7 +211,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
);
|
||||
|
||||
// 规格
|
||||
List<PmsSpecification> specs = iPmsSpecService.listBySpuId(spuId);
|
||||
List<PmsSpec> specs = iPmsSpecService.listBySpuId(spuId);
|
||||
|
||||
// sku
|
||||
List<PmsSku> skuList = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
|
||||
|
@ -9,7 +9,7 @@ import com.youlai.mall.pms.mapper.PmsSpuMapper;
|
||||
import com.youlai.mall.pms.pojo.bo.app.ProductBO;
|
||||
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.PmsSpec;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpu;
|
||||
import com.youlai.mall.pms.pojo.dto.SpuDTO;
|
||||
import com.youlai.mall.pms.service.IPmsSpuAttributeValueService;
|
||||
@ -51,7 +51,7 @@ public class ProductServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> implem
|
||||
);
|
||||
|
||||
// 规格
|
||||
List<PmsSpecification> specs = iPmsSpecService.listBySpuId(spuId);
|
||||
List<PmsSpec> specs = iPmsSpecService.listBySpuId(spuId);
|
||||
|
||||
// sku
|
||||
List<PmsSku> skuList = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
|
||||
|
@ -3,7 +3,7 @@ package com.youlai.mall.pms.controller;
|
||||
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.pojo.domain.PmsSpec;
|
||||
import com.youlai.mall.pms.service.IPmsSpuAttributeValueService;
|
||||
import com.youlai.mall.pms.service.IPmsSpecService;
|
||||
import com.youlai.mall.pms.service.IPmsSpuService;
|
||||
@ -55,7 +55,7 @@ public class ProductControllerTest {
|
||||
|
||||
@Test
|
||||
public void getProductSpecList() {
|
||||
List<PmsSpecification> specifications = iPmsSpecService.listBySpuId(1l);
|
||||
List<PmsSpec> specifications = iPmsSpecService.listBySpuId(1l);
|
||||
log.info(specifications.toString());
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,9 @@ public class DictController {
|
||||
case PAGE:
|
||||
Page<SysDict> result = iSysDictService.page(new Page<>(page, limit), queryWrapper);
|
||||
return Result.success(result.getRecords(), result.getTotal());
|
||||
case LIST:
|
||||
default:
|
||||
List<SysDict> list = iSysDictService.list(queryWrapper);
|
||||
return Result.success(list);
|
||||
default:
|
||||
return Result.failed(ResultCode.QUERY_MODE_IS_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||
|
||||
@Api(tags = "字典项接口")
|
||||
@RestController
|
||||
@RequestMapping("/api.admin/v1/dict-items")
|
||||
@RequestMapping("/api.admin/v1/dict_items")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class DictItemController {
|
||||
|
Loading…
Reference in New Issue
Block a user