From 33bfa1b3d03236922cc95b9435d7d10c91e8c4e5 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期四, 22 八月 2019 09:22:59 +0800 Subject: [PATCH] 明细 --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java | 150 ++++++++++++++++++++++++------------------------- 1 files changed, 73 insertions(+), 77 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java index fc802c9..bf4477a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java @@ -16,11 +16,14 @@ import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.integral.IntegralDetail; import com.yeshi.fanli.entity.integral.IntegralTask; +import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum; +import com.yeshi.fanli.entity.integral.IntegralTaskClass; import com.yeshi.fanli.entity.integral.IntegralTaskRecord; import com.yeshi.fanli.exception.integral.IntegralTaskRecordException; import com.yeshi.fanli.exception.user.UserInfoExtraException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.integral.IntegralDetailService; +import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService; import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService; import com.yeshi.fanli.service.inter.integral.IntegralTaskService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; @@ -34,14 +37,15 @@ @Resource private UserInfoExtraService userInfoExtraService; - + @Resource private IntegralDetailService integralDetailService; - + @Resource private IntegralTaskService integralTaskService; - - + + @Resource + private IntegralTaskClassService integralTaskClassService; @Override public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) { @@ -151,47 +155,14 @@ if (userInfoExtra == null) throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏"); - - List<IntegralTaskRecord> list = integralTaskRecordMapper.listNotReceived(Integer.MAX_VALUE, uid); - if (list == null || list.size() == 0) - throw new IntegralTaskRecordException(1, "鏆傛棤鍙鍙�"); - - - Integer totalGoldCoin = 0; + List<IntegralTaskRecord> list = integralTaskRecordMapper.listNotReceived(Integer.MAX_VALUE, uid); + if (list == null || list.size() == 0) + throw new IntegralTaskRecordException(1, "鏆傛棤鍙鍙�"); + + Integer totalGoldCoin = 0; for (IntegralTaskRecord record : list) { - Long uid2 = record.getUid(); - if (uid2 == null || uid.longValue() != uid2.longValue()) - continue; // 鐢ㄦ埛id涓嶇鍚� - - if (record.getState() != null && record.getState().intValue() == 1) { - continue; // 宸查鍙� - } - - IntegralTaskRecord taskRecord = new IntegralTaskRecord(); - taskRecord.setId(record.getId()); - taskRecord.setState(1); // 宸查鍙� - taskRecord.setUpdateTime(new Date()); - integralTaskRecordMapper.updateByPrimaryKeySelective(taskRecord); - - - Long taskId = record.getTaskId(); - if (taskId == null) - continue; - - - IntegralTask integralTask = integralTaskService.selectByPrimaryKey(taskId); - if (integralTask == null) - continue; - - // 鍔犲叆鏄庣粏 - IntegralDetail detail = new IntegralDetail(); - detail.setUid(uid); - detail.setCreateTime(new Date()); - detail.setMoney(record.getGoldCoin()); - detail.setTitle(integralTask.getName()); - integralDetailService.insertSelective(detail); - - totalGoldCoin += record.getGoldCoin(); + if (addDetail(uid, record)) + totalGoldCoin += record.getGoldCoin(); } Integer goldCoin = userInfoExtra.getGoldCoin(); @@ -228,39 +199,8 @@ if (record == null) continue; - Long uid2 = record.getUid(); - if (uid2 == null || uid.longValue() != uid2.longValue()) - continue; // 鐢ㄦ埛id涓嶇鍚� - - if (record.getState() != null && record.getState().intValue() == 1) { - continue; // 宸查鍙� - } - - IntegralTaskRecord taskRecord = new IntegralTaskRecord(); - taskRecord.setId(record.getId()); - taskRecord.setState(1); // 宸查鍙� - taskRecord.setUpdateTime(new Date()); - integralTaskRecordMapper.updateByPrimaryKeySelective(taskRecord); - - - Long taskId = record.getTaskId(); - if (taskId == null) - continue; - - - IntegralTask integralTask = integralTaskService.selectByPrimaryKey(taskId); - if (integralTask == null) - continue; - - // 鍔犲叆鏄庣粏 - IntegralDetail detail = new IntegralDetail(); - detail.setUid(uid); - detail.setCreateTime(new Date()); - detail.setMoney(record.getGoldCoin()); - detail.setTitle(integralTask.getName()); - integralDetailService.insertSelective(detail); - - totalGoldCoin += record.getGoldCoin(); + if (addDetail(uid, record)) + totalGoldCoin += record.getGoldCoin(); } Integer goldCoin = userInfoExtra.getGoldCoin(); @@ -279,6 +219,62 @@ return extra.getGoldCoin(); } + public boolean addDetail(Long uid, IntegralTaskRecord record) throws IntegralTaskRecordException { + + Long uid2 = record.getUid(); + if (uid2 == null || uid.longValue() != uid2.longValue()) + return false; // 鐢ㄦ埛id涓嶇鍚� + + if (record.getState() != null && record.getState().intValue() == 1) { + return false; // 宸查鍙� + } + + IntegralTaskRecord taskRecord = new IntegralTaskRecord(); + taskRecord.setId(record.getId()); + taskRecord.setState(1); // 宸查鍙� + taskRecord.setUpdateTime(new Date()); + integralTaskRecordMapper.updateByPrimaryKeySelective(taskRecord); + + Long cid = record.getCid(); + if (cid == null) + return false; + + IntegralTaskClass taskClass = integralTaskClassService.selectByPrimaryKey(cid); + if (taskClass == null) + return false; + + Long taskId = record.getTaskId(); + if (taskId == null) + return false; + + IntegralTask integralTask = integralTaskService.selectByPrimaryKey(taskId); + if (integralTask == null) + return false; + + int num = 0; + FrequencyEnum frequency = integralTask.getFrequency(); + if (frequency == FrequencyEnum.everyday) { + num = integralTaskRecordMapper.countByTaskIdTodayNum(uid, taskId, record.getCreateTime()); + } else if (frequency == FrequencyEnum.onlyOne) { + num = 1; + } + + if (num <= 0) + num = 1; + + String title = taskClass.getName() + "-" + integralTask.getName() + "-" + num + "娆�"; + + // 鍔犲叆鏄庣粏 + IntegralDetail detail = new IntegralDetail(); + detail.setUid(uid); + detail.setTitle(title); + detail.setMoney(record.getGoldCoin()); + detail.setCreateTime(record.getCreateTime()); + integralDetailService.insertSelective(detail); + + return true; + } + @Override public Integer countGetCountByTaskIdAndDay(Long taskId, Long uid, Date day) { if (day == null) -- Gitblit v1.8.0