From 121c5ee5345d366ae4aadf7901af9b0678dbb7a8 Mon Sep 17 00:00:00 2001 From: admin <2780501319@qq.com> Date: 星期日, 23 二月 2020 00:24:11 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java | 439 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 318 insertions(+), 121 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java index 8e857f7..a0b7eb0 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java @@ -1,6 +1,7 @@ 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; @@ -16,11 +17,18 @@ 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.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; @@ -31,6 +39,9 @@ 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; @@ -113,7 +124,28 @@ e.printStackTrace(); } } - + + /** + * 淇濆瓨淇℃伅 + * + * @param callback + * @param special + * 0a39676f138c4dcba722e321d43c4284 + * @param out + */ + @RequestMapping(value = "saveGoodsCoupon") + public void saveGoodsCoupon(String callback, String pid, String tags, String tagDesc, PrintWriter out) { + try { + goodsEvaluateService.saveGoodsCoupon(pid, tags, tagDesc); + 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(); + } + } + /** * 淇濆瓨淇℃伅 * @@ -152,42 +184,72 @@ 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("鏌ヨ澶辫触")); e.printStackTrace(); } } - - - - + + /** + * 鑾峰彇淇℃伅 + * + * @param callback + * @param special + * 0a39676f138c4dcba722e321d43c4284 + * @param out + */ + @RequestMapping(value = "getCurrencyCoupon") + public void getCurrencyCoupon(String callback, String pid, PrintWriter out) { + try { + 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 (CommentInfoEnum.currencyCoupon == info.getType()) { + commentInfo = info; + } + } + } + } + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(commentInfo)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触")); + e.printStackTrace(); + } + } + /** * 鑾峰彇淇℃伅 * @@ -200,9 +262,16 @@ public void getSingleGoodsCoupon(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 (CommentInfoEnum.goodsCoupon == info.getType()) { + commentInfo = info; + } + } + } } JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(commentInfo)); } catch (Exception e) { @@ -211,7 +280,72 @@ } } - + /** + * 淇濆瓨澶氫釜鍟嗗搧 + * + * @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(); + } + } + + /** + * 鑾峰彇澶氫釜鍟嗗搧淇℃伅 + * + * @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(); + } + } + /** * 淇濆瓨淇℃伅 * @@ -221,8 +355,8 @@ * @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) { @@ -269,19 +403,43 @@ } 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(); + } + } + /** * 淇濆瓨淇℃伅 * @@ -292,7 +450,10 @@ @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(); @@ -308,10 +469,6 @@ e.printStackTrace(); } } - - - - /** * 鍒犻櫎鍥剧墖浠ュ強淇℃伅 @@ -364,7 +521,7 @@ } 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; @@ -386,7 +543,64 @@ } } - 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); @@ -411,85 +625,44 @@ @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("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("鑾峰彇澶辫触")); @@ -551,6 +724,31 @@ } /** + * 鍒犻櫎淇℃伅 + * + * @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 @@ -589,4 +787,3 @@ } } - -- Gitblit v1.8.0