From 972d3bc71115ec977dccf835fbcd148da3bcc86c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 03 九月 2019 16:41:49 +0800 Subject: [PATCH] 统计可用的免单券数量-countUsableFreeCouponForBuy --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java | 110 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 94 insertions(+), 16 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 6b272d8..540e7a3 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,6 +14,7 @@ import org.yeshi.utils.DateUtil; import com.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper; +import com.yeshi.fanli.dto.msg.MsgOtherRewardIntegralDTO; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.integral.IntegralDetail; import com.yeshi.fanli.entity.integral.IntegralTask; @@ -24,11 +25,14 @@ 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.config.ConfigService; 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.msg.UserOtherMsgNotificationService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; +import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; @Service @@ -48,6 +52,14 @@ @Resource private IntegralTaskClassService integralTaskClassService; + + @Resource + private UserOtherMsgNotificationService userOtherMsgNotificationService; + + @Resource + private ConfigService configService; + + @Override public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) { @@ -191,13 +203,18 @@ if (userInfoExtra == null) { throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏"); } - + Integer totalGoldCoin = 0; for (Long id : idList) { IntegralTaskRecord record = integralTaskRecordMapper.selectByPrimaryKey(id); if (record == null) continue; - + + // 宸查鍙� + Integer state = record.getState(); + if (state != null && state == 1) + continue; + if (addDetail(uid, record)) totalGoldCoin += record.getGoldCoin(); } @@ -279,19 +296,18 @@ } detail.setTitle(taskClass.getName() + "-绗�" + num + "澶�"); } else { - int num = 0; FrequencyEnum frequency = integralTask.getFrequency(); if (frequency == FrequencyEnum.everyday) { - num = integralTaskRecordMapper.countByTaskIdTodayNum(uid, taskId, + int num = integralTaskRecordMapper.countByTaskIdTodayNum(uid, taskId, TimeUtil.getWholeTime(record.getCreateTime().getTime())); + if (num <= 0) + num = 1; + String title = taskClass.getName() + "-" + integralTask.getName() + "-绗�" + num + "娆�"; + detail.setTitle(title); } else if (frequency == FrequencyEnum.onlyOne) { - num = 1; + String title = taskClass.getName() + "-" + integralTask.getName(); + detail.setTitle(title); } - - if (num <= 0) - num = 1; - String title = taskClass.getName() + "-" + integralTask.getName() + "-" + num + "娆�"; - detail.setTitle(title); } detail.setUid(uid); @@ -303,12 +319,17 @@ } @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); + public int countGetCountByTaskIdAndDay(Long taskId, Long uid, Date day) { + Date minTime = null; + Date maxTime = null; + if (day == null) { + minTime = new Date(TimeUtil.convertToTimeTemp("1970-01-01", "yyyy-MM-dd")); + maxTime = new Date(TimeUtil.convertToTimeTemp("2100-01-01", "yyyy-MM-dd")); + } else { + minTime = new Date( + TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(day.getTime(), "yyyy-MM-dd"), "yyyy-MM-dd")); + maxTime = new Date(minTime.getTime() + 1000 * 60 * 60 * 24L); + } return integralTaskRecordMapper.countGetCountByTaskIdAndDay(taskId, uid, minTime, maxTime); } @@ -341,4 +362,61 @@ public long countByCidAndUidAndCreateTime(Long cid, Long uid, Date minTime, Date maxTime) { return integralTaskRecordMapper.countByCidAndUidAndCreateTime(cid, uid, minTime, maxTime); } + + @Override + public List<IntegralTaskRecord> listByUidAndTaskId(Long uid, Long taskId, int page, int count) { + return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count); + } + + /** + * 琚個璇蜂汉涓嬩簡棣栧崟锛堢涓�绗旇繑鍒╄鍗曪級 鐩存帴缁欓個璇蜂汉涓�绗旈噾甯� + * @param uid + */ + @Override + public void firstOrderRewardInviter(Long uid, String beizu) { + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); + if (userInfoExtra == null) + return; + + String reward = configService.get("first_order_reward_boss"); + if (StringUtil.isNullOrEmpty(reward)) + return; + + Integer goldCoin = userInfoExtra.getGoldCoin(); + if (goldCoin == null) + goldCoin = 0; + + int addGoldCoin = Integer.parseInt(reward); + goldCoin = goldCoin + addGoldCoin; + + try { + // 澧炲姞閲戝竵 + UserInfoExtra extra = new UserInfoExtra(); + extra.setId(userInfoExtra.getId()); + extra.setGoldCoin(goldCoin); + userInfoExtraService.saveUserInfoExtra(extra); + } catch (UserInfoExtraException e) { + e.printStackTrace(); + return; + } + + // 閲戝竵璇︽儏 + IntegralDetail detail = new IntegralDetail(); + detail.setTitle("闃熷憳棣栫瑪濂栧姳"); + detail.setUid(uid); + detail.setMoney(addGoldCoin); + detail.setRemark(beizu); + detail.setCreateTime(new Date()); + integralDetailService.insertSelective(detail); + + // 娑堟伅 + MsgOtherRewardIntegralDTO msgOther = new MsgOtherRewardIntegralDTO(); + msgOther.setTitle("閲戝竵濂栧姳"); + msgOther.setSource("涓�绾ч槦鍛橀绗斾笅鍗曪紝绯荤粺濂栧姳閭�璇蜂汉閲戝竵"); + msgOther.setNum(addGoldCoin + "閲戝竵"); + msgOther.setTotal(goldCoin + "閲戝竵"); + msgOther.setExplain("浠呬竴绾ч槦鍛橀绗斾笅鍗曞鍔�"); + userOtherMsgNotificationService.firstOrderRewardMsg(uid, "璁㈠崟宸插埌璐﹀悗绯荤粺浼氳嚜鍔ㄥ鍔�", msgOther); + } + } -- Gitblit v1.8.0