| | |
| | | package com.yeshi.fanli.service.impl.integral;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | 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.integral.IntegralTask;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.exception.integral.IntegralGetException;
|
| | | 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.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskService;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Lazy
|
| | | @Service
|
| | | public class IntegralGetServiceImpl implements IntegralGetService {
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskService integralTaskService;
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleMapper threeSaleMapper;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | // TODO 有bug
|
| | | private UserInfo getBossByUid(Long uid) {
|
| | | return threeSaleMapper.selectBoss(uid);
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid="#uid")
|
| | | @Override
|
| | | public void addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException {
|
| | | switch (event) {
|
| | | case "recommendSearch":
|
| | | break;
|
| | | case "shareInvite":
|
| | | break;
|
| | | case "inShop":
|
| | | break;
|
| | | case "scanPush":
|
| | | break;
|
| | | case "scanGoods":
|
| | | break;
|
| | | case "scanHomeBanner":
|
| | | break;
|
| | | case "scanSpecial":
|
| | | break;
|
| | | case "scanTBCart":
|
| | | break;
|
| | | public IntegralTaskRecord addEventStatistic(Long uid, String event) throws IntegralGetException {
|
| | | Date nowDate = new Date();
|
| | | IntegralTask task = integralTaskService.getByCidAndUniqueKey(null, event);
|
| | | if (task == null)
|
| | | throw new IntegralGetException(1, "事件类型不存在");
|
| | |
|
| | | if (TaskUniqueKeyEnum.inShop == TaskUniqueKeyEnum.valueOf(event)) {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addInShopLevelOne(boss.getId()); // 下级浏览店铺
|
| | | }
|
| | |
|
| | | if (task.getFrequency() == FrequencyEnum.everyday) {
|
| | | int count = integralTaskRecordService.countGetCountByTaskIdAndDay(task.getId(), uid, nowDate);
|
| | | if (count >= task.getUpperLimit())
|
| | | throw new IntegralGetException(2, "事件触发达到上限");
|
| | | } else if (task.getFrequency() == FrequencyEnum.onlyOne) {
|
| | | int count = integralTaskRecordService.countGetCountByTaskIdAndDay(task.getId(), uid, null);
|
| | | if (count > 0)
|
| | | throw new IntegralGetException(2, "事件触发达到上限");
|
| | | }
|
| | |
|
| | | int goldCoin = task.getGoldCoin();
|
| | | if (task.getDoubleNum() != null && task.getDoubleNum() > 0)
|
| | | goldCoin = task.getDoubleNum() * goldCoin;
|
| | |
|
| | | IntegralTaskRecord record = new IntegralTaskRecord();
|
| | | record.setCid(task.getTaskClass().getId());
|
| | | record.setGoldCoin(goldCoin);
|
| | | record.setState(IntegralTaskRecord.STATE_WAITING_RECIEVE);
|
| | | record.setTaskId(task.getId());
|
| | | record.setUid(uid);
|
| | |
|
| | | try {
|
| | | IntegralTaskRecord addRecord = integralTaskRecordService.addRecord(record);
|
| | | return addRecord;
|
| | | } catch (IntegralTaskRecordException e) {
|
| | | throw new IntegralGetException(3, "添加记录失败");
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addRecommendSearch-'+#uid")
|
| | | @Override
|
| | | public void addRecommendSearch(Long uid) throws IntegralGetException {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | public IntegralTaskRecord addRecommendSearch(Long uid) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.recommendSearch.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addSearchResultScan-'+#uid+'-'+#kw")
|
| | | @Override
|
| | | public void addSearchResultScan(Long uid) throws IntegralGetException {
|
| | | // TODO Auto-generated method stub
|
| | | public IntegralTaskRecord addSearchResultScan(Long uid, String kw) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.scanSearchResult.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addShareInvite-'+#uid")
|
| | | @Override
|
| | | public void addShareInvite(Long uid) throws IntegralGetException {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | public IntegralTaskRecord addShareInvite(Long uid) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.shareInvite.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addIntoShop-'+#uid+'-'+#shopUrlMD5")
|
| | | @Override
|
| | | public void addIntoShop(Long uid) throws IntegralGetException {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | public IntegralTaskRecord addIntoShop(Long uid, String shopUrlMD5) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.inShop.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addScanPushHistory(Long uid) throws IntegralGetException {
|
| | | // TODO Auto-generated method stub
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addInShopLevelOne(Long uid) {
|
| | | try {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addInShopLevelTwo(boss.getId()); // 二级队员
|
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inShopLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addScanGoodsDetail(Long uid, int goodsType, Long goodsId) {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addInShopLevelTwo(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inShopLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addScanPushHistory-'+#uid")
|
| | | @Override
|
| | | public void addScanRecommendBanner(Long uid) {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | public IntegralTaskRecord addScanPushHistory(Long uid) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.scanPush.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addScanGoodsDetail-'+#uid+'-'+#goodsType+'-'+#goodsId")
|
| | | @Override
|
| | | public void addScanRecommendSpecial(Long uid) {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | public IntegralTaskRecord addScanGoodsDetail(Long uid, int goodsType, Long goodsId) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.scanGoods.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addScanRecommendBanner-'+#uid+'-'+#id")
|
| | | @Override
|
| | | public void addScanTaoBaoCart(Long uid) {
|
| | | // TODO Auto-generated method stub
|
| | | public IntegralTaskRecord addScanRecommendBanner(Long uid, String id) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.scanHomeBanner.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addScanRecommendSpecial-'+#uid+'-'+#id")
|
| | | @Override
|
| | | public IntegralTaskRecord addScanRecommendSpecial(Long uid, String id) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.scanSpecial.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "integralGetCache", key = "'addScanTaoBaoCart-'+#uid")
|
| | | @Override
|
| | | public IntegralTaskRecord addScanTaoBaoCart(Long uid) {
|
| | | try {
|
| | | return addEventStatistic(uid, TaskUniqueKeyEnum.scanTBCart.name());
|
| | | } catch (IntegralGetException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addTaoLiJinBuy(Long uid, Long goodsId) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.taoLiJinBuy.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addInviteLevelOne(Long uid, Long workerId) {
|
| | | try {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addInviteLevelTwo(boss.getId());
|
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 间接邀请
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addInviteLevelTwo(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addShareSingleGoods(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareSingleGoods.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addShareMultipleGoods(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareMultipleGoods.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addShareTLJGoods(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareTLJGoods.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addGiveRebateCoupon(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.giveRebateCoupon.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addGiveFreeCoupon(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.giveFreeCoupon.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addGiveTaoLiJin(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.giveTaoLiJin.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addCloseRecommendGoods(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.closeRecommendGoods.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addCouponRebate(Long uid) {
|
| | | try {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addCouponRebateLevelOne(boss.getId());
|
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.couponRebate.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 一级队员领券返利
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addCouponRebateLevelOne(Long uid) {
|
| | | try {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addCouponRebateLevelTwo(boss.getId()); // 二级队员
|
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.couponRebateLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 二级队员领券返利
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addCouponRebateLevelTwo(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.couponRebateLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addRebateOrder(Long uid) {
|
| | | try {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addInviteOrderLevelOne(boss.getId());
|
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.rebateOrder.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 一级队员邀请订单
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addInviteOrderLevelOne(Long uid) {
|
| | | try {
|
| | | UserInfo boss = getBossByUid(uid);
|
| | | if (boss != null)
|
| | | addInviteOrderLevelTwo(boss.getId());
|
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 二级队员邀请订单
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | private void addInviteOrderLevelTwo(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addShareOrder(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareOrder.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addBindWeiXin(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindWeiXin.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addBindPhone(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindPhone.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addBindTaoBao(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindTaoBao.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addSetWeiXinNum(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setWeiXinNum.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addSetGender(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setGender.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addSetPortrait(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setPortrait.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addSetNickname(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setNickName.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addBindAlipay(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindAlipay.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @Async()
|
| | | @Override
|
| | | public void addInviteActivate(Long uid) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteActivate.name());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|