yujian
2020-01-08 81ed418ee16df24b768a3f78cd22d02f020d6314
小黄条+ 首页弹框 版本区分
9个文件已修改
468 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/FloatADAdminController.java 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/AdActivityVersionControl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/help/AppPageNotificationServiceImpl.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/help/AppPageNotificationService.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/FloatADService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/AppPageNotificationAdminController.java
@@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
@@ -15,13 +16,20 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.help.AppPageNotification;
import com.yeshi.fanli.entity.bus.help.AppPageNotification.AppPageNotificationTypeEnum;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.help.AppPageNotificationService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
@@ -30,6 +38,12 @@
    @Resource
    private AppPageNotificationService appPageNotificationService;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AdActivityVersionControlService adActivityVersionControlService;
    
    
    /**
@@ -198,15 +212,13 @@
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key,
             Integer show, Integer canClose, PrintWriter out) {
             Integer show, Integer canClose,String version, String platform,  PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        pageSize =Integer.MAX_VALUE;
        try {
            List<AppPageNotification> list = appPageNotificationService.listQuery((pageIndex - 1) * pageSize, 
@@ -238,8 +250,46 @@
                }
            }
            
            long count = appPageNotificationService.countQuery(key, show, canClose);
            List<AppVersionInfo> versionList = null;
            if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
                versionList = new ArrayList<>();
                if (!StringUtil.isNullOrEmpty(version)) {
                    AppVersionInfo appVersion = appVersionService.selectByPrimaryKey(Long.parseLong(version));
                    if (appVersion != null)
                        versionList.add(appVersion);
                } else {
                    List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
                    if (appVersionList != null) {
                        versionList.addAll(appVersionList);
                    }
                }
            }
            // 过滤
            if (versionList != null) {
                if (versionList.size() > 0) {
                    List<Long> sourceIdList = new ArrayList<>();
                    for (AppPageNotification record : list) {
                        sourceIdList.add(record.getId());
                    }
                    List<Long> versionIdList = new ArrayList<>();
                    for (AppVersionInfo versionInfo : versionList)
                        versionIdList.add(versionInfo.getId());
                    Set<Long> sets = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                            AdActivityType.notification, versionIdList);
                    for (int i = 0; i < list.size(); i++) {
                        if (!sets.contains(list.get(i).getId())) {
                            list.remove(i--);
                        }
                    }
                    count = list.size();
                } else {
                    list.clear();
                    count = 0;
                }
            }
            
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -365,7 +415,6 @@
     */
    //@RequestMapping(value = "delete")
    public void delete(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
@@ -390,4 +439,41 @@
        }
    }
    /**
     * 设置版本
     *
     * @param callback
     * @param id
     * @param moveType
     * @param sex
     * @param out
     */
    @RequestMapping(value = "setVersions")
    public void setVersions(String callback, Long id, String versions, PrintWriter out) {
        JSONArray versionArray = JSONArray.fromObject(versions);
        List<Long> versionIds = new ArrayList<>();
        for (int i = 0; i < versionArray.size(); i++) {
            Long version = versionArray.optLong(i);
            versionIds.add(version);
        }
        try {
            appPageNotificationService.setVersions(id, versionIds);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
        }
    }
    @RequestMapping(value = "getVersions")
    public void getVersions(String callback, Long id, PrintWriter out) {
        List<AdActivityVersionControl> list = adActivityVersionControlService
                .listByTypeAndSourceId(AdActivityType.notification, id);
        List<Long> versionList = new ArrayList<>();
        if (list != null)
            for (AdActivityVersionControl control : list)
                versionList.add(control.getVersion().getId());
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(versionList));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/FloatADAdminController.java
@@ -3,6 +3,7 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -15,14 +16,21 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.exception.homemodule.FloatADException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
@@ -34,6 +42,14 @@
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AdActivityVersionControlService adActivityVersionControlService;
    /**
     * 保存信息
@@ -52,7 +68,6 @@
            }else{
                floatADervice.saveObject(null, floatAD, jumpType);
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (FloatADException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -130,15 +145,13 @@
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
            PrintWriter out) {
            String version, String platform, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        pageSize =Integer.MAX_VALUE;
        try {
            List<FloatAD> list = floatADervice.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
@@ -146,8 +159,46 @@
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            long count = floatADervice.countQuery(key, state);
            List<AppVersionInfo> versionList = null;
            if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
                versionList = new ArrayList<>();
                if (!StringUtil.isNullOrEmpty(version)) {
                    AppVersionInfo appVersion = appVersionService.selectByPrimaryKey(Long.parseLong(version));
                    if (appVersion != null)
                        versionList.add(appVersion);
                } else {
                    List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
                    if (appVersionList != null) {
                        versionList.addAll(appVersionList);
                    }
                }
            }
            // 过滤
            if (versionList != null) {
                if (versionList.size() > 0) {
                    List<Long> sourceIdList = new ArrayList<>();
                    for (FloatAD floatAD : list) {
                        sourceIdList.add(floatAD.getId());
                    }
                    List<Long> versionIdList = new ArrayList<>();
                    for (AppVersionInfo versionInfo : versionList)
                        versionIdList.add(versionInfo.getId());
                    Set<Long> sets = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                            AdActivityType.floatAD, versionIdList);
                    for (int i = 0; i < list.size(); i++) {
                        if (!sets.contains(list.get(i).getId())) {
                            list.remove(i--);
                        }
                    }
                    count = list.size();
                } else {
                    list.clear();
                    count = 0;
                }
            }
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -159,12 +210,48 @@
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 设置版本
     *
     * @param callback
     * @param id
     * @param moveType
     * @param sex
     * @param out
     */
    @RequestMapping(value = "setVersions")
    public void setVersions(String callback, Long id, String versions, PrintWriter out) {
        JSONArray versionArray = JSONArray.fromObject(versions);
        List<Long> versionIds = new ArrayList<>();
        for (int i = 0; i < versionArray.size(); i++) {
            Long version = versionArray.optLong(i);
            versionIds.add(version);
        }
        try {
            floatADervice.setVersions(id, versionIds);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
        }
    }
    @RequestMapping(value = "getVersions")
    public void getVersions(String callback, Long id, PrintWriter out) {
        List<AdActivityVersionControl> list = adActivityVersionControlService
                .listByTypeAndSourceId(AdActivityType.floatAD, id);
        List<Long> versionList = new ArrayList<>();
        if (list != null)
            for (AdActivityVersionControl control : list)
                versionList.add(control.getVersion().getId());
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(versionList));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java
@@ -43,9 +43,11 @@
            return;
        }
        AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type);
        if ("home".equalsIgnoreCase(type)
                && VersionUtil.smallerThan_1_5_1(acceptData.getPlatform(), acceptData.getVersion()) && ap != null) {
        String platform = acceptData.getPlatform();
        String version = acceptData.getVersion();
        AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type,platform, Integer.parseInt(version));
        if ("home".equalsIgnoreCase(type) && VersionUtil.smallerThan_1_5_1(platform, version) && ap != null) {
            AppPageNotification no = new AppPageNotification();
            no.setContentUrl("");
            no.setMd5("111111111111111111");
@@ -54,7 +56,7 @@
            no.setType(ap.getType());
            no.setUpdateTime(ap.getUpdateTime());
            no.setCanClose(false);
            no.setContent(String.format("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到%s最新版本",Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
            no.setContent(String.format("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到%s最新版本",Constant.getAppName(platform, version)));
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            out.print(JsonUtil.loadTrueResult(gson.toJson(no)));
            return;
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java
@@ -169,11 +169,13 @@
        if (uid != null && uid == 0L)
            uid = null;
        String platform = acceptData.getPlatform();
        String version = acceptData.getVersion();
        // 活动弹框
        List<FloatAD> listAD = new ArrayList<FloatAD>();
        List<FloatImgDetailVO> listVO = new ArrayList<FloatImgDetailVO>();
        List<FloatAD> list = floatADService.getValidByPosition(FloatAD.POSITION_INDEX);
        List<FloatAD> list = floatADService.getValidFloatADCache(FloatAD.POSITION_INDEX, null, platform,Integer.parseInt(version) );
        if (list != null && !list.isEmpty())
            listAD.addAll(list);
@@ -181,7 +183,7 @@
            FloatAD floatAD = listAD.get(i);
            FloatADTypeEnum typeEnum = floatAD.getTypeEnum();
            if (typeEnum == FloatADTypeEnum.newUserRedPack
                    && (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())
                    && (!VersionUtil.greaterThan_2_0_5(platform, version)
                            || !userTaoLiJinNewbiesService.verifyHasReward(uid, acceptData.getDevice()))) {
                listAD.remove(i);
@@ -230,9 +232,8 @@
        }
        // 是否显示热门功能按钮
        String platform = acceptData.getPlatform();
        data.put("hotFuctionLink",
                configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform, Integer.parseInt(acceptData.getVersion())));
                configService.getByVersion(ConfigKeyEnum.hotFunctionUrl.getKey(), platform, Integer.parseInt(version)));
        if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadTrueResult(data));
        else
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/AdActivityVersionControl.java
@@ -19,6 +19,8 @@
    public enum AdActivityType {
        banner,// 轮播图
        special,// 专题
        floatAD,// 悬浮图
        notification,// 小黄条
        helpClass,// 帮助中心分类
        helpCenter;// 帮助中心文档
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/help/AppPageNotificationServiceImpl.java
@@ -1,16 +1,28 @@
package com.yeshi.fanli.service.impl.help;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.help.AppPageNotificationMapper;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.help.AppPageNotification;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.help.AppPageNotificationService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.util.StringUtil;
@Service
@@ -19,17 +31,46 @@
    @Resource
    private AppPageNotificationMapper appPageNotificationMapper;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AdActivityVersionControlService adActivityVersionControlService;
    @Override
    public AppPageNotification getAppPageNotificationByType(String type) {
        return appPageNotificationMapper.selectByType(type);
    }
    @Cacheable(value = "configCache", key = "'getValidNotificationByTypeCache-'+#type")
    @Cacheable(value = "configCache", key = "'getValidNotificationByTypeCache-'+#type+'-'+ #platform+'-'+#versionCode")
    @Override
    public AppPageNotification getValidNotificationByTypeCache(String type) {
        return appPageNotificationMapper.selectValidByType(type);
    public AppPageNotification getValidNotificationByTypeCache(String type, String platform, Integer versionCode) {
        AppPageNotification record = appPageNotificationMapper.selectValidByType(type);
        if (record == null)
            return null;
        // 过滤版本
        AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
        if (app == null) {
            return null;
    }
        List<Long> versionIdList = new ArrayList<>();
        versionIdList.add(app.getId());
        List<Long> sourceIdList = new ArrayList<>();
        sourceIdList.add(record.getId());
        Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                AdActivityType.notification, versionIdList);
        if (!sourceIds.contains(record.getId())) {
            return null;
        }
        return record;
    }
    @Override
    public void addAppPageNotification(AppPageNotification apn) throws Exception {
@@ -84,4 +125,51 @@
    }
    
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void setVersions(Long id, List<Long> versions) throws Exception {
        AppPageNotification record = appPageNotificationMapper.selectByPrimaryKey(id);
        if (record == null) {
            throw new Exception("专题不存在");
        }
        Set<Long> oldSet = new HashSet<>();
        List<AdActivityVersionControl> versionList = adActivityVersionControlService
                .listByTypeAndSourceId(AdActivityType.notification, id);
        if (versionList != null) {
            for (AdActivityVersionControl control : versionList)
                oldSet.add(control.getVersion().getId());
        }
        Set<Long> newSet = new HashSet<>();
        for (Long version : versions) {
            newSet.add(version);
        }
        Set<Long> delSet = new HashSet<>();
        delSet.addAll(oldSet);
        delSet.removeAll(newSet);
        for (Long versionId : delSet) {
            adActivityVersionControlService.deleteBySourceAndVersion(id, AdActivityType.notification, versionId);
        }
        Set<Long> addSet = new HashSet<>();
        addSet.addAll(newSet);
        addSet.removeAll(oldSet);
        // 添加映射
        for (Long versionId : addSet) {
            AdActivityVersionControl control = new AdActivityVersionControl();
            control.setCreateTime(new Date());
            control.setSourceId(id);
            control.setType(AdActivityType.notification);
            control.setVersion(new AppVersionInfo(versionId));
            try {
                adActivityVersionControlService.addVersionControl(control);
            } catch (Exception e) {
                throw new SwiperPictureException(2, e.getMessage());
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java
@@ -3,23 +3,33 @@
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.homemodule.FloatADMapper;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.exception.homemodule.FloatADException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.StringUtil;
@@ -32,6 +42,12 @@
    
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AdActivityVersionControlService adActivityVersionControlService;
    
    
    @Override
@@ -210,6 +226,12 @@
        // 删除已存在图片
        for (FloatAD floatAD: listSwiper) {
            removePicture(floatAD.getPicture());
            List<AdActivityVersionControl> versionList = adActivityVersionControlService
                    .listByTypeAndSourceId(AdActivityType.floatAD, floatAD.getId());
            if (versionList != null)
                for (AdActivityVersionControl control : versionList)
                    adActivityVersionControlService.deleteByPrimaryKey(control.getId());
        }
        
        return floatADMapper.deleteByPrimaryKeyList(list);
@@ -274,6 +296,7 @@
        return floatADMapper.countQuery(key, state);
    }
    @Cacheable(value = "configCache", key = "'getEffectiveFloatAD-'+#position+'-'+#type")
    @Override
    public FloatAD getEffectiveFloatAD(String position, Integer type) {
        FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position, type);
@@ -295,14 +318,106 @@
    }
    
    
    @Transactional(rollbackFor = Exception.class)
    @Override
    public List<FloatAD> getValidCommonByPosition(String position) {
        return floatADMapper.getValidFloatAD(position, 1);
    public void setVersions(Long id, List<Long> versions) throws Exception {
        FloatAD record = floatADMapper.selectByPrimaryKey(id);
        if (record == null) {
            throw new Exception("专题不存在");
    }
    
    @Override
    public List<FloatAD> getValidByPosition(String position) {
        return floatADMapper.getValidFloatAD(position, null);
        Set<Long> oldSet = new HashSet<>();
        List<AdActivityVersionControl> versionList = adActivityVersionControlService
                .listByTypeAndSourceId(AdActivityType.floatAD, id);
        if (versionList != null) {
            for (AdActivityVersionControl control : versionList)
                oldSet.add(control.getVersion().getId());
    }
        Set<Long> newSet = new HashSet<>();
        for (Long version : versions) {
            newSet.add(version);
        }
        Set<Long> delSet = new HashSet<>();
        delSet.addAll(oldSet);
        delSet.removeAll(newSet);
        for (Long versionId : delSet) {
            adActivityVersionControlService.deleteBySourceAndVersion(id, AdActivityType.floatAD, versionId);
        }
        Set<Long> addSet = new HashSet<>();
        addSet.addAll(newSet);
        addSet.removeAll(oldSet);
        // 添加映射
        for (Long versionId : addSet) {
            AdActivityVersionControl control = new AdActivityVersionControl();
            control.setCreateTime(new Date());
            control.setSourceId(id);
            control.setType(AdActivityType.floatAD);
            control.setVersion(new AppVersionInfo(versionId));
            try {
                adActivityVersionControlService.addVersionControl(control);
            } catch (Exception e) {
                throw new SwiperPictureException(2, e.getMessage());
            }
        }
    }
    @Cacheable(value = "configCache", key = "'getValidFloatADCache-'+#position+'-'+#type+'-'+#platform+'-'+#versionCode")
    @Override
    public List<FloatAD> getValidFloatADCache(String position, Integer type, String platform, Integer versionCode) {
        List<FloatAD> list = floatADMapper.getValidFloatAD(position, type);
        // 过滤
        filterFloatAD(list, platform, versionCode);
        return list;
    }
    /**
     * 过滤
     *
     * @param list
     * @param platform
     * @param versionCode
     */
    private void filterFloatAD(List<FloatAD> list, String platform, int versionCode) {
        if (list == null || list.size() == 0)
            return;
        AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
        if (app == null) {
            list.clear();
            return;
        }
        List<Long> versionIdList = new ArrayList<>();
        versionIdList.add(app.getId());
        List<Long> sourceIdList = new ArrayList<>();
        for (FloatAD record : list) {
            sourceIdList.add(record.getId());
        }
        Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                AdActivityType.floatAD, versionIdList);
        for (int i = 0; i < list.size(); i++) {
            // 过滤版本
            if (!sourceIds.contains(list.get(i).getId())) {
                list.remove(i--);
                continue;
            }
            // 跳转是否登录
            FloatAD floatAD = list.get(i);
            JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
            if (jumpDetail != null) {
                jumpDetail = jumpDetailV2Service.selectByPrimaryKey(jumpDetail.getId());
                if (jumpDetail != null) {
                    jumpDetail.setNeedLogin(floatAD.isJumpNeedLogin());
                }
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/help/AppPageNotificationService.java
@@ -62,9 +62,12 @@
    
    public long countQuery(String key, Integer show, Integer canClose);
    public AppPageNotification getValidNotificationByTypeCache(String type);
    public AppPageNotification getValidNotificationByTypeCache(String type, String platform, Integer versionCode);
    public void updateByPrimaryKey(AppPageNotification record);
    public void setVersions(Long id, List<Long> versions) throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/FloatADService.java
@@ -58,20 +58,22 @@
     */
    public FloatAD getEffectiveFloatAD(String position, Integer type);
    /**
     * 返回多个 - 常规活动(不包含新人)
     * 设置版本信息
     * @param id
     * @param versions
     * @throws Exception
     */
    public void setVersions(Long id, List<Long> versions) throws Exception;
    /**
     *     有效版本信息
     * @param position
     * @param type
     * @return
     */
    public List<FloatAD> getValidCommonByPosition(String position);
    /**
     * 返回多个 - 所有活动
     * @param position
     * @return
     */
    public List<FloatAD> getValidByPosition(String position);
    public List<FloatAD> getValidFloatADCache(String position, Integer type, String platform, Integer versionCode);
}