admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.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;
@@ -13,30 +12,25 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDSearchFilter;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.exception.jd.JDGoodsException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.homemodule.SpecialService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.jd.JDGoodsService;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.homemodule.BannerVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -52,7 +46,7 @@
public class JingDongControllerV2 {
   @Resource
   private HongBaoManageService hongBaoManageService;
   private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
   @Resource
   private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
@@ -62,25 +56,25 @@
   @Resource
   private DaTaoKeGoodsService daTaoKeGoodsService;
   @Resource
   private SwiperPictureService swiperPictureService;
   @Resource
   private QualityGoodsService qualityGoodsService;
   @Resource
   private ConfigService configService;
   @Resource
   private SpecialService specialService;
   @Resource
   private JDGoodsService jdGoodsService;
   /**
    * 京东专题分类
    *
    * @param acceptData
    * @param out
    */
@@ -88,13 +82,14 @@
   public void getJDClass(AcceptData acceptData, PrintWriter out) {
      JSONObject root = new JSONObject();
      root.put("list", jdGoodsService.getSpecialClass());
      root.put("jdLink", configService.get("jingdong_h5_link"));
      root.put("jdLink", configService.get(ConfigKeyEnum.jingdongH5Link.getKey()));
      out.print(JsonUtil.loadTrueResult(root));
   }
   /**
    * 京东专题
    * 京东专题 + 商品列表
    *
    * @param acceptData
    * @param out
    */
@@ -102,44 +97,41 @@
   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<BannerVO> topPicList = swiperPictureService.getByBannerCardAndVersion("jingdong_special_index",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
         if (topPicList == null) {
            topPicList = new ArrayList<SwiperPicture>();
            topPicList = new ArrayList<BannerVO>();
         }
         root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
         int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
         
         List<Special> listSpecial = specialService.listByPlaceKey("jingdong_special_index");
         List<Special> listSpecial = specialService.listByPlaceKey("jingdong_special_index", platformCode, Integer.parseInt(acceptData.getVersion()));
         if (listSpecial == null) {
            listSpecial = new ArrayList<Special>();
         }
         root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
      }
      try {
         JDSearchResult result = jdGoodsService.specialSearch(page, cid);
         List<JDGoods> goodsList = jdGoodsService.specialSearch(page, cid);
         JSONArray array = new JSONArray();
         JSONObject data = new JSONObject();
         if (result != null) {
            List<JDGoods> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
               BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
               BigDecimal shareRate = hongBaoManageService.getShareRate();
               Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                     .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
               for (JDGoods goods : goodsList) {
                  GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate,
                        shareRate);
                  array.add(gson.toJson(goodsDetailVO));
               }
         if (goodsList != null && goodsList.size() > 0) {
             ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                  acceptData.getVersion());
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                  .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            for (JDGoods goods : goodsList) {
               GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
               array.add(gson.toJson(goodsDetailVO));
            }
         }
         data.put("list", array);
         data.put("count", 1000);
         out.print(JsonUtil.loadTrueResult(data));
         root.put("list", array);
         root.put("count", 1000);
         out.print(JsonUtil.loadTrueResult(root));
      } catch (JDGoodsException e) {
         e.printStackTrace();
         out.print(JsonUtil.loadFalseResult(e.getMsg()));
      }
   }