admin
2020-02-23 b59fef5c00b15fdfdfa9d4be26e5bf6b41c75458
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java
@@ -1,6 +1,8 @@
package com.yeshi.fanli.controller.client.v1;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
@@ -12,27 +14,33 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
import com.yeshi.fanli.entity.bus.tlj.DeviceTaoLiJinRecord;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin.TaoLiJinOriginEnum;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.config.AppHomeFloatImg;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.tlj.DeviceTaoLiJinRecordService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.notify.UserActivedRecordService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.vo.user.UserDialogBtnVO;
import com.yeshi.fanli.vo.user.UserDialogVO;
import net.sf.json.JSONObject;
@@ -71,10 +79,16 @@
   private UserTaoLiJinOriginService uerTaoLiJinOriginService;
   @Resource
   private DeviceTaoLiJinRecordService deviceTaoLiJinRecordService;
   private UserActiveLogService userActiveLogService;
   @Resource
   private UserActiveLogService userActiveLogService;
   private SwiperPictureService swiperPictureService;
   @Resource
   private UserActivedRecordService userActivedRecordService;
   @Resource
   private UserInfoService userInfoService;
   /**
    * s 首页配置信息
@@ -102,29 +116,9 @@
         data.put("floatNotifyImg", notifyImg);
      }
      FloatAD floatAD = null;
      if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) {
         if (uid == null) {
            DeviceTaoLiJinRecord deviceRecord = deviceTaoLiJinRecordService.getByDevice(acceptData.getDevice());
            if (deviceRecord == null) {
               floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 1);
            }
         } else {
            UserTaoLiJinOrigin userTaoLiJin = uerTaoLiJinOriginService.getByUidAndOrigin(uid,
                  TaoLiJinOriginEnum.newbiesWin.name());
            if (userTaoLiJin == null) {
               floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 1);
            }
         }
      }
      // 无新人弹框 则查询默认
      if (floatAD == null) {
         floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 0);
      }
      if (floatAD != null) {
      FloatAD floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 0);
      if (floatAD != null && floatAD.getTypeEnum() != FloatADTypeEnum.newUserRedPack) {
         JSONObject detail = new JSONObject();
         detail.put("img", floatAD.getPicture());
         detail.put("jumpDetail", floatAD.getJumpDetail());
@@ -135,13 +129,13 @@
      }
      // 领券帮助链接,1.5.2后生效
      String couponHelp = configService.get("taobao_coupon_help");
      String couponHelp = configService.get(ConfigKeyEnum.taobaoCouponHelp.getKey());
      data.put("couponHelpUrl", couponHelp);
      // 底部网页链接
      String platform = acceptData.getPlatform();
      if ("android".equalsIgnoreCase(platform)) {
         data.put("htmlLink", configService.get("index_html_link_android"));
         data.put("htmlLink", configService.get(ConfigKeyEnum.indexHtmlLinkAndroid.getKey()));
      }
      // 判断新老用户
@@ -154,7 +148,8 @@
      } else {// 老人
         data.put("userTimeType", 1);
      }
      data.put("hotFuctionLink", configService.get("hot_function_url"));
      data.put("hotFuctionLink", configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform,
            Integer.parseInt(acceptData.getVersion())));//
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -167,25 +162,7 @@
    */
   @RequestMapping(value = "getMSGConfig", method = RequestMethod.POST)
   public void getMSGConfig(AcceptData acceptData, Long uid, PrintWriter out) {
      JSONObject data = new JSONObject();
      boolean show = false;
      if (uid != null) {
         show = uerTaoLiJinOriginService.hasRankHongBao(uid);
      }
      if (show) {
         FloatAD floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_MSGCENTER, null);
         if (floatAD != null) {
            JSONObject detail = new JSONObject();
            detail.put("img", floatAD.getPicture());
            detail.put("jumpDetail", floatAD.getJumpDetail());
            detail.put("params", floatAD.getParams());
            detail.put("showTime", floatAD.getShowMode());
            detail.put("accountLogin", floatAD.isJumpNeedLogin());
            data.put("floatImgDetail", detail);
         }
      }
      out.print(JsonUtil.loadTrueResult(data));
      out.print(JsonUtil.loadFalseResult("推广红包相关功能已下线!"));
   }
   @RequestMapping(value = "getTaoBaoCartConfig", method = RequestMethod.POST)
@@ -196,7 +173,8 @@
      }
      // 是否需要购物城转链
      boolean convert = "0".equalsIgnoreCase(configService.get("show_taobao_cart_convert")) ? false : true;
      boolean convert = "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.showTaobaoCartConvert.getKey())) ? false
            : true;
      if (!"cart".equalsIgnoreCase(position) && !convert) {
         out.print(JsonUtil.loadFalseResult(""));
@@ -210,8 +188,8 @@
         clientTBPid = tbPidService.getAndroidDefault();
      }
      String cartJS = configService.get("taobao_cart_js");
      String cartUrl = configService.get("taobao_cart_link");
      String cartJS = configService.get(ConfigKeyEnum.taobaoCartJS.getKey());
      String cartUrl = configService.get(ConfigKeyEnum.taobaoCartLink.getKey());
      if (!convert)// 不转链
      {
         cartUrl = "http://";
@@ -263,27 +241,103 @@
   @RequestMapping(value = "getBindAccountConfig", method = RequestMethod.POST)
   public void getBindAccountConfig(AcceptData acceptData, PrintWriter out) {
      String alipayHelpUrl = configService.get("alipay_help");// 支付宝帮助
      String alipayBindFailUrl = configService.get("alipay_bind_fail_reason");// 支付宝绑定失败原因
      String alipayHelpUrl = configService.get(ConfigKeyEnum.alipayHelp.getKey());// 支付宝帮助
      String alipayBindFailUrl = configService.get(ConfigKeyEnum.alipayBindFailReason.getKey());// 支付宝绑定失败原因
      JSONObject data = new JSONObject();
      data.put("alipayHelp", alipayHelpUrl);
      data.put("alipayBindFailReason", alipayBindFailUrl);
      out.print(JsonUtil.loadTrueResult(data));
   }
   /**
    * 关闭提醒
    *
    * @param acceptData
    * @param uid
    * @param id
    * @param type
    *            0-关闭 1-点击右边按钮 2-点击左边按钮
    * @param out
    */
   @RequestMapping(value = "closeDialogNotify", method = RequestMethod.POST)
   public void closeDialogNotify(AcceptData acceptData, Long uid, String id, int type, PrintWriter out) {
      if (uid == null) {
         out.print(JsonUtil.loadFalseResult("用户未登录"));
         return;
      }
      if (StringUtil.isNullOrEmpty(id)) {
         out.print(JsonUtil.loadFalseResult("id为空"));
         return;
      }
      if (id.equalsIgnoreCase("tearcherNotify")) {
         userActivedRecordService.setTearcherNotified(uid);
         out.print(JsonUtil.loadTrueResult(""));
      } else {
         out.print(JsonUtil.loadFalseResult("id不存在"));
      }
   }
   @RequestMapping(value = "getUserConfig", method = RequestMethod.POST)
   public void getUserConfig(AcceptData acceptData, PrintWriter out) {
   public void getUserConfig(AcceptData acceptData, Long uid, PrintWriter out) {
      try {
         // 用户协议链接
         String serviceProtocol = configService.get("service_protocol_link");
         String serviceProtocol = configService.get(ConfigKeyEnum.serviceProtocolLink.getKey());
         // 隐私条款链接
         String privacyProtocol = configService.get("privacy_protocol_link");
         String privacyProtocol = configService.get(ConfigKeyEnum.privacyProtocolLink.getKey());
         JSONObject data = new JSONObject();
         data.put("serviceProtocolLink", serviceProtocol);
         data.put("privacyProtocolLink", privacyProtocol);
         // 购物车跳转方式(包含jumpDetail与params)
         JSONObject source = JSONObject.fromObject(configService.get("taobao_cart_jump_detail"));
         JSONObject source = JSONObject
               .fromObject(configService.getByVersion(ConfigKeyEnum.taobaoCartJumpDetail.getKey(),
                     acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion())));
         data.put("taoBaoCart", source);
         if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
            // 我的界面banner
            List<SwiperPicture> banner = swiperPictureService.getByBannerCardAndVersion("my_interface_banner",
                  acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (banner == null)
               banner = new ArrayList<SwiperPicture>();
            data.put("banner", JsonUtil.getApiCommonGson().toJson(banner));
         }
         if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) {
            // 转链的网页链接
            String convertLinkUrl = configService.get(ConfigKeyEnum.convertDocWebLink.getKey());
            data.put("convertLinkUrl", convertLinkUrl);
            if (uid != null) {
               String tearcherLink = configService.getByVersion(ConfigKeyEnum.tearcherLink.getKey(),
                     acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
               if (userActivedRecordService.canNotifyAddTearcher(uid)) {
                  UserInfo userInfo = userInfoService.selectAvailableByPrimaryKey(uid);
                  if (userInfo != null) {
                     JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web",
                           Constant.getPlatformCode(acceptData.getPlatform()),
                           Integer.parseInt(acceptData.getVersion()));
                     JSONObject negativeParams = new JSONObject();
                     negativeParams.put("url", configService.getByVersion(ConfigKeyEnum.newerGonglue.getKey(),
                           acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion())));
                     JSONObject positiveParams = new JSONObject();
                     positiveParams.put("url", tearcherLink);
                     UserDialogVO dialog = new UserDialogVO("tearcherNotify", true,
                           "HI," + userInfo.getNickName(),
                           "我是你的导师,为你在省赚过程中解难答疑,对你一对一辅导,倾听你的需求总结并反馈给板栗快省官方运营团队,快来添加我吧。",
                           new UserDialogBtnVO("复制导师微信", jumpDetail, positiveParams),
                           new UserDialogBtnVO("去新手攻略", jumpDetail, negativeParams));
                     data.put("dialog", dialog);
                  }
               }
               data.put("tearcherLink", tearcherLink);
            }
         }
         out.print(JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         out.print(JsonUtil.loadFalseResult("获取失败"));
@@ -301,10 +355,10 @@
   @RequestMapping(value = "getOrderParseConfig", method = RequestMethod.POST)
   public void getOrderParseConfig(AcceptData acceptData, PrintWriter out) {
      if ("0".equalsIgnoreCase(configService.get("auto_find_taobao_order")))
      if ("0".equalsIgnoreCase(configService.get(ConfigKeyEnum.autoFindTaobaoOrder.getKey())))
         out.print(JsonUtil.loadFalseResult(1, "暂不支持"));
      else {
         String orderJS = configService.get("taobao_order_parse_js");
         String orderJS = configService.get(ConfigKeyEnum.taobaoOrderParseJS.getKey());
         JSONObject data = new JSONObject();
         try {
            data.put("orderJS", DESUtil.encode(orderJS, StringUtil.getBase64String("YeShiFANLI889*+"),
@@ -330,7 +384,8 @@
   public void getOrderConfig(AcceptData acceptData, PrintWriter out) {
      JSONObject data = new JSONObject();
      // 测试
      data.put("showTaoBaoOrder", "0".equalsIgnoreCase(configService.get("show_taobao_order").trim()) ? false : true);
      data.put("showTaoBaoOrder",
            "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.showTaobaoOrder.getKey()).trim()) ? false : true);
      data.put("taoBaoOrderUrl", "https://main.m.taobao.com/olist/index.html");
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -338,7 +393,7 @@
   @RequestMapping(value = "getKeFuConfig", method = RequestMethod.POST)
   public void getKeFuConfig(AcceptData acceptData, PrintWriter out) {
      JSONObject data = new JSONObject();
      data.put("meiqia", "1".equalsIgnoreCase(configService.get("kefu_meiqia")) ? true : false);// 是否跳转美洽,不跳转美洽就用原来的
      data.put("meiqia", "1".equalsIgnoreCase(configService.get(ConfigKeyEnum.kefuMeiqia.getKey())) ? true : false);// 是否跳转美洽,不跳转美洽就用原来的
      out.print(JsonUtil.loadTrueResult(data));
      // 设置消息已读
      ThreadUtil.run(new Runnable() {
@@ -359,7 +414,7 @@
   @RequestMapping(value = "getInviteCodeInputHelp", method = RequestMethod.POST)
   public void getInviteCodeInputHelp(AcceptData acceptData, PrintWriter out) {
      JSONObject data = new JSONObject();
      data.put("helpUrl", configService.get("invite_code_input_help"));
      data.put("helpUrl", configService.get(ConfigKeyEnum.inviteCodeInputHelp.getKey()));
      out.print(JsonUtil.loadTrueResult(data));
   }