| | |
| | | import com.yeshi.fanli.dto.ConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo; |
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser; |
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass; |
| | |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String saveSingleGoods(String pid, Long goodsId, Integer goodsType, String videoUrl, Integer picNum, |
| | | public String saveSingleGoods(String pid, String goodsId, Integer goodsType, String videoUrl, Integer picNum, |
| | | String picUrls, MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | |
| | | params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | try { |
| | | TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId)); |
| | | goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | throw new GoodsEvaluateException(1, "商品已下架"); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | jdGoods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(jdGoods, params); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(pddGoods, params); |
| | | } |
| | | |
| | |
| | | if (comments != null && comments.size() > 0) { |
| | | for (CommentInfo commentInfo : comments) { |
| | | if (commentInfo.getTypeEnum() == CommentInfoEnum.goodsCoupon) { |
| | | if (oldGoodsVO != null && oldGoodsVO.getGoodsId().longValue() == goodsId.longValue() |
| | | if (oldGoodsVO != null && oldGoodsVO.getGoodsId().equalsIgnoreCase(goodsId) |
| | | && oldGoodsVO.getGoodsType() == goodsType) { |
| | | addComment = false; |
| | | } |
| | |
| | | String commentText = ""; |
| | | if (addComment) { |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsId, "0"); |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, Long.parseLong(goodsId), "0"); |
| | | String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | commentText = template.replace("[淘口令]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | |
| | | } |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsId), PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | if (jumpLink == null) { |
| | | throw new GoodsEvaluateException(1, "该商品转链失败"); |
| | | } |
| | |
| | | private String createTokenAndLink(GoodsDetailVO goodsDetailVO) throws Exception { |
| | | String commentText = ""; |
| | | if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsDetailVO.getGoodsId(), "0"); |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L,Long.parseLong(goodsDetailVO.getGoodsId()), "0"); |
| | | String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | commentText = template.replace("[淘口令]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_JD) { |
| | | String couponUrl = null; |
| | | |
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsDetailVO.getGoodsId()); |
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsDetailVO.getGoodsId())); |
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods); |
| | | if (couponInfo != null) { |
| | | couponUrl = couponInfo.getLink(); |
| | |
| | | String template = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetailVO.getGoodsId(), |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsDetailVO.getGoodsId()), |
| | | PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | String template = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | |
| | | } |
| | | |
| | | boolean del = false; |
| | | long oldGoodsId = old.getGoods().getGoodsId().longValue(); |
| | | String oldGoodsId = old.getGoods().getGoodsId(); |
| | | int oldGoodsType = old.getGoods().getGoodsType().intValue(); |
| | | for (ImgInfo newInfo : listImg) { |
| | | ImgEnum type2 = old.getType(); |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (oldGoodsId == newInfo.getGoods().getGoodsId().longValue() |
| | | if (oldGoodsId .equalsIgnoreCase(newInfo.getGoods().getGoodsId()) |
| | | && oldGoodsType == newInfo.getGoods().getGoodsType().intValue()) { |
| | | String url = newInfo.getUrl(); |
| | | if (url.equals(old.getUrl())) { |
| | |
| | | public GoodsEvaluate getById(String id) { |
| | | return goodsEvaluateDao.getById(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<GoodsEvaluate> listByStartTime(Date date) { |
| | | return goodsEvaluateDao.listByStartTime(date); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveComment(String pid, CommentInfo commentInfo) throws GoodsEvaluateException { |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateDao.getById(pid); |
| | |
| | | } |
| | | } |
| | | |
| | | private GoodsDetailVO getGoodsNewInfo(Long goodsId, int goodsType, ConfigParamsDTO paramsDTO) { |
| | | private GoodsDetailVO getGoodsNewInfo(String goodsId, int goodsType, ConfigParamsDTO paramsDTO) { |
| | | GoodsDetailVO vo = null; |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoGoodsBrief goods; |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId)); |
| | | if (goods != null) { |
| | | vo = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); |
| | | } |
| | |
| | | } |
| | | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | if (goodsInfo != null) { |
| | | vo = GoodsDetailVOFactory.convertJDGoods(goodsInfo, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | if (goodsInfo != null) |
| | | vo = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, paramsDTO); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void addGoodsEvaluate(Long goodsId, List<ImgInfo> imgList, ActivityUser user, String title, String comment, |
| | | public void addGoodsEvaluate(String goodsId, List<ImgInfo> imgList, ActivityUser user, String title, String comment, |
| | | Date startTime) throws GoodsEvaluateException { |
| | | if (goodsId == null || user == null || StringUtil.isNullOrEmpty(title)) { |
| | | throw new GoodsEvaluateException(1, "相关参数不能为空"); |
| | |
| | | |
| | | TaoBaoGoodsBrief goodsBrief = null; |
| | | try { |
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId)); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | throw new GoodsEvaluateException(1, "商品已下架"); |
| | | } |
| | |
| | | for (GoodsEvaluate goodsEvaluate : listExist) { |
| | | GoodsDetailVO goods = goodsEvaluate.getGoods(); |
| | | if (goods != null && goods.getGoodsType() == 1) { |
| | | listId.add(goods.getGoodsId()); |
| | | listId.add(Long.parseLong(goods.getGoodsId())); |
| | | } |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO, |
| | | goods.getAuctionId()); |
| | | goods.getAuctionId()+""); |
| | | if (queryExist == null || queryExist.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | if (jdGoods == null) { |
| | | return; |
| | | } |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_JD, jdGoods.getSkuId()); |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_JD, jdGoods.getSkuId()+""); |
| | | if (queryExist == null || queryExist.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | if (pddGoods == null) { |
| | | return; |
| | | } |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_PDD, pddGoods.getGoodsId()); |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_PDD, pddGoods.getGoodsId()+""); |
| | | if (queryExist == null || queryExist.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | return; |
| | | } |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_VIP, |
| | | Long.parseLong(goods.getGoodsId())); |
| | | goods.getGoodsId()); |
| | | if (queryExist == null || queryExist.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | updateGoods(queryExist, goodsNew); |
| | | } |
| | | |
| | | @Override |
| | | public void updateSuningGoods(SuningGoodsInfo goods) { |
| | | if (goods == null) { |
| | | return; |
| | | } |
| | | List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_SUNING, |
| | | goods.getCommodityInfo().getCommodityCode()); |
| | | if (queryExist == null || queryExist.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55"); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); |
| | | GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO); |
| | | updateGoods(queryExist, goodsNew); |
| | | } |
| | | |
| | | private void updateGoods(List<GoodsEvaluate> listExist, GoodsDetailVO goodsNew) { |
| | | long goodsId = goodsNew.getGoodsId(); |
| | | String goodsId = goodsNew.getGoodsId(); |
| | | int goodsType = goodsNew.getGoodsType(); |
| | | for (GoodsEvaluate goodsEvaluate : listExist) { |
| | | GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods(); |
| | | if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null && goodsDetailVO.getGoodsId() == goodsId |
| | | if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null && goodsDetailVO.getGoodsId().equalsIgnoreCase(goodsId) |
| | | && goodsDetailVO.getGoodsType() == goodsType) { |
| | | goodsEvaluate.setGoods(goodsNew); |
| | | } |
| | |
| | | |
| | | for (ImgInfo imgInfo : imgList) { |
| | | SimpleGoods simpleGoods = imgInfo.getGoods(); |
| | | if (simpleGoods == null || simpleGoods.getGoodsId() != goodsId |
| | | if (simpleGoods == null || !simpleGoods.getGoodsId().equalsIgnoreCase(goodsId) |
| | | || goodsType != simpleGoods.getGoodsType()) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void offlineTaoBaoGoods(Long goodsId) { |
| | | public void offlineTaoBaoGoods(String goodsId) { |
| | | try { |
| | | if (goodsId == null) { |
| | | return; |
| | | } |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO, goodsId); |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO,goodsId); |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | } |
| | | |
| | | @CacheEvict(value = "dynamicCache", allEntries = true) |
| | | private void offlineGoods(List<GoodsEvaluate> list, int goodsType, Long goodsId) { |
| | | private void offlineGoods(List<GoodsEvaluate> list, int goodsType, String goodsId) { |
| | | |
| | | for (GoodsEvaluate goodsEvaluate : list) { |
| | | // 商品下架 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public GoodsEvaluate queryExistSingle(String goodsId, int goodsType) { |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryExistSingle(goodsType, goodsId); |
| | | if (list != null && list.size() > 0) |
| | | return list.get(0); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |