| | |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink; |
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2; |
| | | import com.yeshi.fanli.exception.dynamic.ActivityUserException; |
| | | import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException; |
| | |
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service; |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.FilePathEnum; |
| | |
| | | import com.yeshi.fanli.util.jd.JDApiUtil; |
| | | import com.yeshi.fanli.util.jd.JDUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.vo.goods.CouponInfoVO; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO; |
| | |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | @Resource |
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException { |
| | | Integer state = record.getState(); |
| | | if (state == null) { |
| | | state = 0; |
| | | } |
| | | record.setState(state); |
| | | |
| | | String tilte = record.getTitle(); |
| | | if (StringUtil.isNullOrEmpty(tilte)) { |
| | |
| | | if (resultObj == null) |
| | | throw new GoodsEvaluateException(1, "修改内容已不存在"); |
| | | |
| | | resultObj.setState(record.getState()); |
| | | resultObj.setUser(record.getUser()); |
| | | resultObj.setShareNum(record.getShareNum()); |
| | | resultObj.setWeight(record.getWeight()); |
| | |
| | | if (totalImg > 0) { |
| | | if (totalImg == 1) { |
| | | lineNum = 1; |
| | | } else if (totalImg == 3) { |
| | | lineNum = 3; |
| | | } else if (totalImg <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | |
| | | if (totalImg > 0) { |
| | | if (totalImg == 1) { |
| | | lineNum = 1; |
| | | } else if (totalImg == 3) { |
| | | lineNum = 3; |
| | | } else if (totalImg <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | |
| | | if (totalImg > 0) { |
| | | if (totalImg == 1) { |
| | | lineNum = 1; |
| | | } else if (totalImg == 3) { |
| | | lineNum = 3; |
| | | } else if (totalImg <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | |
| | | |
| | | ImgInfo imgInfo0 = new ImgInfo(); |
| | | imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgInfo0.setLarge(true); |
| | | imgInfo0.setLarge(false); |
| | | imgInfo0.setPid(pid); |
| | | imgInfo0.setUrl(picLink); |
| | | imgInfo0.setUrlHD(picLink); |
| | |
| | | if (totalImg > 0) { |
| | | if (totalImg == 1) { |
| | | lineNum = 1; |
| | | } else if (totalImg == 3) { |
| | | lineNum = 3; |
| | | } else if (totalImg <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") |
| | | // @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") |
| | | public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type) throws Exception { |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type); |
| | | if (list == null) { |
| | |
| | | } |
| | | imgInfo.setGoods(simpleGoods); |
| | | |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsVO.getGoodsId(), null); |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsVO.getGoodsId(), "0"); |
| | | |
| | | // TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsVO.getGoodsId(), null); |
| | | String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | String commentText = template.replace("[淘口令]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void addGoodsEvaluateByDaTaoKe() { |
| | | try { |
| | | List<DaTaoKeDetailV2> list = daTaoKeGoodsDetailV2Service.getGoodsNotInList(1L, null, 1); |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | DaTaoKeDetailV2 daTaoKe = list.get(0); |
| | | TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(daTaoKe.getGoodsId()); |
| | | if (goodsBrief == null) { |
| | | return; |
| | | } |
| | | |
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); |
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(); |
| | | BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate(); |
| | | ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate); |
| | | GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params); |
| | | // 发布用户 |
| | | ActivityUser user = activityUserService.getRandomByDaTaoKeCid(daTaoKe.getCid()); |
| | | |
| | | String desc = DaTaoKeUtil.getDesc(daTaoKe); |
| | | if (!StringUtil.isNullOrEmpty(desc)) { |
| | | int index = desc.lastIndexOf("\n"); |
| | | String newDesc = desc.substring(index + 1); |
| | | if (StringUtil.isNullOrEmpty(newDesc)) { |
| | | desc = desc.substring(0, index); |
| | | } |
| | | } |
| | | |
| | | GoodsEvaluate goodsEvaluate = new GoodsEvaluate(); |
| | | goodsEvaluate.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | goodsEvaluate.setUser(user); |
| | | goodsEvaluate.setTitle(desc); |
| | | goodsEvaluate.setState(1); |
| | | goodsEvaluate.setDynamicType(1); |
| | | goodsEvaluate.setType(EvaluateEnum.single); |
| | | |
| | | goodsEvaluate.setShareNum((int) (Math.random() * 5000) + 1000); |
| | | goodsEvaluate.setShareNumReal(0); |
| | | goodsEvaluate.setWeight(0.0); |
| | | goodsEvaluate.setStartTime(new Date()); |
| | | goodsEvaluate.setEndTime(DateUtil.plusDayDate(3, new Date())); |
| | | goodsEvaluate.setPublishTime(new Date()); |
| | | goodsEvaluate.setCreateTime(new Date()); |
| | | goodsEvaluate.setUpdateTime(new Date()); |
| | | |
| | | |
| | | List<ImgInfo> imgList = new ArrayList<>(); |
| | | |
| | | int lineNum = 0; |
| | | if (imgList.size() > 0) { |
| | | if (imgList.size() == 1) { |
| | | lineNum = 1; |
| | | } else if (imgList.size() == 3) { |
| | | lineNum = 3; |
| | | } else if (imgList.size() <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | | lineNum = 3; |
| | | } |
| | | } |
| | | goodsEvaluate.setLineNum(lineNum); |
| | | |
| | | int i = 0; |
| | | List<String> imgs = goodsBrief.getImgList(); |
| | | for (String img : imgs) { |
| | | ImgInfo imgInfo = new ImgInfo(); |
| | | imgInfo.setH(1); |
| | | imgInfo.setW(1); |
| | | imgInfo.setLarge(false); |
| | | imgInfo.setUrl(img); |
| | | imgInfo.setUrlHD(img); |
| | | if (i != 0) { |
| | | imgInfo.setType(ImgEnum.img); |
| | | } else { |
| | | imgInfo.setType(ImgEnum.goods); |
| | | SimpleGoods simpleGoods = new SimpleGoods(); |
| | | simpleGoods.setGoodsId(goodsVO.getGoodsId()); |
| | | simpleGoods.setGoodsType(goodsVO.getGoodsType()); |
| | | simpleGoods.setState(goodsVO.getState()); |
| | | CouponInfoVO couponInfo = goodsVO.getCouponInfo(); |
| | | if (couponInfo == null) { |
| | | simpleGoods.setPrice(goodsVO.getZkPrice()); |
| | | } else { |
| | | simpleGoods.setPrice(goodsVO.getCouponPrice()); |
| | | simpleGoods.setAmount(couponInfo.getAmount()); |
| | | } |
| | | imgInfo.setGoods(simpleGoods); |
| | | |
| | | //TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(Constant.LINK_TOKEN_VERIFY_UID, goodsVO.getGoodsId(), null); |
| | | |
| | | String token = shareGoodsService.createTaoBaoToken(Constant.LINK_TOKEN_VERIFY_UID, goodsBrief); |
| | | |
| | | String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | String commentText = template.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token)); |
| | | |
| | | commentText = commentText.replace("[原价]", goodsVO.getZkPrice().toString()); |
| | | if (!goodsVO.isHasCoupon()) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", goodsVO.getCouponPrice().toString()); |
| | | } |
| | | commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n") |
| | | .replace("\r\n\r\n", "\r\n"); |
| | | |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | commentInfo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | commentInfo.setContent(commentText); |
| | | commentInfo.setTypeEnum(CommentInfoEnum.goodsCoupon); |
| | | commentInfo.setType(CommentInfoEnum.goodsCoupon.getDesc()); |
| | | |
| | | List<CommentInfo> commentsNew = new ArrayList<>(); |
| | | commentsNew.add(commentInfo); |
| | | goodsEvaluate.setComments(commentsNew); |
| | | |
| | | goodsEvaluate.setGoods(goodsVO); |
| | | } |
| | | |
| | | imgList.add(imgInfo); |
| | | i ++; |
| | | } |
| | | goodsEvaluate.setImgList(imgList); |
| | | goodsEvaluateDao.save(goodsEvaluate); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | } |