| | |
| | |
|
| | | 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;
|
| | |
| | | @Resource
|
| | | private IntegralTaskService integralTaskService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private IntegralTaskClassService integralTaskClassService;
|
| | |
|
| | |
| | | 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();
|
| | | }
|
| | |
| | | }
|
| | | 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);
|
| | |
| | | return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 被邀请人下了首单(第一笔返利订单) 直接给邀请人一笔金币
|
| | | * @param uid
|
| | | */
|
| | | |
| | | @Async()
|
| | | @Override
|
| | | public void firstOrderRewardInviter(Long uid, String beizu) {
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) |
| | | 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;
|
| | | |
| | | 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();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 金币详情
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("队员首笔奖励");
|
| | | 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.setSource("一级队员首笔下单,系统奖励邀请人金币");
|
| | | msgOther.setNum(addGoldCoin + "金币");
|
| | | msgOther.setTotal(goldCoin + "金币");
|
| | | msgOther.setExplain("仅一级队员首笔下单奖励(已到账)");
|
| | | userOtherMsgNotificationService.firstOrderRewardMsg(uid, "", msgOther);
|
| | | if (StringUtil.isNullOrEmpty(level)) {
|
| | | msgOther.setSource("首笔分享订单,系统奖励金币 ");
|
| | | msgOther.setExplain("首笔分享订单得到的奖金不足0.01元时奖励 ");
|
| | | } else {
|
| | | msgOther.setSource(level + "级队员首次下单,系统奖励金币 ");
|
| | | msgOther.setExplain("仅新邀请队员首下单你得到的奖金不足0.01元时奖励 ");
|
| | | }
|
| | | userOtherMsgNotificationService.firstOrderRewardMsg(uid, null, msgOther);
|
| | | }
|
| | | |
| | | }
|