From 2012b3b5db3c6b06535a68f775bcc81b16151b90 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 06 九月 2019 16:54:00 +0800 Subject: [PATCH] 加入任务 --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java | 152 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 142 insertions(+), 10 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 9b4a6ab..d251491 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 @@ -9,11 +9,14 @@ import javax.annotation.Resource; +import org.springframework.context.annotation.Lazy; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; 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 +27,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 @@ -46,8 +52,17 @@ @Resource private IntegralTaskService integralTaskService; + @Lazy @Resource private IntegralTaskClassService integralTaskClassService; + + @Resource + private UserOtherMsgNotificationService userOtherMsgNotificationService; + + @Resource + private ConfigService configService; + + @Override public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) { @@ -191,13 +206,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 +299,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); @@ -351,4 +370,117 @@ public List<IntegralTaskRecord> listByUidAndTaskId(Long uid, Long taskId, int page, int count) { return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count); } + + + @Async() + @Override + public void firstRebateOrderRewardBoss(Long uid, Long originUid, String beizu) { + if (uid == null || originUid == null) + return; + + String reward = configService.get("first_order_reward_boss"); + if (StringUtil.isNullOrEmpty(reward)) + return; + firstOrderReward(uid, originUid, Integer.parseInt(reward), "涓�", beizu); + } + + @Async() + @Override + public void firstRebateOrderRewardBossSuper(Long uid, Long originUid, String beizu) { + if (uid == null || originUid == null) + return; + + String reward = configService.get("first_order_reward_boss_super"); + if (StringUtil.isNullOrEmpty(reward)) + return; + firstOrderReward(uid, originUid, Integer.parseInt(reward), "浜�", beizu); + } + + + @Async() + @Override + public void firstShareOrderReward(Long uid, String beizu) { + if(uid == null) + return; + + String reward = configService.get("first_share_order_reward"); + if (StringUtil.isNullOrEmpty(reward)) + return; + firstOrderReward(uid, null, Integer.parseInt(reward), null, beizu); + } + + + @Async() + @Override + public void firstSharerOrderRewardBoss(Long uid, Long originUid, String beizu) { + if (uid == null || originUid == null) + return; + + String reward = configService.get("first_share_order_reward_boss"); + if (StringUtil.isNullOrEmpty(reward)) + return; + firstOrderReward(uid, originUid, Integer.parseInt(reward), "涓�", beizu); + } + + + /** + * 闃熷憳棣栧崟濂栧姳閲戝竵 + * @param uid + * @param addGoldCoin + * @param level 鎵�灞炲摢绾ч槦鍛� + * @param beizu + */ + private void firstOrderReward(Long uid, Long originUid, Integer addGoldCoin, String level, String beizu) { + String uniqueKey = "firstOrder-"+ uid.toString(); + if (originUid != null) + uniqueKey = uniqueKey + "-" + originUid; + + // 鍒ゆ柇鏄惁宸查鍙� + IntegralDetail detailRecord = integralDetailService.getDetailByUniqueKey(uniqueKey); + if (detailRecord != null) + return; + + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); + if (userInfoExtra == null) + return; + + Integer goldCoin = userInfoExtra.getGoldCoin(); + if (goldCoin == null) + goldCoin = 0; + goldCoin = goldCoin + addGoldCoin; + + try { + UserInfoExtra extra = new UserInfoExtra(); + extra.setId(userInfoExtra.getId()); + extra.setGoldCoin(goldCoin); + userInfoExtraService.saveUserInfoExtra(extra); + } catch (UserInfoExtraException e) { + LogHelper.errorDetailInfo(e); + return; + } + + // 閲戝竵璇︽儏 + IntegralDetail detail = new IntegralDetail(); + detail.setTitle("閲戝竵濂栧姳"); + detail.setUid(uid); + detail.setMoney(addGoldCoin); + detail.setRemark(beizu); + detail.setUniqueKey(uniqueKey); + detail.setCreateTime(new Date()); + integralDetailService.insertSelective(detail); + + // 娑堟伅 + MsgOtherRewardIntegralDTO msgOther = new MsgOtherRewardIntegralDTO(); + msgOther.setTitle("閲戝竵濂栧姳"); + msgOther.setNum(addGoldCoin + "閲戝竵"); + msgOther.setTotal(goldCoin + "閲戝竵"); + if (StringUtil.isNullOrEmpty(level)) { + msgOther.setSource("棣栫瑪鍒嗕韩璁㈠崟锛岀郴缁熷鍔遍噾甯� "); + msgOther.setExplain("棣栫瑪鍒嗕韩璁㈠崟寰楀埌鐨勫閲戜笉瓒�0.01鍏冩椂濂栧姳 "); + } else { + msgOther.setSource(level + "绾ч槦鍛橀娆′笅鍗曪紝绯荤粺濂栧姳閲戝竵 "); + msgOther.setExplain("浠呮柊閭�璇烽槦鍛橀涓嬪崟浣犲緱鍒扮殑濂栭噾涓嶈冻0.01鍏冩椂濂栧姳 "); + } + userOtherMsgNotificationService.firstOrderRewardMsg(uid, null, msgOther); + } } -- Gitblit v1.8.0