yujian
2019-11-20 394ee5b2dc3416634540b9f942c869574adb3d9c
邀请订单到账
4个文件已修改
63 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java
@@ -552,7 +552,7 @@
            for (Iterator<String> its = sets.iterator(); its.hasNext();)
                array.add(its.next());
        } finally {
            jedisPool.returnResource(jedis);
            jedis.close();
        }
        out.println(array.toString());
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -18,6 +18,7 @@
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
@@ -36,6 +37,7 @@
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
import com.yeshi.fanli.util.annotation.redpack.RedPackGetVersionLimit;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@Service
@@ -163,54 +165,49 @@
    
    
    @RequestSerializableByKeyService(key = "#uid")
    @RedPackGetVersionLimit(uid = "#uid")
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
    public void inviteOrderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
        if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo))
            return;
        
        ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(uid, Constant.RED_PACK_REWARD_TIME);
        if(threeSale == null)
            return;
        bossReward(threeSale.getBoss().getId(), uid, source, orderNo);
    }
    /**
     * 上级奖励
     * @param uid
     * @param teamUid
     * @param source
     * @param orderNo
     * @throws Exception
     */
    @Transactional
    private void  bossReward(Long bossId, Long teamUid, Integer source, String orderNo)  throws Exception {
        UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
        if (activeLog == null)
        //获取订单对应下单人
        List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(source, orderNo);
        if (list == null || list.isEmpty())
            return;
        
        // 小于2.0.2版本不增加
        if (!VersionUtil.greaterThan_2_1("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
                activeLog.getVersionCode()))
        CommonOrder commonOrder = list.get(0);
        if (commonOrder == null || commonOrder.getUserInfo() == null)
            return;
        // 下单人id
        Long teamUid = commonOrder.getUserInfo().getId();
        if (teamUid == null)
            return;
        // 验证上下级关系
        ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(teamUid, Constant.RED_PACK_REWARD_TIME);
        if(threeSale == null || threeSale.getBoss().getId().longValue() != uid.longValue())
            return;
        
        // 第一阶段(验证)
        RedPackWinInvite oneStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(bossId, teamUid, RedPackWinInviteTypeEnum.oneStageReward.name());
        RedPackWinInvite oneStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(uid, teamUid, RedPackWinInviteTypeEnum.oneStageReward.name());
        if (oneStage == null)
            return;
        
        // 第二阶段(验证)
        RedPackWinInvite twoStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(bossId, teamUid, RedPackWinInviteTypeEnum.twoStageReward.name());
        RedPackWinInvite twoStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(uid, teamUid, RedPackWinInviteTypeEnum.twoStageReward.name());
        if (twoStage == null) {
            twoStageRewardToBoss(bossId, teamUid, oneStage.getCreateTime(), source, orderNo);
            twoStageRewardToBoss(uid, teamUid, oneStage.getCreateTime(), source, orderNo);
            return;
        } 
        
        // 第三阶段
        threeStageRewardToBoss(bossId, teamUid, twoStage.getCreateTime(), source, orderNo);
        threeStageRewardToBoss(uid, teamUid, twoStage.getCreateTime(), source, orderNo);
    }
    
    /**
     *    上级奖励--第二阶段
     * @param uid
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
@@ -8,13 +8,13 @@
public interface RedPackWinInviteService {
    /**
     * 订单到账-相关奖励
     * 邀请订单到账-相关奖励
     * @param uid
     * @param inviteeUid
     * @param source
     * @param orderNo
     */
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
    public void inviteOrderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
    /**
     * 查询获得记录
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
@@ -91,12 +91,12 @@
        } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiSeparateByOrderNo.name())) {// 订单到账(按订单号处理)
            OrderMoneyRecievedMQMsg orderMoneyRecievedMQMsg = new Gson().fromJson(new String(message.getBody()),
                    OrderMoneyRecievedMQMsg.class);
            if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU
                    || orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {
            if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_INVITE) {
                if (!StringUtil.isNullOrEmpty(orderMoneyRecievedMQMsg.getOrderId())
                        && orderMoneyRecievedMQMsg.getUid() != null) {
                     try {
                         redPackWinInviteService.orderArriveReward(orderMoneyRecievedMQMsg.getUid(), orderMoneyRecievedMQMsg.getSourceType(), orderMoneyRecievedMQMsg.getOrderId());
                         redPackWinInviteService.inviteOrderArriveReward(orderMoneyRecievedMQMsg.getUid(),
                                 orderMoneyRecievedMQMsg.getSourceType(), orderMoneyRecievedMQMsg.getOrderId());
                     } catch (Exception e) {
                         e.printStackTrace();
                     }