| | |
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.suning.SuningUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.vipshop.VipShopUtil;
|
| | | import com.yeshi.fanli.vo.elme.ElemeConvertInfoResultVO;
|
| | | import com.yeshi.fanli.vo.homemodule.FloatImgDetailVO;
|
| | |
|
| | |
| | |
|
| | | data.put("baichuan", false);// 不需要采用阿里百川的方式加载webview
|
| | |
|
| | | } else if (url != null && (url.contains(".vip.com"))) {// 唯品会
|
| | | String goodsId = VipShopUtil.parseGoodsIdByUrl(url);
|
| | | if (StringUtil.isNullOrEmpty(goodsId))// 不能拦截详情页面,防止前端进入死循环
|
| | | data.put("goodsDetail", true);
|
| | | else
|
| | | data.put("goodsDetail", false);
|
| | | } else if (url != null && (url.contains(".suning.com"))) {// 苏宁
|
| | | String goodsId = SuningUtil.parseGoodsIdByUrl(url);
|
| | | if (StringUtil.isNullOrEmpty(goodsId))// 不能拦截详情页面,防止前端进入死循环
|
| | | data.put("goodsDetail", true);
|
| | | else
|
| | | data.put("goodsDetail", false);
|
| | | } else if (url != null && ((url.contains("yangkeduo.com") && !url.contains("yangkeduo.com/goods.html?")
|
| | | && !url.contains("yangkeduo.com/duo_coupon_landing.html?"))
|
| | | || (url.startsWith("https://p.pinduoduo.com/")))) {
|
| | |
| | | // 商品链接
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
|
| | | // try {
|
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | // } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | // }
|
| | | // try {
|
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | // } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | // }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | |
| | | // 分享路径
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
|
| | | // try {
|
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | // } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | // }
|
| | | // try {
|
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | // } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | // }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | |
| | | // 分享路径
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
|
| | | // try {
|
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | // } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | // }
|
| | | // try {
|
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | // } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | // }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | |
| | | } else {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | |
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null);
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("native", true);
|
| | |
| | | } else {
|
| | | data.put("extend", true);
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_VIP) {
|
| | | VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId);
|
| | | if (goods == null) {
|
| | | data.put("extend", false);
|
| | | data.put("url","");
|
| | | } else {
|
| | | data.put("extend", true);
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
|
| | | SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId.split("-")[1], goodsId.split("-")[0]);
|
| | | if (goods == null) {
|
| | | data.put("extend", false);
|
| | | data.put("url", String.format("https://m.suning.com/product/%s/%s.html", goodsId.split("-")[0],goodsId.split("-")[1]));
|
| | | } else {
|
| | | data.put("extend", true);
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
| | | return; |
| | | } |
| | | |
| | | if (goodsId == null ) { |
| | | if (goodsId == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | // 淘宝 |
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | createTaoBaoShare(acceptData, uid,Long.parseLong(goodsId), totalNum, source, needGoods, request, out); |
| | | createTaoBaoShare(acceptData, uid, Long.parseLong(goodsId), totalNum, source, needGoods, request, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList( |
| | | getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, TaoBaoUtil.getGoodsHongBaoMoney( |
| | | taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP),false))); |
| | | taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP), false))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | uid + ""); |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | } |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | shareInfo.setClickUrl(jumpLink); |
| | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | | |
| | | |
| | | final String jumpLinkNew=jumpLink; |
| | | |
| | | // 异步操作 |
| | | final JDGoods goods = jdGoods; |
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() { |
| | |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId); |
| | | history.setPostPicture(goods.getPicUrl()); |
| | | history.setShareImg(jumpLink); |
| | | history.setShareImg(jumpLinkNew); |
| | | |
| | | List<String> imgList = goods.getImageList(); |
| | | if (imgList == null) { |
New file |
| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | 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.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.service.inter.goods.suning.SuningGoodsService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.homemodule.BannerVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 热销榜
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v2/suning")
|
| | | public class SuningControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private SuningGoodsService suningGoodsService;
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @Resource
|
| | | private SpecialService specialService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | /**
|
| | | * 京东专题分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getClass")
|
| | | public void getJDClass(AcceptData acceptData, PrintWriter out) {
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("list", suningGoodsService.getSpecialClass());
|
| | | root.put("suningLink", "https://www.suning.com/");
|
| | | 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<BannerVO> topPicList = swiperPictureService.getByBannerCardAndVersion("suning_banner_index",
|
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<BannerVO>();
|
| | | }
|
| | | root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
|
| | |
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | |
|
| | | List<Special> listSpecial = specialService.listByPlaceKey("suning_special_index", platformCode,
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | if (listSpecial == null) {
|
| | | listSpecial = new ArrayList<Special>();
|
| | | }
|
| | | root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
|
| | | }
|
| | |
|
| | | List<SuningGoodsInfo> goodsList = suningGoodsService.specialSearch(page, cid);
|
| | |
|
| | | try {
|
| | | JSONArray array = new JSONArray();
|
| | | 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 (SuningGoodsInfo goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | |
|
| | | root.put("list", array);
|
| | | root.put("count", 1000);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取出错"));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | |
|
| | | List<Extract> list = null;
|
| | | String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.extractRecord);
|
| | | if (!StringUtil.isNullOrEmpty(redisContent)) {
|
| | |
| | | }.getType());
|
| | | }
|
| | |
|
| | | // 查询真实
|
| | | long count = 0;
|
| | | if (list == null) {
|
| | | if (list != null && list.size() > 0) {// 有预览数据
|
| | | count=list.size();
|
| | | } else {// 无预览数据
|
| | | list = extractService.getExtractSucceedRecord(page, Constant.PAGE_SIZE, uid);
|
| | | count = extractService.countExtractSucceedRecord(uid);
|
| | | }
|
| | |
|
| | | // 查询真实
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | |
|
| | |
| | | }
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("count", count == 0 ? list.size() : 0);
|
| | | json.put("count", count);
|
| | | json.put("list", JSONArray);
|
| | | out.print(JsonUtil.loadTrueResult(json));
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | 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.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.service.inter.goods.vipshop.VipShopGoodsService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.homemodule.BannerVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 热销榜
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v2/vipshop")
|
| | | public class VipShopControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private VipShopGoodsService vipShopGoodsService;
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @Resource
|
| | | private SpecialService specialService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | /**
|
| | | * 京东专题分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getClass")
|
| | | public void getJDClass(AcceptData acceptData, PrintWriter out) {
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("list", vipShopGoodsService.getSpecialClass());
|
| | | root.put("vipShopLink", "https://www.vip.com/");
|
| | | 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<BannerVO> topPicList = swiperPictureService.getByBannerCardAndVersion("vipshop_banner_index",
|
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<BannerVO>();
|
| | | }
|
| | | root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
|
| | |
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | |
|
| | | List<Special> listSpecial = specialService.listByPlaceKey("vipshop_special_index", platformCode,
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | if (listSpecial == null) {
|
| | | listSpecial = new ArrayList<Special>();
|
| | | }
|
| | | root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
|
| | | }
|
| | |
|
| | | List<VIPGoodsInfo> goodsList = vipShopGoodsService.specialSearch(page, cid);
|
| | |
|
| | | try {
|
| | | JSONArray array = new JSONArray();
|
| | | 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 (VIPGoodsInfo goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | |
|
| | | root.put("list", array);
|
| | | root.put("count", 1000);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取出错"));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON
|
| | | || result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_PRICE_AND_COUPON) {
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, info.getPid());
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | goods.setCouponLink(link);
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, info.getPid(), link);
|
| | | }
|
| | | } else if (goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {// 有券
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, info.getPid());
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | goods.setCouponLink(link);
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, info.getPid(), link);
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(link)) {
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | |
| | | // 查询是否为大淘客商品
|
| | |
|
| | | String link = null;
|
| | | try {
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, app.getPid());
|
| | | } catch (Exception e) {
|
| | | }
|
| | | DaTaoKeDetailV2 v2 = daTaoKeGoodsDetailV2Service.selectByAuctionId(auctionId);
|
| | | if (v2 != null) {
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | if (goods != null) {
|
| | | if (DaTaoKeUtil.canFilterCouponInfo(goods, v2)) {
|
| | | link = DaTaoKeApiUtil.convertLink(auctionId, app.getPid());
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, app.getPid(), link);
|
| | |
|
| | | }
|
| | | // link = DaTaoKeApiUtil.convertLink(auctionId,
|
| | | // app.getPid());
|
| | | |
| | | }
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(4, "商品ID不能为空");
|
| | | }
|
| | | }
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(auctionId, app.getPid(), link);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | |
| | | goods.setCouponLink(taoBaoLink.getCouponLink());
|
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | | |
| | |
|
| | | String link = taoBaoGoodsCacheUtil.getBaseConvertLink(auctionId, info.getPid());
|
| | | if (link != null) {
|
| | | goods.setCouponLink(link);
|
| | |
| | | goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl()))
|
| | |
| | | throw new ShareGoodsException(4, "商品已下架");
|
| | | }
|
| | |
|
| | | BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70),false);
|
| | | BigDecimal perface = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70), false);
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1,
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.goods.suning;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.service.inter.goods.suning.SuningGoodsService;
|
| | | import com.yeshi.fanli.util.suning.SuningApiUtil;
|
| | |
|
| | | @Service
|
| | | public class SuningGoodsServiceImpl implements SuningGoodsService {
|
| | |
|
| | | @Override
|
| | | public List<GoodsClass> getSpecialClass() {
|
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | | list.add(new GoodsClass(1L, "推荐"));
|
| | | // list.add(new GoodsClass(6L, "9.9"));
|
| | | // list.add(new GoodsClass(2L, "热销"));
|
| | | // list.add(new GoodsClass(3L, "热推"));
|
| | | // list.add(new GoodsClass(4L, "爆款"));
|
| | | |
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SuningGoodsInfo> specialSearch(Integer page, Long cid) {
|
| | |
|
| | | List<SuningGoodsInfo> list = SuningApiUtil.getSelectRecommendGoods(Integer.parseInt(cid + ""), page);
|
| | | List<String> strList = new ArrayList<>();
|
| | | for (SuningGoodsInfo info : list) {
|
| | | strList.add(info.getCommodityInfo().getCommodityCode() + "-" + info.getCommodityInfo().getSupplierCode());
|
| | | }
|
| | | return SuningApiUtil.getGoodsDetailList(strList);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.goods.vipshop;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.vip.VIPSearchResult;
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.service.inter.goods.vipshop.VipShopGoodsService;
|
| | | import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
|
| | |
|
| | | @Service
|
| | | public class VipShopGoodsServiceImpl implements VipShopGoodsService {
|
| | |
|
| | | @Override
|
| | | public List<GoodsClass> getSpecialClass() {
|
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | | list.add(new GoodsClass(1L, "推荐"));
|
| | | // list.add(new GoodsClass(6L, "9.9"));
|
| | | // list.add(new GoodsClass(2L, "热销"));
|
| | | // list.add(new GoodsClass(3L, "热推"));
|
| | | // list.add(new GoodsClass(4L, "爆款"));
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<VIPGoodsInfo> specialSearch(Integer page, Long cid) {
|
| | | VIPSearchResult result = VipShopApiUtil.getGoodsList(Integer.parseInt(cid + ""), page);
|
| | | if (result != null)
|
| | | return result.getGoodsList();
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.goods.suning;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.exception.jd.JDGoodsException;
|
| | |
|
| | | public interface SuningGoodsService {
|
| | |
|
| | | /**
|
| | | * 专题分类
|
| | | * @return
|
| | | */
|
| | | public List<GoodsClass> getSpecialClass();
|
| | |
|
| | | |
| | | /**
|
| | | * 专题商品搜索
|
| | | * @param page
|
| | | * @param cid
|
| | | * @return
|
| | | * @throws JDGoodsException
|
| | | */
|
| | | public List<SuningGoodsInfo> specialSearch(Integer page, Long cid);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.goods.vipshop;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.exception.jd.JDGoodsException;
|
| | |
|
| | | public interface VipShopGoodsService {
|
| | |
|
| | | /**
|
| | | * 专题分类
|
| | | * @return
|
| | | */
|
| | | public List<GoodsClass> getSpecialClass();
|
| | |
|
| | | |
| | | /**
|
| | | * 专题商品搜索
|
| | | * @param page
|
| | | * @param cid
|
| | | * @return
|
| | | * @throws JDGoodsException
|
| | | */
|
| | | public List<VIPGoodsInfo> specialSearch(Integer page, Long cid);
|
| | | }
|
| | |
| | |
|
| | | import com.yeshi.fanli.dto.douyin.DouYinGoods;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.util.suning.SuningApiUtil;
|
| | | import com.yeshi.fanli.util.suning.SuningUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
|
| | | import com.yeshi.fanli.util.vipshop.VipShopUtil;
|
| | | import com.yeshi.fanli.vo.msg.TokenVO;
|
| | | import com.yeshi.fanli.vo.search.GoodsDocParseResultVO;
|
| | |
|
| | |
| | | commonGoods.setPicture(goods.getGoodsThumbnailUrl());
|
| | | }
|
| | | }
|
| | | } else if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_VIP) {
|
| | | VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(simpleGoods.getGoodsId());
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | } else if (simpleGoods.getGoodsType() == Constant.SOURCE_TYPE_SUNING) {
|
| | | SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(simpleGoods.getGoodsId().split("-")[1],
|
| | | simpleGoods.getGoodsId().split("-")[0]);
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | }
|
| | |
|
| | | return commonGoods;
|
| | |
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | return new SimpleCommonGoods(pddId, Constant.SOURCE_TYPE_PDD);
|
| | | }
|
| | |
|
| | | // 解析苏宁
|
| | | String suningId = SuningUtil.parseGoodsIdByUrl(link);
|
| | | if (!StringUtil.isNullOrEmpty(suningId)) {
|
| | | return new SimpleCommonGoods(suningId, Constant.SOURCE_TYPE_SUNING);
|
| | | }
|
| | |
|
| | | // 解析唯品会
|
| | | String vipId = VipShopUtil.parseGoodsIdByUrl(link);
|
| | | if (!StringUtil.isNullOrEmpty(vipId)) {
|
| | | return new SimpleCommonGoods(vipId, Constant.SOURCE_TYPE_VIP);
|
| | | }
|
| | |
|
| | | // 解析淘宝
|
| | | String auctionId = parseTBAuctionIdFromLink(link);
|
| | | if (!StringUtil.isNullOrEmpty(auctionId)) {
|
| | |
| | | goodsInfo.setPriceName("拼团价");
|
| | | goodsInfo.setBaoyou(true);
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
|
| | | goodsInfo.setSalesType(1); |
| | | goodsInfo.setGoodsId(SuningUtil.getConcatGoodsIId(SuningUtil.getFullSupplierCode(goods.getSellerId() + ""),
|
| | | goods.getGoodsId() + ""));
|
| | | } else {
|
| | |
| | |
|
| | | if (goodsInfo.getZkPrice().compareTo(coupon.getStartFee()) >= 0) {
|
| | | goodsInfo.setCouponPrice(goodsInfo.getZkPrice().subtract(coupon.getAmount()));
|
| | | }else{
|
| | | goodsInfo.setCouponPrice(goodsInfo.getZkPrice());
|
| | | }
|
| | |
|
| | | } else {
|
| | |
| | | model.put("commodityStr", goodsCode + "-" + supplierCode);
|
| | | model.put("picWidth", 600);
|
| | | model.put("picHeight", 600);
|
| | | model.put("couponMark", 1);
|
| | |
|
| | | String key = "queryCommoditydetail";
|
| | | String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
|
| | |
| | | return new Gson().fromJson(array.optJSONObject(0).toString(), SuningGoodsInfo.class);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
|
| | | String sts = "";
|
| | | for (String st : list) {
|
| | | sts += st + "_";
|
| | | }
|
| | |
|
| | | if (sts.endsWith("_"))
|
| | | sts = sts.substring(0, sts.length() - 1);
|
| | |
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("commodityStr", sts);
|
| | | model.put("picWidth", 300);
|
| | | model.put("picHeight", 300);
|
| | | model.put("couponMark", 1);
|
| | | List<SuningGoodsInfo> goodsList = new ArrayList<>();
|
| | |
|
| | | String key = "queryCommoditydetail";
|
| | | String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
|
| | | System.out.println(result);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
|
| | | if (array != null && array.size() > 0) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | goodsList.add(new Gson().fromJson(array.optJSONObject(i).toString(), SuningGoodsInfo.class));
|
| | | }
|
| | | }
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | public static String convertLink(String productUrl, String quanUrl, String pid, String subUser) {
|
| | |
| | | String result = baseRequest("suning.netalliance.custompromotionurl.query", key, model);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | resultJSON = resultJSON.optJSONObject("sn_responseContent");
|
| | | String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl").optString("shortUrl");
|
| | | String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl")
|
| | | .optString("shortUrl");
|
| | | return URLDecoder.decode(shortUrl);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 商品精选接口
|
| | | * @Title: getSelectRecommendGoods
|
| | | * @Description: |
| | | * @param eliteId
|
| | | * @param page
|
| | | * @return |
| | | * List<SuningGoodsInfo> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static List<SuningGoodsInfo> getSelectRecommendGoods(int eliteId, int page) {
|
| | | JSONObject model = new JSONObject();
|
| | | model.put("eliteId", eliteId);
|
| | | model.put("pageIndex", page);
|
| | | // model.put("picWidth", 320);
|
| | | // model.put("picHeight", 320);
|
| | | model.put("size", 10);
|
| | | model.put("couponMark", 1);
|
| | |
|
| | | String key = "querySelectrecommendcommodity";
|
| | | String result = baseRequest("suning.netalliance.selectrecommendcommodity.query", key, model);
|
| | | System.out.println(result);
|
| | | JSONObject resultJSON = JSONObject.fromObject(result);
|
| | | resultJSON = resultJSON.optJSONObject("sn_responseContent");
|
| | | JSONArray array = resultJSON.optJSONObject("sn_body").optJSONObject(key).optJSONArray("commodityList");
|
| | | if (array != null) {
|
| | | Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
|
| | | }.getType();
|
| | | List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
|
| | | return goodsList;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.math.BigDecimal;
|
| | |
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(afterUseCouponPrice, rate);
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.div(
|
| | | afterUseCouponPrice.multiply(new BigDecimal(goods.getCommodityInfo().getRate())), new BigDecimal(100)),
|
| | | rate);
|
| | | return BigDecimalUtil.getWithNoZera(money).setScale(2);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | return supplierCode + "-" + goodsId;
|
| | | }
|
| | | |
| | | public static String getFullSupplierCode(String supplierCode){
|
| | |
|
| | | public static String getFullSupplierCode(String supplierCode) {
|
| | | for (int i = 0; i < 10; i++) {
|
| | | if (supplierCode.length() < 10)
|
| | | supplierCode = "0" + supplierCode;
|
| | | }
|
| | | |
| | |
|
| | | return supplierCode;
|
| | | }
|
| | |
|
| | |
| | | return String.format("https://product.suning.com/%s/%s.html", supplierCode, goodsId);
|
| | | }
|
| | |
|
| | | public static String parseGoodsIdByUrl(String url) {
|
| | | try {
|
| | | if (url.contains(".suning.com/")
|
| | | && (url.contains(".suning.com/product/") || url.contains("product.suning.com/"))) {
|
| | | String preUrl = url.split("\\?")[0];
|
| | | String[] sts = preUrl.split("/");
|
| | | if (sts.length > 2) {
|
| | | String goodsId = sts[sts.length - 1].replace(".html", "").replace(".htm", "");
|
| | | String supplierCode = sts[sts.length - 2];
|
| | | if (NumberUtil.isNumeric(goodsId) && NumberUtil.isNumeric(supplierCode)) {
|
| | | return supplierCode + "-" + goodsId;
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | params.add(new ParamsKeyValue("pid", pid));
|
| | | if (activityId != null)
|
| | | params.add(new ParamsKeyValue("activityid", activityId));
|
| | | // params.add(new ParamsKeyValue("tb_name", "椰视科技"));
|
| | | String result = basePostRequest("http://v2.api.haodanku.com/ratesurl", params);
|
| | | System.out.println(result);
|
| | | }
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | |
| | | public static VIPSearchResult getGoodsList(int channelType,int page) {
|
| | | Map<String, String> taskParams = new HashMap<>();
|
| | | taskParams.put("channelType",channelType+"");
|
| | | taskParams.put("page", page+ "");
|
| | | taskParams.put("pageSize", 20 + "");
|
| | | taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
|
| | | |
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("request", JSONObject.fromObject(taskParams));
|
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "goodsList", root);
|
| | | System.out.println(result);
|
| | | List<VIPGoodsInfo> goodsList = new ArrayList<>();
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | Gson gson = new Gson();
|
| | | if (resultJson.optInt("returnCode") == 0) {
|
| | | resultJson = resultJson.optJSONObject("result");
|
| | | int count = resultJson.optInt("total");
|
| | | JSONArray array = resultJson.optJSONArray("goodsInfoList");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
|
| | | if (info != null)
|
| | | goodsList.add(info);
|
| | | }
|
| | | return new VIPSearchResult(goodsList, count);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 商品ID转链
|
| | |
| | | import java.math.BigDecimal;
|
| | |
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | |
|
| | | return StringUtil.Md5(orderSn + "#" + goodsId + "#" + sizeId);
|
| | | }
|
| | |
|
| | | public static String parseGoodsIdByUrl(String url) {
|
| | | try {
|
| | | if (url.contains(".vip.com/") && (url.contains("detail-") || url.contains("product-"))) {
|
| | | String preUrl = url.split("\\?")[0];
|
| | | String goodsId = preUrl.split("-")[preUrl.split("-").length - 1].replace(".html", "").replace(".htm",
|
| | | "");
|
| | | if (NumberUtil.isNumeric(goodsId))
|
| | | return goodsId;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|