package com.yeshi.fanli.controller.client.v2;
|
|
import java.io.PrintWriter;
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.yeshi.utils.JsonUtil;
|
|
import com.google.gson.Gson;
|
import com.yeshi.fanli.dto.ConfigParamsDTO;
|
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
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.exception.pdd.PDDOrderException;
|
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
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.lable.QualityGoodsService;
|
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
|
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
import com.yeshi.fanli.util.Constant;
|
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
/**
|
* 热销榜
|
*
|
* @author Administrator
|
*
|
*/
|
@Controller
|
@RequestMapping("api/v2/pdd")
|
public class PinDuoDuoControllerV2 {
|
|
@Resource
|
private HongBaoManageService hongBaoManageService;
|
|
@Resource
|
private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
|
@Resource
|
private JumpDetailV2Service jumpDetailV2Service;
|
|
@Resource
|
private DaTaoKeGoodsService daTaoKeGoodsService;
|
|
@Resource
|
private SwiperPictureService swiperPictureService;
|
|
@Resource
|
private QualityGoodsService qualityGoodsService;
|
|
@Resource
|
private SpecialService specialService;
|
|
@Resource
|
private PDDGoodsService pddGoodsService;
|
|
|
|
/**
|
* 拼多多专题分类
|
* @param acceptData
|
* @param out
|
*/
|
@RequestMapping(value = "getClass")
|
public void getJDClass(AcceptData acceptData, PrintWriter out) {
|
JSONObject root = new JSONObject();
|
root.put("list", pddGoodsService.getSpecialClass());
|
out.print(JsonUtil.loadTrueResult(root));
|
}
|
|
|
/**
|
* 拼多多专题
|
* @param acceptData
|
* @param out
|
*/
|
@RequestMapping(value = "getGoodsInfo")
|
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");
|
if (topPicList == null) {
|
topPicList = new ArrayList<SwiperPicture>();
|
}
|
root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
|
int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
List<Special> listSpecial = specialService.listByPlaceKey("pinduoduo_special_index", platformCode, Integer.parseInt(acceptData.getVersion()));
|
if (listSpecial == null) {
|
listSpecial = new ArrayList<Special>();
|
}
|
root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
|
}
|
|
try {
|
List<PDDGoodsDetail> goodsList = pddGoodsService.specialSearch(page, cid);
|
JSONArray array = new JSONArray();
|
if (goodsList != null && goodsList.size() > 0) {
|
Gson gson = JsonUtil.getApiCommonGson();
|
BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
BigDecimal shareRate = hongBaoManageService.getShareRate();
|
ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
|
for (PDDGoodsDetail goods : goodsList) {
|
GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
|
array.add(gson.toJson(goodsDetailVO));
|
}
|
}
|
root.put("list", array);
|
root.put("count", 1000);
|
out.print(JsonUtil.loadTrueResult(root));
|
} catch (PDDOrderException e) {
|
out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
}
|
}
|
|
}
|