| | |
| | | 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.dto.dataoke.DaTaoKeGoodsResult;
|
| | | 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.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | 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.dataoke.DaTaoKeApiUtil;
|
| | | 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<DaTaoKeDetailV2> detailList = null;
|
| | | if (cid == 1) {
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_HOT, null);
|
| | | if (result != null)
|
| | | detailList = result.getGoodsList();
|
| | |
|
| | | } else if (cid == 2) {
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_TIME, subId);
|
| | | if (result != null)
|
| | | detailList = result.getGoodsList();
|
| | | } else {
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_DAY, subId);
|
| | | if (result != null)
|
| | | detailList = result.getGoodsList();
|
| | | }
|
| | |
|
| | | if (detailList == null)
|
| | | detailList = new ArrayList<>();
|
| | |
|
| | | LogHelper.test("大淘客商品数据:" + detailList.size());
|
| | |
|
| | | List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | if (detailList != null)
|
| | | for (DaTaoKeDetailV2 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();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | 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.goods.facade.dto.taobao.dataoke.DaTaoKeGoodsResult; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; |
| | | import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2; |
| | | 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.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService; |
| | | import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil; |
| | | 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<DaTaoKeDetailV2> detailList = null; |
| | | if (cid == 1) { |
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_HOT, null); |
| | | if (result != null) |
| | | detailList = result.getGoodsList(); |
| | | |
| | | } else if (cid == 2) { |
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_TIME, subId); |
| | | if (result != null) |
| | | detailList = result.getGoodsList(); |
| | | } else { |
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_DAY, subId); |
| | | if (result != null) |
| | | detailList = result.getGoodsList(); |
| | | } |
| | | |
| | | if (detailList == null) |
| | | detailList = new ArrayList<>(); |
| | | |
| | | LogHelper.test("大淘客商品数据:" + detailList.size()); |
| | | |
| | | List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem()); |
| | | if (detailList != null) |
| | | for (DaTaoKeDetailV2 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(); |
| | | } |
| | | } |
| | | |
| | | } |