| | |
| | | goodsType = null;
|
| | | }
|
| | |
|
| | | |
| | | /* 今日订单统计 */
|
| | | Map<String, BigDecimal> countToday = commonOrderService.countHistoryOrder(uid, 1, goodsType);
|
| | |
|
| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.common.CommonContentNav;
|
| | | import com.yeshi.fanli.dto.common.CommonContentResult;
|
| | | import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.common.PDDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | 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.service.inter.goods.CommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | |
| | | @Resource
|
| | | private CommonTemplateContentService commonTemplateContentService;
|
| | |
|
| | | @Resource
|
| | | private JDCommonTemplateContentService jdCommonTemplateContentService;
|
| | |
|
| | | @Resource
|
| | | private PDDCommonTemplateContentService pddCommonTemplateContentService;
|
| | |
|
| | | |
| | | /**
|
| | | * 通用模板导航
|
| | | * |
| | | * @param acceptData
|
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNavList", method = RequestMethod.POST)
|
| | | public void getNavList(AcceptData acceptData, String key, Integer goodsType, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<CommonContentNav> list = null;
|
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key));
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | |
| | | }
|
| | | |
| | | if (list == null) {
|
| | | list = new ArrayList<CommonContentNav>();
|
| | | }
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(new Gson().toJson(list)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取内容
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST)
|
| | | public void getNavContent(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
|
| | | public void getNavContent(AcceptData acceptData, String key, Integer goodsType, Integer page, String cid, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key"));
|
| | | return;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | getListTB(acceptData, key, page, cid, out);
|
| | | return;
|
| | | }
|
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | getListJD(acceptData, key, page, cid, out);
|
| | | return;
|
| | | }
|
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | getListPDD(acceptData, key, page, cid, out);
|
| | | return;
|
| | | }
|
| | | out.print(JsonUtil.loadFalseResult("goodsType参数不正确"));
|
| | | }
|
| | |
|
| | | |
| | | private void getListTB(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
|
| | | CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key),
|
| | | cid, page, Constant.PAGE_SIZE);
|
| | |
|
| | |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate)));
|
| | | }
|
| | | root.put("goodsList", array);
|
| | | root.put("goodsCount", result.getCount());
|
| | | |
| | | root.put("list", array);
|
| | | root.put("count", result.getCount());
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 京东通用专题模板
|
| | | * @param acceptData
|
| | | * @param key
|
| | | * @param page
|
| | | * @param cid
|
| | | * @param out
|
| | | */
|
| | | public void getListJD(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> bannerList = new ArrayList<>();
|
| | | data.put("bannerList", new Gson().toJson(bannerList));
|
| | | }
|
| | |
|
| | | JDSearchResult result = jdCommonTemplateContentService.getContentList(JDCommonContentTypeEnum.valueOf(key), cid, page, Constant.PAGE_SIZE);
|
| | | JSONArray array = new JSONArray();
|
| | | |
| | | long count = 0;
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | | |
| | | 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) {
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate)));
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 拼多多通用专题模板
|
| | | * @param acceptData
|
| | | * @param key
|
| | | * @param page
|
| | | * @param cid
|
| | | * @param out
|
| | | */
|
| | | public void getListPDD(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> bannerList = new ArrayList<>();
|
| | | data.put("bannerList", new Gson().toJson(bannerList));
|
| | | }
|
| | | |
| | | PDDGoodsResult result = pddCommonTemplateContentService.getContentList(PDDCommonContentTypeEnum.valueOf(key), cid, page, Constant.PAGE_SIZE);
|
| | | JSONArray array = new JSONArray();
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | | count = result.getTotalCount();
|
| | | |
| | | List<PDDGoodsDetail> 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 (PDDGoodsDetail goods : goodsList) {
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate)));
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | // 图文详情
|
| | | extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id="+ id);
|
| | |
|
| | | Long inOrderCount30Days = pddGoods.getSoldQuantity();
|
| | | String salesTip = pddGoods.getSalesTip();
|
| | | if (!StringUtil.isNullOrEmpty(salesTip)) {
|
| | | int totalSales = 0;
|
| | | if (salesTip.contains("万")) {
|
| | | salesTip = salesTip.substring(0, salesTip.indexOf("万"));
|
| | | totalSales= (int) (Float.parseFloat(salesTip) * 10000);
|
| | | } else {
|
| | | totalSales = Integer.parseInt(salesTip);
|
| | | }
|
| | | |
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>();
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | if (moneyInfo != null) {
|
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
|
| | | if (Integer.parseInt(inOrderCount30Days.toString()) >= 50000) {
|
| | | if (totalSales >= 50000) {
|
| | | listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
|
| | | if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 50000) {
|
| | | if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | | extraVO.setListCouponUser(listCouponUser);
|
| | | }
|
| | |
|
| | | if (uid != null) {
|
| | | // 是否加入收藏
|
| | |
| | |
|
| | | 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.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.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.jd.JDGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | 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 net.sf.json.JSONArray;
|
| | |
| | |
|
| | |
|
| | | /**
|
| | | * 京东专题
|
| | | * 京东专题 + 商品列表
|
| | | * @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) {
|
| | | // if (cid == 1 && page == 1) {
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jingdong_special_index");
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | |
| | | 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();
|
| | |
| | | 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()));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | 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.taobao.TaoBaoGoodsBrief;
|
| | | 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.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
| | | 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;
|
| | |
| | | @Resource
|
| | | private SpecialService specialService;
|
| | |
|
| | | @Resource
|
| | | private PDDGoodsService pddGoodsService;
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @RequestMapping(value = "getClass")
|
| | | public void getJDClass(AcceptData acceptData, PrintWriter out) {
|
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | | list.add(new GoodsClass(1L, "精选"));
|
| | | list.add(new GoodsClass(2L, "清仓"));
|
| | | list.add(new GoodsClass(3L, "百货"));
|
| | | list.add(new GoodsClass(4L, "母婴"));
|
| | | list.add(new GoodsClass(5L, "食品"));
|
| | | list.add(new GoodsClass(6L, "女装"));
|
| | | list.add(new GoodsClass(7L, "电器"));
|
| | | list.add(new GoodsClass(8L, "鞋包"));
|
| | | list.add(new GoodsClass(9L, "内衣"));
|
| | | list.add(new GoodsClass(10L, "美妆"));
|
| | | list.add(new GoodsClass(11L, "男装"));
|
| | | list.add(new GoodsClass(12L, "汽车"));
|
| | | list.add(new GoodsClass(13L, "水果"));
|
| | | list.add(new GoodsClass(14L, "家居"));
|
| | | list.add(new GoodsClass(15L, "文具"));
|
| | | list.add(new GoodsClass(16L, "运动"));
|
| | | list.add(new GoodsClass(17L, "虚拟"));
|
| | | list.add(new GoodsClass(18L, "医药"));
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("list", list);
|
| | | root.put("list", pddGoodsService.getSpecialClass());
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGoodsInfo")
|
| | | public void getGoodsInfo(AcceptData acceptData, Integer cid, Integer page, PrintWriter out) {
|
| | | public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) {
|
| | | JSONObject root = new JSONObject();
|
| | | if (cid == 1 && page == 1) {
|
| | | // if (cid == 1 && page == 1) {
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("pinduoduo_special_index");
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | |
| | | root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
|
| | | }
|
| | |
|
| | | List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * 20, 20);
|
| | | if (listQuery == null) {
|
| | | listQuery = new ArrayList<QualityFactory>();
|
| | | }
|
| | |
|
| | | try {
|
| | | List<PDDGoodsDetail> goodsList = pddGoodsService.specialSearch(page, cid);
|
| | | JSONArray array = new JSONArray();
|
| | | if (listQuery.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | |
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | for (QualityFactory qualityFactory : listQuery) {
|
| | | TaoBaoGoodsBrief goods = qualityFactory.getTaoBaoGoodsBrief();
|
| | | if (goods == null) {
|
| | | continue;
|
| | | }
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate)));
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate,
|
| | | shareRate);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | long count = qualityGoodsService.countFreeGoods();
|
| | | |
| | | root.put("count", count);
|
| | | root.put("list", array);
|
| | | root.put("count", 1000);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | } catch (PDDOrderException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | 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.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGoodList")
|
| | | public void getGoodList(AcceptData acceptData, Integer goodsType, Integer page,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | public void getGoodList(AcceptData acceptData, Integer goodsType, Integer page, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | if (goodsType == null || page == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数信息不正常"));
|
| | |
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | |
| | | getIndexJDGoods(acceptData, page, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | |
| | | searchPDDGoods(acceptData, page, out);
|
| | | return;
|
| | | }
|
| | | |
| | | List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * 20, 20);
|
| | | if (listQuery == null) {
|
| | | listQuery = new ArrayList<QualityFactory>();
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | if (listQuery.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | |
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | for (QualityFactory qualityFactory : listQuery) {
|
| | | TaoBaoGoodsBrief goods = qualityFactory.getTaoBaoGoodsBrief();
|
| | | if (goods == null) {
|
| | | continue;
|
| | | }
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate)));
|
| | | }
|
| | | }
|
| | | long count = qualityGoodsService.countFreeGoods();
|
| | | |
| | | JSONObject root = new JSONObject();
|
| | | root.put("count", count);
|
| | | root.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | out.print(JsonUtil.loadFalseResult("商品类型错误"));
|
| | | }
|
| | |
|
| | |
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 京东首页商品
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | private void getIndexJDGoods(AcceptData acceptData, int page, PrintWriter out) {
|
| | | JDSearchResult result = null;
|
| | | String way = configService.get("jd_api_search_key");
|
| | | if ("1".equals(way)) {
|
| | | JDFilter filterAPI = new JDFilter();
|
| | | filterAPI.setPageIndex(page);
|
| | | filterAPI.setPageSize(20);
|
| | | result = JDApiUtil.queryByKey(filterAPI);
|
| | | } else {
|
| | | // 网页爬取
|
| | | JDSearchFilter jdfilter = new JDSearchFilter();
|
| | | jdfilter.setPageNo(page);
|
| | | jdfilter.setPageSize(Constant.PAGE_SIZE);
|
| | | result = JDUtil.searchByKey(jdfilter);
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | |
|
| | | 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));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 爆款排行商品-实时热销榜
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | private void searchPDDGoods(AcceptData acceptData, int page, PrintWriter out) {
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page-1, Constant.PAGE_SIZE, 1);
|
| | | |
| | | int count = 0;
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | count = result.getTotalCount();
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | |
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate,
|
| | | shareRate);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | }
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 京东
|
| | | * 拼多多
|
| | | *
|
| | | * @param kw
|
| | | * @param page
|
| | |
| | | shareInfo.setRule(configService.get("share_rule_link_jd"));
|
| | | shareInfo.setPictUrl(jdGoods.getPicUrl());
|
| | |
|
| | | String owner = jdGoods.getOwner();
|
| | | if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | | shareInfo.setJdZY(true);
|
| | | }
|
| | | |
| | |
|
| | | String shareText = "";
|
| | | boolean hasCoupon = false;
|
| | | // 分享模板
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | |
|
| | |
| | | public class GoodsOtherInfoDTO {
|
| | | private String owner;// 京东- g=自营,p=pop
|
| | | private JDPingouInfo pinGouInfo;// 京东-拼购信息
|
| | | private Integer isFreeShipping; // 是否包邮(1:是,0:否,2:自营商品遵从主站包邮规则)
|
| | |
|
| | | public String getOwner() {
|
| | | return owner;
|
| | | }
|
| | |
|
| | | public void setOwner(String owner) {
|
| | | this.owner = owner;
|
| | | }
|
| | |
|
| | | public JDPingouInfo getPinGouInfo() {
|
| | | return pinGouInfo;
|
| | | }
|
| | |
|
| | | public void setPinGouInfo(JDPingouInfo pinGouInfo) {
|
| | | this.pinGouInfo = pinGouInfo;
|
| | | }
|
| | |
|
| | | public Integer getIsFreeShipping() {
|
| | | return isFreeShipping;
|
| | | }
|
| | |
|
| | | public void setIsFreeShipping(Integer isFreeShipping) {
|
| | | this.isFreeShipping = isFreeShipping;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.common;
|
| | |
|
| | | public enum JDCommonContentTypeEnum {
|
| | |
|
| | | _9k9("9.9包邮"), jdPeiSong("京东配送"), jiaDian("精选家电"), baiHuo("百货超市"), juJia("居家生活");
|
| | | private final String desc;
|
| | |
|
| | | private JDCommonContentTypeEnum(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.common;
|
| | |
|
| | | public enum PDDCommonContentTypeEnum {
|
| | |
|
| | | _1k9("1.9包邮", "0"), todayTop("今日爆款", "1"), brandClear("品牌清仓", "2");
|
| | | private final String desc;
|
| | | private final String content;
|
| | | |
| | | private PDDCommonContentTypeEnum(String desc, String content) {
|
| | | this.desc = desc;
|
| | | this.content = content;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | public String getContent() {
|
| | | return content;
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.dto.pdd;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.google.gson.annotations.SerializedName;
|
| | |
|
| | | public class PDDGoodsDetail {
|
| | | public class PDDGoodsDetail implements Serializable {
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | |
| | | @SerializedName("goods_id")
|
| | | private Long goodsId;// 商品id
|
| | | @SerializedName("has_mall_coupon")
|
| | |
| | | this.shareCouponTextTemplate = shareCouponTextTemplate;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public String getShareTaoLiJinTextTemplate() {
|
| | | return shareTaoLiJinTextTemplate;
|
| | | }
|
| | |
| | | public void setSharePDDTextTemplateCoupon(String sharePDDTextTemplateCoupon) {
|
| | | this.sharePDDTextTemplateCoupon = sharePDDTextTemplateCoupon;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | private String owner;// g=自营,p=pop
|
| | | private JDPingouInfo pinGouInfo;// 拼购信息
|
| | | private Long totalCount;// 有效商品总数量
|
| | | private Integer isFreeShipping; // 是否包邮(1:是,0:否,2:自营商品遵从主站包邮规则)
|
| | | |
| | |
|
| | | public JDCategoryInfo getCategoryInfo() {
|
| | | return categoryInfo;
|
| | |
| | | public void setPicUrl(String picUrl) {
|
| | | this.picUrl = picUrl;
|
| | | }
|
| | |
|
| | | public Integer getIsFreeShipping() {
|
| | | return isFreeShipping;
|
| | | }
|
| | |
|
| | | public void setIsFreeShipping(Integer isFreeShipping) {
|
| | | this.isFreeShipping = isFreeShipping;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.pdd;
|
| | |
|
| | | public class PDDGoodsException extends Exception {
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | private int code;
|
| | | private String msg;
|
| | |
|
| | | public int getCode() {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public String getMsg() {
|
| | | return msg;
|
| | | }
|
| | |
|
| | | public PDDGoodsException(int code, String msg) {
|
| | | this.code = code;
|
| | | this.msg = msg;
|
| | | }
|
| | |
|
| | | public PDDGoodsException() {
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getMessage() {
|
| | | return this.msg;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | </if>
|
| | | <if test="shareTaoLiJinTextTemplate != null">st_share_taolijin_text_template=#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="st_share_jd_text_template != null">st_share_jd_text_template=#{st_share_jd_text_template,jdbcType=VARCHAR},
|
| | | <if test="shareJDTextTemplate != null">st_share_jd_text_template=#{shareJDTextTemplate,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="shareJDTextTemplateCoupon != null">st_share_jd_text_template_coupon=#{shareJDTextTemplateCoupon,jdbcType=VARCHAR},
|
| | | </if>
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | |
|
| | | @Service
|
| | | public class JDCommonTemplateContentServiceImpl implements JDCommonTemplateContentService {
|
| | |
|
| | | private Map<String, Long> countMap = new HashMap<String, Long>();
|
| | | |
| | |
|
| | | @Cacheable(value = "jdCommonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | | public JDSearchResult getContentList(JDCommonContentTypeEnum type, String cid, int page, int pageSize) {
|
| | | if (type == JDCommonContentTypeEnum._9k9) {
|
| | | return get9K9Content(cid, page, pageSize);
|
| | | } else if (type == JDCommonContentTypeEnum.jdPeiSong) {
|
| | | return getJDPeiSongContent(cid, page, pageSize);
|
| | | } else if (type == JDCommonContentTypeEnum.jiaDian) {
|
| | | return getJiaDianContent(cid, page, pageSize);
|
| | | } else if (type == JDCommonContentTypeEnum.baiHuo) {
|
| | | return getBaiHuoContent(cid, page, pageSize);
|
| | | } else if (type == JDCommonContentTypeEnum.juJia) {
|
| | | return getJuJiaContent(cid, page, pageSize);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private JDSearchResult get9K9Content(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {10, 17};
|
| | | return getJingFenGoods(page, pageSize, "9k9-", arrayId);
|
| | | }
|
| | | |
| | | private JDSearchResult getJDPeiSongContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {15, 18};
|
| | | return getJingFenGoods(page, pageSize, "peisong-", arrayId);
|
| | | }
|
| | | |
| | | private JDSearchResult getJiaDianContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {5, 2};
|
| | | return getJingFenGoods(page, pageSize, "jiadian-", arrayId);
|
| | | }
|
| | | |
| | | private JDSearchResult getBaiHuoContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {6, 3};
|
| | | return getJingFenGoods(page, pageSize, "baihuo-", arrayId);
|
| | | }
|
| | | |
| | | private JDSearchResult getJuJiaContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {7, 4};
|
| | | return getJingFenGoods(page, pageSize, "jujia-", arrayId);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 9快9包邮
|
| | | * |
| | | * @param cid
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | private JDSearchResult getJingFenGoods(int page, int pageSize, String mapKey, int[] arrayId) {
|
| | | int pageTemp = 0;
|
| | | long addCount = 0;
|
| | | Integer categoryId = null;
|
| | | long totalCount = (long) (page * Constant.PAGE_SIZE);
|
| | | for (int i = 0; i < arrayId.length; i++) {
|
| | | Long count = countMap.get(mapKey + arrayId[i]);
|
| | | if (count != null) {
|
| | | addCount += count;
|
| | | }
|
| | | |
| | | if (count != null && totalCount > addCount) {
|
| | | pageTemp = (int)(addCount / Constant.PAGE_SIZE);
|
| | | continue; // 当前分类商品不足
|
| | | } else {
|
| | | page = page - pageTemp; |
| | | categoryId = arrayId[i];
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (categoryId == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | JDSearchResult result = JDApiUtil.getJingFenGoods(page, categoryId);
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | | }
|
| | | |
| | | long mcount = (count/Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
|
| | | if (mcount == 0) {
|
| | | mcount = 20;
|
| | | }
|
| | | countMap.put(mapKey + categoryId, mcount);
|
| | | return result;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.common.PDDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | |
|
| | | @Service
|
| | | public class PDDCommonTemplateContentServiceImpl implements PDDCommonTemplateContentService {
|
| | |
|
| | | @Cacheable(value = "pddCommonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | | public PDDGoodsResult getContentList(PDDCommonContentTypeEnum type, String cid, int page, int pageSize) {
|
| | | if (type == PDDCommonContentTypeEnum._1k9 || type == PDDCommonContentTypeEnum.todayTop |
| | | || type == PDDCommonContentTypeEnum.brandClear) {
|
| | | return PinDuoDuoApiUtil.searchByChannelType(page - 1, pageSize, type.getContent());
|
| | | } |
| | | return null;
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.jd;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | 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.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class JDGoodsServiceImpl implements JDGoodsService {
|
| | |
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | |
|
| | | private Map<String, Long> countMap = new HashMap<String, Long>();
|
| | | private static final Map<Long, String> cidMap = new HashMap<Long, String>();
|
| | | private static final Map<String, Long> countMap = new HashMap<String, Long>();
|
| | |
|
| | | static {
|
| | | cidMap.put(1L, "nzjh");// 精选
|
| | | cidMap.put(1L, "2,16,1,3");// 精选
|
| | | cidMap.put(2L, "737");// 电器: 家用电器
|
| | | cidMap.put(3L, "652,670");// 数码: 数码/电脑、办公
|
| | | cidMap.put(4L, "9987");// 手机:手机通讯
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | |
| | | @Cacheable(value = "jdSpecialCache", key = "'specialSearch-'+#page+'-'+#cid")
|
| | | @Override
|
| | | @Transactional
|
| | | public JDSearchResult specialSearch(Integer page, Long cid) throws JDGoodsException{
|
| | | public List<JDGoods> specialSearch(Integer page, Long cid) throws JDGoodsException{
|
| | | if (cid == null) {
|
| | | throw new JDGoodsException(1, "分类id为空");
|
| | | }
|
| | |
| | | throw new JDGoodsException(1, "分类id不存在");
|
| | | }
|
| | |
|
| | | Long jdCid1 = null;
|
| | | // 精选
|
| | | if (cid == 1) {
|
| | | Integer categoryId = null;
|
| | | int pageTemp = 0;
|
| | | long addCount = 0;
|
| | | long totalCount = (long) (page * Constant.PAGE_SIZE);
|
| | | |
| | | |
| | | if (jdcid.contains(",")) {
|
| | | String[] arrayId = jdcid.split(",");
|
| | | for (int i = 0; i < arrayId.length; i++) {
|
| | | Long count = countMap.get(cid + "" + arrayId[i]);
|
| | | if (count != null && totalCount > count) {
|
| | | String id = arrayId[i];
|
| | | Long count = countMap.get(cid + "-" + id);
|
| | | if (count != null) {
|
| | | addCount += count;
|
| | | }
|
| | | |
| | | if (count != null && totalCount > addCount) {
|
| | | pageTemp = (int)(addCount / Constant.PAGE_SIZE);
|
| | | continue; // 当前分类商品不足
|
| | | } else {
|
| | | jdCid1 = Long.parseLong(jdcid);
|
| | | categoryId = Integer.parseInt(jdcid);
|
| | | page = page - pageTemp; |
| | | categoryId = Integer.parseInt(id);
|
| | | break;
|
| | | }
|
| | | }
|
| | | } else {
|
| | | jdCid1 = Long.parseLong(jdcid);
|
| | | categoryId = Integer.parseInt(jdcid);
|
| | | }
|
| | |
|
| | | |
| | | // 搜索
|
| | | JDSearchResult result = null;
|
| | | String way = configService.get("jd_api_search_key");
|
| | | if ("1".equals(way)) { // API搜索
|
| | | JDFilter filterAPI = new JDFilter();
|
| | | filterAPI.setPageIndex(page);
|
| | | filterAPI.setPageSize(Constant.PAGE_SIZE);
|
| | | filterAPI.setCid1(jdCid1);
|
| | | result = JDApiUtil.queryByKey(filterAPI);
|
| | | } else { // 网页爬取
|
| | | JDSearchFilter jdfilter = new JDSearchFilter();
|
| | | jdfilter.setPageNo(page);
|
| | | jdfilter.setPageSize(Constant.PAGE_SIZE);
|
| | | jdfilter.setCategoryId(categoryId);
|
| | | result = JDUtil.searchByKey(jdfilter);
|
| | | if (categoryId == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | JDSearchResult result = JDApiUtil.getJingFenGoods(page, categoryId);
|
| | |
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | | }
|
| | | countMap.put(cid + "" + jdCid1, count);
|
| | |
|
| | | return result;
|
| | | long mcount = (count/Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
|
| | | if (mcount == 0) {
|
| | | mcount = 20;
|
| | | }
|
| | | countMap.put(cid + "-" + categoryId, mcount);
|
| | | |
| | | if (result == null) {
|
| | | return null;
|
| | | } else {
|
| | | return result.getGoodsList();
|
| | | }
|
| | | } |
| | | |
| | | |
| | | if (!jdcid.contains(",")) {
|
| | | return search(page, Constant.PAGE_SIZE, jdcid);
|
| | | } |
| | | |
| | | // 多个分类id处理
|
| | | List<JDGoods> list = new ArrayList<JDGoods>();
|
| | | String[] arrayId = jdcid.split(",");
|
| | | for (int i = 0; i < arrayId.length; i++) {
|
| | | if (i >= 3) {
|
| | | break;
|
| | | }
|
| | | List<JDGoods> listGoods = search(page, 10, arrayId[i]);
|
| | | if (listGoods != null && listGoods.size() > 0) {
|
| | | list.addAll(listGoods);
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | |
| | | private List<JDGoods> search(int page, int pageSize, String jdcid) {
|
| | | JDSearchResult result = null;
|
| | | String way = configService.get("jd_api_search_key");
|
| | | if ("1".equals(way)) { // API搜索
|
| | | JDFilter filterAPI = new JDFilter();
|
| | | filterAPI.setPageIndex(page);
|
| | | filterAPI.setPageSize(pageSize);
|
| | | filterAPI.setCid1(Long.parseLong(jdcid));
|
| | | result = JDApiUtil.queryByKey(filterAPI);
|
| | | } else { // 网页爬取
|
| | | JDSearchFilter jdfilter = new JDSearchFilter();
|
| | | jdfilter.setPageNo(page);
|
| | | jdfilter.setPageSize(pageSize);
|
| | | jdfilter.setCategoryId(Integer.parseInt(jdcid));
|
| | | result = JDUtil.searchByKey(jdfilter);
|
| | | }
|
| | | |
| | | if (result == null) {
|
| | | return null;
|
| | | } else {
|
| | | return result.getGoodsList();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.pdd;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.exception.pdd.PDDOrderException;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | |
|
| | | @Service
|
| | | public class PDDGoodsServiceImpl implements PDDGoodsService {
|
| | |
|
| | | private static final Map<Long, String> cidMap = new HashMap<Long, String>();
|
| | |
|
| | | static {
|
| | | cidMap.put(1L, "0");// 精选
|
| | | cidMap.put(2L, "-11");// 清仓
|
| | | cidMap.put(3L, "15");// 百货
|
| | | cidMap.put(4L, "4");// 母婴
|
| | | cidMap.put(5L, "1");// 食品
|
| | | cidMap.put(6L, "14");// 女装
|
| | | cidMap.put(7L, "18");// 电器
|
| | | cidMap.put(8L, "1281");// 鞋包
|
| | | cidMap.put(9L, "1282");// 内衣
|
| | | cidMap.put(10L, "16");// 美妆
|
| | | cidMap.put(11L, "743");// 男装
|
| | | cidMap.put(12L, "2048");// 汽车
|
| | | cidMap.put(13L, "13");// 水果
|
| | | cidMap.put(14L, "818,1917,2974");// 家居:家纺、家装 家具
|
| | | cidMap.put(15L, "2478");// 文具
|
| | | cidMap.put(16L, "1451");// 运动
|
| | | cidMap.put(17L, "590");// 虚拟
|
| | | cidMap.put(18L, "3297");// 医药
|
| | | }
|
| | | |
| | |
|
| | | @Cacheable(value = "pddCache", key = "'getDetailImageList'+#id")
|
| | | @Override
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<GoodsClass> getSpecialClass() {
|
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | | list.add(new GoodsClass(1L, "精选"));
|
| | | list.add(new GoodsClass(2L, "清仓"));
|
| | | list.add(new GoodsClass(3L, "百货"));
|
| | | list.add(new GoodsClass(4L, "母婴"));
|
| | | list.add(new GoodsClass(5L, "食品"));
|
| | | list.add(new GoodsClass(6L, "女装"));
|
| | | list.add(new GoodsClass(7L, "电器"));
|
| | | list.add(new GoodsClass(8L, "鞋包"));
|
| | | list.add(new GoodsClass(9L, "内衣"));
|
| | | list.add(new GoodsClass(10L, "美妆"));
|
| | | list.add(new GoodsClass(11L, "男装"));
|
| | | list.add(new GoodsClass(12L, "汽车"));
|
| | | list.add(new GoodsClass(13L, "水果"));
|
| | | list.add(new GoodsClass(14L, "家居"));
|
| | | list.add(new GoodsClass(15L, "文具"));
|
| | | list.add(new GoodsClass(16L, "运动"));
|
| | | list.add(new GoodsClass(17L, "虚拟"));
|
| | | list.add(new GoodsClass(18L, "医药"));
|
| | | return list; |
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional
|
| | | @Cacheable(value = "pddSpecialCache", key = "'specialSearch-'+#page+'-'+#cid")
|
| | | public List<PDDGoodsDetail> specialSearch(Integer page, Long cid) throws PDDOrderException{
|
| | | if (cid == null) {
|
| | | throw new PDDOrderException(1, "分类id为空");
|
| | | }
|
| | | |
| | | String pddcid = cidMap.get(cid);
|
| | | if (StringUtil.isNullOrEmpty(pddcid)) {
|
| | | throw new PDDOrderException(1, "分类id不存在");
|
| | | }
|
| | | |
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | |
| | | // 精选
|
| | | if (cid == 1) {
|
| | | pddfilter.setPage(page);
|
| | | pddfilter.setPageSize(Constant.PAGE_SIZE);
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result == null) {
|
| | | return null;
|
| | | } else {
|
| | | return result.getGoodsList();
|
| | | }
|
| | | } |
| | | |
| | | // 单个分类
|
| | | if (!pddcid.contains(",")) {
|
| | | pddfilter.setPage(page);
|
| | | pddfilter.setPageSize(Constant.PAGE_SIZE);
|
| | | pddfilter.setOptId(Long.parseLong(pddcid));
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result == null) {
|
| | | return null;
|
| | | } else {
|
| | | return result.getGoodsList();
|
| | | }
|
| | | } |
| | | |
| | | // 多个分类id处理
|
| | | List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>();
|
| | | String[] arrayId = pddcid.split(",");
|
| | | for (int i = 0; i < arrayId.length; i++) {
|
| | | if (i >= 3) {
|
| | | break;
|
| | | }
|
| | | pddfilter.setPage(page);
|
| | | pddfilter.setPageSize(10);
|
| | | pddfilter.setOptId(Long.parseLong(arrayId[i]));
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result != null) {
|
| | | List<PDDGoodsDetail> listGoods = result.getGoodsList();
|
| | | if (listGoods != null && listGoods.size() > 0) {
|
| | | list.addAll(listGoods);
|
| | | }
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.goods;
|
| | |
|
| | | import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | |
|
| | | /**
|
| | | * 商品模板内容服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface JDCommonTemplateContentService {
|
| | |
|
| | | public JDSearchResult getContentList(JDCommonContentTypeEnum type, String cid, int page, int pageSize);
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.goods;
|
| | |
|
| | | import com.yeshi.fanli.dto.common.PDDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | |
|
| | | /**
|
| | | * 商品模板内容服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface PDDCommonTemplateContentService {
|
| | |
|
| | | public PDDGoodsResult getContentList(PDDCommonContentTypeEnum type, String cid, int page, int pageSize);
|
| | | |
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.exception.jd.JDGoodsException;
|
| | |
|
| | | public interface JDGoodsService {
|
| | |
| | | * @return
|
| | | * @throws JDGoodsException
|
| | | */
|
| | | public JDSearchResult specialSearch(Integer page, Long cid) throws JDGoodsException;
|
| | | public List<JDGoods> specialSearch(Integer page, Long cid) throws JDGoodsException;
|
| | |
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.exception.pdd.PDDOrderException;
|
| | |
|
| | | /**
|
| | | * 拼多多商品服务
|
| | | *
|
| | |
| | | */
|
| | | public List<String> getDetailImageList(Long id);
|
| | |
|
| | | /**
|
| | | * 专题分类
|
| | | * @return
|
| | | */
|
| | | public List<GoodsClass> getSpecialClass();
|
| | |
|
| | | /**
|
| | | * 分类商品
|
| | | * @param page
|
| | | * @param cid
|
| | | * @return
|
| | | * @throws PDDOrderException
|
| | | */
|
| | | public List<PDDGoodsDetail> specialSearch(Integer page, Long cid) throws PDDOrderException;
|
| | |
|
| | | }
|
| | |
| | | GoodsOtherInfoDTO other = new GoodsOtherInfoDTO();
|
| | | other.setOwner(owner); // 是否自营
|
| | | other.setPinGouInfo( goods.getPinGouInfo()); // 拼购信息
|
| | | other.setIsFreeShipping(goods.getIsFreeShipping()); // 是否包邮
|
| | | cg.setOtherInfo(JSONObject.toJSON(other).toString());
|
| | |
|
| | | // 保留字段
|
| | |
| | | salesTip = "0";
|
| | | }
|
| | |
|
| | | int totalSales = 0;
|
| | | if (salesTip.contains("万")) {
|
| | | salesTip = salesTip.replace("万", "") + "0000";
|
| | | salesTip = salesTip.substring(0, salesTip.indexOf("万"));
|
| | | totalSales= (int) (Float.parseFloat(salesTip) * 10000);
|
| | | } else {
|
| | | totalSales = Integer.parseInt(salesTip);
|
| | | }
|
| | | cg.setSales(Integer.parseInt(salesTip));
|
| | | cg.setSales(totalSales);
|
| | | cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10)));
|
| | | cg.setSellerId(goods.getMallId());
|
| | | cg.setSellerName(goods.getMallName());
|
| | |
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | // 月销量
|
| | | goodsInfo.setSalesType(1);
|
| | | |
| | | Integer isFreeShipping = otherDTO.getIsFreeShipping();
|
| | | if (isFreeShipping != null && isFreeShipping == 1) {
|
| | | goodsInfo.setBaoyou(true);
|
| | | }
|
| | | |
| | | // 自营
|
| | | String owner = otherDTO.getOwner();
|
| | | if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
|
| | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD){
|
| | | goodsInfo.setSalesType(4); // 总销量
|
| | | goodsInfo.setPriceName("拼团价");
|
| | | goodsInfo.setBaoyou(true);
|
| | | } else {
|
| | | goodsInfo.setSalesType(1); // 月销量
|
| | | goodsInfo.setBaoyou(true);
|
| | | }
|
| | |
|
| | | goodsInfo.setGoodsType(goodsType);
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | return goodsInfo;
|
| | | }
|
| | |
|
| | |
| | | public static GoodsDetailVO convertTaoBaoGoodsBriefExtra(TaoBaoGoodsBriefExtra goods, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setBaoyou(true);
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | goodsInfo.setGoodsId(goods.getAuctionId());
|
| | | goodsInfo.setTitle(goods.getTitle());
|
| | |
| | | public static GoodsDetailVO convertTaoBao(TaoBaoGoodsBrief goods, String pid, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setBaoyou(true);
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | goodsInfo.setGoodsId(goods.getAuctionId());
|
| | | goodsInfo.setTitle(goods.getTitle());
|
| | |
| | | } else {
|
| | | goodsInfo.setState(state);
|
| | | }
|
| | | |
| | |
|
| | | goodsInfo.setSalesCount(TaoBaoUtil.getSaleCount(goods.getBiz30day()));
|
| | |
|
| | |
| | | goodsInfo.setPicUrl(goods.getPicUrl());
|
| | | goodsInfo.setImgList(goods.getImageList());
|
| | | goodsInfo.setState(0);
|
| | | goodsInfo.setShopType(20); // 京东
|
| | |
|
| | | String salesCountMidea = null;
|
| | | Long count = goods.getInOrderCount30Days();
|
| | |
| | | }
|
| | | goodsInfo.setSalesCount(salesCountMidea);
|
| | |
|
| | | |
| | | JDPingouInfo pinGouInfo = goods.getPinGouInfo();
|
| | | if (pinGouInfo != null) {
|
| | | goodsInfo.setZkPrice(pinGouInfo.getPingouPrice());
|
| | |
| | | goodsInfo.setPriceName("京东价");
|
| | | }
|
| | |
|
| | | |
| | | // 资金信息
|
| | | MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
|
| | | moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6
|
| | |
| | | moneyInfoVO.setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(goods, shareRate));
|
| | | goodsInfo.setMoneyInfo(moneyInfoVO);
|
| | |
|
| | | |
| | | |
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | if (couponInfo != null) {
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | // 计算券后价
|
| | | goodsInfo.setCouponPrice(JDUtil.getQuanPrice(goods));
|
| | |
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | CouponInfoVO coupon = new CouponInfoVO();
|
| | | coupon.setAmount(discount);
|
| | |
|
| | | int ran2 = (int) (Math.random()*(5) + 1 ); |
| | | if (ran2 > 3) {
|
| | | if (couponInfo.getGetStartTime() != null) {
|
| | | coupon.setStartTime(sdf.format(new Date(couponInfo.getGetStartTime())));
|
| | | } else {
|
| | | coupon.setStartTime(sdf.format(new Date()));
|
| | | }
|
| | |
|
| | | if (couponInfo.getGetEndTime() != null) {
|
| | | coupon.setEndTime(sdf.format(new Date(couponInfo.getGetEndTime())));
|
| | | } else {
|
| | | coupon.setEndTime(sdf.format(new Date()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | // TODO
|
| | | // coupon.setLeftCount(leftCount);
|
| | | // coupon.setTotalCount(totalCount);
|
| | |
|
| | | coupon.setLink(couponInfo.getLink());
|
| | | coupon.setStartFee(couponInfo.getQuota());
|
| | |
| | | textStyleVO.setColor("#E42219");
|
| | | labels.add(textStyleVO);
|
| | | goodsInfo.setLabels(labels);
|
| | | goodsInfo.setShopType(21); // 京东自营
|
| | | } else {
|
| | | goodsInfo.setShopType(20); // 京东
|
| | | }
|
| | |
|
| | | // 店铺信息
|
| | |
| | | }
|
| | | goodsInfo.setShopInfo(shop);
|
| | | }
|
| | | |
| | | // 是否包邮
|
| | | Integer isFreeShipping = goods.getIsFreeShipping();
|
| | | if (isFreeShipping != null && isFreeShipping == 1) {
|
| | | goodsInfo.setBaoyou(true);
|
| | | }
|
| | | return goodsInfo;
|
| | | }
|
| | |
|
| | |
| | | public static GoodsDetailVO convertPDDGoods(PDDGoodsDetail goods, String pid, BigDecimal fanLiRate,
|
| | | BigDecimal shareRate) {
|
| | | GoodsDetailVO goodsInfo = new GoodsDetailVO();
|
| | | goodsInfo.setBaoyou(true);
|
| | | goodsInfo.setGoodsType(Constant.SOURCE_TYPE_PDD);
|
| | | goodsInfo.setGoodsId(goods.getGoodsId());
|
| | | goodsInfo.setTitle(goods.getGoodsName());
|
| | | goodsInfo.setSalesType(4); // 总销量
|
| | | goodsInfo.setPriceName("拼团价");
|
| | | goodsInfo.setPicUrl(goods.getGoodsThumbnailUrl()); // 缩略图
|
| | | goodsInfo.setZkPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2));
|
| | | goodsInfo.setZkPrice(
|
| | | MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2));
|
| | | goodsInfo.setShopType(30); // 拼多多
|
| | |
|
| | | String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
|
| | |
| | | BigDecimal hundred = new BigDecimal(100);
|
| | | BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred).setScale(2);
|
| | | BigDecimal price = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), hundred).setScale(2);
|
| | | BigDecimal startFree = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), hundred).setScale(2);
|
| | | BigDecimal startFree = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), hundred)
|
| | | .setScale(2);
|
| | |
|
| | | // 计算券后价
|
| | | if (startFree.compareTo(price) <= 0) {
|
| | |
| | | CouponInfoVO coupon = new CouponInfoVO();
|
| | | coupon.setAmount(amount);
|
| | |
|
| | | |
| | | int ran2 = (int) (Math.random()*(5) + 1 ); |
| | | |
| | | if (ran2 > 3) {
|
| | | if (goods.getCouponStartTime() != null) {
|
| | | coupon.setStartTime(sdf.format(new Date(goods.getCouponStartTime() * 1000)));
|
| | | }
|
| | |
|
| | | if (goods.getCouponEndTime() != null) {
|
| | | coupon.setEndTime(sdf.format(new Date(goods.getCouponEndTime() * 1000)));
|
| | | }
|
| | | }
|
| | |
|
| | | coupon.setLink(null);
|
| | |
| | | commissionInfo.setCommission(MoneyBigDecimalUtil
|
| | | .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
|
| | |
|
| | | String isFreeShipping = json.optString("isFreeShipping");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | | |
| | | |
| | | goods.setCommissionInfo(commissionInfo);
|
| | | goods.setCouponInfo(null);
|
| | | goods.setGoodCommentsShare(null);
|
| | |
| | |
|
| | | String key = searchFilter.getKey();
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | data.put("key", "");
|
| | | data.put("keywordType", "kt0");
|
| | | data.put("searchType", "st3");
|
| | | } else {
|
| | |
| | | import com.yeshi.fanli.dto.pdd.PDDOrderResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | return HttpUtil.postSimple(url);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 多多进宝商品查询
|
| | | * @param sf
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult searchGoods(PDDSearchFilter sf) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.goods.search");
|
| | |
| | | if (sf.getGoodsIdList() != null)
|
| | | map.put("goods_id_list", "[" + StringUtil.concat(sf.getGoodsIdList(), ",") + "]");
|
| | |
|
| | | System.out.println(sf.getGoodsIdList().toString());
|
| | |
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | |
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 运营频道商品查询API
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @param channelType 频道类型;0, "1.9包邮", 1, "今日爆款", 2, "品牌清仓", 非必填 ,默认是1
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult searchByChannelType(Integer page, Integer pageSize, String channelType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.goods.recommend.get");
|
| | | map.put("offset", (page == null?0:page) + "");
|
| | | map.put("offset", (pageSize == null?Constant.PAGE_SIZE:pageSize) + "");
|
| | | |
| | | if (channelType != null)
|
| | | map.put("channel_type", channelType);
|
| | | |
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_basic_detail_response");
|
| | | JSONArray array = root.optJSONArray("list");
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | | |
| | | public static void getGoodsClass() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.cats.get");
|
| | | map.put("parent_cat_id", "0");
|
| | | String result = baseRequest(map);
|
| | | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_cats_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_cats_list");
|
| | | }
|
| | | |
| | | |
| | | public static void getGoodsOpt() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.opt.get");
|
| | | map.put("parent_opt_id", "0");
|
| | | String result = baseRequest(map);
|
| | | |
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_opt_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_opt_list");
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 多多客获取爆款排行商品接口
|
| | | * @param pid 推广位id (非必填)
|
| | | * @param page 从多少位置开始请求;默认值 : 0 (非必填)
|
| | | * @param pageSize 请求数量;默认值 :20 (非必填)
|
| | | * @param sortType 1-实时热销榜;2-实时收益榜 (非必填)
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult getTopList(String pid, Integer page, Integer pageSize, Integer sortType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.top.goods.list.query");
|
| | | map.put("offset", (page == null? 0: page) +"");
|
| | | map.put("limit", (pageSize == null? Constant.PAGE_SIZE : pageSize) +"");
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(pid))
|
| | | map.put("p_id", pid + "");
|
| | | |
| | | if (sortType != null)
|
| | | map.put("sort_type", sortType + "");
|
| | | |
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("top_goods_list_get_response");
|
| | | JSONArray array = root.optJSONArray("list");
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {}.getType();
|
| | | |
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 商品转链
|
| | | *
|
| | |
| | | private Date createtime; // 创建时间
|
| | | @Expose
|
| | | private OtherInfo otherInfo; // 其他信息
|
| | | @Expose
|
| | | private boolean baoyou; // 是否包邮
|
| | | |
| | |
|
| | | public Long getGoodsId() {
|
| | | return goodsId;
|
| | |
| | | public void setPriceName(String priceName) {
|
| | | this.priceName = priceName;
|
| | | }
|
| | |
|
| | | public boolean isBaoyou() {
|
| | | return baoyou;
|
| | | }
|
| | |
|
| | | public void setBaoyou(boolean baoyou) {
|
| | | this.baoyou = baoyou;
|
| | | }
|
| | | }
|
| | |
| | | @Expose
|
| | | private String surplusMoney;
|
| | |
|
| | | |
| | | public String getShareId() {
|
| | | return shareId;
|
| | | }
|
| | |
| | | timeToLiveSeconds="1800" overflowToDisk="true"
|
| | | memoryStoreEvictionPolicy="LRU" />
|
| | |
|
| | | <!-- 京东通用模板缓存 -->
|
| | | <cache name="jdCommonContentCache" maxElementsInMemory="1000"
|
| | | maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="1800"
|
| | | timeToLiveSeconds="1800" overflowToDisk="true"
|
| | | memoryStoreEvictionPolicy="LRU" />
|
| | | |
| | | <!-- 拼多多通用模板缓存 -->
|
| | | <cache name="pddCommonContentCache" maxElementsInMemory="1000"
|
| | | maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="1800"
|
| | | timeToLiveSeconds="1800" overflowToDisk="true"
|
| | | memoryStoreEvictionPolicy="LRU" />
|
| | | |
| | | <!-- 拼多多缓存 -->
|
| | |
|
| | |
| | | memoryStoreEvictionPolicy="LRU" />
|
| | |
|
| | | |
| | | <!-- 京东专题缓存 -->
|
| | | <cache name="jdSpecialCache" maxElementsInMemory="1000"
|
| | | maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="1800"
|
| | | timeToLiveSeconds="1800" overflowToDisk="true"
|
| | | memoryStoreEvictionPolicy="LRU" />
|
| | | |
| | | <!-- 拼多多专题缓存 -->
|
| | | <cache name="pddSpecialCache" maxElementsInMemory="1000"
|
| | | maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="1800"
|
| | | timeToLiveSeconds="1800" overflowToDisk="true"
|
| | | memoryStoreEvictionPolicy="LRU" /> |
| | |
|
| | |
|
| | | </ehcache>
|