| | |
| | | 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.bus.user.vip.UserLevelEnum; |
| | | 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.ImgInfo.ImgEnum; |
| | | import com.yeshi.fanli.entity.dynamic.ListComment; |
| | | 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.log.LogHelper; |
| | | 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.service.manger.IClipboardAnalysisResult; |
| | | import com.yeshi.fanli.tag.PageEntity; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | |
| | | 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.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.msg.TokenVO; |
| | | import com.yeshi.fanli.vo.search.GoodsDocParseResultVO; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | private CommonGoods commonGoods; |
| | | |
| | | |
| | | /** |
| | | * 修改状态 |
| | | * @param callback |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "switchState") |
| | | public void switchState(String callback, String id, PrintWriter out) { |
| | | try { |
| | | goodsEvaluateService.switchState(id); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | @RequestMapping(value = "saveHead") |
| | | public void saveHead(String callback, GoodsEvaluate evaluate, HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | String id = null; |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request; |
| | | goodsEvaluateService.saveHead(fileRequest.getFile("portraitFile"), evaluate); |
| | | id = goodsEvaluateService.saveHead(fileRequest.getFile("portraitFile"), evaluate); |
| | | } else { |
| | | goodsEvaluateService.saveHead(null, evaluate); |
| | | id = goodsEvaluateService.saveHead(null, evaluate); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(id)); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | |
| | | * 保存信息 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * 0a39676f138c4dcba722e321d43c4284 |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveSingleGoods") |
| | |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | fileRequest = (MultipartHttpServletRequest) request; |
| | | } |
| | | goodsEvaluateService.saveSingleGoods(pid, goodsId, goodsType, videoUrl, picNum, picUrls, fileRequest); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveSingleGoodsCoupon") |
| | | public void saveSingleGoodsCoupon(String callback, String pid, CommentInfo commentInfo, PrintWriter out) { |
| | | try { |
| | | goodsEvaluateService.saveSingleGoodsCoupon(pid, commentInfo); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | String commentText = goodsEvaluateService.saveSingleGoods(pid, goodsId, goodsType, videoUrl, picNum, |
| | | picUrls, fileRequest); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("comment", commentText); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * 0a39676f138c4dcba722e321d43c4284 |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSingleGoodsinfo") |
| | |
| | | String videoPic = ""; |
| | | Integer picNum = 1; |
| | | List<String> list = new ArrayList<String>(); |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null && goodsEvaluate.getImgList().size() > 0) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | | if (type == ImgEnum.video) { |
| | | videoPic = imgInfo.getUrl(); |
| | | videoUrl = imgInfo.getVideoUrl(); |
| | | } else if (type == ImgEnum.goods) { |
| | | list.add(imgInfo.getUrl()); |
| | | goodsId = imgInfo.getGoods().getGoodsId().toString(); |
| | | goodsType = imgInfo.getGoods().getGoodsType().toString(); |
| | | } else if (type == ImgEnum.img) { |
| | | list.add(imgInfo.getUrl()); |
| | | if (!StringUtil.isNullOrEmpty(pid)) { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null |
| | | && goodsEvaluate.getImgList().size() > 0) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | | if (type == ImgEnum.video) { |
| | | videoPic = imgInfo.getUrl(); |
| | | videoUrl = imgInfo.getVideoUrl(); |
| | | } else if (type == ImgEnum.goods) { |
| | | list.add(imgInfo.getUrl()); |
| | | goodsId = imgInfo.getGoods().getGoodsId().toString(); |
| | | goodsType = imgInfo.getGoods().getGoodsType().toString(); |
| | | } else if (type == ImgEnum.img) { |
| | | list.add(imgInfo.getUrl()); |
| | | } |
| | | } |
| | | picNum = goodsEvaluate.getMainPicNum(); |
| | | } |
| | | 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("查询失败")); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @param callback |
| | | * @param comments |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveGoodsComment") |
| | | public void saveGoodsComment(String callback, String id, int kind, ListComment comments, PrintWriter out) { |
| | | try { |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请先保存推荐语信息")); |
| | | return; |
| | | } |
| | | if (comments == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("文本内容为空")); |
| | | return; |
| | | } |
| | | goodsEvaluateService.saveGoodsComment(id, kind, comments.getComment()); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param callback |
| | | * @param comments |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getGoodsComment") |
| | | public void getGoodsComment(String callback, String id, PrintWriter out) { |
| | | try { |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请先保存推荐语信息")); |
| | | return; |
| | | } |
| | | |
| | | List<CommentInfo> newList = new ArrayList<>(); |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); |
| | | if (goodsEvaluate != null) { |
| | | List<CommentInfo> comments = goodsEvaluate.getComments(); |
| | | if (comments != null && comments.size() > 0) { |
| | | for (CommentInfo commentInfo : comments) { |
| | | CommentInfoEnum typeEnum = commentInfo.getTypeEnum(); |
| | | if (typeEnum == CommentInfoEnum.goodsCoupon) { |
| | | newList.add(commentInfo); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", newList); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | | * @param callback |
| | | * @param pid |
| | | * @param kind : 1单品 2多品 3活动 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveCurrencyCoupon") |
| | | public void saveCurrencyCoupon(String callback, String pid, int kind, CommentInfo commentInfo, PrintWriter out) { |
| | | try { |
| | | goodsEvaluateService.saveCurrencyCoupon(pid, kind, commentInfo); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * 0a39676f138c4dcba722e321d43c4284 |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSingleGoodsCoupon") |
| | | public void getSingleGoodsCoupon(String callback, String pid, PrintWriter out) { |
| | | @RequestMapping(value = "getCurrencyCoupon") |
| | | public void getCurrencyCoupon(String callback, String pid, PrintWriter out) { |
| | | try { |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getComments() != null && goodsEvaluate.getComments().size() > 0) { |
| | | commentInfo = goodsEvaluate.getComments().get(0); |
| | | 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 (info != null) |
| | | if (CommentInfoEnum.currencyCoupon == info.getTypeEnum()) { |
| | | commentInfo = info; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(commentInfo)); |
| | | } catch (Exception e) { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存多个商品 |
| | | * |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveMultipleGoods") |
| | | public void saveMultipleGoods(String callback, String pid, String videoUrl, String goodsList, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | MultipartHttpServletRequest fileRequest = null; |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | fileRequest = (MultipartHttpServletRequest) request; |
| | | } |
| | | goodsEvaluateService.saveMultipleGoods(pid, videoUrl, goodsList, fileRequest); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e); |
| | | LogHelper.test(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取多个商品信息 |
| | | * |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getMultipleGoods") |
| | | public void getMultipleGoods(String callback, String pid, PrintWriter out) { |
| | | try { |
| | | String videoUrl = ""; |
| | | 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) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | | if (type == ImgEnum.video) { |
| | | videoPic = imgInfo.getUrl(); |
| | | videoUrl = imgInfo.getVideoUrl(); |
| | | } else if (type == ImgEnum.goods) { |
| | | list.add(imgInfo.getUrl()); |
| | | 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); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * 0a39676f138c4dcba722e321d43c4284 |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @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) { |
| | |
| | | * 获取信息 |
| | | * |
| | | * @param callback |
| | | * @param special |
| | | * 0a39676f138c4dcba722e321d43c4284 |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getActivityPic") |
| | |
| | | } |
| | | |
| | | 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 callback |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveSuCai") |
| | | public void saveSuCai(String callback, String pid, String videoUrl, String picUrls, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | MultipartHttpServletRequest fileRequest = null; |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | fileRequest = (MultipartHttpServletRequest) request; |
| | | } |
| | | goodsEvaluateService.saveSuCai(pid, videoUrl, picUrls, fileRequest); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e); |
| | | LogHelper.test(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | | * @param callback |
| | | * @param special 0a39676f138c4dcba722e321d43c4284 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSuCaiPic") |
| | | public void getSuCaiPic(String callback, String pid, PrintWriter out) { |
| | | try { |
| | | String videoUrl = ""; |
| | | String videoPic = ""; |
| | | String activityUrl = ""; |
| | | 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) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | | if (type == ImgEnum.video) { |
| | | videoPic = imgInfo.getUrl(); |
| | | videoUrl = imgInfo.getVideoUrl(); |
| | | } else if (type == ImgEnum.activity) { |
| | | activityUrl = imgInfo.getActivityPic(); |
| | | } else if (type == ImgEnum.img) { |
| | | list.add(imgInfo.getUrl()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("activityUrl", activityUrl); |
| | | data.put("videoUrl", videoUrl); |
| | | data.put("videoPic", videoPic); |
| | | data.put("list", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | |
| | | @RequestMapping(value = "getEvaluate") |
| | | public void getEvaluate(String callback, String id, PrintWriter out) { |
| | | try { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); |
| | | GoodsEvaluate goodsEvaluate = null; |
| | | if (!StringUtil.isNullOrEmpty(id)) { |
| | | goodsEvaluate = goodsEvaluateService.getById(id); |
| | | } |
| | | if (goodsEvaluate == null) |
| | | goodsEvaluate = new GoodsEvaluate(); |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 删除图片以及信息 |
| | |
| | | } |
| | | |
| | | try { |
| | | List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state); |
| | | List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 1); |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | long count = goodsEvaluateService.count(key, state); |
| | | long count = goodsEvaluateService.count(key, state, 1); |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param bannerId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "querySuCai") |
| | | public void querySuCai(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, |
| | | PrintWriter out) { |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | if (pageSize == null || pageSize < 1) { |
| | | pageSize = Constant.PAGE_SIZE; |
| | | } |
| | | |
| | | try { |
| | | List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 2); |
| | | if (list == null || list.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | for (GoodsEvaluate article : list) { |
| | | Date startTime = article.getStartTime(); |
| | | if (startTime == null) { |
| | | article.setStartTimeChar(""); |
| | | } else { |
| | | article.setStartTimeChar(TimeUtil.formatDateAddT(startTime)); |
| | | } |
| | | |
| | | Date endTime = article.getEndTime(); |
| | | if (endTime == null) { |
| | | article.setEndTimeChar(""); |
| | | } else { |
| | | article.setEndTimeChar(TimeUtil.formatDateAddT(endTime)); |
| | | } |
| | | } |
| | | |
| | | long count = goodsEvaluateService.count(key, state, 2); |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | |
| | | @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); |
| | | // 根据口令链接获取商品 |
| | | getGoods(link); |
| | | |
| | | CommonGoods commonGoods = getCommonGoods(); |
| | | 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.getFanLiRate(UserLevelEnum.superVIP); |
| | | 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()); |
| | | String pictUrlWhite = goodsBrief.getPictUrlWhite(); |
| | | if (!StringUtil.isNullOrEmpty(pictUrlWhite)) { |
| | | goodsBrief.setPictUrl(pictUrlWhite); |
| | | |
| | | // if (goodsDetail == null) { |
| | | // JsonUtil.printMode(out, callback, |
| | | // JsonUtil.loadFalseResult("未找到该商品")); |
| | | // return; |
| | | // } |
| | | List<String> picList = new ArrayList<>(); |
| | | picList.add(pictUrlWhite); |
| | | |
| | | 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"); |
| | | List<String> imgList = goodsBrief.getImgList(); |
| | | if (imgList != null) { |
| | | picList.addAll(imgList); |
| | | } |
| | | goodsBrief.setImgList(picList); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("goodsId", 551062664275L); |
| | | object.put("goodsType", 1); |
| | | 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(); |
| | | } finally { |
| | | setCommonGoods(null); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void getGoods(String text) { |
| | | Long uid = Constant.LINK_TOKEN_VERIFY_UID; |
| | | clipboardAnalysisManager.parse("android", "55", text, uid, new IClipboardAnalysisResult() { |
| | | @Override |
| | | public void onResult(GoodsDocParseResultVO result) {} |
| | | |
| | | @Override |
| | | public void onResult(String result) {} |
| | | |
| | | @Override |
| | | public void onResult(CommonGoods goods) { |
| | | setCommonGoods(goods); |
| | | } |
| | | |
| | | @Override |
| | | public void onResult(TokenVO tokenVO) { |
| | | } |
| | | @Override |
| | | public void none() { |
| | | } |
| | | |
| | | @Override |
| | | public void needLogin(String msg) { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除信息 |
| | | * |
| | | * @param callback |
| | | * @param idArray |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "release") |
| | | public void release(String callback, String id, PrintWriter out) { |
| | | try { |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据")); |
| | | return; |
| | | } |
| | | |
| | | goodsEvaluateService.release(id); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("发布成功")); |
| | | } catch (GoodsEvaluateException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("发布失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询品论 |
| | | * |
| | | * @param callback |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | public CommonGoods getCommonGoods() { |
| | | return commonGoods; |
| | | } |
| | | |
| | | public void setCommonGoods(CommonGoods commonGoods) { |
| | | this.commonGoods = commonGoods; |
| | | } |
| | | |
| | | |
| | | |
| | | } |