yujian
2019-11-07 44919f5505a7b42a5f1a33f6c6d27b16188a42c6
消息
2个文件已修改
65 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -12,6 +12,7 @@
import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackWinInviteMapper;
import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
import com.yeshi.fanli.dto.msg.MsgRedPackAddContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -229,7 +230,17 @@
    }
    
    
    @RequestSerializableByKeyService(key = "#uid")
    @RedPackGetVersionLimit(uid = "#bindingMQMsg.uid")
    @RequestSerializableByKeyService(key = "#bindingMQMsg.uid")
    public void userAccountBinding(UserAccountBindingMQMsg bindingMQMsg) throws Exception{
        Integer type = bindingMQMsg.getType();
        if (type == UserAccountBindingMQMsg.TYPE_PHONE || type == UserAccountBindingMQMsg.TYPE_TAOBAO) {
            inviteSucceedReward(bindingMQMsg.getUid());
        }
    }
    @Override
    @Transactional
    public void inviteSucceedReward(Long uid) throws Exception{
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
@@ -11,12 +11,14 @@
import com.google.gson.Gson;
import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
import com.yeshi.fanli.dto.mq.order.body.OrderMQMsg;
import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
import com.yeshi.fanli.dto.mq.user.body.UserRegisterMQMsg;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
@@ -32,6 +34,9 @@
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private RedPackWinInviteService redPackWinInviteService;
    @Override
    public Action consume(Message message, ConsumeContext context) {
@@ -44,25 +49,62 @@
        if (baseBody.isTest() != Constant.IS_TEST)
            return Action.ReconsumeLater;
        if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
            if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {// 返利到账
                OrderMoneyRecievedMQMsg orderMoneyRecievedMQMsg = new Gson().fromJson(new String(message.getBody()),
                        OrderMoneyRecievedMQMsg.class);
                if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {
                    try {// 上级分享订单奖励
                        redPackWinInviteService.orderArriveReward(orderMoneyRecievedMQMsg.getUid(),
                                orderMoneyRecievedMQMsg.getSourceType(), orderMoneyRecievedMQMsg.getOrderId());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) {// 订单统计
                OrderMQMsg orderMQMsg = new Gson().fromJson(new String(message.getBody()),
                        OrderMQMsg.class);
                if (orderMQMsg.isValid()) {
                    try {// 邀请奖励
                        redPackWinInviteService.inviteSucceedReward(orderMQMsg.getUid());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } else if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
            boolean inviteSucceedReward = false;
            Long uid = null;
            if (tag.equalsIgnoreCase(UserTopicTagEnum.userAccountBinding.name())) {// 账号绑定
                UserAccountBindingMQMsg userAccountBindingMQMsg = new Gson().fromJson(new String(message.getBody()),
                        UserAccountBindingMQMsg.class);
                Integer type = userAccountBindingMQMsg.getType();
                if (type == UserAccountBindingMQMsg.TYPE_PHONE || type == UserAccountBindingMQMsg.TYPE_TAOBAO) {
                    inviteSucceedReward = true;
                    uid = userAccountBindingMQMsg.getUid();
                }
            } else if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {// 邀请成功
                UserInviteMQMsg userInviteMQMsg = new Gson().fromJson(new String(message.getBody()),
                        UserInviteMQMsg.class);
                inviteSucceedReward = true;
                uid = userInviteMQMsg.getWorkerId();
            } else if (tag.equalsIgnoreCase(UserTopicTagEnum.integralTaskFinish.name())) {// 金币任务完成
                IntegralTaskMQMsg integralTaskMQMsg = new Gson().fromJson(new String(message.getBody()),
                        IntegralTaskMQMsg.class);
                inviteSucceedReward = true;
                uid = integralTaskMQMsg.getUid();
            }
            if (inviteSucceedReward ) {
                try {// 邀请奖励
                    redPackWinInviteService.inviteSucceedReward(uid);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return Action.CommitMessage;
    }