| | |
| | | import com.yeshi.fanli.entity.dynamic.CommentInfo; |
| | | 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.exception.dynamic.GoodsEvaluateException; |
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; |
| | |
| | | * 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 { |
| | |
| | | String videoPic = ""; |
| | | Integer picNum = 1; |
| | | 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(); |
| | |
| | | } |
| | | } |
| | | picNum = goodsEvaluate.getMainPicNum(); |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | |
| | | * 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(); |
| | | if (!StringUtil.isNullOrEmpty(pid)) { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid); |
| | | if (goodsEvaluate != null && goodsEvaluate.getComments() != null && goodsEvaluate.getComments().size() > 0) { |
| | | commentInfo = goodsEvaluate.getComments().get(0); |
| | | for (CommentInfo info: goodsEvaluate.getComments()) { |
| | | if (CommentInfoEnum.currencyCoupon == info.getType()) { |
| | | commentInfo = info; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(commentInfo)); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | | * @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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存多个商品 |
| | | * @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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存信息 |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | | * |
| | | * @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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存信息 |
| | |
| | | @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); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | | * @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); |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | /** |
| | | * 根据链接查询商品 |
| | | * |
| | |
| | | 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); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除信息 |
| | | * |
| | | * @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 |