admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
@@ -1,7 +1,6 @@
package com.yeshi.fanli.controller.client.v2;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -22,11 +21,10 @@
import com.yeshi.fanli.entity.brand.BrandInfoRecord;
import com.yeshi.fanli.entity.brand.BrandShopCahe;
import com.yeshi.fanli.entity.brand.TaoBaoShopHistory;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.brand.BrandClassService;
@@ -38,19 +36,21 @@
import com.yeshi.fanli.service.inter.brand.TaoBaoShopHistoryService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.BrandInfoVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import com.yeshi.fanli.vo.homemodule.BannerVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -72,13 +72,13 @@
   private TaoBaoShopHistoryService taoBaoShopHistoryService;
   @Resource
   private HongBaoManageService hongBaoManageService;
   private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
   @Resource
   private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
   @Resource
   private DaTaoKeGoodsService daTaoKeGoodsService;
   private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
   @Resource
   private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
@@ -110,7 +110,7 @@
      if (page == null || page < 1) {
         page = 1;
      }
      JSONObject data = brandClassShopService.listEffectiveCacheV2(page, cid);
      JSONObject data = brandClassShopService.listEffectiveCacheV2(page, cid,acceptData.getPlatform(),acceptData.getVersion());
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -251,9 +251,9 @@
      List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
      // 先查询大淘客数据
      List<DaTaoKeDetail> listDaTaoKe = daTaoKeGoodsService.listBySellerId(0, pageSize, sid);
      List<DaTaoKeDetailV2> listDaTaoKe = daTaoKeGoodsDetailV2Service.listBySellerId(0, pageSize, sid);
      if (listDaTaoKe != null && listDaTaoKe.size() > 0) {
         for (DaTaoKeDetail daTaoKe : listDaTaoKe) {
         for (DaTaoKeDetailV2 daTaoKe : listDaTaoKe) {
            listGoodsBrief.add(TaoBaoUtil.convert(daTaoKe));
         }
      }
@@ -307,9 +307,8 @@
         Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
               .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
         BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
         BigDecimal shareRate = hongBaoManageService.getShareRate();
         ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
         ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
               acceptData.getVersion());
         // 商品信息过滤
         listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
@@ -351,11 +350,17 @@
    */
   @RequestMapping(value = "getList", method = RequestMethod.POST)
   public void getList(AcceptData acceptData, Integer page, Long cid, Long uid, PrintWriter out) {
      if (Constant.IS_TEST) {
         getListV3(acceptData, page, cid, uid, out);
         return;
      if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
         if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            getListV3(acceptData, page, cid, uid, out);
            return;
         }
      } else {
         if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getListV3(acceptData, page, cid, uid, out);
            return;
         }
      }
      
      if (page == null || page < 1) {
         out.print(JsonUtil.loadFalseResult("页码不正确"));
@@ -377,7 +382,7 @@
      
      long count = brandInfoService.countBrandInfo(cid);
      
      List<BrandInfoVO> list = brandInfoService.listBrandInfoCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid);
      List<BrandInfoVO> list = brandInfoService.listBrandInfoCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion());
      if (list == null)
         list = new ArrayList<BrandInfoVO>();
      
@@ -400,9 +405,16 @@
   @RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
   public void getShopInfoV2(AcceptData acceptData, Integer page, Long id, Long uid, PrintWriter out) {
      
      if (Constant.IS_TEST) {
         getShopInfoV3(acceptData, page, id, uid, out);
         return;
      if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
         if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            getShopInfoV3(acceptData, page, id, uid, out);
            return;
         }
      } else {
         if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getShopInfoV3(acceptData, page, id, uid, out);
            return;
         }
      }
      
      if (id == null) {
@@ -411,12 +423,12 @@
      }
      
      List<TaoBaoShop> shopList = new ArrayList<TaoBaoShop>();
      List<SwiperPicture> topPicList = new ArrayList<>();
      List<BannerVO> topPicList = new ArrayList<>();
      
      JSONObject data = new JSONObject();
      if (page == 1) {
         // 2、顶部轮播图
         List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture");
         List<BannerVO> 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);
@@ -463,9 +475,9 @@
      List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
      // 先查询大淘客数据
      List<DaTaoKeDetail> listDaTaoKe = daTaoKeGoodsService.listBySellerId(0, pageSize, id);
      List<DaTaoKeDetailV2> listDaTaoKe = daTaoKeGoodsDetailV2Service.listBySellerId(0, pageSize, id);
      if (listDaTaoKe != null && listDaTaoKe.size() > 0) {
         for (DaTaoKeDetail daTaoKe : listDaTaoKe) {
         for (DaTaoKeDetailV2 daTaoKe : listDaTaoKe) {
            listGoodsBrief.add(TaoBaoUtil.convert(daTaoKe));
         }
      }
@@ -519,9 +531,8 @@
         Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
               .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
         BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
         BigDecimal shareRate = hongBaoManageService.getShareRate();
         ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
         ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
               acceptData.getVersion());
         // 商品信息过滤
         listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
@@ -563,9 +574,16 @@
    */
   @RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
   public void getHistoryV2(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
      if (Constant.IS_TEST) {
         getHistoryV3(acceptData, page, uid, type, out);
         return;
      if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
         if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
            getHistoryV3(acceptData, page, uid, type, out);
            return;
         }
      } else {
         if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
            getHistoryV3(acceptData, page, uid, type, out);
            return;
         }
      }
      
      if (type == null) {
@@ -644,12 +662,19 @@
         out.print(JsonUtil.loadFalseResult("页码不正确"));
         return;
      }
      if (cid != null && cid == 0) {
         cid = null;
      }
      
      JSONObject data = new JSONObject();
      if (page == 1  && cid == null) { // 精选页banner
         List<BannerVO> banners = swiperPictureService.getByBannerCardAndVersion("brand_banners",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
         if (banners == null)
            banners = new ArrayList<>();
         data.put("banners", JsonUtil.getApiCommonGson().toJson(banners));
      }
      if (page == 1 && cid != null) {
         List<BrandInfo> brandlist = brandInfoService.listValidByCidToApp(cid);
         if(brandlist == null)
@@ -657,10 +682,9 @@
         data.put("brandlist", JsonUtil.getApiCommonGson().toJson(brandlist));
      }
      
      long count = brandInfoService.countValidByCidToApp(cid);
      
      List<BrandInfoVO> list = brandInfoService.listValidToApp((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid);
      List<BrandInfoVO> list = brandInfoService.listValidToApp((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,acceptData.getPlatform(),acceptData.getVersion());
      if (list == null)
         list = new ArrayList<BrandInfoVO>();
      
@@ -693,12 +717,12 @@
         brandInfoRecordService.addRecord(id, uid, acceptData.getDevice());
      }
      
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
            .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
      
      ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
      ConfigParamsDTO paramsDTO =  orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion());
      JSONArray array = new JSONArray();
      
      List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId((page - 1) * 50, 50,id);
@@ -725,8 +749,8 @@
      JSONObject data = new JSONObject();
      if (page == 1 && array.size() > 0) {
         // 2、顶部轮播图
         List<SwiperPicture> topPicList = new ArrayList<>();
         List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture");
         List<BannerVO> topPicList = new ArrayList<>();
         List<BannerVO> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
         if (oldtopPicList != null && oldtopPicList.size() > 0)
            topPicList.addAll(oldtopPicList);
         
@@ -741,7 +765,7 @@
         data.put("shopList", JsonUtil.getApiCommonGson().toJson(shopList));
      }
      
      data.put("count", 50);
      data.put("count", array.size());
      data.put("list", array);
      out.print(JsonUtil.loadTrueResult(data));
   }