yj
2020-03-06 bf6ca2b873f4d3c71d2810fad2683b03ae5efe4a
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java
@@ -24,6 +24,7 @@
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;
@@ -41,8 +42,6 @@
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;
@@ -117,8 +116,10 @@
         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) {
@@ -152,14 +153,14 @@
    * 保存信息
    * 
    * @param callback
    * @param special
    *            0a39676f138c4dcba722e321d43c4284
    * @param pid
    * @param kind : 1单品  2多品 3活动
    * @param out
    */
   @RequestMapping(value = "saveSingleGoodsCoupon")
   public void saveSingleGoodsCoupon(String callback, String pid, CommentInfo commentInfo, PrintWriter out) {
   @RequestMapping(value = "saveCurrencyCoupon")
   public void saveCurrencyCoupon(String callback, String pid, int kind, CommentInfo commentInfo, PrintWriter out) {
      try {
         goodsEvaluateService.saveSingleGoodsCoupon(pid, commentInfo);
         goodsEvaluateService.saveCurrencyCoupon(pid, kind,commentInfo);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
      } catch (GoodsEvaluateException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -304,8 +305,75 @@
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
         e.printStackTrace();
         LogHelper.errorDetailInfo(e);
         LogHelper.test(e);
      }
   }
   /**
    *
    * @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();
      }
   }
   /**
    * 获取多个商品信息