Commit b2536282 by xunj

正是上线发布版本

1 parent 2e39e83a
Showing 23 changed files with 186 additions and 68 deletions
...@@ -23,7 +23,9 @@ public enum CommonTypeEnum { ...@@ -23,7 +23,9 @@ public enum CommonTypeEnum {
//红包雨活动状态 //红包雨活动状态
ACTIVITY_STATUS1("1","未开始"), ACTIVITY_STATUS1("1","未开始"),
ACTIVITY_STATUS2("2","进行中"), ACTIVITY_STATUS2("2","进行中"),
ACTIVITY_STATUS3("3","已结束"); ACTIVITY_STATUS3("3","已结束"),
LINK_SHARE_YES("1","牛牌已被分享");
//编码 //编码
private String code; private String code;
//描述 //描述
......
...@@ -53,4 +53,10 @@ public class CattleController { ...@@ -53,4 +53,10 @@ public class CattleController {
return cattleBrandService.getTaskStatus(param); return cattleBrandService.getTaskStatus(param);
} }
@PostMapping("/getOpenCattleBrandResult" )
@ResponseBody
public ApiResult getOpenCattleBrandResult(@RequestBody @Validated ComposeCattleBrandParam param) {
return cattleBrandService.getTaskStatus(param);
}
} }
...@@ -37,6 +37,12 @@ public class UserController { ...@@ -37,6 +37,12 @@ public class UserController {
return userInfoService.getShareLink(param); return userInfoService.getShareLink(param);
} }
@PostMapping("/saveShareCallBack" )
@ResponseBody
public ApiResult saveShareCallBack(@RequestBody @Validated ShareLinkParam param) {
return userInfoService.saveShareCallBack(param);
}
@PostMapping("/saveShareCattle" ) @PostMapping("/saveShareCattle" )
@ResponseBody @ResponseBody
public ApiResult saveShareCattle(@RequestBody @Validated ShareLinkParam param) { public ApiResult saveShareCattle(@RequestBody @Validated ShareLinkParam param) {
......
...@@ -45,6 +45,6 @@ public interface ActivityMapper extends BaseMapper<ActItemDto> { ...@@ -45,6 +45,6 @@ public interface ActivityMapper extends BaseMapper<ActItemDto> {
int getRedPackRecharge(GrapRedPackResultDto dto); int getRedPackRecharge(GrapRedPackResultDto dto);
List<GrapRedPackResultVO> getGrapRedRainRank(GrapRedPackResultDto dto); List<GrapRedPackResultVO> getGrapRedRainRank(GrapRedPackResultDto dto);
RedAmountConfVO getRedAmountConf(@Param("redSource") String redSource,@Param("batchNum") Long batchNum); RedAmountConfVO getRedAmountConf(@Param("redSource") String redSource,@Param("batchNum") Long batchNum);
List<Long> getRedIdToCattle(@Param("redAmount") BigDecimal redAmount); List<Long> getRedIdToCattle(@Param("redAmount") BigDecimal redAmount,@Param("limit") Integer limit);
} }
...@@ -29,6 +29,8 @@ public interface CattleBrandMapper extends BaseMapper<CattleBrandDto> { ...@@ -29,6 +29,8 @@ public interface CattleBrandMapper extends BaseMapper<CattleBrandDto> {
int saveShareForCattle(ShareDto dto); int saveShareForCattle(ShareDto dto);
int deleteUsetCattleById(@Param("id") Long id); int deleteUsetCattleById(@Param("id") Long id);
List<RankVO> getRedSourceType4Rank(); List<RankVO> getRedSourceType4Rank();
UserCattleVO getUserCattleVOById(@Param("id") Long id ); UserCattleVO getUserCattleVOById(@Param("id") Long id,@Param("status") String status );
int updateUserCattleStatus(@Param("id") Long id ,@Param("status") String status);
} }
...@@ -15,4 +15,6 @@ public class UpdateUserStatesDto { ...@@ -15,4 +15,6 @@ public class UpdateUserStatesDto {
private String hammerStatus; private String hammerStatus;
//0 牛牌合成未打卡 1 已打开 //0 牛牌合成未打卡 1 已打开
private String cattleOpenStatus; private String cattleOpenStatus;
//0 首次分享 1 非首次分享
private String isFirstShare;
} }
...@@ -21,4 +21,6 @@ public class UserInfoDto implements Serializable { ...@@ -21,4 +21,6 @@ public class UserInfoDto implements Serializable {
private BigDecimal redBalance; private BigDecimal redBalance;
@ApiModelProperty("部门名称") @ApiModelProperty("部门名称")
private String deptName; private String deptName;
private String isFirst;
} }
...@@ -20,4 +20,5 @@ public class ShareLinkParam { ...@@ -20,4 +20,5 @@ public class ShareLinkParam {
private String cardType; private String cardType;
//链接上的牛牌Id //链接上的牛牌Id
private Long cattleBrandId; private Long cattleBrandId;
private String isFirstShare;
} }
...@@ -34,5 +34,7 @@ public class UserInfoVO implements Serializable { ...@@ -34,5 +34,7 @@ public class UserInfoVO implements Serializable {
private String cattleOpenStatus; private String cattleOpenStatus;
//牛牌种类数量 //牛牌种类数量
private String cattleTypeNum; private String cattleTypeNum;
//0 首次分享 1 非首次分享
private String isFirstShare;
} }
...@@ -11,4 +11,5 @@ public interface CattleBrandService { ...@@ -11,4 +11,5 @@ public interface CattleBrandService {
ApiResult saveComposeCattleBrand(ComposeCattleBrandParam param); ApiResult saveComposeCattleBrand(ComposeCattleBrandParam param);
ApiResult saveOpenCattleBrand(ComposeCattleBrandParam param); ApiResult saveOpenCattleBrand(ComposeCattleBrandParam param);
ApiResult getTaskStatus(ComposeCattleBrandParam param); ApiResult getTaskStatus(ComposeCattleBrandParam param);
ApiResult getOpenCattleBrandResult(ComposeCattleBrandParam param);
} }
...@@ -12,6 +12,7 @@ public interface UserInfoService { ...@@ -12,6 +12,7 @@ public interface UserInfoService {
ApiResult queryAuthUser(UserInfoParam param); ApiResult queryAuthUser(UserInfoParam param);
ApiResult getShareLink(ShareLinkParam param); ApiResult getShareLink(ShareLinkParam param);
ApiResult saveShareCattle(ShareLinkParam param); ApiResult saveShareCattle(ShareLinkParam param);
ApiResult saveShareCallBack(ShareLinkParam param);
ApiResult saveUserSign(UserInfoParam param); ApiResult saveUserSign(UserInfoParam param);
ApiResult getFirsetLgoinRed(Long userId); ApiResult getFirsetLgoinRed(Long userId);
ApiResult queryUserSignByUserId(Long userId,String signDate); ApiResult queryUserSignByUserId(Long userId,String signDate);
......
...@@ -202,4 +202,19 @@ public class CattleBrandServiceImpl implements CattleBrandService { ...@@ -202,4 +202,19 @@ public class CattleBrandServiceImpl implements CattleBrandService {
String today = DateUtil.format(new Date(),"yyyy-MM-dd"); String today = DateUtil.format(new Date(),"yyyy-MM-dd");
return ApiResult.ok(cattleBrandMapper.getTaskStatus(param.getUserId(),today)); return ApiResult.ok(cattleBrandMapper.getTaskStatus(param.getUserId(),today));
} }
@Override
public ApiResult getOpenCattleBrandResult(ComposeCattleBrandParam param) {
OpenCattleVO openCattleVO = new OpenCattleVO();
//查询排名
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);
return ApiResult.ok(openCattleVO);
}
} }
...@@ -23,6 +23,7 @@ import com.polysoft.activity.model.vo.*; ...@@ -23,6 +23,7 @@ import com.polysoft.activity.model.vo.*;
import com.polysoft.activity.service.UserInfoService; import com.polysoft.activity.service.UserInfoService;
import com.polysoft.activity.utils.ApiResult; import com.polysoft.activity.utils.ApiResult;
import com.polysoft.activity.utils.MathRandom; import com.polysoft.activity.utils.MathRandom;
import com.polysoft.activity.utils.RandomUtils;
import com.polysoft.activity.utils.SHA1; import com.polysoft.activity.utils.SHA1;
import com.polysoft.activity.utils.SnowFlakeUtil; import com.polysoft.activity.utils.SnowFlakeUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -36,6 +37,7 @@ import javax.annotation.Resource; ...@@ -36,6 +37,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -75,6 +77,7 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -75,6 +77,7 @@ public class UserInfoServiceImpl implements UserInfoService {
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
public ApiResult getShareLink(ShareLinkParam param) { public ApiResult getShareLink(ShareLinkParam param) {
try { try {
...@@ -108,14 +111,7 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -108,14 +111,7 @@ public class UserInfoServiceImpl implements UserInfoService {
shareLinkVO.setNoncestr(noncestr); shareLinkVO.setNoncestr(noncestr);
shareLinkVO.setTimestamp(timestamp); shareLinkVO.setTimestamp(timestamp);
shareLinkVO.setSignature(SHA1.encode(signStr)); shareLinkVO.setSignature(SHA1.encode(signStr));
//存储分享连接
ShareDto shareDto = new ShareDto();
shareDto.setId(SnowFlakeUtil.nextId());
shareDto.setUserId(param.getUserId());
shareDto.setShareUrl(param.getUrl());
shareDto.setCreateTime(date);
shareDto.setShareDate(date);
cattleBrandMapper.saveShareForCattle(shareDto);
return ApiResult.ok(shareLinkVO); return ApiResult.ok(shareLinkVO);
} catch (RestClientException e) { } catch (RestClientException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -126,29 +122,35 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -126,29 +122,35 @@ public class UserInfoServiceImpl implements UserInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public ApiResult saveShareCattle(ShareLinkParam param) { public ApiResult saveShareCattle(ShareLinkParam param) {
Long userId = param.getUserId();
try { try {
//查询牛牌是否存 //查询牛牌是否存
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
UserCattleVO cattleVO = cattleBrandMapper.getUserCattleVOById(param.getCattleId()); UserCattleVO cattleVO = cattleBrandMapper.getUserCattleVOById(param.getCattleId(),CommonTypeEnum.LINK_SHARE_YES.getCode());
if(cattleVO == null){ if(cattleVO == null){
object.put("cardType",param.getCardType()); object.put("cardType",param.getCardType());
object.put("isReceived",false); object.put("isReceived",false);
return ApiResult.ok("200","牛牌已被领取",object); return ApiResult.ok("200","牛牌已被领取",object);
} }
if(cattleVO.getUserId().equals(userId)){
object.put("cardType",param.getCardType());
object.put("isReceived",false);
return ApiResult.ok("200","不允许领取自己分享的牛牌",object);
}
List<SaveUserCattleDto> list = new ArrayList<>(); List<SaveUserCattleDto> list = new ArrayList<>();
SaveUserCattleDto dto = new SaveUserCattleDto(); SaveUserCattleDto dto = new SaveUserCattleDto();
dto.setId(SnowFlakeUtil.nextId()); dto.setId(SnowFlakeUtil.nextId());
dto.setUserId(param.getUserId()); dto.setUserId(userId);
dto.setCattleBrandId(cattleVO.getCattleBrandId()); dto.setCattleBrandId(cattleVO.getCattleBrandId());
list.add(dto); list.add(dto);
int k1 = mapper.saveCattleBrand(list); int k1 = mapper.saveCattleBrand(list);
if(k1 < 1){ if(k1 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@分享获取牛牌异常"); throw new BusinessException("ID@@"+userId+"@@分享获取牛牌异常");
} }
//删除用户牛牌关系表数据 //删除用户牛牌关系表数据
int k2 = cattleBrandMapper.deleteUsetCattleById(param.getCattleId()); int k2 = cattleBrandMapper.deleteUsetCattleById(param.getCattleId());
if(k2 < 1){ if(k2 < 1){
throw new BusinessException("ID@@"+param.getUserId()+"@@分享获取牛牌异常"); throw new BusinessException("ID@@"+userId+"@@分享获取牛牌异常");
} }
object.put("cardType",param.getCardType()); object.put("cardType",param.getCardType());
object.put("isReceived",true); object.put("isReceived",true);
...@@ -256,6 +258,8 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -256,6 +258,8 @@ public class UserInfoServiceImpl implements UserInfoService {
try { try {
List<FirstLoginRedVO> firstLoginRedVOList = mapper.queryFirstLoginRed(); List<FirstLoginRedVO> firstLoginRedVOList = mapper.queryFirstLoginRed();
if(firstLoginRedVOList != null && firstLoginRedVOList.size() >0){ if(firstLoginRedVOList != null && firstLoginRedVOList.size() >0){
HashSet<Integer> set = RandomUtils.getLuckUser(1,firstLoginRedVOList.size());
//新增到红包雨表 作为红包基础数据 //新增到红包雨表 作为红包基础数据
FirstLoginRedVO redVO = firstLoginRedVOList.get(0); FirstLoginRedVO redVO = firstLoginRedVOList.get(0);
AddRedRainDto dto = new AddRedRainDto(); AddRedRainDto dto = new AddRedRainDto();
...@@ -276,6 +280,7 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -276,6 +280,7 @@ public class UserInfoServiceImpl implements UserInfoService {
UserInfoDto userInfoDto = new UserInfoDto(); UserInfoDto userInfoDto = new UserInfoDto();
userInfoDto.setUserId(userId); userInfoDto.setUserId(userId);
userInfoDto.setRedBalance(redVO.getAmount()); userInfoDto.setRedBalance(redVO.getAmount());
userInfoDto.setIsFirst("1");
userInfoDtoList.add(userInfoDto); userInfoDtoList.add(userInfoDto);
int k2 = mapper.updateRedBalace(userInfoDtoList); int k2 = mapper.updateRedBalace(userInfoDtoList);
if(k2 < 1){ if(k2 < 1){
...@@ -304,5 +309,36 @@ public class UserInfoServiceImpl implements UserInfoService { ...@@ -304,5 +309,36 @@ public class UserInfoServiceImpl implements UserInfoService {
dto.setHammerStatus("1"); dto.setHammerStatus("1");
return ApiResult.ok(mapper.updateUserStates(dto)); return ApiResult.ok(mapper.updateUserStates(dto));
} }
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult saveShareCallBack(ShareLinkParam param){
Date date = new Date();
//更新牛牌状态为已分享
int k1 = cattleBrandMapper.updateUserCattleStatus(param.getCattleId(),CommonTypeEnum.LINK_SHARE_YES.getCode());
if(k1 < 1){
throw new BusinessException("牛牌分享异常");
}
//更新用户是否首次分享状态
UpdateUserStatesDto dto = new UpdateUserStatesDto();
dto.setUserId(param.getUserId());
dto.setIsFirstShare("1");
if(!"1".equals(param.getIsFirstShare())){
int k2 = mapper.updateUserStates(dto);
if(k2 < 1){
throw new BusinessException("牛牌分享异常");
}
}
//存储分享连接
ShareDto shareDto = new ShareDto();
shareDto.setId(SnowFlakeUtil.nextId());
shareDto.setUserId(param.getUserId());
shareDto.setShareUrl(param.getUrl());
shareDto.setCreateTime(date);
shareDto.setShareDate(date);
int k3 = cattleBrandMapper.saveShareForCattle(shareDto);
if(k3 < 1){
throw new BusinessException("牛牌分享异常");
}
return ApiResult.ok();
}
} }
...@@ -36,7 +36,7 @@ public class CattleBrandCarveUpTask { ...@@ -36,7 +36,7 @@ public class CattleBrandCarveUpTask {
// @Scheduled( cron = "0 20 20 * * ? ") // @Scheduled( cron = "0 20 20 * * ? ")
// @Scheduled(initialDelay = 5000, fixedRate = 1*15*60*1000) // @Scheduled(initialDelay = 5000, fixedRate = 1*15*60*1000)
@Scheduled( cron = "0 1 20 17 2 ? ") // 2021年2月17号 20时分0秒 执行 @Scheduled( cron = "0 40 14 5 2 ? ") // 2021年2月17号 20时分0秒 执行
public void execute() { public void execute() {
try { try {
sendWechat(); sendWechat();
...@@ -47,97 +47,93 @@ public class CattleBrandCarveUpTask { ...@@ -47,97 +47,93 @@ public class CattleBrandCarveUpTask {
private void sendWechat() { private void sendWechat() {
log.info("牛牌瓜分红包任务开始"); log.info("牛牌瓜分红包任务开始");
//查询已经合成牛牌的红包 //查询已经合成牛牌的红包
List<Long> list = activityMapper.getRedIdToCattle(null); List<Long> list = activityMapper.getRedIdToCattle(null,null);
//第一批 牛牌瓜分 //第一批 牛牌瓜分
//生成数量 //生成数量
int count_1 = (int) (list.size()*0.05)+1; int count_1 ;
//生成范围 if(isIntegerForDouble(list.size()*0.05)){
int random_1 = list.size(); count_1 = (int) (list.size()*0.05);
HashSet<Integer> set_1 = getLuckUser(count_1,random_1); }else {
count_1 = (int) (list.size() * 0.05) + 1;
}
List<Long> list_1 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00),count_1);
//第一批瓜分 //第一批瓜分
RedPacketUtil redpack = new RedPacketUtil(); RedPacketUtil redpack = new RedPacketUtil();
//查询第一批红包配置 //查询第一批红包配置
RedAmountConfVO confVO_1 = activityMapper.getRedAmountConf("4",1L); RedAmountConfVO confVO_1 = activityMapper.getRedAmountConf("4",1L);
List<Double> redAmount_1 = redpack.getMoney(confVO_1.getTotalMoney(),count_1,confVO_1.getRedMinAmount(),confVO_1.getRedMaxAmonut(),2.1); List<Double> redAmount_1 = redpack.getMoney(confVO_1.getTotalMoney(),count_1,confVO_1.getRedMinAmount(),confVO_1.getRedMaxAmonut(),2.1);
List<AddRedRainDto> batchList_1 = new ArrayList<>(); List<AddRedRainDto> batchList_1 = new ArrayList<>();
int bt_1 = 0; for (int bt_1 =0;bt_1<list_1.size();bt_1++) {
for (Integer s:set_1) {
AddRedRainDto addRedRainDto = new AddRedRainDto(); AddRedRainDto addRedRainDto = new AddRedRainDto();
addRedRainDto.setRedId(list.get(s)); addRedRainDto.setRedId(list_1.get(bt_1));
addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_1.get(bt_1))); addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_1.get(bt_1)));
addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode()); addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode());
addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode()); addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
batchList_1.add(addRedRainDto); batchList_1.add(addRedRainDto);
bt_1++;
} }
activityMapper.updateRedPackage(batchList_1); activityMapper.updateRedPackage(batchList_1);
//第二批 牛牌瓜分 //第二批 牛牌瓜分
//未充值的牛牌红包
List<Long> redCattlePacke_2 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00));
//生成数量 //生成数量
int count_2 = (int) (list.size()*0.15)+1; int count_2 ;
//生成范围 if(isIntegerForDouble((list.size()*0.15))){
int random_2 = redCattlePacke_2.size(); count_2 = (int) (list.size()*0.15);
HashSet<Integer> set_2 = getLuckUser(count_2,random_2); }else {
count_2 = (int) (list.size()*0.15)+1;
}
List<Long> list_2 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00),count_2);
//查询第二批红包配置 //查询第二批红包配置
RedAmountConfVO confVO_2 = activityMapper.getRedAmountConf("4",2L); RedAmountConfVO confVO_2 = activityMapper.getRedAmountConf("4",2L);
List<Double> redAmount_2 = redpack.getMoney(confVO_2.getTotalMoney(),count_2,confVO_2.getRedMinAmount(),confVO_2.getRedMaxAmonut(),2.1); List<Double> redAmount_2 = redpack.getMoney(confVO_2.getTotalMoney(),count_2,confVO_2.getRedMinAmount(),confVO_2.getRedMaxAmonut(),2.1);
List<AddRedRainDto> batchList_2 = new ArrayList<>(); List<AddRedRainDto> batchList_2 = new ArrayList<>();
int bt_2 = 0; for (int bt_2 =0;bt_2<list_2.size();bt_2++) {
for (Integer s:set_2) {
AddRedRainDto addRedRainDto = new AddRedRainDto(); AddRedRainDto addRedRainDto = new AddRedRainDto();
addRedRainDto.setRedId(redCattlePacke_2.get(s)); addRedRainDto.setRedId(list_2.get(bt_2));
addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_2.get(bt_2))); addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_2.get(bt_2)));
addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode()); addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode());
addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode()); addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
batchList_2.add(addRedRainDto); batchList_2.add(addRedRainDto);
bt_2++;
} }
activityMapper.updateRedPackage(batchList_2); activityMapper.updateRedPackage(batchList_2);
//第三批 牛牌瓜分 //第三批 牛牌瓜分
//未充值的牛牌红包
List<Long> redCattlePacke_3 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00));
//生成数量 //生成数量
int count_3 = (int) (list.size()*0.40)+1; int count_3 ;
if(isIntegerForDouble((list.size()*0.40))){
count_3 =(int) (list.size()*0.40);
}else {
count_3 = (int) (list.size()*0.40)+1;
}
//生成范围 //生成范围
int random_3 = redCattlePacke_3.size(); List<Long> list_3 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00),count_3);
HashSet<Integer> set_3 = getLuckUser(count_3,random_3);
//查询第三批红包配置 //查询第三批红包配置
RedAmountConfVO confVO_3 = activityMapper.getRedAmountConf("4",3L); RedAmountConfVO confVO_3 = activityMapper.getRedAmountConf("4",3L);
List<Double> redAmount_3 = redpack.getMoney(confVO_3.getTotalMoney(),count_3,confVO_3.getRedMinAmount(),confVO_3.getRedMaxAmonut(),2.1); List<Double> redAmount_3 = redpack.getMoney(confVO_3.getTotalMoney(),count_3,confVO_3.getRedMinAmount(),confVO_3.getRedMaxAmonut(),2.1);
List<AddRedRainDto> batchList_3 = new ArrayList<>(); List<AddRedRainDto> batchList_3 = new ArrayList<>();
int bt_3 = 0; for (int bt_3 = 0;bt_3<list_3.size();bt_3++) {
for (Integer s:set_3) {
AddRedRainDto addRedRainDto = new AddRedRainDto(); AddRedRainDto addRedRainDto = new AddRedRainDto();
addRedRainDto.setRedId(redCattlePacke_3.get(s)); addRedRainDto.setRedId(list_3.get(bt_3));
addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_3.get(bt_3))); addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_3.get(bt_3)));
addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode()); addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode());
addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode()); addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
batchList_3.add(addRedRainDto); batchList_3.add(addRedRainDto);
bt_3++;
} }
activityMapper.updateRedPackage(batchList_3); activityMapper.updateRedPackage(batchList_3);
//第四批 牛牌瓜分 //第四批 牛牌瓜分
//未充值的牛牌红包 //未充值的牛牌红包
List<Long> redCattlePacke_4 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00)); List<Long> list_4 = activityMapper.getRedIdToCattle(BigDecimal.valueOf(0.00),null);
//生成数量 //生成数量
int count_4 = redCattlePacke_4.size(); int count_4 = list_4.size();
//生成范围 //生成范围
int random_4 = redCattlePacke_4.size();
HashSet<Integer> set_4 = getLuckUser(count_4,random_4);
//查询第四批红包配置 //查询第四批红包配置
RedAmountConfVO confVO_4 = activityMapper.getRedAmountConf("4",4L); RedAmountConfVO confVO_4 = activityMapper.getRedAmountConf("4",4L);
List<Double> redAmount_4 = redpack.getMoney(confVO_4.getTotalMoney(),count_4,confVO_4.getRedMinAmount(),confVO_4.getRedMaxAmonut(),2.1); List<Double> redAmount_4 = redpack.getMoney(confVO_4.getTotalMoney(),count_4,confVO_4.getRedMinAmount(),confVO_4.getRedMaxAmonut(),2.1);
List<AddRedRainDto> batchList_4 = new ArrayList<>(); List<AddRedRainDto> batchList_4 = new ArrayList<>();
int bt_4 = 0; for (int bt_4 = 0; bt_4 < list_4.size();bt_4++) {
for (Integer s:set_4) {
AddRedRainDto addRedRainDto = new AddRedRainDto(); AddRedRainDto addRedRainDto = new AddRedRainDto();
addRedRainDto.setRedId(redCattlePacke_4.get(s)); addRedRainDto.setRedId(list_4.get(bt_4));
addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_4.get(bt_4))); addRedRainDto.setRedAmount(BigDecimal.valueOf(redAmount_4.get(bt_4)));
addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode()); addRedRainDto.setRedType(CommonTypeEnum.REDPACK_TYPE1.getCode());
addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode()); addRedRainDto.setIsEnble(CommonTypeEnum.RED_ISENBLE_NO.getCode());
batchList_4.add(addRedRainDto); batchList_4.add(addRedRainDto);
bt_4++;
} }
activityMapper.updateRedPackage(batchList_4); activityMapper.updateRedPackage(batchList_4);
log.info("牛牌瓜分红包任务结束"); log.info("牛牌瓜分红包任务结束");
...@@ -161,12 +157,25 @@ public class CattleBrandCarveUpTask { ...@@ -161,12 +157,25 @@ public class CattleBrandCarveUpTask {
} }
return has; return has;
} }
/**
* 判断double是否为整数
* @param obj
* @return
*/
public boolean isIntegerForDouble(double obj) {
double eps = 1e-10; // 精度范围
return obj-Math.floor(obj) < eps;
}
public static void main(String[] args) { public static void main(String[] args) {
RedPacketUtil redpack = new RedPacketUtil(); RedPacketUtil redpack = new RedPacketUtil();
// List<Double> redAmount= redpack.getMoney(2000,12,100,250,2.1); // List<Double> redAmount= redpack.getMoney(2000,12,100,250,2.1);
// List<Double> redAmount= redpack.getMoney(5000,35,100,250,2.1); // List<Double> redAmount= redpack.getMoney(5000,35,100,250,2.1);
// List<Double> redAmount= redpack.getMoney(8000,91,50,150,2.1); // List<Double> redAmount= redpack.getMoney(8000,91,50,150,2.1);
List<Double> redAmount= redpack.getMoney(5000,91,50,150,2.1); // List<Double> redAmount= redpack.getMoney(200,100,150,150,2.1);
redAmount.forEach(a -> System.out.println(a)); // redAmount.forEach(a -> System.out.println(a));
double ss = 99*0.05;
System.out.println(new CattleBrandCarveUpTask().isIntegerForDouble(ss));
} }
} }
...@@ -47,9 +47,8 @@ public class InitRedPackageTask1 { ...@@ -47,9 +47,8 @@ public class InitRedPackageTask1 {
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000) // @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "40 10 17 * * ? ") // @Scheduled( cron = "40 10 17 * * ? ")
@Scheduled( cron = "40 0 20 11 2 ? ") // 2月11日 20点0分40秒执行 @Scheduled( cron = "45 0 20 11 2 ? ") // 2月11日 20点0分45秒执行
public void execute() { public void execute() {
System.out.println("时间正确");
try { try {
Thread.sleep(5000); Thread.sleep(5000);
sendWechat(); sendWechat();
......
...@@ -46,7 +46,7 @@ public class InitRedPackageTask2 { ...@@ -46,7 +46,7 @@ public class InitRedPackageTask2 {
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000) // @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "40 15 17 * * ? ") // @Scheduled( cron = "40 15 17 * * ? ")
@Scheduled( cron = "40 0 22 11 2 ? ") // 2月11日 22点0分40秒执行 @Scheduled( cron = "45 0 22 11 2 ? ") // 2月11日 22点0分45秒执行
public void execute() { public void execute() {
try { try {
Thread.sleep(5000); Thread.sleep(5000);
......
...@@ -47,7 +47,7 @@ public class InitRedPackageTask3 { ...@@ -47,7 +47,7 @@ public class InitRedPackageTask3 {
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000) // @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "40 20 17 * * ? ") // @Scheduled( cron = "40 20 17 * * ? ")
@Scheduled( cron = "40 0 0 12 2 ? ") // 2月12日 0时0点0分40秒执行 @Scheduled( cron = "45 0 0 12 2 ? ") // 2月12日 0时0点0分45秒执行
public void execute() { public void execute() {
try { try {
Thread.sleep(5000); Thread.sleep(5000);
......
...@@ -43,7 +43,7 @@ public class WishLuckDrawTask { ...@@ -43,7 +43,7 @@ public class WishLuckDrawTask {
} }
private void sendWechat(){ private void sendWechat(){
LoggerHelper.info(this.getClass(),"任务开始"); LoggerHelper.info(this.getClass(),"心愿抽奖任务开始");
List<QueryLuckDrawWishVO> wishForToday = wishService.queryLuckDrawWish(); List<QueryLuckDrawWishVO> wishForToday = wishService.queryLuckDrawWish();
QueryRealPrizeVO realPrizeVO = wishService.querRealPrize(); QueryRealPrizeVO realPrizeVO = wishService.querRealPrize();
List<WishRealPrizeDto> dtos = new ArrayList<>(); List<WishRealPrizeDto> dtos = new ArrayList<>();
...@@ -76,6 +76,7 @@ public class WishLuckDrawTask { ...@@ -76,6 +76,7 @@ public class WishLuckDrawTask {
}else { }else {
LoggerHelper.info(this.getClass(),"无抽奖"); LoggerHelper.info(this.getClass(),"无抽奖");
} }
LoggerHelper.info(this.getClass(),"心愿抽奖任务结束");
} }
private HashSet<Integer> getLuckUser(int count,int random){ private HashSet<Integer> getLuckUser(int count,int random){
HashSet<Integer> has = new HashSet<Integer>(); HashSet<Integer> has = new HashSet<Integer>();
......
...@@ -262,6 +262,10 @@ ...@@ -262,6 +262,10 @@
source_type = '4' and is_enble='0' source_type = '4' and is_enble='0'
<if test="redAmount != null"> <if test="redAmount != null">
and red_amount = #{redAmount} and red_amount = #{redAmount}
order by create_time asc
</if>
<if test="limit != null">
limit #{limit}
</if> </if>
</select> </select>
<select id="getRedPackRecharge" resultType="java.lang.Integer"> <select id="getRedPackRecharge" resultType="java.lang.Integer">
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
compose_cattle_time = #{time} compose_cattle_time = #{time}
where user_id = #{userId} where user_id = #{userId}
</update> </update>
<update id="updateUserCattleStatus">
update t_user_cattle set is_share =#{status} where id = #{id}
</update>
<delete id="deleteUserCalltle" parameterType="list"> <delete id="deleteUserCalltle" parameterType="list">
delete from t_user_cattle delete from t_user_cattle
where id IN where id IN
...@@ -66,7 +69,7 @@ ...@@ -66,7 +69,7 @@
FROM FROM
t_user_cattle t t_user_cattle t
WHERE WHERE
t.user_id = #{userId} t.user_id = #{userId} and t.is_share = '0'
GROUP BY GROUP BY
t.cattle_brand_id t.cattle_brand_id
</select> </select>
...@@ -93,7 +96,7 @@ ...@@ -93,7 +96,7 @@
t_user_cattle t1 LEFT join t_cattle_brand t2 ON ( t2.cattle_id = t1.cattle_brand_id ) t_user_cattle t1 LEFT join t_cattle_brand t2 ON ( t2.cattle_id = t1.cattle_brand_id )
WHERE WHERE
t1.user_id = #{userId} t1.user_id = #{userId}
AND t2.brand_type =#{type} AND t2.brand_type =#{type} and t1.is_share = '0'
</select> </select>
<select id="getTaskStatus" resultType="com.polysoft.activity.model.vo.TaskStatusVO"> <select id="getTaskStatus" resultType="com.polysoft.activity.model.vo.TaskStatusVO">
SELECT SELECT
...@@ -124,6 +127,6 @@ ...@@ -124,6 +127,6 @@
FROM FROM
t_user_cattle t t_user_cattle t
WHERE WHERE
t.id = #{id} t.id = #{id} and is_share =#{status}
</select> </select>
</mapper> </mapper>
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
compose_cattle_time, compose_cattle_time,
hammer_status, hammer_status,
cattle_open_status, cattle_open_status,
(select count(*) from (select tc.cattle_brand_id from t_user_cattle tc where tc.user_id = #{userId} GROUP BY tc.cattle_brand_id)tab) as cattleTypeNum is_first_share,
(select count(*) from (select tc.cattle_brand_id from t_user_cattle tc where tc.user_id = #{userId} and tc.is_share = '0' GROUP BY tc.cattle_brand_id)tab) as cattleTypeNum
from from
t_user where t_user where
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
SELECT SELECT
id, id,
amount amount
from t_first_login_red where is_flag = '0' order by id asc limit 1 from t_first_login_red where is_flag = '0'
</select> </select>
<select id="getFirstoginYesOrNo" resultType="java.lang.Integer"> <select id="getFirstoginYesOrNo" resultType="java.lang.Integer">
SELECT count(*) from t_user where user_id=#{userId} and is_first='0' SELECT count(*) from t_user where user_id=#{userId} and is_first='0'
...@@ -73,6 +74,9 @@ ...@@ -73,6 +74,9 @@
<if test="cattleOpenStatus != null and cattleOpenStatus != ''"> <if test="cattleOpenStatus != null and cattleOpenStatus != ''">
cattle_open_status = #{cattleOpenStatus} cattle_open_status = #{cattleOpenStatus}
</if> </if>
<if test="isFirstShare != null and isFirstShare != ''">
is_first_share = #{isFirstShare}
</if>
<where> <where>
user_id = #{userId} user_id = #{userId}
</where> </where>
......
...@@ -30,9 +30,8 @@ ...@@ -30,9 +30,8 @@
FROM FROM
t_wish t t_wish t
WHERE WHERE
t.push_date = '2021-02-04' t.push_date = DATE_FORMAT(NOW(),'%Y-%m-%d')
/* 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 )
*/ AND t.user_id NOT IN ( SELECT t2.user_id FROM t_wish_real_prize t2 )
GROUP by t.user_id GROUP by t.user_id
order by t.user_id asc order by t.user_id asc
</select> </select>
......
package com.polysoft.activity.utils;
import java.util.HashSet;
import java.util.Random;
/**
* @author lvyp
* @date 2021/2/5
*/
public class RandomUtils {
public static HashSet<Integer> getLuckUser(int count, int random){
HashSet<Integer> has = new HashSet<Integer>();
Integer i = 0;
for (int j = 1; j != 0; j++) {
i = new Random().nextInt(random);
has.add(i);
if (count == has.size()) {
break;
}
}
return has;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!