日常任务-房间日流水奖励双重校验发放
This commit is contained in:
@@ -16,5 +16,5 @@ public interface RoomDayDiamondRewardRecordMapper extends BaseMapper<RoomDayDiam
|
||||
|
||||
IPage<RoomDayDiamondRewardRecordVo> listRecord(IPage<RoomDayDiamondRewardRecordVo> iPage, @Param("partitionId") Integer partitionId, @Param("regionId") Integer regionId,
|
||||
@Param("roomUid") Long roomUid, @Param("startDate") String startDate, @Param("endDate") String endDate,
|
||||
@Param("status") Integer status, @Param("notEqualsTodate") String notEqualsTodate, @Param("guildId") Integer guildId);
|
||||
@Param("status") Integer status, @Param("todayDayDate") String todayDayDate, @Param("guildId") Integer guildId);
|
||||
}
|
||||
|
@@ -16,4 +16,6 @@ public interface RoomDayDiamondRewardRecvRecordMapper extends BaseMapper<RoomDay
|
||||
|
||||
List<RoomDayDiamondRewardRecvRecord> getUniqueKeyList(@Param("partitionId") Integer partitionId, @Param("startDate") String startDate,
|
||||
@Param("endDate") String endDate, @Param("roomUids") List<Long> roomUids);
|
||||
|
||||
RoomDayDiamondRewardRecvRecord getUniqueKeyOne(@Param("partitionId") Integer partitionId, @Param("statDate") String statDate, @Param("roomUid") Long roomUid);
|
||||
}
|
||||
|
@@ -20,4 +20,6 @@ public interface RoomDayDiamondRewardRecordService extends IService<RoomDayDiamo
|
||||
BusiResult send(Long id, Integer adminId);
|
||||
|
||||
void loadDayDataRobotSend(Integer partitionId, String startDate, String endDate);
|
||||
|
||||
Boolean checkExist(Integer partitionId, Long roomUid, String statDate);
|
||||
}
|
||||
|
@@ -46,6 +46,8 @@ public class RoomDayDiamondRewardRecvRecordService extends ServiceImpl<RoomDayDi
|
||||
private UserPurseService userPurseService;
|
||||
@Autowired
|
||||
private BillRecordService billRecordService;
|
||||
@Autowired
|
||||
private RoomDayDiamondRewardRecordService roomDayDiamondRewardRecordService;
|
||||
|
||||
public BusiResult receive(Long uid, Long roomUid, String receiveDate, String level) {
|
||||
Users users = usersService.getUsersByUid(roomUid);
|
||||
@@ -65,6 +67,9 @@ public class RoomDayDiamondRewardRecvRecordService extends ServiceImpl<RoomDayDi
|
||||
if (!todayDate.equals(receiveDate)) {
|
||||
throw new ServiceException(BusiStatus.DAILY_RECEIVE_EXPIRE);
|
||||
}
|
||||
if (roomDayDiamondRewardRecordService.checkExist(partitionId, roomUid, receiveDate)) {
|
||||
throw new ServiceException(BusiStatus.ROOM_DAY_DIAMOND_REWARD_SEND);
|
||||
}
|
||||
BigDecimal goldNum = roomDayDiamondNumService.getGoldNum(partitionId, roomUid, receiveDate);
|
||||
RoomDayDiamondReward diamondReward = roomDayDiamondRewardService.getByLevel(partitionId, level);
|
||||
if (diamondReward == null || goldNum.compareTo(diamondReward.getDiamondNum()) < 0) {
|
||||
@@ -111,4 +116,8 @@ public class RoomDayDiamondRewardRecvRecordService extends ServiceImpl<RoomDayDi
|
||||
return uniqueKeyList.stream().collect(Collectors.toMap(x -> String.format("%s_%s", x.getRoomUid(), x.getStatDate()),
|
||||
x -> x));
|
||||
}
|
||||
|
||||
public RoomDayDiamondRewardRecvRecord getUniqueKeyOne(Integer partitionId, String statDate, Long roomUid) {
|
||||
return baseMapper.getUniqueKeyOne(partitionId, statDate, roomUid);
|
||||
}
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ public class RoomDayDiamondRewardRecordServiceImpl extends ServiceImpl<RoomDayDi
|
||||
endDate = DateUtil.formatDate(date);
|
||||
}
|
||||
//查询列表不包含今天
|
||||
String notEqualsTodate = DateTimeUtil.convertWithZoneId(new Date(), PartitionEnum.getByPartitionId(partitionId).getZoneId())
|
||||
String todayDate = DateTimeUtil.convertWithZoneId(new Date(), PartitionEnum.getByPartitionId(partitionId).getZoneId())
|
||||
.format(DateTimeUtil.dateFormatter);
|
||||
if (erbanNo != null) {
|
||||
Users user = usersService.getUserByErbanNo(erbanNo);
|
||||
@@ -119,7 +119,7 @@ public class RoomDayDiamondRewardRecordServiceImpl extends ServiceImpl<RoomDayDi
|
||||
}
|
||||
|
||||
IPage<RoomDayDiamondRewardRecordVo> iPage = new Page<>(pageNo, pageSize);
|
||||
iPage = baseMapper.listRecord(iPage, partitionId, regionId, roomUid, startDate, endDate, status, notEqualsTodate, guildId);
|
||||
iPage = baseMapper.listRecord(iPage, partitionId, regionId, roomUid, startDate, endDate, status, todayDate, guildId);
|
||||
PageResult<RoomDayDiamondRewardRecordVo> pageResult = new PageResult<>(iPage);
|
||||
List<RoomDayDiamondRewardRecordVo> rows = pageResult.getRows();
|
||||
if (CollectionUtils.isEmpty(rows)) {
|
||||
@@ -140,6 +140,9 @@ public class RoomDayDiamondRewardRecordServiceImpl extends ServiceImpl<RoomDayDi
|
||||
if (row.getCreateTime() != null) {
|
||||
row.setSendTime(DateUtil.formatDateTime(row.getCreateTime()));
|
||||
}
|
||||
if (row.getStatDate().equals(todayDate)) {
|
||||
row.setStatus((byte)2);
|
||||
}
|
||||
if (row.getRewardGold() != null) {
|
||||
continue;
|
||||
}
|
||||
@@ -176,6 +179,13 @@ public class RoomDayDiamondRewardRecordServiceImpl extends ServiceImpl<RoomDayDi
|
||||
if (notEqualsTodate.equals(dayDiamondNum.getStatDate())) {
|
||||
throw new AdminServiceException("该区(" + PartitionEnum.getByPartitionId(partitionId).getDesc() + ")当天未结束,不允许发放");
|
||||
}
|
||||
|
||||
RoomDayDiamondRewardRecvRecord uniqueKeyOne = roomDayDiamondRewardRecvRecordService
|
||||
.getUniqueKeyOne(partitionId, dayDiamondNum.getStatDate(), dayDiamondNum.getRoomUid());
|
||||
if (uniqueKeyOne != null && uniqueKeyOne.getRewardGold().compareTo(BigDecimal.ZERO) > 0) {
|
||||
throw new AdminServiceException("该房间房主今日已经在app日常任务中领取过奖励,不允许发放");
|
||||
}
|
||||
|
||||
String lockKey = "RoomDayDiamondNum:" + id;
|
||||
RLock lock = redissonClient.getLock(lockKey);
|
||||
boolean locked = false;
|
||||
@@ -244,7 +254,7 @@ public class RoomDayDiamondRewardRecordServiceImpl extends ServiceImpl<RoomDayDi
|
||||
this.sendRobotMsg(partitionId, startDate, roomNum, diamondNum, coins);
|
||||
}
|
||||
|
||||
private Boolean checkExist(Integer partitionId, Long roomUid, String statDate) {
|
||||
public Boolean checkExist(Integer partitionId, Long roomUid, String statDate) {
|
||||
LambdaQueryWrapper<RoomDayDiamondRewardRecord> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(RoomDayDiamondRewardRecord::getPartitionId, partitionId).eq(RoomDayDiamondRewardRecord::getRoomUid, roomUid).eq(RoomDayDiamondRewardRecord::getStatDate, statDate);
|
||||
return baseMapper.selectCount(wrapper) > 0;
|
||||
|
@@ -52,14 +52,16 @@
|
||||
<when test="status != null and status == 0">
|
||||
and reward.id is null
|
||||
</when>
|
||||
<when test="status != null and status == 1">
|
||||
<when test="status != null and (status == 1)">
|
||||
and reward.id is not null
|
||||
</when>
|
||||
<when test="status != null and status == 2">
|
||||
and rn.stat_date = #{todayDayDate}
|
||||
</when>
|
||||
</choose>
|
||||
<if test="guildId != null">
|
||||
and gm.guild_id = #{guildId}
|
||||
</if>
|
||||
and rn.stat_date != #{notEqualsTodate}
|
||||
</where>
|
||||
order by rn.stat_date desc, rn.diamond_num desc, `status` asc
|
||||
</select>
|
||||
|
@@ -19,4 +19,18 @@
|
||||
</foreach>
|
||||
GROUP BY stat_date, room_uid
|
||||
</select>
|
||||
|
||||
<select id="getUniqueKeyOne" resultType="com.accompany.business.model.room.RoomDayDiamondRewardRecvRecord">
|
||||
SELECT
|
||||
stat_date,
|
||||
room_uid,
|
||||
uid,
|
||||
sum(reward_gold) reward_gold
|
||||
FROM
|
||||
room_day_diamond_reward_recv_record
|
||||
WHERE
|
||||
partition_id = #{partitionId}
|
||||
and stat_date = #{statDate}
|
||||
AND room_uid = #{roomUid}
|
||||
</select>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user