From 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 09 五月 2020 21:41:27 +0800 Subject: [PATCH] 2.1需求 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java | 368 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 260 insertions(+), 108 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 fe1d57b..846e223 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 @@ -19,19 +19,23 @@ 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; @@ -40,9 +44,9 @@ 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 com.yeshi.fanli.vo.msg.TokenVO; +import com.yeshi.fanli.vo.search.GoodsDocParseResultVO; import net.sf.json.JSONObject; @@ -74,6 +78,28 @@ @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(); + } + } + /** * 淇濆瓨淇℃伅 * @@ -104,8 +130,7 @@ * 淇濆瓨淇℃伅 * * @param callback - * @param special - * 0a39676f138c4dcba722e321d43c4284 + * @param special 0a39676f138c4dcba722e321d43c4284 * @param out */ @RequestMapping(value = "saveSingleGoods") @@ -116,8 +141,11 @@ if (request instanceof MultipartHttpServletRequest) { fileRequest = (MultipartHttpServletRequest) request; } - goodsEvaluateService.saveSingleGoods(pid, goodsId, goodsType, videoUrl, picNum, picUrls, fileRequest); - 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) { @@ -126,54 +154,12 @@ } } - /** - * 淇濆瓨淇℃伅 - * - * @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(); - } - } - - /** - * 淇濆瓨淇℃伅 - * - * @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("淇濆瓨鎴愬姛")); - } 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 = "getSingleGoodsinfo") @@ -220,13 +206,98 @@ e.printStackTrace(); } } + + /** + * + * @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 = "getCurrencyCoupon") @@ -238,9 +309,10 @@ if (goodsEvaluate != null && goodsEvaluate.getComments() != null && goodsEvaluate.getComments().size() > 0) { for (CommentInfo info : goodsEvaluate.getComments()) { - if (CommentInfoEnum.currencyCoupon == info.getType()) { - commentInfo = info; - } + if (info != null) + if (CommentInfoEnum.currencyCoupon == info.getTypeEnum()) { + commentInfo = info; + } } } } @@ -250,36 +322,12 @@ e.printStackTrace(); } } + - /** - * 鑾峰彇淇℃伅 - * - * @param callback - * @param special - * 0a39676f138c4dcba722e321d43c4284 - * @param out - */ - @RequestMapping(value = "getSingleGoodsCoupon") - public void getSingleGoodsCoupon(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.goodsCoupon == info.getType()) { - commentInfo = info; - } - } - } - } - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(commentInfo)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触")); - e.printStackTrace(); - } - } + + + + /** * 淇濆瓨澶氫釜鍟嗗搧 @@ -301,8 +349,12 @@ } catch (Exception e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触")); e.printStackTrace(); + LogHelper.errorDetailInfo(e); + LogHelper.test(e); } } + + /** * 鑾峰彇澶氫釜鍟嗗搧淇℃伅 @@ -351,19 +403,18 @@ * 淇濆瓨淇℃伅 * * @param callback - * @param special - * 0a39676f138c4dcba722e321d43c4284 + * @param special 0a39676f138c4dcba722e321d43c4284 * @param out */ @RequestMapping(value = "saveActivityPic") - public void saveActivityPic(String callback, String pid, ImgInfo imgInfo, HttpServletRequest request, + public void saveActivityPic(String callback, String pid, ImgInfo imgInfo, String picUrls, HttpServletRequest request, PrintWriter out) { try { MultipartHttpServletRequest fileRequest = null; if (request instanceof MultipartHttpServletRequest) { fileRequest = (MultipartHttpServletRequest) request; } - goodsEvaluateService.saveActivityPic(pid, imgInfo, fileRequest); + goodsEvaluateService.saveActivityPic(pid, imgInfo,picUrls, fileRequest); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); } catch (GoodsEvaluateException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); @@ -377,8 +428,7 @@ * 鑾峰彇淇℃伅 * * @param callback - * @param special - * 0a39676f138c4dcba722e321d43c4284 + * @param special 0a39676f138c4dcba722e321d43c4284 * @param out */ @RequestMapping(value = "getActivityPic") @@ -386,19 +436,19 @@ try { String videoPic = ""; String videoUrl = ""; - String activityPic = ""; String activityUrl = ""; + List<String> list = new ArrayList<String>(); GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); if (goodsEvaluate != null && goodsEvaluate.getImgList() != null && goodsEvaluate.getImgList().size() > 0) { + activityUrl = goodsEvaluate.getJumpLink(); 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) { - activityPic = imgInfo.getUrl(); - activityUrl = imgInfo.getActivityUrl(); + } else { + list.add(imgInfo.getUrl()); } } } @@ -406,7 +456,7 @@ JSONObject data = new JSONObject(); data.put("videoUrl", videoUrl); data.put("videoPic", videoPic); - data.put("activityPic", activityPic); + data.put("listPic", list); data.put("activityUrl", activityUrl); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { @@ -419,8 +469,7 @@ * 淇濆瓨淇℃伅 * * @param callback - * @param special - * 0a39676f138c4dcba722e321d43c4284 + * @param special 0a39676f138c4dcba722e321d43c4284 * @param out */ @RequestMapping(value = "saveSuCai") @@ -437,6 +486,53 @@ 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(); } } @@ -512,8 +608,7 @@ * @param out */ @RequestMapping(value = "query") - public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, - PrintWriter out) { + public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, String typeEnum, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { pageIndex = 1; } @@ -522,7 +617,7 @@ } try { - List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 1); + List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 1, typeEnum); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; @@ -544,7 +639,7 @@ } } - long count = goodsEvaluateService.count(key, state, 1); + long count = goodsEvaluateService.count(key, state, 1, typeEnum); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); @@ -579,7 +674,7 @@ } try { - List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 2); + List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state, 2, null); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; @@ -601,7 +696,7 @@ } } - long count = goodsEvaluateService.count(key, state, 2); + long count = goodsEvaluateService.count(key, state, 2, null); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); @@ -626,7 +721,11 @@ @RequestMapping(value = "getGoodsByUrl") public void getGoodsByUrl(String callback, String link, PrintWriter out) { try { - CommonGoods commonGoods = clipboardAnalysisManager.parseLink(link); + //CommonGoods commonGoods = clipboardAnalysisManager.parseLink(link); + // 鏍规嵁鍙d护閾炬帴鑾峰彇鍟嗗搧 + getGoods(link); + + CommonGoods commonGoods = getCommonGoods(); if (commonGoods == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈壘鍒拌鍟嗗搧")); return; @@ -634,13 +733,26 @@ GoodsDetailVO goodsDetail = null; BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); - BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); - ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, - vipFanLiRate); + 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()); + String pictUrlWhite = goodsBrief.getPictUrlWhite(); + if (!StringUtil.isNullOrEmpty(pictUrlWhite)) { + goodsBrief.setPictUrl(pictUrlWhite); + + List<String> picList = new ArrayList<>(); + picList.add(pictUrlWhite); + + 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("璇ュ晢鍝佸凡涓嬫灦")); @@ -662,13 +774,43 @@ JSONObject object = new JSONObject(); object.put("goodsId", goodsDetail.getGoodsId()); object.put("goodsType", goodsDetail.getGoodsType()); - object.put("picUrl",goodsDetail.getPicUrl()); + 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) { + } + }); } /** @@ -787,4 +929,14 @@ } } + public CommonGoods getCommonGoods() { + return commonGoods; + } + + public void setCommonGoods(CommonGoods commonGoods) { + this.commonGoods = commonGoods; + } + + + } -- Gitblit v1.8.0