| | |
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.vo.integral.DailySignVO;
|
| | | import com.yeshi.fanli.vo.integral.IntegralTaskClassVO;
|
| | | import com.yeshi.fanli.vo.integral.SignDateVO;
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public IntegralTaskClass selectByPrimaryKey(Long id) {
|
| | | return integralTaskClassMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<IntegralTaskClassVO> getIntegralTaskClassVO(Long uid, long start, int count) {
|
| | | // 用户签到
|
| | | Integer baseGoldCoin = 5;
|
| | | boolean dailySign = false;
|
| | | if (start == 0) { // 第一页签到
|
| | | try { |
| | | baseGoldCoin = finishedDailySign(uid);
|
| | | dailySign = true;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | List<IntegralTaskClassVO> listVo = integralTaskClassMapper.getIntegralTaskClassVO(start, count);
|
| | | if (listVo == null || listVo.size() == 0) {
|
| | | return listVo;
|
| | | }
|
| | |
|
| | | for (IntegralTaskClassVO taskClassVO : listVo) {
|
| | | String progress = taskClassVO.getProgress();
|
| | | if (StringUtil.isNullOrEmpty(progress))
|
| | | continue;
|
| | | |
| | | Integer taskNum = taskClassVO.getTaskNum();
|
| | | if (taskNum == null)
|
| | | continue;
|
| | |
|
| | | // 目前只有签到变灰
|
| | | UniqueKeyEnum uniqueKey = taskClassVO.getUniqueKey();
|
| | | if (uniqueKey == UniqueKeyEnum.dailySign) {
|
| | | taskClassVO.setTotalCoin(baseGoldCoin);
|
| | | taskClassVO.setLightUp(dailySign);
|
| | | } else {
|
| | | taskClassVO.setLightUp(true);
|
| | | }
|
| | | |
| | | |
| | | Integer dateType = 1; // 查询当日
|
| | | if (uniqueKey == UniqueKeyEnum.orderReward)
|
| | | dateType = null; // 查询历史
|
| | |
|
| | | Long id = taskClassVO.getId();
|
| | | int countFinished = 0;
|
| | | Integer totalGoldCoin = integralTaskRecordService.getTotalGoldCoin(uid, id, dateType);
|
| | | if (totalGoldCoin != null && totalGoldCoin > 0) {
|
| | | taskClassVO.setFinishedCoin("+" + totalGoldCoin);
|
| | | if (uniqueKey != UniqueKeyEnum.dailySign)
|
| | | countFinished = integralTaskRecordService.countFinished(uid, id, dateType);
|
| | | }
|
| | | progress = progress.replace("{已完成}", countFinished + "").replace("{总任务}", taskNum + "");
|
| | | |
| | | if (!dailySign && uniqueKey == UniqueKeyEnum.dailySign) {
|
| | | progress = "未签到";
|
| | | taskClassVO.setBtnName("签到");
|
| | | } |
| | | taskClassVO.setProgress(progress);
|
| | | }
|
| | | return listVo;
|
| | | return integralTaskClassMapper.getIntegralTaskClassVO(start, count);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | */
|
| | | @Transactional
|
| | | public Integer finishedDailySign(long uid) throws Exception{
|
| | | Integer baseGoldCoin = 5;
|
| | | |
| | | IntegralTaskClass taskClass = getByUniqueKey(UniqueKeyEnum.dailySign.name());
|
| | | if (taskClass == null || taskClass.getState() == null || taskClass.getState() != 1)
|
| | | return baseGoldCoin;
|
| | | throw new Exception("抛出异常:任务分类不存在");
|
| | |
|
| | | Long cid = taskClass.getId();
|
| | | |
| | | // 今日已签到完成
|
| | | if (integralTaskRecordService.isToDaySign(uid, cid))
|
| | | return baseGoldCoin;
|
| | | return 2;
|
| | |
|
| | | // 任务
|
| | | Integer num = integralTaskRecordService.getNowdaySignNum(uid, cid);
|
| | | String uniqueKey = UniqueKeyEnum.dailySign.name() + num;
|
| | | IntegralTask integralTask = integralTaskService.getByCidAndUniqueKey(cid, uniqueKey);
|
| | | if (integralTask == null)
|
| | | return baseGoldCoin;
|
| | | throw new Exception("抛出异常:任务不存在");
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null)
|
| | | return baseGoldCoin;
|
| | | throw new Exception("抛出异常:额外信息不存在");
|
| | |
|
| | | UserRank userRank = userInfoExtra.getUserRank();
|
| | | if (userRank == null)
|
| | | return baseGoldCoin;
|
| | | throw new Exception("抛出异常:等级信息不存在");
|
| | |
|
| | | Integer goldCoin = integralTask.getGoldCoin();
|
| | | Integer baseDoubleNum = integralTask.getDoubleNum();
|
| | | if (baseDoubleNum != null && baseDoubleNum > 0)
|
| | | goldCoin = goldCoin * baseDoubleNum;
|
| | | |
| | | baseGoldCoin = goldCoin;
|
| | |
|
| | | // 根据等级计算是否增加或加倍
|
| | | Long taskId = integralTask.getId();
|
| | |
| | | }
|
| | | // 加入记录
|
| | | integralTaskRecordService.finishedTask(uid, cid, taskId, goldCoin);
|
| | | return baseGoldCoin;
|
| | | |
| | | return 1;
|
| | | }
|
| | |
|
| | |
|
| | |
| | | }
|
| | |
|
| | | for (int i = 1; i <= 7- listDays.size(); i ++) {
|
| | | String after = format.format(DateUtil.reduceDay(i, date));
|
| | | String after = format.format(DateUtil.plusDayDate(i, date));
|
| | | if (after.startsWith("0"))
|
| | | after = after.substring(1, after.length());
|
| | |
|