yujian
2019-07-19 de10879ac00f9c94dc02cada9a8a6117a8d81caf
拼多多 京东分享模板兼容
11个文件已修改
2个文件已添加
1783 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 205 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 547 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/goods/ShareGoodsTextTemplate.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/UserShareGoodsHistoryMapper.xml 248 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/goods/ShareGoodsTextTemplateMapper.xml 209 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java 229 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsTextTemplateService.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/JDGoodsCacheUtil.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/PinDuoDuoCacheUtil.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -58,6 +58,7 @@
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
@@ -146,6 +147,9 @@
    @Resource
    private TLJBuyGoodsService tljBuyGoodsService;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    
    
    /**
@@ -553,6 +557,10 @@
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
            return;
        }
        // 保存缓存
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -20,6 +20,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDSearchFilter;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
@@ -49,6 +50,7 @@
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
@@ -375,16 +377,26 @@
            }
        } 
        
        if (!StringUtil.isNullOrEmpty(filter)) {
            JSONArray array = JSONArray.fromObject(filter);
            for (int i = 0; i < array.size(); i++) {
                String ty = array.optJSONObject(i).optString("type");
                if ("coupon".equalsIgnoreCase(ty)) { // 有券
                    sf.setQuan(1);
                } else if ("tmall".equalsIgnoreCase(ty)) { // 天猫
                    sf.setTmall(true);
                }
            JSONObject jsonfilter = JSONObject.fromObject(filter);
            Boolean coupon = jsonfilter.optBoolean("coupon");
            if (coupon != null && coupon) {
                sf.setQuan(1); // 有券
            }
            Boolean tmall = jsonfilter.optBoolean("tmall");
            if (tmall != null && tmall) {
                sf.setTmall(true); // 天猫
            }
            String minPrice = jsonfilter.optString("minPrice");
            if (!StringUtil.isNullOrEmpty(minPrice)) {
                sf.setStartPrice(new BigDecimal(minPrice));
            }
            String maxPrice = jsonfilter.optString("maxPrice");
            if (!StringUtil.isNullOrEmpty(maxPrice)) {
                sf.setEndPrice(new BigDecimal(maxPrice));
            }
        }
@@ -465,54 +477,130 @@
     * @return
     */
    private void searchJDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) {
        JDSearchFilter jdfilter = new JDSearchFilter();
        jdfilter.setKey(SearchFilterUtil.filterSearchContent(key));
        jdfilter.setPageNo(page);
        jdfilter.setPageSize(Constant.PAGE_SIZE);
        JDSearchResult result = null;
        String way = configService.get("jd_api_search_key");
        if ("1".equals(way)) {
            JDFilter filterAPI = new JDFilter();
            filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(key));
            filterAPI.setPageIndex(page);
            filterAPI.setPageSize(Constant.PAGE_SIZE);
        if (order != null) {
            int sort = order.intValue();
            switch (sort) {
            case 1: // 销量 desc
                jdfilter.setSort(JDSearchFilter.SORT_DESC);
                jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS);
                break;
            case 2: // 价格—desc
                jdfilter.setSort(JDSearchFilter.SORT_DESC);
                jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE);
                break;
            case 3: // 价格—asc
                jdfilter.setSort(JDSearchFilter.SORT_ASC);
                jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE);
                break;
            case 4: // 返利比—DESC
                jdfilter.setSort(JDSearchFilter.SORT_DESC);
                jdfilter.setSortName(JDSearchFilter.SORTNAME_COMMISSION_SHARE);
                break;
            default:
                break;
            }
        }
        if (!StringUtil.isNullOrEmpty(filter)) {
            JSONArray array = JSONArray.fromObject(filter);
            for (int i = 0; i < array.size(); i++) {
                String ty = array.optJSONObject(i).optString("type");
                if ("coupon".equalsIgnoreCase(ty)) {
                    jdfilter.setHasCoupon(1); // 有券
                } else if ("zy".equalsIgnoreCase(ty)) {
                    jdfilter.setIsZY(1); // 是否自营
                } else if ("delivery".equalsIgnoreCase(ty)) {
                    jdfilter.setDeliveryType(1); // 是否京东配送
            if (order != null) {
                int sort = order.intValue();
                switch (sort) {
                case 1: // 销量 desc
                    filterAPI.setSort(JDFilter.SORT_DESC);
                    filterAPI.setSortName(JDFilter.SORTNAME_ORDER_COUNT_30DAYS);
                    break;
                case 2: // 价格—desc
                    filterAPI.setSort(JDFilter.SORT_DESC);
                    filterAPI.setSortName(JDFilter.SORTNAME_PRICE);
                    break;
                case 3: // 价格—asc
                    filterAPI.setSort(JDFilter.SORT_ASC);
                    filterAPI.setSortName(JDFilter.SORTNAME_PRICE);
                    break;
                case 4: // 返利比—DESC
                    filterAPI.setSort(JDFilter.SORT_DESC);
                    filterAPI.setSortName(JDFilter.SORTNAME_COMMISSION_SHARE);
                    break;
                default:
                    break;
                }
            }
        }
            if (!StringUtil.isNullOrEmpty(filter)) {
                JSONObject jsonfilter = JSONObject.fromObject(filter);
                Boolean coupon = jsonfilter.optBoolean("coupon");
                if (coupon != null && coupon) {
                    filterAPI.setIsCoupon(1); // 有券
                }
                Boolean zy = jsonfilter.optBoolean("zy");
                if (zy != null && zy) {
                    filterAPI.setOwner("g"); // 自营
                }
                String minPrice = jsonfilter.optString("minPrice");
                if (!StringUtil.isNullOrEmpty(minPrice)) {
                    filterAPI.setPricefrom(Double.parseDouble(minPrice));
                }
                String maxPrice = jsonfilter.optString("maxPrice");
                if (!StringUtil.isNullOrEmpty(maxPrice)) {
                    filterAPI.setPriceto(Double.parseDouble(maxPrice));
                }
            }
            result = JDApiUtil.queryByKey(filterAPI);
        } else {
            // 网页爬取
            JDSearchFilter jdfilter = new JDSearchFilter();
            jdfilter.setKey(SearchFilterUtil.filterSearchContent(key));
            jdfilter.setPageNo(page);
            jdfilter.setPageSize(Constant.PAGE_SIZE);
            if (order != null) {
                int sort = order.intValue();
                switch (sort) {
                case 1: // 销量 desc
                    jdfilter.setSort(JDSearchFilter.SORT_DESC);
                    jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS);
                    break;
                case 2: // 价格—desc
                    jdfilter.setSort(JDSearchFilter.SORT_DESC);
                    jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE);
                    break;
                case 3: // 价格—asc
                    jdfilter.setSort(JDSearchFilter.SORT_ASC);
                    jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE);
                    break;
                case 4: // 返利比—DESC
                    jdfilter.setSort(JDSearchFilter.SORT_DESC);
                    jdfilter.setSortName(JDSearchFilter.SORTNAME_COMMISSION_SHARE);
                    break;
                default:
                    break;
                }
            }
            if (!StringUtil.isNullOrEmpty(filter)) {
                JSONObject jsonfilter = JSONObject.fromObject(filter);
                Boolean coupon = jsonfilter.optBoolean("coupon");
                if (coupon != null && coupon) {
                    jdfilter.setHasCoupon(1); // 有券
                }
                Boolean zy = jsonfilter.optBoolean("zy");
                if (zy != null && zy) {
                    jdfilter.setIsZY(1); // 自营
                }
                Boolean delivery = jsonfilter.optBoolean("delivery");
                if (delivery != null && delivery) {
                    jdfilter.setDeliveryType(1); // 京东配送
                }
                String minPrice = jsonfilter.optString("minPrice");
                if (!StringUtil.isNullOrEmpty(minPrice)) {
                    jdfilter.setFromPrice(Integer.parseInt(minPrice));
                }
                String maxPrice = jsonfilter.optString("maxPrice");
                if (!StringUtil.isNullOrEmpty(maxPrice)) {
                    jdfilter.setToPrice(Integer.parseInt(maxPrice));
                }
            }
            result = JDUtil.searchByKey(jdfilter);
        }
        long count = 0;
        JSONObject data = new JSONObject();
        JSONArray array = new JSONArray();
        JDSearchResult result = JDUtil.searchByKey(jdfilter);
        if (result != null) {
            PageEntity pageEntity = result.getPageEntity();
            if (pageEntity != null) {
@@ -577,14 +665,15 @@
        }
        
        if (!StringUtil.isNullOrEmpty(filter)) {
            JSONArray array = JSONArray.fromObject(filter);
            for (int i = 0; i < array.size(); i++) {
                String ty = array.optJSONObject(i).optString("type");
                if ("coupon".equalsIgnoreCase(ty)) {
                    pddfilter.setHasCoupon(true); // 有券
                } else if ("brand".equalsIgnoreCase(ty)) {
                    pddfilter.setIsBrand(true); // 是否是品牌
                }
            JSONObject jsonfilter = JSONObject.fromObject(filter);
            Boolean coupon = jsonfilter.optBoolean("coupon");
            if (coupon != null && coupon) {
                pddfilter.setHasCoupon(true); // 有券
            }
            Boolean brand = jsonfilter.optBoolean("brand");
            if (brand != null && brand) {
                pddfilter.setIsBrand(true); // 是否是品牌
            }
        }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -13,6 +13,7 @@
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.JsonUtil;
@@ -31,10 +32,13 @@
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.ShareGoodsException;
import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
@@ -61,6 +65,9 @@
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.MonitorFactory;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -113,6 +120,12 @@
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private RedisManager redisManager;
@@ -187,10 +200,10 @@
            return;
        }
    }
    /**
     * 创建淘宝分享信息
     *
     * @param acceptData
     * @param uid
     * @param goodsId
@@ -212,7 +225,7 @@
            out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号"));
            return;
        }
        // 淘礼金创建分享
        if (source != null && "taolijin".equals(source)) {
            createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
@@ -221,7 +234,7 @@
        try {
            ShareInfoVO shareInfo = new ShareInfoVO();
            TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
            String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
@@ -264,16 +277,15 @@
            shareText = shareText.replace("{店铺类型}", shopType)
                    .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
                    .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
            shareInfo.setShareText(shareText);
            String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
            if (descText.startsWith("\\r\\n")) {
                descText = descText.substring(0);
            }
            shareInfo.setDescText(descText);
            // 提示图文内容
            String imgs = configService.get("goods_share_notify_imgs");
            JSONArray array = JSONArray.fromObject(imgs);
@@ -287,7 +299,7 @@
            BigDecimal rate = hongBaoManageService.getShareRate();
            BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
            shareInfo.setShareMoney("¥" + shareMoney.toString());
            // 分享id
            try {
                ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
@@ -300,7 +312,7 @@
                    e1.printStackTrace();
                }
            }
            out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
            final TaoBaoLink taobaoLink = taoBaoLink;
@@ -410,7 +422,7 @@
            shareInfo.setToken(taoBaoLink.getTaoToken());
            shareInfo.setRule(configService.get("share_single_goods_rule"));
            shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
            // 无券
            String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
            String shareText = "";
@@ -439,12 +451,11 @@
                    .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
                    .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
            shareInfo.setShareText(shareText);
            String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
            if (descText.startsWith("\\r\\n"))
                descText = descText.substring(0);
            shareInfo.setDescText(descText);
            String imgs = configService.get("goods_share_notify_imgs");
@@ -548,7 +559,6 @@
        shareInfo.setClickUrl(url);
        shareInfo.setRule(configService.get("share_rule_link_jd"));
        shareInfo.setPictUrl(jdGoods.getPicUrl());
        String shareText = "";
        String shopType = "京东价";
@@ -584,7 +594,7 @@
            descText = descText.substring(0);
        }
        shareInfo.setDescText(descText);
        //
        String imgs = configService.get("goods_share_notify_imgs");
        JSONArray array = JSONArray.fromObject(imgs);
@@ -593,7 +603,6 @@
            shareInfo.setNotifyPicture(array.optString(p));
        }
        shareInfo.setNotifyDesc(configService.get("goods_share_notify_jd"));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
@@ -656,7 +665,7 @@
        }
        ShareInfoVO shareInfo = new ShareInfoVO();
        // TODO
        String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
@@ -699,13 +708,13 @@
                .replace("{月销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{领券短链}", shortLink)
                .replace("{淘口令}", null);
        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.get("goods_share_notify_imgs");
        JSONArray array = JSONArray.fromObject(imgs);
@@ -714,13 +723,12 @@
            shareInfo.setNotifyPicture(array.optString(p));
        }
        shareInfo.setNotifyDesc(configService.get("goods_share_notify_pdd"));
        // 添加分享记录
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
        shareInfo.setShareMoney("¥" + shareMoney.toString());
        try {
            ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
                    Constant.SOURCE_TYPE_JD);
@@ -765,6 +773,503 @@
    }
    /**
     * 预览分享模板
     *
     * @param acceptData
     * @param uid
     * @param template
     * @param goodsId
     * @param hasCoupon
     * @param out
     */
    @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST)
    public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, Long goodsId,
            Long tljId, Boolean hasCoupon, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (goodsId == null) {
            out.print(JsonUtil.loadFalseResult(3, "商品ID不能为空"));
            return;
        }
        if (goodsType == null || goodsType > 3 || goodsType < 1) {
            out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
            return;
        }
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            createTaoBaoViewText(goodsType, uid, template, goodsId, tljId, hasCoupon, out);
            return;
        }
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
            return;
        }
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
            return;
        }
    }
    /**
     * 创建淘宝分享模板
     *
     * @param uid
     * @param template
     * @param goodsType
     * @param goodsId
     * @param tljId
     * @param hasCoupon
     * @param out
     */
    public void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId,
            Boolean hasCoupon, PrintWriter out) {
        TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId);
        if (goods == null)
            try {
                goods = redisManager.getTaoBaoGoodsBrief(goodsId);
            } catch (TaobaoGoodsDownException e) {
                goods = null;
            }
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(4, "商品已下架"));
            return;
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = getShareTemplate(goodsType, uid, hasCoupon, tljId);
        }
        // 校验券模板是否正确
        if (hasCoupon) {
            // 有券商品
            if (tljId != null) {
                try {
                    shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
                } catch (ShareGoodsTextTemplateException e) {
                    out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                    return;
                }
            } else {
                try {
                    shareGoodsTextTemplateService.isCouponTemplateRight(template);
                } catch (ShareGoodsTextTemplateException e) {
                    out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                    return;
                }
            }
        } else {
            // 普通商品
            try {
                shareGoodsTextTemplateService.isCommonTemplateRight(template);
            } catch (ShareGoodsTextTemplateException e) {
                out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                return;
            }
        }
        String url = null;
        if (tljId != null) {
            UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId);
            if (userTaoLiJinRecord == null) {
                out.print(JsonUtil.loadFalseResult(5, "淘礼金领取链接不存在"));
                return;
            }
            url = userTaoLiJinRecord.getSendUrl();
        } else {
            url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
                    Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                    goods.getAuctionId() + "");
        }
        String shortLink = HttpUtil.getShortLink(url);
        // 查询是否有分享
        UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId());
        String token = "";
        if (userShareHistory != null) {
            token = userShareHistory.getTkCode();
        }
        if (StringUtil.isNullOrEmpty(token)) {
            TaoKeAppInfo app = new TaoKeAppInfo();
            app.setAdzoneId(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
            app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
            app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
            app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT);
            TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
            if (goodsLink != null)
                token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
                        StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl()
                                : goodsLink.getCouponLink());
        }
        String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink,
                hasCoupon, tljId);
        JSONObject data = new JSONObject();
        data.put("content", content);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 创建京东分享模板
     *
     * @param uid
     * @param template
     * @param goodsType
     * @param goodsId
     * @param tljId
     * @param hasCoupon
     * @param out
     */
    public void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
            PrintWriter out) {
        JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(4, "商品已下架"));
            return;
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = getShareTemplate(goodsType, uid, hasCoupon, null);
        }
        // 校验券模板是否正确
        if (hasCoupon) {
            // 有券商品
            try {
                shareGoodsTextTemplateService.isCouponTemplateRightJD(template);
            } catch (ShareGoodsTextTemplateException e) {
                out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                return;
            }
        } else {
            // 普通商品
            try {
                shareGoodsTextTemplateService.isCommonTemplateRightJD(template);
            } catch (ShareGoodsTextTemplateException e) {
                out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                return;
            }
        }
        String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goodsId + "");
        String shortLink = HttpUtil.getShortLink(url);
        String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
                hasCoupon);
        JSONObject data = new JSONObject();
        data.put("content", content);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 创建京东分享模板
     *
     * @param uid
     * @param template
     * @param goodsType
     * @param goodsId
     * @param tljId
     * @param hasCoupon
     * @param out
     */
    public void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
            PrintWriter out) {
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(4, "商品已下架"));
            return;
        }
        if (StringUtil.isNullOrEmpty(template)) {
            template = getShareTemplate(goodsType, uid, hasCoupon, null);
        }
        // 校验券模板是否正确
        if (hasCoupon) {
            // 有券商品
            try {
                shareGoodsTextTemplateService.isCouponTemplateRightPDD(template);
            } catch (ShareGoodsTextTemplateException e) {
                out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                return;
            }
        } else {
            // 普通商品
            try {
                shareGoodsTextTemplateService.isCommonTemplateRightPDD(template);
            } catch (ShareGoodsTextTemplateException e) {
                out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
                return;
            }
        }
        // 创建h5连接
        String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goodsId + "");
        String shortLink = HttpUtil.getShortLink(url);
        // 创建口令
        String token = PinDuoDuoApiUtil.createGenerate(goodsId);
        // 生成分享内容
        String content = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
                hasCoupon, token);
        JSONObject data = new JSONObject();
        data.put("content", content);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取分享模板
     *
     * @param uid
     * @param hasCoupon
     * @param tljId
     * @return
     */
    private String getShareTemplate(int goodsType, Long uid, boolean hasCoupon, Long tljId) {
        String template = "";
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            if (hasCoupon) {
                if (tljId != null) {
                    template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
                    if (StringUtil.isNullOrEmpty(template))
                        template = configTaoLiJinService.getValueByKey("goods_share_text");
                } else {
                    template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
                    if (StringUtil.isNullOrEmpty(template))
                        template = configService.get("goods_share_text_coupon");
                }
            } else {
                template = shareGoodsTextTemplateService.getCommonTemplate(uid);
                if (StringUtil.isNullOrEmpty(template))
                    template = configService.get("goods_share_text_nocoupon");
            }
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
            if (hasCoupon) {
                if (textTemplate != null) {
                    template = textTemplate.getShareJDTextTemplateCoupon();
                }
                if (StringUtil.isNullOrEmpty(template)) {
                    template = configService.get("goods_share_text_coupon_jd");
                }
            } else {
                if (textTemplate != null) {
                    template = textTemplate.getShareJDTextTemplate();
                }
                if (StringUtil.isNullOrEmpty(template)) {
                    template = configService.get("goods_share_text_nocoupon_jd");
                }
            }
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
            if (hasCoupon) {
                if (textTemplate != null) {
                    template = textTemplate.getSharePDDTextTemplateCoupon();
                }
                if (StringUtil.isNullOrEmpty(template)) {
                    template = configService.get("goods_share_text_coupon_pdd");
                }
            } else {
                if (textTemplate != null) {
                    template = textTemplate.getSharePDDTextTemplate();
                }
                if (StringUtil.isNullOrEmpty(template)) {
                    template = configService.get("goods_share_text_nocoupon_pdd");
                }
            }
        }
        return template;
    }
    /**
     * 获取分享模板
     *
     * @param acceptData
     * @param uid
     * @param hasCoupon
     * @param out
     */
    @RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST)
    public void getShareTextTemplate(AcceptData acceptData, Integer goodsType, Long uid, Long tljId, Boolean hasCoupon,
            PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (hasCoupon == null) {
            out.print(JsonUtil.loadFalseResult(1, "是否有券字段为空"));
            return;
        }
        JSONObject data = new JSONObject();
        data.put("template", getShareTemplate(goodsType, uid, hasCoupon, tljId));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 获取分享模板编辑规则
     *
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST)
    public void getShareTextTemplateRules(AcceptData acceptData, Integer goodsType, Long tljId, PrintWriter out) {
        if (goodsType == null || goodsType > 3 || goodsType < 1) {
            out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
            return;
        }
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            if (tljId != null) {
                out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules")));
            } else {
                out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
            }
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_jd")));
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_pdd")));
        }
    }
    /**
     * 保存模板
     *
     * @param acceptData
     * @param uid
     * @param hasCoupon
     * @param template
     * @param out
     */
    @RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST)
    public void saveShareTextTemplate(AcceptData acceptData, Integer goodsType, Long uid, Long tljId, Boolean hasCoupon,
            String template, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(template)) {
            out.print(JsonUtil.loadFalseResult(1, "分享模板为空"));
            return;
        }
        if (goodsType == null || goodsType > 3 || goodsType < 1) {
            out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
            return;
        }
        try {
            if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
                // 校验券模板是否正确
                if (hasCoupon) {
                    // 有券商品
                    if (tljId != null) {
                        shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
                        shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template);
                    } else {
                        shareGoodsTextTemplateService.isCouponTemplateRight(template);
                        shareGoodsTextTemplateService.saveCouponTemplate(uid, template);
                    }
                } else {
                    // 普通商品
                    shareGoodsTextTemplateService.isCommonTemplateRight(template);
                    shareGoodsTextTemplateService.saveCommonTemplate(uid, template);
                }
            } else if (goodsType == Constant.SOURCE_TYPE_JD) {
                if (hasCoupon) {
                    shareGoodsTextTemplateService.isCouponTemplateRightJD(template);
                    shareGoodsTextTemplateService.saveCouponTemplateJD(uid, template);
                } else {
                    shareGoodsTextTemplateService.isCommonTemplateRightJD(template);
                    shareGoodsTextTemplateService.saveCommonTemplateJD(uid, template);
                    out.print(JsonUtil.loadTrueResult(""));
                }
            } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
                if (hasCoupon) {
                    shareGoodsTextTemplateService.isCouponTemplateRightPDD(template);
                    shareGoodsTextTemplateService.saveCouponTemplatePDD(uid, template);
                } else {
                    shareGoodsTextTemplateService.isCommonTemplateRightPDD(template);
                    shareGoodsTextTemplateService.saveCommonTemplatePDD(uid, template);
                    out.print(JsonUtil.loadTrueResult(""));
                }
            }
        } catch (ShareGoodsTextTemplateException e) {
            out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
            return;
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 还原模板
     *
     * @param acceptData
     * @param uid
     * @param hasCoupon  -是否有券
     * @param out
     */
    @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST)
    public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon,
            Integer goodsType, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (goodsType == null || goodsType > 3 || goodsType < 1) {
            out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
            return;
        }
         if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            if (hasCoupon) {
                if (tljId != null) {
                    shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
                } else {
                    shareGoodsTextTemplateService.resetCouponTemplate(uid);
                }
            } else {
                shareGoodsTextTemplateService.resetCommonTemplate(uid);
            }
         } else  if (goodsType == Constant.SOURCE_TYPE_JD) {
             if (hasCoupon) {
                shareGoodsTextTemplateService.resetCouponTemplateJD(uid);
            } else {
                shareGoodsTextTemplateService.resetCommonTemplateJD(uid);
            }
         } else  if (goodsType == Constant.SOURCE_TYPE_PDD) {
             if (hasCoupon) {
                shareGoodsTextTemplateService.resetCouponTemplatePDD(uid);
            } else {
                shareGoodsTextTemplateService.resetCommonTemplatePDD(uid);
            }
         }
        if (goodsId != null) {
            viewShareTextTemplate(acceptData, uid, null, goodsType, goodsId, tljId, hasCoupon, out);
            return;
        }
        out.print(JsonUtil.loadTrueResult(""));
    }
    /**
     * 获取分享记录中的商品 分享信息
     * 
     * @param acceptData
fanli/src/main/java/com/yeshi/fanli/entity/goods/ShareGoodsTextTemplate.java
@@ -23,6 +23,14 @@
    private String shareCouponTextTemplate;// 券分享模板
    @Column(name = "st_share_taolijin_text_template")
    private String shareTaoLiJinTextTemplate;// 淘礼金分享模板
    @Column(name = "st_share_jd_text_template")
    private String shareJDTextTemplate;// 京东无券分享模板
    @Column(name = "st_share_jd_text_template_coupon")
    private String shareJDTextTemplateCoupon;// 京东有券分享模板
    @Column(name = "st_share_pdd_text_template")
    private String sharePDDTextTemplate;// 拼多多无券分享模板
    @Column(name = "st_share_pdd_text_template_coupon")
    private String sharePDDTextTemplateCoupon;// 拼多多有券分享模板
    @Column(name = "st_create_time")
    private Date createTime;
    @Column(name = "st_update_time")
@@ -83,4 +91,36 @@
    public void setShareTaoLiJinTextTemplate(String shareTaoLiJinTextTemplate) {
        this.shareTaoLiJinTextTemplate = shareTaoLiJinTextTemplate;
    }
    public String getShareJDTextTemplate() {
        return shareJDTextTemplate;
    }
    public void setShareJDTextTemplate(String shareJDTextTemplate) {
        this.shareJDTextTemplate = shareJDTextTemplate;
    }
    public String getShareJDTextTemplateCoupon() {
        return shareJDTextTemplateCoupon;
    }
    public void setShareJDTextTemplateCoupon(String shareJDTextTemplateCoupon) {
        this.shareJDTextTemplateCoupon = shareJDTextTemplateCoupon;
    }
    public String getSharePDDTextTemplate() {
        return sharePDDTextTemplate;
    }
    public void setSharePDDTextTemplate(String sharePDDTextTemplate) {
        this.sharePDDTextTemplate = sharePDDTextTemplate;
    }
    public String getSharePDDTextTemplateCoupon() {
        return sharePDDTextTemplateCoupon;
    }
    public void setSharePDDTextTemplateCoupon(String sharePDDTextTemplateCoupon) {
        this.sharePDDTextTemplateCoupon = sharePDDTextTemplateCoupon;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/UserShareGoodsHistoryMapper.xml
@@ -1,124 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">
        <id column="sgus_id" property="id" jdbcType="BIGINT" />
        <result column="sgus_goods_type" property="goodsType" jdbcType="INTEGER" />
        <result column="sgus_goods_id" property="goodsId" jdbcType="BIGINT" />
        <result column="sgus_post_picture" property="postPicture"
            jdbcType="VARCHAR" />
        <result column="sgu_pictures" property="pictures" jdbcType="VARCHAR" />
        <result column="sgu_hongbao" property="hongbao" jdbcType="DECIMAL" />
        <result column="sgu_link" property="link" jdbcType="VARCHAR" />
        <result column="sgu_quanlink" property="quanLink" jdbcType="VARCHAR" />
        <result column="sgu_tkcode" property="tkCode" jdbcType="VARCHAR" />
        <result column="sgu_createtime" property="createTime" jdbcType="TIMESTAMP" />
        <result column="sgus_share_img" property="shareImg" jdbcType="VARCHAR" />
        <association property="user" column="sgus_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
    </resultMap>
    <sql id="Base_Column_List">sgus_id,sgus_uid as
        uid,sgus_goods_type,sgus_goods_id,sgus_post_picture,sgu_pictures,sgu_hongbao,sgu_link,sgu_quanlink,sgu_tkcode,sgu_createtime,sgus_uid,sgus_share_img
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_goods_usershare where sgus_id =
        #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByUidAndAuctionId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_goods_usershare where sgus_uid = #{uid} and
        sgus_goods_id=#{auctionId} limit 1
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_share_goods_usershare where sgus_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_share_goods_usershare
        (sgus_id,sgus_uid,sgus_goods_type,sgus_goods_id,sgus_post_picture,sgu_pictures,sgu_hongbao,sgu_link,sgu_quanlink,sgu_tkcode,sgu_createtime,sgus_share_img)
        values
        (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{goodsType,jdbcType=INTEGER},#{goodsId,jdbcType=BIGINT},#{postPicture,jdbcType=VARCHAR},#{pictures,jdbcType=VARCHAR},#{hongbao,jdbcType=DECIMAL},#{link,jdbcType=VARCHAR},#{quanLink,jdbcType=VARCHAR},#{tkCode,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{shareImg,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_share_goods_usershare
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">sgus_id,</if>
            <if test="user != null">sgus_uid,</if>
            <if test="goodsType != null">sgus_goods_type,</if>
            <if test="goodsId != null">sgus_goods_id,</if>
            <if test="postPicture != null">sgus_post_picture,</if>
            <if test="pictures != null">sgu_pictures,</if>
            <if test="hongbao != null">sgu_hongbao,</if>
            <if test="link != null">sgu_link,</if>
            <if test="quanLink != null">sgu_quanlink,</if>
            <if test="tkCode != null">sgu_tkcode,</if>
            <if test="createTime != null">sgu_createtime,</if>
            <if test="shareImg != null">sgus_share_img,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="user != null">#{user.id,jdbcType=BIGINT},</if>
            <if test="goodsType != null">#{goodsType,jdbcType=INTEGER},</if>
            <if test="goodsId != null">#{goodsId,jdbcType=BIGINT},</if>
            <if test="postPicture != null">#{postPicture,jdbcType=VARCHAR},</if>
            <if test="pictures != null">#{pictures,jdbcType=VARCHAR},</if>
            <if test="hongbao != null">#{hongbao,jdbcType=DECIMAL},</if>
            <if test="link != null">#{link,jdbcType=VARCHAR},</if>
            <if test="quanLink != null">#{quanLink,jdbcType=VARCHAR},</if>
            <if test="tkCode != null">#{tkCode,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="shareImg != null">#{shareImg,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">update yeshi_ec_share_goods_usershare set sgus_uid =
        #{user.id,jdbcType=BIGINT},sgus_goods_type =
        #{goodsType,jdbcType=INTEGER},sgus_goods_id =
        #{goodsId,jdbcType=BIGINT},sgus_post_picture =
        #{postPicture,jdbcType=VARCHAR},sgu_pictures =
        #{pictures,jdbcType=VARCHAR},sgu_hongbao =
        #{hongbao,jdbcType=DECIMAL},sgu_link =
        #{link,jdbcType=VARCHAR},sgu_quanlink =
        #{quanLink,jdbcType=VARCHAR},sgu_tkcode =
        #{tkCode,jdbcType=VARCHAR},sgu_createtime =
        #{createTime,jdbcType=TIMESTAMP} ,sgus_share_img
        =#{shareImg,jdbcType=VARCHAR} where sgus_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">
        update yeshi_ec_share_goods_usershare
        <set>
            <if test="user != null">sgus_uid=#{user.id,jdbcType=BIGINT},</if>
            <if test="goodsType != null">sgus_goods_type=#{goodsType,jdbcType=INTEGER},</if>
            <if test="goodsId != null">sgus_goods_id=#{goodsId,jdbcType=BIGINT},</if>
            <if test="postPicture != null">sgus_post_picture=#{postPicture,jdbcType=VARCHAR},</if>
            <if test="pictures != null">sgu_pictures=#{pictures,jdbcType=VARCHAR},</if>
            <if test="hongbao != null">sgu_hongbao=#{hongbao,jdbcType=DECIMAL},</if>
            <if test="link != null">sgu_link=#{link,jdbcType=VARCHAR},</if>
            <if test="quanLink != null">sgu_quanlink=#{quanLink,jdbcType=VARCHAR},</if>
            <if test="tkCode != null">sgu_tkcode=#{tkCode,jdbcType=VARCHAR},</if>
            <if test="createTime != null">sgu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="id !=null">sgus_id =#{id,jdbcType=BIGINT},</if>
            <if test="shareImg !=null">sgus_share_img =#{shareImg,jdbcType=VARCHAR},</if>
        </set>
        where sgus_id = #{id,jdbcType=BIGINT}
    </update>
    <select id="countUserShares" parameterType="java.lang.Long" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(sgus_id),0) FROM  yeshi_ec_share_goods_usershare WHERE sgus_uid =#{userId,jdbcType=BIGINT}
   </select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">
        <id column="sgus_id" property="id" jdbcType="BIGINT" />
        <result column="sgus_goods_type" property="goodsType" jdbcType="INTEGER" />
        <result column="sgus_goods_id" property="goodsId" jdbcType="BIGINT" />
        <result column="sgus_post_picture" property="postPicture"
            jdbcType="VARCHAR" />
        <result column="sgu_pictures" property="pictures" jdbcType="VARCHAR" />
        <result column="sgu_hongbao" property="hongbao" jdbcType="DECIMAL" />
        <result column="sgu_link" property="link" jdbcType="VARCHAR" />
        <result column="sgu_quanlink" property="quanLink" jdbcType="VARCHAR" />
        <result column="sgu_tkcode" property="tkCode" jdbcType="VARCHAR" />
        <result column="sgu_createtime" property="createTime" jdbcType="TIMESTAMP" />
        <result column="sgus_share_img" property="shareImg" jdbcType="VARCHAR" />
        <association property="user" column="sgus_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
    </resultMap>
    <sql id="Base_Column_List">sgus_id,sgus_uid as
        uid,sgus_goods_type,sgus_goods_id,sgus_post_picture,sgu_pictures,sgu_hongbao,sgu_link,sgu_quanlink,sgu_tkcode,sgu_createtime,sgus_uid,sgus_share_img
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_goods_usershare where sgus_id =
        #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByUidAndAuctionId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_goods_usershare where sgus_uid = #{uid} and
        sgus_goods_id=#{auctionId} limit 1
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_share_goods_usershare where sgus_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_share_goods_usershare
        (sgus_id,sgus_uid,sgus_goods_type,sgus_goods_id,sgus_post_picture,sgu_pictures,sgu_hongbao,sgu_link,sgu_quanlink,sgu_tkcode,sgu_createtime,sgus_share_img)
        values
        (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{goodsType,jdbcType=INTEGER},#{goodsId,jdbcType=BIGINT},#{postPicture,jdbcType=VARCHAR},#{pictures,jdbcType=VARCHAR},#{hongbao,jdbcType=DECIMAL},#{link,jdbcType=VARCHAR},#{quanLink,jdbcType=VARCHAR},#{tkCode,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{shareImg,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_share_goods_usershare
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">sgus_id,</if>
            <if test="user != null">sgus_uid,</if>
            <if test="goodsType != null">sgus_goods_type,</if>
            <if test="goodsId != null">sgus_goods_id,</if>
            <if test="postPicture != null">sgus_post_picture,</if>
            <if test="pictures != null">sgu_pictures,</if>
            <if test="hongbao != null">sgu_hongbao,</if>
            <if test="link != null">sgu_link,</if>
            <if test="quanLink != null">sgu_quanlink,</if>
            <if test="tkCode != null">sgu_tkcode,</if>
            <if test="createTime != null">sgu_createtime,</if>
            <if test="shareImg != null">sgus_share_img,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="user != null">#{user.id,jdbcType=BIGINT},</if>
            <if test="goodsType != null">#{goodsType,jdbcType=INTEGER},</if>
            <if test="goodsId != null">#{goodsId,jdbcType=BIGINT},</if>
            <if test="postPicture != null">#{postPicture,jdbcType=VARCHAR},</if>
            <if test="pictures != null">#{pictures,jdbcType=VARCHAR},</if>
            <if test="hongbao != null">#{hongbao,jdbcType=DECIMAL},</if>
            <if test="link != null">#{link,jdbcType=VARCHAR},</if>
            <if test="quanLink != null">#{quanLink,jdbcType=VARCHAR},</if>
            <if test="tkCode != null">#{tkCode,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="shareImg != null">#{shareImg,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">update yeshi_ec_share_goods_usershare set sgus_uid =
        #{user.id,jdbcType=BIGINT},sgus_goods_type =
        #{goodsType,jdbcType=INTEGER},sgus_goods_id =
        #{goodsId,jdbcType=BIGINT},sgus_post_picture =
        #{postPicture,jdbcType=VARCHAR},sgu_pictures =
        #{pictures,jdbcType=VARCHAR},sgu_hongbao =
        #{hongbao,jdbcType=DECIMAL},sgu_link =
        #{link,jdbcType=VARCHAR},sgu_quanlink =
        #{quanLink,jdbcType=VARCHAR},sgu_tkcode =
        #{tkCode,jdbcType=VARCHAR},sgu_createtime =
        #{createTime,jdbcType=TIMESTAMP} ,sgus_share_img
        =#{shareImg,jdbcType=VARCHAR} where sgus_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective"
        parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory">
        update yeshi_ec_share_goods_usershare
        <set>
            <if test="user != null">sgus_uid=#{user.id,jdbcType=BIGINT},</if>
            <if test="goodsType != null">sgus_goods_type=#{goodsType,jdbcType=INTEGER},</if>
            <if test="goodsId != null">sgus_goods_id=#{goodsId,jdbcType=BIGINT},</if>
            <if test="postPicture != null">sgus_post_picture=#{postPicture,jdbcType=VARCHAR},</if>
            <if test="pictures != null">sgu_pictures=#{pictures,jdbcType=VARCHAR},</if>
            <if test="hongbao != null">sgu_hongbao=#{hongbao,jdbcType=DECIMAL},</if>
            <if test="link != null">sgu_link=#{link,jdbcType=VARCHAR},</if>
            <if test="quanLink != null">sgu_quanlink=#{quanLink,jdbcType=VARCHAR},</if>
            <if test="tkCode != null">sgu_tkcode=#{tkCode,jdbcType=VARCHAR},</if>
            <if test="createTime != null">sgu_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="id !=null">sgus_id =#{id,jdbcType=BIGINT},</if>
            <if test="shareImg !=null">sgus_share_img =#{shareImg,jdbcType=VARCHAR},</if>
        </set>
        where sgus_id = #{id,jdbcType=BIGINT}
    </update>
    <select id="countUserShares" parameterType="java.lang.Long" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(sgus_id),0) FROM  yeshi_ec_share_goods_usershare WHERE sgus_uid =#{userId,jdbcType=BIGINT}
   </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/goods/ShareGoodsTextTemplateMapper.xml
@@ -1,92 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate">
        <id column="st_id" property="id" jdbcType="BIGINT" />
        <result column="st_uid" property="uid" jdbcType="BIGINT" />
        <result column="st_share_text_template" property="shareTextTemplate"
            jdbcType="VARCHAR" />
        <result column="st_share_coupon_text_template" property="shareCouponTextTemplate"
            jdbcType="VARCHAR" />
        <result column="st_share_taolijin_text_template" property="shareTaoLiJinTextTemplate" jdbcType="VARCHAR" />
        <result column="st_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="st_update_time" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">st_id,st_uid,st_share_text_template,st_share_coupon_text_template,st_share_taolijin_text_template,st_create_time,st_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_template where st_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByUid" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_template where st_uid = #{0}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_share_template where st_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_share_template
        (st_id,st_uid,st_share_text_template,st_share_coupon_text_template,st_share_taolijin_text_template,st_create_time,st_update_time)
        values
        (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{shareTextTemplate,jdbcType=VARCHAR},#{shareCouponTextTemplate,jdbcType=VARCHAR},#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_share_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">st_id,</if>
            <if test="uid != null">st_uid,</if>
            <if test="shareTextTemplate != null">st_share_text_template,</if>
            <if test="shareCouponTextTemplate != null">st_share_coupon_text_template,</if>
            <if test="shareTaoLiJinTextTemplate != null">st_share_taolijin_text_template,</if>
            <if test="createTime != null">st_create_time,</if>
            <if test="updateTime != null">st_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="shareTextTemplate != null">#{shareTextTemplate,jdbcType=VARCHAR},</if>
            <if test="shareCouponTextTemplate != null">#{shareCouponTextTemplate,jdbcType=VARCHAR},</if>
            <if test="shareTaoLiJinTextTemplate != null">#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate">update
        yeshi_ec_share_template set st_uid =
        #{uid,jdbcType=BIGINT},st_share_text_template =
        #{shareTextTemplate,jdbcType=VARCHAR},st_share_coupon_text_template =
        #{shareCouponTextTemplate,jdbcType=VARCHAR},st_share_taolijin_text_template =
        #{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},st_create_time =
        #{createTime,jdbcType=TIMESTAMP},st_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where st_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate">
        update yeshi_ec_share_template
        <set>
            <if test="uid != null">st_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="shareTextTemplate != null">st_share_text_template=#{shareTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="shareCouponTextTemplate != null">st_share_coupon_text_template=#{shareCouponTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="shareTaoLiJinTextTemplate != null">st_share_taolijin_text_template=#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">st_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">st_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where st_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate">
        <id column="st_id" property="id" jdbcType="BIGINT" />
        <result column="st_uid" property="uid" jdbcType="BIGINT" />
        <result column="st_share_text_template" property="shareTextTemplate"
            jdbcType="VARCHAR" />
        <result column="st_share_coupon_text_template" property="shareCouponTextTemplate"
            jdbcType="VARCHAR" />
        <result column="st_share_taolijin_text_template" property="shareTaoLiJinTextTemplate" jdbcType="VARCHAR" />
        <result column="st_share_jd_text_template" property="shareJDTextTemplate" jdbcType="VARCHAR" />
        <result column="st_share_jd_text_template_coupon" property="shareJDTextTemplateCoupon" jdbcType="VARCHAR" />
        <result column="st_share_pdd_text_template" property="sharePDDTextTemplate" jdbcType="VARCHAR" />
        <result column="st_share_pdd_text_template_coupon" property="sharePDDTextTemplateCoupon" jdbcType="VARCHAR" />
        <result column="st_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="st_update_time" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">st_id,st_uid,st_share_text_template,st_share_coupon_text_template,st_share_taolijin_text_template,st_create_time,st_share_jd_text_template,st_share_jd_text_template_coupon,st_share_pdd_text_template,st_share_pdd_text_template_coupon,st_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_template where st_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByUid" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_share_template where st_uid = #{0}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_share_template where st_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_share_template
        (st_id,st_uid,st_share_text_template,st_share_coupon_text_template,st_share_taolijin_text_template,st_share_jd_text_template,st_share_jd_text_template_coupon,st_share_pdd_text_template,st_share_pdd_text_template_coupon,st_create_time,st_update_time)
        values
        (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{shareTextTemplate,jdbcType=VARCHAR},#{shareCouponTextTemplate,jdbcType=VARCHAR},#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},#{shareJDTextTemplate,jdbcType=VARCHAR},#{shareJDTextTemplateCoupon,jdbcType=VARCHAR},#{sharePDDTextTemplate,jdbcType=VARCHAR},#{sharePDDTextTemplateCoupon,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_share_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">st_id,</if>
            <if test="uid != null">st_uid,</if>
            <if test="shareTextTemplate != null">st_share_text_template,</if>
            <if test="shareCouponTextTemplate != null">st_share_coupon_text_template,</if>
            <if test="shareTaoLiJinTextTemplate != null">st_share_taolijin_text_template,</if>
            <if test="shareJDTextTemplate != null">st_share_jd_text_template,</if>
            <if test="shareJDTextTemplateCoupon != null">st_share_jd_text_template_coupon,</if>
            <if test="sharePDDTextTemplate != null">st_share_pdd_text_template,</if>
            <if test="sharePDDTextTemplateCoupon != null">st_share_pdd_text_template_coupon,</if>
            <if test="createTime != null">st_create_time,</if>
            <if test="updateTime != null">st_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="shareTextTemplate != null">#{shareTextTemplate,jdbcType=VARCHAR},</if>
            <if test="shareCouponTextTemplate != null">#{shareCouponTextTemplate,jdbcType=VARCHAR},</if>
            <if test="shareTaoLiJinTextTemplate != null">#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},</if>
            <if test="shareJDTextTemplate != null">#{shareJDTextTemplate,jdbcType=VARCHAR},</if>
            <if test="shareJDTextTemplateCoupon != null">#{shareJDTextTemplateCoupon,jdbcType=VARCHAR},</if>
            <if test="sharePDDTextTemplate != null">#{sharePDDTextTemplate,jdbcType=VARCHAR},</if>
            <if test="sharePDDTextTemplateCoupon != null">#{sharePDDTextTemplateCoupon,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate">update
        yeshi_ec_share_template set st_uid =
        #{uid,jdbcType=BIGINT},st_share_text_template =
        #{shareTextTemplate,jdbcType=VARCHAR},st_share_coupon_text_template =
        #{shareCouponTextTemplate,jdbcType=VARCHAR},
        st_share_taolijin_text_template =#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},
        st_share_jd_text_template =#{shareJDTextTemplate,jdbcType=VARCHAR},
        st_share_jd_text_template_coupon =#{shareJDTextTemplateCoupon,jdbcType=VARCHAR},
        st_share_pdd_text_template =#{sharePDDTextTemplate,jdbcType=VARCHAR},
        st_share_pdd_text_template_coupon =#{sharePDDTextTemplateCoupon,jdbcType=VARCHAR},
        st_create_time =#{createTime,jdbcType=TIMESTAMP},st_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where st_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate">
        update yeshi_ec_share_template
        <set>
            <if test="uid != null">st_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="shareTextTemplate != null">st_share_text_template=#{shareTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="shareCouponTextTemplate != null">st_share_coupon_text_template=#{shareCouponTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="shareTaoLiJinTextTemplate != null">st_share_taolijin_text_template=#{shareTaoLiJinTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="st_share_jd_text_template != null">st_share_jd_text_template=#{st_share_jd_text_template,jdbcType=VARCHAR},
            </if>
            <if test="shareJDTextTemplateCoupon != null">st_share_jd_text_template_coupon=#{shareJDTextTemplateCoupon,jdbcType=VARCHAR},
            </if>
            <if test="sharePDDTextTemplate != null">st_share_pdd_text_template=#{sharePDDTextTemplate,jdbcType=VARCHAR},
            </if>
            <if test="sharePDDTextTemplateCoupon != null">st_share_pdd_text_template_coupon=#{sharePDDTextTemplateCoupon,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">st_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">st_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where st_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -10,12 +10,17 @@
import org.yeshi.utils.BigDecimalUtil;
import com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
@@ -56,7 +61,44 @@
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
    public void saveCommonTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException {
        isCommonTemplateRight(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setShareJDTextTemplate(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setShareJDTextTemplate(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
    public void saveCommonTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException {
        isCommonTemplateRight(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setSharePDDTextTemplate(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setSharePDDTextTemplate(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Override
@@ -84,6 +126,51 @@
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setShareCouponTextTemplate(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Transactional
    @Override
    public void saveCouponTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException {
        // 格式验证
        isTaoLiJinTemplateRight(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setShareJDTextTemplateCoupon(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setShareJDTextTemplateCoupon(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
    }
    @Transactional
    @Override
    public void saveCouponTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException {
        // 格式验证
        isTaoLiJinTemplateRight(template);
        ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (old != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(old.getId());
            update.setSharePDDTextTemplateCoupon(template);
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        } else {
            ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
            textTemplate.setCreateTime(new Date());
            textTemplate.setSharePDDTextTemplateCoupon(template);
            textTemplate.setUid(uid);
            shareGoodsTextTemplateMapper.insertSelective(textTemplate);
        }
@@ -131,6 +218,11 @@
    }
    
    @Override
    public ShareGoodsTextTemplate getShareGoodsTextTemplate(Long uid) {
        return shareGoodsTextTemplateMapper.selectByUid(uid);
    }
    @Override
    public void isCommonTemplateRight(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{店铺类型}", "{商品原价}", "{月销量}", "{短链}", "{淘口令}" };
        int keysCount = 0;
@@ -142,8 +234,54 @@
    }
    @Override
    public void isCommonTemplateRightJD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}",  "{商品原价}", "{月销量}", "{短链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void isCommonTemplateRightPDD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{商品原价}", "{月销量}", "{短链接}", "{多多口令}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void isCouponTemplateRight(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{店铺类型}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{月销量}", "{领券短链}", "{淘口令}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void isCouponTemplateRightJD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{月销量}", "{短链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
                keysCount++;
        if (keysCount == 0)
            throw new ShareGoodsTextTemplateException(1, "模板格式有误");
    }
    @Override
    public void isCouponTemplateRightPDD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{总销量}", "{短链接}"};
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
@@ -194,6 +332,43 @@
                    .replace("{店铺类型}", goods.getUserType() == 1 ? "天猫价" : "淘宝价");
        }
    }
    @Override
    public String createContentByTemplateJD(String template, Long uid, JDGoods goods, String shortLink, boolean hasCoupon) {
        if (!hasCoupon) {
            return template.replace("{标题}", goods.getSkuName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(goods.getPrice()).toString())
                    .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink);
        } else {
            return template.replace("{标题}", goods.getSkuName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera( goods.getPrice()).toString())
                    .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink)
                    .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(goods.getCouponInfo().getDiscount()).toString())
                    .replace("{优惠券价}", BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(goods)).toString());
        }
    }
    @Override
    public String createContentByTemplatePDD(String template, Long uid, PDDGoodsDetail goods,
            String shortLink, boolean hasCoupon, String token) {
        if (!hasCoupon) {
            template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())).toString())
                    .replace("{总销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{短链接}", shortLink);
        } else {
            template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())).toString())
                    .replace("{总销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{短链接}", shortLink)
                    .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())).toString())
                    .replace("{优惠券价}", BigDecimalUtil.getWithNoZera( PinDuoDuoUtil.getQuanPrice(goods)).toString());
        }
        if (StringUtil.isNullOrEmpty(token)) {
            template = template.replace("{多多口令}打开拼多多,", "");
        } else {
            template = template.replace("{多多口令}", token);
        }
        return template;
    }
    @Override
    public void resetCommonTemplate(Long uid) {
@@ -219,6 +394,58 @@
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public void resetCommonTemplateJD(Long uid) {
        ShareGoodsTextTemplate template = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (template != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(template.getId());
            update.setShareJDTextTemplate("");
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public void resetCouponTemplateJD(Long uid) {
        ShareGoodsTextTemplate template = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (template != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(template.getId());
            update.setShareJDTextTemplateCoupon("");
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public void resetCommonTemplatePDD(Long uid) {
        ShareGoodsTextTemplate template = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (template != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(template.getId());
            update.setSharePDDTextTemplate("");
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public void resetCouponTemplatePDD(Long uid) {
        ShareGoodsTextTemplate template = shareGoodsTextTemplateMapper.selectByUid(uid);
        if (template != null) {
            ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
            update.setId(template.getId());
            update.setSharePDDTextTemplateCoupon("");
            update.setUpdateTime(new Date());
            shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public void resetTaoLijinTemplate(Long uid) {
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsTextTemplateService.java
@@ -1,5 +1,8 @@
package com.yeshi.fanli.service.inter.goods;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
@@ -107,4 +110,90 @@
     * @return
     */
    public String getTaoLiJinTemplate(Long uid);
    /**
     * 京东有券验证
     * @param template
     * @throws ShareGoodsTextTemplateException
     */
    public void isCouponTemplateRightJD(String template) throws ShareGoodsTextTemplateException;
    /**
     * 拼多多有券验证
     * @param template
     * @throws ShareGoodsTextTemplateException
     */
    public void isCouponTemplateRightPDD(String template) throws ShareGoodsTextTemplateException;
    /**
     * 京东无券验证
     * @param template
     * @throws ShareGoodsTextTemplateException
     */
    public void isCommonTemplateRightJD(String template) throws ShareGoodsTextTemplateException;
    /**
     * 拼多多无券验证
     * @param template
     * @throws ShareGoodsTextTemplateException
     */
    public void isCommonTemplateRightPDD(String template) throws ShareGoodsTextTemplateException;
    /**
     * 京东
     * @param template
     * @param uid
     * @param goods
     * @param shortLink
     * @param hasCoupon
     * @return
     */
    public String createContentByTemplateJD(String template, Long uid, JDGoods goods, String shortLink, boolean hasCoupon);
    /**
     * 拼多多
     * @param template
     * @param uid
     * @param goods
     * @param token
     * @param shortLink
     * @param hasCoupon
     * @param tljId
     * @return
     */
    public String createContentByTemplatePDD(String template, Long uid, PDDGoodsDetail goods,String shortLink, boolean hasCoupon, String token);
    /**
     * 重置京东
     * @param uid
     */
    public void resetCommonTemplateJD(Long uid);
    /**
     * 重置京东有券
     * @param uid
     */
    public void resetCouponTemplateJD(Long uid);
    /**
     * 重置拼多多
     * @param uid
     */
    public void resetCommonTemplatePDD(Long uid);
    /**
     * 重置拼多多有券
     * @param uid
     */
    public void resetCouponTemplatePDD(Long uid);
    public ShareGoodsTextTemplate getShareGoodsTextTemplate(Long uid);
    public void saveCouponTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void saveCouponTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void saveCommonTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException;
    public void saveCommonTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException;
}
fanli/src/main/java/com/yeshi/fanli/util/cache/JDGoodsCacheUtil.java
New file
@@ -0,0 +1,62 @@
package com.yeshi.fanli.util.cache;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@Component
public class JDGoodsCacheUtil {
    @Resource
    private RedisManager redisManager;
    /**
     * 保存常规的京东商品详情(搜索,详情)
     *
     * @param goods
     */
    public void saveGoodsInfo(JDGoods goods) {
        if (goods == null || goods.getSkuId() == null) {
            return;
        }
        // 保存20分钟
        String key = "JD-goods-" + goods.getSkuId();
        redisManager.cacheCommonString(key, new Gson().toJson(goods), 60 * 20);
    }
    /**
     * 获取缓存数据
     * @param goodsId
     * @return
     */
    public JDGoods getGoodsInfo(long goodsId){
        String key = "JD-goods-" + goodsId;
        String value = redisManager.getCommonString(key);
        if (!StringUtil.isNullOrEmpty(value)) {
            return JsonUtil.getSimpleGson().fromJson(value, JDGoods.class);
        }
        JDGoods goods = JDApiUtil.queryGoodsDetail(goodsId);
        if (goods == null) {
            goods = JDApiUtil.getGoodsDetail(goodsId);
        }
        // 缓存20分钟
        if (goods != null) {
            redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(goods), 60 * 20);
        }
        return goods;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/cache/PinDuoDuoCacheUtil.java
New file
@@ -0,0 +1,55 @@
package com.yeshi.fanli.util.cache;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
@Component
public class PinDuoDuoCacheUtil {
    @Resource
    private RedisManager redisManager;
    /**
     * 保存常规的京东商品详情(搜索,详情)
     *
     * @param goods
     */
    public void saveGoodsInfo(PDDGoodsDetail goods) {
        if (goods == null || goods.getGoodsId() == null) {
            return;
        }
        // 保存20分钟
        String key = "PDD-goods-" + goods.getGoodsId();
        redisManager.cacheCommonString(key, new Gson().toJson(goods), 60 * 20);
    }
    /**
     * 获取缓存数据
     * @param goodsId
     * @return
     */
    public PDDGoodsDetail getGoodsInfo(long goodsId){
        String key = "PDD-goods-" + goodsId;
        String value = redisManager.getCommonString(key);
        if (!StringUtil.isNullOrEmpty(value)) {
            return JsonUtil.getSimpleGson().fromJson(value, PDDGoodsDetail.class);
        }
        PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
        // 缓存20分钟
        if (goods != null) {
            redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(goods), 60 * 20);
        }
        return goods;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -10,6 +10,7 @@
import org.yeshi.utils.taobao.TbImgUtil;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.jd.JDShopInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
@@ -384,13 +385,13 @@
        }
        // 店铺信息
//        JDShopInfo shopInfo = goods.getShopInfo();
//        if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) {
//            ShopInfoVO shop = new ShopInfoVO();
//            shop.setShopName(shopInfo.getShopName());
//            shop.setId(shopInfo.getShopId().toString());
//            goodsInfo.setShopInfo(shop);
//        }
        JDShopInfo shopInfo = goods.getShopInfo();
        if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) {
            ShopInfoVO shop = new ShopInfoVO();
            shop.setShopName(shopInfo.getShopName());
            shop.setId(shopInfo.getShopId().toString());
            goodsInfo.setShopInfo(shop);
        }
        
        // 京东自营标签
@@ -498,16 +499,15 @@
        }
        // 店铺信息
//        String mallName = goods.getMallName();
//        if (!StringUtil.isMobile(mallName)) {
//            ShopInfoVO shop = new ShopInfoVO();
//            shop.setShopName(mallName);
//
//            if (goods.getMallId() != null) {
//                shop.setId(goods.getMallId().toString());
//            }
//            goodsInfo.setShopInfo(shop);
//        }
        String mallName = goods.getMallName();
        if (!StringUtil.isMobile(mallName)) {
            ShopInfoVO shop = new ShopInfoVO();
            shop.setShopName(mallName);
            if (goods.getMallId() != null) {
                shop.setId(goods.getMallId().toString());
            }
            goodsInfo.setShopInfo(shop);
        }
        return goodsInfo;
    }
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -22,9 +22,11 @@
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDOrderResult;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.jd.JDShopInfo;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.jd.JDOrder;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@@ -176,9 +178,12 @@
        filter.setPageIndex(1);
        filter.setPageSize(20);
        filter.setListId(skuIdList);
        List<JDGoods> list = queryByKey(filter);
        if (list != null && list.size() > 0)
            return list.get(0);
        JDSearchResult searchResult = queryByKey(filter);
        if (searchResult != null) {
            List<JDGoods> list = searchResult.getGoodsList();
            if (list != null && list.size() > 0)
                return list.get(0);
        }
        return null;
    }
    
@@ -187,7 +192,9 @@
     * @param skuIdList
     * @return
     */
    public static List<JDGoods> queryByKey(JDFilter filter) {
    public static JDSearchResult queryByKey(JDFilter filter) {
        JDSearchResult searchResult = new JDSearchResult();
        List<JDGoods> list = new ArrayList<>();
        JSONObject json = new JSONObject();
        json.put("pageIndex", filter.getPageIndex());
@@ -273,8 +280,15 @@
                    }
                }
            }
            long totalCount = resultJson.optLong("totalCount");
            PageEntity pageEntity = new PageEntity();
            pageEntity.setTotalCount(totalCount);
            searchResult.setPageEntity(pageEntity);
        }
        return list;
        searchResult.setGoodsList(list);
        return searchResult;
    }
    
    
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -90,13 +90,6 @@
        map.put("pid", PID_FANLI);
        String result = baseRequest(map);
        
        try {
            result = new String(result.getBytes("GBK"),"UTF-8");
//            result = new String(result.getBytes("GBK"),"ISO-8859-1");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        JSONObject json = JSONObject.fromObject(result);
        JSONObject root = json.optJSONObject("goods_search_response");
        JSONArray array = root.optJSONArray("goods_list");
@@ -205,5 +198,31 @@
            return goodsList.get(0);
        return null;
    }
    /**
     * 获取商品详情
     *
     * @param goodsId
     */
    public static String createGenerate(Long goodsId) {
        JSONArray array = new JSONArray();
        array.add(goodsId);
        Map<String, String> map = new HashMap<>();
        map.put("type", "pdd.ddk.phrase.generate");
        map.put("goods_id_list", array.toString());
        map.put("p_id", PID_FANLI);
        String result = baseRequest(map);
        JSONObject resultJson = JSONObject.fromObject(result);
        System.out.println(result);
        JSONObject root = resultJson.optJSONObject("ddk_phrase_generate_response");
        if (root != null) {
            array = root.optJSONArray("promotion_phrase_list");
            JSONObject phraseObject = JSONObject.fromObject( array.get(0));
            return phraseObject.optString("phrase");
        }
        return null;
    }
}