增加优惠券发放方法,修复秒杀排序重复
This commit is contained in:
@@ -40,63 +40,63 @@ spring:
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# datasource:
|
||||
# master:
|
||||
# url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: root
|
||||
# slave: # 模拟从库,可根据自己需要修改
|
||||
# url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: root
|
||||
# bxg: # 农场数据源
|
||||
# url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: root
|
||||
# erp: # 进销存
|
||||
# url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: root
|
||||
# farm: # 农场数据源
|
||||
# url: jdbc:p6spy:mysql://192.168.10.250:3306/zsw-farm?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: root
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:p6spy:mysql://localhost:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
username: root
|
||||
password: 123456
|
||||
password: root
|
||||
slave: # 模拟从库,可根据自己需要修改
|
||||
url: jdbc:p6spy:mysql://localhost:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
username: root
|
||||
password: 123456
|
||||
password: root
|
||||
bxg: # 农场数据源
|
||||
url: jdbc:p6spy:mysql://localhost:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
username: root
|
||||
password: 123456
|
||||
password: root
|
||||
erp: # 进销存
|
||||
url: jdbc:p6spy:mysql://localhost/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
username: root
|
||||
password: 123456
|
||||
password: root
|
||||
farm: # 农场数据源
|
||||
url: jdbc:p6spy:mysql://localhost/zsw-farm?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
url: jdbc:p6spy:mysql://192.168.10.250:3306/zsw-farm?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
username: root
|
||||
password: 123456
|
||||
password: root
|
||||
# datasource:
|
||||
# master:
|
||||
# url: jdbc:p6spy:mysql://localhost:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: 123456
|
||||
# slave: # 模拟从库,可根据自己需要修改
|
||||
# url: jdbc:p6spy:mysql://localhost:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: 123456
|
||||
# bxg: # 农场数据源
|
||||
# url: jdbc:p6spy:mysql://localhost:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: 123456
|
||||
# erp: # 进销存
|
||||
# url: jdbc:p6spy:mysql://localhost/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: 123456
|
||||
# farm: # 农场数据源
|
||||
# url: jdbc:p6spy:mysql://localhost/zsw-farm?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
# username: root
|
||||
# password: 123456
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
redis:
|
||||
# host: 192.168.10.250 # 地址
|
||||
host: 127.0.0.1 # 地址
|
||||
host: 192.168.10.250 # 地址
|
||||
# host: 127.0.0.1 # 地址
|
||||
port: 6379 # 端口
|
||||
database: 0 # 数据库索引
|
||||
|
||||
@@ -270,7 +270,7 @@ dubbo:
|
||||
bxg:
|
||||
shop:
|
||||
# API_URL: http://192.168.10.113:48080/bxgApp
|
||||
API_URL: http://78871492.r2.cpolar.top
|
||||
API_URL: http://6fa9fbb0.cpolar.top
|
||||
SITE_URL: http://192.168.10.113:48080/bxgApp
|
||||
UNI_SITE_URL: http://192.168.10.113:48080/bxgApp
|
||||
ADMIN_API_URL: http://192.168.10.113:48080/bxg
|
||||
|
||||
@@ -5,16 +5,27 @@
|
||||
*/
|
||||
package co.yixiang.modules.activity.rest;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
||||
import co.yixiang.enums.CouponEnum;
|
||||
import co.yixiang.event.TemplateBean;
|
||||
import co.yixiang.event.TemplateEvent;
|
||||
import co.yixiang.event.TemplateListenEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.activity.domain.YxStoreCoupon;
|
||||
import co.yixiang.modules.activity.service.YxStoreCouponIssueService;
|
||||
import co.yixiang.modules.activity.service.YxStoreCouponIssueUserService;
|
||||
import co.yixiang.modules.activity.service.YxStoreCouponService;
|
||||
import co.yixiang.modules.activity.service.YxStoreCouponUserService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreCouponQueryCriteria;
|
||||
import co.yixiang.modules.aop.ForbidSubmit;
|
||||
import co.yixiang.modules.user.domain.YxUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -29,6 +40,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-11-09
|
||||
@@ -39,6 +53,17 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class StoreCouponController {
|
||||
|
||||
private final YxStoreCouponService yxStoreCouponService;
|
||||
@Autowired
|
||||
private YxStoreCouponUserService storeCouponUserService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponIssueService couponIssueService;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponIssueUserService storeCouponIssueUserService;
|
||||
|
||||
public StoreCouponController(YxStoreCouponService yxStoreCouponService) {
|
||||
this.yxStoreCouponService = yxStoreCouponService;
|
||||
@@ -67,6 +92,35 @@ public class StoreCouponController {
|
||||
return new ResponseEntity<>(yxStoreCouponService.save(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Log("发放优惠券")
|
||||
@ApiOperation(value = "发放优惠券")
|
||||
@PostMapping(value = "/yxStoreCoupon/give")
|
||||
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_EDIT')")
|
||||
public ResponseEntity giveOut(@Validated @RequestBody CouponGive couponGive){
|
||||
Long couponId = couponGive.getCouponId();
|
||||
couponGive.getUserIds().forEach(yxUser -> {
|
||||
//用户的券记录
|
||||
storeCouponUserService.addUserCoupon(yxUser.getUid(),Math.toIntExact(couponId));
|
||||
// //领取记录
|
||||
// storeCouponIssueUserService.addUserIssue(yxUser.getUid(),Math.toIntExact(couponId));
|
||||
//这里调用微信订阅模板发送消息
|
||||
TemplateBean templateBean = TemplateBean.builder()
|
||||
.couponId(Math.toIntExact(couponId))
|
||||
.uid(yxUser.getUid())
|
||||
.templateType(TemplateListenEnum.TYPE_10.getValue())
|
||||
.time(DateUtil.formatTime(new Date()))
|
||||
.build();
|
||||
publisher.publishEvent(new TemplateEvent(this, templateBean));
|
||||
});
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
||||
//优惠券发放内部类
|
||||
@Data
|
||||
static class CouponGive{
|
||||
private Long couponId;
|
||||
private List<YxUser> userIds;
|
||||
}
|
||||
|
||||
@Log("修改")
|
||||
@ApiOperation(value = "修改")
|
||||
|
||||
+5
-7
@@ -90,6 +90,11 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
|
||||
}
|
||||
|
||||
storeCouponUserService.addUserCoupon(uid,couponIssueQueryVo.getCid());
|
||||
storeCouponIssueUserService.addUserIssue(uid,id);
|
||||
|
||||
if(couponIssueQueryVo.getTotalCount() > 0){
|
||||
yxStoreCouponIssueMapper.decCount(id);
|
||||
}
|
||||
//这里调用微信订阅模板发送消息
|
||||
TemplateBean templateBean = TemplateBean.builder()
|
||||
.couponId(couponIssueQueryVo.getCid())
|
||||
@@ -98,13 +103,6 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
|
||||
.time(DateUtil.formatTime(new Date()))
|
||||
.build();
|
||||
publisher.publishEvent(new TemplateEvent(this, templateBean));
|
||||
|
||||
storeCouponIssueUserService.addUserIssue(uid,id);
|
||||
|
||||
if(couponIssueQueryVo.getTotalCount() > 0){
|
||||
yxStoreCouponIssueMapper.decCount(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ import co.yixiang.modules.activity.service.mapper.YxStoreCouponIssueUserMapper;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -55,6 +56,7 @@ public class YxStoreCouponIssueUserServiceImpl extends BaseServiceImpl<YxStoreCo
|
||||
couponIssueUser.setIssueCouponId(id);
|
||||
couponIssueUser.setUid(uid);
|
||||
this.save(couponIssueUser);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加优惠券记录
|
||||
* 给用户添加优惠券记录
|
||||
* @param uid 用户id
|
||||
* @param cid 优惠券id
|
||||
*/
|
||||
|
||||
+8
-3
@@ -265,7 +265,9 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
||||
.in(YxStoreSeckill::getTimeId,idList)
|
||||
.le(YxStoreSeckill::getStartTime,nowTime)
|
||||
.ge(YxStoreSeckill::getStopTime,nowTime)
|
||||
.orderByDesc(YxStoreSeckill::getSort);
|
||||
// .orderByDesc(YxStoreSeckill::getSort);
|
||||
.orderByDesc(YxStoreSeckill::getId);
|
||||
|
||||
List<YxStoreSeckillQueryVo> yxStoreSeckillQueryVos = generator.convert
|
||||
(yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords(),
|
||||
YxStoreSeckillQueryVo.class);
|
||||
@@ -307,7 +309,8 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
||||
wrapper.eq(YxStoreSeckill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue())
|
||||
.le(YxStoreSeckill::getStartTime,new Date())
|
||||
.ge(YxStoreSeckill::getStopTime,new Date())
|
||||
.orderByDesc(YxStoreSeckill::getSort);
|
||||
// .orderByDesc(YxStoreSeckill::getSort);
|
||||
.orderByDesc(YxStoreSeckill::getId);
|
||||
List<Integer> timeIds=new ArrayList<>();
|
||||
seckillConfigVo.getSeckillTime().forEach(seckillTimeDto -> {
|
||||
if (seckillTimeDto.getStatus()==1){
|
||||
@@ -357,7 +360,9 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
||||
wrapper.eq(YxStoreSeckill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue())
|
||||
.le(YxStoreSeckill::getStartTime,nowTime)
|
||||
.ge(YxStoreSeckill::getStopTime,nowTime)
|
||||
.orderByDesc(YxStoreSeckill::getSort);
|
||||
// .orderByDesc(YxStoreSeckill::getSort);
|
||||
.orderByDesc(YxStoreSeckill::getId);
|
||||
|
||||
SeckillConfigVo seckillConfigVo=yxStoreSeckillService.getStoreSeckil();
|
||||
if (seckillConfigVo.getSeckillTime().size()==0){
|
||||
return null; //没有秒杀配置,不返回秒杀商品
|
||||
|
||||
Reference in New Issue
Block a user