package com.yeshi.fanli.service.impl.integral;
|
|
import java.util.Date;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.stereotype.Service;
|
|
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.hongbao.ThreeSaleSerivce;
|
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;
|
|
@Service
|
public class IntegralGetServiceImpl implements IntegralGetService {
|
|
@Resource
|
private IntegralTaskService integralTaskService;
|
|
@Resource
|
private IntegralTaskRecordService integralTaskRecordService;
|
|
@Resource
|
private ThreeSaleSerivce threeSaleSerivce;
|
|
@Resource
|
private RedisManager redisManager;
|
|
@Override
|
public IntegralTaskRecord addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException {
|
Date nowDate = new Date();
|
IntegralTask task = integralTaskService.getByCidAndUniqueKey(null, event);
|
if (task == null)
|
throw new IntegralGetException(1, "事件类型不存在");
|
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);
|
if (TaskUniqueKeyEnum.inShop == TaskUniqueKeyEnum.valueOf(event)) {
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addInShopLevelOne(boss.getId()); // 下级浏览店铺
|
}
|
return addRecord;
|
} catch (IntegralTaskRecordException e) {
|
throw new IntegralGetException(3, "添加记录失败");
|
}
|
|
|
|
|
// 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;
|
// }
|
}
|
|
@Override
|
public void addRecommendSearch(Long uid) throws IntegralGetException {
|
|
}
|
|
@Cacheable(value = "integralGetCache", key = "'addSearchResultScan-'+#uid+'-'+#kw")
|
@Override
|
public void addSearchResultScan(Long uid, String kw) throws IntegralGetException {
|
System.out.println("搜索");
|
}
|
|
@Override
|
public void addShareInvite(Long uid) throws IntegralGetException {
|
|
}
|
|
@Override
|
public void addIntoShop(Long uid) throws IntegralGetException {
|
// TODO Auto-generated method stub
|
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addInShopLevelOne(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inShopLevelOne.name(), null);
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addInShopLevelTwo(boss.getId()); // 二级队员
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addInShopLevelTwo(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inShopLevelTwo.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@Override
|
public void addScanPushHistory(Long uid) throws IntegralGetException {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void addScanGoodsDetail(Long uid, int goodsType, Long goodsId) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void addScanRecommendBanner(Long uid) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void addScanRecommendSpecial(Long uid) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void addScanTaoBaoCart(Long uid) {
|
// TODO Auto-generated method stub
|
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addTaoLiJinBuy(Long uid, Long goodsId) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.taoLiJinBuy.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addInviteLevelOne(Long uid, Long workerId) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelOne.name(), null);
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addInviteLevelTwo(boss.getId());
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
/**
|
* 间接邀请
|
* @param uid
|
*/
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addInviteLevelTwo(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelTwo.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addShareSingleGoods(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.shareSingleGoods.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addShareMultipleGoods(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.shareMultipleGoods.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addShareTLJGoods(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.shareTLJGoods.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addGiveRebateCoupon(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.giveRebateCoupon.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addGiveFreeCoupon(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.giveFreeCoupon.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addGiveTaoLiJin(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.giveTaoLiJin.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addCloseRecommendGoods(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.closeRecommendGoods.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addCouponRebate(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.couponRebate.name(), null);
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addCouponRebateLevelOne(boss.getId());
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
/**
|
* 一级队员领券返利
|
* @param uid
|
*/
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addCouponRebateLevelOne(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.couponRebateLevelOne.name(), null);
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addCouponRebateLevelTwo(boss.getId()); // 二级队员
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
/**
|
* 二级队员领券返利
|
* @param uid
|
*/
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addCouponRebateLevelTwo(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.couponRebateLevelTwo.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addRebateOrder(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.rebateOrder.name(), null);
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addInviteOrderLevelOne(boss.getId());
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
/**
|
* 一级队员邀请订单
|
* @param uid
|
*/
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addInviteOrderLevelOne(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelOne.name(), null);
|
UserInfo boss = threeSaleSerivce.getBoss(uid);
|
if (boss != null)
|
addInviteOrderLevelTwo(boss.getId());
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
/**
|
* 二级队员邀请订单
|
* @param uid
|
*/
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
private void addInviteOrderLevelTwo(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelTwo.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addShareOrder(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.shareOrder.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addBindWeiXin(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.bindWeiXin.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addBindPhone(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.bindPhone.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addBindTaoBao(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.bindTaoBao.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addSetWeiXinNum(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.setWeiXinNum.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addSetGender(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.setGender.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addSetPortrait(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.setPortrait.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addSetNickname(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.setNickName.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addBindAlipay(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.bindAlipay.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
@IntegralGetVersionLimit(uid="#uid")
|
@Async()
|
@Override
|
public void addInviteActivate(Long uid) {
|
try {
|
addEventStatistic(uid, TaskUniqueKeyEnum.inviteActivate.name(), null);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
}
|