yujian
2019-09-03 972d3bc71115ec977dccf835fbcd148da3bcc86c
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
@@ -2,6 +2,7 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@@ -17,11 +18,13 @@
import com.yeshi.fanli.dao.mybatis.homemodule.SpecialMapper;
import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.homemodule.SpecialException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.homemodule.SpecialCardService;
import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
@@ -49,6 +52,10 @@
   @Resource
   private ConfigService configService;
   @Resource
   private AppVersionService appVersionService;
   @Override
   public Special selectByPrimaryKey(Long id) {
@@ -72,6 +79,26 @@
      Integer sex = record.getSex();
      if (sex == null) {
         throw new SpecialException(1, "性别不能为空");
      }
      String version = record.getVersion();
      Integer platformCode = record.getPlatform();
      if (!StringUtil.isNullOrEmpty(version) && platformCode != null) {
         String platform = "android";
         if (platformCode == 2)
            platform = "ios";
         AppVersionInfo versionInfo = appVersionService.getByPlatformAndVersion(platform, version);
         if (versionInfo == null)
            throw new SpecialException(1, "版本号信息缺失");
         record.setVersionCode(versionInfo.getVersionCode());
         record.setPlatform(platformCode);
      } else {
         if (!StringUtil.isNullOrEmpty(version))
            throw new SpecialException(1, "平台类型不能为空");
         if (platformCode != null)
            throw new SpecialException(1, "版本号不能为空");
      }
      String params = record.getParams();
@@ -365,6 +392,13 @@
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listByVersion-'+#start+'-'+#count+'-'+#card+'-'+#platform+'-'+#versionCode")
   public List<Special> listByVersion(long start, int count, String card, Integer platform, Integer versionCode) {
      return specialMapper.listByVersion(start, count, card, platform, versionCode);
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex")
   public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception {
@@ -390,9 +424,10 @@
         }
      }
      int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
      // 处理9.9包邮
      if (listArc != null && VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())
            && !Constant.IS_TEST)
      if (listArc != null && VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion()))
         for (Special s : listArc) {
            if (s.getName().contains("9.9")) {// 9块9
               s.setJumpDetail(jumpDetailV2Service.getByTypeCache("common_template"));
@@ -400,6 +435,16 @@
               params.put("key", CommonContentTypeEnum._9k9.name());
               params.put("title", CommonContentTypeEnum._9k9.getDesc());
               s.setParams(params.toString());
            } else if (s.getName().contains("自购立减")) {
               if (hour < 6) {// 0-6点之间不进入自购立减的页面
                  s.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
                  JSONObject params = new JSONObject();
                  params.put("url", configService.get("tlj_own_buy_nogoods"));
                  s.setParams(params.toString());
               } else {
                  s.setJumpDetail(jumpDetailV2Service.getByTypeCache("tlj_own_buy"));
                  s.setParams(null);
               }
            }
         }