From a9b7fab63c4345a6b183bffdab1bb0884f4202b5 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 22 八月 2019 15:22:19 +0800
Subject: [PATCH] Merge branch 'mater-1.6.0' into div
---
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java | 101 +++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 82 insertions(+), 19 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 8e40a10..1b4ac74 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
@@ -14,13 +14,19 @@
import com.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper;
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;
-import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@Service
@@ -31,6 +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) {
@@ -140,9 +155,14 @@
if (userInfoExtra == null)
throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏");
- int totalGoldCoin = integralTaskRecordMapper.countTotalGoldCoin(uid);
- if (totalGoldCoin > 0) {
- integralTaskRecordMapper.updateReceived(uid);
+ 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) {
+ if (addDetail(uid, record))
+ totalGoldCoin += record.getGoldCoin();
}
Integer goldCoin = userInfoExtra.getGoldCoin();
@@ -179,21 +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);
-
- totalGoldCoin += record.getGoldCoin();
+ if (addDetail(uid, record))
+ totalGoldCoin += record.getGoldCoin();
}
Integer goldCoin = userInfoExtra.getGoldCoin();
@@ -212,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, TimeUtil.getWholeTime(record.getCreateTime().getTime()));
+ } 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