yujian
2019-07-25 0cc3b905e5945d1b4b02ee5f91a615bcfd8f08d6
京东兼容
26个文件已修改
4个文件已添加
1100 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserCouponController.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 192 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/common/GoodsOtherInfoDTO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/goods/CommonGoods.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/jd/JDGoodsException.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/goods/CommonGoodsMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/jd/JDGoodsServiceImpl.java 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/jd/JDGoodsService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/StringUtil.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/JDGoodsCacheUtil.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/cache/PinDuoDuoCacheUtil.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java 138 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java 109 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsDetailVO.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
@@ -23,8 +23,6 @@
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.util.Constant;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserCouponController.java
@@ -216,14 +216,18 @@
     * @param out
     */
    @RequestMapping(value = "useFreeCoupon", method = RequestMethod.POST)
    public void useFreeCoupon(AcceptData acceptData, Long uid, Long cid, Long goodId, PrintWriter out) {
    public void useFreeCoupon(AcceptData acceptData, Long uid, Long cid, Long goodId, Integer goodsType, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
        if (goodsType == null || goodsType > 3 || goodsType < 1) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
        try {
            UserSystemCouponService.useGoodsCoupon(uid, cid, goodId);
            UserSystemCouponService.useGoodsCoupon(uid, cid, goodId, goodsType);
            out.print(JsonUtil.loadTrueResult("使用成功"));
        } catch (UserSystemCouponException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
@@ -293,11 +297,8 @@
        
        try {
            UserSystemCouponService.useOrderCoupon(uid, cid, orderNo, goodsType);
            JSONObject data = commonOrderService.getRewardJumpInfo(orderNo);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserSystemCouponException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
@@ -314,17 +315,16 @@
     * @param out
     */
    @RequestMapping(value = "getRewardRecord", method = RequestMethod.POST)
    public void getRewardCounponRecord(AcceptData acceptData, String orderNo, PrintWriter out) {
    public void getRewardCounponRecord(AcceptData acceptData, String orderNo, Integer goodsType, PrintWriter out) {
        try {
            UserSystemCouponRecordVO rewardRecord = UserSystemCouponService.getRewardCouponRecord(orderNo);
            if (goodsType == null || goodsType > 3 || goodsType < 1) {
                goodsType = Constant.SOURCE_TYPE_TAOBAO;
            }
            UserSystemCouponRecordVO rewardRecord = UserSystemCouponService.getRewardCouponRecord(orderNo, goodsType);
            JSONObject data = new JSONObject();
            data.put("rewardRecord", rewardRecord);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserSystemCouponException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
@@ -341,17 +341,16 @@
     * @param out
     */
    @RequestMapping(value = "getFreeCounponRecord", method = RequestMethod.POST)
    public void getFreeCounponRecord(AcceptData acceptData, String orderNo, PrintWriter out) {
    public void getFreeCounponRecord(AcceptData acceptData, String orderNo, Integer goodsType, PrintWriter out) {
        try {
            UserSystemCouponRecordVO rewardRecord = UserSystemCouponService.getFreeCouponRecord(orderNo);
            if (goodsType == null || goodsType > 3 || goodsType < 1) {
                goodsType = Constant.SOURCE_TYPE_TAOBAO;
            }
            UserSystemCouponRecordVO rewardRecord = UserSystemCouponService.getFreeCouponRecord(orderNo, goodsType);
            JSONObject data = new JSONObject();
            data.put("frreCouponRecord", rewardRecord);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserSystemCouponException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -14,9 +14,13 @@
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.taobao.TbImgUtil;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.ShamUser;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
import com.yeshi.fanli.entity.jd.JDGoods;
@@ -51,6 +55,7 @@
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserMoneyExtraService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
@@ -59,11 +64,14 @@
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.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
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;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
@@ -72,6 +80,7 @@
import com.yeshi.fanli.vo.goods.MoneyInfoVO;
import com.yeshi.fanli.vo.goods.OtherInfo;
import com.yeshi.fanli.vo.goods.ShareVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.tlj.ReduceHongBao;
import com.yeshi.fanli.vo.tlj.SpreadHongBao;
@@ -149,8 +158,14 @@
    private TLJBuyGoodsService tljBuyGoodsService;
    
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    private UserInfoService userInfoService;
    
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    
    /**
     * 淘宝商品详情
@@ -548,9 +563,10 @@
            return;
        }
        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id);
        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口
        if (jdGoods == null) {
            jdGoods = JDApiUtil.getGoodsDetail(id);
            jdGoods = JDUtil.getGoodsDetail(id); // 爬取网页
            //jdGoods = JDApiUtil.getGoodsDetail(id); // 普通接口
        }
        
        if (jdGoods == null) {
@@ -558,14 +574,27 @@
            return;
        }
        
        List<String> imageList = jdGoods.getImageList();
        if (imageList == null) {
            imageList = new ArrayList<String>();
            imageList.add(jdGoods.getPicUrl());
        }
        // 保存缓存
        jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate);
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
@@ -690,6 +719,14 @@
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate);
        ShopInfoVO shopInfo = goodsDetail.getShopInfo();
        if (shopInfo != null) {
            if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
                    || shopInfo.getScoreSeller() == null) {
                goodsDetail.setShopInfo(null);
            }
        }
        GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
        extraVO.setIsNative(false);
        // IOS是否正在上线
@@ -793,7 +830,28 @@
        if (goodsType == Constant.SOURCE_TYPE_JD) {
            JSONObject data = new JSONObject();
            data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
            data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
            List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
            if (list == null) {
                list = new ArrayList<JDGoods>();
            } else if (list.size() > 10) {
                list = list.subList(0, 10);
            }
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
            for (JDGoods goods: list) {
                listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate));
            }
            // 取偶数个数据
            if (listDetailVO.size() % 2 != 0) {
                listDetailVO.remove(listDetailVO.size() - 1);
            }
            data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listDetailVO));
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
@@ -802,7 +860,41 @@
        if (goodsType == Constant.SOURCE_TYPE_PDD) {
            JSONObject data = new JSONObject();
            data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
            data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
            List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
            List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(id);
            if (goodsIdList != null && goodsIdList.size() > 0) {
                PDDSearchFilter pddfilter = new PDDSearchFilter();
                pddfilter.setPage(1);
                pddfilter.setPageSize(Constant.PAGE_SIZE);
                Long[] strings = new Long[goodsIdList.size()];
                pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
                PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
                if (result != null) {
                    List<PDDGoodsDetail> goodsList = result.getGoodsList();
                    if (goodsList != null && goodsList.size() > 0) {
                        if (goodsList.size() > 10) {
                            goodsList = goodsList.subList(0, 10);
                        }
                        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                        BigDecimal shareRate = hongBaoManageService.getShareRate();
                        for (PDDGoodsDetail goods : goodsList) {
                            listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate));
                        }
                    }
                }
            }
            // 取偶数个数据
            if (listDetailVO.size() % 2 != 0) {
                listDetailVO.remove(listDetailVO.size() - 1);
            }
            data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listDetailVO));
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
@@ -881,5 +973,93 @@
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 京东购买链接
     * @param acceptData
     * @param uid
     * @param id
     * @param source
     * @param request
     * @param out
     */
    @RequestMapping(value = "getJDLink")
    public void getJDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        String couponUrl = null;
        String materialId = "https://item.jd.com/" + id + ".html";
        JDCouponInfo couponInfo = goods.getCouponInfo();
        if (couponInfo != null) {
            couponUrl = couponInfo.getLink();
        }
        String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", id + "");
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 拼多多购买链接
     * @param acceptData
     * @param uid
     * @param id
     * @param source
     * @param request
     * @param out
     */
    @RequestMapping(value = "getPDDLink")
    public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
            return;
        }
        UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
        if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
            out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
            return;
        }
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(id);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
            return;
        }
        String jumpLink = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        out.print(JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java
@@ -13,19 +13,30 @@
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.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.jd.JDGoodsException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.homemodule.SpecialService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.jd.JDGoodsService;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -61,6 +72,13 @@
    @Resource
    private ConfigService configService;
    
    @Resource
    private SpecialService specialService;
    @Resource
    private JDGoodsService jdGoodsService;
    /**
     * 京东专题分类
     * @param acceptData
@@ -68,15 +86,8 @@
     */
    @RequestMapping(value = "getClass")
    public void getJDClass(AcceptData acceptData, PrintWriter out) {
        List<GoodsClass> list = new ArrayList<GoodsClass>();
        list.add(new GoodsClass(1L, "精选"));
        list.add(new GoodsClass(2L, "女装"));
        list.add(new GoodsClass(3L, "男装"));
        list.add(new GoodsClass(4L, "美妆"));
        list.add(new GoodsClass(5L, "美食"));
        list.add(new GoodsClass(6L, "居家"));
        JSONObject root = new JSONObject();
        root.put("list", list);
        root.put("list", jdGoodsService.getSpecialClass());
        root.put("jdLink", configService.get("jingdong_h5_link"));
        out.print(JsonUtil.loadTrueResult(root));
    }
@@ -88,41 +99,48 @@
     * @param out
     */
    @RequestMapping(value = "getGoodsInfo")
    public void getGoodsInfo(AcceptData acceptData, Integer cid, Integer page, PrintWriter out) {
    public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) {
        JSONObject root = new JSONObject();
        if (cid == 1 && page == 1) {
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jingdong_special_top");
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jingdong_special_index");
            if (topPicList == null) {
                topPicList = new ArrayList<SwiperPicture>();
            }
            root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
        }
        List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * 20, 20);
        if (listQuery == null) {
            listQuery = new ArrayList<QualityFactory>();
        }
        JSONArray array = new JSONArray();
        if (listQuery.size() > 0) {
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            for (QualityFactory qualityFactory : listQuery) {
                TaoBaoGoodsBrief goods = qualityFactory.getTaoBaoGoodsBrief();
                if (goods == null) {
                    continue;
                }
                array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate)));
            List<Special> listSpecial = specialService.listByPlaceKey("jingdong_special_index");
            if (listSpecial == null) {
                listSpecial = new ArrayList<Special>();
            }
            root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial));
        }
        long count = qualityGoodsService.countFreeGoods();
        
        root.put("count", count);
        root.put("list", array);
        out.print(JsonUtil.loadTrueResult(root));
        try {
            JDSearchResult result = jdGoodsService.specialSearch(page, cid);
            JSONArray array = new JSONArray();
            JSONObject data = new JSONObject();
            if (result != null) {
                List<JDGoods> goodsList = result.getGoodsList();
                if (goodsList != null && goodsList.size() > 0) {
                    BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                    BigDecimal shareRate = hongBaoManageService.getShareRate();
                    Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                            .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                    for (JDGoods goods : goodsList) {
                        GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate,
                                shareRate);
                        array.add(gson.toJson(goodsDetailVO));
                    }
                }
            }
            data.put("list", array);
            data.put("count", 1000);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (JDGoodsException e) {
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java
@@ -73,11 +73,23 @@
    public void getJDClass(AcceptData acceptData, PrintWriter out) {
        List<GoodsClass> list = new ArrayList<GoodsClass>();
        list.add(new GoodsClass(1L, "精选"));
        list.add(new GoodsClass(2L, "女装"));
        list.add(new GoodsClass(3L, "男装"));
        list.add(new GoodsClass(4L, "美妆"));
        list.add(new GoodsClass(5L, "美食"));
        list.add(new GoodsClass(6L, "居家"));
        list.add(new GoodsClass(2L, "清仓"));
        list.add(new GoodsClass(3L, "百货"));
        list.add(new GoodsClass(4L, "母婴"));
        list.add(new GoodsClass(5L, "食品"));
        list.add(new GoodsClass(6L, "女装"));
        list.add(new GoodsClass(7L, "电器"));
        list.add(new GoodsClass(8L, "鞋包"));
        list.add(new GoodsClass(9L, "内衣"));
        list.add(new GoodsClass(10L, "美妆"));
        list.add(new GoodsClass(11L, "男装"));
        list.add(new GoodsClass(12L, "汽车"));
        list.add(new GoodsClass(13L, "水果"));
        list.add(new GoodsClass(14L, "家居"));
        list.add(new GoodsClass(15L, "文具"));
        list.add(new GoodsClass(16L, "运动"));
        list.add(new GoodsClass(17L, "虚拟"));
        list.add(new GoodsClass(18L, "医药"));
        JSONObject root = new JSONObject();
        root.put("list", list);
        out.print(JsonUtil.loadTrueResult(root));
@@ -93,13 +105,13 @@
    public void getGoodsInfo(AcceptData acceptData, Integer cid, Integer page, PrintWriter out) {
        JSONObject root = new JSONObject();
        if (cid == 1 && page == 1) {
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("index_top");
            List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("pinduoduo_special_index");
            if (topPicList == null) {
                topPicList = new ArrayList<SwiperPicture>();
            }
            root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList));
            
            List<Special> listSpecial = specialService.listByPlaceKey("pinduoduo_special_top");
            List<Special> listSpecial = specialService.listByPlaceKey("pinduoduo_special_index");
            if (listSpecial == null) {
                listSpecial = new ArrayList<Special>();
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -71,7 +71,6 @@
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.MonitorFactory;
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;
@@ -533,18 +532,12 @@
     * @param out
     */
    public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
        if (jdGoods == null) {
            jdGoods = JDApiUtil.getGoodsDetail(goodsId);
        }
        JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
        if (jdGoods == null) {
            out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
            return;
        }
        ShareInfoVO shareInfo = new ShareInfoVO();
        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goodsId + "");
@@ -555,6 +548,7 @@
            url = shortLink;
        }
        ShareInfoVO shareInfo = new ShareInfoVO();
        shareInfo.setClickUrl(url);
        shareInfo.setRule(configService.get("share_rule_link_jd"));
        shareInfo.setPictUrl(jdGoods.getPicUrl());
@@ -649,13 +643,11 @@
     * @param out
     */
    public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
        PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
        if (goods == null) {
            out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
            return;
        }
        ShareInfoVO shareInfo = new ShareInfoVO();
        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
@@ -665,7 +657,8 @@
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        ShareInfoVO shareInfo = new ShareInfoVO();
        shareInfo.setClickUrl(url);
        shareInfo.setRule(configService.get("share_rule_link_pdd"));
        shareInfo.setPictUrl(goods.getGoodsImageUrl());
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java
@@ -16,6 +16,7 @@
import com.google.gson.Gson;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
@@ -461,11 +462,20 @@
        String materialId = "https://item.jd.com/" + id + ".html";
        String jumpLink = JDApiUtil.convertLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid);
        
        int priceType = 1;
        BigDecimal price = jdGoods.getPrice();;
        JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
        if (pinGouInfo != null) {
            priceType = 2; // 拼购价
            price =  pinGouInfo.getPingouPrice();
        }
        JSONObject data = new JSONObject();
        data.put("jdzy", jdzy);
        data.put("imgs", imageList);
        data.put("title", jdGoods.getSkuName());
        data.put("zkPrice", jdGoods.getPrice());
        data.put("zkPrice", price);
        data.put("priceType", priceType);
        data.put("coupon", hasCoupon);
        data.put("couponAmount", discount);
        data.put("couponPrice", JDUtil.getQuanPrice(jdGoods));
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -209,7 +209,7 @@
     * @return
     */
    CommonOrderVO getCommonOrderByOrderNo(@Param("uid") Long uid, @Param("orderNo") String orderNo,
            @Param("orderState") Integer orderState);
            @Param("orderState") Integer orderState, @Param("sourceType") Integer sourceType);
    /**
     * 根据来源和交易ID获取订单详情
fanli/src/main/java/com/yeshi/fanli/dto/common/GoodsOtherInfoDTO.java
New file
@@ -0,0 +1,21 @@
package com.yeshi.fanli.dto.common;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
public class GoodsOtherInfoDTO {
    private String owner;// 京东- g=自营,p=pop
    private JDPingouInfo pinGouInfo;// 京东-拼购信息
    public String getOwner() {
        return owner;
    }
    public void setOwner(String owner) {
        this.owner = owner;
    }
    public JDPingouInfo getPinGouInfo() {
        return pinGouInfo;
    }
    public void setPinGouInfo(JDPingouInfo pinGouInfo) {
        this.pinGouInfo = pinGouInfo;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/goods/CommonGoods.java
@@ -63,6 +63,8 @@
    private String videoUrl;
    @Column(name = "cg_material_lib_type")
    private Integer materialLibType;// 物料库类型 1-营销商品库 0-非营销商品库
    @Column(name = "cg_other_info")
    private String otherInfo; // 商品其他信息-json字符串
    @Column(name = "cg_createtime")
    private Date createTime;
    @Column(name = "cg_updatetime")
@@ -258,4 +260,13 @@
    public void setPictureWhite(String pictureWhite) {
        this.pictureWhite = pictureWhite;
    }
    public String getOtherInfo() {
        return otherInfo;
    }
    public void setOtherInfo(String otherInfo) {
        this.otherInfo = otherInfo;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/jd/JDGoodsException.java
New file
@@ -0,0 +1,32 @@
package com.yeshi.fanli.exception.jd;
public class JDGoodsException extends Exception {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public JDGoodsException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public JDGoodsException() {
    }
    @Override
    public String getMessage() {
        return this.msg;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/goods/CommonGoodsMapper.xml
@@ -28,12 +28,13 @@
            jdbcType="INTEGER" />
        <result column="cg_video_cover" property="videoCover" jdbcType="VARCHAR" />
        <result column="cg_video_url" property="videoUrl" jdbcType="VARCHAR" />
        <result column="cg_other_info" property="otherInfo" jdbcType="VARCHAR" />
        <result column="cg_createtime" property="createTime" jdbcType="TIMESTAMP" />
        <result column="cg_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="cg_material_lib_type" property="materialLibType"
            jdbcType="INTEGER" />
    </resultMap>
    <sql id="Base_Column_List">cg_id,cg_title,cg_goods_id,cg_goods_type,cg_shop_type,cg_seller_id,cg_seller_name,cg_sales,cg_rate,cg_picture,cg_picture_white,cg_state,cg_price,cg_coupon_info,cg_coupon_startprice,cg_coupon_amount,cg_coupon_left_count,cg_coupon_total_count,cg_video_cover,cg_video_url,cg_createtime,cg_updatetime,cg_material_lib_type
    <sql id="Base_Column_List">cg_id,cg_title,cg_goods_id,cg_goods_type,cg_shop_type,cg_seller_id,cg_seller_name,cg_sales,cg_rate,cg_picture,cg_picture_white,cg_state,cg_price,cg_coupon_info,cg_coupon_startprice,cg_coupon_amount,cg_coupon_left_count,cg_coupon_total_count,cg_video_cover,cg_video_url,cg_other_info,cg_createtime,cg_updatetime,cg_material_lib_type
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
@@ -45,9 +46,9 @@
        yeshi_ec_common_goods where cg_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.goods.CommonGoods"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_goods
        (cg_id,cg_title,cg_goods_id,cg_goods_type,cg_shop_type,cg_seller_id,cg_seller_name,cg_sales,cg_rate,cg_picture,cg_picture_white,cg_state,cg_price,cg_coupon_info,cg_coupon_startprice,cg_coupon_amount,cg_coupon_left_count,cg_coupon_total_count,cg_video_cover,cg_video_url,cg_createtime,cg_updatetime,cg_material_lib_type)
        (cg_id,cg_title,cg_goods_id,cg_goods_type,cg_shop_type,cg_seller_id,cg_seller_name,cg_sales,cg_rate,cg_picture,cg_picture_white,cg_state,cg_price,cg_coupon_info,cg_coupon_startprice,cg_coupon_amount,cg_coupon_left_count,cg_coupon_total_count,cg_video_cover,cg_video_url,cg_other_info,cg_createtime,cg_updatetime,cg_material_lib_type)
        values
        (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{goodsId,jdbcType=BIGINT},#{goodsType,jdbcType=INTEGER},#{shopType,jdbcType=INTEGER},#{sellerId,jdbcType=BIGINT},#{sellerName,jdbcType=VARCHAR},#{sales,jdbcType=INTEGER},#{rate,jdbcType=DECIMAL},#{picture,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{couponInfo,jdbcType=VARCHAR},#{couponStartPrice,jdbcType=DECIMAL},#{couponAmount,jdbcType=DECIMAL},#{couponLeftCount,jdbcType=INTEGER},#{couponTotalCount,jdbcType=INTEGER},#{videoCover,jdbcType=VARCHAR},#{videoUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{materialLibType,jdbcType=INTEGER})
        (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{goodsId,jdbcType=BIGINT},#{goodsType,jdbcType=INTEGER},#{shopType,jdbcType=INTEGER},#{sellerId,jdbcType=BIGINT},#{sellerName,jdbcType=VARCHAR},#{sales,jdbcType=INTEGER},#{rate,jdbcType=DECIMAL},#{picture,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{couponInfo,jdbcType=VARCHAR},#{couponStartPrice,jdbcType=DECIMAL},#{couponAmount,jdbcType=DECIMAL},#{couponLeftCount,jdbcType=INTEGER},#{couponTotalCount,jdbcType=INTEGER},#{videoCover,jdbcType=VARCHAR},#{videoUrl,jdbcType=VARCHAR},#{otherInfo,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{materialLibType,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.CommonGoods"
        useGeneratedKeys="true" keyProperty="id">
@@ -73,6 +74,7 @@
            <if test="couponTotalCount != null">cg_coupon_total_count,</if>
            <if test="videoCover != null">cg_video_cover,</if>
            <if test="videoUrl != null">cg_video_url,</if>
            <if test="otherInfo != null">cg_other_info,</if>
            <if test="createTime != null">cg_createtime,</if>
            <if test="updateTime != null">cg_updatetime,</if>
            <if test="materialLibType != null">cg_material_lib_type,</if>
@@ -99,6 +101,7 @@
            <if test="couponTotalCount != null">#{couponTotalCount,jdbcType=INTEGER},</if>
            <if test="videoCover != null">#{videoCover,jdbcType=VARCHAR},</if>
            <if test="videoUrl != null">#{videoUrl,jdbcType=VARCHAR},</if>
            <if test="otherInfo != null">#{otherInfo,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="materialLibType != null">#{materialLibType,jdbcType=INTEGER}</if>
@@ -124,7 +127,8 @@
        #{couponLeftCount,jdbcType=INTEGER},cg_coupon_total_count =
        #{couponTotalCount,jdbcType=INTEGER},cg_video_cover =
        #{videoCover,jdbcType=VARCHAR},cg_video_url =
        #{videoUrl,jdbcType=VARCHAR},cg_createtime =
        #{videoUrl,jdbcType=VARCHAR},cg_other_info =
        #{otherInfo,jdbcType=VARCHAR},cg_createtime =
        #{createTime,jdbcType=TIMESTAMP},cg_updatetime =
        #{updateTime,jdbcType=TIMESTAMP} ,cg_material_lib_type
        =#{materialLibType,jdbcType=INTEGER} where cg_id =
@@ -154,6 +158,7 @@
            </if>
            <if test="videoCover != null">cg_video_cover=#{videoCover,jdbcType=VARCHAR},</if>
            <if test="videoUrl != null">cg_video_url=#{videoUrl,jdbcType=VARCHAR},</if>
            <if test="otherInfo != null">cg_other_info=#{otherInfo,jdbcType=VARCHAR},</if>
            <if test="createTime != null">cg_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">cg_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="id !=null">cg_id =#{id,jdbcType=BIGINT},</if>
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -769,7 +769,7 @@
        FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo}
        WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND  co.`co_source_type` = #{sourceType}
        <if test="orderState != null">
            AND co.co_state = #{orderState}
            <!-- 已收货 -->
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -10,6 +10,7 @@
import org.yeshi.utils.BigDecimalUtil;
import com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
@@ -236,7 +237,7 @@
    @Override
    public void isCommonTemplateRightJD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}",  "{商品原价}", "{月销量}", "{短链接}" };
        String[] keys = new String[] { "{标题}","{京东价}", "{商品原价}", "{月销量}", "{短链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
@@ -270,7 +271,7 @@
    
    @Override
    public void isCouponTemplateRightJD(String template) throws ShareGoodsTextTemplateException {
        String[] keys = new String[] { "{标题}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{月销量}", "{短链接}" };
        String[] keys = new String[] { "{标题}","{京东价}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{月销量}", "{短链接}" };
        int keysCount = 0;
        for (String key : keys)
            if (template != null && template.contains(key))
@@ -337,15 +338,28 @@
    
    @Override
    public String createContentByTemplateJD(String template, Long uid, JDGoods goods, String shortLink, boolean hasCoupon) {
        BigDecimal price = goods.getPrice();
        JDPingouInfo pinGouInfo = goods.getPinGouInfo();
        if (pinGouInfo != null) {
            price = pinGouInfo.getPingouPrice();
        }
        if (!hasCoupon) {
            return template.replace("{标题}", goods.getSkuName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(goods.getPrice()).toString())
            template = template.replace("{标题}", goods.getSkuName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(price).toString())
                    .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink);
        } else {
            return template.replace("{标题}", goods.getSkuName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera( goods.getPrice()).toString())
            template = template.replace("{标题}", goods.getSkuName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera(price).toString())
                    .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink)
                    .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(goods.getCouponInfo().getDiscount()).toString())
                    .replace("{优惠券价}", BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(goods)).toString());
        }
        if (pinGouInfo != null) {
            template = template.replace("{京东价}", "拼购价");
        } else {
            template = template.replace("{京东价}", "京东价");
        }
        return template;
    }
    
    
fanli/src/main/java/com/yeshi/fanli/service/impl/jd/JDGoodsServiceImpl.java
New file
@@ -0,0 +1,159 @@
package com.yeshi.fanli.service.impl.jd;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.JsonUtil;
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.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.exception.jd.JDGoodsException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.jd.JDGoodsService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
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.vo.goods.GoodsDetailVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service
public class JDGoodsServiceImpl implements JDGoodsService {
    @Resource
    private ConfigService configService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    private static final Map<Long, String> cidMap = new HashMap<Long, String>();
    private static final Map<String, Long> countMap = new HashMap<String, Long>();
    static {
        cidMap.put(1L, "nzjh");// 精选
        cidMap.put(2L, "737");// 电器: 家用电器
        cidMap.put(3L, "652,670");// 数码: 数码/电脑、办公
        cidMap.put(4L, "9987");// 手机:手机通讯
        cidMap.put(5L, "12218");// 生鲜
        cidMap.put(6L, "1315");// 服饰: 服饰内衣
        cidMap.put(7L, "1319,6233");// 母婴: 母婴/玩具乐器
        cidMap.put(8L, "1713");// 图书
        cidMap.put(9L, "6196");// 厨具
        cidMap.put(10L, "1320");// 食品: 食品饮料
        cidMap.put(11L, "1316,16750");// 美妆: 美妆护肤/个人护理
        cidMap.put(12L, "15901,1620,1672,12259,9192");// 百货:家庭清洁、纸品/居家日用/礼品/酒类/医药保健
        cidMap.put(13L, "11729");// 鞋靴
        cidMap.put(14L, "1318");// 运动:运动户外
        cidMap.put(15L, "17329");// 箱包: 箱包皮具
        cidMap.put(16L, "6994");// 宠物: 宠物生活
        cidMap.put(17L, "9855,9847,15248");// 家居: 家装建材/家具/家纺
        cidMap.put(18L, "6728");// 汽车:汽车用品
    }
    @Override
    public List<GoodsClass> getSpecialClass() {
        List<GoodsClass> list = new ArrayList<GoodsClass>();
        list.add(new GoodsClass(1L, "精选"));
        list.add(new GoodsClass(2L, "电器"));
        list.add(new GoodsClass(3L, "数码"));
        list.add(new GoodsClass(4L, "手机"));
        list.add(new GoodsClass(5L, "生鲜"));
        list.add(new GoodsClass(6L, "服饰"));
        list.add(new GoodsClass(7L, "母婴"));
        list.add(new GoodsClass(8L, "图书"));
        list.add(new GoodsClass(9L, "厨具"));
        list.add(new GoodsClass(10L, "食品"));
        list.add(new GoodsClass(11L, "美妆"));
        list.add(new GoodsClass(12L, "百货"));
        list.add(new GoodsClass(13L, "鞋靴"));
        list.add(new GoodsClass(14L, "运动"));
        list.add(new GoodsClass(15L, "箱包"));
        list.add(new GoodsClass(16L, "宠物"));
        list.add(new GoodsClass(17L, "家居"));
        list.add(new GoodsClass(18L, "汽车"));
        return list;
    }
    @Override
    @Transactional
    public JDSearchResult specialSearch(Integer page, Long cid) throws JDGoodsException{
        if (cid == null) {
            throw new JDGoodsException(1, "分类id为空");
        }
        String jdcid = cidMap.get(cid);
        if (StringUtil.isNullOrEmpty(jdcid)) {
            throw new JDGoodsException(1, "分类id不存在");
        }
        Long jdCid1 = null;
        Integer categoryId = null;
        long totalCount = (long) (page * Constant.PAGE_SIZE);
        if (jdcid.contains(",")) {
            String[] arrayId = jdcid.split(",");
            for (int i = 0; i < arrayId.length; i++) {
                Long count = countMap.get(cid + "" + arrayId[i]);
                if (count != null && totalCount > count) {
                    continue; // 当前分类商品不足
                } else {
                    jdCid1 =  Long.parseLong(jdcid);
                    categoryId = Integer.parseInt(jdcid);
                }
            }
        } else {
            jdCid1 =  Long.parseLong(jdcid);
            categoryId = Integer.parseInt(jdcid);
        }
        // 搜索
        JDSearchResult result = null;
        String way = configService.get("jd_api_search_key");
        if ("1".equals(way)) { // API搜索
            JDFilter filterAPI = new JDFilter();
            filterAPI.setPageIndex(page);
            filterAPI.setPageSize(Constant.PAGE_SIZE);
            filterAPI.setCid1(jdCid1);
            result = JDApiUtil.queryByKey(filterAPI);
        } else { // 网页爬取
            JDSearchFilter jdfilter = new JDSearchFilter();
            jdfilter.setPageNo(page);
            jdfilter.setPageSize(Constant.PAGE_SIZE);
            jdfilter.setCategoryId(categoryId);
            result = JDUtil.searchByKey(jdfilter);
        }
        long count = 0;
        if (result != null) {
            PageEntity pageEntity = result.getPageEntity();
            if (pageEntity != null) {
                count = pageEntity.getTotalCount();
            }
        }
        countMap.put(cid + "" + jdCid1, count);
        return result;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1155,10 +1155,14 @@
    @Override
    public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState)
    public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState, Integer sourceType)
            throws CommonOrderException {
        CommonOrderVO commonOrderVO = commonOrderMapper.getCommonOrderByOrderNo(uid, orderNo, orderState);
        if (sourceType == null) {
            sourceType = Constant.SOURCE_TYPE_TAOBAO;
        }
        CommonOrderVO commonOrderVO = commonOrderMapper.getCommonOrderByOrderNo(uid, orderNo, orderState, sourceType);
        // 订单信息为空
        if (commonOrderVO == null) {
            return null;
@@ -1183,13 +1187,13 @@
            }
            String orderNo1 = commonOrder.getOrderNo();
            Integer sourceType = commonOrder.getSourceType();
            Integer sourceType1 = commonOrder.getSourceType();
            String orderNo2 = commonOrderVO.getOrderNo();
            Integer sourceType2 = commonOrderVO.getSourceType();
            // 来源、订单号相同
            if (sourceType.equals(sourceType2) && orderNo1.equals(orderNo2)) {
            if (sourceType1.equals(sourceType2) && orderNo1.equals(orderNo2)) {
                // 加入商品信息
                List<CommonOrderGoodsVO> listOrderGoods = commonOrderVO.getListOrderGoods();
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -609,7 +609,7 @@
    @Transactional
    @Override
    public void useGoodsCoupon(Long uid, Long id, Long goodId) throws UserSystemCouponException, Exception {
    public void useGoodsCoupon(Long uid, Long id, Long goodId, Integer sourceType) throws UserSystemCouponException, Exception {
        if (uid == null) {
            throw new UserSystemCouponException(1, "用户未登录");
        }
@@ -660,7 +660,7 @@
        // 插入使用券记录
        UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
        couponRecord.setGoodId(goodId);
        couponRecord.setGoodSource(Constant.SOURCE_TYPE_TAOBAO); // 默认淘宝
        couponRecord.setGoodSource(sourceType); // 默认淘宝
        couponRecord.setState(UserSystemCouponRecord.STATE_WAIT); // 正在匹配
        couponRecord.setUserSystemCoupon(userSystemCoupon);
        couponRecord.setCouponType(baseCoupon.getType().name());
@@ -684,12 +684,16 @@
    @Transactional
    @Override
    public void useOrderCoupon(Long uid, Long id, String orderNo, Integer goodsType) throws UserSystemCouponException, Exception {
    public void useOrderCoupon(Long uid, Long id, String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
        if (id == null) {
            throw new UserSystemCouponException(1, "券id不存在");
        }
        if (sourceType == null) {
            sourceType = Constant.SOURCE_TYPE_TAOBAO;
        }
        // 用户券
        UserSystemCoupon userSystemCoupon = selectByPrimaryKey(id);
        if (userSystemCoupon == null) {
@@ -724,7 +728,7 @@
        }
        // 订单
        CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS);
        CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS, sourceType);
        if (orderVO == null) {
            throw new UserSystemCouponException(1, "订单信息获取失败");
        }
@@ -738,7 +742,7 @@
        // 条件: A:必须是返利订单 、B:必须已经处于已到账状态
        if (HongBaoV2.TYPE_ZIGOU == hongBaoType && HongBaoV2.STATE_YILINGQU == hongBaoState || hongBao != null) {
            Order order = orderService.findOrderByOrderIdAndType(orderNo, goodsType);
            Order order = orderService.findOrderByOrderIdAndType(orderNo, sourceType);
            if (order == null)
                return;
@@ -766,14 +770,14 @@
            // 2.插入关联
            orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
            // 3.插入资金明细,用户余额 // TODO
            UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo,goodsType, money,
            // 3.插入资金明细,用户余额
            UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo, sourceType, money,
                    new UserInfo(uid));
            userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
            userInfoService.addMoney(new UserInfo(uid), money);
            // 插入资金通知
            userMoneyMsgNotificationService.orderReward(uid, orderNo,goodsType, money,
            userMoneyMsgNotificationService.orderReward(uid, orderNo, sourceType, money,
                    userInfoService.selectByPKey(uid).getMyHongBao());
            /* 用户券信息状态及记录处理 */
@@ -788,7 +792,7 @@
            // 插入使用券记录
            UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
            couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
            couponRecord.setGoodSource(goodsType);
            couponRecord.setGoodSource(sourceType);
            couponRecord.setOrderNo(orderNo);
            couponRecord.setUserSystemCoupon(userSystemCoupon);
            couponRecord.setCouponType(systemCoupon.getType().name());
@@ -807,7 +811,7 @@
    }
    @Override
    public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
    public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
        if (orderNo == null || orderNo.trim().length() == 0) {
            throw new UserSystemCouponException(1, "订单号不存在");
@@ -843,7 +847,7 @@
        Long uid = userSystemCoupon.getUid();
        CommonOrderVO commonOrderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo,
                CommonOrder.STATE_JS);
                CommonOrder.STATE_JS, sourceType);
        if (commonOrderVO == null) {
            throw new UserSystemCouponException(1, "订单信息获取失败");
@@ -885,7 +889,7 @@
    }
    @Override
    public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
    public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
        if (orderNo == null || orderNo.trim().length() == 0) {
            throw new UserSystemCouponException(1, "订单号不存在");
@@ -913,7 +917,7 @@
        }
        // 订单
        CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null);
        CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null, sourceType);
        if (orderVO == null) {
            throw new UserSystemCouponException(1, "订单信息获取失败");
        }
fanli/src/main/java/com/yeshi/fanli/service/inter/jd/JDGoodsService.java
New file
@@ -0,0 +1,28 @@
package com.yeshi.fanli.service.inter.jd;
import java.util.List;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.exception.jd.JDGoodsException;
public interface JDGoodsService {
    /**
     * 专题分类
     * @return
     */
    public List<GoodsClass> getSpecialClass();
    /**
     * 专题商品搜索
     * @param page
     * @param cid
     * @return
     * @throws JDGoodsException
     */
    public JDSearchResult specialSearch(Integer page, Long cid) throws JDGoodsException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -233,7 +233,7 @@
     * @return
     * @throws CommonOrderException
     */
    public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState)
    public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState, Integer sourceType)
            throws CommonOrderException;
    /**
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -80,7 +80,7 @@
     * @throws UserSystemCouponException
     * @throws Exception
     */
    public void useGoodsCoupon(Long uid, Long id, Long goodId) throws UserSystemCouponException, Exception;
    public void useGoodsCoupon(Long uid, Long id, Long goodId, Integer sourceType) throws UserSystemCouponException, Exception;
    
    
    /**
@@ -90,7 +90,7 @@
     * @throws UserSystemCouponException
     * @throws Exception
     */
    public void useOrderCoupon(Long uid, Long id, String orderNo, Integer goodsType) throws UserSystemCouponException, Exception;
    public void useOrderCoupon(Long uid, Long id, String orderNo, Integer sourceType) throws UserSystemCouponException, Exception;
    /**
     * 根据订单号获取奖励券使用进度
@@ -99,7 +99,7 @@
     * @throws UserSystemCouponException
     * @throws Exception
     */
    public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo) throws UserSystemCouponException, Exception;
    public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception;
    /**
     * 是否存在奖励券
@@ -115,7 +115,7 @@
     * @throws UserSystemCouponException
     * @throws Exception
     */
    public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo) throws UserSystemCouponException, Exception;
    public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception;
    /**
     * 根据订单来源查询
fanli/src/main/java/com/yeshi/fanli/util/StringUtil.java
@@ -303,6 +303,21 @@
            str = str.substring(0, str.length() - sperator.length());
        return str;
    }
    public static String concat(Object[] array, String sperator) {
        if (array == null)
            return null;
        String str = "";
        for (int i = 0; i < array.length; i++) {
            str += array[i] + sperator;
        }
        if (str.endsWith(sperator))
            str = str.substring(0, str.length() - sperator.length());
        return str;
    }
    /**
     * 淘口令提取
fanli/src/main/java/com/yeshi/fanli/util/cache/JDGoodsCacheUtil.java
@@ -7,14 +7,10 @@
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;
import com.yeshi.fanli.util.jd.JDUtil;
@Component
public class JDGoodsCacheUtil {
@@ -48,10 +44,12 @@
            return JsonUtil.getSimpleGson().fromJson(value, JDGoods.class);
        }
        
        JDGoods goods = JDApiUtil.queryGoodsDetail(goodsId);
        JDGoods goods = JDApiUtil.queryGoodsDetail(goodsId); // 高级接口
        if (goods == null) {
            goods = JDApiUtil.getGoodsDetail(goodsId);
            goods = JDUtil.getGoodsDetail(goodsId); // 爬取网页
            //jdGoods = JDApiUtil.getGoodsDetail(goodsId); // 普通接口
        }
        // 缓存20分钟
        if (goods != null) {
            redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(goods), 60 * 20);
fanli/src/main/java/com/yeshi/fanli/util/cache/PinDuoDuoCacheUtil.java
@@ -7,11 +7,8 @@
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
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java
@@ -2,6 +2,8 @@
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONObject;
import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
import com.yeshi.fanli.dto.jd.JDCommissionInfo;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.jd.JDShopInfo;
@@ -109,6 +111,12 @@
        
        cg.setState(CommonGoods.STATE_NORMAL);
        
        // 其他信息
        GoodsOtherInfoDTO other = new GoodsOtherInfoDTO();
        other.setOwner(owner); // 是否自营
        other.setPinGouInfo( goods.getPinGouInfo());  // 拼购信息
        cg.setOtherInfo(JSONObject.toJSON(other).toString());
        // 保留字段
        cg.setVideoCover(null);
        cg.setVideoUrl(null);
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -9,7 +9,9 @@
import org.yeshi.utils.taobao.TbImgUtil;
import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.jd.JDShopInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.CommonGoods;
@@ -31,6 +33,8 @@
import com.yeshi.fanli.vo.goods.MoneyInfoVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import net.sf.json.JSONObject;
/**
 * 商品加工
@@ -57,10 +61,13 @@
        Integer shopType = goods.getShopType();
        if (shopType == null) { 
            goodsInfo.setShopType(10); // 淘宝
            goodsInfo.setPriceName("淘宝价");
        } else if (shopType == 1) {
            goodsInfo.setShopType(10); // 淘宝
            goodsInfo.setPriceName("淘宝价");
        } else if (shopType == 2) {
            goodsInfo.setShopType(11); // 天猫
            goodsInfo.setPriceName("天猫价");
        } else {
            goodsInfo.setShopType(goods.getShopType());
        }
@@ -70,8 +77,37 @@
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
        }
        
        if (goodsType == Constant.SOURCE_TYPE_PDD) {
        GoodsOtherInfoDTO otherDTO = null;
        String otherInfo = goods.getOtherInfo();
        if (!StringUtil.isNullOrEmpty(otherInfo)) {
            JSONObject json = JSONObject.fromObject(otherInfo);
            otherDTO = (GoodsOtherInfoDTO)JSONObject.toBean(json,GoodsOtherInfoDTO.class);
        }
        if (goodsType == Constant.SOURCE_TYPE_JD) {
            // 月销量
            goodsInfo.setSalesType(1);
            // 自营
            String owner = otherDTO.getOwner();
            if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
                List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>();
                ClientTextStyleVO  textStyleVO = new ClientTextStyleVO();
                textStyleVO.setContent("京东自营");
                textStyleVO.setColor("#E42219");
                labels.add(textStyleVO);
                goodsInfo.setLabels(labels);
            }
            // 拼团价
            JDPingouInfo pinGouInfo = otherDTO.getPinGouInfo();
            if (pinGouInfo != null) {
                goods.setPrice(pinGouInfo.getPingouPrice());
                goodsInfo.setPriceName("拼购价");
            } else {
                goodsInfo.setPriceName("京东价");
            }
        } else if (goodsType == Constant.SOURCE_TYPE_PDD){
            goodsInfo.setSalesType(4); // 总销量
            goodsInfo.setPriceName("拼团价");
        } else {
            goodsInfo.setSalesType(1); // 月销量
        }
@@ -91,7 +127,6 @@
        } else {
            goodsInfo.setPicUrl(goods.getPicture());
        }
        // 资金信息
        MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
@@ -158,8 +193,10 @@
        Integer shopType = goods.getUserType();
        if (shopType != null && shopType == 1) {
            goodsInfo.setShopType(11); // 天猫
            goodsInfo.setPriceName("天猫价");
        } else {
            goodsInfo.setShopType(10); // 淘宝
            goodsInfo.setPriceName("淘宝价");
        }
        // 资金信息
@@ -254,8 +291,10 @@
        Integer shopType = goods.getUserType();
        if (shopType != null && shopType == 1) {
            goodsInfo.setShopType(11); // 天猫
            goodsInfo.setPriceName("天猫价");
        } else {
            goodsInfo.setShopType(10); // 淘宝
            goodsInfo.setPriceName("淘宝价");
        }
        // 资金信息
@@ -321,7 +360,6 @@
        goodsInfo.setTitle(goods.getSkuName());
        goodsInfo.setSalesType(1); // 默认月销量
        goodsInfo.setPicUrl(goods.getPicUrl());
        goodsInfo.setZkPrice(goods.getPrice());
        goodsInfo.setImgList(goods.getImageList());
        goodsInfo.setState(0);
        goodsInfo.setShopType(20); // 京东
@@ -336,7 +374,17 @@
            salesCountMidea = salesCountMidea + "万";
        }
        goodsInfo.setSalesCount(salesCountMidea);
        JDPingouInfo pinGouInfo = goods.getPinGouInfo();
        if (pinGouInfo != null) {
            goodsInfo.setZkPrice(pinGouInfo.getPingouPrice());
            goodsInfo.setPriceName("拼购价");
        } else {
            goodsInfo.setZkPrice(goods.getPrice());
            goodsInfo.setPriceName("京东价");
        }
        
        // 资金信息
        MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
@@ -345,33 +393,34 @@
        moneyInfoVO.setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(goods, shareRate));
        goodsInfo.setMoneyInfo(moneyInfoVO);
        JDCouponInfo couponInfo = goods.getCouponInfo();
        if (couponInfo != null) {
            BigDecimal discount = couponInfo.getDiscount();
            BigDecimal price = goods.getPrice();
            // 计算券后价
            BigDecimal sub = price.subtract(couponInfo.getQuota());
            if (sub.compareTo(BigDecimal.valueOf(0)) >= 0) {
                BigDecimal quanPrice = MoneyBigDecimalUtil.sub(price, discount);
                goodsInfo.setCouponPrice(quanPrice);
            } else {
                goodsInfo.setCouponPrice(price);
            }
            goodsInfo.setCouponPrice(JDUtil.getQuanPrice(goods));
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
            CouponInfoVO coupon = new CouponInfoVO();
            coupon.setAmount(discount);
            if (couponInfo.getGetStartTime() != null) {
                coupon.setStartTime(sdf.format(new Date(couponInfo.getGetStartTime())));
            } else {
                coupon.setStartTime(sdf.format(new Date()));
            }
             int ran2 = (int) (Math.random()*(5) + 1 );
             if (ran2 > 3) {
                 if (couponInfo.getGetStartTime() != null) {
                        coupon.setStartTime(sdf.format(new Date(couponInfo.getGetStartTime())));
                    } else {
                        coupon.setStartTime(sdf.format(new Date()));
                    }
            if (couponInfo.getGetEndTime() != null) {
                coupon.setEndTime(sdf.format(new Date(couponInfo.getGetEndTime())));
            } else {
                coupon.setEndTime(sdf.format(new Date()));
            }
                    if (couponInfo.getGetEndTime() != null) {
                        coupon.setEndTime(sdf.format(new Date(couponInfo.getGetEndTime())));
                    } else {
                        coupon.setEndTime(sdf.format(new Date()));
                    }
             }
            
            // TODO
//            coupon.setLeftCount(leftCount);
@@ -384,16 +433,6 @@
            goodsInfo.setCouponInfo(coupon);
        }
        // 店铺信息
        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);
        }
        // 京东自营标签
        String owner = goods.getOwner();
        if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
@@ -404,7 +443,20 @@
            labels.add(textStyleVO);
            goodsInfo.setLabels(labels);
        }
        // 店铺信息
        JDShopInfo shopInfo = goods.getShopInfo();
        if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) {
            ShopInfoVO shop = new ShopInfoVO();
            shop.setShopName(shopInfo.getShopName());
            shop.setId(shopInfo.getShopId().toString());
            if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) {
                shop.setUserType(20);
            } else {
                shop.setUserType(21);
            }
            goodsInfo.setShopInfo(shop);
        }
        return goodsInfo;
    }
@@ -423,6 +475,7 @@
        goodsInfo.setGoodsId(goods.getGoodsId());
        goodsInfo.setTitle(goods.getGoodsName());
        goodsInfo.setSalesType(4); // 总销量
        goodsInfo.setPriceName("拼团价");
        goodsInfo.setPicUrl(goods.getGoodsThumbnailUrl()); // 缩略图
        goodsInfo.setZkPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2));
        goodsInfo.setShopType(30); // 拼多多
@@ -471,13 +524,20 @@
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
            CouponInfoVO coupon = new CouponInfoVO();
            coupon.setAmount(amount);
            if (goods.getCouponStartTime() != null) {
                coupon.setStartTime(sdf.format(new Date(goods.getCouponStartTime() * 1000)));
            }
            int ran2 = (int) (Math.random()*(5) + 1 );
            if (ran2 > 3) {
                if (goods.getCouponStartTime() != null) {
                    coupon.setStartTime(sdf.format(new Date(goods.getCouponStartTime() * 1000)));
                }
            if (goods.getCouponEndTime() != null) {
                coupon.setEndTime(sdf.format(new Date(goods.getCouponEndTime() * 1000)));
            }
                if (goods.getCouponEndTime() != null) {
                    coupon.setEndTime(sdf.format(new Date(goods.getCouponEndTime() * 1000)));
                }
            }
            coupon.setLink(null);
            coupon.setStartFee(startFree);
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -421,6 +421,7 @@
                jdPinGouInfo.setTotalCount(pinGouInfoJson.optLong("totalCount"));
                jdPinGouInfo.setPingouEndTime(pinGouInfoJson.optLong("pingouEndTime"));
                jdPinGouInfo.setPingouStartTime(pinGouInfoJson.optLong("pingouStartTime"));
                goods.setPinGouInfo(jdPinGouInfo);
            }
        }
        
@@ -543,6 +544,48 @@
        searchResult.setGoodsList(list);
        return searchResult;
    }
    public static JDSearchResult getGoodsClass() {
        JDSearchResult searchResult = new JDSearchResult();
        List<JDGoods> list = new ArrayList<>();
        JSONObject json = new JSONObject();
        json.put("parentId", 0);
        json.put("grade", 0);
        JSONObject jsonDTO = new JSONObject();
        jsonDTO.put("req", json);
        String result = baseRequest2("jd.union.open.category.goods.get", null, jsonDTO);
        System.out.println(result);
        JSONObject resultJson = JSONObject.fromObject(result);
        resultJson = resultJson.optJSONObject("jd_union_open_goods_jingfen_query_response");
        if (resultJson.optInt("code") == 0) {
            result = resultJson.optString("result");
            resultJson = JSONObject.fromObject(result);
            String message = resultJson.optString("message");
            if ("SUCCESS".equalsIgnoreCase(message)) {
                JSONArray array = resultJson.optJSONArray("data");
                if (array != null) {
                    for (int i = 0; i < array.size(); i++) {
                        JDGoods goods = parseJDGoods(array.optJSONObject(i));
                        if (goods != null)
                            list.add(goods);
                    }
                }
            }
            long totalCount = resultJson.optLong("totalCount");
            PageEntity pageEntity = new PageEntity();
            pageEntity.setTotalCount(totalCount);
            searchResult.setPageEntity(pageEntity);
        }
        searchResult.setGoodsList(list);
        return searchResult;
    }
    public static JDGoods getGoodsDetail(Long skuId) {
        List<Long> skuIdList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.dto.jd.JDCommissionInfo;
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.jd.JDSearchFilter;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.jd.JDShopInfo;
@@ -100,6 +101,12 @@
        System.out.println(result);
    }
    /**
     * 搜索网页
     * @param searchFilter
     * @return
     */
    @SuppressWarnings("deprecation")
    public static JDSearchResult searchByKey(JDSearchFilter searchFilter) {
@@ -180,16 +187,69 @@
                        }
                    }
                }
                json.optJSONObject("data").optJSONArray("unionGoods");
            }
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        searchResult.setGoodsList(goodsList);
        return searchResult;
    }
    /**
     * 搜索网页
     * @param searchFilter
     * @return
     */
    @SuppressWarnings("deprecation")
    public static List<JDGoods> getRecommendGoodsById(Long skuId) {
        List<JDGoods> goodsList = new ArrayList<>();
        JSONObject params = new JSONObject();
        params.put("pageNo", 1);
        params.put("pageSize", 60);
        params.put("searchUUID", StringUtil.Md5(System.currentTimeMillis() + ""));
        JSONObject data = new JSONObject();
        data.put("lock", "0");
        data.put("deliveryType", 0);
        data.put("hasCoupon",0);
        data.put("isCare", 0);
        data.put("isPinGou", 0);
        data.put("isZY", 0);
        data.put("orientationFlag", 0);
        data.put("key", skuId);
        data.put("keywordType", "kt0");
        data.put("searchType", "st2");
        params.put("data", data);
        HttpClient client = new HttpClient();
        PostMethod pm = new PostMethod("https://union.jd.com/api/goods/search");
        pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
        pm.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
        pm.setRequestHeader("Referer", "https://union.jd.com/proManager/index?pageNo=1&keywords=%E9%9E%8B%E5%AD%90");
        pm.setRequestBody(params.toString());
        try {
            client.executeMethod(pm);
            String result = pm.getResponseBodyAsString();
            JSONObject json = JSONObject.fromObject(result);
            if (json.optInt("code") == 200) {
                if (json.optJSONObject("data") != null) {
                    JSONArray array = json.optJSONObject("data").optJSONArray("unionRecommendGoods");
                    if (array != null) {
                        for (int i = 0; i < array.size(); i++) {
                            goodsList.add(parseGoods(array.optJSONArray(i).optJSONObject(0).toString()));
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return goodsList;
    }
    public static JDGoods getGoodsDetail(Long skuId) {
@@ -235,17 +295,24 @@
        goods.setCommissionInfo(commission);
        goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
        // 券信息
        if (json.optString("hasCoupon") != null && json.optInt("hasCoupon") == 1
                && json.optInt("couponRemainCnt") > 0) {
            // 有券
            JDCouponInfo coupon = new JDCouponInfo();
            coupon.setDiscount(new BigDecimal(json.optString("couponDiscount")));
            coupon.setQuota(new BigDecimal(json.optString("couponQuota")));
            coupon.setLink("https:" + json.optString("couponLink"));
            goods.setCouponInfo(coupon);
        } else {
            // 无券
        }
        }
        // 团购信息
        if (json.optString("isPinGou") != null && json.optInt("isPinGou") == 1) {
            JDPingouInfo jdPinGouInfo = new JDPingouInfo();
            jdPinGouInfo.setPingouPrice(new BigDecimal(json.optString("pingouPrice")));
            jdPinGouInfo.setPingouTmCount(json.optLong("pingouTmCount"));
            goods.setPinGouInfo(jdPinGouInfo);
        }
        return goods;
    }
    
@@ -264,13 +331,20 @@
            return money;
        }
        
        BigDecimal price = null;
        JDPingouInfo pinGouInfo = goods.getPinGouInfo();
        if (pinGouInfo == null) {
             price =  goods.getPrice();
        } else {
             price =  pinGouInfo.getPingouPrice();
        }
        JDCouponInfo couponInfo = goods.getCouponInfo();
        if (couponInfo == null) {
            // 佣金
            BigDecimal commission = commissionInfo.getCommission();
            return MoneyBigDecimalUtil.mul(commission, MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
            money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
                    MoneyBigDecimalUtil.mul(price,commissionInfo.getCommissionShare()),
                    new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
        } else {
            BigDecimal price = goods.getPrice();
            BigDecimal quota = couponInfo.getQuota();
            BigDecimal discount = couponInfo.getDiscount();
            if (quota.compareTo(price) <= 0 && price.compareTo(discount) > 0) {
@@ -304,7 +378,13 @@
        } 
        
        BigDecimal discount = couponInfo.getDiscount();
        BigDecimal price = jdGoods.getPrice();
        BigDecimal price = null;
        JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
        if (pinGouInfo == null) {
             price =  jdGoods.getPrice();
        } else {
             price =  pinGouInfo.getPingouPrice();
        }
        // 计算券后价
        BigDecimal sub = price.subtract(couponInfo.getQuota());
        if (sub.compareTo(BigDecimal.valueOf(0)) >= 0) {
@@ -333,6 +413,11 @@
        return salesCountMidea;
    }
    
    /**
     * 搜索候选词
     * @param key
     * @return
     */
    public static List<String> suggestSearch(String key) {
        List<String> list = new ArrayList<>();
        if (StringUtil.isNullOrEmpty(key))
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -86,8 +86,9 @@
        if (sf.getKw() != null)
            map.put("keyword", sf.getKw());
        if (sf.getGoodsIdList() != null)
            map.put("goods_id_list", sf.getGoodsIdList().toString());
            map.put("goods_id_list", "[" + StringUtil.concat(sf.getGoodsIdList(), ",") + "]");
        
        System.out.println(sf.getGoodsIdList().toString());
        
        map.put("pid", PID_FANLI);
        String result = baseRequest(map);
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java
@@ -10,6 +10,8 @@
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
@@ -122,7 +124,47 @@
        return imgList;
    }
    public static List<Long> getRecommendGoodsId(Long id) {
        List<Long> list = new ArrayList<Long>();
            JSONObject params = new JSONObject();
            params.put("pageNo", 1);
            params.put("show_tags", 1);
            params.put("goods_id", id);
            params.put("app_name", "goods_detail");
            params.put("list_id", "goods_detail_HgfiMc");
            params.put("pdduid", StringUtil.Md5(System.currentTimeMillis() + ""));
            HttpClient client = new HttpClient();
            PostMethod pm = new PostMethod("https://mobile.yangkeduo.com/proxy/api/api/tesla/query");
            pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
            pm.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
            pm.setRequestHeader("Referer", "https://union.jd.com/proManager/index?pageNo=1&keywords=%E9%9E%8B%E5%AD%90");
            pm.setRequestBody(params.toString());
            try {
                client.executeMethod(pm);
                String result = pm.getResponseBodyAsString();
                JSONObject json = JSONObject.fromObject(result);
                JSONArray array = json.optJSONArray("data");
                if (array != null) {
                    for (int i = 0; i < array.size(); i++) {
                        list.add(array.optJSONObject(i).optLong("goods_id"));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        return list;
    }
    /**
     * 搜索候选词
     * @param key
     * @return
     */
    public static List<String> suggestSearch(String key) {
        List<String> list = new ArrayList<>();
        if (StringUtil.isNullOrEmpty(key))
fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsDetailVO.java
@@ -39,6 +39,8 @@
    @Expose
    private BigDecimal couponPrice;// 券后价
    @Expose
    private String priceName;// 价格名称
    @Expose
    private String picUrl;// 图片链接
    @Expose
    private List<String> imgList;
@@ -231,6 +233,13 @@
    public void setId(Long id) {
        this.id = id;
    }
    }
    public String getPriceName() {
        return priceName;
    }
    public void setPriceName(String priceName) {
        this.priceName = priceName;
    }
}