admin
2020-07-07 c9cbad5f5d18c6b2ac5a063e41007933d7028329
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserVIPMessageListener.java
@@ -2,6 +2,10 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.SystemInfoUtil;
import org.springframework.stereotype.Component;
import com.aliyun.openservices.ons.api.Action;
@@ -31,7 +35,6 @@
 * 用户超级会员
 * 
 * @author Administrator
 *
 */
@Component
public class UserVIPMessageListener implements MessageListener {
@@ -50,6 +53,9 @@
   @Resource
   private UserActiveLogService userActiveLogService;
    @Resource
    private UserInfoService userInfoService;
   
   @Override
@@ -70,6 +76,12 @@
         if (tag.equalsIgnoreCase(UserTopicTagEnum.userLevelChanged.name())) {// 用户等级发生变化
            UserLevelChangedMQMsg msg = new Gson().fromJson(new String(message.getBody()),
                  UserLevelChangedMQMsg.class);
                //判断系统是否有三级分销功能
                Long sourceUid = msg.getUid();
                SystemEnum system = userInfoService.getUserSystem(sourceUid);
                if (!SystemInfoUtil.hasFunctions(system, SystemFunction.threeSale, SystemFunction.vip))
                    return Action.CommitMessage;
            for (Long fuid : Constant.NO_UPGRADE_UIDS) {// 禁止不能升级的用户升级
               if (msg.getUid().longValue() == fuid)
@@ -95,14 +107,17 @@
         if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
            OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
                  OrderMoneyRecievedMQMsg.class);
            if (dto != null) {
                    SystemEnum system = userInfoService.getUserSystem(dto.getUid());
                    if (!SystemInfoUtil.hasFunctions(system, SystemFunction.vip))
                        return Action.CommitMessage;
               for (Long fuid : Constant.NO_UPGRADE_UIDS) {// 禁止不能升级的用户升级
                  if (dto.getUid().longValue() == fuid)
                     return Action.CommitMessage;
               }
               // 判断版本
               UserActiveLog log = userActiveLogService.getUserLatestActiveInfo(dto.getUid());
               if (log == null || !VersionUtil.greaterThan_2_1(
                     "appstore".equalsIgnoreCase(log.getChannel()) ? "ios" : "android", log.getVersionCode())) {
                  return Action.CommitMessage;
@@ -116,9 +131,13 @@
                  userVIPPreInfoService.upgradeVipByMyOrder(dto.getUid());
               }
            }
         } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderConfirm.name())) {
            OrderConfirmMQMsg dto = new Gson().fromJson(new String(message.getBody()), OrderConfirmMQMsg.class);
            if (dto != null) {
                    SystemEnum system = userInfoService.getUserSystem(dto.getSourceUid());
                    if (!SystemInfoUtil.hasFunctions(system, SystemFunction.vip))
                        return Action.CommitMessage;
               for (Long fuid : Constant.NO_UPGRADE_UIDS) {// 禁止不能升级的用户升级
                  if (dto.getSourceUid().longValue() == fuid)
                     return Action.CommitMessage;