From f1a2d46aaa612253afba7b1d61ad04a2f0ef7eed Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 21 八月 2019 11:55:52 +0800 Subject: [PATCH] 金币获得客户端事件添加 --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java | 134 ++++++++++++++++++++++++++------------------ 1 files changed, 79 insertions(+), 55 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 ca3dda5..8e40a10 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 @@ -20,26 +20,28 @@ import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.TimeUtil; @Service public class IntegralTaskRecordServiceImpl implements IntegralTaskRecordService { @Resource private IntegralTaskRecordMapper integralTaskRecordMapper; - + @Resource private UserInfoExtraService userInfoExtraService; - + @Override public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) { return integralTaskRecordMapper.getTotalGoldCoin(uid, cid, dateType); } - + @Override public Integer countFinished(long uid, Long cid, Integer dateType) { return integralTaskRecordMapper.countFinished(uid, cid, dateType); } - + @Override public void finishedTask(long uid, long cid, long taskId, int goldCoin) { IntegralTaskRecord taskRecord = new IntegralTaskRecord(); @@ -52,16 +54,16 @@ taskRecord.setUpdateTime(new Date()); integralTaskRecordMapper.insertSelective(taskRecord); } - + @Override public boolean isToDaySign(long uid, Long cid) { - Integer countFinished = integralTaskRecordMapper.countFinished(uid, cid, 1); - if (countFinished != null && countFinished > 0) { - return true; - } - return false; + Integer countFinished = integralTaskRecordMapper.countFinished(uid, cid, 1); + if (countFinished != null && countFinished > 0) { + return true; + } + return false; } - + @Override public Integer getNowdaySignNum(long uid, Long cid) { int num = 1; @@ -69,30 +71,29 @@ // 绛惧埌鏃堕棿鍊掑簭鏌ヨ杩�7澶╂暟鎹� List<IntegralTaskRecord> list = integralTaskRecordMapper.listDaySignRecord(uid, cid); if (list != null && list.size() > 0) { - Date today =new Date(); - for (IntegralTaskRecord record: list) { - if (DateUtil.daysBetween2(record.getCreateTime(),today) == 0) { - continue; + Date today = new Date(); + for (IntegralTaskRecord record : list) { + if (DateUtil.daysBetween2(record.getCreateTime(), today) == 0) { + continue; } - - if (DateUtil.daysBetween2(record.getCreateTime(),today) != 1) { + + if (DateUtil.daysBetween2(record.getCreateTime(), today) != 1) { break; // 澶╂暟鏈繛缁� } today = record.getCreateTime(); - num ++ ; + num++; } } } catch (Exception e) { LogHelper.errorDetailInfo(e); } - + if (num > 7) { num = 1; } return num; } - - + @Override public List<Date> getSignDays(long uid, Long cid) { List<Date> listDate = new ArrayList<Date>(); @@ -101,9 +102,9 @@ List<IntegralTaskRecord> list = integralTaskRecordMapper.listDaySignRecord(uid, cid); if (list != null && list.size() > 0) { Date date = new Date(); - for (IntegralTaskRecord record: list) { + for (IntegralTaskRecord record : list) { Date createTime = record.getCreateTime(); - if (DateUtil.daysBetween2(createTime,date) > 1) { + if (DateUtil.daysBetween2(createTime, date) > 1) { break; // 澶╂暟鏈繛缁� } date = createTime; @@ -113,18 +114,17 @@ } catch (Exception e) { LogHelper.errorDetailInfo(e); } - + // 鍊掑簭 - Collections.reverse(listDate); + Collections.reverse(listDate); return listDate; } - + @Override public List<IntegralTaskRecord> listNotReceived(int count, long uid) { return integralTaskRecordMapper.listNotReceived(count, uid); } - - + @Override public List<IntegralTaskRecord> listNotReceivedExcludeId(int count, long uid, Set<Long> idList) { if (idList != null && idList.size() == 0) { @@ -132,24 +132,23 @@ } return integralTaskRecordMapper.listNotReceivedExcludeId(count, uid, idList); } - - + @Override @Transactional - public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException { + public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException { UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); - if (userInfoExtra == null) + if (userInfoExtra == null) throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏"); - + int totalGoldCoin = integralTaskRecordMapper.countTotalGoldCoin(uid); if (totalGoldCoin > 0) { integralTaskRecordMapper.updateReceived(uid); } - + Integer goldCoin = userInfoExtra.getGoldCoin(); - if (goldCoin == null) + if (goldCoin == null) goldCoin = 0; - + UserInfoExtra extra = new UserInfoExtra(); extra.setId(userInfoExtra.getId()); extra.setGoldCoin(goldCoin + totalGoldCoin); @@ -158,51 +157,49 @@ } catch (UserInfoExtraException e) { throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏"); } - + return extra.getGoldCoin(); } - - - + @Override @Transactional - public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException { - if(idList == null || idList.size() == 0) { + public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException { + if (idList == null || idList.size() == 0) { throw new IntegralTaskRecordException(1, "id涓虹┖"); } - + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra == null) { throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏"); } - + Integer totalGoldCoin = 0; - for (Long id: idList) { + for (Long id : idList) { IntegralTaskRecord record = integralTaskRecordMapper.selectByPrimaryKey(id); - if (record == null) + 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(); } - + Integer goldCoin = userInfoExtra.getGoldCoin(); - if (goldCoin == null) + if (goldCoin == null) goldCoin = 0; - + UserInfoExtra extra = new UserInfoExtra(); extra.setId(userInfoExtra.getId()); extra.setGoldCoin(goldCoin + totalGoldCoin); @@ -211,8 +208,35 @@ } catch (UserInfoExtraException e) { throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏"); } - + return extra.getGoldCoin(); } -} + @Override + public Integer countGetCountByTaskIdAndDay(Long taskId, Long uid, Date day) { + if (day == null) + return null; + Date minTime = new Date( + TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(day.getTime(), "yyyy-MM-dd"), "yyyy-MM-dd")); + Date maxTime = new Date(minTime.getTime() + 1000 * 60 * 60 * 24L); + return integralTaskRecordMapper.countGetCountByTaskIdAndDay(taskId, uid, minTime, maxTime); + } + + @Override + public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException { + if (record == null) + throw new IntegralTaskRecordException(1, "璁板綍涓虹┖"); + + if (record.getCid() == null || record.getTaskId() == null || record.getGoldCoin() == null + || record.getState() == null || record.getUid() == null) + throw new IntegralTaskRecordException(2, "鏁版嵁涓嶅畬鎴�"); + + if (record.getCreateTime() == null) + record.setCreateTime(new Date()); + + if (record.getUpdateTime() == null) + record.setUpdateTime(new Date()); + integralTaskRecordMapper.insertSelective(record); + return record; + } +} -- Gitblit v1.8.0