yujian
2019-08-27 d8359ddb48dab5cc797a9d552e11fde571f4920c
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -7,8 +7,11 @@
import com.google.gson.Gson;
import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherExchangeContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherTaoLiJinContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail.MsgTypeAccountTypeEnum;
import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
@@ -20,6 +23,7 @@
import com.yeshi.fanli.entity.bus.user.Extract;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.account.UserUtil;
@@ -27,6 +31,7 @@
import com.yeshi.fanli.vo.msg.CommonMsgItemVO;
import com.yeshi.fanli.vo.msg.UserMsgVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class UserMsgVOFactory {
@@ -56,6 +61,13 @@
      List<CommonMsgItemVO> items = new ArrayList<>();
      List<ClientTextStyleVO> contentList = new ArrayList<>();
      if (msg.getType() == MsgTypeOrderTypeEnum.found) {
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO("订单找回", COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("类别", COLOR_TITLE), contentList));
@@ -78,8 +90,20 @@
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("找回金额", COLOR_TITLE), contentList));
      } else {
         contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单号", COLOR_TITLE), contentList,true));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         String orderId = msg.getOrderId();
         MsgTypeOrderTypeEnum type = msg.getType();
         if (type == MsgTypeOrderTypeEnum.invite || type == MsgTypeOrderTypeEnum.share) {
            orderId = UserUtil.filterOrderId(orderId);
         }
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(orderId, COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单号", COLOR_TITLE), contentList, true));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO("共", COLOR_CONTENT));
@@ -213,7 +237,7 @@
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("提现金额", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO("¥验证成功", COLOR_HIGHLIGHT_CONTENT));
         contentList.add(new ClientTextStyleVO("验证成功", COLOR_HIGHLIGHT_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("验证状态", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
@@ -228,6 +252,12 @@
         return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_extract.png", "提现账号验证",
               msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.fanli) {
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         // 返利到账
         contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("返利订单", COLOR_TITLE), contentList));
@@ -256,6 +286,12 @@
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.invite || msg.getMsgType() == MsgTypeMoneyTypeEnum.share) {
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         // 邀请奖金,分享奖金
         contentList.add(new ClientTextStyleVO(msg.getOrderCount() + "", COLOR_CONTENT));
@@ -295,6 +331,12 @@
                  msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.fanliWeiQuan) {
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("返利订单", COLOR_TITLE), contentList));
@@ -318,6 +360,13 @@
         return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_fanli.png", msg.getMsgType().getDesc(),
               msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.shareWeiQuan) {
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("邀请订单", COLOR_TITLE), contentList));
@@ -342,6 +391,12 @@
               msg.getMsgType().getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
               items);
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.inviteWeiQuan) {
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("邀请订单", COLOR_TITLE), contentList));
@@ -366,6 +421,12 @@
               msg.getMsgType().getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
               items);
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.orderReward) {// 奖励订单
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("奖励订单", COLOR_TITLE), contentList));
@@ -385,13 +446,13 @@
         return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_order_reward.png",
               msg.getMsgType().getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
               items);
      }else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.systemEqualize ) {// 奖励订单
      } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.systemEqualize) {// 系统补偿
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getMoney()) + "", COLOR_HIGHLIGHT_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("补齐金额", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(msg.getOrderId()+ "", COLOR_CONTENT));
         contentList.add(new ClientTextStyleVO(msg.getOrderId() + "", COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("补齐原因", COLOR_TITLE), contentList));
         contentList = new ArrayList<>();
@@ -421,7 +482,7 @@
      List<CommonMsgItemVO> items = new ArrayList<>();
      List<ClientTextStyleVO> contentList = new ArrayList<>();
      contentList.add(new ClientTextStyleVO(msg.getType().getDesc() + "", COLOR_CONTENT));
      contentList.add(new ClientTextStyleVO(msg.getTitle() + "", COLOR_CONTENT));
      items.add(new CommonMsgItemVO(new ClientTextStyleVO("事项", COLOR_TITLE), contentList));
      // 状态修改
@@ -430,24 +491,36 @@
      int fromIndex = 0;
      int toIndex = 0;
      String stateDesc = msg.getContent();
      while (stateDesc.indexOf("<highlight>") > -1) {
         fromIndex = stateDesc.indexOf("<highlight>");
         toIndex = stateDesc.indexOf("</highlight>");
         String content1 = stateDesc.substring(0, fromIndex);
         String content2 = stateDesc.substring(fromIndex + "<highlight>".length(), toIndex);
         stateDesc = stateDesc.substring(toIndex + "</highlight>".length(), stateDesc.length());
      if (msg.getType() == MsgTypeAccountTypeEnum.taoBaoAuthFail) {// 淘宝授权失败
         JSONArray array = JSONArray.fromObject(stateDesc);
         for (int i = 0; i < array.size(); i++) {
            String name = array.optJSONObject(i).optString("name");
            String content = array.optJSONObject(i).optString("content");
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(content, i > 0 ? COLOR_HIGHLIGHT_CONTENT : COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO(name, COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(content1)) {
            contentList.add(new ClientTextStyleVO(content1, COLOR_CONTENT));
      } else {
         while (stateDesc.indexOf("<highlight>") > -1) {
            fromIndex = stateDesc.indexOf("<highlight>");
            toIndex = stateDesc.indexOf("</highlight>");
            String content1 = stateDesc.substring(0, fromIndex);
            String content2 = stateDesc.substring(fromIndex + "<highlight>".length(), toIndex);
            stateDesc = stateDesc.substring(toIndex + "</highlight>".length(), stateDesc.length());
            if (!StringUtil.isNullOrEmpty(content1)) {
               contentList.add(new ClientTextStyleVO(content1, COLOR_CONTENT));
            }
            if (!StringUtil.isNullOrEmpty(content2)) {
               contentList.add(new ClientTextStyleVO(content2, COLOR_HIGHLIGHT_CONTENT));
            }
         }
         if (!StringUtil.isNullOrEmpty(content2)) {
            contentList.add(new ClientTextStyleVO(content2, COLOR_HIGHLIGHT_CONTENT));
         if (!StringUtil.isNullOrEmpty(stateDesc)) {
            contentList.add(new ClientTextStyleVO(stateDesc, COLOR_CONTENT));
         }
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList));
      }
      if (!StringUtil.isNullOrEmpty(stateDesc)) {
         contentList.add(new ClientTextStyleVO(stateDesc, COLOR_CONTENT));
      }
      items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList));
      contentList = new ArrayList<>();
      contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu() + "",
@@ -553,7 +626,15 @@
         if (dto.getLeftDay() != null) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getLeftDay() + "", COLOR_HIGHLIGHT_CONTENT));
            contentList.add(new ClientTextStyleVO("天", COLOR_CONTENT));
            if (msg.getType() == MsgTypeOtherTypeEnum.couponReward) {
               contentList.add(new ClientTextStyleVO("天(未使用将会过期)", COLOR_CONTENT));
            } else if (msg.getType() == MsgTypeOtherTypeEnum.couponMianDan) {
               contentList.add(new ClientTextStyleVO("天(未使用将会过期)", COLOR_CONTENT));
            } else {
               contentList.add(new ClientTextStyleVO("天", COLOR_CONTENT));
            }
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("剩余天数", COLOR_TITLE), contentList));
         }
@@ -587,7 +668,7 @@
            contentList.add(new ClientTextStyleVO(dto.getSource() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("来源", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getTimeDesc())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getTimeDesc() + "", COLOR_CONTENT));
@@ -601,24 +682,118 @@
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("面额", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getReason())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getReason() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("原因", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getResult())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getResult() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("结果", COLOR_TITLE), contentList));
         }
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
               COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
      } else if (msg.getType() == MsgTypeOtherTypeEnum.give) {
         if (StringUtil.isNullOrEmpty(msg.getContent()))
            return null;
         MsgOtherGiveContentDTO dto = new Gson().fromJson(msg.getContent(), MsgOtherGiveContentDTO.class);
         if (dto == null)
            return null;
         String type = dto.getType();
         if (type == null)
            return null;
         if (MsgOtherGiveContentDTO.TYEP_COUPON.equalsIgnoreCase(type)) {
            icon = "http://img.flqapp.com/resource/msg/icon_msg_other_coupon.png";
         } else {
            icon = "http://img.flqapp.com/resource/msg/icon_msg_other_tlj.png";
         }
         List<ClientTextStyleVO> contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(dto.getGiveType(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送类别", COLOR_TITLE), contentList));
         if (!StringUtil.isNullOrEmpty(dto.getReceiveInfo())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getReceiveInfo() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("领取用户", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getGiveTime())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getGiveTime() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送时间", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getReceiveTime())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getReceiveTime() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("领取时间", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getReturnTime())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getReturnTime() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("退回时间", COLOR_TITLE), contentList));
         }
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
               COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
         UserMsgVO userMsgVO = new UserMsgVO();
         userMsgVO.setIcon(icon);
         userMsgVO.setTitle(dto.getTitle());
         userMsgVO.setTime(msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime());
         userMsgVO.setContentItems(items);
         return userMsgVO;
      } else if (msg.getType() == MsgTypeOtherTypeEnum.exchange) {
         if (StringUtil.isNullOrEmpty(msg.getContent()))
            return null;
         MsgOtherExchangeContentDTO dto = new Gson().fromJson(msg.getContent(), MsgOtherExchangeContentDTO.class);
         if (dto == null)
            return null;
         icon = "http://img.flqapp.com/resource/msg/icon_msg_other_integral.png";
         List<ClientTextStyleVO> contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(dto.getState(), COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList));
         if (!StringUtil.isNullOrEmpty(dto.getExpend())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getExpend() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("消耗", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getTotalGold())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getTotalGold() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("剩余", COLOR_TITLE), contentList));
         }
         if (!StringUtil.isNullOrEmpty(dto.getThing())) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getThing() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("兑换物品", COLOR_TITLE), contentList));
         }
         contentList = new ArrayList<>();
         contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
               COLOR_CONTENT));
         items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
      }
      return new UserMsgVO(icon, msg.getType().getDesc(),