| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | 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;
|
| | |
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | 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.user.integral.IntegralTaskClassService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Override
|
| | | public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) {
|
| | | return integralTaskRecordMapper.getTotalGoldCoin(uid, cid, dateType);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void invalidGoldCoin() {
|
| | | integralTaskRecordMapper.invalidGoldCoin();
|
| | | }
|
| | | |
| | | @Override
|
| | | public void finishedTask(long uid, long cid, long taskId, int goldCoin) {
|
| | | IntegralTaskRecord taskRecord = new IntegralTaskRecord();
|
| | | taskRecord.setUid(uid);
|
| | | taskRecord.setCid(cid);
|
| | | taskRecord.setTaskId(taskId);
|
| | | taskRecord.setGoldCoin(goldCoin);
|
| | | taskRecord.setState(0);
|
| | | taskRecord.setState(IntegralTaskRecord.STATE_WAITING_RECIEVE);
|
| | | taskRecord.setCreateTime(new Date());
|
| | | taskRecord.setUpdateTime(new Date());
|
| | | integralTaskRecordMapper.insertSelective(taskRecord);
|
| | |
| | | // 更新金币
|
| | | userInfoExtraService.updateGoldCoin(userInfoExtra.getId(), totalGoldCoin);
|
| | |
|
| | | return (userInfoExtra.getGoldCoin()==null?0:userInfoExtra.getGoldCoin()) + totalGoldCoin;
|
| | | return (userInfoExtra.getGoldCoin() == null ? 0 : userInfoExtra.getGoldCoin()) + totalGoldCoin;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | // 已领取
|
| | | Integer state = record.getState();
|
| | | if (state != null && state == 1)
|
| | | if (state != null && state != 0)
|
| | | continue;
|
| | |
|
| | | if (addDetail(uid, record))
|
| | |
| | | // 更新金币
|
| | | userInfoExtraService.updateGoldCoin(userInfoExtra.getId(), totalGoldCoin);
|
| | |
|
| | | return totalGoldCoin+(userInfoExtra.getGoldCoin()==null?0:userInfoExtra.getGoldCoin());
|
| | | return totalGoldCoin + (userInfoExtra.getGoldCoin() == null ? 0 : userInfoExtra.getGoldCoin());
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean addDetail(Long uid, IntegralTaskRecord record) throws IntegralTaskRecordException {
|
| | | Long uid2 = record.getUid();
|
| | | if (uid2 == null || uid.longValue() != uid2.longValue())
|
| | |
| | | return integralTaskRecordMapper.countGetCountByTaskIdAndDay(taskId, uid, minTime, maxTime);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException {
|
| | | if (record == null)
|
| | |
| | | if (record.getCid() == null || record.getTaskId() == null || record.getGoldCoin() == null
|
| | | || record.getState() == null || record.getUid() == null)
|
| | | throw new IntegralTaskRecordException(2, "数据不完成");
|
| | |
|
| | | Date date = new Date();
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | | record.setCreateTime(date);
|
| | |
|
| | | if (record.getUpdateTime() == null)
|
| | | record.setUpdateTime(new Date());
|
| | | record.setUpdateTime(date);
|
| | | |
| | | // 设置有效期
|
| | | record.setEndTime(DateUtil.plusDayDate(Constant.GOLD_COIN_VALID_DAYS, date));
|
| | | integralTaskRecordMapper.insertSelective(record);
|
| | | return record;
|
| | | }
|
| | |
| | | return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long getTotalGoldCoinByUid(Long uid) {
|
| | | return integralTaskRecordMapper.getTotalGoldCoinByUid(uid);
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @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");
|
| | | String reward = configService.get(ConfigKeyEnum.firstOrderRewardBoss.getKey());
|
| | | if (StringUtil.isNullOrEmpty(reward))
|
| | | return;
|
| | | firstOrderReward(uid, originUid, Integer.parseInt(reward), "一", beizu);
|
| | |
| | | if (uid == null || originUid == null)
|
| | | return;
|
| | |
|
| | | String reward = configService.get("first_order_reward_boss_super");
|
| | | String reward = configService.get(ConfigKeyEnum.firstOrderRewardBossSuper.getKey());
|
| | | if (StringUtil.isNullOrEmpty(reward))
|
| | | return;
|
| | | firstOrderReward(uid, originUid, Integer.parseInt(reward), "二", beizu);
|
| | |
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | String reward = configService.get("first_share_order_reward");
|
| | | String reward = configService.get(ConfigKeyEnum.firstShareOrderReward.getKey());
|
| | | if (StringUtil.isNullOrEmpty(reward))
|
| | | return;
|
| | | firstOrderReward(uid, null, Integer.parseInt(reward), null, beizu);
|
| | | //firstOrderReward(uid, null, Integer.parseInt(reward), null, beizu);
|
| | | }
|
| | |
|
| | | @Async()
|
| | |
| | | if (uid == null || originUid == null)
|
| | | return;
|
| | |
|
| | | String reward = configService.get("first_share_order_reward_boss");
|
| | | String reward = configService.get(ConfigKeyEnum.firstShareOrderRewardBoss.getKey());
|
| | | if (StringUtil.isNullOrEmpty(reward))
|
| | | return;
|
| | | firstOrderReward(uid, originUid, Integer.parseInt(reward), "一", beizu);
|
| | |
| | | if (userInfoExtra == null)
|
| | | return;
|
| | |
|
| | | Integer goldCoin = userInfoExtra.getGoldCoin();
|
| | | if (goldCoin == null)
|
| | | goldCoin = 0;
|
| | | goldCoin = goldCoin + addGoldCoin;
|
| | |
|
| | | int totalGoldCoin = 0;
|
| | | try {
|
| | | UserInfoExtra extra = new UserInfoExtra();
|
| | | extra.setId(userInfoExtra.getId());
|
| | | extra.setGoldCoin(goldCoin);
|
| | | Integer goldCoin = userInfoExtra.getGoldCoin();
|
| | | if (goldCoin == null) {
|
| | | extra.setGoldCoin(addGoldCoin);
|
| | | } else {
|
| | | extra.setGoldCoin(goldCoin + addGoldCoin);
|
| | | }
|
| | | userInfoExtraService.saveUserInfoExtra(extra);
|
| | | totalGoldCoin = extra.getGoldCoin();
|
| | | } catch (UserInfoExtraException e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | return;
|
| | |
| | | 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元时奖励 ");
|
| | | if (level.equalsIgnoreCase("一") || level.equalsIgnoreCase("1")) {
|
| | | // 直接粉丝
|
| | | userOtherMsgNotificationService.goldCoinOrderSubsidyMsg(originUid, addGoldCoin, totalGoldCoin, true);
|
| | | } else {
|
| | | msgOther.setSource(level + "级队员首次下单,系统奖励金币 ");
|
| | | msgOther.setExplain("仅新邀请队员首下单你得到的奖金不足0.01元时奖励 ");
|
| | | // 间接粉丝
|
| | | userOtherMsgNotificationService.goldCoinOrderSubsidyMsg(originUid, addGoldCoin, totalGoldCoin, false);
|
| | | }
|
| | | userOtherMsgNotificationService.firstOrderRewardMsg(uid, null, msgOther);
|
| | | |
| | | }
|
| | | |
| | | }
|