| | |
| | | package com.yeshi.fanli.controller.admin; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.fanli.dto.ConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.entity.dynamic.CommentInfo; |
| | | import com.yeshi.fanli.entity.dynamic.CommentInfo.CommentInfoEnum; |
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate; |
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo; |
| | | import com.yeshi.fanli.entity.dynamic.CommentInfo.CommentInfoEnum; |
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum; |
| | | 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.exception.dynamic.GoodsEvaluateException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.manger.ClipboardAnalysisManager; |
| | |
| | | import com.yeshi.fanli.util.TimeUtil; |
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; |
| | | 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.JSONObject; |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | List<String> list = new ArrayList<String>(); |
| | | if (!StringUtil.isNullOrEmpty(pid)) { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null && goodsEvaluate.getImgList().size() > 0) { |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null |
| | | && goodsEvaluate.getImgList().size() > 0) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | |
| | | picNum = goodsEvaluate.getMainPicNum(); |
| | | } |
| | | } |
| | | |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goodsId", goodsId); |
| | | data.put("goodsType", goodsType); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | data.put("picNum", picNum); |
| | | data.put("list", list); |
| | | data.put("goodsId", goodsId); |
| | | data.put("goodsType", goodsType); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | data.put("picNum", picNum); |
| | | data.put("list", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | if (!StringUtil.isNullOrEmpty(pid)) { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getComments() != null && goodsEvaluate.getComments().size() > 0) { |
| | | for (CommentInfo info: goodsEvaluate.getComments()) { |
| | | if (goodsEvaluate != null && goodsEvaluate.getComments() != null |
| | | && goodsEvaluate.getComments().size() > 0) { |
| | | for (CommentInfo info : goodsEvaluate.getComments()) { |
| | | if (CommentInfoEnum.currencyCoupon == info.getType()) { |
| | | commentInfo = info; |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | if (!StringUtil.isNullOrEmpty(pid)) { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getComments() != null && goodsEvaluate.getComments().size() > 0) { |
| | | for (CommentInfo info: goodsEvaluate.getComments()) { |
| | | if (goodsEvaluate != null && goodsEvaluate.getComments() != null |
| | | && goodsEvaluate.getComments().size() > 0) { |
| | | for (CommentInfo info : goodsEvaluate.getComments()) { |
| | | if (CommentInfoEnum.goodsCoupon == info.getType()) { |
| | | commentInfo = info; |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存多个商品 |
| | | * |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveMultipleGoods") |
| | | public void saveMultipleGoods(String callback, String pid, String videoUrl, String goodsList, |
| | | public void saveMultipleGoods(String callback, String pid, String videoUrl, String goodsList, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | MultipartHttpServletRequest fileRequest = null; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取多个商品信息 |
| | | * |
| | |
| | | String videoPic = ""; |
| | | List<String> list = new ArrayList<String>(); |
| | | List<String> goodsList = new ArrayList<String>(); |
| | | |
| | | |
| | | if (!StringUtil.isNullOrEmpty(pid)) { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null && goodsEvaluate.getImgList().size() > 0) { |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null |
| | | && goodsEvaluate.getImgList().size() > 0) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | |
| | | videoUrl = imgInfo.getVideoUrl(); |
| | | } else if (type == ImgEnum.goods) { |
| | | list.add(imgInfo.getUrl()); |
| | | goodsList.add(imgInfo.getGoods().getGoodsId() + "-"+ imgInfo.getGoods().getGoodsType()); |
| | | } |
| | | goodsList.add(imgInfo.getGoods().getGoodsId() + "-" + imgInfo.getGoods().getGoodsType()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", list); |
| | | data.put("goodsList", goodsList); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | data.put("list", list); |
| | | data.put("goodsList", goodsList); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveActivityPic") |
| | | public void saveActivityPic(String callback, String pid, ImgInfo imgInfo, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | public void saveActivityPic(String callback, String pid, ImgInfo imgInfo, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | MultipartHttpServletRequest fileRequest = null; |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | data.put("activityPic", activityPic); |
| | | data.put("activityUrl", activityUrl); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | data.put("activityPic", activityPic); |
| | | data.put("activityUrl", activityUrl); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveSuCai") |
| | | public void saveSuCai(String callback, String pid, String videoUrl, String picUrls, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | public void saveSuCai(String callback, String pid, String videoUrl, String picUrls, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | MultipartHttpServletRequest fileRequest = null; |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 删除图片以及信息 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据链接查询商品 |
| | | * |
| | |
| | | @RequestMapping(value = "getGoodsByUrl") |
| | | public void getGoodsByUrl(String callback, String link, PrintWriter out) { |
| | | try { |
| | | // CommonGoods commonGoods = |
| | | // clipboardAnalysisManager.parseLink(link); |
| | | // if (commonGoods == null) { |
| | | // JsonUtil.printMode(out, callback, |
| | | // JsonUtil.loadFalseResult("未找到该商品")); |
| | | // return; |
| | | // } |
| | | // |
| | | CommonGoods commonGoods = clipboardAnalysisManager.parseLink(link); |
| | | if (commonGoods == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未找到该商品")); |
| | | return; |
| | | } |
| | | GoodsDetailVO goodsDetail = null; |
| | | |
| | | // try { |
| | | // BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); |
| | | // BigDecimal shareRate = hongBaoManageService.getShareRate(); |
| | | // BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); |
| | | // ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, |
| | | // shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate); |
| | | // TaoBaoGoodsBrief goodsBrief = |
| | | // redisManager.getTaoBaoGoodsBrief(596617470742L); |
| | | // goodsDetail = GoodsDetailVOFactory.convertTaoBao(goodsBrief, |
| | | // params); |
| | | // } catch (TaobaoGoodsDownException e) { |
| | | // JsonUtil.printMode(out, callback, |
| | | // JsonUtil.loadFalseResult("该商品已下架")); |
| | | // return; |
| | | // } |
| | | |
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); |
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(); |
| | | BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); |
| | | ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, |
| | | vipFanLiRate); |
| | | |
| | | // if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | | // try { |
| | | // TaoBaoGoodsBrief goodsBrief = |
| | | // redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId()); |
| | | // goodsDetail = GoodsDetailVOFactory.convertTaoBao(goodsBrief, |
| | | // params); |
| | | // } catch (TaobaoGoodsDownException e) { |
| | | // JsonUtil.printMode(out, callback, |
| | | // JsonUtil.loadFalseResult("该商品已下架")); |
| | | // return; |
| | | // } |
| | | // } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_JD) |
| | | // { |
| | | // JDGoods goodsInfo = |
| | | // JDApiUtil.queryGoodsDetail(commonGoods.getGoodsId()); // 高级接口 |
| | | // if (goodsInfo == null) { |
| | | // goodsInfo = JDUtil.getGoodsDetail(commonGoods.getGoodsId()); // |
| | | // 爬取网页 |
| | | // //jdGoods = JDApiUtil.getGoodsDetail(goodsId); // 普通接口 |
| | | // } |
| | | //// JDGoods goodsInfo = |
| | | // jdGoodsCacheUtil.getGoodsInfo(commonGoods.getGoodsId()); |
| | | // goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo, |
| | | // params); |
| | | // } else if (commonGoods.getGoodsType() == |
| | | // Constant.SOURCE_TYPE_PDD) { |
| | | // PDDGoodsDetail goodsInfo = |
| | | // pinDuoDuoCacheUtil.getGoodsInfo(commonGoods.getGoodsId()); |
| | | // goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, |
| | | // params); |
| | | // } |
| | | if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | | try { |
| | | TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId()); |
| | | goodsDetail = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_JD) { |
| | | JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(commonGoods.getGoodsId()); |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params); |
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(commonGoods.getGoodsId()); |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params); |
| | | } |
| | | |
| | | // if (goodsDetail == null) { |
| | | // JsonUtil.printMode(out, callback, |
| | | // JsonUtil.loadFalseResult("未找到该商品")); |
| | | // return; |
| | | // } |
| | | |
| | | List<String> imgList = new ArrayList<>(); |
| | | imgList.add( |
| | | "https://img.alicdn.com/bao/uploaded/i1/2578900982/O1CN01SUiNLE1J7nWMlpy1A_!!0-item_pic.jpg_220x220"); |
| | | imgList.add( |
| | | "https://img.alicdn.com/bao/uploaded/i1/2398662401/O1CN01I2UoTF1TbhXVwhJrz_!!0-item_pic.jpg_220x220"); |
| | | imgList.add( |
| | | "https://img.alicdn.com/bao/uploaded/i4/2640238597/O1CN01A5xBr32DNTYWJSDZe_!!0-item_pic.jpg_220x220"); |
| | | imgList.add( |
| | | "https://img.alicdn.com/bao/uploaded/i3/2640238597/O1CN01H5Q0Ni2DNTYxGAy3V_!!0-item_pic.jpg_220x220"); |
| | | if (goodsDetail == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未找到该商品")); |
| | | return; |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("goodsId", 551062664275L); |
| | | object.put("goodsType", 1); |
| | | object.put("picUrl", "https://img.alicdn.com/bao/uploaded/i3/2640238597/O1CN01H5Q0Ni2DNTYxGAy3V_!!0-item_pic.jpg_220x220"); |
| | | object.put("imgList", imgList); |
| | | object.put("goodsId", goodsDetail.getGoodsId()); |
| | | object.put("goodsType", goodsDetail.getGoodsType()); |
| | | object.put("picUrl",goodsDetail.getPicUrl()); |
| | | object.put("imgList", goodsDetail.getImgList()); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败")); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除信息 |
| | | * |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询品论 |
| | |
| | | } |
| | | |
| | | } |
| | | |