yshop1.5版本新增秒杀功能,手机端新增H5支付,修复其他bug,导出最新sql
This commit is contained in:
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
|
||||
<modules>
|
||||
<module>yshop-common</module>
|
||||
|
@ -1 +1 @@
|
||||
nohup java -jar yshop-api-1.4.jar --spring.profiles.active=prod &
|
||||
nohup java -jar yshop-api-1.5.jar --spring.profiles.active=prod &
|
@ -1,4 +1,4 @@
|
||||
PID=$(ps -ef | grep yshop-api-1.4.jar | grep -v grep | awk '{ print $2 }')
|
||||
PID=$(ps -ef | grep yshop-api-1.5.jar | grep -v grep | awk '{ print $2 }')
|
||||
if [ -z "$PID" ];then
|
||||
echo Application is already stopped
|
||||
else
|
||||
|
191
sql/yxshop.sql
191
sql/yxshop.sql
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -21,18 +21,18 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-tools</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-mp</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!--jwt-->
|
||||
|
@ -0,0 +1,113 @@
|
||||
package co.yixiang.modules.activity.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品表
|
||||
* </p>
|
||||
*
|
||||
* @author xuwenbo
|
||||
* @since 2019-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "YxStoreSeckill对象", description = "商品秒杀产品表")
|
||||
public class YxStoreSeckill extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "商品秒杀产品表id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "返多少积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Integer startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Integer stopTime;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "产品状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮")
|
||||
private Integer isPostage;
|
||||
|
||||
@ApiModelProperty(value = "热门推荐")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "删除 0未删除1已删除")
|
||||
private Integer isDel;
|
||||
|
||||
@ApiModelProperty(value = "最多秒杀几个")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "显示")
|
||||
private Integer isShow;
|
||||
|
||||
private Date endTimeDate;
|
||||
|
||||
private Date startTimeDate;
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package co.yixiang.modules.activity.mapper;
|
||||
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreProductQueryVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import co.yixiang.modules.activity.entity.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuwenbo
|
||||
* @since 2019-12-14
|
||||
*/
|
||||
@Repository
|
||||
public interface YxStoreSeckillMapper extends BaseMapper<YxStoreSeckill> {
|
||||
|
||||
@Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" +
|
||||
" where id=#{seckillId}")
|
||||
int decStockIncSales(@Param("num") int num,@Param("seckillId") int seckillId);
|
||||
|
||||
@Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," +
|
||||
"c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" +
|
||||
" FROM yx_store_seckill c " +
|
||||
" WHERE c.id = #{id} ")
|
||||
YxStoreProductQueryVo seckillInfo(int id);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStoreSeckillQueryVo getYxStoreSeckillById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param yxStoreSeckillQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<YxStoreSeckillQueryVo> getYxStoreSeckillPageList(@Param("page") Page page, @Param("param") YxStoreSeckillQueryParam yxStoreSeckillQueryParam);
|
||||
|
||||
@Select("select t.id, t.image, t.images, t.title, t.info, t.price, t.cost, t.sort, t.stock, t.sales, " +
|
||||
"t.postage, t.description, t.status, t.num from yx_store_seckill t" +
|
||||
"INNER JOIN yx_store_product s ON s.id=t.product_id " +
|
||||
"WHERE t.is_show = 1 AND t.is_del = 0 AND t.start_time < unix_timestamp(now()) " +
|
||||
"AND t.stop_time > unix_timestamp(now()) ORDER BY t.sort desc,t.id desc")
|
||||
List<YxStoreSeckillQueryVo> getCombList(Page<YxStoreSeckill> pageModel, @Param("time") String time);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.activity.mapping;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.activity.entity.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-12-17
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface StoreSeckillMap extends EntityMapper<YxStoreSeckillQueryVo, YxStoreSeckill> {
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package co.yixiang.modules.activity.service;
|
||||
|
||||
import co.yixiang.modules.activity.entity.YxStoreSeckill;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.activity.web.dto.StoreSeckillDTO;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuwenbo
|
||||
* @since 2019-12-14
|
||||
*/
|
||||
public interface YxStoreSeckillService extends BaseService<YxStoreSeckill> {
|
||||
|
||||
void decStockIncSales(int num,int seckillId);
|
||||
|
||||
YxStoreSeckill getSeckill(int id);
|
||||
|
||||
StoreSeckillDTO getDetail(int id) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取产品详情
|
||||
* @param page
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
List<YxStoreSeckillQueryVo> getList(int page, int limit, int startTime,int endTime);
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStoreSeckillQueryVo getYxStoreSeckillById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param yxStoreSeckillQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<YxStoreSeckillQueryVo> getYxStoreSeckillPageList(YxStoreSeckillQueryParam yxStoreSeckillQueryParam) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.entity.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.mapper.YxStoreSeckillMapper;
|
||||
import co.yixiang.modules.activity.mapping.StoreSeckillMap;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.activity.web.dto.StoreSeckillDTO;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductReplyService;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-12-14
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMapper, YxStoreSeckill> implements YxStoreSeckillService {
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillMapper yxStoreSeckillMapper;
|
||||
|
||||
@Autowired
|
||||
private StoreSeckillMap storeSeckillMap;
|
||||
|
||||
@Autowired
|
||||
private YxStoreProductReplyService replyService;
|
||||
|
||||
/**
|
||||
* 减库存增加销量
|
||||
* @param num
|
||||
* @param seckillId
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void decStockIncSales(int num, int seckillId) {
|
||||
yxStoreSeckillMapper.decStockIncSales(num,seckillId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreSeckill getSeckill(int id) {
|
||||
QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>();
|
||||
int nowTime = OrderUtil.getSecondTimestampTwo();
|
||||
wrapper.eq("id",id).eq("is_del",0).eq("status",1)
|
||||
.le("start_time",nowTime).ge("stop_time",nowTime);
|
||||
return yxStoreSeckillMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StoreSeckillDTO getDetail(int id) throws Exception{
|
||||
YxStoreSeckillQueryVo yxStoreSeckillQueryVo = getYxStoreSeckillById(id);
|
||||
|
||||
if(ObjectUtil.isNull(yxStoreSeckillQueryVo)){
|
||||
throw new ErrorRequestException("秒杀产品不存在或已下架");
|
||||
}
|
||||
|
||||
StoreSeckillDTO storeSeckillDTO = StoreSeckillDTO.builder()
|
||||
.storeInfo(yxStoreSeckillQueryVo)
|
||||
.reply(replyService.getReply(yxStoreSeckillQueryVo.getProductId()))
|
||||
.replyCount(replyService.productReplyCount(yxStoreSeckillQueryVo.getProductId()))
|
||||
.build();
|
||||
|
||||
return storeSeckillDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀产品列表
|
||||
* @param page
|
||||
* @param limit
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<YxStoreSeckillQueryVo> getList(int page, int limit,int startTime,int endTime) {
|
||||
Page<YxStoreSeckill> pageModel = new Page<>(page, limit);
|
||||
QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_del",0).eq("status",1)
|
||||
.le("start_time",startTime).ge("stop_time",endTime).orderByDesc("sort");
|
||||
List<YxStoreSeckillQueryVo> yxStoreSeckillQueryVos = storeSeckillMap
|
||||
.toDto(yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords());
|
||||
yxStoreSeckillQueryVos.forEach(item->{
|
||||
Integer sum = item.getSales() + item.getStock();
|
||||
item.setPercent(NumberUtil.round(NumberUtil.mul(NumberUtil.div(item.getSales(),sum),
|
||||
100),0).intValue());
|
||||
});
|
||||
return yxStoreSeckillQueryVos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreSeckillQueryVo getYxStoreSeckillById(Serializable id) throws Exception{
|
||||
|
||||
return yxStoreSeckillMapper.getYxStoreSeckillById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<YxStoreSeckillQueryVo> getYxStoreSeckillPageList(YxStoreSeckillQueryParam yxStoreSeckillQueryParam) throws Exception{
|
||||
Page page = setPageParam(yxStoreSeckillQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<YxStoreSeckillQueryVo> iPage = yxStoreSeckillMapper.getYxStoreSeckillPageList(page,yxStoreSeckillQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
package co.yixiang.modules.activity.web.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.activity.web.dto.SeckillConfigDTO;
|
||||
import co.yixiang.modules.activity.web.dto.SeckillTimeDTO;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.modules.shop.entity.YxSystemGroupData;
|
||||
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuwenbo
|
||||
* @since 2019-12-14
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping
|
||||
@Api(value = "商品秒杀", tags = "商品秒杀", description = "商品秒杀")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class StoreSeckillController extends BaseController {
|
||||
|
||||
private final YxStoreSeckillService yxStoreSeckillService;
|
||||
|
||||
private final YxSystemGroupDataService yxSystemGroupDataService;
|
||||
|
||||
/**
|
||||
* 秒杀产品列表
|
||||
*/
|
||||
@GetMapping("/seckill/list/{time}")
|
||||
@ApiOperation(value = "秒杀产品列表", notes = "秒杀产品列表", response = YxStoreSeckillQueryVo.class)
|
||||
public ApiResult<Object> getYxStoreSeckillPageList(@PathVariable String time,
|
||||
@RequestParam(value = "page", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int limit) throws Exception {
|
||||
if(StrUtil.isBlank(time)) return ApiResult.fail("参数错误");
|
||||
YxSystemGroupData systemGroupData = yxSystemGroupDataService
|
||||
.findData(Integer.valueOf(time));
|
||||
if(ObjectUtil.isNull(systemGroupData)) return ApiResult.fail("参数错误");
|
||||
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));//今天开始的时间戳
|
||||
JSONObject jsonObject = JSONObject.parseObject(systemGroupData.getValue());
|
||||
int startTime = today + (jsonObject.getInteger("time") * 3600);
|
||||
int endTime = today + ((jsonObject.getInteger("time")+jsonObject.getInteger("continued")) * 3600);
|
||||
|
||||
|
||||
return ApiResult.ok(yxStoreSeckillService.getList(page,limit,startTime,endTime));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取商品秒杀产品详情
|
||||
*/
|
||||
@GetMapping("/seckill/detail/{id}")
|
||||
@ApiOperation(value = "获取YxStoreSeckill对象详情", notes = "查看商品秒杀产品表", response = YxStoreSeckillQueryVo.class)
|
||||
public ApiResult<Object> getYxStoreSeckill(@PathVariable Integer id) throws Exception {
|
||||
return ApiResult.ok(yxStoreSeckillService.getDetail(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 秒杀产品时间区间
|
||||
*/
|
||||
@GetMapping("/seckill/index")
|
||||
@ApiOperation(value = "秒杀产品时间区间", notes = "秒杀产品时间区间", response = YxStoreSeckillQueryVo.class)
|
||||
public ApiResult<Object> getYxStoreSeckillIndex() throws Exception {
|
||||
//获取秒杀配置
|
||||
AtomicInteger seckillTimeIndex = new AtomicInteger();
|
||||
SeckillConfigDTO seckillConfigDTO = new SeckillConfigDTO();
|
||||
List<YxSystemGroupData> yxSystemGroupDataList = yxSystemGroupDataService.list(new QueryWrapper<YxSystemGroupData>().eq("group_name", "routine_seckill_time"));
|
||||
List<SeckillTimeDTO> list = new ArrayList<>();
|
||||
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
|
||||
yxSystemGroupDataList.forEach(i -> {
|
||||
String jsonStr = i.getValue();
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
int time = Integer.valueOf(jsonObject.get("time").toString());//时间 5
|
||||
int continued = Integer.valueOf(jsonObject.get("continued").toString());//活动持续事件 3
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH");
|
||||
String nowTime = sdf.format(new Date());
|
||||
String index = nowTime.substring(0, 1);
|
||||
int currentHour = index.equals("0") ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime);
|
||||
SeckillTimeDTO seckillseckillTimeDTO = new SeckillTimeDTO();
|
||||
seckillseckillTimeDTO.setId(i.getId());
|
||||
//活动结束时间
|
||||
int activityEndHour = Integer.valueOf(time).intValue() + Integer.valueOf(continued).intValue();
|
||||
if (activityEndHour > 24) {
|
||||
seckillseckillTimeDTO.setState("即将开始");
|
||||
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
|
||||
seckillseckillTimeDTO.setStatus(2);
|
||||
seckillseckillTimeDTO.setStop(today + activityEndHour * 3600);
|
||||
} else {
|
||||
if (currentHour >= time && currentHour < activityEndHour) {
|
||||
seckillseckillTimeDTO.setState("抢购中");
|
||||
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
|
||||
seckillseckillTimeDTO.setStatus(1);
|
||||
seckillseckillTimeDTO.setStop(today + activityEndHour * 3600);
|
||||
seckillTimeIndex.set(yxSystemGroupDataList.indexOf(i));
|
||||
|
||||
} else if (currentHour < time) {
|
||||
seckillseckillTimeDTO.setState("即将开始");
|
||||
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
|
||||
seckillseckillTimeDTO.setStatus(2);
|
||||
seckillseckillTimeDTO.setStop(OrderUtil.dateToTimestamp(new Date()) + activityEndHour * 3600);
|
||||
} else if (currentHour >= activityEndHour) {
|
||||
seckillseckillTimeDTO.setState("已结束");
|
||||
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
|
||||
seckillseckillTimeDTO.setStatus(0);
|
||||
seckillseckillTimeDTO.setStop(today + activityEndHour * 3600);
|
||||
}
|
||||
}
|
||||
list.add(seckillseckillTimeDTO);
|
||||
});
|
||||
seckillConfigDTO.setSeckillTimeIndex(seckillTimeIndex.get());
|
||||
seckillConfigDTO.setSeckillTime(list);
|
||||
return ApiResult.ok(seckillConfigDTO);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.activity.web.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SeckillConfigDTO {
|
||||
|
||||
|
||||
private List<SeckillTimeDTO> seckillTime;
|
||||
|
||||
private String lovely;
|
||||
|
||||
private Integer seckillTimeIndex;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package co.yixiang.modules.activity.web.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SeckillTimeDTO {
|
||||
|
||||
private Integer id;
|
||||
/**
|
||||
* 00:00
|
||||
*/
|
||||
private String time;
|
||||
/**
|
||||
*状态
|
||||
*/
|
||||
private String state;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Integer stop;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package co.yixiang.modules.activity.web.dto;
|
||||
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreProductReplyQueryVo;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 秒杀产品表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-12-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class StoreSeckillDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private YxStoreProductReplyQueryVo reply;
|
||||
|
||||
private Integer replyCount = 0;
|
||||
|
||||
private YxStoreSeckillQueryVo storeInfo;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package co.yixiang.modules.activity.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import co.yixiang.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxStoreSeckillQueryParam对象", description="商品秒杀产品表查询参数")
|
||||
public class YxStoreSeckillQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package co.yixiang.modules.activity.web.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品秒杀产品表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="YxStoreSeckillQueryVo对象", description="商品秒杀产品表查询参数")
|
||||
public class YxStoreSeckillQueryVo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "商品秒杀产品表id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
private List<String> sliderImageArr;
|
||||
|
||||
public List<String> getSliderImageArr() {
|
||||
if(StrUtil.isNotEmpty(images)){
|
||||
return Arrays.asList(images.split(","));
|
||||
}else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String[] pics;
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "返多少积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Integer startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Integer stopTime;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "产品状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮")
|
||||
private Integer isPostage;
|
||||
|
||||
@ApiModelProperty(value = "热门推荐")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "删除 0未删除1已删除")
|
||||
private Integer isDel;
|
||||
|
||||
@ApiModelProperty(value = "最多秒杀几个")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "显示")
|
||||
private Integer isShow;
|
||||
|
||||
private Integer percent; //百分比
|
||||
|
||||
|
||||
|
||||
}
|
@ -15,6 +15,7 @@ import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
|
||||
|
||||
@ -81,6 +82,8 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
|
||||
|
||||
WxPayMpOrderResult wxPay(String orderId) throws WxPayException;
|
||||
|
||||
WxPayMwebOrderResult wxH5Pay(String orderId) throws WxPayException;
|
||||
|
||||
String aliPay(String orderId) throws Exception;
|
||||
|
||||
void delCacheOrderInfo(int uid, String key);
|
||||
|
@ -8,6 +8,7 @@ import co.yixiang.domain.vo.TradeVo;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.manage.service.YxExpressService;
|
||||
import co.yixiang.modules.manage.web.dto.ChartDataDTO;
|
||||
import co.yixiang.modules.manage.web.dto.OrderDataDTO;
|
||||
@ -59,6 +60,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
@ -150,6 +152,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
@Autowired
|
||||
private YxStoreCombinationService combinationService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillService storeSeckillService;
|
||||
|
||||
@Autowired
|
||||
private YxStorePinkService pinkService;
|
||||
|
||||
@ -936,6 +941,48 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
return payUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayMwebOrderResult wxH5Pay(String orderId) throws WxPayException {
|
||||
|
||||
String apiUrl = systemConfigService.getData("api_url");
|
||||
if(StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
|
||||
|
||||
//读取redis配置
|
||||
String appId = RedisUtil.get("wxpay_appId");
|
||||
String mchId = RedisUtil.get("wxpay_mchId");
|
||||
String mchKey = RedisUtil.get("wxpay_mchKey");
|
||||
if(StrUtil.isBlank(appId) || StrUtil.isBlank(mchId) || StrUtil.isBlank(mchKey)){
|
||||
throw new ErrorRequestException("请配置微信支付");
|
||||
}
|
||||
WxPayConfig wxPayConfig = new WxPayConfig();
|
||||
wxPayConfig.setAppId(appId);
|
||||
wxPayConfig.setMchId(mchId);
|
||||
wxPayConfig.setMchKey(mchKey);
|
||||
wxPayService.setConfig(wxPayConfig);
|
||||
|
||||
YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId,0);
|
||||
if(ObjectUtil.isNull(orderInfo)) throw new ErrorRequestException("订单不存在");
|
||||
if(orderInfo.getPaid() == 1) throw new ErrorRequestException("该订单已支付");
|
||||
|
||||
if(orderInfo.getPayPrice().doubleValue() <= 0) throw new ErrorRequestException("该支付无需支付");
|
||||
|
||||
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
||||
YxUser wechatUser = userService.getById(orderInfo.getUid());
|
||||
if(ObjectUtil.isNull(wechatUser)) throw new ErrorRequestException("用户错误");
|
||||
orderRequest.setTradeType("MWEB");
|
||||
orderRequest.setBody("商品购买");
|
||||
orderRequest.setOutTradeNo(orderId);
|
||||
BigDecimal bigDecimal = new BigDecimal(100);
|
||||
orderRequest.setTotalFee(bigDecimal.multiply(orderInfo.getPayPrice()).intValue());//元转成分
|
||||
orderRequest.setSpbillCreateIp("127.0.0.1");
|
||||
orderRequest.setNotifyUrl(apiUrl+"/api/wechat/notify");
|
||||
|
||||
|
||||
WxPayMwebOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
||||
|
||||
return orderResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
* @param orderId
|
||||
@ -967,14 +1014,15 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
||||
YxWechatUser wechatUser = wechatUserService.getById(orderInfo.getUid());
|
||||
if(ObjectUtil.isNull(wechatUser)) throw new ErrorRequestException("用户错误");
|
||||
orderRequest.setTradeType("JSAPI");
|
||||
orderRequest.setOpenid(wechatUser.getOpenid());
|
||||
orderRequest.setBody("商品购买");
|
||||
orderRequest.setOutTradeNo(orderId);
|
||||
BigDecimal bigDecimal = new BigDecimal(100);
|
||||
orderRequest.setTotalFee(bigDecimal.multiply(orderInfo.getPayPrice()).intValue());//元转成分
|
||||
orderRequest.setOpenid(wechatUser.getOpenid());
|
||||
orderRequest.setSpbillCreateIp("127.0.0.1");
|
||||
orderRequest.setNotifyUrl(apiUrl+"/api/wechat/notify");
|
||||
orderRequest.setTradeType("JSAPI");
|
||||
|
||||
|
||||
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
||||
|
||||
@ -1055,14 +1103,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
Integer gainIntegral = 0;
|
||||
List<String> cartIds = new ArrayList<>();
|
||||
int combinationId = 0;
|
||||
int seckillId = 0;
|
||||
|
||||
for (YxStoreCartQueryVo cart : cartInfo) {
|
||||
combinationId = cart.getCombinationId();
|
||||
seckillId = cart.getSeckillId();
|
||||
cartIds.add(cart.getId().toString());
|
||||
totalNum += cart.getCartNum();
|
||||
//计算积分
|
||||
BigDecimal cartInfoGainIntegral = BigDecimal.ZERO;
|
||||
if(combinationId == 0 ){//拼团等活动不参与积分
|
||||
if(combinationId == 0 && seckillId == 0){//拼团等活动不参与积分
|
||||
if(cart.getProductInfo().getGiveIntegral().intValue() > 0){
|
||||
cartInfoGainIntegral = NumberUtil.mul(cart.getCartNum(),cart.
|
||||
getProductInfo().getGiveIntegral());
|
||||
@ -1089,7 +1139,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
|
||||
boolean deduction = false;//todo 拼团等
|
||||
//拼团等不参与抵扣
|
||||
if(combinationId > 0) deduction = true;
|
||||
if(combinationId > 0 || seckillId > 0) deduction = true;
|
||||
if(deduction){
|
||||
couponId = 0;
|
||||
useIntegral = 0;
|
||||
@ -1175,7 +1225,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
storeOrder.setMark(param.getMark());
|
||||
storeOrder.setCombinationId(combinationId);
|
||||
storeOrder.setPinkId(param.getPinkId());
|
||||
storeOrder.setSeckillId(0);
|
||||
storeOrder.setSeckillId(seckillId);
|
||||
storeOrder.setBargainId(0);
|
||||
storeOrder.setCost(BigDecimal.valueOf(cacheDTO.getPriceGroup().getCostPrice()));
|
||||
storeOrder.setIsChannel(param.getIsChannel());
|
||||
@ -1190,6 +1240,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
for (YxStoreCartQueryVo cart : cartInfo) {
|
||||
if(combinationId > 0){
|
||||
combinationService.decStockIncSales(cart.getCartNum(),combinationId);
|
||||
}else if(seckillId > 0){
|
||||
storeSeckillService.decStockIncSales(cart.getCartNum(),seckillId);
|
||||
} else {
|
||||
productService.decProductStock(cart.getCartNum(),cart.getProductId(),
|
||||
cart.getProductAttrUnique());
|
||||
@ -1246,14 +1298,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
Double payPrice = cacheDTO.getPriceGroup().getTotalPrice();
|
||||
Double payPostage = cacheDTO.getPriceGroup().getStorePostage();
|
||||
|
||||
boolean deduction = false;//todo 拼团等
|
||||
boolean deduction = false;//拼团秒杀砍价等
|
||||
int combinationId = 0;
|
||||
int seckillId = 0;
|
||||
List<YxStoreCartQueryVo> cartInfo = cacheDTO.getCartInfo();
|
||||
for (YxStoreCartQueryVo cart : cartInfo) {
|
||||
combinationId = cart.getCombinationId();
|
||||
seckillId = cart.getSeckillId();
|
||||
}
|
||||
//拼团等不参与抵扣
|
||||
if(combinationId > 0) deduction = true;
|
||||
if(combinationId > 0 || seckillId > 0) deduction = true;
|
||||
|
||||
|
||||
if(deduction){
|
||||
|
@ -31,6 +31,7 @@ import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -96,7 +97,7 @@ public class StoreOrderController extends BaseController {
|
||||
|
||||
confirmOrderDTO.setUsableCoupon(couponUserService
|
||||
.beUsableCoupon(uid,priceGroup.getTotalPrice()));
|
||||
//todo 积分抵扣下个版本 已经do
|
||||
//积分抵扣
|
||||
OtherDTO other = new OtherDTO();
|
||||
other.setIntegralRatio(systemConfigService.getData("integral_ratio"));
|
||||
|
||||
@ -108,8 +109,15 @@ public class StoreOrderController extends BaseController {
|
||||
combinationId = cartQueryVo.getCombinationId();
|
||||
}
|
||||
|
||||
//拼团砍价类产品不参与抵扣
|
||||
if(combinationId > 0) confirmOrderDTO.setDeduction(true);
|
||||
int secKillId = 0;
|
||||
if(cartId.split(",").length == 1){
|
||||
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
|
||||
.valueOf(cartId));
|
||||
secKillId = cartQueryVo.getSeckillId();
|
||||
}
|
||||
|
||||
//拼团砍价秒杀类产品不参与抵扣
|
||||
if(combinationId > 0 || secKillId > 0) confirmOrderDTO.setDeduction(true);
|
||||
|
||||
confirmOrderDTO.setAddressInfo(addressService.getUserDefaultAddress(uid));
|
||||
|
||||
@ -117,7 +125,7 @@ public class StoreOrderController extends BaseController {
|
||||
confirmOrderDTO.setPriceGroup(priceGroup);
|
||||
confirmOrderDTO.setOrderKey(storeOrderService.cacheOrderInfo(uid,cartInfo,
|
||||
priceGroup,other));
|
||||
//todo VIP会员
|
||||
|
||||
|
||||
confirmOrderDTO.setUserInfo(userService.getYxUserById(uid));
|
||||
|
||||
@ -167,16 +175,21 @@ public class StoreOrderController extends BaseController {
|
||||
if(StrUtil.isNotEmpty(orderId)){
|
||||
switch (param.getPayType()){
|
||||
case "weixin":
|
||||
if(param.getFrom().equals("weixinh5")){//此此为支付宝支付
|
||||
|
||||
throw new ErrorRequestException("H5模式不支持微信支付,请用公众号演示");
|
||||
}
|
||||
try {
|
||||
Map<String,String> jsConfig = new HashMap<>();
|
||||
if(param.getFrom().equals("weixinh5")){
|
||||
WxPayMwebOrderResult wxPayMwebOrderResult = storeOrderService
|
||||
.wxH5Pay(orderId);
|
||||
log.info("wxPayMwebOrderResult:{}",wxPayMwebOrderResult);
|
||||
jsConfig.put("mweb_url",wxPayMwebOrderResult.getMwebUrl());
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
map.put("status","WECHAT_H5_PAY");
|
||||
return ApiResult.ok(map);
|
||||
}else{
|
||||
map.put("status","WECHAT_PAY");
|
||||
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
|
||||
.wxPay(orderId);
|
||||
//重新组装
|
||||
Map<String,String> jsConfig = new HashMap<>();
|
||||
jsConfig.put("appId",wxPayMpOrderResult.getAppId());
|
||||
jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp());
|
||||
jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr());
|
||||
@ -186,6 +199,8 @@ public class StoreOrderController extends BaseController {
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
return ApiResult.ok(map,"订单创建成功");
|
||||
}
|
||||
|
||||
} catch (WxPayException e) {
|
||||
return ApiResult.fail(e.getMessage());
|
||||
}
|
||||
@ -230,15 +245,22 @@ public class StoreOrderController extends BaseController {
|
||||
if(StrUtil.isNotEmpty(orderId)){
|
||||
switch (param.getPaytype()){
|
||||
case "weixin":
|
||||
if(param.getFrom().equals("weixinh5")){
|
||||
throw new ErrorRequestException("H5模式不支持微信支付,请用公众号演示");
|
||||
}
|
||||
try {
|
||||
Map<String,String> jsConfig = new HashMap<>();
|
||||
if(param.getFrom().equals("weixinh5")){
|
||||
WxPayMwebOrderResult wxPayMwebOrderResult = storeOrderService
|
||||
.wxH5Pay(orderId);
|
||||
log.info("wxPayMwebOrderResult:{}",wxPayMwebOrderResult);
|
||||
jsConfig.put("mweb_url",wxPayMwebOrderResult.getMwebUrl());
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
map.put("status","WECHAT_H5_PAY");
|
||||
return ApiResult.ok(map);
|
||||
}else{
|
||||
map.put("status","WECHAT_PAY");
|
||||
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
|
||||
.wxPay(orderId);
|
||||
//重新组装
|
||||
Map<String,String> jsConfig = new HashMap<>();
|
||||
jsConfig.put("appId",wxPayMpOrderResult.getAppId());
|
||||
jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp());
|
||||
jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr());
|
||||
@ -248,6 +270,8 @@ public class StoreOrderController extends BaseController {
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
} catch (WxPayException e) {
|
||||
return ApiResult.fail(e.getMessage());
|
||||
}
|
||||
|
@ -115,6 +115,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/wechat/notify").anonymous()
|
||||
.antMatchers("/wechat/serve").anonymous()
|
||||
.antMatchers("/logistics").anonymous()
|
||||
.antMatchers("/seckill/index").anonymous()
|
||||
.antMatchers("/seckill/list/**").anonymous()
|
||||
.antMatchers("/seckill/list/**").anonymous()
|
||||
.antMatchers("/seckill/detail/*").anonymous()
|
||||
// 支付宝回调
|
||||
.antMatchers("/api/aliPay/return").anonymous()
|
||||
.antMatchers("/api/aliPay/notify").anonymous()
|
||||
|
@ -22,4 +22,6 @@ public interface YxSystemGroupDataService extends BaseService<YxSystemGroupData>
|
||||
|
||||
List<Map<String,Object>> getDatas(String name);
|
||||
|
||||
YxSystemGroupData findData(Integer id);
|
||||
|
||||
}
|
||||
|
@ -4,8 +4,13 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.entity.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.mapper.YxStoreCombinationMapper;
|
||||
import co.yixiang.modules.activity.mapper.YxStoreSeckillMapper;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||
import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCart;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProductAttrValue;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCartMapper;
|
||||
@ -70,6 +75,15 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
@Autowired
|
||||
private YxStoreCombinationMapper storeCombinationMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillService storeSeckillService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreOrderService storeOrderService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillMapper storeSeckillMapper;
|
||||
|
||||
@Autowired
|
||||
private YxUserService userService;
|
||||
|
||||
@ -153,6 +167,8 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
YxStoreProductQueryVo storeProduct = null;
|
||||
if(storeCart.getCombinationId() > 0){
|
||||
storeProduct = storeCombinationMapper.combinatiionInfo(storeCart.getCombinationId());
|
||||
}else if(storeCart.getSeckillId() > 0){
|
||||
storeProduct = storeSeckillMapper.seckillInfo(storeCart.getSeckillId());
|
||||
}else{
|
||||
storeProduct = productService
|
||||
.getYxStoreProductById(storeCart.getProductId());
|
||||
@ -177,12 +193,17 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
}else{
|
||||
storeProduct.setAttrInfo(productAttrValue);
|
||||
|
||||
//todo 设置真实价格
|
||||
//设置真实价格
|
||||
//设置VIP价格
|
||||
double vipPrice = userService.setLevelPrice(
|
||||
double vipPrice = 0d;
|
||||
if(storeCart.getCombinationId() > 0 || storeCart.getSeckillId() > 0){
|
||||
vipPrice = productAttrValue.getPrice().doubleValue();
|
||||
}else{
|
||||
vipPrice = userService.setLevelPrice(
|
||||
productAttrValue.getPrice().doubleValue(),uid);
|
||||
}
|
||||
storeCartQueryVo.setTruePrice(vipPrice);
|
||||
//todo 设置会员价
|
||||
//设置会员价
|
||||
storeCartQueryVo.setVipTruePrice(productAttrValue.getPrice()
|
||||
.doubleValue());
|
||||
storeCartQueryVo.setCostPrice(productAttrValue.getCost()
|
||||
@ -193,8 +214,15 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
}
|
||||
}else{
|
||||
//设置VIP价格
|
||||
double vipPrice = userService.setLevelPrice(
|
||||
//设置VIP价格
|
||||
double vipPrice = 0d;
|
||||
if(storeCart.getCombinationId() > 0 || storeCart.getSeckillId() > 0){
|
||||
vipPrice = storeProduct.getPrice().doubleValue();
|
||||
}else{
|
||||
vipPrice = userService.setLevelPrice(
|
||||
storeProduct.getPrice().doubleValue(),uid);
|
||||
}
|
||||
|
||||
storeCartQueryVo.setTruePrice(vipPrice);
|
||||
//todo 设置会员价
|
||||
storeCartQueryVo.setVipTruePrice(0d);
|
||||
@ -236,6 +264,20 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
|
||||
YxStoreCombination storeCombination = storeCombinationService.getCombination(combinationId);
|
||||
if(ObjectUtil.isNull(storeCombination)) throw new ErrorRequestException("该产品已下架或删除");
|
||||
}else if(seckillId > 0){//秒杀
|
||||
YxStoreSeckill yxStoreSeckill = storeSeckillService.getSeckill(seckillId);
|
||||
if(ObjectUtil.isNull(yxStoreSeckill)){
|
||||
throw new ErrorRequestException("该产品已下架或删除");
|
||||
}
|
||||
if(yxStoreSeckill.getStock() < cartNum){
|
||||
throw new ErrorRequestException("该产品库存不足");
|
||||
}
|
||||
int seckillOrderCount = storeOrderService.count(new QueryWrapper<YxStoreOrder>()
|
||||
.eq("uid", uid).eq("paid",1).eq("seckill_id",seckillId));
|
||||
if(yxStoreSeckill.getNum() <= seckillOrderCount || yxStoreSeckill.getNum() < cartNum){
|
||||
throw new ErrorRequestException("每人限购:"+yxStoreSeckill.getNum()+"件");
|
||||
}
|
||||
|
||||
}else{
|
||||
YxStoreProductQueryVo productQueryVo = productService
|
||||
.getYxStoreProductById(productId);
|
||||
@ -263,7 +305,6 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
storeCart.setBargainId(bargainId);
|
||||
storeCart.setCartNum(cartNum);
|
||||
storeCart.setCombinationId(combinationId);
|
||||
storeCart.setIsNew(0);
|
||||
storeCart.setProductAttrUnique(productAttrUnique);
|
||||
storeCart.setProductId(productId);
|
||||
storeCart.setSeckillId(seckillId);
|
||||
|
@ -60,7 +60,13 @@ public class YxSystemGroupDataServiceImpl extends BaseServiceImpl<YxSystemGroupD
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public YxSystemGroupData findData(Integer id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
}
|
||||
|
@ -88,8 +88,14 @@ public class StoreCartController extends BaseController {
|
||||
combinationId = jsonObject.getInteger("combinationId");
|
||||
}
|
||||
|
||||
//秒杀
|
||||
int seckillId = 0;
|
||||
if(ObjectUtil.isNotNull(jsonObject.get("secKillId"))){
|
||||
seckillId = jsonObject.getInteger("secKillId");
|
||||
}
|
||||
|
||||
map.put("cartId",storeCartService.addCart(uid,productId,cartNum,uniqueId
|
||||
,"product",isNew,combinationId,0,0));
|
||||
,"product",isNew,combinationId,seckillId,0));
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
|
@ -1,91 +0,0 @@
|
||||
package co.yixiang.modules.user.web.controller;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxUserRecharge;
|
||||
import co.yixiang.modules.user.service.YxUserRechargeService;
|
||||
import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.common.web.param.IdParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户充值表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-12-08
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/yxUserRecharge")
|
||||
@Api("用户充值表 API")
|
||||
public class YxUserRechargeController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private YxUserRechargeService yxUserRechargeService;
|
||||
|
||||
/**
|
||||
* 添加用户充值表
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加YxUserRecharge对象",notes = "添加用户充值表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> addYxUserRecharge(@Valid @RequestBody YxUserRecharge yxUserRecharge) throws Exception{
|
||||
boolean flag = yxUserRechargeService.save(yxUserRecharge);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户充值表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改YxUserRecharge对象",notes = "修改用户充值表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> updateYxUserRecharge(@Valid @RequestBody YxUserRecharge yxUserRecharge) throws Exception{
|
||||
boolean flag = yxUserRechargeService.updateById(yxUserRecharge);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户充值表
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除YxUserRecharge对象",notes = "删除用户充值表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> deleteYxUserRecharge(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
boolean flag = yxUserRechargeService.removeById(idParam.getId());
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户充值表
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
@ApiOperation(value = "获取YxUserRecharge对象详情",notes = "查看用户充值表",response = YxUserRechargeQueryVo.class)
|
||||
public ApiResult<YxUserRechargeQueryVo> getYxUserRecharge(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
YxUserRechargeQueryVo yxUserRechargeQueryVo = yxUserRechargeService.getYxUserRechargeById(idParam.getId());
|
||||
return ApiResult.ok(yxUserRechargeQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户充值表分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取YxUserRecharge分页列表",notes = "用户充值表分页列表",response = YxUserRechargeQueryVo.class)
|
||||
public ApiResult<Paging<YxUserRechargeQueryVo>> getYxUserRechargePageList(@Valid @RequestBody(required = false) YxUserRechargeQueryParam yxUserRechargeQueryParam) throws Exception{
|
||||
Paging<YxUserRechargeQueryVo> paging = yxUserRechargeService.getYxUserRechargePageList(yxUserRechargeQueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?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="co.yixiang.modules.activity.mapper.YxStoreSeckillMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, product_id, image, images, title, info, price, cost, ot_price, give_integral, sort, stock, sales, unit_name, postage, description, start_time, stop_time, add_time, status, is_postage, is_hot, is_del, num, is_show, end_time_date, start_time_date
|
||||
</sql>
|
||||
|
||||
<select id="getYxStoreSeckillById" resultType="co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_store_seckill where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getYxStoreSeckillPageList" resultType="co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_store_seckill
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!--模板引擎-->
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -20,12 +20,12 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-logging</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-mp</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -0,0 +1,153 @@
|
||||
package co.yixiang.modules.activity.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="yx_store_seckill")
|
||||
public class YxStoreSeckill implements Serializable {
|
||||
|
||||
// 商品秒杀产品表id
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Integer id;
|
||||
|
||||
// 商品id
|
||||
@Column(name = "product_id",nullable = false)
|
||||
private Integer productId;
|
||||
|
||||
// 推荐图
|
||||
@Column(name = "image",nullable = false)
|
||||
@NotBlank(message = "请上传产品图片")
|
||||
private String image;
|
||||
|
||||
// 轮播图
|
||||
@Column(name = "images",nullable = false)
|
||||
@NotBlank(message = "请上传产品轮播图")
|
||||
private String images;
|
||||
|
||||
// 活动标题
|
||||
@Column(name = "title",nullable = false)
|
||||
@NotBlank(message = "请输入产品标题")
|
||||
private String title;
|
||||
|
||||
// 简介
|
||||
@Column(name = "info",nullable = false)
|
||||
@NotBlank(message = "请输入秒杀简介")
|
||||
private String info;
|
||||
|
||||
// 价格
|
||||
@Column(name = "price",nullable = false)
|
||||
@NotNull(message = "秒杀价必填")
|
||||
@Min(value = 0,message = "秒杀价必须大于0")
|
||||
private BigDecimal price;
|
||||
|
||||
// 成本
|
||||
@Column(name = "cost",nullable = false)
|
||||
@NotNull(message = "成本价必填")
|
||||
@Min(value = 0,message = "成本价必须大于0")
|
||||
private BigDecimal cost;
|
||||
|
||||
// 原价
|
||||
@Column(name = "ot_price",nullable = false)
|
||||
@NotNull(message = "原价必填")
|
||||
@Min(value = 0,message = "原价必须大于0")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
// 返多少积分
|
||||
@Column(name = "give_integral",nullable = false)
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
// 排序
|
||||
@Column(name = "sort",nullable = false)
|
||||
@NotNull(message = "排序必填")
|
||||
private Integer sort;
|
||||
|
||||
// 库存
|
||||
@Column(name = "stock",nullable = false)
|
||||
@NotNull(message = "库存必填")
|
||||
private Integer stock;
|
||||
|
||||
// 销量
|
||||
@Column(name = "sales",nullable = false)
|
||||
@NotNull(message = "销量必填")
|
||||
private Integer sales;
|
||||
|
||||
// 单位名
|
||||
@Column(name = "unit_name",nullable = false)
|
||||
@NotBlank(message = "单位名不能为空")
|
||||
private String unitName;
|
||||
|
||||
// 邮费
|
||||
@Column(name = "postage",nullable = false)
|
||||
@NotNull(message = "邮费必填")
|
||||
private BigDecimal postage;
|
||||
|
||||
// 内容
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
// 开始时间
|
||||
@Column(name = "start_time",nullable = false)
|
||||
private Integer startTime;
|
||||
|
||||
// 结束时间
|
||||
@Column(name = "stop_time",nullable = false)
|
||||
private Integer stopTime;
|
||||
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
private Date startTimeDate;
|
||||
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
private Date endTimeDate;
|
||||
|
||||
// 添加时间
|
||||
@Column(name = "add_time",nullable = false)
|
||||
private String addTime;
|
||||
|
||||
// 产品状态
|
||||
@Column(name = "status",nullable = false)
|
||||
@NotNull(message = "活动状态必须选择")
|
||||
private Integer status;
|
||||
|
||||
// 是否包邮
|
||||
@Column(name = "is_postage",nullable = false)
|
||||
@NotNull(message = "包邮状态必须选择")
|
||||
private Integer isPostage;
|
||||
|
||||
// 热门推荐
|
||||
@Column(name = "is_hot",insertable = false)
|
||||
private Integer isHot;
|
||||
|
||||
// 删除 0未删除1已删除
|
||||
@Column(name = "is_del",insertable = false)
|
||||
private Integer isDel;
|
||||
|
||||
// 最多秒杀几个
|
||||
@Column(name = "num",nullable = false)
|
||||
@NotNull(message = "限购必填")
|
||||
@Min(value = 1,message = "限购必须大于0")
|
||||
private Integer num;
|
||||
|
||||
// 显示
|
||||
@Column(name = "is_show",nullable = false)
|
||||
private Integer isShow;
|
||||
|
||||
public void copy(YxStoreSeckill source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package co.yixiang.modules.activity.repository;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
public interface YxStoreSeckillRepository extends JpaRepository<YxStoreSeckill, Integer>, JpaSpecificationExecutor {
|
||||
}
|
@ -46,7 +46,6 @@ public class YxStoreCombinationController {
|
||||
@PutMapping(value = "/yxStoreCombination")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody YxStoreCombination resources){
|
||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||
if(ObjectUtil.isNotNull(resources.getStartTimeDate())){
|
||||
resources.setStartTime(OrderUtil.
|
||||
dateToTimestamp(resources.getStartTimeDate()));
|
||||
|
@ -0,0 +1,73 @@
|
||||
package co.yixiang.modules.activity.rest;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Api(tags = "秒杀管理")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class YxStoreSeckillController {
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillService yxStoreSeckillService;
|
||||
|
||||
@Log("查询YxStoreSeckill")
|
||||
@ApiOperation(value = "查询YxStoreSeckill")
|
||||
@GetMapping(value = "/yxStoreSeckill")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTORESECKILL_ALL','YXSTORESECKILL_SELECT')")
|
||||
public ResponseEntity getYxStoreSeckills(YxStoreSeckillQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(yxStoreSeckillService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Log("修改YxStoreSeckill")
|
||||
@ApiOperation(value = "修改YxStoreSeckill")
|
||||
@PutMapping(value = "/yxStoreSeckill")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTORESECKILL_ALL','YXSTORESECKILL_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody YxStoreSeckill resources){
|
||||
if(ObjectUtil.isNotNull(resources.getStartTimeDate())){
|
||||
resources.setStartTime(OrderUtil.
|
||||
dateToTimestamp(resources.getStartTimeDate()));
|
||||
}
|
||||
if(ObjectUtil.isNotNull(resources.getEndTimeDate())){
|
||||
resources.setStopTime(OrderUtil.
|
||||
dateToTimestamp(resources.getEndTimeDate()));
|
||||
}
|
||||
if(ObjectUtil.isNull(resources.getId())){
|
||||
resources.setAddTime(String.valueOf(OrderUtil.getSecondTimestampTwo()));
|
||||
return new ResponseEntity(yxStoreSeckillService.create(resources),HttpStatus.CREATED);
|
||||
}else{
|
||||
yxStoreSeckillService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Log("删除YxStoreSeckill")
|
||||
@ApiOperation(value = "删除YxStoreSeckill")
|
||||
@DeleteMapping(value = "/yxStoreSeckill/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTORESECKILL_ALL','YXSTORESECKILL_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Integer id){
|
||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||
yxStoreSeckillService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package co.yixiang.modules.activity.service;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDTO;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
//@CacheConfig(cacheNames = "yxStoreSeckill")
|
||||
public interface YxStoreSeckillService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable
|
||||
Map<String,Object> queryAll(YxStoreSeckillQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable
|
||||
List<YxStoreSeckillDTO> queryAll(YxStoreSeckillQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(key = "#p0")
|
||||
YxStoreSeckillDTO findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
YxStoreSeckillDTO create(YxStoreSeckill resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void update(YxStoreSeckill resources);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void delete(Integer id);
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package co.yixiang.modules.activity.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Data
|
||||
public class YxStoreSeckillDTO implements Serializable {
|
||||
|
||||
// 商品秒杀产品表id
|
||||
private Integer id;
|
||||
|
||||
// 商品id
|
||||
private Integer productId;
|
||||
|
||||
// 推荐图
|
||||
private String image;
|
||||
|
||||
// 轮播图
|
||||
private String images;
|
||||
|
||||
// 活动标题
|
||||
private String title;
|
||||
|
||||
// 简介
|
||||
private String info;
|
||||
|
||||
// 价格
|
||||
private BigDecimal price;
|
||||
|
||||
// 成本
|
||||
private BigDecimal cost;
|
||||
|
||||
// 原价
|
||||
private BigDecimal otPrice;
|
||||
|
||||
// 返多少积分
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
// 排序
|
||||
private Integer sort;
|
||||
|
||||
// 库存
|
||||
private Integer stock;
|
||||
|
||||
// 销量
|
||||
private Integer sales;
|
||||
|
||||
// 单位名
|
||||
private String unitName;
|
||||
|
||||
// 邮费
|
||||
private BigDecimal postage;
|
||||
|
||||
// 内容
|
||||
private String description;
|
||||
|
||||
// 开始时间
|
||||
private Integer startTime;
|
||||
|
||||
// 结束时间
|
||||
private Integer stopTime;
|
||||
|
||||
// 添加时间
|
||||
private String addTime;
|
||||
|
||||
// 产品状态
|
||||
private Integer status;
|
||||
|
||||
// 是否包邮
|
||||
private Integer isPostage;
|
||||
|
||||
// 热门推荐
|
||||
private Integer isHot;
|
||||
|
||||
// 删除 0未删除1已删除
|
||||
private Integer isDel;
|
||||
|
||||
// 最多秒杀几个
|
||||
private Integer num;
|
||||
|
||||
// 显示
|
||||
private Integer isShow;
|
||||
|
||||
private Date startTimeDate;
|
||||
|
||||
private Date endTimeDate;
|
||||
|
||||
private String statusStr;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.activity.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Data
|
||||
public class YxStoreSeckillQueryCriteria{
|
||||
|
||||
// 模糊
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String title;
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import co.yixiang.modules.activity.repository.YxStoreSeckillRepository;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDTO;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
||||
import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import co.yixiang.utils.PageUtil;
|
||||
import co.yixiang.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class YxStoreSeckillServiceImpl implements YxStoreSeckillService {
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillRepository yxStoreSeckillRepository;
|
||||
|
||||
@Autowired
|
||||
private YxStoreSeckillMapper yxStoreSeckillMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(YxStoreSeckillQueryCriteria criteria, Pageable pageable){
|
||||
Page<YxStoreSeckill> page = yxStoreSeckillRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
|
||||
QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
List<YxStoreSeckillDTO> storeSeckillDTOS = yxStoreSeckillMapper
|
||||
.toDto(page.getContent());
|
||||
int nowTime = OrderUtil.getSecondTimestampTwo();
|
||||
for (YxStoreSeckillDTO storeSeckillDTO : storeSeckillDTOS){
|
||||
if(storeSeckillDTO.getStatus() > 0){
|
||||
if(storeSeckillDTO.getStartTime() > nowTime){
|
||||
storeSeckillDTO.setStatusStr("活动未开始");
|
||||
}else if(storeSeckillDTO.getStopTime() < nowTime){
|
||||
storeSeckillDTO.setStatusStr("活动已结束");
|
||||
}else if(storeSeckillDTO.getStopTime() > nowTime && storeSeckillDTO.getStartTime() < nowTime){
|
||||
storeSeckillDTO.setStatusStr("正在进行中");
|
||||
}
|
||||
}else {
|
||||
storeSeckillDTO.setStatusStr("关闭");
|
||||
}
|
||||
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",storeSeckillDTOS);
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<YxStoreSeckillDTO> queryAll(YxStoreSeckillQueryCriteria criteria){
|
||||
return yxStoreSeckillMapper.toDto(yxStoreSeckillRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreSeckillDTO findById(Integer id) {
|
||||
Optional<YxStoreSeckill> yxStoreSeckill = yxStoreSeckillRepository.findById(id);
|
||||
ValidationUtil.isNull(yxStoreSeckill,"YxStoreSeckill","id",id);
|
||||
return yxStoreSeckillMapper.toDto(yxStoreSeckill.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public YxStoreSeckillDTO create(YxStoreSeckill resources) {
|
||||
return yxStoreSeckillMapper.toDto(yxStoreSeckillRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(YxStoreSeckill resources) {
|
||||
Optional<YxStoreSeckill> optionalYxStoreSeckill = yxStoreSeckillRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalYxStoreSeckill,"YxStoreSeckill","id",resources.getId());
|
||||
YxStoreSeckill yxStoreSeckill = optionalYxStoreSeckill.get();
|
||||
yxStoreSeckill.copy(resources);
|
||||
yxStoreSeckillRepository.save(yxStoreSeckill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Integer id) {
|
||||
yxStoreSeckillRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.modules.activity.service.mapper;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-14
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface YxStoreSeckillMapper extends EntityMapper<YxStoreSeckillDTO, YxStoreSeckill> {
|
||||
|
||||
}
|
@ -89,7 +89,6 @@ public class YxStoreOrderController {
|
||||
criteria.setRefundStatus(0);
|
||||
break;
|
||||
case "1":
|
||||
System.out.println(orderStatus);
|
||||
criteria.setIsDel(0);
|
||||
criteria.setPaid(1);
|
||||
criteria.setStatus(0);
|
||||
|
@ -18,7 +18,7 @@ public interface YxStoreOrderService {
|
||||
|
||||
Map<String,Object> chartCount();
|
||||
|
||||
String orderType(int id,int pinkId,int combinationId);
|
||||
String orderType(int id,int pinkId,int combinationId,int seckillId);
|
||||
|
||||
void refund(YxStoreOrder resources);
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String orderType(int id,int pinkId, int combinationId) {
|
||||
public String orderType(int id,int pinkId, int combinationId,int seckillId) {
|
||||
String str = "[普通订单]";
|
||||
if(pinkId > 0 || combinationId > 0){
|
||||
YxStorePink storePink = storePinkRepository.findByOrderIdKey(id);
|
||||
@ -171,6 +171,8 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
}else if(seckillId > 0){
|
||||
str = "[秒杀订单]";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@ -211,7 +213,8 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
yxStoreOrderDTO.setPayTypeName(payTypeName);
|
||||
|
||||
yxStoreOrderDTO.setPinkName(orderType(yxStoreOrder.getId()
|
||||
,yxStoreOrder.getPinkId(),yxStoreOrder.getCombinationId()));
|
||||
,yxStoreOrder.getPinkId(),yxStoreOrder.getCombinationId()
|
||||
,yxStoreOrder.getSeckillId()));
|
||||
|
||||
List<StoreOrderCartInfo> cartInfos = yxStoreOrderCartInfoRepository
|
||||
.findByOid(yxStoreOrder.getId());
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-generator</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>co.yixiang</groupId>
|
||||
@ -32,12 +32,12 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-tools</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-shop</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!--jwt-->
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-logging</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!--邮件依赖-->
|
||||
|
Reference in New Issue
Block a user