Merge remote-tracking branch 'origin/div' into div
Conflicts:
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
| | |
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
|
| | | // @Around("execution(public * com.yeshi.fanli.controller.admin..*.*(..))")
|
| | | @Around("execution(public * com.yeshi.fanli.controller.admin..*.*(..))") |
| | | public Object verifyLoginState(ProceedingJoinPoint joinPoint) throws IOException {
|
| | |
|
| | | Signature signature = joinPoint.getSignature();
|
| | |
| | | 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.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; |
| | |
| | | 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; |
| | |
| | | * 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) { |
| | | if (goodsEvaluate != null && goodsEvaluate.getImgList() != null |
| | | && goodsEvaluate.getImgList().size() > 0) { |
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList(); |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | |
| | | } |
| | | picNum = goodsEvaluate.getMainPicNum(); |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goodsId", goodsId); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取信息 |
| | | * |
| | | * @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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取信息 |
| | |
| | | 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) { |
| | | commentInfo = goodsEvaluate.getComments().get(0); |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存多个商品 |
| | | * |
| | | * @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 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 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); |
| | | |
| | | 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); |
| | | if (commonGoods == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未找到该商品")); |
| | | return; |
| | | } |
| | | 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); |
| | | |
| | | // 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; |
| | | // } |
| | | 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 (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 (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("获取失败")); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除信息 |
| | | * |
| | | * @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 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.QrCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | // //发圈测试
|
| | | public void evaluateTest(AcceptData acceptData, PrintWriter out) {
|
| | | JSONObject data = JSONObject.fromObject(configService.get("test"));
|
| | | out.print(data.toString());
|
| | | /** |
| | | * 发圈列表 |
| | | * |
| | | * @param acceptData |
| | | * @param page |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "evaluate2", method = RequestMethod.POST) |
| | | public void evaluate2(AcceptData acceptData, Integer page,Integer type, PrintWriter out) { |
| | | if(type == null) { |
| | | type = 1; |
| | | }
|
| | | List<GoodsEvaluate> list = goodsEvaluateService.queryMaterialsCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, type); |
| | | if (list == null) { |
| | | list = new ArrayList<>(); |
| | | } |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(CommentInfoEnum.class, new JsonSerializer<CommentInfoEnum>() { |
| | | @Override |
| | | public JsonElement serialize(CommentInfoEnum value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(1); |
| | | } else { |
| | | return new JsonPrimitive(value.getDesc()); |
| | | } |
| | | } |
| | | }).registerTypeAdapter(ImgEnum.class, new JsonSerializer<ImgEnum>() { |
| | | @Override |
| | | public JsonElement serialize(ImgEnum value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(value.getVlaue()); |
| | | } |
| | | } |
| | | }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | String desc = ""; |
| | | if (value != null) { |
| | | // 判断是否是同一天 |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(value); |
| | | int y1 = calendar.get(Calendar.YEAR);// 获取年份 |
| | | int d1 = calendar.get(Calendar.DAY_OF_YEAR);// 获取年中第几天 |
| | | |
| | | Date nowDate = new Date(); |
| | | Calendar calendar2 = Calendar.getInstance(); |
| | | calendar2.setTime(nowDate); |
| | | int y2 = calendar2.get(Calendar.YEAR);// 获取年份 |
| | | int d2 = calendar2.get(Calendar.DAY_OF_YEAR);// 获取年中第几天 |
| | | |
| | | long old = value.getTime(); |
| | | long now = nowDate.getTime(); |
| | | if (y1 == y2) { |
| | | if (d1 == d2) { |
| | | long cha = now - old; |
| | | if (cha < 1000 * 60 * 2L) { |
| | | desc = "刚刚"; |
| | | } else if (cha < 1000 * 60 * 60L) { |
| | | desc = (cha / (1000 * 60)) + "分钟前"; |
| | | } else { |
| | | desc = (cha / (1000 * 60 * 60)) + "小时前"; |
| | | } |
| | | } else if (d2 - d1 == 1) { |
| | | desc = "昨天"; |
| | | } else { |
| | | desc = (d2 - d1) + "天前"; |
| | | } |
| | | } else { |
| | | int timeDistance = 0; |
| | | for (int i = y1; i < y2; i++) { |
| | | if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) { |
| | | timeDistance += 366; // 闰年 |
| | | } else { |
| | | timeDistance += 365; // 不是闰年 |
| | | } |
| | | } |
| | | desc = timeDistance + (d2 - d1) + "天前"; |
| | | } |
| | | |
| | | return new JsonPrimitive(desc); |
| | | } |
| | | |
| | | return new JsonPrimitive(""); |
| | | } |
| | | }); |
| | | Gson gson = gsonBuilder.create(); |
| | | long count = goodsEvaluateService.countValidMaterials(type); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | data.put("list", gson.toJson(list)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | |
|
| | | /**
|
| | | * 发圈列表
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "evaluate", method = RequestMethod.POST)
|
| | | public void evaluate(AcceptData acceptData, Integer page, PrintWriter out) {
|
| | | if ("1".equalsIgnoreCase(configService.get("test-open"))) {
|
| | | evaluateTest(acceptData, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | public void evaluate(AcceptData acceptData, Integer page, Integer type, PrintWriter out) { |
| | | long cid = 1;
|
| | | long subId = 1;
|
| | | List<DynamicInfo> listd = dynamicInfoService.queryV2(2, 74, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE,
|
| | |
| | |
|
| | | List<GoodsEvaluate> list = new ArrayList<>();
|
| | |
|
| | | int p = 0;
|
| | | for (DynamicInfo info : listd) {
|
| | | p++;
|
| | |
|
| | | GoodsEvaluate goodsEvaluate = new GoodsEvaluate();
|
| | | goodsEvaluate.setId(info.getId());
|
| | | ActivityUser user = info.getUser();
|
| | |
| | |
|
| | | List<ImgInfo> imgList = new ArrayList<>();
|
| | | int i = 0;
|
| | |
|
| | | for (GoodsPicture goodsPicture : imgs) {
|
| | | ImgInfo imgInfo = new ImgInfo();
|
| | | GoodsDetailVO goodsVO = goodsPicture.getGoodsVO();
|
| | |
| | | // i++;
|
| | |
|
| | | imgList.add(imgInfo);
|
| | | }
|
| | |
|
| | | if (p == 1) {
|
| | | ImgInfo imgInfo = new ImgInfo();
|
| | | imgInfo.setLarge(true);
|
| | | imgInfo.setType(ImgEnum.img);
|
| | | imgInfo.setUrl(
|
| | | "http://ec-1255749512.file.myqcloud.com/img/invite/new/10ea86eb8db94f7cbb5e68864480d5fe.jpg");
|
| | | imgInfo.setH(1334);
|
| | | imgInfo.setW(750);
|
| | | imgList.add(0, imgInfo);
|
| | |
|
| | | imgInfo = new ImgInfo();
|
| | | imgInfo.setType(ImgEnum.video);
|
| | | imgInfo.setLarge(true);
|
| | | imgInfo.setUrl(
|
| | | "http://ec-1255749512.file.myqcloud.com/img/invite/new/10ea86eb8db94f7cbb5e68864480d5fe.jpg");
|
| | | imgInfo.setH(315);
|
| | | imgInfo.setW(560);
|
| | | imgInfo.setUrl("https://zzya.beva.cn/img/Fr56bczo_F8NvroeG54jLH5ey0aC.jpg");
|
| | | imgInfo.setVideoUrl("http://img.flqapp.com/resource/video.mp4");
|
| | | imgList.add(0, imgInfo);
|
| | |
|
| | | }
|
| | |
|
| | | goodsEvaluate.setImgList(imgList);
|
| | |
| | | list.add(goodsEvaluate);
|
| | | }
|
| | |
|
| | | // List<GoodsEvaluate> list =
|
| | | // goodsEvaluateService.queryValidEvaluateCache((page - 1) *
|
| | | // Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | // List<GoodsEvaluate> list = goodsEvaluateService.queryValidEvaluateCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE); |
| | | // if (list == null) {
|
| | | // list = new ArrayList<>();
|
| | | // }
|
| | |
| | | }
|
| | |
|
| | | @RequestMapping(value = "evaluateShare", method = RequestMethod.POST)
|
| | | public void evaluateShare(AcceptData acceptData, Long uid, String id, Integer type, Long goodsId, Integer goodsType,
|
| | | PrintWriter out) {
|
| | | public void evaluateShare(AcceptData acceptData, Long uid, String id, Integer type, Long goodsId, Integer goodsType, PrintWriter out) { |
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | DynamicInfo dynamicInfo = dynamicInfoService.getById(id);
|
| | | if (dynamicInfo == null) {
|
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); |
| | | if (goodsEvaluate == null) { |
| | | out.print(JsonUtil.loadFalseResult("该内容已不存在"));
|
| | | return;
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "邀请码未激活")); |
| | | return; |
| | | } |
| | | |
| | | List<ImgInfo> imgs = goodsEvaluate.getImgList(); |
| | | if (imgs == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该图片内容已不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | int total = 0;
|
| | | for (GoodsPicture goodsPicture : imgs) {
|
| | | GoodsDetailVO goodsVO = goodsPicture.getGoodsVO();
|
| | | if (goodsVO != null) {
|
| | | for (ImgInfo imgInfo : imgs) { |
| | | SimpleGoods goods = imgInfo.getGoods(); |
| | | if (goods != null) { |
| | | total++;
|
| | | }
|
| | | }
|
| | |
|
| | | List<String> list = new ArrayList<>();
|
| | | for (GoodsPicture goodsPicture : imgs) {
|
| | | GoodsDetailVO goodsVO = goodsPicture.getGoodsVO();
|
| | | for (ImgInfo imgInfo : imgs) { |
| | | GoodsDetailVO goodsVO = imgInfo.getGoodsVO(); |
| | | if (goodsVO == null && total <= 1) {
|
| | | list.add(goodsPicture.getUrl());
|
| | | list.add(imgInfo.getUrl()); |
| | | continue;
|
| | | }
|
| | |
|
| | | |
| | | if (type == 1) {
|
| | | if (goodsVO.getGoodsId().longValue() == goodsId.longValue()
|
| | | && goodsVO.getGoodsType() == goodsType.intValue()) {
|
| | | String jumpLink = getJumpLink(goodsVO, user);
|
| | | if (goodsVO.getGoodsId().longValue() == goodsId.longValue() && goodsVO.getGoodsType() == goodsType.intValue()) { |
| | | String jumpLink = getJumpLink(goodsVO, user, inviteCode); |
| | | if (!StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | list.add(jumpLink);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | String jumpLink = getJumpLink(goodsVO, user);
|
| | | String jumpLink = getJumpLink(goodsVO, user, inviteCode); |
| | | if (!StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | list.add(jumpLink);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Integer shareCount = dynamicInfo.getShareCount();
|
| | | Integer shareCount = goodsEvaluate.getShareNum(); |
| | | if (shareCount == null) {
|
| | | shareCount = 0;
|
| | | }
|
| | |
|
| | | if (type == 3) {
|
| | | shareCount++;
|
| | | dynamicInfoService.updateShareCount(dynamicInfo);
|
| | | goodsEvaluateService.addShareNum(id); |
| | | }
|
| | |
|
| | | if (list.size() == 0) {
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | private String getJumpLink(GoodsDetailVO goodsVO, UserInfo user) {
|
| | | private String getJumpLink(GoodsDetailVO goodsVO, UserInfo user, String inviteCode) { |
| | | String jumpLink = null;
|
| | | if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | user.getId() + "");
|
| | | } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsVO.getGoodsId(), PinDuoDuoApiUtil.PID_SHARE + "",
|
| | | user.getId() + "");
|
| | | jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsVO.getGoodsId(), PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + ""); |
| | | }
|
| | | FileUploadResult uploadResult = qrCodeService.drawGoodsPoster(jumpLink, user.getPortrait(), goodsVO);
|
| | | |
| | | |
| | | FileUploadResult uploadResult = qrCodeService.drawDynamicGoodsPoster(jumpLink, user.getPortrait(), inviteCode, goodsVO); |
| | | if (uploadResult != null) {
|
| | | return uploadResult.getUrl();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 评论复制
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param cid
|
| | | * 评论id
|
| | | * @param cid 评论id |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "evaluateComment", method = RequestMethod.POST)
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | DynamicInfo dynamicInfo = dynamicInfoService.getById(id);
|
| | | if (dynamicInfo == null) {
|
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); |
| | | if (goodsEvaluate == null) { |
| | | out.print(JsonUtil.loadFalseResult("该内容已不存在"));
|
| | | return;
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | String text = ""; |
| | | List<CommentInfo> comments = goodsEvaluate.getComments(); |
| | | if (comments != null) { |
| | | for (CommentInfo commentInfo: comments){ |
| | | if (cid.equals(commentInfo.getId())) { |
| | | text = commentInfo.getContent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("text", "安妮贝拉卡通版儿拉卡通版拉卡通版拉卡通版拉卡通版拉卡通版拉卡通版拉卡通版");
|
| | | data.put("text", text); |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
| | | * |
| | | * @return |
| | | */ |
| | | public List<GoodsEvaluate> query(int start, int count, String key, Integer state) { |
| | | public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("dynamicType").is(dynamicType)); |
| | | if (state != null) { |
| | | query.addCriteria(Criteria.where("state").is(state)); |
| | | } |
| | |
| | | return mongoTemplate.find(query, GoodsEvaluate.class); |
| | | } |
| | | |
| | | public long count(String key, Integer state) { |
| | | public long count(String key, Integer state, int dynamicType) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("dynamicType").is(dynamicType)); |
| | | |
| | | if (state != null) { |
| | | query.addCriteria(Criteria.where("state").is(state)); |
| | | } |
| | |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public List<GoodsEvaluate> queryValid(int start, int count) { |
| | | public List<GoodsEvaluate> queryValid(int start, int count, int dynamicType) { |
| | | Date now = new Date(); |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("state").is(dynamicType)); |
| | | query.addCriteria(Criteria.where("state").is(1)); |
| | | query.addCriteria(Criteria.where("startTime").lte(now)); |
| | | query.addCriteria(Criteria.where("endTime").gte(now)); |
| | |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public long countValid() { |
| | | public long countValid(int dynamicType) { |
| | | Date now = new Date(); |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("dynamicType").is(dynamicType)); |
| | | query.addCriteria(Criteria.where("state").is(1)); |
| | | query.addCriteria(Criteria.where("startTime").lte(now)); |
| | | query.addCriteria(Criteria.where("endTime").gte(now)); |
| | |
| | | @Field("mainPicNum") |
| | | private Integer mainPicNum; // 图片主图 |
| | | |
| | | @Field("dynamicType") |
| | | private Integer dynamicType; // 1发圈 2素材 |
| | | |
| | | |
| | | private String startTimeChar; |
| | |
| | | this.type = type; |
| | | } |
| | | |
| | | public Integer getDynamicType() { |
| | | return dynamicType; |
| | | } |
| | | |
| | | public void setDynamicType(Integer dynamicType) { |
| | | this.dynamicType = dynamicType; |
| | | } |
| | | |
| | | } |
| | |
| | | import java.io.Serializable; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | |
| | | public class ImgInfo implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | // 商品信息 |
| | | @Expose |
| | | private SimpleGoods goods; |
| | | |
| | | private GoodsDetailVO goodsVO; |
| | | |
| | | private String activityPic; |
| | | private String activityUrl; |
| | |
| | | this.activityPic = activityPic; |
| | | } |
| | | |
| | | public GoodsDetailVO getGoodsVO() { |
| | | return goodsVO; |
| | | } |
| | | |
| | | public void setGoodsVO(GoodsDetailVO goodsVO) { |
| | | this.goodsVO = goodsVO; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser; |
| | | 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.GoodsEvaluate.EvaluateEnum; |
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo; |
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum; |
| | | import com.yeshi.fanli.entity.dynamic.SimpleGoods; |
| | |
| | | |
| | | if (record.getStartTime() != null && record.getEndTime().getTime() <= record.getStartTime().getTime()) |
| | | throw new GoodsEvaluateException(1, "截止时间必须大于开始时间"); |
| | | } |
| | | |
| | | Integer dynamicType = record.getDynamicType(); |
| | | if (dynamicType == null) { |
| | | record.setDynamicType(1); |
| | | } |
| | | |
| | | if (record.getShareNum() == null) |
| | |
| | | if (pics != null) { |
| | | listpic = new ArrayList<>(); |
| | | for (int i = 0; i < pics.length; i++ ) { |
| | | if(pics[i].startsWith("http")){ |
| | | listpic.add(pics[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | String picLink = pics[i]; |
| | | if (fileRequest != null) { |
| | | for (int i = 0; i < 9; i++) { |
| | | MultipartFile file = fileRequest.getFile("file" + i); |
| | | if (file == null) { |
| | | continue; |
| | | } |
| | | // 上传文件 |
| | | String picLink = uploadPicture(file); |
| | | if (listpic != null && listpic.size() > i) { |
| | | // 需要删除的list |
| | | String delUrl = listpic.get(i); |
| | | listDel.add(delUrl); |
| | | listpic.set(i, picLink); |
| | | continue; |
| | | picLink = uploadPicture(file); |
| | | } |
| | | if (picLink.startsWith("http")) { |
| | | listpic.add(picLink); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 指定主图 |
| | |
| | | } |
| | | |
| | | if (listpic != null && listpic.size() > 0) { |
| | | // 对比图片 |
| | | for (int j = 0; j < listOld.size(); j++) { |
| | | boolean del = true; |
| | | for (int i = 0; i < listpic.size(); i++) { |
| | | if (listpic.get(i).equals(listOld.get(j))) { |
| | | del = false; |
| | | break; |
| | | } |
| | | } |
| | | if (del) |
| | | listDel.add(listOld.get(j)); |
| | | } |
| | | |
| | | for (int i = 0; i < listpic.size(); i++) { |
| | | ImgInfo imgInfo0 = new ImgInfo(); |
| | | imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); |
| | |
| | | if (picNum - 1 == i) { |
| | | imgInfo0.setType(ImgEnum.goods); |
| | | // 商品信息 |
| | | GoodsDetailVO goodsDetailVO = null; // TODO |
| | | // getGoodsDetailVO(goodsId, goodsType); |
| | | // if (goodsDetailVO == null) { |
| | | // throw new GoodsEvaluateException(1, "该商品信息不存在"); |
| | | // } |
| | | GoodsDetailVO goodsDetailVO = getGoodsDetailVO(goodsId, goodsType); |
| | | if (goodsDetailVO == null) { |
| | | throw new GoodsEvaluateException(1, "该商品信息不存在"); |
| | | } |
| | | |
| | | SimpleGoods simpleGoods = new SimpleGoods(); |
| | | simpleGoods.setGoodsId(goodsId); |
| | | simpleGoods.setGoodsType(goodsType); |
| | | // simpleGoods.setPrice(goodsDetailVO.getCouponPrice()); |
| | | // CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo(); |
| | | // if (couponInfo == null) { |
| | | // simpleGoods.setState(1); |
| | | // } else { |
| | | // simpleGoods.setAmount(couponInfo.getAmount()); |
| | | // simpleGoods.setState(0); |
| | | // } |
| | | simpleGoods.setPrice(goodsDetailVO.getCouponPrice()); |
| | | CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo(); |
| | | if (couponInfo == null) { |
| | | simpleGoods.setState(1); |
| | | } else { |
| | | simpleGoods.setAmount(couponInfo.getAmount()); |
| | | simpleGoods.setState(0); |
| | | } |
| | | imgInfo0.setGoods(simpleGoods); |
| | | } else { |
| | | imgInfo0.setType(ImgEnum.img); |
| | | } |
| | | listImg.add(imgInfo0); |
| | | } |
| | | } |
| | | |
| | | if (listOld != null && listOld.size() > 0) { |
| | | for (int j = 0; j < listOld.size(); j++) { |
| | | boolean del = true; |
| | | String oldPic = listOld.get(j); |
| | | for (ImgInfo imgInfo: listImg) { |
| | | String url = imgInfo.getUrl(); |
| | | if (url.equals(oldPic)) { |
| | | del = false; |
| | | } |
| | | } |
| | | if (del) |
| | | listDel.add(listOld.get(j)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveMultipleGoods(String pid, String videoUrl, String goodsList, |
| | | MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | | } |
| | | |
| | | GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid); |
| | | if (resultObj == null) |
| | | throw new GoodsEvaluateException(1, "第一部分信息缺失"); |
| | | |
| | | // 原封视频面图 |
| | | ImgInfo imgVideo = null; |
| | | List<String> listDel = new ArrayList<String>(); |
| | | List<ImgInfo> oldGoodsList = new ArrayList<ImgInfo>(); |
| | | |
| | | // 处理图片 |
| | | List<ImgInfo> resultList = resultObj.getImgList(); |
| | | if (resultList != null && resultList.size() > 0) { |
| | | for (ImgInfo info : resultList) { |
| | | ImgEnum type = info.getType(); |
| | | if (type == ImgEnum.video) { |
| | | imgVideo = info; |
| | | } else if (type == ImgEnum.goods) { |
| | | oldGoodsList.add(info); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 视频部分 |
| | | if (fileRequest != null) { |
| | | MultipartFile filevideo = fileRequest.getFile("filevideo"); |
| | | if (filevideo != null) { |
| | | if (StringUtil.isNullOrEmpty(videoUrl)) { |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | |
| | | String picLink = uploadPicture(filevideo); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | } else { |
| | | imgVideo = new ImgInfo(); |
| | | imgVideo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgVideo.setW(1); |
| | | imgVideo.setH(1); |
| | | imgVideo.setLarge(true); |
| | | imgVideo.setPid(pid); |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | imgVideo.setType(ImgEnum.video); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<ImgInfo> listImg = new ArrayList<ImgInfo>(); |
| | | if (imgVideo != null) { |
| | | if (!StringUtil.isNullOrEmpty(videoUrl)) { |
| | | if (imgVideo != null && StringUtil.isNullOrEmpty(imgVideo.getUrl())) { |
| | | throw new GoodsEvaluateException(1, "视频封面图不能为空"); |
| | | } |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | listImg.add(imgVideo); |
| | | } else { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(goodsList)) { |
| | | String[] goodsArray = goodsList.split(","); |
| | | if (goodsArray != null && goodsArray.length > 0) { |
| | | for (int i = 0; i < goodsArray.length || i < 9; i++) { |
| | | String goodsids = goodsArray[i]; |
| | | String[] g = goodsids.split("-"); |
| | | GoodsDetailVO goodsDetailVO = getGoodsDetailVO(Long.parseLong(g[0]), Integer.parseInt(g[1])); |
| | | if (goodsDetailVO == null) { |
| | | continue; |
| | | } |
| | | |
| | | String picUrl = goodsDetailVO.getPicUrl(); |
| | | if (fileRequest != null) { |
| | | MultipartFile file = fileRequest.getFile("file" + i); |
| | | if (file != null) { |
| | | picUrl = uploadPicture(file); |
| | | } |
| | | } |
| | | |
| | | ImgInfo imgInfo0 = new ImgInfo(); |
| | | imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgInfo0.setW(1); |
| | | imgInfo0.setH(1); |
| | | imgInfo0.setLarge(false); |
| | | imgInfo0.setPid(pid); |
| | | imgInfo0.setUrl(picUrl); |
| | | imgInfo0.setUrlHD(picUrl); |
| | | imgInfo0.setType(ImgEnum.goods); |
| | | |
| | | SimpleGoods simpleGoods = new SimpleGoods(); |
| | | simpleGoods.setGoodsId(goodsDetailVO.getGoodsId()); |
| | | simpleGoods.setGoodsType(goodsDetailVO.getGoodsType()); |
| | | simpleGoods.setPrice(goodsDetailVO.getCouponPrice()); |
| | | CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo(); |
| | | if (couponInfo == null) { |
| | | simpleGoods.setState(1); |
| | | } else { |
| | | simpleGoods.setAmount(couponInfo.getAmount()); |
| | | simpleGoods.setState(0); |
| | | } |
| | | imgInfo0.setGoods(simpleGoods); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 数据对比 删除图片 |
| | | if (oldGoodsList != null && oldGoodsList.size() > 0) { |
| | | for (ImgInfo old : oldGoodsList) { |
| | | ImgEnum type = old.getType(); |
| | | if (type != ImgEnum.goods) { |
| | | continue; |
| | | } |
| | | |
| | | boolean del = false; |
| | | long oldGoodsId = old.getGoods().getGoodsId().longValue(); |
| | | int oldGoodsType = old.getGoods().getGoodsType().intValue(); |
| | | for (ImgInfo newInfo : listImg) { |
| | | ImgEnum type2 = old.getType(); |
| | | if (type2 != ImgEnum.goods) { |
| | | continue; |
| | | } |
| | | |
| | | if (oldGoodsId == newInfo.getGoods().getGoodsId().longValue() |
| | | && oldGoodsType == newInfo.getGoods().getGoodsType().intValue()) { |
| | | String url = newInfo.getUrl(); |
| | | if (url.equals(old.getUrl())) { |
| | | |
| | | } else if (url.contains(FilePathEnum.goodsEvaluate.getPath())) { |
| | | del = true; |
| | | } else { |
| | | newInfo.setUrl(old.getUrl()); |
| | | newInfo.setUrlHD(old.getUrlHD()); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (del) { |
| | | listDel.add(old.getUrl()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 保存图片信息 |
| | | resultObj.setImgList(listImg); |
| | | goodsEvaluateDao.save(resultObj); |
| | | |
| | | // 删除图片 |
| | | if (listDel.size() > 0) { |
| | | for (String url : listDel) { |
| | | if (url.contains(FilePathEnum.goodsEvaluate.getPath())) { |
| | | removePicture(url); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void saveGoodsCoupon(String pid, String tags, String content) throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | | } |
| | | |
| | | GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid); |
| | | if (resultObj == null) |
| | | throw new GoodsEvaluateException(1, "第一部分信息缺失"); |
| | | |
| | | CommentInfo goodsCoupon = null; |
| | | CommentInfo currencyCoupon = null; |
| | | List<CommentInfo> oldComments = resultObj.getComments(); |
| | | if (oldComments != null) { |
| | | for (CommentInfo info: oldComments) { |
| | | if(CommentInfoEnum.goodsCoupon == info.getType()) { |
| | | goodsCoupon = info; |
| | | } else if (CommentInfoEnum.currencyCoupon == info.getType()) { |
| | | currencyCoupon = info; |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<CommentInfo> comments = new ArrayList<>(); |
| | | if (!StringUtil.isNullOrEmpty(content)) { |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | if (goodsCoupon != null) { |
| | | commentInfo.setId(goodsCoupon.getId()); |
| | | } else { |
| | | commentInfo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | } |
| | | commentInfo.setContent(content); |
| | | commentInfo.setType(CommentInfoEnum.goodsCoupon); |
| | | comments.add(currencyCoupon); |
| | | } |
| | | |
| | | if (currencyCoupon != null) { |
| | | comments.add(currencyCoupon); |
| | | } |
| | | |
| | | resultObj.setComments(comments); |
| | | goodsEvaluateDao.save(resultObj); |
| | | } |
| | | |
| | | @Override |
| | | public void saveSingleGoodsCoupon(String pid, CommentInfo commentInfo) throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | |
| | | if (resultObj == null) |
| | | throw new GoodsEvaluateException(1, "第一部分信息缺失"); |
| | | |
| | | CommentInfo goodsCoupon = null; |
| | | CommentInfo currencyCoupon = null; |
| | | List<CommentInfo> oldComments = resultObj.getComments(); |
| | | if (oldComments != null) { |
| | | for (CommentInfo info: oldComments) { |
| | | if(CommentInfoEnum.goodsCoupon == info.getType()) { |
| | | goodsCoupon = info; |
| | | } else if (CommentInfoEnum.currencyCoupon == info.getType()) { |
| | | currencyCoupon = info; |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<CommentInfo> comments = new ArrayList<>(); |
| | | if (goodsCoupon != null) { |
| | | comments.add(goodsCoupon); |
| | | } |
| | | |
| | | if (commentInfo != null) { |
| | | if (currencyCoupon != null) { |
| | | commentInfo.setId(currencyCoupon.getId()); |
| | | } else { |
| | | commentInfo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | } |
| | | commentInfo.setType(CommentInfoEnum.currencyCoupon); |
| | | |
| | | // 标签信息 |
| | | List<ClientTextStyleVO> tagList = new ArrayList<>(); |
| | | String couponSource = commentInfo.getCouponSource(); |
| | | if (!StringUtil.isNullOrEmpty(couponSource)) { |
| | | ClientTextStyleVO styleVO = new ClientTextStyleVO(); |
| | | styleVO.setColor("#16C253"); |
| | | styleVO.setContent(couponSource); |
| | | tagList.add(styleVO); |
| | | } |
| | | String coupon = commentInfo.getCoupon(); |
| | | if (!StringUtil.isNullOrEmpty(coupon)) { |
| | | ClientTextStyleVO styleVO = new ClientTextStyleVO(); |
| | | styleVO.setColor("#E5005C"); |
| | | styleVO.setContent(coupon); |
| | | tagList.add(styleVO); |
| | | } |
| | | commentInfo.setTagList(tagList); |
| | | |
| | | comments.add(commentInfo); |
| | | } |
| | | |
| | | resultObj.setComments(comments); |
| | | |
| | | goodsEvaluateDao.save(resultObj); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveActivityPic(String pid, ImgInfo imgInfo, MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception { |
| | | public void saveActivityPic(String pid, ImgInfo imgInfo, MultipartHttpServletRequest fileRequest) |
| | | throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | | } |
| | |
| | | for(ImgInfo info: resultList) { |
| | | if (info.getType() == ImgEnum.activity) { |
| | | activityPic = info.getActivityPic(); |
| | | imgVideo = info; |
| | | imgactivity = info; |
| | | } else { |
| | | imgVideo = info; |
| | | videoPic = info.getUrl(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | List<ImgInfo> listImg = new ArrayList<ImgInfo>(); |
| | | if (fileRequest != null) { |
| | |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(activityPic) || !StringUtil.isNullOrEmpty(imgInfo.getActivityUrl())) { |
| | | if (imgactivity != null) { |
| | | imgactivity.setUrl(activityPic); |
| | | imgactivity.setUrlHD(activityPic); |
| | | imgactivity.setActivityUrl(imgInfo.getActivityUrl()); |
| | | } else { |
| | | imgactivity = new ImgInfo(); |
| | | imgactivity.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgactivity.setW(1); |
| | | imgactivity.setH(1); |
| | | imgactivity.setLarge(true); |
| | | imgactivity.setPid(pid); |
| | | imgactivity.setUrl(activityPic); |
| | | imgactivity.setUrlHD(activityPic); |
| | | imgactivity.setActivityUrl(imgInfo.getActivityUrl()); |
| | | imgactivity.setType(ImgEnum.activity); |
| | | } |
| | | listImg.add(imgactivity); |
| | | } |
| | | resultObj.setImgList(listImg); |
| | | goodsEvaluateDao.save(resultObj); |
| | | } |
| | | |
| | | @Override |
| | | public void saveSuCai(String pid, String videoUrl, String picUrls, |
| | | MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | | } |
| | | |
| | | GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid); |
| | | if (resultObj == null) |
| | | throw new GoodsEvaluateException(1, "第一部分信息缺失"); |
| | | |
| | | // 原封视频面图 |
| | | ImgInfo imgVideo = null; |
| | | List<String> listDel = new ArrayList<String>(); |
| | | List<String> listOld = new ArrayList<String>(); |
| | | |
| | | // 处理图片 |
| | | List<ImgInfo> resultList = resultObj.getImgList(); |
| | | if (resultList != null && resultList.size() > 0) { |
| | | for (ImgInfo info : resultList) { |
| | | ImgEnum type = info.getType(); |
| | | if (type == ImgEnum.video) { |
| | | imgVideo = info; |
| | | } else if (type == ImgEnum.img) { |
| | | String url = info.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listOld.add(url); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 视频部分 |
| | | if (fileRequest != null) { |
| | | MultipartFile filevideo = fileRequest.getFile("filevideo"); |
| | | if (filevideo != null) { |
| | | if (StringUtil.isNullOrEmpty(videoUrl)) { |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | |
| | | String picLink = uploadPicture(filevideo); |
| | | if (imgVideo != null){ |
| | | imgVideo.setUrl(activityPic); |
| | | imgVideo.setUrlHD(activityPic); |
| | | imgVideo.setVideoUrl(imgInfo.getVideoUrl()); |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | } else { |
| | | imgVideo = new ImgInfo(); |
| | | imgVideo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | |
| | | imgVideo.setH(1); |
| | | imgVideo.setLarge(true); |
| | | imgVideo.setPid(pid); |
| | | imgVideo.setUrl(activityPic); |
| | | imgVideo.setUrlHD(activityPic); |
| | | imgVideo.setActivityUrl(imgInfo.getActivityUrl()); |
| | | imgVideo.setType(ImgEnum.activity); |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | imgVideo.setType(ImgEnum.video); |
| | | } |
| | | listImg.add(imgVideo); |
| | | } |
| | | resultObj.setImgList(listImg); |
| | | goodsEvaluateDao.save(resultObj); |
| | | } |
| | | |
| | | List<ImgInfo> listImg = new ArrayList<ImgInfo>(); |
| | | if (imgVideo != null) { |
| | | if (!StringUtil.isNullOrEmpty(videoUrl)) { |
| | | if (imgVideo != null && StringUtil.isNullOrEmpty(imgVideo.getUrl())) { |
| | | throw new GoodsEvaluateException(1, "视频封面图不能为空"); |
| | | } |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | listImg.add(imgVideo); |
| | | } else { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 编辑图片 |
| | | List<String> listpic = null; |
| | | if (!StringUtil.isNullOrEmpty(picUrls)) { |
| | | String[] pics = picUrls.split(","); |
| | | if (pics != null) { |
| | | listpic = new ArrayList<>(); |
| | | for (int i = 0; i < pics.length; i++) { |
| | | String picLink = pics[i]; |
| | | if (fileRequest != null) { |
| | | MultipartFile file = fileRequest.getFile("file" + i); |
| | | if (file != null) { |
| | | picLink = uploadPicture(file); |
| | | } |
| | | } |
| | | |
| | | if (picLink.startsWith("http")) { |
| | | listpic.add(picLink); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (listpic != null && listpic.size() > 0) { |
| | | for (int i = 0; i < listpic.size(); i++) { |
| | | ImgInfo imgInfo0 = new ImgInfo(); |
| | | imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgInfo0.setW(1); |
| | | imgInfo0.setH(1); |
| | | imgInfo0.setLarge(false); |
| | | imgInfo0.setPid(pid); |
| | | imgInfo0.setUrl(listpic.get(i)); |
| | | imgInfo0.setUrlHD(listpic.get(i)); |
| | | imgInfo0.setType(ImgEnum.img); |
| | | listImg.add(imgInfo0); |
| | | } |
| | | } |
| | | |
| | | if (listOld != null && listOld.size() > 0) { |
| | | for (int j = 0; j < listOld.size(); j++) { |
| | | boolean del = true; |
| | | String oldPic = listOld.get(j); |
| | | for (ImgInfo imgInfo: listImg) { |
| | | String url = imgInfo.getUrl(); |
| | | if (url.equals(oldPic)) { |
| | | del = false; |
| | | } |
| | | } |
| | | if (del) |
| | | listDel.add(listOld.get(j)); |
| | | } |
| | | } |
| | | |
| | | resultObj.setImgList(listImg); |
| | | goodsEvaluateDao.save(resultObj); |
| | | |
| | | // 删除图片 |
| | | if (listDel.size() > 0) { |
| | | for (String url : listDel) { |
| | | if (url.contains(FilePathEnum.goodsEvaluate.getPath())) { |
| | | removePicture(url); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteBatchByPrimaryKey(List<String> list) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void release(String id) throws GoodsEvaluateException { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateDao.getById(id); |
| | | if (goodsEvaluate == null) { |
| | | throw new GoodsEvaluateException(1, "动态已不存在"); |
| | | } |
| | | goodsEvaluate.setState(1); |
| | | goodsEvaluateDao.save(goodsEvaluate); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void deleteComment(String pid, List<String> list) throws GoodsEvaluateException { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<GoodsEvaluate> query(int start, int count, String key, Integer state) { |
| | | return goodsEvaluateDao.query(start, count, key, state); |
| | | public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType) { |
| | | return goodsEvaluateDao.query(start, count, key, state, dynamicType); |
| | | } |
| | | |
| | | @Override |
| | | public long count(String key, Integer state) { |
| | | return goodsEvaluateDao.count(key, state); |
| | | public long count(String key, Integer state, int dynamicType) { |
| | | return goodsEvaluateDao.count(key, state, dynamicType); |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(value = "dynamicCache", key = "'queryValidEvaluateCache-'+#start") |
| | | public List<GoodsEvaluate> queryValidEvaluateCache(int start, int count) { |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count); |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, 1); |
| | | |
| | | // 更新商品信息 |
| | | executor.execute(new Runnable() { |
| | |
| | | |
| | | @Override |
| | | public long countValid() { |
| | | return goodsEvaluateDao.countValid(); |
| | | return goodsEvaluateDao.countValid(1); |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") |
| | | public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type) { |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type); |
| | | // 更新商品信息 |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | updateGoodInfo(list); |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public long countValidMaterials(int type) { |
| | | return goodsEvaluateDao.countValid(type); |
| | | } |
| | | |
| | | /** |
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public FileUploadResult drawDynamicGoodsPoster(String erCodeUrl, String portrait, String inviteCode, GoodsDetailVO goods) { |
| | | // 二维码流 |
| | | InputStream erCodeStream = null; |
| | | try { |
| | | erCodeStream = QRCodeUtil.getInstance(250).encode(erCodeUrl); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | |
| | | // 头像 |
| | | InputStream portraitStream = null; |
| | | if (!StringUtil.isNullOrEmpty(portrait)) { |
| | | try { |
| | | portraitStream = HttpUtil.getAsInputStream(portrait); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if (portraitStream == null) { |
| | | portraitStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_default_head.jpg"); |
| | | } |
| | | |
| | | // 画图 |
| | | InputStream drawStream = ImageUtil.drawGoodsPoster(erCodeStream, portraitStream,inviteCode, goods); |
| | | // 上传位置 |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String upPath = FilePathEnum.shareGoods.getPath() + uuid + "_" + goods.getGoodsId() + "_" + System.currentTimeMillis() + ".png"; |
| | | // 上传文件 |
| | | return COSManager.getInstance().uploadInputStream(drawStream, upPath); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public FileUploadResult drawGoodsPoster(String erCodeUrl, String portrait, GoodsDetailVO goods) {
|
| | | // 二维码流
|
| | | InputStream erCodeStream = null;
|
| | |
| | | * @param state |
| | | * @return |
| | | */ |
| | | public List<GoodsEvaluate> query(int start, int count, String key, Integer state); |
| | | public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType); |
| | | |
| | | public long count(String key, Integer state); |
| | | public long count(String key, Integer state,int dynamicType); |
| | | |
| | | |
| | | /** |
| | |
| | | throws GoodsEvaluateException, Exception; |
| | | |
| | | |
| | | /** |
| | | * 多个商品保存信息 |
| | | * @param pid |
| | | * @param videoUrl |
| | | * @param goodsList |
| | | * @param fileRequest |
| | | * @throws GoodsEvaluateException |
| | | * @throws Exception |
| | | */ |
| | | public void saveMultipleGoods(String pid, String videoUrl, String goodsList, MultipartHttpServletRequest fileRequest) |
| | | throws GoodsEvaluateException, Exception; |
| | | |
| | | |
| | | /** |
| | | * 素材 |
| | | * @param pid |
| | | * @param videoUrl |
| | | * @param picUrls |
| | | * @param fileRequest |
| | | * @throws GoodsEvaluateException |
| | | * @throws Exception |
| | | */ |
| | | public void saveSuCai(String pid, String videoUrl, String picUrls, MultipartHttpServletRequest fileRequest) |
| | | throws GoodsEvaluateException, Exception; |
| | | |
| | | |
| | | /** |
| | | * 查询素材 |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<GoodsEvaluate> queryMaterialsCache(int start, int count,int type); |
| | | |
| | | public long countValidMaterials(int type); |
| | | |
| | | |
| | | public void saveGoodsCoupon(String pid, String tags, String content) throws GoodsEvaluateException, Exception; |
| | | |
| | | |
| | | public void release(String id) throws GoodsEvaluateException; |
| | | |
| | | |
| | | } |
| | |
| | | * @return
|
| | | */
|
| | | public FileUploadResult drawGoodsPosterXCX(InputStream erCodeStream, UserInfo user, GoodsDetailVO goods);
|
| | | |
| | | public FileUploadResult drawDynamicGoodsPoster(String erCodeUrl, String portrait, String inviteCode, GoodsDetailVO goods); |
| | | }
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 分析海报图 |
| | | * @param qrcode |
| | | * @param portraitStream |
| | | * @param goods |
| | | * @return |
| | | */ |
| | | public static InputStream drawGoodsPoster(InputStream qrcode, InputStream portraitStream, String inviteCode, GoodsDetailVO goods) { |
| | | try { |
| | | String fontPath = "/usr/share/fonts/PingFang_Medium.ttf"; |
| | | String os = System.getProperty("os.name"); |
| | | if (os.toLowerCase().startsWith("win")) { |
| | | fontPath = "D:/PingFang_Medium.ttf"; |
| | | } |
| | | |
| | | String fontBoldPath = "/usr/share/fonts/PingFang_Heavy_0.ttf"; |
| | | if (os.toLowerCase().startsWith("win")) { |
| | | fontBoldPath = "D:/PingFang_Heavy_0.ttf"; |
| | | } |
| | | Font font24 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(24.0f); |
| | | Font font26 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(26.0f); |
| | | Font boldFont36 = Font.createFont(Font.PLAIN, new File(fontBoldPath)).deriveFont(36.0f); |
| | | |
| | | int px = 640; // 图片宽度 |
| | | int py = 1154; // 图片高度 |
| | | final BufferedImage targetImg = new BufferedImage(px, py, BufferedImage.TYPE_INT_RGB); |
| | | HashMap<Key, Object> mapH = new HashMap<Key, Object>(); |
| | | mapH.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);// 抗锯齿 (抗锯齿总开关) |
| | | mapH.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);// 文字抗锯齿 |
| | | |
| | | final Graphics2D g2d = (Graphics2D) targetImg.getGraphics(); |
| | | g2d.setRenderingHints(mapH); |
| | | g2d.setColor(Color.WHITE); |
| | | g2d.fillRect(0, 0, px, py); |
| | | |
| | | int x = 640; |
| | | int y = 640; |
| | | int spacing = 20; // 右边距 |
| | | |
| | | // 1、画商品主图 |
| | | InputStream picStream = HttpUtil.getAsInputStream(goods.getPicUrl().replace("https://", "http://")); |
| | | // InputStream picStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/share/test_pic1.jpg"); |
| | | g2d.drawImage(ImageIO.read(picStream), 0, 0, x, y, null); |
| | | |
| | | // 2、画来源图标 |
| | | int length = 10; |
| | | int row1 = 450; |
| | | int iconWidth = 72; |
| | | String source = ""; |
| | | InputStream icon = null; |
| | | int goodsType = goods.getGoodsType(); |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | source = "淘宝"; |
| | | if (goods.getShopType() == 10) { |
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_tb.png"); |
| | | } else { |
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_tm.png"); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | source = "京东"; |
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_jd.png"); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | source = "拼多多"; |
| | | length = 9; |
| | | row1 = row1 - 26; |
| | | iconWidth = iconWidth + 28; |
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_pdd.png"); |
| | | } else { |
| | | return null; |
| | | } |
| | | g2d.drawImage(ImageIO.read(icon), spacing, y + 20, iconWidth, 34, null); |
| | | |
| | | // 3、商品标题内容 |
| | | int row = 0; |
| | | String title = goods.getTitle(); |
| | | length = ImageUtil.getTextLengthByWidth(g2d, font26, title, row1, length); |
| | | g2d.setFont(font26); |
| | | g2d.setColor(new Color(0, 0, 0)); |
| | | g2d.drawString(title.substring(0, length), spacing + iconWidth + 5, y + 45 + row * 36); |
| | | |
| | | row++; |
| | | title = title.substring(length); |
| | | int length2 = ImageUtil.getTextLengthByWidth(g2d, font26, title, 600, 11); |
| | | if (length2 > 24) { |
| | | g2d.drawString(title.substring(0, 21) + "...", spacing, y + 45 + row * 36); |
| | | } else { |
| | | g2d.drawString(title.substring(0, length2), spacing, y + 45 + row * 36); |
| | | } |
| | | |
| | | if (!goods.isHasCoupon()) { |
| | | // 无券 |
| | | g2d.setColor(new Color(229, 0, 92)); |
| | | g2d.drawString("¥ ", spacing, y + 125); |
| | | g2d.setFont(boldFont36); |
| | | g2d.drawString(MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()).toString(), spacing + 21, y + 125); |
| | | } else { |
| | | // 券后价 |
| | | g2d.setFont(font26); |
| | | g2d.setColor(new Color(229, 0, 92)); |
| | | g2d.drawString("券后价 ¥ ", spacing, y + 125); |
| | | |
| | | g2d.setFont(boldFont36); |
| | | String couponPrice = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()).toString(); |
| | | g2d.drawString(couponPrice, spacing + 116, y + 125); |
| | | |
| | | FontMetrics fm2 = g2d.getFontMetrics(boldFont36); |
| | | int textLength1 = 116 + fm2.stringWidth(couponPrice); |
| | | |
| | | // 渠道原价 |
| | | g2d.setColor(new Color(153, 153, 153)); |
| | | g2d.setFont(font24); |
| | | g2d.drawString(goods.getPriceName() + " ¥ " + MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()), |
| | | spacing + textLength1 + 10, y + 125); |
| | | |
| | | // 券字 |
| | | InputStream quan = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_quan.png"); |
| | | g2d.drawImage(ImageIO.read(quan), spacing, y + 140, 47, 40, null); |
| | | // 券面额 |
| | | String quanAmount = "¥ " + goods.getCouponInfo().getAmount(); |
| | | FontMetrics fm = g2d.getFontMetrics(font26); |
| | | int textLength = fm.stringWidth(quanAmount); |
| | | |
| | | g2d.setFont(font26); |
| | | g2d.setColor(new Color(229, 0, 92)); |
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2d.drawRoundRect(spacing + 42, y + 140, textLength + 20, 39, 10, 10); |
| | | g2d.drawString(quanAmount, spacing + 55, y + 170); |
| | | } |
| | | |
| | | // 自营 、包邮 |
| | | if (goods.getShopType() == 21) { |
| | | InputStream ziying = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_ziying.png"); |
| | | g2d.drawImage(ImageIO.read(ziying), spacing + 180, y + 150, 60, 30, null); |
| | | } else if (goods.isBaoyou()) { |
| | | InputStream ziying = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_baoyou.png"); |
| | | g2d.drawImage(ImageIO.read(ziying), spacing + 180, y + 150, 60, 30, null); |
| | | } |
| | | |
| | | // 销量 |
| | | String sale = null; |
| | | int salesType = goods.getSalesType(); |
| | | if (salesType == 1) { |
| | | sale = "月销"; |
| | | } else if (salesType == 2) { |
| | | sale = "2小时销量"; |
| | | } else if (salesType == 3) { |
| | | sale = "今日销量"; |
| | | } else if (salesType == 4) { |
| | | sale = "总销量"; |
| | | } else { |
| | | sale = "月销"; |
| | | } |
| | | sale = sale + " " + goods.getSalesCount(); |
| | | FontMetrics fm = g2d.getFontMetrics(font24); |
| | | int textLength = fm.stringWidth(sale); |
| | | g2d.setFont(font24); |
| | | g2d.setColor(new Color(153, 153, 153)); |
| | | g2d.drawString(sale, spacing + 580 - textLength, y + 125); |
| | | |
| | | |
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2d.setColor(new Color(255,222, 235)); |
| | | g2d.fillRoundRect(spacing, y + 200, 385, 203, 10, 10); |
| | | |
| | | Font font22 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(22.0f); |
| | | g2d.setFont(font22); |
| | | g2d.setColor(new Color(229,0, 92)); |
| | | g2d.drawString("如何下单?", spacing + 6, y + 245); |
| | | g2d.drawString("1.长按识别本图", spacing + 6, y + 290); |
| | | g2d.drawString("2.点击页面右上角[ ... ],选择[复制链接]", spacing + 6, y + 330); |
| | | g2d.drawString("3.打开"+source+"App,领券下单", spacing + 6, y + 370); |
| | | |
| | | // 二维码图框 |
| | | InputStream codeFrame = ImageUtil.class.getClassLoader().getResourceAsStream("image/share/qr_code_frame01.png"); |
| | | g2d.drawImage(ImageIO.read(codeFrame), spacing + 405, y + 200, 200, 203, null); |
| | | |
| | | // 画二维码 |
| | | int codeSize = 170; |
| | | int pX = spacing + 420; |
| | | int pY = y + 215; |
| | | g2d.drawImage(ImageIO.read(qrcode), pX, pY, codeSize, codeSize, null); |
| | | |
| | | int portraitSize = 200 * 5 / 23; |
| | | int pPX = pX + codeSize / 2 - portraitSize / 2; |
| | | int pPY = pY + codeSize / 2 - portraitSize / 2; |
| | | // 头像白色边框 |
| | | g2d.setColor(Color.WHITE); |
| | | g2d.fillRoundRect(pPX - 4, pPY - 4, portraitSize + 8, portraitSize + 8, 5, 5); |
| | | g2d.setRenderingHints(mapH); |
| | | // 画头像 |
| | | BufferedImage portraitImg = ImageIO.read(portraitStream); |
| | | portraitImg = ImageUtil.zoomInImage(portraitImg, portraitSize, portraitSize); |
| | | portraitImg = ImageUtil.roundImage(portraitImg, 10); |
| | | g2d.drawImage(portraitImg, pPX, pPY, portraitSize, portraitSize, null); |
| | | |
| | | |
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2d.setColor(new Color(255,231, 224)); |
| | | g2d.fillRoundRect(spacing, y + 420, 607, 79, 10, 10); |
| | | |
| | | InputStream banliStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/banlikuaisheng.png"); |
| | | g2d.drawImage(ImageIO.read(banliStream), spacing + 20, y + 440, 170, 38, null); |
| | | |
| | | inviteCode = "邀请码:" + inviteCode; |
| | | Font font26d28 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(26.28f); |
| | | FontMetrics fmcode = g2d.getFontMetrics(font26d28); |
| | | int codeLength = fmcode.stringWidth(inviteCode); |
| | | // 邀请码背景 |
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | g2d.setColor(new Color(229,71, 27)); |
| | | g2d.fillRoundRect(spacing + (600 - (int)(codeLength * 1.1)), y + 440, 10 + codeLength, 37, 10, 10); |
| | | // 邀请码文字 |
| | | g2d.setFont(font26d28); |
| | | g2d.setColor(new Color(255, 255, 255)); |
| | | g2d.drawString(inviteCode, spacing + (600 - (int)(codeLength * 1.1) + 5), y + 468); |
| | | |
| | | g2d.dispose(); |
| | | |
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream(); |
| | | ImageIO.write(targetImg, "JPEG", aos); |
| | | return new ByteArrayInputStream(aos.toByteArray()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 单个商品分享图
|
| | | *
|
| | | * @param qrcode 二维码流
|
| | |
| | | mongo.dbname=flq
|
| | | mongo.dbname=flq-wxmp
|
| | | mongo.port=27016
|
| | | #开发环境
|
| | | #mongo.host=192.168.1.253
|
| | |
| | | redis.addr=192.168.1.253
|
| | | #redis.addr=192.168.1.253
|
| | | #redis.port=6379 |
| | | #redis.auth=123456
|
| | | redis.addr=193.112.34.40
|
| | | redis.port=6379 |
| | | redis.auth=123456
|
| | | redis.auth=weikou2014
|
| | | redis.max_total=1024 |
| | | redis.max_idle=200
|
| | | redis.max_wait=10000
|
| | |
| | |
|
| | | package org.fanli;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.io.InputStreamReader;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Scanner;
|
| | |
|
| | | import org.junit.Test;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
| | |
|
| | | @Test
|
| | | public void test2() {
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(571754672318L,
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET));
|
| | | System.out.println(goods);
|
| | | try {
|
| | | TaoKeApiUtil.getSimpleGoodsInfo(539432362036L);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void test12() {
|
| | |
|
| | | try {
|
| | |
|
| | | BufferedReader br = new BufferedReader(new InputStreamReader(
|
| | | new FileInputStream(new File("C:/Users/Administrator/Desktop/新建文本文档 (2).txt"))));
|
| | | String text = "";
|
| | | String lineTxt = null;
|
| | | while ((lineTxt = br.readLine()) != null) {// 数据以逗号分隔
|
| | | text += new String(lineTxt.getBytes("unicode"), "UTF-8");
|
| | | }
|
| | | System.out.println(text);
|
| | | br.close();
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|