admin
2020-03-08 1bcbc66438458a1393591c933243e94f47b7acd2
Merge remote-tracking branch 'origin/div' into div
6个文件已修改
237 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 182 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/DateUtil.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -42,6 +42,7 @@
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.exception.goods.ConvertLinkExceptionException;
import com.yeshi.fanli.exception.share.ShareGoodsException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
@@ -972,8 +973,14 @@
            }
        }
        String newText =  text;
        try {
            text = convertLinkManager.convertLinkFromText(text, uid, true);
            newText = convertLinkManager.convertLinkFromText(text, uid, true);
        } catch (ConvertLinkExceptionException e) {
            if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) {
                out.print(JsonUtil.loadFalseResult("评论生成失败"));
                return;
            }
        } catch (Exception e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseResult("评论生成失败"));
@@ -981,7 +988,7 @@
        }
        JSONObject data = new JSONObject();
        data.put("text", text);
        data.put("text", newText);
        out.print(JsonUtil.loadTrueResult(data));
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -44,6 +44,7 @@
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;
@@ -54,6 +55,7 @@
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;
@@ -66,7 +68,9 @@
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;
@@ -103,6 +107,11 @@
    @Resource
    private ConvertLinkManager convertLinkManager;
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Override
    public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException {
@@ -110,6 +119,7 @@
        if (state == null) {
            state = 0;
        }
        record.setState(state);
        String tilte = record.getTitle();
        if (StringUtil.isNullOrEmpty(tilte)) {
@@ -161,6 +171,7 @@
            if (resultObj == null)
                throw new GoodsEvaluateException(1, "修改内容已不存在");
            resultObj.setState(record.getState());
            resultObj.setUser(record.getUser());
            resultObj.setShareNum(record.getShareNum());
            resultObj.setWeight(record.getWeight());
@@ -427,6 +438,8 @@
        if (totalImg > 0) {
            if (totalImg == 1) {
                lineNum = 1;
            } else if (totalImg == 3) {
                lineNum = 3;
            } else if (totalImg <= 4) {
                lineNum = 2;
            } else {
@@ -752,6 +765,8 @@
        if (totalImg > 0) {
            if (totalImg == 1) {
                lineNum = 1;
            } else if (totalImg == 3) {
                lineNum = 3;
            } else if (totalImg <= 4) {
                lineNum = 2;
            } else {
@@ -1103,6 +1118,8 @@
        if (totalImg > 0) {
            if (totalImg == 1) {
                lineNum = 1;
            } else if (totalImg == 3) {
                lineNum = 3;
            } else if (totalImg <= 4) {
                lineNum = 2;
            } else {
@@ -1241,7 +1258,7 @@
                            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);
@@ -1289,6 +1306,8 @@
        if (totalImg > 0) {
            if (totalImg == 1) {
                lineNum = 1;
            } else if (totalImg == 3) {
                lineNum = 3;
            } else if (totalImg <= 4) {
                lineNum = 2;
            } else {
@@ -1472,14 +1491,14 @@
    }
    @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) {
            list = new ArrayList<>();
        }
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<GoodsEvaluate> listNew = new ArrayList<>();
        for (GoodsEvaluate goodsEvaluate : list) {
@@ -1527,23 +1546,26 @@
                    if (!StringUtil.isNullOrEmpty(coupon) && !StringUtil.isNullOrEmpty(endTime)) {
                        Date endDay = sdf.parse(endTime);
                        if (endDay.getTime() > now.getTime()) {
                            int daysBetween = DateUtil.daysBetween(now, endDay);
                            if (daysBetween > 0) {
                            String daysBetween = DateUtil.dateDiff5(now, endDay);
                            if (!StringUtil.isNullOrEmpty(daysBetween)) {
                                List<ClientTextStyleVO> tagListNew = new ArrayList<>();
                                List<ClientTextStyleVO> tagList = commentInfoNew.getTagList();
                                if (tagList != null) {
                                    tagListNew.addAll(tagList);
                                }
                                ClientTextStyleVO styleVO = new ClientTextStyleVO();
                                styleVO.setColor("#E5005C");
                                styleVO.setContent(daysBetween + "天后过期");
                                List<ClientTextStyleVO> tagList = commentInfoNew.getTagList();
                                tagList.add(styleVO);
                                commentInfoNew.setTagList(tagList);
                                styleVO.setContent(daysBetween + "后过期");
                                tagListNew.add(styleVO);
                                commentInfoNew.setTagList(tagListNew);
                                commentNew.add(commentInfoNew);
                                continue;
                            }
                        }
                    }
                    commentNew.add(commentInfo);
                    commentNew.add(commentInfoNew);
                }
                evaluateNew.setComments(commentNew);
@@ -1790,7 +1812,9 @@
                    }
                    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()));
@@ -1826,4 +1850,136 @@
        }
    }
    @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);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -467,6 +467,17 @@
    }
    @Override
    public String createTaoBaoToken(Long uid, TaoBaoGoodsBrief goods) {
        String quanToken = "";
        if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) {// 通过立即推广方式获取淘口令成功
            quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(), goods.getCouponLink());
        } else if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl())) {
            quanToken = convertLinkManager.createTaoBaoToken(uid,goods.getPictUrl(), goods.getTitle(), goods.getAuctionUrl());
        }
        return quanToken;
    }
    @Override
    public TaoBaoLink getTaoBaoLinkForBuy(Long uid, Long auctionId, int pidType) throws ShareGoodsException {
        if (uid == null || uid <= 0) {
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java
@@ -141,4 +141,10 @@
    public void saveGoodsComment(String id, int kind, List<CommentInfo> comments) throws GoodsEvaluateException, Exception;
    /**
     * 自动生成数据
     */
    public void addGoodsEvaluateByDaTaoKe();
}
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsService.java
@@ -143,4 +143,6 @@
     */
    public TaoBaoLink getTaoLiJinLinkForBuyWithOutFanLi(Long uid,  Long auctionId,TaoKeAppInfo app) throws ShareGoodsException,TaoLiJinCreateException;
    public String createTaoBaoToken(Long uid, TaoBaoGoodsBrief goods);
}
utils/src/main/java/org/yeshi/utils/DateUtil.java
@@ -114,6 +114,31 @@
        return datatime;
    }
    public static String dateDiff5(Date startTime, Date endTime) throws Exception {
        long nm = 1000 * 60;// 一分钟的毫秒数
        long nh = 1000 * 60 * 60;// 一小时的毫秒数
        long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
        // 获得两个时间的毫秒时间差异
        long diff = endTime.getTime() - startTime.getTime();
        long day = diff / nd;// 计算差多少天
        long hour = diff % nd / nh;// 计算差多少小时
        long min = diff % nd % nh / nm;// 计算差多少分钟
        long second = (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60); // 计算差多少秒
        String datatime = "";
        if (day > 0) {
            datatime = day + "天";
        } else if (hour > 0) {
            datatime = hour + "小时";
        } else if (min > 0) {
            datatime = min + "分钟";
        } else if(second > 0) {
            datatime = second + "秒";
        }
        return datatime;
    }
    /**
     * 通过时间秒毫秒数判断两个时间的间隔
     *