admin
2020-07-03 651a15c78f668bef3859d9ed1bb7ad0b669d3600
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
@@ -12,7 +12,10 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.util.*;
import org.apache.commons.beanutils.PropertyUtils;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -42,10 +45,6 @@
import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
import com.yeshi.fanli.service.inter.homemodule.SpecialService;
import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.vo.homemodule.SpecialVO;
import net.sf.json.JSONObject;
@@ -55,12 +54,6 @@
   @Resource
   private SpecialMapper specialMapper;
   @Resource
   private SpecialPlaceService specialPlaceService;
   @Resource
   private SpecialCardService specialCardService;
   @Resource
   private CommonShareInfoService commonShareInfoService;
@@ -286,8 +279,7 @@
   /**
    * 删除图片-不更新数据库
    *
    * @param record
    * @param picture
    * @throws Exception
    */
   public void removePicture(String picture) throws Exception {
@@ -484,25 +476,11 @@
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listBySystemAndCard-'+#card+'-'+#systemId")
   public List<SpecialVO> listBySystemAndCard(String card, Long systemId) {
      List<Special> specialList = specialMapper.listBySystemAndCard(card, systemId);
      return transformVO(specialList);
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listPageBySystemAndCard-'+#start+'-'+#count+'-'+#card+'-'+#systemId")
   public List<SpecialVO> listPageBySystemAndCard(long start, int count, String card, Long systemId) {
      List<Special> specialList = specialMapper.listPageBySystemAndCard(start, count, card, systemId);
      return transformVO(specialList);
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listByVersion-'+#start+'-'+#count+'-'+#card+'-'+#platform+'-'+#versionCode")
   public List<SpecialVO> listByVersion(long start, int count, String card, String platform, Integer versionCode) {
      List<Special> specialList = specialMapper.listByPlaceKey(card, null, null, null);
      filterSpecial(specialList, platform, versionCode);
      return transformVO(specialList);
   @Cacheable(value = "specialCache", key = "'listByVersion-'+#start+'-'+#count+'-'+#card+'-'+#platform+'-'+#versionCode+'-'+#system")
   public List<SpecialVO> listByVersion(long start, int count, String card, String platform, Integer versionCode,SystemEnum system) {
      List<Special> specialList = specialMapper.listByPlaceKey(card, null, null, null, system);
      filterSpecial(specialList, platform, versionCode,system);
      return transformVO(specialList,system);
   }
   /**
@@ -512,10 +490,10 @@
    * @param platform
    * @param versionCode
    */
   private void filterSpecial(List<Special> list, String platform, int versionCode) {
   private void filterSpecial(List<Special> list, String platform, int versionCode,SystemEnum system) {
      if (list == null || list.size() == 0)
         return;
      AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
      AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode,system);
      if (app == null) {
         list.clear();
         return;
@@ -537,8 +515,8 @@
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex")
   public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception {
   @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex+'-'+#system")
   public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex,SystemEnum system) throws Exception {
      // 首页-5圆形2排区域
      JSONObject arcMap = new JSONObject();
@@ -557,8 +535,8 @@
      int platformCode = Constant.getPlatformCode(platform);
      int version = Integer.parseInt(acceptData.getVersion());
      List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version);
      filterSpecial(listArc, platform, version);
      List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version,system);
      filterSpecial(listArc, platform, version,system);
      if (listArc == null) {
         listArc = new ArrayList<Special>();
      } else if (listArc.size() > 0) {
@@ -584,7 +562,7 @@
               if (hour < 6) {// 0-6点之间不进入自购立减的页面
                  s.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
                  JSONObject params = new JSONObject();
                  params.put("url", configService.get(ConfigKeyEnum.tljOwnBuyNogoods.getKey()));
                  params.put("url", configService.getValue(ConfigKeyEnum.tljOwnBuyNogoods.getKey(), SystemInfoUtil.getSystem(acceptData)));
                  s.setParams(params.toString());
               } else {
                  // 查询专题详情
@@ -603,19 +581,19 @@
      // 数据处理
//      handlelist(listArc);
      arcMap.put("list", JsonUtil.getApiCommonGson().toJson(transformVO(listArc)));
      arcMap.put("list", JsonUtil.getApiCommonGson().toJson(transformVO(listArc,SystemInfoUtil.getSystem(acceptData))));
      // 首页-活动区域(女王节)
      JSONObject activityMap = new JSONObject();
      List<Special> listActivity = null;
      if ("ios".equalsIgnoreCase(acceptData.getPlatform())
            && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
            && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), SystemInfoUtil.getSystem(acceptData))) {
         // 如果IOS当前版本处于审核状态就不返回
      } else {
         listActivity = specialMapper.listByPlaceKey("index_activity", null, platformCode, version);
         listActivity = specialMapper.listByPlaceKey("index_activity", null, platformCode, version,system);
      }
      filterSpecial(listActivity, platform, version);
      filterSpecial(listActivity, platform, version,system);
      if (listActivity == null) {
         listActivity = new ArrayList<Special>();
@@ -629,7 +607,7 @@
      handlelist(listActivity);
      activityMap.put("list", JsonUtil.getApiCommonGson().toJson(transformVO(listActivity)));
      activityMap.put("list", JsonUtil.getApiCommonGson().toJson(transformVO(listActivity,system)));
      // 首页-方形专题(品牌券、母婴...)
      String indexBlock = "index_block";
@@ -637,8 +615,8 @@
         indexBlock = "index_block_1.5.6";
      JSONObject blockJsonMap = new JSONObject();
      List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex, platformCode, version);
      filterSpecial(listBlock, platform, version);
      List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex, platformCode, version,system);
      filterSpecial(listBlock, platform, version,system);
      if (listBlock == null) {
         listBlock = new ArrayList<Special>();
      } else if (listBlock.size() > 0) {
@@ -662,7 +640,7 @@
      // 数据处理
      handlelist(listBlock);
      blockJsonMap.put("list", JsonUtil.getApiCommonGson().toJson(transformVO(listBlock)));
      blockJsonMap.put("list", JsonUtil.getApiCommonGson().toJson(transformVO(listBlock,system)));
      JSONObject root = new JSONObject();
      root.put("arcArea", arcMap);
@@ -672,28 +650,28 @@
   }
   @Override
   public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode) {
      return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode);
   public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode,SystemEnum system) {
      return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode,system);
   }
   @Override
   public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform,
         Integer versionCode) {
      return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode);
         Integer versionCode,SystemEnum system) {
      return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode,system);
   }
   @Override
   public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode) {
      return specialMapper.countByPlaceKeyList(list, null, platform, versionCode);
   public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode,SystemEnum system) {
      return specialMapper.countByPlaceKeyList(list, null, platform, versionCode,system);
   }
   @Override
   @Cacheable(value = "specialCache", key = "'listByPlaceKeyHasLabel'+#start+'-'+#platform+'-'+#versionCode+'-'+#list")
   public List<SpecialVO> listByPlaceKeyHasLabel(long start, int count, List<String> list, Integer platform,
         Integer versionCode) {
         Integer versionCode,SystemEnum system) {
      List<Special> listSpecial =  specialMapper.listByPlaceKeyHasLabel(start, count, list, null,
            platform, versionCode);
      return    transformVO(listSpecial);
            platform, versionCode,system);
      return    transformVO(listSpecial,system);
   }
   
   
@@ -702,7 +680,7 @@
    * @param list
    * @return
    */
   private List<SpecialVO> transformVO(List<Special> list) {
   private List<SpecialVO> transformVO(List<Special> list, SystemEnum system) {
      List<SpecialVO> listVo = new ArrayList<SpecialVO>();
      if (list != null && list.size() > 0) {
         for (Special special: list) {
@@ -718,7 +696,7 @@
            CommonShareInfo info = commonShareInfoService.getByPidAndType(specialVO.getId(), 
                  CommonShareInfoEnum.special.name());
            if (info != null && !StringUtil.isNullOrEmpty(info.getComment())) {
               String link = configService.get(ConfigKeyEnum.activityDetailLink.getKey()) + "?type=%s&id=%s";
               String link = configService.getValue(ConfigKeyEnum.activityDetailLink.getKey(),system) + "?type=%s&id=%s";
               link = String.format(link, CommonShareInfoEnum.special.name(),specialVO.getId());
               
               // 跳转链接