Commit bedce491 by xunj

正是上线发布版本

1 parent faadb547
Showing 19 changed files with 204 additions and 75 deletions
......@@ -4,7 +4,9 @@ public enum MsgCodeEnum {
BALANCE_NO("1001","余额不足"),
OPEN_CATTLE1("2001","该用户不存在"),
OPEN_CATTLE2("2002","福牛红包已被领取"),
OPEN_CATTLE3("2003","开奖时间2020-02-17 20:21:00,请少侠耐心等待");
OPEN_CATTLE3("2003","开奖时间2020-02-17 20:21:00,请少侠耐心等待"),
//
RED_PACK_RECHAGE_NO("3001","红包雨未结算完成");
private String code;
private String msg;
......
......@@ -35,14 +35,12 @@ public class CattleController {
}
return cattleBrandService.queryCattleBrandByUserId2(userId);
}
//1,牛牌合成
@PostMapping("/saveComposeCattleBrand" )
@ResponseBody
public ApiResult saveComposeCattleBrand(@RequestBody @Validated ComposeCattleBrandParam param) {
return cattleBrandService.saveComposeCattleBrand(param);
}
//2,打卡合成牛牌
@PostMapping("/saveOpenCattleBrand" )
@ResponseBody
public ApiResult saveOpenCattleBrand(@RequestBody @Validated ComposeCattleBrandParam param) {
......
......@@ -42,6 +42,7 @@ public interface ActivityMapper extends BaseMapper<ActItemDto> {
List<SmashBasinVO> getcollectCardMoney();
List<SmashBasinVO> getGrapRedPackMoney();
GrapRedPackResultVO getGrapRedPackResult(GrapRedPackResultDto dto);
int getRedPackRecharge(GrapRedPackResultDto dto);
List<GrapRedPackResultVO> getGrapRedRainRank(GrapRedPackResultDto dto);
RedAmountConfVO getRedAmountConf(@Param("redSource") String redSource,@Param("batchNum") Long batchNum);
List<Long> getRedIdToCattle(@Param("redAmount") BigDecimal redAmount);
......
......@@ -10,6 +10,7 @@ import java.math.BigDecimal;
*/
@Data
public class RedPackInfoVO {
private Long redId;
private BigDecimal redamount;
private String sourceType;
private String createTime;
......
......@@ -3,10 +3,9 @@ package com.polysoft.activity.service.impl;
import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.polysoft.activity.common.utils.BeanTransferUtils;
import com.polysoft.activity.common.utils.PageQuery;
import com.polysoft.activity.common.utils.PageResult;
import com.polysoft.activity.config.exception.BusinessException;
import com.polysoft.activity.constant.CommonTypeEnum;
import com.polysoft.activity.constant.MsgCodeEnum;
import com.polysoft.activity.mapper.ActivityMapper;
import com.polysoft.activity.mapper.UserInfoMapper;
import com.polysoft.activity.model.dto.AddRedRainDto;
......@@ -56,12 +55,12 @@ public class ActItemServiceImpl implements ActItemService{
item.setActivityStatus(CommonTypeEnum.ACTIVITY_STATUS1.getCode());
item.setSurplusSecond(endTime-cuttentTime);
}
if(cuttentTime < startTime && (startTime - cuttentTime) <30){
/*if(cuttentTime < startTime && (startTime - cuttentTime) <30){
//即将开始
activityMapper.updateActStatus(item.getId(), CommonTypeEnum.ACTIVITY_STATUS2.getCode());
item.setActivityStatus(CommonTypeEnum.ACTIVITY_STATUS2.getCode());
item.setSurplusSecond(endTime-endTime);
}
}*/
if (cuttentTime > endTime) {
//已结束
activityMapper.updateActStatus(item.getId(), CommonTypeEnum.ACTIVITY_STATUS3.getCode());
......@@ -128,6 +127,16 @@ public class ActItemServiceImpl implements ActItemService{
@Override
public ApiResult getGrapRedPackResult(QueeryGrapRedPackResultParam param) {
//查询红包雨是否结算完成
GrapRedPackResultDto dto1 = new GrapRedPackResultDto();
dto1.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
dto1.setBatchNum(param.getBatchNum());
int count = activityMapper.getRedPackRecharge(dto1);
if(count > 0){
return ApiResult.ok(MsgCodeEnum.RED_PACK_RECHAGE_NO.getCode(),MsgCodeEnum.RED_PACK_RECHAGE_NO.getMsg());
}
GrapRedPackResultDto dto = new GrapRedPackResultDto();
dto.setUserId(param.getUserId());
dto.setBatchNum(param.getBatchNum());
......@@ -146,7 +155,7 @@ public class ActItemServiceImpl implements ActItemService{
return ApiResult.ok(activityMapper.getGrapRedRainRank(dto));
}
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = RuntimeException.class)
@Override
public ApiResult testOne() {
AddRedRainDto rainDto = new AddRedRainDto();
......
......@@ -2,6 +2,7 @@ package com.polysoft.activity.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.polysoft.activity.common.exception.BusinessException;
import com.polysoft.activity.constant.CommonTypeEnum;
import com.polysoft.activity.constant.MsgCodeEnum;
import com.polysoft.activity.mapper.ActivityMapper;
......@@ -23,7 +24,10 @@ import com.polysoft.activity.model.vo.UserInfoVO;
import com.polysoft.activity.service.CattleBrandService;
import com.polysoft.activity.utils.ApiResult;
import com.polysoft.activity.utils.SnowFlakeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.math.BigDecimal;
......@@ -36,6 +40,7 @@ import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class CattleBrandServiceImpl implements CattleBrandService {
@Resource
......@@ -85,6 +90,7 @@ public class CattleBrandServiceImpl implements CattleBrandService {
return ApiResult.ok(map);
}
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult saveComposeCattleBrand(ComposeCattleBrandParam param) {
JSONObject object = new JSONObject();
......@@ -97,8 +103,16 @@ public class CattleBrandServiceImpl implements CattleBrandService {
try {
List<UserCattleVO> list = cattleBrandMapper.getComposeCattleBrand(param.getUserId());
if(list !=null && list.size() == 5){
cattleBrandMapper.updateComposeCattleStatus(param.getUserId(),"1", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
cattleBrandMapper.deleteUserCalltle(list);
int k1 = cattleBrandMapper.updateComposeCattleStatus(param.getUserId(),"1", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
if(k1 < 1){
log.error("更新合成牛牌状态是失败");
throw new BusinessException("更新合成牛牌状态是异常");
}
int k2 = cattleBrandMapper.deleteUserCalltle(list);
if(k2 < 1){
log.error("合成牛牌过程,消费牛牌异常");
throw new BusinessException("合成牛牌过程,消费牛牌异常");
}
//插入到t_red_rain
AddRedRainDto rainDto = new AddRedRainDto();
rainDto.setRedId(SnowFlakeUtil.nextId());
......@@ -109,19 +123,24 @@ public class CattleBrandServiceImpl implements CattleBrandService {
rainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
rainDto.setSourceType(CommonTypeEnum.REDPACK_SOURCE_TYPE4.getCode());
rainDto.setCreateTime(new Date());
activityMapper.saveRedRainForOne(rainDto);
int k3 = activityMapper.saveRedRainForOne(rainDto);
if(k3 < 1){
log.error("牛牌合成t_red_rain表失败");
throw new BusinessException("牛牌合成t_red_rain表失败");
}
object.put("isCompose",true);
return ApiResult.ok("200","恭喜合成牛牌",object);
}else {
object.put("isCompose",false);
return ApiResult.ok("200","请继续收集牛牌",object);
}
} catch (Exception e) {
} catch (RuntimeException e) {
e.printStackTrace();
return ApiResult.error();
throw new BusinessException("牛牌合成异常");
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult saveOpenCattleBrand(ComposeCattleBrandParam param) {
//判断是否已经打开过牛牌
......@@ -135,7 +154,7 @@ public class CattleBrandServiceImpl implements CattleBrandService {
return ApiResult.ok(MsgCodeEnum.OPEN_CATTLE2.getCode(),MsgCodeEnum.OPEN_CATTLE2.getMsg());
}
Long currentTime = System.currentTimeMillis()/1000;
Long guiDingTime = DateUtil.parse("2021-02-17 22:21:10","yyyy-MM-dd HH:mm:ss").getTime()/1000;
Long guiDingTime = DateUtil.parse("2021-02-17 22:21:00","yyyy-MM-dd HH:mm:ss").getTime()/1000;
if(currentTime < guiDingTime){
return ApiResult.ok(MsgCodeEnum.OPEN_CATTLE2.getCode(),MsgCodeEnum.OPEN_CATTLE3.getMsg());
}
......@@ -143,7 +162,11 @@ public class CattleBrandServiceImpl implements CattleBrandService {
UpdateUserStatesDto dto = new UpdateUserStatesDto();
dto.setUserId(param.getUserId());
dto.setCattleOpenStatus("1");
userInfoMapper.updateUserStates(dto);
int k1 = userInfoMapper.updateUserStates(dto);
if(k1 < 1){
log.info("ID@@"+param.getUserId()+"@@更新牛一牛状态异常");
throw new BusinessException("更新牛一牛状态异常");
}
//更新聚宝盆余额
List<UserInfoDto> userInfoDtoList = new ArrayList<>();
OpenCattleVO openCattleVO = userInfoMapper.getCattleAmount(param.getUserId());
......@@ -151,15 +174,23 @@ public class CattleBrandServiceImpl implements CattleBrandService {
userInfoDto.setUserId(param.getUserId());
userInfoDto.setRedBalance(openCattleVO.getRedAmount());
userInfoDtoList.add(userInfoDto);
userInfoMapper.updateRedBalace(userInfoDtoList);
activityMapper.updateRedRainIsEnble(openCattleVO.getRedId());
int k2 = userInfoMapper.updateRedBalace(userInfoDtoList);
if(k2 < 1){
log.info("ID@@"+param.getUserId()+"@@更新聚宝盆余额异常");
throw new BusinessException("更新牛一牛状态异常");
}
int k3 = activityMapper.updateRedRainIsEnble(openCattleVO.getRedId());
if(k3 < 1){
log.info("ID@@"+param.getUserId()+"@@打开牛牌更新t_red_rain表异常");
throw new BusinessException("打开牛牌更新t_red_rain表异常");
}
//查询排名
List<RankVO> rankVOList = cattleBrandMapper.getRedSourceType4Rank();
int total = rankVOList.size();
Map<Long, Integer> map = rankVOList.stream().collect(Collectors.toMap(RankVO::getUserId, RankVO::getRanking));
int rank = map.get(param.getUserId());
DecimalFormat df = new DecimalFormat("######0%");
String percent = df.format(Double.valueOf(total-rank)/total);
openCattleVO.setTotalPerson(total);
openCattleVO.setPercent(percent);
......
......@@ -2,6 +2,7 @@ package com.polysoft.activity.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.polysoft.activity.common.exception.BusinessException;
import com.polysoft.activity.common.log.LoggerHelper;
import com.polysoft.activity.constant.CommonTypeEnum;
import com.polysoft.activity.constant.MsgCodeEnum;
......@@ -27,6 +28,7 @@ import com.polysoft.activity.utils.SnowFlakeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
......@@ -121,6 +123,7 @@ public class UserInfoServiceImpl implements UserInfoService {
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult saveShareCattle(ShareLinkParam param) {
try {
......@@ -138,9 +141,15 @@ public class UserInfoServiceImpl implements UserInfoService {
dto.setUserId(param.getUserId());
dto.setCattleBrandId(cattleVO.getCattleBrandId());
list.add(dto);
mapper.saveCattleBrand(list);
int k1 = mapper.saveCattleBrand(list);
if(k1 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@分享获取牛牌异常");
}
//删除用户牛牌关系表数据
cattleBrandMapper.deleteUsetCattleById(param.getCattleId());
int k2 = cattleBrandMapper.deleteUsetCattleById(param.getCattleId());
if(k2 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@分享获取牛牌异常");
}
object.put("cardType",param.getCardType());
object.put("isReceived",true);
return ApiResult.ok("200","领取牛牌成功",object);
......@@ -150,6 +159,7 @@ public class UserInfoServiceImpl implements UserInfoService {
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult saveUserSign(UserInfoParam param) {
try {
......@@ -162,6 +172,9 @@ public class UserInfoServiceImpl implements UserInfoService {
UserSignDto userSignDto = new UserSignDto();
CattleBrandVO cattleBrandVO = null;
CattleBrandConfVO confVO = cattleBrandMapper.queryCattleBrandConf(today);
if(confVO == null){
return ApiResult.error("牛牌概率未配置");
}
if(param.getSignId() != null){
//扣除金额
BigDecimal kouchu = BigDecimal.valueOf(20.00);
......@@ -175,7 +188,10 @@ public class UserInfoServiceImpl implements UserInfoService {
userSignDto.setId(param.getSignId());
userSignDto.setCreateTime(date);
userSignDto.setSignStatus(CommonTypeEnum.USER_SIGN_STATUS1.getCode());
mapper.updateUserSign(userSignDto);
int k1 = mapper.updateUserSign(userSignDto);
if(k1 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@更新签到状态异常");
}
AddRedRainDto rainDto = new AddRedRainDto();
rainDto.setRedId(SnowFlakeUtil.nextId());
rainDto.setUserId(param.getUserId());
......@@ -184,38 +200,52 @@ public class UserInfoServiceImpl implements UserInfoService {
rainDto.setCreateTime(date);
rainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_YES.getCode());
rainDto.setSourceType(CommonTypeEnum.REDPACK_SOURCE_TYPE3.getCode());
activityMapper.saveRedRainForOne(rainDto);
int k2 = activityMapper.saveRedRainForOne(rainDto);
if(k2 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@补签扣钱新增t_red_rain表异常");
}
List<UserInfoDto> list = new ArrayList<>();
UserInfoDto infoDto = new UserInfoDto();
infoDto.setUserId(param.getUserId());
infoDto.setRedBalance(rainDto.getRedAmount());
list.add(infoDto);
mapper.updateRedBalace(list);
}else{
int k3= mapper.updateRedBalace(list);
if(k3 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@补签更新余额异常");
}
}else {
userSignDto.setId(SnowFlakeUtil.nextId());
userSignDto.setUserId(param.getUserId());
userSignDto.setSignStatus("1");
userSignDto.setSignDate(date);
userSignDto.setCreateTime(date);
mapper.saveUserSign(userSignDto);
int k4 = mapper.saveUserSign(userSignDto);
if (k4 < 1) {
throw new BusinessException("ID@@" + param.getUserId() + "@@签到异常");
}
MathRandom random = new MathRandom(confVO.getRate1(), confVO.getRate2(), confVO.getRate3(), confVO.getRate4(), confVO.getRate5());
List<SaveUserCattleDto> list = new ArrayList<>();
SaveUserCattleDto dto = new SaveUserCattleDto();
dto.setId(SnowFlakeUtil.nextId());
dto.setUserId(param.getUserId());
String barandType = random.PercentageRandom() + "";
cattleBrandVO = cattleBrandMapper.queryCattleBrandList(barandType).get(0);
dto.setCattleBrandId(cattleBrandVO.getCattleId());
list.add(dto);
int k5 = mapper.saveCattleBrand(list);
if (k5 < 1) {
throw new BusinessException("ID@@" + param.getUserId() + "@@签到发送牛牌异常");
}
return ApiResult.ok(cattleBrandVO);
}
MathRandom random = new MathRandom(confVO.getRate1(),confVO.getRate2(),confVO.getRate3(),confVO.getRate4(),confVO.getRate5());
List<SaveUserCattleDto> list = new ArrayList<>();
SaveUserCattleDto dto = new SaveUserCattleDto();
dto.setId(SnowFlakeUtil.nextId());
dto.setUserId(param.getUserId());
String barandType = random.PercentageRandom()+"";
cattleBrandVO = cattleBrandMapper.queryCattleBrandList(barandType).get(0);
dto.setCattleBrandId(cattleBrandVO.getCattleId());
list.add(dto);
mapper.saveCattleBrand(list);
return ApiResult.ok(cattleBrandVO);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error(e.getMessage());
}
return ApiResult.ok();
}
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult getFirsetLgoinRed(Long userId) {
//判断是否首次登录
......@@ -237,21 +267,27 @@ public class UserInfoServiceImpl implements UserInfoService {
dto.setSourceType(CommonTypeEnum.REDPACK_SOURCE_TYPE2.getCode());
dto.setBatchNum(99);
dto.setCreateTime(new Date());
activityMapper.saveRedRainForOne(dto);
int k1 = activityMapper.saveRedRainForOne(dto);
if(k1 < 1){
throw new BusinessException("首次登录新增t_red_rain表异常");
}
//更新聚宝盆余额
List<UserInfoDto> userInfoDtoList = new ArrayList<>();
UserInfoDto userInfoDto = new UserInfoDto();
userInfoDto.setUserId(userId);
userInfoDto.setRedBalance(redVO.getAmount());
userInfoDtoList.add(userInfoDto);
mapper.updateRedBalace(userInfoDtoList);
int k2 = mapper.updateRedBalace(userInfoDtoList);
if(k2 < 1){
throw new BusinessException("ID@@"+userId+"@@首次登录更新余额异常");
}
//更新首次登录状态
mapper.updateFirstLoginStatus(userId);
return ApiResult.ok(redVO.getAmount());
}
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error();
throw new BusinessException("ID@@"+userId+"@@首次登录更新余额异常");
}
return ApiResult.ok();
}
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.polysoft.activity.common.exception.BusinessException;
import com.polysoft.activity.common.utils.BeanTransferUtils;
import com.polysoft.activity.common.utils.PageResult;
import com.polysoft.activity.mapper.CattleBrandMapper;
......@@ -29,6 +30,7 @@ import com.polysoft.activity.utils.MathRandom;
import com.polysoft.activity.utils.SnowFlakeUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
......@@ -54,6 +56,7 @@ public class WishServiceImpl implements WishService {
@Value("${fileUpload.callWishPicUrl}")
private String callWishPicUrl;
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult addWish(AddWishParam param) {
try {
......@@ -86,16 +89,22 @@ public class WishServiceImpl implements WishService {
saveUserCattleDto.setUserId(param.getUserId());
String barandType = random.PercentageRandom()+"";
cattleBrandVO = cattleBrandMapper.queryCattleBrandList(barandType).get(0);
if(cattleBrandVO == null) {
throw new BusinessException("ID@@"+param.getUserId()+"@@发送心愿发放牛牌异常");
}
saveUserCattleDto.setCattleBrandId(cattleBrandVO.getCattleId());
list.add(saveUserCattleDto);
userInfoMapper.saveCattleBrand(list);
int k2 = userInfoMapper.saveCattleBrand(list);
if(k2 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@发送心愿发放牛牌异常");
}
return ApiResult.ok(cattleBrandVO);
}else{
return ApiResult.ok();
}
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error(e.getMessage());
throw new BusinessException("ID@@"+param.getUserId()+"@@发送心愿发放牛牌异常");
}
}
......
......@@ -35,8 +35,8 @@ public class CattleBrandCarveUpTask {
private ActivityMapper activityMapper;
// @Scheduled( cron = "0 20 20 * * ? ")
// @Scheduled(initialDelay = 60000, fixedRate = 1*15*60*1000)
@Scheduled( cron = "0 5 20 17 2 ? ") // 2021年2月17号 20时5分0秒 执行
// @Scheduled(initialDelay = 5000, fixedRate = 1*15*60*1000)
@Scheduled( cron = "0 1 20 17 2 ? ") // 2021年2月17号 20时分0秒 执行
public void execute() {
try {
sendWechat();
......@@ -48,10 +48,9 @@ public class CattleBrandCarveUpTask {
log.info("牛牌瓜分红包任务开始");
//查询已经合成牛牌的红包
List<Long> list = activityMapper.getRedIdToCattle(null);
List<Long> lastList = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00));
//第一批 牛牌瓜分
//生成数量
int count_1 = (int) (list.size()*0.05);
int count_1 = (int) (list.size()*0.05)+1;
//生成范围
int random_1 = list.size();
HashSet<Integer> set_1 = getLuckUser(count_1,random_1);
......@@ -76,7 +75,7 @@ public class CattleBrandCarveUpTask {
//未充值的牛牌红包
List<Long> redCattlePacke_2 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00));
//生成数量
int count_2 = (int) (list.size()*0.15);
int count_2 = (int) (list.size()*0.15)+1;
//生成范围
int random_2 = redCattlePacke_2.size();
HashSet<Integer> set_2 = getLuckUser(count_2,random_2);
......@@ -99,7 +98,7 @@ public class CattleBrandCarveUpTask {
//未充值的牛牌红包
List<Long> redCattlePacke_3 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00));
//生成数量
int count_3 = (int) (list.size()*0.40);
int count_3 = (int) (list.size()*0.40)+1;
//生成范围
int random_3 = redCattlePacke_3.size();
HashSet<Integer> set_3 = getLuckUser(count_3,random_3);
......
......@@ -3,12 +3,15 @@ package com.polysoft.activity.task;
import com.polysoft.activity.common.utils.BeanTransferUtils;
import com.polysoft.activity.constant.CommonTypeEnum;
import com.polysoft.activity.mapper.ActivityMapper;
import com.polysoft.activity.mapper.CattleBrandMapper;
import com.polysoft.activity.mapper.UserInfoMapper;
import com.polysoft.activity.model.dto.*;
import com.polysoft.activity.model.vo.CattleBrandConfVO;
import com.polysoft.activity.model.vo.CattleBrandVO;
import com.polysoft.activity.model.vo.RedAmountTotalVO;
import com.polysoft.activity.model.vo.RedRainVO;
import com.polysoft.activity.service.CattleBrandService;
import com.polysoft.activity.utils.MathRandom;
import com.polysoft.activity.utils.RedPacketUtil;
import com.polysoft.activity.utils.SnowFlakeUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -39,13 +42,22 @@ public class InitRedPackageTask1 {
private CattleBrandService cattleBrandService;
@Resource
private UserInfoMapper userInfoMapper;
@Resource
private CattleBrandMapper cattleBrandMapper;
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "30 50 14 * * ? ")
@Scheduled( cron = "32 0 20 11 2 ? ") // 2月11日 20点0分32秒执行
// @Scheduled( cron = "40 10 17 * * ? ")
@Scheduled( cron = "40 0 20 11 2 ? ") // 2月11日 20点0分40秒执行
public void execute() {
System.out.println("时间正确");
try {
Thread.sleep(5000);
sendWechat();
} catch (InterruptedException e) {
e.printStackTrace();
throw new RuntimeException("第一场红包雨线程睡眠异常");
}
}
private void sendWechat(){
log.info("第一批红包雨任务开始");
......@@ -61,7 +73,7 @@ public class InitRedPackageTask1 {
//前10%红包
int redNum = (int)(list.size()*0.1);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list.size());
int i = 0;
for (Integer s : set) {
......@@ -91,7 +103,7 @@ public class InitRedPackageTask1 {
//前20%红包
int redNum = (int)(list.size()*0.2);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list2.size());
int i = 0;
for (Integer s : set) {
......@@ -119,7 +131,7 @@ public class InitRedPackageTask1 {
//前65%红包
int redNum = (int)(list.size()*0.65);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.5,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.5,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list2.size());
int i = 0;
for (Integer s : set) {
......
......@@ -45,10 +45,16 @@ public class InitRedPackageTask2 {
private UserInfoMapper userInfoMapper;
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "20 17 21 * * ? ")
@Scheduled( cron = "32 0 22 11 2 ? ") // 2月11日 22点0分32秒执行
// @Scheduled( cron = "40 15 17 * * ? ")
@Scheduled( cron = "40 0 22 11 2 ? ") // 2月11日 22点0分40秒执行
public void execute() {
try {
Thread.sleep(5000);
sendWechat();
} catch (InterruptedException e) {
e.printStackTrace();
throw new RuntimeException("第二场红包雨线程睡眠异常");
}
}
private void sendWechat(){
......@@ -65,7 +71,7 @@ public class InitRedPackageTask2 {
//前10%红包
int redNum = (int)(list.size()*0.1);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list.size());
int i = 0;
for (Integer s : set) {
......@@ -95,7 +101,7 @@ public class InitRedPackageTask2 {
//前20%红包
int redNum = (int)(list.size()*0.2);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list2.size());
int i = 0;
for (Integer s : set) {
......@@ -123,7 +129,7 @@ public class InitRedPackageTask2 {
//前65%红包
int redNum = (int)(list.size()*0.65);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.5,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.5,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list2.size());
int i = 0;
for (Integer s : set) {
......
......@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
......@@ -45,10 +46,16 @@ public class InitRedPackageTask3 {
private UserInfoMapper userInfoMapper;
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "20 17 21 * * ? ")
@Scheduled( cron = "32 0 0 12 2 ? ") // 2月12日 0时0点0分32秒执行
// @Scheduled( cron = "40 20 17 * * ? ")
@Scheduled( cron = "40 0 0 12 2 ? ") // 2月12日 0时0点0分40秒执行
public void execute() {
try {
Thread.sleep(5000);
sendWechat();
} catch (InterruptedException e) {
e.printStackTrace();
throw new RuntimeException("第三场红包雨线程睡眠异常");
}
}
private void sendWechat(){
......@@ -62,10 +69,11 @@ public class InitRedPackageTask3 {
dto1.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
dto1.setBatchNum(batchNum);
List<RedRainVO> list = activityMapper.queryRedRainList(dto1);
// !CollectionUtils.isEmpty(blackLists)
//前10%红包
int redNum = (int)(list.size()*0.1);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list.size());
int i = 0;
for (Integer s : set) {
......@@ -95,7 +103,7 @@ public class InitRedPackageTask3 {
//前20%红包
int redNum = (int)(list.size()*0.2);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.25,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list2.size());
int i = 0;
for (Integer s : set) {
......@@ -123,7 +131,7 @@ public class InitRedPackageTask3 {
//前65%红包
int redNum = (int)(list.size()*0.65);
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(totalMoney*0.5,redNum,0.01,100,2.1);
List<Double> redAmount= redpack.getMoney(totalMoney*0.5,redNum,0.01,200,2.1);
HashSet<Integer> set = getLuckUser(redNum,list2.size());
int i = 0;
for (Integer s : set) {
......
......@@ -29,9 +29,8 @@ public class UserSignTask {
/**
* 补签任务
*/
// @Scheduled( cron = "0 21 20 * * ? ")
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
@Scheduled( cron = "0 5 0 4,13,14,15,16,17 2 ? ") //2月12,13,14,15,16,17 0时5分0秒执行
// @Scheduled( cron = "0 35 17 * * ? ")
@Scheduled( cron = "0 5 0 12,13,14,15,16,17 2 ? ") //2月12,13,14,15,16,17 0时5分0秒执行
public void execute() {
try {
sendWechat();
......
......@@ -31,7 +31,8 @@ public class WishLuckDrawTask {
@Resource
private WishRealPrizeMapper wishRealPrizeMapper;
// @Scheduled( cron = "0 21 20 * * ? ")
// @Scheduled( cron = "0 40 17 * * ? ")
// @Scheduled(initialDelay = 5000, fixedRate = 1*15*60*1000)
@Scheduled( cron = "0 20 20 11,12,13,14,15,16,17 2 ? ")//2月11,12,13,14,15,16,17, 20时20分0秒执行
public void execute() {
try {
......@@ -65,7 +66,7 @@ public class WishLuckDrawTask {
WishRealPrizeDto dto = new WishRealPrizeDto();
dto.setId(SnowFlakeUtil.nextId());
dto.setUserId(item.getUserId());
dto.setWishId(dto.getWishId());
dto.setWishId(item.getWishId());
dto.setPrizeId(realPrizeVO.getPrizeId());
dto.setCreateTime(date);
dtos.add(dto);
......
......@@ -172,6 +172,7 @@
</select>
<select id="queryRedPackInfo" resultType="com.polysoft.activity.model.vo.RedPackInfoVO">
SELECT
t.red_id ,
t.red_amount,
t.source_type,
t.create_time
......@@ -180,7 +181,7 @@
WHERE
t.user_id = #{userId} and red_type = '1' and t.is_enble='1'
ORDER BY
t.create_time DESC
t.red_id DESC
</select>
<select id="getKukcyMoney" resultType="com.polysoft.activity.model.vo.SmashBasinVO">
SELECT
......@@ -263,4 +264,13 @@
and red_amount = #{redAmount}
</if>
</select>
<select id="getRedPackRecharge" resultType="java.lang.Integer">
SELECT
count(*)
FROM
t_red_rain t
WHERE
t.batch_num = #{batchNum}
AND t.is_enble = #{isEnble}
</select>
</mapper>
......@@ -98,8 +98,8 @@
<select id="getTaskStatus" resultType="com.polysoft.activity.model.vo.TaskStatusVO">
SELECT
t.user_id AS userId,
(select count(*) from t_wish tw where tw.user_id = t.user_id and tw.push_date=#{today}) AS everyDaySign,
(select count(*) from t_user_sign tus where tus.user_id = t.user_id and tus.sign_status='1' and tus.sign_date=#{today}) AS everyDayWish,
(select count(*) from t_wish tw where tw.user_id = t.user_id and tw.push_date=#{today}) AS everyDayWish ,
(select count(*) from t_user_sign tus where tus.user_id = t.user_id and tus.sign_status='1' and tus.sign_date=#{today}) AS everyDaySign,
(select count(*) from t_share ts where ts.user_id = t.user_id and ts.share_date=#{today}) AS everyDayShare
FROM
t_user t
......
......@@ -30,8 +30,9 @@
FROM
t_wish t
WHERE
t.push_date = DATE_FORMAT(NOW(),'%Y-%m-%d')
AND t.user_id NOT IN ( SELECT t2.user_id FROM t_wish_real_prize t2 )
t.push_date = '2021-02-04'
/* t.push_date = DATE_FORMAT(NOW(),'%Y-%m-%d')
*/ AND t.user_id NOT IN ( SELECT t2.user_id FROM t_wish_real_prize t2 )
GROUP by t.user_id
order by t.user_id asc
</select>
......
package com.polysoft.activity.config.exception;
package com.polysoft.activity.common.exception;
import javax.servlet.http.HttpServletResponse;
......@@ -6,13 +6,13 @@ import javax.servlet.http.HttpServletResponse;
* @author by zhangbr
* @date 2020/4/20.
*/
public class BusinessException extends Exception {
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 1L;
private Integer statusCode;
public BusinessException() {
public BusinessException() {
super ();
this.statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
......
......@@ -78,4 +78,10 @@ public class RedPacketUtil {
return splitRedPackets(money,count,MINMONEY, MAXMONEY,TIMES);
}
public static void main(String[] args) {
RedPacketUtil redpack = new RedPacketUtil();
List<Double> redAmount= redpack.getMoney(4000,227,5,100,2.1);
redAmount.forEach(a -> System.out.println(a));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!