admin
2019-08-27 fe879975a3e8a0a1aa280fb839e02d159bfbcff8
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java
@@ -1,17 +1,20 @@
package com.yeshi.fanli.service.impl.integral;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.ThreeSaleMapper;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.bus.user.UserRank;
import com.yeshi.fanli.entity.integral.IntegralTask;
import com.yeshi.fanli.entity.integral.IntegralTaskRank;
import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum;
import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum;
import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
@@ -19,9 +22,12 @@
import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.integral.IntegralGetService;
import com.yeshi.fanli.service.inter.integral.IntegralTaskRankService;
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.RedisManager;
import com.yeshi.fanli.util.annotation.integral.IntegralGetFrequencyLimit;
import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit;
@Lazy
@@ -39,13 +45,19 @@
   @Resource
   private RedisManager redisManager;
   @Resource
   private UserInfoExtraService userInfoExtraService;
   @Resource
   private IntegralTaskRankService integralTaskRankService;
   // TODO 有bug
   private UserInfo getBossByUid(Long uid) {
      return threeSaleMapper.selectBoss(uid);
   }
   @IntegralGetVersionLimit(uid="#uid")
   @IntegralGetVersionLimit(uid = "#uid")
   @Override
   public IntegralTaskRecord addEventStatistic(Long uid, String event) throws IntegralGetException {
      Date nowDate = new Date();
@@ -68,10 +80,31 @@
         if (count > 0)
            throw new IntegralGetException(2, "事件触发达到上限");
      }
      UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
      if (userInfoExtra == null)
         throw new IntegralGetException(2, "额外信息不存在");
      UserRank userRank = userInfoExtra.getUserRank();
      if (userRank == null)
         throw new IntegralGetException(2,"等级信息不存在");
      int goldCoin = task.getGoldCoin();
      if (task.getDoubleNum() != null && task.getDoubleNum() > 0)
         goldCoin = task.getDoubleNum() * goldCoin;
      Long taskId = task.getId();
      IntegralTaskRank traskRank = integralTaskRankService.getByTsakIdAndRankId(taskId, userRank.getId());
      if (traskRank != null) {
         Integer addCoin = traskRank.getAddCoin();
         if (addCoin != null && addCoin > 0)
            goldCoin += addCoin;
         Integer doubleNum = traskRank.getDoubleNum();
         if (doubleNum != null && doubleNum > 0) {
            goldCoin = goldCoin * doubleNum;
         }
      }
      IntegralTaskRecord record = new IntegralTaskRecord();
      record.setCid(task.getTaskClass().getId());
@@ -88,7 +121,7 @@
      }
   }
   @Cacheable(value = "integralGetCache", key = "'addRecommendSearch-'+#uid")
   @IntegralGetFrequencyLimit(key = "'addRecommendSearch-'+#uid")
   @Override
   public IntegralTaskRecord addRecommendSearch(Long uid) {
      try {
@@ -99,7 +132,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addSearchResultScan-'+#uid+'-'+#kw")
   @IntegralGetFrequencyLimit(key = "'addSearchResultScan-'+#uid+'-'+#kw")
   @Override
   public IntegralTaskRecord addSearchResultScan(Long uid, String kw) {
      try {
@@ -111,7 +144,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addShareInvite-'+#uid")
   @IntegralGetFrequencyLimit(key = "'addShareInvite-'+#uid")
   @Override
   public IntegralTaskRecord addShareInvite(Long uid) {
      try {
@@ -122,7 +155,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addIntoShop-'+#uid+'-'+#shopUrlMD5")
   @IntegralGetFrequencyLimit(key = "'addIntoShop-'+#uid+'-'+#shopUrlMD5")
   @Override
   public IntegralTaskRecord addIntoShop(Long uid, String shopUrlMD5) {
      try {
@@ -157,7 +190,7 @@
      }
   }
   @Cacheable(value = "integralGetCache", key = "'addScanPushHistory-'+#uid")
   @IntegralGetFrequencyLimit(key = "'addScanPushHistory-'+#uid")
   @Override
   public IntegralTaskRecord addScanPushHistory(Long uid) {
      try {
@@ -168,7 +201,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addScanGoodsDetail-'+#uid+'-'+#goodsType+'-'+#goodsId")
   @IntegralGetFrequencyLimit(key = "'addScanGoodsDetail-'+#uid+'-'+#goodsType+'-'+#goodsId")
   @Override
   public IntegralTaskRecord addScanGoodsDetail(Long uid, int goodsType, Long goodsId) {
      try {
@@ -179,7 +212,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addScanRecommendBanner-'+#uid+'-'+#id")
   @IntegralGetFrequencyLimit(key = "'addScanRecommendBanner-'+#uid+'-'+#id")
   @Override
   public IntegralTaskRecord addScanRecommendBanner(Long uid, String id) {
      try {
@@ -190,7 +223,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addScanRecommendSpecial-'+#uid+'-'+#id")
   @IntegralGetFrequencyLimit(key = "'addScanRecommendSpecial-'+#uid+'-'+#id")
   @Override
   public IntegralTaskRecord addScanRecommendSpecial(Long uid, String id) {
      try {
@@ -202,7 +235,7 @@
      return null;
   }
   @Cacheable(value = "integralGetCache", key = "'addScanTaoBaoCart-'+#uid")
   @IntegralGetFrequencyLimit(key = "'addScanTaoBaoCart-'+#uid")
   @Override
   public IntegralTaskRecord addScanTaoBaoCart(Long uid) {
      try {