| | |
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRank;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRankService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
|
| | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | |
| | | @Override
|
| | | public IntegralTaskClass selectByPrimaryKey(Long id) {
|
| | | return integralTaskClassMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<IntegralTaskClassVO> getIntegralTaskClassVO(Long uid, long start, int count) {
|
| | |
| | |
|
| | | @Override
|
| | | public DailySignVO getDailySignList(Long uid, Long rankId) throws ParseException{
|
| | | SimpleDateFormat format = new SimpleDateFormat("MM.dd");
|
| | | List<SignDateVO> listSign = new ArrayList<SignDateVO>();
|
| | | IntegralTaskClass taskClass = integralTaskClassMapper.getByUniqueKey(UniqueKeyEnum.dailySign.name());
|
| | | if (taskClass == null || taskClass.getState() == null || taskClass.getState() != 1)
|
| | | return null;
|
| | |
|
| | | Long cid = taskClass.getId();
|
| | | List<IntegralTask> listTask = integralTaskService.listByCid(cid);
|
| | | if (listTask == null || listTask.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Date date = new Date();
|
| | | SimpleDateFormat format = new SimpleDateFormat("MM.dd");
|
| | | List<SignDateVO> listSign = new ArrayList<SignDateVO>();
|
| | | |
| | | List<Date> listDays = integralTaskRecordService.getSignDays(uid, cid);
|
| | | for (int i = 0; i < listDays.size(); i ++) {
|
| | | if(i == listDays.size() -1) {
|
| | | SignDateVO signDate = new SignDateVO();
|
| | | signDate.setDate("今日");
|
| | | signDate.setLightUp(true);
|
| | | listSign.add(signDate);
|
| | | break;
|
| | | }
|
| | | |
| | | String before = format.format(listDays.get(i));
|
| | | if (before.startsWith("0")) |
| | | before = before.substring(1, before.length());
|
| | | SignDateVO signDateVO = new SignDateVO();
|
| | | signDateVO.setDate(before);
|
| | | listSign.add(signDateVO);
|
| | | }
|
| | | |
| | | for (int i = 1; i <= 7- listDays.size(); i ++) {
|
| | | String after = format.format(DateUtil.plusDayDate(i, date));
|
| | | if (after.startsWith("0")) |
| | | after = after.substring(1, after.length());
|
| | | |
| | | SignDateVO signDateVO = new SignDateVO();
|
| | | signDateVO.setDate(after);
|
| | | listSign.add(signDateVO);
|
| | | }
|
| | | |
| | | DailySignVO dailySignVO = new DailySignVO();
|
| | | for (int i = 0; i < listTask.size(); i++) {
|
| | | if (listSign.size() <= i) {
|
| | | break;
|
| | | }
|
| | | SignDateVO signDateVO = listSign.get(i);
|
| | | |
| | | IntegralTask task = listTask.get(i);
|
| | | Integer goldCoin = task.getGoldCoin();
|
| | | Integer baseDoubleNum = task.getDoubleNum();
|
| | | if (baseDoubleNum != null && baseDoubleNum > 0)
|
| | | goldCoin = goldCoin * baseDoubleNum;
|
| | | |
| | | IntegralTaskRank traskRank = integralTaskRankService.getByTsakIdAndRankId(task.getId(), rankId);
|
| | | if (traskRank != null) {
|
| | | Integer addCoin = traskRank.getAddCoin();
|
| | | if (addCoin != null && addCoin > 0)
|
| | | goldCoin += addCoin;
|
| | |
|
| | | Integer doubleNum = traskRank.getDoubleNum();
|
| | | if (doubleNum != null && doubleNum > 0) {
|
| | | goldCoin = goldCoin * doubleNum;
|
| | | |
| | | Long cid = taskClass.getId();
|
| | | List<IntegralTaskRecord> listRecord = integralTaskRecordService.getSignDaysRecord(uid, cid);
|
| | | if (listRecord != null && listRecord.size() > 0) {
|
| | | for (int i = listRecord.size() - 1; i >= 0; i--) {
|
| | | IntegralTaskRecord taskRecord = listRecord.get(i);
|
| | | SignDateVO signDateVO = new SignDateVO();
|
| | | signDateVO.setLightUp(true);
|
| | | signDateVO.setGoldCoin("+" + taskRecord.getGoldCoin());
|
| | | if(i == 0) {
|
| | | signDateVO.setDate("今日");
|
| | | dailySignVO.setGoldCoin(taskRecord.getGoldCoin());
|
| | | } else {
|
| | | String before = format.format(taskRecord.getCreateTime());
|
| | | if (before.startsWith("0")) |
| | | before = before.substring(1, before.length());
|
| | | signDateVO.setDate(before);
|
| | | }
|
| | | listSign.add(signDateVO);
|
| | | }
|
| | | signDateVO.setGoldCoin("+" + goldCoin);
|
| | | |
| | | if("今日".equals(signDateVO.getDate()))
|
| | | dailySignVO.setGoldCoin(goldCoin);
|
| | | |
| | | }
|
| | |
|
| | | dailySignVO.setDays(listDays.size());
|
| | | |
| | | dailySignVO.setDays(listSign.size());
|
| | | |
| | | if (listSign.size() < 7) {
|
| | | List<IntegralTask> listTask = integralTaskService.listByCid(cid);
|
| | | if (listTask == null || listTask.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Date date = new Date();
|
| | | int j = 1;
|
| | | for (int i = listSign.size(); i < listTask.size(); i ++) {
|
| | | String after = format.format(DateUtil.plusDayDate(j, date));
|
| | | if (after.startsWith("0")) |
| | | after = after.substring(1, after.length());
|
| | | |
| | | IntegralTask task = listTask.get(i);
|
| | | Integer goldCoin = task.getGoldCoin();
|
| | | Integer baseDoubleNum = task.getDoubleNum();
|
| | | if (baseDoubleNum != null && baseDoubleNum > 0)
|
| | | goldCoin = goldCoin * baseDoubleNum;
|
| | | |
| | | IntegralTaskRank traskRank = integralTaskRankService.getByTsakIdAndRankId(task.getId(), rankId);
|
| | | if (traskRank != null) {
|
| | | Integer addCoin = traskRank.getAddCoin();
|
| | | if (addCoin != null && addCoin > 0)
|
| | | goldCoin += addCoin;
|
| | |
|
| | | Integer doubleNum = traskRank.getDoubleNum();
|
| | | if (doubleNum != null && doubleNum > 0) {
|
| | | goldCoin = goldCoin * doubleNum;
|
| | | }
|
| | | }
|
| | | |
| | | SignDateVO signDateVO = new SignDateVO();
|
| | | signDateVO.setDate(after);
|
| | | signDateVO.setGoldCoin("+" + goldCoin);
|
| | | listSign.add(signDateVO);
|
| | | j++;
|
| | | }
|
| | | } |
| | | dailySignVO.setListDate(listSign);
|
| | | return dailySignVO;
|
| | | }
|