package com.yeshi.fanli.controller.client.v1;
|
|
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.springframework.web.bind.annotation.RequestMethod;
|
import org.yeshi.utils.JsonUtil;
|
|
import com.yeshi.fanli.entity.accept.AcceptData;
|
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
import com.yeshi.fanli.log.LogHelper;
|
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
|
import net.sf.json.JSONObject;
|
|
/**
|
* 热销榜
|
*
|
* @author Administrator
|
*
|
*/
|
@Controller
|
@RequestMapping("api/v1/hotsell")
|
public class HotSellController {
|
|
@Resource
|
private HongBaoManageService hongBaoManageService;
|
|
@Resource
|
private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
|
@Resource
|
private JumpDetailV2Service jumpDetailV2Service;
|
|
@Resource
|
private DaTaoKeGoodsService daTaoKeGoodsService;
|
|
/**
|
* 查询分类
|
*
|
* @param acceptData
|
* @param cid
|
* 2实时 3今日 1热销
|
* @param out
|
*/
|
@RequestMapping(value = "getClass", method = RequestMethod.POST)
|
public void getClass(AcceptData acceptData, Integer cid, PrintWriter out) {
|
try {
|
List<GoodsClass> list = new ArrayList<GoodsClass>();
|
if (cid == 2 || cid == 3) {
|
GoodsClass c0 = new GoodsClass();
|
c0.setId(0L);
|
c0.setName("全部");
|
list.addAll(DaTaoKeUtil.goodsClasses);
|
list.add(0, c0);
|
}
|
JSONObject data = new JSONObject();
|
data.put("count", 1);
|
data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
out.print(JsonUtil.loadTrueResult(data));
|
} catch (Exception e) {
|
out.print(JsonUtil.loadFalseResult("查询失败"));
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 获取动态列表
|
*
|
* @param acceptData
|
* @param page
|
* @param cid
|
* 主分类(实时-2 今日-3 热销-1)
|
* @param subId
|
* 子分类id
|
* @param out
|
*/
|
@RequestMapping(value = "getList", method = RequestMethod.POST)
|
public void getList(AcceptData acceptData, Integer page, Integer cid, Integer subId, PrintWriter out) {
|
try {
|
// 全部
|
if (subId != null && subId == 0)
|
subId = null;
|
|
TaoBaoGoodsBriefExtra goods = null;
|
List<DaTaoKeDetail> detailList = null;
|
if (cid == 1) {
|
detailList = daTaoKeGoodsService.getCurrentHotSalesRankGoodsList();
|
} else if (cid == 2) {
|
detailList = daTaoKeGoodsService.getCurrentSalesRankGoodsList(subId);
|
} else {
|
detailList = daTaoKeGoodsService.getCurrentDaySalesRankGoodsList(subId);
|
}
|
|
if (detailList == null)
|
detailList = new ArrayList<>();
|
|
LogHelper.test("大淘客商品数据:" + detailList.size());
|
|
List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
|
BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
if (detailList != null)
|
for (DaTaoKeDetail detail : detailList) {
|
goods = TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(detail), proportion.toString(),
|
null);
|
if (cid == 2)
|
goods.setSalesType(2);
|
else if (cid == 3)
|
goods.setSalesType(3);
|
else
|
goods.setSalesType(1);
|
list.add(goods);
|
}
|
|
LogHelper.test("最终商品数据:" + list.size());
|
JSONObject data = new JSONObject();
|
data.put("count", detailList.size());
|
data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
out.print(JsonUtil.loadTrueResult(data));
|
} catch (Exception e) {
|
out.print(JsonUtil.loadFalseResult("查询失败"));
|
e.printStackTrace();
|
}
|
}
|
|
}
|