admin
2020-05-21 6d2dc50e035f68b1ddea4621e7fa7bf36c393080
好单库入库
13个文件已修改
8个文件已添加
2058 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 173 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 137 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/MongodbBaseDao.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/goods/taobao/haodanku/HDKGoodsDetailDao.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKGoodsListResultDTO.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKWXCircleContentDTO.java 201 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/goods/ShareGoodsTextTemplate.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/system/ConfigKeyEnum.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/taobao/haodanku/HDKGoodsDetail.java 509 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/goods/HDKGoodsJob.java 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/haodanku/HDKGoodsDetailServiceImpl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ScanHistoryV2Service.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsTextTemplateService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/haodanku/HDKGoodsDetailService.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/HaoDanKuApiUtil.java 226 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -26,6 +26,7 @@
import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.dto.taobao.DaTaoKeFilterResult;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.ShamUser;
import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -98,6 +99,8 @@
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.user.UserLevelUtil;
import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
import com.yeshi.fanli.util.vipshop.VipShopUtil;
import com.yeshi.fanli.vo.goods.CouponInfoVO;
import com.yeshi.fanli.vo.goods.GoodsDetailExtraVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
@@ -243,12 +246,12 @@
                }
                String link = taoBaoGoodsCacheUtil.getBaseConvertLink(goods.getAuctionId(), dpid);
                if (!StringUtil.isNullOrEmpty(link)) {
//                    result.getGoods().setCouponLink(link);
                    // result.getGoods().setCouponLink(link);
                    return result.getGoods();
                } else {
                    link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid);
                    if (!StringUtil.isNullOrEmpty(link)) {
//                        result.getGoods().setCouponLink(link);
                        // result.getGoods().setCouponLink(link);
                        taoBaoGoodsCacheUtil.cacheBaseConvertLink(goods.getAuctionId(), dpid, link);
                    }
                    return result.getGoods();
@@ -1073,6 +1076,146 @@
    }
    /**
     * 唯品会详情
     *
     * @param acceptData
     * @param id
     * @param uid
     * @param from
     * @param out
     */
    @RequestMapping(value = "getDetailVIP", method = RequestMethod.POST)
    public void getDetialVIP(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
        // 系统验证
        BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
                acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
            return;
        }
        VIPGoodsInfo vipGoodsInfo = VipShopApiUtil.getGoodsDetail(id + "");
        if (vipGoodsInfo == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertVIPGoods(vipGoodsInfo, paramsDTO);
        if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
            goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
            goodsDetail.getMoneyInfo().setShareMoney("¥" + VipShopUtil.getGoodsFanLiMoney(vipGoodsInfo,
                    hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
            goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
            goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
        }
        goodsDetail.getMoneyInfo()
                .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
        // 附加信息
        OtherInfo otherInfo = new OtherInfo();
        RewardCouponVO rewardCoupon = new RewardCouponVO();
        rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
        JSONObject params1 = new JSONObject();
        if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            params1.put("url", configService.get(ConfigKeyEnum.specialGuideRewardCouponLink.getKey()));
        else
            params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
        rewardCoupon.setDesc("返");
        params1.put("url", userVipConfigService.getValueByKey("vip_link"));
        rewardCoupon.getJumpDetail().setNeedLogin(true);
        rewardCoupon.setParams(params1.toString());
        otherInfo.setRewardCoupon(rewardCoupon);
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
            otherInfo.setRewardCoupon(null);
        goodsDetail.setOtherInfo(otherInfo);
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
            String version = acceptData.getVersion();
            extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
        }
        // 图文详情
        extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
        if (uid != null) {
            // 是否加入收藏
            CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
                    Constant.SOURCE_TYPE_VIP);
            extraVO.setCollected(collectionGoods != null ? true : false);
            // 是否加入选品库
            extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_VIP));
        }
        extraVO.setIsNative(true);
        // 分享路径
        String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
        try {
            extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
        } catch (Exception e) {
            extraVO.setH5Url(h5Url);
        }
        String helpLink = null;
        extraVO.setFanliValid(true);
        extraVO.setShareValid(true);
        if (StringUtil.isNullOrEmpty(helpLink)) {
            helpLink = configService.get(ConfigKeyEnum.noRebateHelpLink.getKey());
        }
        ShareVO shareInfoVO = new ShareVO();
        shareInfoVO.setHelpLink(helpLink);
        extraVO.setShare(shareInfoVO);
        // if (convertUrl != null) {
        // extraVO.setCouponJumpLink(convertUrl.getUrl());
        // extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        // }
        JSONObject object = new JSONObject();
        object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
        object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
        out.print(JsonUtil.loadTrueResult(object.toString()));
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                try {
                    scanHistoryV2Service.addVIPScanHistory(uid, acceptData.getDevice(), vipGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    goodsEvaluateService.updateVIPGoods(vipGoodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * 商品详情推荐(猜你喜欢 + 推荐)
     * 
     * @param acceptData
@@ -1509,4 +1652,30 @@
        }
        out.print(JsonUtil.loadTrueResult(gson.toJson(voList)));
    }
    /**
     * 京东转链
     * @Title: getJDLink
     * @Description:
     * @param acceptData
     * @param link
     * @param uid
     * @param out
     * void 返回类型
     * @throws
     */
    @RequestMapping(value = "convertJDLink")
    public void convertJDLink(AcceptData acceptData, String link, Long uid, String callback, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(link)) {
            out.print(JsonUtil.loadFalseResult(1, "链接为空"));
            return;
        }
        link = JDApiUtil.convertLinkWithSubUnionId(link, null, JDApiUtil.POSITION_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("link", link);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -24,6 +24,9 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.dto.vip.VIPSearchFilter;
import com.yeshi.fanli.dto.vip.VIPSearchResult;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
@@ -69,6 +72,7 @@
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
import com.yeshi.fanli.vo.brand.BrandInfoVO;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
import com.yeshi.fanli.vo.common.JumpDetailContentVO;
@@ -139,7 +143,7 @@
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
@@ -192,15 +196,13 @@
                        Gson gson = JsonUtil.getApiCommonGson();
                        data.put("title", "智能搜索");
                        int state = 0;
                        if (result.getFirstGoods() != null && result.getFirstGoods().getGoodsId() != null) {
                            state = 2;
                            data.put("stateDesc", "选择搜券或转链");
                            JSONObject params = new JSONObject();
                            params.put("id", result.getFirstGoods().getGoodsId()+"");
                            params.put("id", result.getFirstGoods().getGoodsId() + "");
                            params.put("from", "转链");
                            if (result.getFirstGoods().getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
                                view = new JumpDetailContentVO();
@@ -499,8 +501,15 @@
            return;
        }
        /*-------- 唯品会商品 ------*/
        if (goodsType.intValue() == Constant.SOURCE_TYPE_VIP) {
            searchVIPGoods(acceptData, searchkey, page, filter, order, out);
            return;
        }
        /*-------- 淘宝商品  -------*/
        searchTaoBaoGoods(acceptData, searchkey, page, filter, order, out);
    }
    /**
@@ -900,4 +909,86 @@
        data.put("count", count);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 搜索唯品会商品
     * @Title: searchVIPGoods
     * @Description:
     * @param acceptData
     * @param key
     * @param page
     * @param filter
     * @param order
     * @param out
     * void 返回类型
     * @throws
     */
    private void searchVIPGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
            PrintWriter out) {
        VIPSearchFilter searchFilter = new VIPSearchFilter();
        searchFilter.setKeyword(key);
        searchFilter.setPage(page);
        searchFilter.setPageSize(Constant.PAGE_SIZE);
        if (order != null) {
            int sort = order.intValue();
            switch (sort) {
            case 2: // 价格—desc
                searchFilter.setFieldName("price");
                searchFilter.setOrder(1);
                break;
            case 3: // 价格—asc
                searchFilter.setFieldName("price");
                searchFilter.setOrder(0);
                break;
            case 4: // 折扣—desc
                searchFilter.setFieldName("discount");
                searchFilter.setOrder(1);
                break;
            case 5: // 折扣—aec
                searchFilter.setFieldName("discount");
                searchFilter.setOrder(0);
                break;
            default: // 综合排序
                break;
            }
        }
        if (!StringUtil.isNullOrEmpty(filter)) {
            JSONObject jsonfilter = JSONObject.fromObject(filter);
            String minPrice = jsonfilter.optString("minPrice");
            if (!StringUtil.isNullOrEmpty(minPrice)) {
                searchFilter.setPriceStart(minPrice);
            }
            String maxPrice = jsonfilter.optString("maxPrice");
            if (!StringUtil.isNullOrEmpty(maxPrice)) {
                searchFilter.setPriceEnd(maxPrice);
            }
        }
        int count = 0;
        JSONObject data = new JSONObject();
        JSONArray array = new JSONArray();
        VIPSearchResult result = VipShopApiUtil.search(searchFilter);
        if (result != null) {
            count = result.getTotal();
            Gson gson = JsonUtil.getApiCommonGson();
            List<VIPGoodsInfo> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                        acceptData.getVersion());
                for (VIPGoodsInfo goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
                    array.add(gson.toJson(goodsDetailVO));
                }
            }
        }
        data.put("result", array);
        data.put("count", count);
        out.print(JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -27,6 +27,7 @@
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
@@ -84,6 +85,8 @@
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
import com.yeshi.fanli.util.vipshop.VipShopApiUtil;
import com.yeshi.fanli.util.vipshop.VipShopUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo;
import com.yeshi.fanli.vo.goods.ShareInfoVO;
@@ -247,6 +250,13 @@
            createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
            return;
        }
        // 唯品会
        if (goodsType == Constant.SOURCE_TYPE_VIP) {
            createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
            return;
        }
    }
    public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) {
@@ -1038,6 +1048,133 @@
    }
    /**
     * 拼多多分享
     *
     * @param acceptData
     * @param uid
     * @param goodsId
     * @param source
     * @param out
     */
    public void createVIPShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
            PrintWriter out) {
        VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + "");
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
            return;
        }
        String jumpLink = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(uid));
        ShareInfoVO shareInfo = new ShareInfoVO();
        shareInfo.setClickUrl(jumpLink);
        shareInfo.setWxErCode(jumpLink);
        shareInfo.setCommentTexts(new ArrayList<>());
        shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkVIP.getKey()));
        shareInfo.setPictUrl(goods.getGoodsThumbUrl());
        if (needGoods) {
            shareInfo
                    .setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods,
                            new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
                                    hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,
                                    hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
        }
        String template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid);
        String shareText = shareGoodsTextTemplateService.createContentVIP(template, goods, jumpLink);
        shareInfo.setShareText(shareText);
        String descText = shareText.replace(goods.getGoodsName(), "").trim();
        if (descText.startsWith("\\r\\n")) {
            descText = descText.substring(0);
        }
        shareInfo.setDescText(descText);
        //
        String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(),
                Integer.parseInt(acceptData.getVersion()));
        JSONArray array = JSONArray.fromObject(imgs);
        shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0));
        // 2.0.7版本后的提示图片
        imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey());
        array = JSONArray.fromObject(imgs);
        shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0));
        shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey()));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal shareMoney = VipShopUtil.getGoodsFanLiMoney(goods, shareRate);
        shareInfo.setShareMoney("¥" + shareMoney.toString());
        try {
            ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
                    Constant.SOURCE_TYPE_VIP, false);
            shareInfo.setShareId(shareRecord.getRedisKey());
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
        String commentText = "";
        String recommendText = "";
        String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey());
        recommendText = qtemplate.replace("[商品标题]", goods.getGoodsName());
        recommendText = recommendText.replace("推荐理由:[推荐语]", "");
        String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey());
        commentText = quickCommentText.replace("[原价]", goods.getMarketPrice());
        commentText = commentText.replace("[链接]", jumpLink);
        commentText = commentText.replace("领券抢购", "抢购");
        commentText = commentText.replace("【券后价】[券后价]元", "");
        recommendText = recommendText.replace("优惠券:[券面额]元", "");
        shareInfo.setRecommendText(deleteBlankLine(recommendText));
        shareInfo.setCommentText(deleteBlankLine(commentText));
        // 设置评论文本选项
        shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode,
                VipShopUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
        out.print(JsonUtil.loadTrueResult(
                JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
        // 异步操作
        com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
            @Override
            public void run() {
                // 异步操作 添加分享记录
                UserShareGoodsHistory history = new UserShareGoodsHistory();
                history.setUser(new UserInfo(uid));
                history.setHongbao(shareMoney);
                history.setCreateTime(new Date());
                history.setGoodsType(Constant.SOURCE_TYPE_VIP);
                history.setTkCode(null);
                history.setLink(null);
                history.setQuanLink(null);
                history.setGoodsId(goodsId);
                history.setPostPicture(goods.getGoodsThumbUrl());
                history.setShareImg(jumpLink);
                List<String> imgList = goods.getGoodsDetailPictures();
                if (imgList == null) {
                    imgList = new ArrayList<>();
                }
                history.setPictures(JsonUtil.getGson().toJson(imgList));
                shareGoodsService.addShareGoodsHistory(history);
            }
        });
    }
    /**
     * 预览分享模板
     * 
     * @param acceptData
fanli/src/main/java/com/yeshi/fanli/dao/MongodbBaseDao.java
@@ -87,6 +87,10 @@
        Query query = Query.query(Criteria.where("id").is(id));
        mongoTemplate.remove(query, getEntityClass());
    }
    public void delete(Query query) {
        mongoTemplate.remove(query, getEntityClass());
    }
    @SuppressWarnings("unchecked")
    protected Class<T> getEntityClass() {
fanli/src/main/java/com/yeshi/fanli/dao/goods/taobao/haodanku/HDKGoodsDetailDao.java
New file
@@ -0,0 +1,94 @@
package com.yeshi.fanli.dao.goods.taobao.haodanku;
import java.util.Date;
import java.util.List;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
@Repository
public class HDKGoodsDetailDao extends MongodbBaseDao<HDKGoodsDetail> {
    /**
     * 根据商品ID检索
     * @Title: selectByAuctionId
     * @Description:
     * @param auctionId
     * @return
     * DaTaoKeDetailV2 返回类型
     * @throws
     */
    public HDKGoodsDetail selectByAuctionId(Long auctionId) {
        Query query = new Query();
        query.addCriteria(Criteria.where("itemid").is(auctionId));
        query.limit(1);
        List<HDKGoodsDetail> list = mongoTemplate.find(query, HDKGoodsDetail.class);
        if (list != null && list.size() > 0) {
            return list.get(0);
        } else
            return null;
    }
    /**
     * 选择更新
     * @Title: updateSelective
     * @Description:
     * @param goods
     * void 返回类型
     * @throws
     */
    public void updateSelective(HDKGoodsDetail goods) {
        Query query = new Query();
        query.addCriteria(Criteria.where("product_id").is(goods.getProduct_id()));
        Update update = new Update();
        if (goods.getItemsale() != null)
            update.set("itemsale", goods.getItemsale());
        if (goods.getItemsale2() != null)
            update.set("itemsale2", goods.getItemsale2());
        if (goods.getTodaysale() != null)
            update.set("todaysale", goods.getTodaysale());
        if (goods.getGeneral_index() != null)
            update.set("general_index", goods.getGeneral_index());
        if (goods.getCouponurl() != null)
            update.set("couponurl", goods.getCouponurl());
        if (goods.getCouponreceive2() != null)
            update.set("couponreceive2", goods.getCouponreceive2());
        if (goods.getCouponsurplus() != null)
            update.set("couponsurplus", goods.getCouponsurplus());
        if (goods.getActivityid() != null)
            update.set("activityid", goods.getActivityid());
        if (goods.getCouponmoney() != null)
            update.set("couponmoney", goods.getCouponmoney());
        update.set("updateTime", new Date());
        update(query, update);
    }
    /**
     * 批量删除
     * @Title: deleteByItemIds
     * @Description:
     * @param itemIds
     * void 返回类型
     * @throws
     */
    public void deleteByItemIds(List<Long> itemIds) {
        if (itemIds == null || itemIds.size() == 0)
            return;
        Criteria[] ids = new Criteria[itemIds.size()];
        for (int i = 0; i < itemIds.size(); i++)
            ids[i] = Criteria.where("itemid").is(itemIds.get(i));
        Query query = new Query();
        query.addCriteria(new Criteria().orOperator(ids));
        mongoTemplate.remove(query, HDKGoodsDetail.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKGoodsListResultDTO.java
New file
@@ -0,0 +1,37 @@
package com.yeshi.fanli.dto.taobao.haodanku;
import java.util.List;
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
/**
 * 好单库微信发圈内容
 * @author Administrator
 *
 */
public class HDKGoodsListResultDTO {
    private List<HDKGoodsDetail> goodsList;
    private Integer minId;
    public HDKGoodsListResultDTO(List<HDKGoodsDetail> goodsList, Integer minId) {
        super();
        this.goodsList = goodsList;
        this.minId = minId;
    }
    public List<HDKGoodsDetail> getGoodsList() {
        return goodsList;
    }
    public void setGoodsList(List<HDKGoodsDetail> goodsList) {
        this.goodsList = goodsList;
    }
    public Integer getMinId() {
        return minId;
    }
    public void setMinId(Integer minId) {
        this.minId = minId;
    }
}
fanli/src/main/java/com/yeshi/fanli/dto/taobao/haodanku/HDKWXCircleContentDTO.java
New file
@@ -0,0 +1,201 @@
package com.yeshi.fanli.dto.taobao.haodanku;
import java.util.List;
/**
 * 好单库微信发圈内容
 * @author Administrator
 *
 */
public class HDKWXCircleContentDTO {
    private String edit_id;
    private String itemid;
    private List<String> itempic; // 多张宝贝图片,
    private String title;// itemtitle
    private String couponurl;// 优惠券链接
    private String copy_content;
    private String comment;// 朋友圈评论内容(表情未处理),多条评论用“|”做区分
    private String add_time;
    private String show_time;// 展示时间戳
    private String itemendprice;// 宝贝券后价
    private String couponmoney;// 优惠券金额
    private String sola_image;//
    private String dummy_click_statistics;// 该商品被分享次数
    private String tkrates;// 佣金比例
    private String itemprice;// 在售价
    private String content;// 单品导购内容(表情未处理)
    private String show_content;// 导购文案展示内容,含表情
    private String copy_comment;// 导购文案复制内容,含表情
    private String show_comment;// 朋友圈评论展示内容,含表情,多条评论用“|”做区分
    private String itemtitle;// 宝贝标题
    private String advise_time;//
    public String getEdit_id() {
        return edit_id;
    }
    public void setEdit_id(String edit_id) {
        this.edit_id = edit_id;
    }
    public String getItemid() {
        return itemid;
    }
    public void setItemid(String itemid) {
        this.itemid = itemid;
    }
    public List<String> getItempic() {
        return itempic;
    }
    public void setItempic(List<String> itempic) {
        this.itempic = itempic;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getCouponurl() {
        return couponurl;
    }
    public void setCouponurl(String couponurl) {
        this.couponurl = couponurl;
    }
    public String getCopy_content() {
        return copy_content;
    }
    public void setCopy_content(String copy_content) {
        this.copy_content = copy_content;
    }
    public String getComment() {
        return comment;
    }
    public void setComment(String comment) {
        this.comment = comment;
    }
    public String getAdd_time() {
        return add_time;
    }
    public void setAdd_time(String add_time) {
        this.add_time = add_time;
    }
    public String getShow_time() {
        return show_time;
    }
    public void setShow_time(String show_time) {
        this.show_time = show_time;
    }
    public String getItemendprice() {
        return itemendprice;
    }
    public void setItemendprice(String itemendprice) {
        this.itemendprice = itemendprice;
    }
    public String getCouponmoney() {
        return couponmoney;
    }
    public void setCouponmoney(String couponmoney) {
        this.couponmoney = couponmoney;
    }
    public String getSola_image() {
        return sola_image;
    }
    public void setSola_image(String sola_image) {
        this.sola_image = sola_image;
    }
    public String getDummy_click_statistics() {
        return dummy_click_statistics;
    }
    public void setDummy_click_statistics(String dummy_click_statistics) {
        this.dummy_click_statistics = dummy_click_statistics;
    }
    public String getTkrates() {
        return tkrates;
    }
    public void setTkrates(String tkrates) {
        this.tkrates = tkrates;
    }
    public String getItemprice() {
        return itemprice;
    }
    public void setItemprice(String itemprice) {
        this.itemprice = itemprice;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getShow_content() {
        return show_content;
    }
    public void setShow_content(String show_content) {
        this.show_content = show_content;
    }
    public String getCopy_comment() {
        return copy_comment;
    }
    public void setCopy_comment(String copy_comment) {
        this.copy_comment = copy_comment;
    }
    public String getShow_comment() {
        return show_comment;
    }
    public void setShow_comment(String show_comment) {
        this.show_comment = show_comment;
    }
    public String getItemtitle() {
        return itemtitle;
    }
    public void setItemtitle(String itemtitle) {
        this.itemtitle = itemtitle;
    }
    public String getAdvise_time() {
        return advise_time;
    }
    public void setAdvise_time(String advise_time) {
        this.advise_time = advise_time;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/goods/ShareGoodsTextTemplate.java
@@ -31,6 +31,20 @@
    private String sharePDDTextTemplate;// 拼多多无券分享模板
    @Column(name = "st_share_pdd_text_template_coupon")
    private String sharePDDTextTemplateCoupon;// 拼多多有券分享模板
    @Column(name = "st_share_vip_text_template")
    private String shareVIPTextTemplate;// 唯品会无券分享模板
    public String getShareVIPTextTemplate() {
        return shareVIPTextTemplate;
    }
    public void setShareVIPTextTemplate(String shareVIPTextTemplate) {
        this.shareVIPTextTemplate = shareVIPTextTemplate;
    }
    @Column(name = "st_create_time")
    private Date createTime;
    @Column(name = "st_update_time")
fanli/src/main/java/com/yeshi/fanli/entity/system/ConfigKeyEnum.java
@@ -19,6 +19,7 @@
    shareSina("shareSina", "分享商品到新浪的前缀内容"), // 未找到对应Call
    shareRuleLinkJD("share_rule_link_jd", "京东分享规则(帮助中心)"),
    shareRuleLinkPDD("share_rule_link_pdd", "拼多多分享规则(帮助中心)"),
    shareRuleLinkVIP("share_rule_link_vip", "唯品会分享规则(帮助中心)"),
    shareSingleGoodsRule("share_single_goods_rule", "单品分享规则"),
    shareGoodsTemplateRules("share_goods_template_rules", "分享模板规则"), // 存在2个相同
                                                                        // 内容不同、版本但一样
fanli/src/main/java/com/yeshi/fanli/entity/taobao/haodanku/HDKGoodsDetail.java
New file
@@ -0,0 +1,509 @@
package com.yeshi.fanli.entity.taobao.haodanku;
import java.util.Date;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
/**
 * 好单库商品详情
 * @author Administrator
 *
 */
@Document(collection = "haoDanKuGoods")
public class HDKGoodsDetail {
    @Id
    private Integer product_id;// 自增ID
    @Field
    @Indexed
    private Long itemid;// 宝贝ID
    @Field
    private String itemtitle;// 宝贝标题
    @Field
    private String itemshorttitle;// 宝贝短标题
    @Field
    private String itemdesc;// 宝贝推荐语
    @Field
    private Double itemprice;// 在售价
    @Field
    private Integer itemsale;// 宝贝月销量
    @Field
    private Integer itemsale2;// 宝贝近2小时跑单
    @Field
    private Integer todaysale;// 当天销量
    @Field
    private String itempic;// 宝贝主图原始图像
    @Field
    private String itempic_copy;// 推广长图
    @Field
    private String taobao_image;// 轮播主图,用英文逗号分隔开来
    @Field
    private Integer fqcat;// 商品类目
    @Field
    private Double itemendprice;// 宝贝券后价
    @Field
    private String shoptype;// 店铺类型
    @Field
    private String couponurl;// 优惠券链接
    @Field
    private Double couponmoney;// 优惠券金额
    @Field
    private Integer is_brand;// 是否为品牌产品
    @Field
    private Integer is_live;// 是否为直播
    @Field
    private String guide_article;// 推广导购文案
    @Field
    private String videoid;// 商品视频ID
    @Field
    private String activity_type;// 活动类型
    @Field
    private String planlink;// 营销计划链接
    @Field
    private String userid;// 店主的userid
    @Field
    private String sellernick;// 店铺掌柜名
    @Field
    private String shopname;// 店铺名
    @Field
    private String tktype;// 佣金计划:隐藏 ,营销
    @Field
    private Double tkrates;// 佣金比例
    @Field
    private Integer cuntao;// 是否村淘(1是)
    @Field
    private Double tkmoney;// 预计可得(宝贝价格 * 佣金比例 / 100)
    @Field
    private Integer couponreceive2;// 当天优惠券领取量
    @Field
    private Integer couponsurplus;// 优惠券剩余量
    @Field
    private Integer couponnum;// 优惠券总数量
    @Field
    private String coupon_condition;// 优惠券使用条件
    @Field
    private String couponexplain;// 优惠券使用条件
    @Field
    private Integer couponstarttime;// 优惠券开始时间
    @Field
    private Integer couponendtime;// 优惠券结束时间
    @Field
    private Integer start_time;// 活动开始时间
    @Field
    private Integer end_time;// 活动结束时间
    @Field
    private Integer starttime;// 发布时间
    @Field
    private Integer report_status;// 举报处理条件 0未举报 1为待处理 2为忽略 3为下架
    @Field
    private Integer general_index;// 好单指数
    @Field
    private String seller_name;// 放单人名号
    @Field
    private Double discount;// 折扣力度
    @Field
    private Double deposit;// 双十一定金
    @Field
    private Double deposit_deduct;// 双十一定金抵扣金额
    @Field
    private Date createTime;// 创建时间
    @Field
    private Date updateTime;// 更新时间
    @Field
    private String activityid;
    public String getActivityid() {
        return activityid;
    }
    public void setActivityid(String activityid) {
        this.activityid = activityid;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getProduct_id() {
        return product_id;
    }
    public void setProduct_id(Integer product_id) {
        this.product_id = product_id;
    }
    public Long getItemid() {
        return itemid;
    }
    public void setItemid(Long itemid) {
        this.itemid = itemid;
    }
    public String getItemtitle() {
        return itemtitle;
    }
    public void setItemtitle(String itemtitle) {
        this.itemtitle = itemtitle;
    }
    public String getItemshorttitle() {
        return itemshorttitle;
    }
    public void setItemshorttitle(String itemshorttitle) {
        this.itemshorttitle = itemshorttitle;
    }
    public String getItemdesc() {
        return itemdesc;
    }
    public void setItemdesc(String itemdesc) {
        this.itemdesc = itemdesc;
    }
    public Double getItemprice() {
        return itemprice;
    }
    public void setItemprice(Double itemprice) {
        this.itemprice = itemprice;
    }
    public Integer getItemsale() {
        return itemsale;
    }
    public void setItemsale(Integer itemsale) {
        this.itemsale = itemsale;
    }
    public Integer getItemsale2() {
        return itemsale2;
    }
    public void setItemsale2(Integer itemsale2) {
        this.itemsale2 = itemsale2;
    }
    public Integer getTodaysale() {
        return todaysale;
    }
    public void setTodaysale(Integer todaysale) {
        this.todaysale = todaysale;
    }
    public String getItempic() {
        return itempic;
    }
    public void setItempic(String itempic) {
        this.itempic = itempic;
    }
    public String getItempic_copy() {
        return itempic_copy;
    }
    public void setItempic_copy(String itempic_copy) {
        this.itempic_copy = itempic_copy;
    }
    public String getTaobao_image() {
        return taobao_image;
    }
    public void setTaobao_image(String taobao_image) {
        this.taobao_image = taobao_image;
    }
    public Integer getFqcat() {
        return fqcat;
    }
    public void setFqcat(Integer fqcat) {
        this.fqcat = fqcat;
    }
    public Double getItemendprice() {
        return itemendprice;
    }
    public void setItemendprice(Double itemendprice) {
        this.itemendprice = itemendprice;
    }
    public String getShoptype() {
        return shoptype;
    }
    public void setShoptype(String shoptype) {
        this.shoptype = shoptype;
    }
    public String getCouponurl() {
        return couponurl;
    }
    public void setCouponurl(String couponurl) {
        this.couponurl = couponurl;
    }
    public Double getCouponmoney() {
        return couponmoney;
    }
    public void setCouponmoney(Double couponmoney) {
        this.couponmoney = couponmoney;
    }
    public Integer getIs_brand() {
        return is_brand;
    }
    public void setIs_brand(Integer is_brand) {
        this.is_brand = is_brand;
    }
    public Integer getIs_live() {
        return is_live;
    }
    public void setIs_live(Integer is_live) {
        this.is_live = is_live;
    }
    public String getGuide_article() {
        return guide_article;
    }
    public void setGuide_article(String guide_article) {
        this.guide_article = guide_article;
    }
    public String getVideoid() {
        return videoid;
    }
    public void setVideoid(String videoid) {
        this.videoid = videoid;
    }
    public String getActivity_type() {
        return activity_type;
    }
    public void setActivity_type(String activity_type) {
        this.activity_type = activity_type;
    }
    public String getPlanlink() {
        return planlink;
    }
    public void setPlanlink(String planlink) {
        this.planlink = planlink;
    }
    public String getUserid() {
        return userid;
    }
    public void setUserid(String userid) {
        this.userid = userid;
    }
    public String getSellernick() {
        return sellernick;
    }
    public void setSellernick(String sellernick) {
        this.sellernick = sellernick;
    }
    public String getShopname() {
        return shopname;
    }
    public void setShopname(String shopname) {
        this.shopname = shopname;
    }
    public String getTktype() {
        return tktype;
    }
    public void setTktype(String tktype) {
        this.tktype = tktype;
    }
    public Double getTkrates() {
        return tkrates;
    }
    public void setTkrates(Double tkrates) {
        this.tkrates = tkrates;
    }
    public Integer getCuntao() {
        return cuntao;
    }
    public void setCuntao(Integer cuntao) {
        this.cuntao = cuntao;
    }
    public Double getTkmoney() {
        return tkmoney;
    }
    public void setTkmoney(Double tkmoney) {
        this.tkmoney = tkmoney;
    }
    public Integer getCouponreceive2() {
        return couponreceive2;
    }
    public void setCouponreceive2(Integer couponreceive2) {
        this.couponreceive2 = couponreceive2;
    }
    public Integer getCouponsurplus() {
        return couponsurplus;
    }
    public void setCouponsurplus(Integer couponsurplus) {
        this.couponsurplus = couponsurplus;
    }
    public Integer getCouponnum() {
        return couponnum;
    }
    public void setCouponnum(Integer couponnum) {
        this.couponnum = couponnum;
    }
    public String getCouponexplain() {
        return couponexplain;
    }
    public void setCouponexplain(String couponexplain) {
        this.couponexplain = couponexplain;
    }
    public Integer getCouponstarttime() {
        return couponstarttime;
    }
    public void setCouponstarttime(Integer couponstarttime) {
        this.couponstarttime = couponstarttime;
    }
    public Integer getCouponendtime() {
        return couponendtime;
    }
    public void setCouponendtime(Integer couponendtime) {
        this.couponendtime = couponendtime;
    }
    public Integer getStart_time() {
        return start_time;
    }
    public void setStart_time(Integer start_time) {
        this.start_time = start_time;
    }
    public Integer getEnd_time() {
        return end_time;
    }
    public void setEnd_time(Integer end_time) {
        this.end_time = end_time;
    }
    public Integer getStarttime() {
        return starttime;
    }
    public void setStarttime(Integer starttime) {
        this.starttime = starttime;
    }
    public Integer getReport_status() {
        return report_status;
    }
    public void setReport_status(Integer report_status) {
        this.report_status = report_status;
    }
    public Integer getGeneral_index() {
        return general_index;
    }
    public void setGeneral_index(Integer general_index) {
        this.general_index = general_index;
    }
    public String getSeller_name() {
        return seller_name;
    }
    public void setSeller_name(String seller_name) {
        this.seller_name = seller_name;
    }
    public Double getDiscount() {
        return discount;
    }
    public void setDiscount(Double discount) {
        this.discount = discount;
    }
    public Double getDeposit() {
        return deposit;
    }
    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }
    public Double getDeposit_deduct() {
        return deposit_deduct;
    }
    public void setDeposit_deduct(Double deposit_deduct) {
        this.deposit_deduct = deposit_deduct;
    }
    public String getCoupon_condition() {
        return coupon_condition;
    }
    public void setCoupon_condition(String coupon_condition) {
        this.coupon_condition = coupon_condition;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/goods/HDKGoodsJob.java
New file
@@ -0,0 +1,159 @@
package com.yeshi.fanli.job.goods;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO;
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
import com.yeshi.fanli.service.inter.taobao.haodanku.HDKGoodsDetailService;
import com.yeshi.fanli.util.taobao.HaoDanKuApiUtil;
@Component
public class HDKGoodsJob {
    @Resource
    private HDKGoodsDetailService hdkGoodsDetailService;
    /**
     * 同步所有商品
     * @Title: syncAll
     * @Description:
     * @param param
     * @return
     * @throws Exception
     * ReturnT<String> 返回类型
     * @throws
     */
    @XxlJob("goods-taobao-hdk-syncall")
    public ReturnT<String> syncAll(String param) throws Exception {
        Integer minId = 1;
        while (minId != null) {
            HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listGoods(minId, null, 200);
            if (dto != null) {
                minId = dto.getMinId();
                List<HDKGoodsDetail> goodsList = dto.getGoodsList();
                if (goodsList != null)
                    for (HDKGoodsDetail goods : goodsList) {
                        try {
                            hdkGoodsDetailService.addGoods(goods);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
            } else {
                minId = null;
            }
        }
        return ReturnT.SUCCESS;
    }
    /**
     * 新增
     * @Title: syncNewAdd
     * @Description:
     * @param param
     * @return
     * @throws Exception
     * ReturnT<String> 返回类型
     * @throws
     */
    @XxlJob("goods-taobao-hdk-newadd")
    public ReturnT<String> newAdd(String param) throws Exception {
        // 更新最近2小时的数据
        int endHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        int startHour = endHour - 2;
        if (startHour < 0)
            startHour = 0;
        Integer minId = 1;
        while (minId != null) {
            HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listAddGoods(minId, startHour, endHour, 200);
            if (dto != null) {
                minId = dto.getMinId();
                List<HDKGoodsDetail> goodsList = dto.getGoodsList();
                if (goodsList != null)
                    for (HDKGoodsDetail goods : goodsList) {
                        try {
                            hdkGoodsDetailService.addGoods(goods);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
            } else {
                minId = null;
            }
        }
        return ReturnT.SUCCESS;
    }
    /**
     * 更新最新的数据
     * @Title: update
     * @Description:
     * @param param
     * @return
     * @throws Exception
     * ReturnT<String> 返回类型
     * @throws
     */
    @XxlJob("goods-taobao-hdk-update")
    public ReturnT<String> update(String param) throws Exception {
        Integer minId = 1;
        while (minId != null) {
            HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listUpdateGoods(minId, 200);
            if (dto != null) {
                minId = dto.getMinId();
                List<HDKGoodsDetail> goodsList = dto.getGoodsList();
                if (goodsList != null)
                    for (HDKGoodsDetail goods : goodsList) {
                        try {
                            hdkGoodsDetailService.updateGoods(goods);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
            } else {
                minId = null;
            }
        }
        return ReturnT.SUCCESS;
    }
    /**
     * 下架失效的
     * @Title: offlineInvalid
     * @Description:
     * @param param
     * @return
     * @throws Exception
     * ReturnT<String> 返回类型
     * @throws
     */
    @XxlJob("goods-taobao-hdk-offline-invalid")
    public ReturnT<String> offlineInvalid(String param) throws Exception {
        int endHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        int startHour = endHour - 2;
        if (startHour < 0)
            startHour = 0;
        List<Long> ids = HaoDanKuApiUtil.getInstance().listInvalidGoods(startHour, endHour);
        // 分页删除
        int pageSize = 100;
        int page = ids.size() % pageSize == 0 ? ids.size() / pageSize : ids.size() / pageSize + 1;
        for (int i = 0; i < page; i++) {
            int start = i * pageSize;
            List<Long> tempList = ids.subList(start, start + pageSize > ids.size() ? ids.size() : start + pageSize);
            hdkGoodsDetailService.deleteByItemIds(tempList);
        }
        return ReturnT.SUCCESS;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -31,6 +31,7 @@
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.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.bus.activity.ActivityUser;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.dynamic.CommentInfo;
@@ -91,7 +92,7 @@
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
@@ -116,18 +117,17 @@
    @Resource
    private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
    @Override
    public void switchState(String id) throws GoodsEvaluateException {
        if (id == null) {
            throw new GoodsEvaluateException(1, "请传递正确参数");
        }
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(id);
        if (resultObj == null) {
            throw new GoodsEvaluateException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
@@ -136,8 +136,7 @@
        }
        goodsEvaluateDao.updateSatate(id, state);
    }
    @Override
    public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException {
        Integer state = record.getState();
@@ -254,21 +253,22 @@
        }
        return null;
    }
    private ImgInfo uploadOriginalPicture(MultipartFile file) {
        try {
            InputStream inputStream = file.getInputStream();
            String contentType = file.getContentType();
            String type = contentType.substring(contentType.indexOf("/") + 1);
            String filePath = FilePathEnum.goodsEvaluate.getPath() + UUID.randomUUID().toString().replace("-", "") + "."+ type;
            String filePath = FilePathEnum.goodsEvaluate.getPath() + UUID.randomUUID().toString().replace("-", "") + "."
                    + type;
            BufferedImage sourceImg = ImageIO.read(inputStream);
            ImgInfo info = new ImgInfo();
            int width = sourceImg.getWidth();
            int height = sourceImg.getHeight();
            String picLink = COSManager.getInstance().uploadFile(file.getInputStream(), filePath).getUrl();
            info.setH(height);
            info.setW(width);
            info.setUrl(picLink);
@@ -278,7 +278,6 @@
        }
        return null;
    }
    private String uploadPicture(File file, String contentType) throws Exception {
        InputStream inputStream = new FileInputStream(file);
@@ -908,7 +907,7 @@
            if (StringUtil.isNullOrEmpty(commentInfo.getId())) {
                commentInfo.setId(UUID.randomUUID().toString().replace("-", ""));
            }
            commentInfo.setNeedSpin(true);
            commentInfo.setType(commentInfo.getTags());
            commentInfo.setTypeEnum(CommentInfoEnum.goodsCoupon);
@@ -923,7 +922,6 @@
        goodsEvaluateDao.save(resultObj);
    }
    @Override
    public void saveCurrencyCoupon(String pid, int kind, CommentInfo commentInfo)
            throws GoodsEvaluateException, Exception {
@@ -934,7 +932,7 @@
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
        if (resultObj == null)
            throw new GoodsEvaluateException(1, "第一部分信息缺失");
        if (EvaluateEnum.activity != resultObj.getType()) {
            if (StringUtil.isNullOrEmpty(commentInfo.getCoupon())) {
                throw new GoodsEvaluateException(1, "券面额不能为空");
@@ -966,7 +964,7 @@
        if (commentInfo.getNeedSpin() == null) {
            commentInfo.setNeedSpin(false);
        }
        String content = commentInfo.getContent();
        if (!StringUtil.isNullOrEmpty(content) && commentInfo.getNeedSpin()) {
            try {
@@ -979,7 +977,6 @@
                throw new GoodsEvaluateException(1, "包含不可转链的口令与链接");
            }
        }
        List<CommentInfo> comments = new ArrayList<>();
        CommentInfo currencyCoupon = null;
@@ -1040,7 +1037,7 @@
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
        if (resultObj == null)
            throw new GoodsEvaluateException(1, "第一部分信息缺失");
        if (imgInfo == null || StringUtil.isNullOrEmpty(imgInfo.getActivityUrl())) {
            throw new GoodsEvaluateException(1, "活动链接不能为空");
        }
@@ -1058,7 +1055,7 @@
                }
            }
        }
        // 视频部分
        if (fileRequest != null) {
            MultipartFile filevideo = fileRequest.getFile("filevideo");
@@ -1091,7 +1088,6 @@
            }
        }
        List<ImgInfo> listImg = new ArrayList<ImgInfo>();
        if (imgVideo != null) {
            if (!StringUtil.isNullOrEmpty(imgInfo.getVideoUrl())) {
@@ -1107,7 +1103,7 @@
                }
            }
        }
        String activityUrl = imgInfo.getActivityUrl();
        // 编辑图片
        List<ImgInfo> tempList = new ArrayList<ImgInfo>();
@@ -1118,7 +1114,7 @@
                    String picLink = pics[i];
                    if (picLink.startsWith("http")) {
                        if (listOld != null) {
                            for (ImgInfo info: listOld) {
                            for (ImgInfo info : listOld) {
                                if (info.getUrl().equals(picLink)) {
                                    info.setActivityUrl(activityUrl);
                                    tempList.add(info);
@@ -1131,7 +1127,6 @@
            }
        }
        // 上传文件替换
        if (fileRequest != null) {
            for (int i = 0; i < 9; i++) {
@@ -1153,11 +1148,10 @@
                    } else {
                        tempList.add(imgInfo0);
                    }
                }
                }
            }
        }
        int lineNum = 0;
        int totalImg = tempList.size();
        if (totalImg > 0) {
@@ -1171,19 +1165,19 @@
                lineNum = 3;
            }
        }
        // 一张图显示为大图
        if (tempList.size() == 1) {
            tempList.get(0).setLarge(true);
        }
        if (tempList.size() > 0) {
            listImg.addAll(tempList);
        }
        // 清理老图片
        if (listOld != null && listOld.size() > 0) {
            for (ImgInfo infoOld: listOld) {
            for (ImgInfo infoOld : listOld) {
                boolean del = true;
                String oldPic = infoOld.getUrl();
                for (ImgInfo info : listImg) {
@@ -1195,12 +1189,12 @@
                    listDel.add(infoOld.getUrl());
            }
        }
        resultObj.setJumpLink(activityUrl);
        resultObj.setLineNum(lineNum);
        resultObj.setImgList(listImg);
        goodsEvaluateDao.save(resultObj);
        // 删除图片
        if (listDel.size() > 0) {
            for (String url : listDel) {
@@ -1541,7 +1535,8 @@
    }
    @Override
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType, String typeEnum) {
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType,
            String typeEnum) {
        return goodsEvaluateDao.query(start, count, key, state, dynamicType, typeEnum);
    }
@@ -1601,7 +1596,7 @@
                // 删除已过期
                removeOverdue();
                removeDownGoods();
            }
        });
@@ -1770,7 +1765,7 @@
                // 删除已过期
                removeOverdue();
                removeDownGoods();
            }
        });
@@ -2004,8 +1999,9 @@
            if (!goodsVO.isHasCoupon()) {
                commentText = commentText.replace("领券抢购", "抢购");
                commentText = commentText.replace("【券后价】[券后价]元", "");
                commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n","\r\n");
            }
                commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n",
                        "\r\n");
            }
            commentInfo.setContent(commentText);
            commentInfo.setType(CommentInfoEnum.goodsCoupon.getDesc());
        }
@@ -2158,7 +2154,6 @@
            }
            imgs.addAll(goodsimgs);
            int i = 0;
            List<ImgInfo> imgList = new ArrayList<>();
            for (String img : imgs) {
@@ -2197,8 +2192,9 @@
                    if (!goodsVO.isHasCoupon()) {
                        commentText = commentText.replace("领券抢购", "抢购");
                        commentText = commentText.replace("【券后价】[券后价]元", "");
                        commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
                    }
                        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.setNeedSpin(true);
@@ -2241,7 +2237,7 @@
                imgList.add(imgInfo);
                i++;
            }
            int lineNum = 0;
            if (imgList.size() > 0) {
                if (imgList.size() == 1) {
@@ -2362,6 +2358,23 @@
        updateGoods(queryExist, goodsNew);
    }
    @Override
    public void updateVIPGoods(VIPGoodsInfo goods) {
        if (goods == null) {
            return;
        }
        List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_VIP,
                Long.parseLong(goods.getGoodsId()));
        if (queryExist == null || queryExist.size() == 0) {
            return;
        }
        ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO);
        updateGoods(queryExist, goodsNew);
    }
    private void updateGoods(List<GoodsEvaluate> listExist, GoodsDetailVO goodsNew) {
        long goodsId = goodsNew.getGoodsId();
        int goodsType = goodsNew.getGoodsType();
@@ -2404,8 +2417,7 @@
            goodsEvaluateDao.save(goodsEvaluate);
        }
    }
    @Override
    public void offlineTaoBaoGoods(Long goodsId) {
        try {
@@ -2416,7 +2428,7 @@
            if (list == null || list.size() == 0) {
                return;
            }
            // 下架商品
            offlineGoods(list, Constant.SOURCE_TYPE_TAOBAO, goodsId);
        } catch (Exception e) {
@@ -2426,12 +2438,12 @@
    @CacheEvict(value = "dynamicCache", allEntries = true)
    private void offlineGoods(List<GoodsEvaluate> list, int goodsType, Long goodsId) {
        for (GoodsEvaluate goodsEvaluate : list) {
            // 商品下架
            GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
            goodsDetailVO.setState(1);
            List<ImgInfo> imgList = goodsEvaluate.getImgList();
            if (imgList == null || imgList.size() == 0) {
                goodsEvaluate.setUpdateTime(new Date());
@@ -2448,7 +2460,7 @@
                simpleGoods.setState(1);
                GoodsDetailVO goodsVO = imgInfo.getGoodsVO();
                goodsVO.setState(1);
                imgInfo.setGoods(simpleGoods);
                imgInfo.setGoodsVO(goodsVO);
            }
@@ -2458,15 +2470,14 @@
            goodsEvaluateDao.save(goodsEvaluate);
        }
    }
    /**
     * 删除已过期时间
     */
    private void removeOverdue() {
        if(1>0)
        if (1 > 0)
            return;
        List<GoodsEvaluate> list = goodsEvaluateDao.queryOverdue();
        if (list == null || list.size() == 0) {
            return;
@@ -2491,7 +2502,7 @@
     * 删除商品已下架-单品
     */
    private void removeDownGoods() {
        if(1>0)
        if (1 > 0)
            return;
        try {
            List<GoodsEvaluate> list = goodsEvaluateDao.removeDownGoods();
@@ -2506,4 +2517,5 @@
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java
@@ -9,6 +9,7 @@
import com.yeshi.fanli.dao.mybatis.goods.ScanHistoryV2Mapper;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.ScanHistoryV2;
@@ -31,77 +32,102 @@
    private ScanHistoryV2Mapper scanHistoryV2Mapper;
    @Override
    public void addScanHistory(Long uid, String device, TaoBaoGoodsBrief goods)
    public void addVIPScanHistory(Long uid, String device, VIPGoodsInfo goods)
            throws CommonGoodsException, ScanHistoryException {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            throw new ScanHistoryException(1, "设备或用户信息缺失");
        CommonGoods commonGoods = CommonGoodsFactory.create(goods);
        commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
        if (commonGoods == null)
            throw new CommonGoodsException(2, "商品信息不完整");
        // 添加浏览记录
        ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2();
        scanHistoryV2.setCommonGoods(commonGoods);
        scanHistoryV2.setCreateTime(new Date());
        scanHistoryV2.setDevice(device);
        if (uid != null)
            scanHistoryV2.setUserInfo(new UserInfo(uid));
        scanHistoryV2.setUpdateTime(new Date());
        scanHistoryV2Mapper.insertSelective(scanHistoryV2);
    }
    @Override
    public void addJDScanHistory(Long uid, String device, JDGoods goods) throws CommonGoodsException, ScanHistoryException {
    public void addScanHistory(Long uid, String device, TaoBaoGoodsBrief goods)
            throws CommonGoodsException, ScanHistoryException {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            throw new ScanHistoryException(1, "设备或用户信息缺失");
        CommonGoods commonGoods = CommonGoodsFactory.create(goods);
        commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
        if (commonGoods == null)
            throw new CommonGoodsException(2, "商品信息不完整");
        // 添加浏览记录
        ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2();
        scanHistoryV2.setCommonGoods(commonGoods);
        scanHistoryV2.setCreateTime(new Date());
        scanHistoryV2.setDevice(device);
        if (uid != null)
            scanHistoryV2.setUserInfo(new UserInfo(uid));
        scanHistoryV2.setUpdateTime(new Date());
        scanHistoryV2Mapper.insertSelective(scanHistoryV2);
    }
    @Override
    public void addPDDScanHistory(Long uid, String device, PDDGoodsDetail pddGoods) throws CommonGoodsException, ScanHistoryException {
    public void addJDScanHistory(Long uid, String device, JDGoods goods)
            throws CommonGoodsException, ScanHistoryException {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            throw new ScanHistoryException(1, "设备或用户信息缺失");
        CommonGoods commonGoods = CommonGoodsFactory.create(goods);
        commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
        if (commonGoods == null)
            throw new CommonGoodsException(2, "商品信息不完整");
        // 添加浏览记录
        ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2();
        scanHistoryV2.setCommonGoods(commonGoods);
        scanHistoryV2.setCreateTime(new Date());
        scanHistoryV2.setDevice(device);
        if (uid != null)
            scanHistoryV2.setUserInfo(new UserInfo(uid));
        scanHistoryV2.setUpdateTime(new Date());
        scanHistoryV2Mapper.insertSelective(scanHistoryV2);
    }
    @Override
    public void addPDDScanHistory(Long uid, String device, PDDGoodsDetail pddGoods)
            throws CommonGoodsException, ScanHistoryException {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            throw new ScanHistoryException(1, "设备或用户信息缺失");
        CommonGoods commonGoods = CommonGoodsFactory.create(pddGoods);
        commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
        if (commonGoods == null)
            throw new CommonGoodsException(2, "商品信息不完整");
        // 添加浏览记录
        ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2();
        scanHistoryV2.setCommonGoods(commonGoods);
        scanHistoryV2.setCreateTime(new Date());
        scanHistoryV2.setDevice(device);
        if (uid != null)
            scanHistoryV2.setUserInfo(new UserInfo(uid));
        scanHistoryV2.setUpdateTime(new Date());
        scanHistoryV2Mapper.insertSelective(scanHistoryV2);
    }
    @Override
    public void addScanHistory(ScanHistoryV2 history) throws CommonGoodsException, ScanHistoryException {
        if (history == null)
@@ -117,7 +143,8 @@
    }
    @Override
    public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize, Integer source) {
    public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize,
            Integer source) {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            return null;
        return scanHistoryV2Mapper.selectByDeviceOrUid(uid, device, (page - 1) * pageSize, pageSize, source);
@@ -145,19 +172,19 @@
    public void deleteByAuctionIdAndDeviceOrUid(Long uid, String device, Long auctionId) {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            return;
        List<ScanHistoryV2> list = scanHistoryV2Mapper.selectByDeviceOrUidAndGoodsIdAndGoodsType(uid, device, auctionId);
        List<ScanHistoryV2> list = scanHistoryV2Mapper.selectByDeviceOrUidAndGoodsIdAndGoodsType(uid, device,
                auctionId);
        if (list != null)
            for (ScanHistoryV2 sv : list)
                scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId());
    }
    @Override
    public void deleteByCommonIdAndDeviceOrUid(Long uid, String device, Long commonId) {
        if (uid == null && StringUtil.isNullOrEmpty(device)) {
            return;
        }
        List<ScanHistoryV2> list = scanHistoryV2Mapper.getByCommonGoodsId(uid, device, commonId);
        if (list != null && list.size() > 0) {
            for (ScanHistoryV2 sv : list) {
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -12,6 +12,7 @@
import com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
@@ -111,7 +112,7 @@
        return null;
    }
    @Transactional(rollbackFor=Exception.class)
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveCouponTemplate(Long uid, String template) throws ShareGoodsTextTemplateException {
        // 格式验证
@@ -133,7 +134,7 @@
        }
    }
    @Transactional(rollbackFor=Exception.class)
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveCouponTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException {
        // 格式验证
@@ -155,7 +156,7 @@
        }
    }
    @Transactional(rollbackFor=Exception.class)
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveCouponTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException {
        // 格式验证
@@ -177,7 +178,7 @@
        }
    }
    @Transactional(rollbackFor=Exception.class)
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveTaoLiJinTemplate(Long uid, String template) throws ShareGoodsTextTemplateException {
@@ -227,51 +228,68 @@
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getShareTextTemplate())) {
            template = objct.getShareTextTemplate();
            if (template.contains("{商品原价}")|| template.contains("{优惠券面额}") ||
                    template.contains("{优惠券价}")|| template.contains("{月销量}")) {
            if (template.contains("{商品原价}") || template.contains("{优惠券面额}") || template.contains("{优惠券价}")
                    || template.contains("{月销量}")) {
                template = ""; // 老板分享
            }
        }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextTB.getKey());
        }
        return template;
    }
    @Override
    public String getTextTemplateByJD(Long uid) {
        String template = "";
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getShareJDTextTemplate())) {
            template = objct.getShareJDTextTemplate();
            if (template.contains("{商品原价}")|| template.contains("{月销量}") || template.contains("{短链接}")) {
            if (template.contains("{商品原价}") || template.contains("{月销量}") || template.contains("{短链接}")) {
                template = ""; // 老板分享
            }
        }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextJD.getKey());
        }
        return template;
    }
    @Override
    public String getTextTemplateByPDD(Long uid) {
        String template = "";
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getSharePDDTextTemplate())) {
            template = objct.getSharePDDTextTemplate();
            if (template.contains("{商品原价}")|| template.contains("{总销量}") || template.contains("{短链接}")) {
            if (template.contains("{商品原价}") || template.contains("{总销量}") || template.contains("{短链接}")) {
                template = ""; // 老板分享
            }
        }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextPDD.getKey());
        }
        return template;
    }
    @Override
    public String getTextTemplateByVIP(Long uid) {
        String template = "";
        ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (objct != null && !StringUtil.isNullOrEmpty(objct.getSharePDDTextTemplate())) {
            template = objct.getSharePDDTextTemplate();
            if (template.contains("{商品原价}") || template.contains("{总销量}") || template.contains("{短链接}")) {
                template = ""; // 老板分享
            }
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = configService.get(ConfigKeyEnum.shareCommentTextPDD.getKey());
        }
        return template;
    }
    @Override
    public void saveTemplateTB(Long uid, String template) throws ShareGoodsTextTemplateException {
        verifyRightTB(template);
@@ -328,12 +346,10 @@
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
    public void verifyRightTB(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{原价}", "{券后价}","{淘口令}" };
        String[] keys = new String[] { "{原价}", "{券后价}", "{淘口令}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
@@ -341,10 +357,10 @@
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void verifyRightJD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{原价}", "{券后价}","{链接}" };
        String[] keys = new String[] { "{原价}", "{券后价}", "{链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
@@ -352,11 +368,10 @@
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void verifyRightPDD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{原价}", "{券后价}","{链接}" };
        String[] keys = new String[] { "{原价}", "{券后价}", "{链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
@@ -364,8 +379,7 @@
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public String createContentTB(String template, TaoBaoGoodsBrief goods, String token, boolean coupon) {
        String commentText = template.replace("{原价}", goods.getZkPrice().toString());
@@ -374,12 +388,11 @@
            commentText = commentText.replace("领券抢购", "抢购");
            commentText = commentText.replace("【券后价】{券后价}元", "");
        } else {
            commentText = commentText.replace("{券后价}",
                    TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
            commentText = commentText.replace("{券后价}", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
        }
        return deleteBlankLine(commentText);
    }
    @Override
    public String createContentJD(String template, JDGoods goods, String jumpLink, boolean coupon) {
        String commentText = template.replace("{原价}", goods.getPrice().toString());
@@ -393,7 +406,7 @@
        }
        return deleteBlankLine(commentText);
    }
    @Override
    public String createContentPDD(String template, PDDGoodsDetail goods, String jumpLink, boolean coupon) {
        String commentText = template.replace("{原价}", MoneyBigDecimalUtil
@@ -408,9 +421,18 @@
        }
        return deleteBlankLine(commentText);
    }
    @Override
    public String createContentVIP(String template, VIPGoodsInfo goods, String jumpLink) {
        String commentText = template.replace("{原价}", goods.getMarketPrice());
        commentText = commentText.replace("{链接}", jumpLink);
        commentText = commentText.replace("领券抢购", "抢购");
        commentText = commentText.replace("【券后价】{券后价}元", "");
        return deleteBlankLine(commentText);
    }
    @Override
    public void isCommonTemplateRight(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{店铺类型}", "{商品原价}", "{月销量}", "{短链}", "{淘口令}" };
@@ -489,12 +511,10 @@
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    private String deleteBlankLine(String st){
    private String deleteBlankLine(String st) {
        return st.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
    }
    @Override
    public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, String token,
            String shortLink, boolean hasCoupon, Long tljId) {
@@ -512,7 +532,8 @@
                    .replace("{淘礼金面额}", BigDecimalUtil.getWithNoZera(spreadMoney).toString())
                    .replace("{优惠券价}",
                            BigDecimalUtil.getWithNoZera(TaoBaoUtil.getAfterUseCouplePrice(goods)).toString())
                    .replace("{店铺类型}", goods.getUserType() == 1 ? TaoBaoConstant.SHARE_PRICE_TM : TaoBaoConstant.SHARE_PRICE_TAOBAO);
                    .replace("{店铺类型}", goods.getUserType() == 1 ? TaoBaoConstant.SHARE_PRICE_TM
                            : TaoBaoConstant.SHARE_PRICE_TAOBAO);
        }
        if (!hasCoupon) {
@@ -520,7 +541,7 @@
                    .replace("{商品原价}", BigDecimalUtil.getWithNoZera(goods.getZkPrice()).toString())
                    .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{领券短链}", shortLink)
                    .replace("{淘口令}", token).replace("{店铺类型}", goods.getUserType() == 1 ? TaoBaoConstant.SHARE_PRICE_TM
                            :  TaoBaoConstant.SHARE_PRICE_TAOBAO);
                            : TaoBaoConstant.SHARE_PRICE_TAOBAO);
        } else {
            return template.replace("{标题}", goods.getTitle())
                    .replace("{商品原价}", BigDecimalUtil.getWithNoZera(goods.getZkPrice()).toString())
@@ -529,7 +550,8 @@
                    .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString())
                    .replace("{优惠券价}",
                            BigDecimalUtil.getWithNoZera(TaoBaoUtil.getAfterUseCouplePrice(goods)).toString())
                    .replace("{店铺类型}", goods.getUserType() == 1 ? TaoBaoConstant.SHARE_PRICE_TM : TaoBaoConstant.SHARE_PRICE_TAOBAO);
                    .replace("{店铺类型}", goods.getUserType() == 1 ? TaoBaoConstant.SHARE_PRICE_TM
                            : TaoBaoConstant.SHARE_PRICE_TAOBAO);
        }
    }
@@ -550,7 +572,8 @@
            template = template.replace("{标题}", goods.getSkuName())
                    .replace("{商品原价}", BigDecimalUtil.getWithNoZera(price).toString())
                    .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink)
                    .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(JDUtil.getShowCouponInfo( goods).getDiscount()).toString())
                    .replace("{优惠券面额}",
                            BigDecimalUtil.getWithNoZera(JDUtil.getShowCouponInfo(goods).getDiscount()).toString())
                    .replace("{优惠券价}", BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(goods)).toString());
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/haodanku/HDKGoodsDetailServiceImpl.java
New file
@@ -0,0 +1,37 @@
package com.yeshi.fanli.service.impl.taobao.haodanku;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.goods.taobao.haodanku.HDKGoodsDetailDao;
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
import com.yeshi.fanli.service.inter.taobao.haodanku.HDKGoodsDetailService;
@Service
public class HDKGoodsDetailServiceImpl implements HDKGoodsDetailService {
    @Resource
    private HDKGoodsDetailDao hdkGoodsDetailDao;
    @Override
    public void addGoods(HDKGoodsDetail goods) {
        if (goods.getCreateTime() != null)
            goods.setCreateTime(new Date());
        hdkGoodsDetailDao.save(goods);
    }
    @Override
    public void updateGoods(HDKGoodsDetail goods) {
        goods.setUpdateTime(new Date());
        hdkGoodsDetailDao.updateSelective(goods);
    }
    @Override
    public void deleteByItemIds(List<Long> itemIds) {
        hdkGoodsDetailDao.deleteByItemIds(itemIds);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java
@@ -7,6 +7,7 @@
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.bus.activity.ActivityUser;
import com.yeshi.fanli.entity.dynamic.CommentInfo;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
@@ -153,6 +154,9 @@
    public void updatePDDGoods(PDDGoodsDetail pddGoods);
    public void updateVIPGoods(VIPGoodsInfo goods);
    public void addRanDomShareCount();
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ScanHistoryV2Service.java
@@ -3,6 +3,7 @@
import java.util.List;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.goods.ScanHistoryV2;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -86,6 +87,22 @@
     */
    public void addPDDScanHistory(Long uid, String device, PDDGoodsDetail pddGoods)
            throws CommonGoodsException, ScanHistoryException;
    /**
     * 唯品会浏览记录
     * @Title: addVIPScanHistory
     * @Description:
     * @param uid
     * @param device
     * @param pddGoods
     * @throws CommonGoodsException
     * @throws ScanHistoryException
     * void 返回类型
     * @throws
     */
    public void addVIPScanHistory(Long uid, String device, VIPGoodsInfo pddGoods)
            throws CommonGoodsException, ScanHistoryException;
    /**
     * 根据简版商品ID删除
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsTextTemplateService.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.inter.goods;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -208,12 +209,16 @@
    public String createContentJD(String template, JDGoods goods, String jumpLink, boolean coupon);
    
    public String createContentPDD(String template, PDDGoodsDetail goods, String jumpLink, boolean coupon);
    public String createContentVIP(String template, VIPGoodsInfo goods, String jumpLink);
    public String getTextTemplateByJD(Long uid);
    public String getTextTemplateByTB(Long uid);
    public String getTextTemplateByPDD(Long uid);
    public String getTextTemplateByVIP(Long uid);
    public void saveTemplateTB(Long uid, String template) throws ShareGoodsTextTemplateException;
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/haodanku/HDKGoodsDetailService.java
New file
@@ -0,0 +1,44 @@
package com.yeshi.fanli.service.inter.taobao.haodanku;
import java.util.List;
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
/**
 * 好单库商品服务
 * @author Administrator
 *
 */
public interface HDKGoodsDetailService {
    /**
     * 新增
     * @Title: addGoods
     * @Description:
     * @param goods
     * void 返回类型
     * @throws
     */
    public void addGoods(HDKGoodsDetail goods);
    /**
     * 更新
     * @Title: updateGoods
     * @Description:
     * @param goods
     * void 返回类型
     * @throws
     */
    public void updateGoods(HDKGoodsDetail goods);
    /**
     * 按商品ID批量删除
     * @Title: deleteByItemIds
     * @Description:
     * @param itemIds
     * void 返回类型
     * @throws
     */
    public void deleteByItemIds(List<Long> itemIds);
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/HaoDanKuApiUtil.java
New file
@@ -0,0 +1,226 @@
package com.yeshi.fanli.util.taobao;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.yeshi.utils.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO;
import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
 * 好单库API
 * @author Administrator
 *
 */
public class HaoDanKuApiUtil {
    private final static String API_KEY = "blks";
    private static HaoDanKuApiUtil instance;
    public static HaoDanKuApiUtil getInstance() {
        if (instance == null)
            instance = new HaoDanKuApiUtil();
        return instance;
    }
    private String baseGetRequest(String path, List<ParamsKeyValue> params) {
        params.add(0, new HaoDanKuApiUtil.ParamsKeyValue("apikey", API_KEY));
        String url = "http://v2.api.haodanku.com/" + path;
        for (ParamsKeyValue keyValue : params) {
            url += ("/" + keyValue.key + "/" + keyValue.value);
        }
        return HttpUtil.get(url);
    }
    private String basePostRequest(String url, List<ParamsKeyValue> params) {
        params.add(0, new HaoDanKuApiUtil.ParamsKeyValue("apikey", API_KEY));
        Map<String, String> parmasMap = new HashMap<>();
        for (ParamsKeyValue keyValue : params) {
            parmasMap.put(keyValue.key, keyValue.value);
        }
        return HttpUtil.post(url, parmasMap, null);
    }
    /**
     * 获取朋友圈API的内容
     * @Title: getSendWXCircleContent
     * @Description:
     * void 返回类型
     * @throws
     */
    public void getSendWXCircleContent(Integer minId) {
        if (minId == null)
            minId = 1;
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("min_id", minId + ""));
        String result = baseGetRequest("selected_item", params);
        System.out.println(result);
    }
    public void convertLink(Long auctionId, String pid, String activityId) {
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("itemid", auctionId + ""));
        params.add(new ParamsKeyValue("pid", pid));
        if (activityId != null)
            params.add(new ParamsKeyValue("activityid", activityId));
        // params.add(new ParamsKeyValue("tb_name", "椰视科技"));
        String result = basePostRequest("http://v2.api.haodanku.com/ratesurl", params);
        System.out.println(result);
    }
    /**
     * 商品列表
     * @Title: listGoods
     * @Description:
     * @param minId
     * @param catIds
     * @param pageSize
     * @return
     * HDKGoodsListResultDTO 返回类型
     * @throws
     */
    // 详情:https://www.haodanku.com/api/detail/show/1.html
    public HDKGoodsListResultDTO listGoods(Integer minId, List<Integer> catIds, int pageSize) {
        if (minId == null)
            minId = 1;
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("nav", 3+ ""));
        params.add(new ParamsKeyValue("back", pageSize + ""));
        params.add(new ParamsKeyValue("min_id", minId + ""));
        params.add(new ParamsKeyValue("sort", 0 + ""));
        if (catIds != null && catIds.size() > 0) {
            params.add(new ParamsKeyValue("cid", StringUtil.concat(catIds, ",")));
        }
        String result = baseGetRequest("itemlist", params);
        JSONObject resultData = JSONObject.fromObject(result);
        if (resultData.optInt("code") == 1) {
            Integer newMinId = resultData.optInt("min_id");
            Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() {
            }.getType();
            List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type);
            return new HDKGoodsListResultDTO(list, newMinId);
        }
        return null;
    }
    /**
     * 增量更新的商品
     * @Title: listAddGoods
     * @Description:
     * @param minId
     * @param startHour
     * @param endHour
     * @param pageSize
     * @return
     * HDKGoodsListResultDTO 返回类型
     * @throws
     */
    public HDKGoodsListResultDTO listAddGoods(Integer minId, int startHour, int endHour, int pageSize) {
        if (minId == null)
            minId = 1;
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("back", pageSize + ""));
        params.add(new ParamsKeyValue("min_id", minId + ""));
        params.add(new ParamsKeyValue("start", startHour + ""));
        params.add(new ParamsKeyValue("end", endHour + ""));
        String result = baseGetRequest("timing_items", params);
        JSONObject resultData = JSONObject.fromObject(result);
        if (resultData.optInt("code") == 1) {
            Integer newMinId = resultData.optInt("min_id");
            Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() {
            }.getType();
            List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type);
            return new HDKGoodsListResultDTO(list, newMinId);
        }
        return null;
    }
    /**
     * 更新商品信息
     * @Title: listUpdateGoods
     * @Description:
     * @param minId
     * @param pageSize
     * void 返回类型
     * @throws
     */
    public HDKGoodsListResultDTO listUpdateGoods(Integer minId, int pageSize) {
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("back", pageSize + ""));
        params.add(new ParamsKeyValue("min_id", minId + ""));
        String result = baseGetRequest("update_item", params);
        JSONObject resultData = JSONObject.fromObject(result);
        if (resultData.optInt("code") == 1) {
            Integer newMinId = resultData.optInt("min_id");
            Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() {
            }.getType();
            List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type);
            return new HDKGoodsListResultDTO(list, newMinId);
        }
        return null;
    }
    /**
     * 拉取失效商品
     * @Title: listInvalidGoods
     * @Description:
     * @param startHour
     * @param endHour
     * @return
     * List<Long> 返回类型
     * @throws
     */
    public List<Long> listInvalidGoods(int startHour, int endHour) {
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("start", startHour + ""));
        params.add(new ParamsKeyValue("end", endHour + ""));
        String result = baseGetRequest("get_down_items", params);
        JSONObject resultData = JSONObject.fromObject(result);
        List<Long> goodsIdList = new ArrayList<>();
        if (resultData.optInt("code") == 1) {
            JSONArray array = resultData.optJSONArray("data");
            for (int i = 0; i < array.size(); i++) {
                goodsIdList.add(array.optJSONObject(i).optLong("itemid"));
            }
        }
        return goodsIdList;
    }
    class ParamsKeyValue {
        String key;
        String value;
        public ParamsKeyValue(String key, String value) {
            super();
            this.key = key;
            this.value = value;
        }
    }
    public void getGoodsDetail(Long auctionId) {
        List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>();
        params.add(new ParamsKeyValue("itemid", auctionId + ""));
        String result = baseGetRequest("item_detail", params);
        JSONObject resultJSON = JSONObject.fromObject(result);
        System.out.println(resultJSON.optJSONObject("data").optString("coupon_share_url"));
        System.out.println(resultJSON.optJSONObject("data").optString("couponurl"));
    }
}
fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java
@@ -165,7 +165,7 @@
     * 
     * @param goodsId
     */
    public static void convertLink(String goodsId, String tag) {
    public static String convertLink(String goodsId, String tag) {
        JSONObject taskParams = new JSONObject();
        JSONArray goodsIdArray = new JSONArray();
        goodsIdArray.add(goodsId);
@@ -175,6 +175,7 @@
        String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId",
                JSONObject.fromObject(taskParams));
        System.out.println(result);
        return null;
    }
    /**