yujian
2019-12-17 7e51ff02bba60c1577e321d6a0d0f31474e0a2fa
Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div
23个文件已修改
742 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SpecialCardAdminController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java 258 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BanLiShopController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/InviteGetMoneyController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserCouponController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCouponControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/SpecialMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/config/AppVersionServiceImpl.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/AdActivityVersionControlServiceImpl.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java 214 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/config/AppVersionService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/AdActivityVersionControlService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SwiperPictureService.java 68 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SpecialCardAdminController.java
@@ -279,15 +279,10 @@
        List<AppVersionInfo> versionList = null;
        if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
            versionList = new ArrayList<>();
            if (!StringUtil.isNullOrEmpty(version) && !StringUtil.isNullOrEmpty(platform)) {
                AppVersionInfo appVersion = appVersionService.getByPlatformAndVersion(platform, version);
            if (!StringUtil.isNullOrEmpty(version)) {
                AppVersionInfo appVersion = appVersionService.selectByPrimaryKey(Long.parseLong(version));
                if (appVersion != null)
                    versionList.add(appVersion);
            } else if (!StringUtil.isNullOrEmpty(version)) {
                List<AppVersionInfo> appVersionList = appVersionService.listByVersion(version);
                if (appVersionList != null) {
                    versionList.addAll(appVersionList);
                }
            } else {
                List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
                if (appVersionList != null) {
@@ -317,13 +312,8 @@
                    List<Long> versionIdList = new ArrayList<>();
                    for (AppVersionInfo versionInfo : versionList)
                        versionIdList.add(versionInfo.getId());
                    List<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                    Set<Long> sets = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                            AdActivityType.special, versionIdList);
                    Set<Long> sets = new HashSet<>();
                    if (sourceIds != null)
                        for (Long sourceId : sourceIds) {
                            sets.add(sourceId);
                        }
                    for (int i = 0; i < list.size(); i++) {
                        if (!sets.contains(list.get(i).getId())) {
                            list.remove(i--);
@@ -388,7 +378,7 @@
        List<Long> versionList = new ArrayList<>();
        if (list != null)
            for (AdActivityVersionControl control : list)
                versionList.add(control.getId());
                versionList.add(control.getVersion().getId());
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(versionList));
    }
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java
@@ -5,8 +5,10 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -19,6 +21,9 @@
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.AdActivityType;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.SwiperBanner;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.common.JumpDetailV2;
@@ -26,17 +31,21 @@
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.service.AdminUserService;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.config.SystemConfigService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.service.inter.homemodule.SwiperBannerService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
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;
/**
 * 轮播图管理
 *
 * @author Administrator
 *
 */
@@ -46,22 +55,28 @@
    @Resource
    private AdminUserService adminUserService;
    @Resource
    private SwiperBannerService swiperBannerService;
    @Resource
    private SwiperPictureService swiperPictureService;
    @Resource
    private SystemConfigService systemConfigService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private AdActivityVersionControlService adActivityVersionControlService;
    /**
     * 新增
     *
     * @param callback
     * @param swiperBanner
     * @param out
@@ -93,6 +108,7 @@
    /**
     * 修改
     *
     * @param callback
     * @param swiperBanner
     * @param out
@@ -139,9 +155,9 @@
        }
    }
    /**
     * 修该状态
     *
     * @param callback
     * @param id
     * @param out
@@ -160,19 +176,19 @@
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
                return;
            }
            Integer state = resultObj.getState();
            if (state == null ||  state.equals(1) || state == 1) {
            if (state == null || state.equals(1) || state == 1) {
                resultObj.setState(0);
            } else {
                resultObj.setState(1);
            }
            swiperBannerService.updateByPrimaryKeySelective(resultObj);
            JSONObject data = new JSONObject();
            data.put("state", resultObj.getState());
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (SwiperBannerException e) {
@@ -181,14 +197,16 @@
        }
    }
    /**
     * 查询
     *
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param key  模糊查询:说明、标识
     * @param sort 排序 : 创建时间倒序1  默认正序
     * @param key
     *            模糊查询:说明、标识
     * @param sort
     *            排序 : 创建时间倒序1 默认正序
     * @param out
     */
    @RequestMapping(value = "query")
@@ -209,20 +227,20 @@
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            for (SwiperBanner swiperBanne: list) {
                long TotalPic= swiperPictureService.countQueryByBannerID(swiperBanne.getId());
            for (SwiperBanner swiperBanne : list) {
                long TotalPic = swiperPictureService.countQueryByBannerID(swiperBanne.getId());
                swiperBanne.setTotalPic(TotalPic);
            }
            long count = swiperBannerService.countQuery(key);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
@@ -238,9 +256,9 @@
    }
    /**
     * 删除
     *
     * @param callback
     * @param idArray
     * @param out
@@ -255,16 +273,17 @@
            }
            Gson gson = new Gson();
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            int count = swiperBannerService.deleteBatchByPrimaryKey(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除["+ count +"]条数据"));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
@@ -272,48 +291,48 @@
        }
    }
    @RequestMapping(value = "getEffectiveOption")
    public void getEffectiveOption(String callback, PrintWriter out) {
        try {
            List<Object> list = new ArrayList<Object>();
            Map<String,Object> mapDefalut =new HashMap<String,Object>();
            Map<String, Object> mapDefalut = new HashMap<String, Object>();
            mapDefalut.put("key", 0);
            mapDefalut.put("value", "--未选择--");
            list.add(mapDefalut);
            List<SwiperBanner> listBanner = swiperBannerService.getEffectiveOption();
            if (listBanner != null && listBanner.size() > 0) {
                for (SwiperBanner swiperBanner: listBanner) {
                    Map<String,Object> map =new HashMap<String,Object>();
                for (SwiperBanner swiperBanner : listBanner) {
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("key", swiperBanner.getId());
                    map.put("value", swiperBanner.getTitle());
                    list.add(map);
                }
            }
            JSONObject data = new JSONObject();
            data.put("result_list", list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    /**
     *  查询图片列表
     * 查询图片列表
     *
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param bannerId
     * @param bannerId
     * @param out
     */
    @RequestMapping(value = "queryPicInfo")
    public void queryPicInfo(String callback, Integer pageIndex, Integer pageSize, Long bannerId, PrintWriter out) {
    public void queryPicInfo(String callback, Integer pageIndex, Integer pageSize, Long bannerId, String version,
            String platform, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -323,24 +342,41 @@
            pageSize = Constant.PAGE_SIZE;
        }
        pageSize = 100;
        if (bannerId == null) {
            out.print(JsonUtil.loadFalseResult("轮播图管理ID不能为空"));
            return;
        }
        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);
                }
            }
        }
        try {
            List<SwiperPicture> list = swiperPictureService.queryByBannerID((pageIndex - 1) * pageSize,
                    pageSize, bannerId);
            List<SwiperPicture> list = swiperPictureService.queryByBannerID((pageIndex - 1) * pageSize, pageSize,
                    bannerId);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            // 跳转链接
            for (SwiperPicture swiperPicture: list) {
            for (SwiperPicture swiperPicture : list) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
                Date startTime = swiperPicture.getStartTime();
                if (startTime == null) {
@@ -348,28 +384,24 @@
                } else {
                    swiperPicture.setStartTime_str(sdf.format(startTime));
                }
                Date endTime = swiperPicture.getEndTime();
                if (endTime == null) {
                    swiperPicture.setEndTime_str("");
                } else {
                    swiperPicture.setEndTime_str(sdf.format(endTime));
                }
                String params = swiperPicture.getParams();
                if (params == null) {
                    swiperPicture.setParams("");
                }
                String remark = swiperPicture.getRemark();
                if (remark == null) {
                    swiperPicture.setRemark("");
                }
                JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
                if (jumpDetail == null) {
                    // 默认未选择
@@ -379,15 +411,39 @@
                    swiperPicture.setJumpDetail(jumpDetailV2);
                }
            }
            long count = swiperPictureService.countQueryByBannerID(bannerId);
            // 过滤
            if (versionList != null) {
                if (versionList.size() > 0) {
                    List<Long> sourceIdList = new ArrayList<>();
                    for (SwiperPicture swiperPicture : list) {
                        sourceIdList.add(swiperPicture.getId());
                    }
                    List<Long> versionIdList = new ArrayList<>();
                    for (AppVersionInfo versionInfo : versionList)
                        versionIdList.add(versionInfo.getId());
                    Set<Long> sets = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                            AdActivityType.banner, 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);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm").create();
            JSONObject data = new JSONObject();
@@ -402,8 +458,7 @@
        }
    }
    /**
     * 保存信息
     * 
@@ -412,16 +467,17 @@
     * @param out
     */
    @RequestMapping(value = "savePicInfo")
    public void savePicInfo(String callback, SwiperPicture record, String jumpType, HttpServletRequest request,PrintWriter out) {
    public void savePicInfo(String callback, SwiperPicture record, String jumpType, HttpServletRequest request,
            PrintWriter out) {
        try {
            // 1. 先判断httpRequest 是否含有文件类型
            // 1. 先判断httpRequest 是否含有文件类型
            if (request instanceof MultipartHttpServletRequest) {
                MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
                swiperPictureService.saveObject(fileRequest.getFile("file"), record, jumpType);
            }else{
                swiperPictureService.saveObject(null, record, jumpType);
            }
                MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
                swiperPictureService.saveObject(fileRequest.getFile("file"), record, jumpType);
            } else {
                swiperPictureService.saveObject(null, record, jumpType);
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (SwiperPictureException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -430,11 +486,10 @@
            e.printStackTrace();
        }
    }
    /**
     * 删除图片以及信息
     *
     * @param callback
     * @param idArray
     * @param out
@@ -449,23 +504,23 @@
            }
            Gson gson = new Gson();
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            int count = swiperPictureService.deleteBatchByPrimaryKey(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除["+ count +"]条数据"));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    /**
     * 修改排序
@@ -475,18 +530,18 @@
     * @param out
     */
    @RequestMapping(value = "saveOrder")
    public void saveOrder(String callback, Long id,Integer moveType, PrintWriter out) {
    public void saveOrder(String callback, Long id, Integer moveType, PrintWriter out) {
        if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递的类型不正确"));
            return;
        }
        if (id == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
            return;
        }
        try {
            SwiperPicture resultObj = swiperPictureService.selectByPrimaryKey(id);
@@ -494,21 +549,21 @@
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
                return;
            }
            Long bannerId = resultObj.getBannerId();
            Integer oldOrder = resultObj.getOrder();
            List<SwiperPicture> list = swiperPictureService.getOrderByBannerID(bannerId, moveType, oldOrder);
            if (list != null && list.size() > 0) {
                SwiperPicture changeObj = list.get(0);
                // 交换排序序号
                resultObj.setOrder(changeObj.getOrder());
                changeObj.setOrder(oldOrder);
                swiperPictureService.updateByPrimaryKeySelective(changeObj);
            }
            swiperPictureService.updateByPrimaryKeySelective(resultObj);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
@@ -519,5 +574,42 @@
        }
    }
    /**
     * 设置版本
     *
     * @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 {
            swiperPictureService.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.banner, 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/BanLiShopController.java
@@ -67,7 +67,7 @@
    @Resource
    private BanLiShopGoodsSetService banLiShopGoodsSetService;
    @Resource
    private RedPackForbidService redPackForbidService;
@@ -80,14 +80,15 @@
     * @param out
     */
    @RequestMapping(value = "goodsList")
    public void goodsList(AcceptData acceptData, int page,Long uid, String callback, PrintWriter out) {
    public void goodsList(AcceptData acceptData, int page, Long uid, String callback, PrintWriter out) {
        if (page <= 0)
            page = 1;
        List<BanLiShopGoods> goodsList = banLiShopGoodsService.listGoods(null, BanLiShopGoods.STATE_ONLINE, page,
                Constant.PAGE_SIZE);
        long count = banLiShopGoodsService.countGoods(null, BanLiShopGoods.STATE_ONLINE);
        // 获取banner
        List<SwiperPicture> pictureList = swiperPictureService.getByBannerCard("hongbao_exchange_goods_list");
        List<SwiperPicture> pictureList = swiperPictureService.getByBannerCardAndVersion("hongbao_exchange_goods_list",
                acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
        JSONObject data = new JSONObject();
        if (pictureList != null && pictureList.size() > 0) {
@@ -96,7 +97,7 @@
        data.put("data", goodsList);
        data.put("count", count);
        data.put("redPackLock", redPackForbidService.verifyForbid(uid));
        if (!StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        else
@@ -181,7 +182,7 @@
                }
            }
        BigDecimal money = redPackBalanceService.getBalance(uid);
        JSONObject data = new JSONObject();
        data.put("goods", goods);
        data.put("hongBaoBalance", money);
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java
@@ -254,7 +254,7 @@
            
            if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                // 我的界面banner
                List<SwiperPicture> banner = swiperPictureService.getByBannerCard("my_interface_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));
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java
@@ -168,7 +168,8 @@
            // 轮播图
            List<SwiperPicture> picList = null;
            if (swpid != null) {
                picList = swiperPictureService.getByBannerId(swpid);
                picList = swiperPictureService.getByBannerId(swpid, acceptData.getPlatform(),
                        Integer.parseInt(acceptData.getVersion()));
            }
            if (picList == null) {
                picList = new ArrayList<SwiperPicture>();
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/InviteGetMoneyController.java
@@ -126,7 +126,7 @@
        data.put("activityRules", valueBr);
        data.put("inviteList", String.format("http://%s/%s/client/share/friends_new.html",
                Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
        List<SwiperPicture> pictureList = swiperPictureService.getByBannerCard("invite_top_banner");
        List<SwiperPicture> pictureList = swiperPictureService.getByBannerCardAndVersion("invite_top_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
        if (pictureList != null && pictureList.size() > 0) {
            SwiperPicture picture = pictureList.get(0);
            com.alibaba.fastjson.JSONObject pictureJson = new com.alibaba.fastjson.JSONObject();
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java
@@ -1595,7 +1595,8 @@
        if (!StringUtil.isNullOrEmpty(specialCard)) {
            try {
                listswiper = swiperPictureService.getByBannerCard(swiperCard);
                listswiper = swiperPictureService.getByBannerCardAndVersion(swiperCard, acceptData.getPlatform(),
                        Integer.parseInt(acceptData.getVersion()));
                if (listswiper == null) {
                    listswiper = new ArrayList<SwiperPicture>();
@@ -1715,7 +1716,7 @@
            JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex);
            // 2、顶部轮播图
            List<SwiperPicture> topPicList = getSwiperByCard("index_top");
            List<SwiperPicture> topPicList = getSwiperByCard("index_top",acceptData);
            if (topPicList == null) {
                topPicList = new ArrayList<SwiperPicture>();
            }
@@ -1727,7 +1728,7 @@
                    && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
                // 如果IOS当前版本处于审核状态就不返回
            } else {
                invitePicList = getSwiperByCard("index_invite");
                invitePicList = getSwiperByCard("index_invite",acceptData);
            }
            if (invitePicList == null) {
@@ -1768,15 +1769,16 @@
            return null;
        }
        List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");
        List<SwiperPicture> invitePicList = getSwiperByCard("index_invite",acceptData);
        return invitePicList;
    }
    public List<SwiperPicture> getSwiperByCard(String card) {
    public List<SwiperPicture> getSwiperByCard(String card, AcceptData acceptData) {
        List<SwiperPicture> swiperList = null;
        try {
            swiperList = swiperPictureService.getByBannerCard(card);
            swiperList = swiperPictureService.getByBannerCardAndVersion(card, acceptData.getPlatform(),
                    Integer.parseInt(acceptData.getVersion()));
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserCouponController.java
@@ -104,7 +104,7 @@
            // 福利中心图片
            String topPicture = null;
            if (page == 1) {
                List<SwiperPicture> listswiper = swiperPictureService.getByBannerCard("welfare_top");
                List<SwiperPicture> listswiper = swiperPictureService.getByBannerCardAndVersion("welfare_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
                if (listswiper != null && listswiper.size() > 0) {
                    topPicture = listswiper.get(0).getSrc();
                }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
@@ -430,7 +430,7 @@
        JSONObject data = new JSONObject();
        if (page == 1) {
            // 2、顶部轮播图
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture");
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (oldtopPicList != null && oldtopPicList.size() > 0)
                topPicList.addAll(oldtopPicList);
            TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(id);
@@ -747,7 +747,7 @@
        if (page == 1 && array.size() > 0) {
            // 2、顶部轮播图
            List<SwiperPicture> topPicList = new ArrayList<>();
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture");
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (oldtopPicList != null && oldtopPicList.size() > 0)
                topPicList.addAll(oldtopPicList);
            
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -241,7 +241,7 @@
            // 2、顶部轮播图
            List<SwiperPicture> bannerList = null;
            if (Constant.IS_TEST) {
                bannerList = swiperPictureService.getByBannerCard("index_top");
                bannerList = swiperPictureService.getByBannerCardAndVersion("index_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            }
            if (bannerList == null) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java
@@ -97,7 +97,7 @@
    public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) {
        JSONObject root = new JSONObject();
        if (cid == 1 && page == 1) {
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jingdong_special_index");
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCardAndVersion("jingdong_special_index",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (topPicList == null) {
                topPicList = new ArrayList<SwiperPicture>();
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java
@@ -91,7 +91,7 @@
    public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) {
        JSONObject root = new JSONObject();
        if (cid == 1 && page == 1) {
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("pinduoduo_special_index");
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCardAndVersion("pinduoduo_special_index",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (topPicList == null) {
                topPicList = new ArrayList<SwiperPicture>();
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -149,7 +149,9 @@
            JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex);
            // 2、顶部轮播图
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("index_top");
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("index_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            List<SwiperPicture> topPicList = new ArrayList<>();
            if (oldtopPicList != null && oldtopPicList.size() > 0)
                topPicList.addAll(oldtopPicList);
@@ -162,7 +164,7 @@
                    && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
                // 如果IOS当前版本处于审核状态就不返回
            } else {
                invitePicList = swiperPictureService.getByBannerCard("index_invite");
                invitePicList = swiperPictureService.getByBannerCardAndVersion("index_invite",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            }
            if (invitePicList == null) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -616,7 +616,7 @@
        data.put("count", array.size());
        data.put("list", array);
        if (page == 1) {
            List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner");
            List<SwiperPicture> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (bannerList != null && bannerList.size() > 0)
                data.put("topPicture", bannerList.get(0).getSrc());
@@ -703,7 +703,7 @@
        data.put("count", array.size());
        data.put("list", array);
        if (page == 1) {
            List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner");
            List<SwiperPicture> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            if (bannerList != null && bannerList.size() > 0)
                data.put("topPicture", bannerList.get(0).getSrc());
@@ -752,7 +752,7 @@
            }
            // 2、顶部轮播图
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("redpack_win_detail_banner");
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("redpack_win_detail_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
            List<SwiperPicture> topPicList = new ArrayList<>();
            if (oldtopPicList != null && oldtopPicList.size() > 0)
                topPicList.addAll(oldtopPicList);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCouponControllerV2.java
@@ -103,7 +103,7 @@
            JSONObject data = new JSONObject();
            if (page == 1) {
                // 福利中心图片
                List<SwiperPicture> listswiper = swiperPictureService.getByBannerCard("welfare_top_1.6.5");
                List<SwiperPicture> listswiper = swiperPictureService.getByBannerCardAndVersion("welfare_top_1.6.5",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
                if (listswiper != null && listswiper.size() > 0) {
                    String topPicture = listswiper.get(0).getSrc();
                    data.put("topPicture", topPicture);
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/SpecialMapper.xml
@@ -408,10 +408,10 @@
        WHERE sp.`b_state` = 0  
            AND IF(sp.b_start_time IS NULL,TRUE, sp.b_start_time<![CDATA[<=]]> NOW()) 
              AND IF(sp.b_end_time IS NULL,TRUE, sp.b_end_time <![CDATA[>=]]> NOW())
              <if test="platform == 1">
              <if test="platform == 1 and versionCode!=null">
              AND IF(sp.`b_min_android_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_android_version_code,TRUE)
            </if>
            <if test="platform == 2">
            <if test="platform == 2 and versionCode!=null">
              AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
            </if>
            <include refid="Sex_Screen" />
fanli/src/main/java/com/yeshi/fanli/service/impl/config/AppVersionServiceImpl.java
@@ -112,8 +112,18 @@
    @Override
    public List<AppVersionInfo> listByVersion(String version) {
        return null;
    }
    @Override
    public AppVersionInfo getClientVersion(String platform, int versionCode) {
        AppVersionInfo appInfo = getAppVersionInfoListByPlatformAndVersion(platform, versionCode);
        if (appInfo != null)
            return appInfo;
        // 如果不存在就降低版本号查询
        if (versionCode > 0)
            return getClientVersion(platform, versionCode - 1);
        return null;
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/AdActivityVersionControlServiceImpl.java
@@ -2,7 +2,9 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
@@ -48,7 +50,7 @@
    }
    @Override
    public List<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList) {
    public Set<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList) {
        if (sourceIdList == null || sourceIdList.size() == 0)
            return null;
@@ -57,7 +59,7 @@
        List<AdActivityVersionControl> list = adActivityVersionControlMapper.listByVersionAndSourceId(sourceIdList,
                type, versionIdList);
        List<Long> resultList = new ArrayList<>();
        Set<Long> resultList = new HashSet<>();
        if (list != null)
            for (AdActivityVersionControl control : list)
                if (control != null && control.getSourceId() != null)
@@ -66,4 +68,12 @@
        return resultList;
    }
    @Override
    public void deleteBySourceAndVersion(Long sourceId, AdActivityType type, Long version) {
        AdActivityVersionControl control = adActivityVersionControlMapper.selectBySourceIdAndTypeAndVersion(sourceId,
                type, version);
        if (control != null)
            deleteByPrimaryKey(control.getId());
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
@@ -5,7 +5,9 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Resource;
@@ -25,6 +27,7 @@
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.exception.homemodule.HomeNavbarException;
import com.yeshi.fanli.exception.homemodule.SpecialException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
@@ -449,6 +452,37 @@
        return specialMapper.listByVersion(start, count, card, platform, versionCode);
    }
    /**
     * 专题版本过滤
     *
     * @param list
     * @param platform
     * @param versionCode
     */
    private void filterSpecial(List<Special> 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 (Special special : list) {
            sourceIdList.add(special.getId());
        }
        Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                AdActivityType.special, versionIdList);
        for (int i = 0; i < list.size(); i++) {
            if (!sourceIds.contains(list.get(i).getId())) {
                list.remove(i--);
            }
        }
    }
    @Override
    @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex")
    public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception {
@@ -466,10 +500,12 @@
        else if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion()))
            indexArc = "index_arc_1.5.6";
        int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
        String platform = acceptData.getPlatform();
        int platformCode = Constant.getPlatformCode(platform);
        int version = Integer.parseInt(acceptData.getVersion());
        List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version);
        filterSpecial(listArc, platform, version);
        if (listArc == null) {
            listArc = new ArrayList<Special>();
        } else if (listArc.size() > 0) {
@@ -520,6 +556,8 @@
            listActivity = specialMapper.listByPlaceKey("index_activity", null, platformCode, version);
        }
        filterSpecial(listActivity, platform, version);
        if (listActivity == null) {
            listActivity = new ArrayList<Special>();
        } else if (listActivity.size() > 0) {
@@ -541,6 +579,7 @@
        JSONObject blockJsonMap = new JSONObject();
        List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex, platformCode, version);
        filterSpecial(listBlock, platform, version);
        if (listBlock == null) {
            listBlock = new ArrayList<Special>();
        } else if (listBlock.size() > 0) {
@@ -621,20 +660,45 @@
        if (special == null) {
            throw new Exception("专题不存在");
        }
        Set<Long> oldSet = new HashSet<>();
        List<AdActivityVersionControl> versionList = adActivityVersionControlService
                .listByTypeAndSourceId(AdActivityType.special, special.getId());
                .listByTypeAndSourceId(AdActivityType.special, specialId);
        if (versionList != null) {
            for (AdActivityVersionControl control : versionList)
                adActivityVersionControlService.deleteByPrimaryKey(control.getId());
                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(specialId, AdActivityType.special, versionId);
        }
        Set<Long> addSet = new HashSet<>();
        addSet.addAll(newSet);
        addSet.removeAll(oldSet);
        // 添加映射
        for (Long versionId : versions) {
        for (Long versionId : addSet) {
            AdActivityVersionControl control = new AdActivityVersionControl();
            control.setCreateTime(new Date());
            control.setSourceId(special.getId());
            control.setType(AdActivityType.special);
            control.setVersion(new AppVersionInfo(versionId));
            adActivityVersionControlService.addVersionControl(control);
            try {
                adActivityVersionControlService.addVersionControl(control);
            } catch (Exception e) {
                throw new SwiperPictureException(2, e.getMessage());
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java
@@ -3,8 +3,11 @@
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;
@@ -16,10 +19,16 @@
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.homemodule.SwiperPictureMapper;
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.Special;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
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.SwiperPictureService;
import com.yeshi.fanli.util.StringUtil;
@@ -28,11 +37,15 @@
    @Resource
    private SwiperPictureMapper swiperPictureMapper;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private AdActivityVersionControlService adActivityVersionControlService;
    @Resource
    private AppVersionService appVersionService;
    @Override
    public int insertSelective(SwiperPicture record) {
@@ -50,47 +63,47 @@
    }
    @Override
    public int updateByPrimaryKey(SwiperPicture record){
    public int updateByPrimaryKey(SwiperPicture record) {
        return swiperPictureMapper.updateByPrimaryKey(record);
    }
    @Override
    public List<SwiperPicture> queryByBannerID(long start, int count, Long bannerId) throws SwiperPictureException{
    public List<SwiperPicture> queryByBannerID(long start, int count, Long bannerId) throws SwiperPictureException {
        return swiperPictureMapper.queryByBannerID(start, count, bannerId);
    }
    @Override
    public long countQueryByBannerID(Long bannerId) throws SwiperPictureException{
    public long countQueryByBannerID(Long bannerId) throws SwiperPictureException {
        return swiperPictureMapper.countQueryByBannerID(bannerId);
    }
    @Override
    public void saveObject(MultipartFile file, SwiperPicture record, String jumpType) throws SwiperPictureException, Exception{
    public void saveObject(MultipartFile file, SwiperPicture record, String jumpType)
            throws SwiperPictureException, Exception {
        if (record == null) {
            throw new SwiperPictureException(1, "参数不能为空");
        }
        Long bannerId = record.getBannerId();
        if (bannerId == null) {
            throw new SwiperPictureException(1, "标识管理ID不能为空");
        }
        String params = record.getParams();
        if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params) ) {
        if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
            record.setParams(null);
        } else if (!StringUtil.isJson(params)) {
            throw new SwiperPictureException(1, "跳转参数非JSON格式");
        }
        if (!StringUtil.isNullOrEmpty(jumpType)) {
            List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
            if (listByType !=null && listByType.size() > 0) {
            if (listByType != null && listByType.size() > 0) {
                record.setJumpDetail(listByType.get(0));
            }
            }
        }
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            String startTime_str = record.getStartTime_str();
@@ -98,40 +111,39 @@
                startTime_str = startTime_str.replaceAll("T", " ");
                record.setStartTime(format.parse(startTime_str));
            }
            String endTime_str = record.getEndTime_str();
            if (endTime_str != null && endTime_str.trim().length() > 0) {
                endTime_str = endTime_str.replaceAll("T", " ");
                record.setEndTime(format.parse(endTime_str));
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String remark = record.getRemark();
        if (remark != null && (remark.trim().length() == 0 || remark.equalsIgnoreCase("null"))) {
            record.setRemark(null);
        }
        String picture = null;
        if (file != null) {
            picture = uploadPicture(file);
        }
        Long id = record.getId();
        if (id == null) {
            int maxOrder = swiperPictureMapper.getMaxOrderByBannerID(bannerId);
            record.setOrder(maxOrder + 1);
            Integer state = record.getState();
            // 默认停用
            if (state == null) {
                record.setState(1);
            }
            Integer autoControl = record.getAutoControl();
            if (autoControl == null) {
                // 默认非系统控制
@@ -140,7 +152,7 @@
            record.setCreatetime(new Date());
            record.setUpdatetime(new Date());
            record.setSrc(picture);
            swiperPictureMapper.insert(record);
        } else {
            // 修改
@@ -148,49 +160,49 @@
            if (resultObj == null) {
                throw new SwiperPictureException(1, "参数不能为空");
            }
            if (picture != null && picture.trim().length() > 0) {
                // 删除已存在图片
                removePicture(resultObj);
                record.setSrc(picture);
            } else {
                record.setSrc(resultObj.getSrc());
            }
            record.setOrder(resultObj.getOrder());
            record.setCreatetime(resultObj.getCreatetime());
            record.setUpdatetime(new Date());
            swiperPictureMapper.updateByPrimaryKey(record);
        }
    }
    /**
     * 上传图片
     *
     * @param file
     * @return
     * @throws Exception
     */
    public String uploadPicture(MultipartFile file) throws Exception {
        // 文件解析
        // 文件解析
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        // 文件路径
        String filePath="/img/swiperPic/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
        String filePath = "/img/swiperPic/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
        // 执行上传
        String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
        String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
        return fileLink;
    }
    /**
     * 删除图片-不更新数据库
     *
     * @param record
     * @throws Exception
     */
@@ -200,32 +212,31 @@
            COSManager.getInstance().deleteFile(picture);
        }
    }
    @Override
    @Transactional
    public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException{
    public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException {
        List<SwiperPicture> listSwiper = swiperPictureMapper.queryByListPrimaryKey(list);
        for (SwiperPicture swiperPicture: listSwiper) {
        for (SwiperPicture swiperPicture : listSwiper) {
            String src = swiperPicture.getSrc();
            if (!StringUtil.isNullOrEmpty(src)) {
                COSManager.getInstance().deleteFile(src);
            }
        }
        return swiperPictureMapper.deleteBatchByPrimaryKey(list);
    }
    @Override
    public int deleteBatchByBannerID(List<Long> list) throws SwiperPictureException{
    public int deleteBatchByBannerID(List<Long> list) throws SwiperPictureException {
        return swiperPictureMapper.deleteBatchByBannerID(list);
    }
    @Override
    public List<SwiperPicture> queryByListBannerID(List<Long> list) throws Exception{
    public List<SwiperPicture> queryByListBannerID(List<Long> list) throws Exception {
        return swiperPictureMapper.queryByListBannerID(list);
    }
    @Override
    public List<SwiperPicture> getOrderByBannerID(Long bannerId, Integer type, Integer order) {
@@ -236,13 +247,13 @@
    public int getMaxOrderByBannerID(Long bannerId) throws SwiperPictureException {
        return swiperPictureMapper.getMaxOrderByBannerID(bannerId);
    }
    @Override
    @Cacheable(value = "bannerCache", key = "'getByBannerCard-'+#card")
    public List<SwiperPicture> getByBannerCard(String card) {
        List<SwiperPicture> list = swiperPictureMapper.getByBannerCard(card);
        if (list != null && list.size() > 0) {
            for (SwiperPicture swiperPicture: list) {
            for (SwiperPicture swiperPicture : list) {
                boolean needLogin = swiperPicture.isJumpNeedLogin();
                JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
                if (jumpDetail != null) {
@@ -253,13 +264,110 @@
        }
        return list;
    }
    /**
     * 专题版本过滤
     *
     * @param list
     * @param platform
     * @param versionCode
     */
    private void filterSwipePicture(List<SwiperPicture> 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 (SwiperPicture picture : list) {
            sourceIdList.add(picture.getId());
        }
        Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
                AdActivityType.banner, versionIdList);
        for (int i = 0; i < list.size(); i++) {
            if (!sourceIds.contains(list.get(i).getId())) {
                list.remove(i--);
            }
        }
    }
    @Cacheable(value = "bannerCache", key = "'getByBannerCardAndVersion-'+#card+'-'+#platform+'-'+#version")
    @Override
    public List<SwiperPicture> getByBannerCardAndVersion(String card, String platform, int version) {
        List<SwiperPicture> list = swiperPictureMapper.getByBannerCard(card);
        filterSwipePicture(list, platform, version);
        return list;
    }
    @Override
    @Cacheable(value = "bannerCache", key = "'getByBannerId-'+#bannerId")
    public List<SwiperPicture> getByBannerId(Long bannerId) {
        return swiperPictureMapper.getByBannerId(bannerId);
    }
}
    @Cacheable(value = "bannerCache", key = "'getByBannerId-'+#bannerId+'-'+#platform+'-'+#version")
    @Override
    public List<SwiperPicture> getByBannerId(Long bannerId, String platform, int version)
            throws SwiperPictureException {
        List<SwiperPicture> pictureList = swiperPictureMapper.getByBannerId(bannerId);
        filterSwipePicture(pictureList, platform, version);
        return pictureList;
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void setVersions(Long id, List<Long> versions) throws SwiperPictureException {
        SwiperPicture swiperPicture = selectByPrimaryKey(id);
        if (swiperPicture == null) {
            throw new SwiperPictureException(1, "Banner不存在");
        }
        Set<Long> oldSet = new HashSet<>();
        List<AdActivityVersionControl> versionList = adActivityVersionControlService
                .listByTypeAndSourceId(AdActivityType.banner, swiperPicture.getId());
        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.banner, 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(swiperPicture.getId());
            control.setType(AdActivityType.banner);
            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/inter/config/AppVersionService.java
@@ -97,4 +97,13 @@
     */
    public List<AppVersionInfo> listByVersion(String version);
    /**
     * 获取客户端版本
     *
     * @param platform
     * @param versionCode
     * @return
     */
    public AppVersionInfo getClientVersion(String platform, int versionCode);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/AdActivityVersionControlService.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.inter.homemodule;
import java.util.List;
import java.util.Set;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
@@ -29,6 +30,14 @@
    public void deleteByPrimaryKey(Long id);
    /**
     * 根据来源与版本删除
     * @param sourceId
     * @param type
     * @param version
     */
    public void deleteBySourceAndVersion(Long sourceId, AdActivityType type, Long version);
    /**
     * 根据类型与内容ID查询
     * 
     * @param type
@@ -45,6 +54,6 @@
     * @param appVersionId
     * @return
     */
    public List<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList);
    public Set<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SwiperPictureService.java
@@ -1,7 +1,5 @@
package com.yeshi.fanli.service.inter.homemodule;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;
@@ -11,7 +9,6 @@
public interface SwiperPictureService {
    public int insertSelective(SwiperPicture record);
    public SwiperPicture selectByPrimaryKey(Long id);
@@ -19,9 +16,10 @@
    public int updateByPrimaryKeySelective(SwiperPicture record);
    public int updateByPrimaryKey(SwiperPicture record);
    /**
     * 查询
     *
     * @param start
     * @param count
     * @param bannerId
@@ -29,36 +27,41 @@
     * @throws SwiperPictureException
     */
    public List<SwiperPicture> queryByBannerID(long start, int count, Long bannerId) throws SwiperPictureException;
    public long countQueryByBannerID(Long bannerId) throws SwiperPictureException;
    /**
     * 批量删除
     * @param list  主键id
     *
     * @param list
     *            主键id
     * @return
     * @throws SwiperPictureException
     */
    public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException;
    /**
     * 批量删除
     * @param list  管理id
     * 批量删除
     *
     * @param list
     *            管理id
     * @return
     * @throws SwiperPictureException
     */
    public int deleteBatchByBannerID(List<Long> list) throws SwiperPictureException;
    /**
     * 根据管理id集合 查询
     *
     * @param list
     * @return
     * @throws Exception
     */
    public List<SwiperPicture> queryByListBannerID(List<Long> list) throws Exception;
    /**
     * 获取附近排序值
     *
     * @param bannerId
     * @param type
     * @param order
@@ -69,6 +72,7 @@
    /**
     * 获取最大排序值
     *
     * @param bannerId
     * @return
     */
@@ -76,24 +80,60 @@
    /**
     * 根据 唯一标识查询
     * @param card 唯一标识
     *
     * @param card
     *            唯一标识
     * @return
     */
    public List<SwiperPicture> getByBannerCard(String card);
    /**
     * 根据标识与版本查询
     *
     * @param card
     * @param platform
     * @param version
     * @return
     */
    public List<SwiperPicture> getByBannerCardAndVersion(String card, String platform, int version);
    /**
     * 保存信息
     *
     * @param record
     * @throws SwiperPictureException
     */
    public void saveObject(MultipartFile file, SwiperPicture record, String jumpType) throws SwiperPictureException, Exception;
    public void saveObject(MultipartFile file, SwiperPicture record, String jumpType)
            throws SwiperPictureException, Exception;
    /**
     * 根据管理id 查询有效轮播图
     *
     * @param bannerId
     * @return
     * @throws SwiperPictureException
     */
    public List<SwiperPicture> getByBannerId(Long bannerId) throws SwiperPictureException;
    /**
     *  根据管理id 查询有效轮播图(更加版本区分)
     * @param bannerId
     * @param platform
     * @param version
     * @return
     * @throws SwiperPictureException
     */
    public List<SwiperPicture> getByBannerId(Long bannerId,String platform,int version) throws SwiperPictureException;
    /**
     * 为banner设置版本
     *
     * @param id
     * @param versions
     * @throws SwiperPictureException
     */
    public void setVersions(Long id, List<Long> versions) throws SwiperPictureException;
}