Compare commits
No commits in common. "d9237a949b91eecefc9c51b7115d66f9337f5bda" and "8db5bb35f73a3e3ec58b364c7198833c6ac99fe9" have entirely different histories.
d9237a949b
...
8db5bb35f7
|
@ -1,74 +0,0 @@
|
||||||
package com.mall.common.domain.request;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.boot.autoconfigure.batch.BatchDataSource;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*Spikes接参
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SpikesRequest {
|
|
||||||
/**
|
|
||||||
* 商品主图
|
|
||||||
*/
|
|
||||||
private String spikesImg;
|
|
||||||
/**
|
|
||||||
* 轮播图
|
|
||||||
*/
|
|
||||||
private String spikesManyImg;
|
|
||||||
/**
|
|
||||||
* 商品标题
|
|
||||||
*/
|
|
||||||
private String spikesTitle;
|
|
||||||
/**
|
|
||||||
* 秒杀活动简介
|
|
||||||
*/
|
|
||||||
private String spikesThings;
|
|
||||||
/**
|
|
||||||
* 单位
|
|
||||||
*/
|
|
||||||
private String spikesUnit;
|
|
||||||
/**
|
|
||||||
* 当天参与活动次数
|
|
||||||
*/
|
|
||||||
private Integer spikesNum;
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
|
||||||
/**
|
|
||||||
* 结束时间
|
|
||||||
*/
|
|
||||||
private Date endTime;
|
|
||||||
/**
|
|
||||||
* 状态(0已开启1为开启)
|
|
||||||
*/
|
|
||||||
private Integer spikesState;
|
|
||||||
/**
|
|
||||||
* spuId
|
|
||||||
*/
|
|
||||||
private Long spuId;
|
|
||||||
/**
|
|
||||||
* 秒杀商品信息
|
|
||||||
*/
|
|
||||||
private List<Sku> skuList;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Sku{
|
|
||||||
private Long skuId; //商品id
|
|
||||||
private BigDecimal activityPrice; //秒杀价格
|
|
||||||
private Integer inventoryRestrict; //限制数量
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.mall.common.domain.vo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*活动商品信息Vo
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ActivitySkuVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* spuId
|
|
||||||
*/
|
|
||||||
private Long spuId;
|
|
||||||
/**
|
|
||||||
* sku名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
* 所属分类id
|
|
||||||
*/
|
|
||||||
private Long categoryId;
|
|
||||||
/**
|
|
||||||
* 品牌id
|
|
||||||
*/
|
|
||||||
private Long brandId;
|
|
||||||
/**
|
|
||||||
* 默认图片
|
|
||||||
*/
|
|
||||||
private String defaultImage;
|
|
||||||
/**
|
|
||||||
* 标题
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
/**
|
|
||||||
* 副标题
|
|
||||||
*/
|
|
||||||
private String subtitle;
|
|
||||||
/**
|
|
||||||
* 价格
|
|
||||||
*/
|
|
||||||
private BigDecimal price;
|
|
||||||
/**
|
|
||||||
* 活动价格
|
|
||||||
*/
|
|
||||||
private BigDecimal activityPrice;
|
|
||||||
/**
|
|
||||||
* 重量(克)
|
|
||||||
*/
|
|
||||||
private Integer weight;
|
|
||||||
/**
|
|
||||||
* 库存
|
|
||||||
*/
|
|
||||||
private Integer inventory;
|
|
||||||
/**
|
|
||||||
* 库存限制量
|
|
||||||
*/
|
|
||||||
private Integer inventoryRestrict;
|
|
||||||
/**
|
|
||||||
* 秒杀id(0未开启秒杀)
|
|
||||||
*/
|
|
||||||
private Integer spikesId;
|
|
||||||
/**
|
|
||||||
* 砍价id(0未开启砍价)
|
|
||||||
*/
|
|
||||||
private Integer bargainId;
|
|
||||||
/**
|
|
||||||
* 拼团id(0未开启拼团)
|
|
||||||
*/
|
|
||||||
private Integer groupId;
|
|
||||||
/**
|
|
||||||
* 秒杀开始时间
|
|
||||||
*/
|
|
||||||
private Date startTime;
|
|
||||||
/**
|
|
||||||
* 秒杀结束时间
|
|
||||||
*/
|
|
||||||
private Date endTime;
|
|
||||||
}
|
|
|
@ -52,10 +52,10 @@
|
||||||
<version>1.2</version>
|
<version>1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- seata事务-->
|
<!-- seata事务-->
|
||||||
<!-- <dependency>-->
|
<dependency>
|
||||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<!-- <artifactId>spring-cloud-starter-alibaba-seata</artifactId>-->
|
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
||||||
<!-- </dependency>-->
|
</dependency>
|
||||||
<!-- canal-->
|
<!-- canal-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.javatool</groupId>
|
<groupId>top.javatool</groupId>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.mall.server;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*server启动类
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class ServerApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(ServerApplication.class,args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package com.mall.server.aop;
|
|
||||||
import com.mall.common.utils.JwtUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.Around;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*aop
|
|
||||||
*/
|
|
||||||
@Aspect
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class LogAnnotationAspect {
|
|
||||||
|
|
||||||
@Pointcut("execution(* com.mall.server.service.impl.*.*(..))")
|
|
||||||
private void allMethod(){}
|
|
||||||
|
|
||||||
//应用周围通知
|
|
||||||
@Around("allMethod()")
|
|
||||||
public void doAround(ProceedingJoinPoint call) throws Throwable{
|
|
||||||
long start = new Date().getTime();
|
|
||||||
String methodName = call.getSignature().getName(); // 获取方法名
|
|
||||||
Object[] args = call.getArgs(); // 获取方法的参数
|
|
||||||
call.proceed();
|
|
||||||
long end = new Date().getTime();
|
|
||||||
log.info("耗时:"+(end-start)/1000+"秒");
|
|
||||||
log.info(methodName+"()方法执行");
|
|
||||||
for (Object arg : args) {
|
|
||||||
log.info("参数:"+String.valueOf(arg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package com.mall.server.controller;
|
|
||||||
import com.mall.common.domain.request.SpikesRequest;
|
|
||||||
import com.mall.common.result.Result;
|
|
||||||
import com.mall.server.service.SpikesService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
/**
|
|
||||||
*秒杀controller
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("spikes")
|
|
||||||
public class SpikesController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SpikesService spikesService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加秒杀场次
|
|
||||||
* @param spikesRequest
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("add")
|
|
||||||
public Result add(@RequestBody SpikesRequest spikesRequest){
|
|
||||||
return spikesService.add(spikesRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.mall.server.controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Test {
|
||||||
|
}
|
|
@ -1,84 +0,0 @@
|
||||||
package com.mall.server.domain;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品Sku
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@TableName("pms_sku")
|
|
||||||
public class SkuEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* spuId
|
|
||||||
*/
|
|
||||||
private Long spuId;
|
|
||||||
/**
|
|
||||||
* sku名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
* 所属分类id
|
|
||||||
*/
|
|
||||||
private Long categoryId;
|
|
||||||
/**
|
|
||||||
* 品牌id
|
|
||||||
*/
|
|
||||||
private Long brandId;
|
|
||||||
/**
|
|
||||||
* 默认图片
|
|
||||||
*/
|
|
||||||
private String defaultImage;
|
|
||||||
/**
|
|
||||||
* 标题
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
/**
|
|
||||||
* 副标题
|
|
||||||
*/
|
|
||||||
private String subtitle;
|
|
||||||
/**
|
|
||||||
* 价格
|
|
||||||
*/
|
|
||||||
private BigDecimal price;
|
|
||||||
/**
|
|
||||||
* 活动价格
|
|
||||||
*/
|
|
||||||
private BigDecimal activityPrice;
|
|
||||||
/**
|
|
||||||
* 重量(克)
|
|
||||||
*/
|
|
||||||
private Integer weight;
|
|
||||||
/**
|
|
||||||
* 库存
|
|
||||||
*/
|
|
||||||
private Integer inventory;
|
|
||||||
/**
|
|
||||||
* 库存限制量
|
|
||||||
*/
|
|
||||||
private Integer inventoryRestrict;
|
|
||||||
/**
|
|
||||||
* 秒杀id(0未开启秒杀)
|
|
||||||
*/
|
|
||||||
private Integer spikesId;
|
|
||||||
/**
|
|
||||||
* 砍价id(0未开启砍价)
|
|
||||||
*/
|
|
||||||
private Integer bargainId;
|
|
||||||
/**
|
|
||||||
* 拼团id(0未开启拼团)
|
|
||||||
*/
|
|
||||||
private Integer groupId;
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package com.mall.server.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*秒杀表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("pms_spikes")
|
|
||||||
public class SpikesEntity {
|
|
||||||
/**
|
|
||||||
* 秒杀id
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long spikesId;
|
|
||||||
/**
|
|
||||||
* 商品主图
|
|
||||||
*/
|
|
||||||
private String spikesImg;
|
|
||||||
/**
|
|
||||||
* 轮播图
|
|
||||||
*/
|
|
||||||
private String spikesManyImg;
|
|
||||||
/**
|
|
||||||
* 商品标题
|
|
||||||
*/
|
|
||||||
private String spikesTitle;
|
|
||||||
/**
|
|
||||||
* 秒杀活动简介
|
|
||||||
*/
|
|
||||||
private String spikesThings;
|
|
||||||
/**
|
|
||||||
* 单位
|
|
||||||
*/
|
|
||||||
private String spikesUnit;
|
|
||||||
/**
|
|
||||||
* 当天参与活动次数
|
|
||||||
*/
|
|
||||||
private Integer spikesNum;
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
|
||||||
/**
|
|
||||||
* 结束时间
|
|
||||||
*/
|
|
||||||
private Date endTime;
|
|
||||||
/**
|
|
||||||
* 状态(0已开启1为开启)
|
|
||||||
*/
|
|
||||||
private Integer spikesState;
|
|
||||||
/**
|
|
||||||
* 0未删除1已删除
|
|
||||||
*/
|
|
||||||
private Integer isDelete;
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package com.mall.server.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品Spu
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("pms_spu")
|
|
||||||
public class SpuEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 商品名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
*所属分类id
|
|
||||||
*/
|
|
||||||
private Long categoryId;
|
|
||||||
/**
|
|
||||||
*品牌id
|
|
||||||
*/
|
|
||||||
private Long brandId;
|
|
||||||
/**
|
|
||||||
*上架状态[0 - 下架,1 - 上架]
|
|
||||||
*/
|
|
||||||
private Integer publishStatus;
|
|
||||||
/**
|
|
||||||
*创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
|
||||||
/**
|
|
||||||
*更新时间
|
|
||||||
*/
|
|
||||||
private Date updateTime;
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.mall.server.enumerate;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum ActivityEnum {
|
|
||||||
SPIKES(0,"秒杀未开启"),
|
|
||||||
BARGAIN(0,"砍价未开启"),
|
|
||||||
GROUP(0,"拼团未开启");
|
|
||||||
|
|
||||||
private Integer code;
|
|
||||||
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
ActivityEnum(Integer code, String msg) {
|
|
||||||
this.code = code;
|
|
||||||
this.msg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMsg() {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMsg(String msg) {
|
|
||||||
this.msg = msg;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.mall.server.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.mall.server.domain.SkuEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品SkuMapperr
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SkuMapper extends BaseMapper<SkuEntity> {
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.mall.server.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.mall.server.domain.SpikesEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 秒杀表mapper
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SpikesMapper extends BaseMapper<SpikesEntity> {
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.mall.server.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.mall.server.domain.SpuEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品spuMapper
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SpuMapper extends BaseMapper<SpuEntity> {
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.mall.server.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.mall.server.domain.SkuEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品SkuService
|
|
||||||
*/
|
|
||||||
public interface SkuService extends IService<SkuEntity> {
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.mall.server.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.mall.common.domain.request.SpikesRequest;
|
|
||||||
import com.mall.common.result.Result;
|
|
||||||
import com.mall.server.domain.SpikesEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*秒杀service
|
|
||||||
*/
|
|
||||||
public interface SpikesService extends IService<SpikesEntity> {
|
|
||||||
|
|
||||||
Result add(SpikesRequest spikesRequest);
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.mall.server.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.mall.server.domain.SpuEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品spuService
|
|
||||||
*/
|
|
||||||
public interface SpuService extends IService<SpuEntity> {
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.mall.server.service.impl;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.mall.server.domain.SkuEntity;
|
|
||||||
import com.mall.server.mapper.SkuMapper;
|
|
||||||
import com.mall.server.service.SkuService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品SkuServiceImpl
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SkuServiceImpl extends ServiceImpl<SkuMapper, SkuEntity>
|
|
||||||
implements SkuService {
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
package com.mall.server.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.mall.common.domain.request.SpikesRequest;
|
|
||||||
import com.mall.common.domain.vo.ActivitySkuVo;
|
|
||||||
import com.mall.common.redis.RedisCache;
|
|
||||||
import com.mall.common.result.Result;
|
|
||||||
import com.mall.server.domain.SkuEntity;
|
|
||||||
import com.mall.server.domain.SpikesEntity;
|
|
||||||
import com.mall.server.enumerate.ActivityEnum;
|
|
||||||
import com.mall.server.mapper.SpikesMapper;
|
|
||||||
import com.mall.server.service.SkuService;
|
|
||||||
import com.mall.server.service.SpikesService;
|
|
||||||
import com.mall.server.service.SpuService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.BoundZSetOperations;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*秒杀serviceImpl
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SpikesServiceImpl extends ServiceImpl<SpikesMapper, SpikesEntity>
|
|
||||||
implements SpikesService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SpikesMapper spikesMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SpuService spuService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SkuService skuService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisCache redisCache;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisTemplate redisTemplate;
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public Result add(SpikesRequest spikesRequest) {
|
|
||||||
//秒杀表信息
|
|
||||||
int spikesId = spikesMapper.insert(
|
|
||||||
SpikesEntity.builder()
|
|
||||||
.spikesImg(spikesRequest.getSpikesImg())
|
|
||||||
.spikesManyImg(spikesRequest.getSpikesManyImg())
|
|
||||||
.spikesTitle(spikesRequest.getSpikesTitle())
|
|
||||||
.spikesThings(spikesRequest.getSpikesThings())
|
|
||||||
.spikesUnit(spikesRequest.getSpikesUnit())
|
|
||||||
.spikesNum(spikesRequest.getSpikesNum())
|
|
||||||
.createTime(spikesRequest.getCreateTime())
|
|
||||||
.endTime(spikesRequest.getEndTime())
|
|
||||||
.spikesState(spikesRequest.getSpikesState())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
//修改sku商品信息
|
|
||||||
skuService.updateBatchById(
|
|
||||||
spikesRequest.getSkuList().stream().map(c->
|
|
||||||
SkuEntity.builder()
|
|
||||||
.id(c.getSkuId())
|
|
||||||
.inventoryRestrict(c.getInventoryRestrict())
|
|
||||||
.activityPrice(c.getActivityPrice())
|
|
||||||
.spikesId(spikesId).build()
|
|
||||||
).collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
//遍历修改后的sku商品信息作转换
|
|
||||||
List<ActivitySkuVo> activitySkuVoList = skuService.list(
|
|
||||||
new LambdaQueryWrapper<SkuEntity>()
|
|
||||||
.eq(SkuEntity::getSpikesId, spikesId)
|
|
||||||
).stream().map(c ->
|
|
||||||
ActivitySkuVo.builder()
|
|
||||||
.id(c.getId())
|
|
||||||
.spuId(c.getSpuId())
|
|
||||||
.name(c.getName())
|
|
||||||
.categoryId(c.getCategoryId())
|
|
||||||
.brandId(c.getBrandId())
|
|
||||||
.defaultImage(c.getDefaultImage())
|
|
||||||
.title(c.getTitle())
|
|
||||||
.subtitle(c.getSubtitle())
|
|
||||||
.price(c.getPrice())
|
|
||||||
.activityPrice(c.getActivityPrice())
|
|
||||||
.weight(c.getWeight())
|
|
||||||
.inventory(c.getInventory())
|
|
||||||
.inventoryRestrict(c.getInventoryRestrict())
|
|
||||||
.spikesId(c.getSpikesId())
|
|
||||||
.bargainId(c.getBargainId())
|
|
||||||
.groupId(c.getGroupId())
|
|
||||||
.startTime(spikesRequest.getCreateTime())
|
|
||||||
.endTime(spikesRequest.getEndTime()).build()).collect(Collectors.toList());
|
|
||||||
activitySkuVoList.forEach(c->{
|
|
||||||
//redis秒杀信息存在时间
|
|
||||||
long expire = c.getEndTime().getTime() - System.currentTimeMillis()/1000/1000;
|
|
||||||
redisCache.setCacheObject("spikes_"+c.getId(),c,expire, TimeUnit.MINUTES);
|
|
||||||
});
|
|
||||||
return Result.success(true,"添加秒杀成功");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.mall.server.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.mall.server.domain.SpuEntity;
|
|
||||||
import com.mall.server.mapper.SpuMapper;
|
|
||||||
import com.mall.server.service.SpuService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*商品spuServiceImpl
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SpuServiceImpl extends ServiceImpl<SpuMapper, SpuEntity>
|
|
||||||
implements SpuService {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
# Auto Configure
|
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
com.mall.common.config.MybatisPlusConfig,\
|
|
||||||
com.mall.common.config.RedisConfig,\
|
|
||||||
com.mall.common.redis.RedisCache,\
|
|
||||||
com.mall.common.config.ThreadPoolConfig,\
|
|
||||||
com.mall.common.handler.GlobalExceptionHandler
|
|
Loading…
Reference in New Issue