admin
2021-04-30 4e4af90184f5fa5b40d87e2d08d9192bfd237ef0
拼多多备案,京东、拼多多,唯品会,苏宁支持小程序跳转
1 文件已重命名
6个文件已修改
1个文件已添加
1453 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 119 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java 682 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java 492 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsJumpLinkVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/suning/SuningConvertLinkResult.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
@@ -19,6 +19,7 @@
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.util.GsonUtil;
import com.yeshi.fanli.util.StringUtil;
@@ -148,9 +149,6 @@
    private UserInfoService userInfoService;
    @Resource
    private OrderService orderService;
    @Resource
    private BindingAccountService bindingAccountService;
    @Resource
@@ -162,8 +160,6 @@
    @Resource
    private BusinessSystemService businessSystemService;
    @Resource
    private ShamUserService shamUserService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
@@ -177,8 +173,6 @@
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserAccountService loginService;
    @Resource
    private RedisManager redisManager;
@@ -219,8 +213,6 @@
    @Resource
    private AppVersionService appVersionService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private AccountMessageService accountMessageService;
@@ -236,12 +228,6 @@
    @Resource
    private BindRemindService bindRemindService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private UserRankService userRankService;
    @Resource
    private UserVIPInfoService userVIPInfoService;
@@ -269,6 +255,9 @@
    @Resource
    private PreviewInfoService previewInfoService;
    @Resource
    private PDDAuthService pddAuthService;
    private static final String EXTRACT_MIN_MONEY = ConfigKeyEnum.extractMoneyMin.getKey();
    private static final String EXTRACT_MAX_MONEY = ConfigKeyEnum.extractMoneyMAX.getKey();
@@ -2285,8 +2274,8 @@
            data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
            //拼多多是否绑定
            if (VersionUtil.greaterThan_2_1_5(acceptData.getPlatform(), acceptData.getVersion())) {
                boolean pddBuyBind = PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_FANLI, PinDuoDuoUtil.getCustomParams(uid));
                boolean pddShareBind = PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, PinDuoDuoUtil.getCustomParams(uid));
                boolean pddBuyBind = PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_FANLI, pddAuthService.getFanliCustomParams(uid));
                boolean pddShareBind = PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, pddAuthService.getFanliCustomParams(uid));
                data.put("pddBuyBind", pddBuyBind);
                data.put("pddShareBind", pddShareBind);
            }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -1,7 +1,10 @@
package com.yeshi.fanli.controller.client.v2;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -17,7 +20,8 @@
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO;
import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO;
import com.yeshi.fanli.vo.pdd.PDDJumpLinkVO;
import com.yeshi.fanli.vo.goods.GoodsJumpLinkVO;
import com.yeshi.fanli.vo.suning.SuningConvertLinkResult;
import org.json.simple.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -31,7 +35,6 @@
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.PDDPromotionUrl;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
import com.yeshi.fanli.dto.suning.SuningGoodsInfoRecommend;
@@ -71,23 +74,18 @@
import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.jd.JDGoodsClassService;
import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TLJFreeBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
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.integral.IntegralGetService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
@@ -1680,9 +1678,21 @@
            }
        }
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();
        vo.set_native(true);
        vo.setJumpLink(jumpLink);
        vo.setNativeJumpLink(jumpLink);
        try {
            String wxPage = "pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jumpLink, "UTF-8");
            WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO();
            wxxcxJumpInfoVO.setUserName("gh_45b306365c3d");
            wxxcxJumpInfoVO.setPath(wxPage);
            vo.setWxxcxJumpInfo(wxxcxJumpInfoVO);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        out.print(JsonUtil.loadTrueResult(data));
    }
@@ -1749,9 +1759,22 @@
            }
        }
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", jumpLink);
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();
        vo.set_native(true);
        vo.setJumpLink(jumpLink);
        vo.setNativeJumpLink(jumpLink);
        try {
            String wxPage = "pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jumpLink, "UTF-8");
            WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO();
            wxxcxJumpInfoVO.setUserName("gh_45b306365c3d");
            wxxcxJumpInfoVO.setPath(wxPage);
            vo.setWxxcxJumpInfo(wxxcxJumpInfoVO);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
@@ -1837,7 +1860,7 @@
            LogHelper.test(String.format("拼多多转链:uid:%s data:%s", uid + "", data.toString()));
        }
        PDDJumpLinkVO vo = new PDDJumpLinkVO();
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();
        vo.set_native(true);
        vo.setNativeJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
        vo.setJumpLink(convertUrl.getUrl());
@@ -1856,7 +1879,7 @@
    }
    /**
     * 拼多多购买链接
     * 唯品会购买链接
     *
     * @param acceptData
     * @param uid
@@ -1897,12 +1920,21 @@
        }
        VIPConvertResultDTO convertUrl = VipShopApiUtil.convertLink(id + "", tag);
        JSONObject data = new JSONObject();
        data.put("native", true);
        data.put("jumpLink", convertUrl.getUrl());
        data.put("nativeJumpLink", convertUrl.getDeeplinkUrl());
        out.print(JsonUtil.loadTrueResult(data));
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();
        vo.set_native(true);
        vo.setJumpLink(convertUrl.getUrl());
        vo.setNativeJumpLink(convertUrl.getDeeplinkUrl());
        if (!StringUtil.isNullOrEmpty(convertUrl.getVipWxUrl())) {
            WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO();
            wxxcxJumpInfoVO.setUserName("gh_8ed2afad9972");
            wxxcxJumpInfoVO.setPath(convertUrl.getVipWxUrl());
            vo.setWxxcxJumpInfo(wxxcxJumpInfoVO);
        }
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
    }
@@ -1944,12 +1976,31 @@
        String quanUrl = null;
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl()))
            quanUrl = goods.getCouponInfo().getCouponUrl();
        String link = SuningApiUtil.convertLink(SuningUtil.getProductUrl(supplierCode, goodsCode), quanUrl,
        SuningConvertLinkResult link = SuningApiUtil.convertLinkNew(goodsCode, supplierCode,
                pid, uid + "");
        JSONObject data = new JSONObject();
        data.put("native", false);
        data.put("jumpLink", link);
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();
        vo.set_native(false);
        try {
            vo.setJumpLink(URLDecoder.decode(link.getWapExtendUrl(), "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        if (!StringUtil.isNullOrEmpty(link.getSpPageUrl())) {
            WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO();
            wxxcxJumpInfoVO.setUserName("gh_1d1e15e90afc");
            try {
                wxxcxJumpInfoVO.setPath(URLDecoder.decode(link.getSpPageUrl(), "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            vo.setWxxcxJumpInfo(wxxcxJumpInfoVO);
        }
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        out.print(JsonUtil.loadTrueResult(data));
        // 获得金币
        integralGetService.addCouponRebate(uid);
@@ -2135,8 +2186,24 @@
        link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, JDApiUtil.POSITION_FANLI + "", uid + "");
        JSONObject data = new JSONObject();
        data.put("link", link);
        GoodsJumpLinkVO vo = new GoodsJumpLinkVO();
        vo.set_native(true);
        vo.setJumpLink(link);
        vo.setNativeJumpLink(link);
        try {
            String wxPage = "pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(link, "UTF-8");
            WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO();
            wxxcxJumpInfoVO.setUserName("gh_45b306365c3d");
            wxxcxJumpInfoVO.setPath(wxPage);
            vo.setWxxcxJumpInfo(wxxcxJumpInfoVO);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        JSONObject data = JSONObject.fromObject(new Gson().toJson(vo));
        data.put("native", vo.is_native());
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java
@@ -6,11 +6,12 @@
import javax.annotation.Resource;
import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO;
import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO;
import com.yeshi.fanli.vo.pdd.PDDJumpLinkVO;
import com.yeshi.fanli.vo.goods.GoodsJumpLinkVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -50,25 +51,16 @@
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private DaTaoKeGoodsService daTaoKeGoodsService;
    @Resource
    private SwiperPictureService swiperPictureService;
    @Resource
    private QualityGoodsService qualityGoodsService;
    @Resource
    private SpecialService specialService;
    @Resource
    private PDDGoodsService pddGoodsService;
    @Resource
    private PDDAuthService pddAuthService;
    /**
@@ -144,9 +136,9 @@
            pid = PinDuoDuoApiUtil.PID_SHARE;
        }
        PDDConvertLinkResultVO authLink = PinDuoDuoApiUtil.getAuthLink(pid, PinDuoDuoUtil.getCustomParams(uid));
        PDDConvertLinkResultVO authLink = PinDuoDuoApiUtil.getAuthLink(pid, pddAuthService.getFanliCustomParams(uid));
        PDDJumpLinkVO pddJumpLinkVO = new PDDJumpLinkVO();
        GoodsJumpLinkVO pddJumpLinkVO = new GoodsJumpLinkVO();
        pddJumpLinkVO.set_native(true);
        pddJumpLinkVO.setJumpLink(authLink.getMobile_url());
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -12,6 +12,7 @@
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.util.StringUtil;
@@ -144,6 +145,9 @@
    @Resource
    private UserTaoLiJinRecordService userTaoLiJinRecordService;
    @Resource
    private PDDAuthService pddAuthService;
    private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode,
                                                                   BigDecimal fanliMoney) {
@@ -892,8 +896,14 @@
        //查询当前用户是否授权
        if (VersionUtil.greaterThan_2_1_5(acceptData.getPlatform(), acceptData.getVersion())) {
            if (!PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, PinDuoDuoUtil.getCustomParams(uid))) {
            if (!PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, pddAuthService.getFanliCustomParams(uid))) {
                JsonUtil.loadFalseResult(20001, "尚未备案,请先备案");
                return;
            }
        } else {
            if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2021-05-01", "yyyy-MM-dd") && !PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_SHARE, pddAuthService.getFanliCustomParams(uid))) {
                JsonUtil.loadFalseResult(20001, "请升级到最新版");
                return;
            }
        }
fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java
@@ -10,6 +10,7 @@
import java.util.List;
import java.util.Map;
import com.yeshi.fanli.vo.suning.SuningConvertLinkResult;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;
@@ -29,370 +30,397 @@
public class SuningApiUtil {
    public final static String APP_SECRET = "a217bc7018fd8ca112bb60f09057d996";
    public final static String APP_KEY = "6fca015e83eff7ef150bebcad418ea32";
    public final static String APP_SECRET = "a217bc7018fd8ca112bb60f09057d996";
    public final static String APP_KEY = "6fca015e83eff7ef150bebcad418ea32";
    public final static String PID_SHARE = "666527";
    public final static String PID_BUY = "666526";
    public final static String PID_COUPON = "666528";
    public final static String PID_SHARE = "666527";
    public final static String PID_BUY = "666526";
    public final static String PID_COUPON = "666528";
    private static String post(String url, String entity, Map<String, String> headers) {
        String charset = "utf-8";
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(url);
        method.addRequestHeader("Content-Type", "text/html;charset=" + charset);
        method.setRequestHeader("Content-Type", "text/html;charset=" + charset);
        method.setRequestBody(entity);
        for (Iterator<String> its = headers.keySet().iterator(); its.hasNext();) {
            String key = its.next();
            method.addRequestHeader(key, headers.get(key));
        }
    private static String post(String url, String entity, Map<String, String> headers) {
        String charset = "utf-8";
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(url);
        method.addRequestHeader("Content-Type", "text/html;charset=" + charset);
        method.setRequestHeader("Content-Type", "text/html;charset=" + charset);
        method.setRequestBody(entity);
        for (Iterator<String> its = headers.keySet().iterator(); its.hasNext(); ) {
            String key = its.next();
            method.addRequestHeader(key, headers.get(key));
        }
        try {
            client.executeMethod(method);
            return method.getResponseBodyAsString();
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
        try {
            client.executeMethod(method);
            return method.getResponseBodyAsString();
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
    private static String getSign(Map<String, String> baseParams, String resParams) {
        StringBuffer sb = new StringBuffer();
        try {
            sb.append(APP_SECRET);
            sb.append(baseParams.get("appMethod"));
            sb.append(baseParams.get("appRequestTime"));
            sb.append(baseParams.get("appKey"));
            sb.append(baseParams.get("versionNo"));
        } catch (Exception e) {
    private static String getSign(Map<String, String> baseParams, String resParams) {
        StringBuffer sb = new StringBuffer();
        try {
            sb.append(APP_SECRET);
            sb.append(baseParams.get("appMethod"));
            sb.append(baseParams.get("appRequestTime"));
            sb.append(baseParams.get("appKey"));
            sb.append(baseParams.get("versionNo"));
        } catch (Exception e) {
        }
        }
        try {
            sb.append(StringUtil.getBase64String(resParams));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sb.append(StringUtil.getBase64String(resParams));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return StringUtil.Md5(sb.toString());
    }
        return StringUtil.Md5(sb.toString());
    }
    private static String baseRequest(String method, JSONObject params) {
        Map<String, String> baseParams = new HashMap<>();
        baseParams.put("appMethod", method);
        baseParams.put("appRequestTime", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
        baseParams.put("format", "json");
        baseParams.put("appKey", APP_KEY);
        baseParams.put("versionNo", "v1.2");
        String sign = getSign(baseParams, params.toString());
        baseParams.put("signInfo", sign);
        String result = post("https://open.suning.com/api/http/sopRequest/" + method, params.toString(), baseParams);
        System.out.println(result);
        return result;
    }
    private static String baseRequest(String method, JSONObject params) {
        Map<String, String> baseParams = new HashMap<>();
        baseParams.put("appMethod", method);
        baseParams.put("appRequestTime", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
        baseParams.put("format", "json");
        baseParams.put("appKey", APP_KEY);
        baseParams.put("versionNo", "v1.2");
        String sign = getSign(baseParams, params.toString());
        baseParams.put("signInfo", sign);
        String result = post("https://open.suning.com/api/http/sopRequest/" + method, params.toString(), baseParams);
        System.out.println(result);
        return result;
    }
    private static String baseRequest(String method, String key, JSONObject params) {
        JSONObject keyJSON = new JSONObject();
        for (Iterator<String> its = params.keySet().iterator(); its.hasNext();) {
            String k = its.next();
            keyJSON.put(k, params.get(k));
        }
        JSONObject content = new JSONObject();
        content.put(key, keyJSON);
        JSONObject body = new JSONObject();
        body.put("sn_body", content);
        JSONObject request = new JSONObject();
        request.put("sn_request", body);
        return baseRequest(method, request);
    }
    private static String baseRequest(String method, String key, JSONObject params) {
        JSONObject keyJSON = new JSONObject();
        for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) {
            String k = its.next();
            keyJSON.put(k, params.get(k));
        }
        JSONObject content = new JSONObject();
        content.put(key, keyJSON);
        JSONObject body = new JSONObject();
        body.put("sn_body", content);
        JSONObject request = new JSONObject();
        request.put("sn_request", body);
        return baseRequest(method, request);
    }
    /**
     * 查询商品
     * @Title: searchGoods
     * @Description:
     * @param model
     * @return
     * List<SuningGoodsInfo> 返回类型
     * @throws
     */
    public static List<SuningGoodsInfo> searchGoods(SuningQueryModel model) {
        model.setPicWidth(320);
        model.setPicHeight(320);
        String key = "querySearchcommoditynew";
        String json = new Gson().toJson(model);
        // String result =
        // baseRequest("suning.netalliance.searchcommoditynew.query", key,
        // JSONObject.fromObject(json));
        String result = baseRequest("suning.netalliance.searchcommoditynew.query", key, JSONObject.fromObject(json));
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
                .optJSONArray("commodityList");
        if (array != null) {
            Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
            }.getType();
            List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
            return goodsList;
        }
    /**
     * 查询商品
     *
     * @param model
     * @return List<SuningGoodsInfo> 返回类型
     * @throws
     * @Title: searchGoods
     * @Description:
     */
    public static List<SuningGoodsInfo> searchGoods(SuningQueryModel model) {
        model.setPicWidth(320);
        model.setPicHeight(320);
        String key = "querySearchcommoditynew";
        String json = new Gson().toJson(model);
        // String result =
        // baseRequest("suning.netalliance.searchcommoditynew.query", key,
        // JSONObject.fromObject(json));
        String result = baseRequest("suning.netalliance.searchcommoditynew.query", key, JSONObject.fromObject(json));
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
                .optJSONArray("commodityList");
        if (array != null) {
            Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
            }.getType();
            List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
            return goodsList;
        }
        return null;
    }
        return null;
    }
    /**
     * 查询商品
     * @Title: searchGoods
     * @Description:
     * @param model
     * @return
     * List<SuningGoodsInfo> 返回类型
     * @throws
     */
    public static List<SuningGoodsInfo> searchGoodsOld(SuningQueryModel model) {
        model.setPicWidth(320);
        model.setPicHeight(320);
        String key = "querySearchcommodity";
        String json = new Gson().toJson(model);
        String result = baseRequest("suning.netalliance.searchcommodity.query", key, JSONObject.fromObject(json));
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONObject responseContent = resultJSON.optJSONObject("sn_responseContent");
        if (responseContent != null) {
            JSONObject snBody = responseContent.optJSONObject("sn_body");
            if (snBody != null) {
                JSONArray array = snBody.optJSONArray(key);
                if (array != null) {
                    Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
                    }.getType();
                    List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
                    return goodsList;
                }
            }
        }
        return null;
    }
    /**
     * 查询商品
     *
     * @param model
     * @return List<SuningGoodsInfo> 返回类型
     * @throws
     * @Title: searchGoods
     * @Description:
     */
    public static List<SuningGoodsInfo> searchGoodsOld(SuningQueryModel model) {
        model.setPicWidth(320);
        model.setPicHeight(320);
        String key = "querySearchcommodity";
        String json = new Gson().toJson(model);
        String result = baseRequest("suning.netalliance.searchcommodity.query", key, JSONObject.fromObject(json));
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONObject responseContent = resultJSON.optJSONObject("sn_responseContent");
        if (responseContent != null) {
            JSONObject snBody = responseContent.optJSONObject("sn_body");
            if (snBody != null) {
                JSONArray array = snBody.optJSONArray(key);
                if (array != null) {
                    Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
                    }.getType();
                    List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
                    return goodsList;
                }
            }
        }
        return null;
    }
    public static SuningGoodsInfo getGoodsDetail(String goodsCode, String supplierCode) {
        JSONObject model = new JSONObject();
        model.put("commodityStr", goodsCode + "-" +SuningUtil.getFullSupplierCode( supplierCode));
        model.put("picWidth", 600);
        model.put("picHeight", 600);
        model.put("couponMark", 1);
    public static SuningGoodsInfo getGoodsDetail(String goodsCode, String supplierCode) {
        JSONObject model = new JSONObject();
        model.put("commodityStr", goodsCode + "-" + SuningUtil.getFullSupplierCode(supplierCode));
        model.put("picWidth", 600);
        model.put("picHeight", 600);
        model.put("couponMark", 1);
        String key = "queryCommoditydetail";
        String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        if( resultJSON.optJSONObject("sn_responseContent")==null)
            return null;
        if(resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body")==null)
            return null;
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
        if (array != null && array.size() > 0) {
            return new Gson().fromJson(array.optJSONObject(0).toString(), SuningGoodsInfo.class);
        }
        return null;
    }
        String key = "queryCommoditydetail";
        String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
    /**
     * 查询关联商品
     * @Title: searchGoods
     * @Description:
     * @param model
     * @return
     * List<SuningGoodsInfo> 返回类型
     * @throws
     */
    public static List<SuningGoodsInfoRecommend> getRecommendGoods(String goodsCode, String supplierCode) {
        JSONObject model = new JSONObject();
        model.put("commodityCode", goodsCode);
        model.put("supplierCode", supplierCode);
        model.put("picWidth", 320);
        model.put("picHeight", 320);
        if (resultJSON.optJSONObject("sn_responseContent") == null)
            return null;
        if (resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body") == null)
            return null;
        String key = "getMorerecommend";
        String json = new Gson().toJson(model);
        String result = baseRequest("suning.netalliance.morerecommend.get", key, JSONObject.fromObject(json));
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
                .optJSONArray("commodityList");
        if (array != null) {
            Type type = new TypeToken<ArrayList<SuningGoodsInfoRecommend>>() {
            }.getType();
            List<SuningGoodsInfoRecommend> goodsList = new Gson().fromJson(array.toString(), type);
            return goodsList;
        }
        return null;
    }
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
        if (array != null && array.size() > 0) {
            return new Gson().fromJson(array.optJSONObject(0).toString(), SuningGoodsInfo.class);
        }
        return null;
    }
    public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
        String sts = "";
        for (String st : list) {
            sts += st + "_";
        }
    /**
     * 查询关联商品
     *
     * @param model
     * @return List<SuningGoodsInfo> 返回类型
     * @throws
     * @Title: searchGoods
     * @Description:
     */
    public static List<SuningGoodsInfoRecommend> getRecommendGoods(String goodsCode, String supplierCode) {
        JSONObject model = new JSONObject();
        model.put("commodityCode", goodsCode);
        model.put("supplierCode", supplierCode);
        model.put("picWidth", 320);
        model.put("picHeight", 320);
        if (sts.endsWith("_"))
            sts = sts.substring(0, sts.length() - 1);
        String key = "getMorerecommend";
        String json = new Gson().toJson(model);
        String result = baseRequest("suning.netalliance.morerecommend.get", key, JSONObject.fromObject(json));
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
                .optJSONArray("commodityList");
        if (array != null) {
            Type type = new TypeToken<ArrayList<SuningGoodsInfoRecommend>>() {
            }.getType();
            List<SuningGoodsInfoRecommend> goodsList = new Gson().fromJson(array.toString(), type);
            return goodsList;
        }
        return null;
    }
        JSONObject model = new JSONObject();
        model.put("commodityStr", sts);
        model.put("picWidth", 300);
        model.put("picHeight", 300);
        model.put("couponMark", 1);
        List<SuningGoodsInfo> goodsList = new ArrayList<>();
    public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
        String sts = "";
        for (String st : list) {
            sts += st + "_";
        }
        String key = "queryCommoditydetail";
        String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
        if (array != null && array.size() > 0) {
            for (int i = 0; i < array.size(); i++) {
                goodsList.add(new Gson().fromJson(array.optJSONObject(i).toString(), SuningGoodsInfo.class));
            }
        }
        return goodsList;
    }
        if (sts.endsWith("_"))
            sts = sts.substring(0, sts.length() - 1);
    public static String convertLink(String productUrl, String quanUrl, String pid, String subUser) {
        JSONObject model = new JSONObject();
        if (productUrl != null)
            model.put("productUrl", productUrl);
        JSONObject model = new JSONObject();
        model.put("commodityStr", sts);
        model.put("picWidth", 300);
        model.put("picHeight", 300);
        model.put("couponMark", 1);
        List<SuningGoodsInfo> goodsList = new ArrayList<>();
        if (!StringUtil.isNullOrEmpty(quanUrl))
            model.put("quanUrl", quanUrl);
        String key = "queryCommoditydetail";
        String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
        if (array != null && array.size() > 0) {
            for (int i = 0; i < array.size(); i++) {
                goodsList.add(new Gson().fromJson(array.optJSONObject(i).toString(), SuningGoodsInfo.class));
            }
        }
        return goodsList;
    }
        if (pid != null)
            model.put("promotionId", pid);
    public static String convertLink(String productUrl, String quanUrl, String pid, String subUser) {
        JSONObject model = new JSONObject();
        if (productUrl != null)
            model.put("productUrl", productUrl);
        if (subUser != null)
            model.put("subUser", subUser);
        if (!StringUtil.isNullOrEmpty(quanUrl))
            model.put("quanUrl", quanUrl);
        String key = "getExtensionlink";
        String result = baseRequest("suning.netalliance.extensionlink.get", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONObject json = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key);
        String link = json.optString("shortLink");
        return link;
    }
        if (pid != null)
            model.put("promotionId", pid);
    /**
     * 0
     * @Title: getOrderList
     * @Description:
     * @param startTime
     * @param endTime
     * @param page
     * @param orderLineStatus  (0:全部状态;1:等待付款;2:支付完成;3:退款;4:订单已取消;5:确认收货)
     * @return
     * SuningOrderQueryResultDTO 返回类型
     * @throws
     */
    public static SuningOrderQueryResultDTO getOrderList(Date startTime, Date endTime, int page, int orderLineStatus) {
        JSONObject model = new JSONObject();
        model.put("startTime", TimeUtil.getGernalTime(startTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
        model.put("endTime", TimeUtil.getGernalTime(endTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
        model.put("pageSize", 20);
        model.put("pageNo", page);
        model.put("orderLineStatus", orderLineStatus);
        if (subUser != null)
            model.put("subUser", subUser);
        String key = "queryOrder";
        String result = baseRequest("suning.netalliance.order.query", key, model);
        JSONObject resultJSON = JSONObject.fromObject(result);
        resultJSON = resultJSON.optJSONObject("sn_responseContent");
        JSONObject snBody = resultJSON.optJSONObject("sn_body");
        if (snBody == null)
            return null;
        String key = "getExtensionlink";
        String result = baseRequest("suning.netalliance.extensionlink.get", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONObject json = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key);
        String link = json.optString("shortLink");
        return link;
    }
        JSONArray array = snBody.optJSONArray(key);
        if (array == null)
            return null;
    public static SuningConvertLinkResult convertLinkNew(String commCode, String mertCode, String pid, String subUser) {
        JSONObject model = new JSONObject();
        if (commCode != null)
            model.put("commCode", commCode);
        Gson gson = new Gson();
        if (!StringUtil.isNullOrEmpty(mertCode))
            model.put("mertCode", mertCode);
        Type type = new TypeToken<ArrayList<SuningOrderInfo>>() {
        }.getType();
        if (pid != null)
            model.put("adBookId", pid);
        if (array != null) {
            List<SuningOrderInfo> orderList = new ArrayList<>();
            for (int i = 0; i < array.size(); i++) {
                JSONObject data = array.optJSONObject(i);
                JSONArray itemArray = data.optJSONArray("orderDetail");
                List<SuningOrderInfo> tempList = gson.fromJson(itemArray.toString(), type);
                for (SuningOrderInfo info : tempList) {
                    info.setOrderCode(data.optString("orderCode"));
                    orderList.add(info);
                }
            }
        if (subUser != null)
            model.put("subUser", subUser);
            return new SuningOrderQueryResultDTO(resultJSON.optJSONObject("sn_head").optInt("totalSize"), orderList);
        }
        String key = "queryStorepromotionurl";
        String result = baseRequest("suning.netalliance.storepromotionurl.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        JSONObject json = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key);
        return null;
    }
        return new Gson().fromJson(json.toString(), SuningConvertLinkResult.class);
    }
    /**
     * 常规转链
     * @Title: convertCommonLink
     * @Description:
     * @param url
     * @param pid
     * @param subUser
     * @return
     * String 返回类型
     * @throws
     */
    public static String convertCommonLink(String url, String pid, String subUser) {
        JSONObject model = new JSONObject();
        model.put("adBookId", pid);
        model.put("visitUrl", url);
        model.put("subUser", subUser);
        String key = "queryCustompromotionurl";
        String result = baseRequest("suning.netalliance.custompromotionurl.query", key, model);
        JSONObject resultJSON = JSONObject.fromObject(result);
        resultJSON = resultJSON.optJSONObject("sn_responseContent");
        String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl")
                .optString("shortUrl");
        return URLDecoder.decode(shortUrl);
    }
    /**
     * 0
     *
     * @param startTime
     * @param endTime
     * @param page
     * @param orderLineStatus (0:全部状态;1:等待付款;2:支付完成;3:退款;4:订单已取消;5:确认收货)
     * @return SuningOrderQueryResultDTO 返回类型
     * @throws
     * @Title: getOrderList
     * @Description:
     */
    public static SuningOrderQueryResultDTO getOrderList(Date startTime, Date endTime, int page, int orderLineStatus) {
        JSONObject model = new JSONObject();
        model.put("startTime", TimeUtil.getGernalTime(startTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
        model.put("endTime", TimeUtil.getGernalTime(endTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
        model.put("pageSize", 20);
        model.put("pageNo", page);
        model.put("orderLineStatus", orderLineStatus);
    /**
     * 商品精选接口
     * @Title: getSelectRecommendGoods
     * @Description:
     * @param eliteId
     * @param page
     * @return
     * List<SuningGoodsInfo> 返回类型
     * @throws
     */
    public static List<SuningGoodsInfo> getSelectRecommendGoods(int eliteId, int page) {
        JSONObject model = new JSONObject();
        model.put("eliteId", eliteId);
        model.put("pageIndex", page);
        // model.put("picWidth", 320);
        // model.put("picHeight", 320);
        model.put("size", 10);
        model.put("couponMark", 1);
        String key = "queryOrder";
        String result = baseRequest("suning.netalliance.order.query", key, model);
        JSONObject resultJSON = JSONObject.fromObject(result);
        resultJSON = resultJSON.optJSONObject("sn_responseContent");
        JSONObject snBody = resultJSON.optJSONObject("sn_body");
        if (snBody == null)
            return null;
        String key = "querySelectrecommendcommodity";
        String result = baseRequest("suning.netalliance.selectrecommendcommodity.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        resultJSON = resultJSON.optJSONObject("sn_responseContent");
        JSONArray array = resultJSON.optJSONObject("sn_body").optJSONObject(key).optJSONArray("commodityList");
        if (array != null) {
            Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
            }.getType();
            List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
            return goodsList;
        }
        return null;
    }
        JSONArray array = snBody.optJSONArray(key);
        if (array == null)
            return null;
        Gson gson = new Gson();
        Type type = new TypeToken<ArrayList<SuningOrderInfo>>() {
        }.getType();
        if (array != null) {
            List<SuningOrderInfo> orderList = new ArrayList<>();
            for (int i = 0; i < array.size(); i++) {
                JSONObject data = array.optJSONObject(i);
                JSONArray itemArray = data.optJSONArray("orderDetail");
                List<SuningOrderInfo> tempList = gson.fromJson(itemArray.toString(), type);
                for (SuningOrderInfo info : tempList) {
                    info.setOrderCode(data.optString("orderCode"));
                    orderList.add(info);
                }
            }
            return new SuningOrderQueryResultDTO(resultJSON.optJSONObject("sn_head").optInt("totalSize"), orderList);
        }
        return null;
    }
    /**
     * 常规转链
     *
     * @param url
     * @param pid
     * @param subUser
     * @return String 返回类型
     * @throws
     * @Title: convertCommonLink
     * @Description:
     */
    public static String convertCommonLink(String url, String pid, String subUser) {
        JSONObject model = new JSONObject();
        model.put("adBookId", pid);
        model.put("visitUrl", url);
        model.put("subUser", subUser);
        String key = "queryCustompromotionurl";
        String result = baseRequest("suning.netalliance.custompromotionurl.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        resultJSON = resultJSON.optJSONObject("sn_responseContent");
        String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl")
                .optString("shortUrl");
        return URLDecoder.decode(shortUrl);
    }
    /**
     * 商品精选接口
     *
     * @param eliteId
     * @param page
     * @return List<SuningGoodsInfo> 返回类型
     * @throws
     * @Title: getSelectRecommendGoods
     * @Description:
     */
    public static List<SuningGoodsInfo> getSelectRecommendGoods(int eliteId, int page) {
        JSONObject model = new JSONObject();
        model.put("eliteId", eliteId);
        model.put("pageIndex", page);
        // model.put("picWidth", 320);
        // model.put("picHeight", 320);
        model.put("size", 10);
        model.put("couponMark", 1);
        String key = "querySelectrecommendcommodity";
        String result = baseRequest("suning.netalliance.selectrecommendcommodity.query", key, model);
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        resultJSON = resultJSON.optJSONObject("sn_responseContent");
        JSONArray array = resultJSON.optJSONObject("sn_body").optJSONObject(key).optJSONArray("commodityList");
        if (array != null) {
            Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
            }.getType();
            List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
            return goodsList;
        }
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java
@@ -32,265 +32,269 @@
/**
 * TODO 未完成 唯品会接口
 *
 * @author Administrator
 *
 * @author Administrator
 */
public class VipShopApiUtil {
    private final static String appKey = "f9e7f22f";
    private final static String appSecret = "9B2291352497FAF42B2DF44BFCF62316";
    private final static String appKey = "f9e7f22f";
    private final static String appSecret = "9B2291352497FAF42B2DF44BFCF62316";
    /**
     * 获取签名
     *
     * @param params
     * @return
     */
    private static String getSign(Map<String, String> systemParams, JSONObject taskParams) {
        List<String> list = new ArrayList<>();
        for (Iterator<String> its = systemParams.keySet().iterator(); its.hasNext();) {
            String key = its.next();
            String value = systemParams.get(key);
            list.add(key + value);
        }
        Collections.sort(list);
        String source = "";
        for (String st : list)
            source += st;
        source += taskParams.toString();
        return StringUtil.MD5Hmac(source, appSecret);
    }
    /**
     * 获取签名
     *
     * @param params
     * @return
     */
    private static String getSign(Map<String, String> systemParams, JSONObject taskParams) {
        List<String> list = new ArrayList<>();
        for (Iterator<String> its = systemParams.keySet().iterator(); its.hasNext(); ) {
            String key = its.next();
            String value = systemParams.get(key);
            list.add(key + value);
        }
        Collections.sort(list);
        String source = "";
        for (String st : list)
            source += st;
        source += taskParams.toString();
        return StringUtil.MD5Hmac(source, appSecret);
    }
    private static Map<String, String> getSystemParams(String service, String method) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("service", service);
        params.put("method", method);
        params.put("version", "1.0");
        params.put("timestamp", System.currentTimeMillis() / 1000 + "");
        params.put("format", "json");
        params.put("appKey", appKey);
        return params;
    }
    private static Map<String, String> getSystemParams(String service, String method) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("service", service);
        params.put("method", method);
        params.put("version", "1.0");
        params.put("timestamp", System.currentTimeMillis() / 1000 + "");
        params.put("format", "json");
        params.put("appKey", appKey);
        return params;
    }
    /**
     * 基础请求
     *
     * @param service
     * @param method
     * @param taskParams
     * @return
     */
    private static String baseRequest(String service, String method, JSONObject taskParams) {
        Map<String, String> systemParams = getSystemParams(service, method);
        String sign = getSign(systemParams, taskParams);
        systemParams.put("sign", sign);
        String baseUrl = "https://gw.vipapis.com";
        baseUrl += "?";
        for (Iterator<String> its = systemParams.keySet().iterator(); its.hasNext();) {
            String key = its.next();
            String value = "";
            try {
                value = URLEncoder.encode(systemParams.get(key), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            baseUrl += key + "=" + value + "&";
        }
        baseUrl = baseUrl.endsWith("&") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
        String result = post(baseUrl, taskParams.toString());
        return result;
    }
    /**
     * 基础请求
     *
     * @param service
     * @param method
     * @param taskParams
     * @return
     */
    private static String baseRequest(String service, String method, JSONObject taskParams) {
        Map<String, String> systemParams = getSystemParams(service, method);
        String sign = getSign(systemParams, taskParams);
        systemParams.put("sign", sign);
        String baseUrl = "https://gw.vipapis.com";
        baseUrl += "?";
        for (Iterator<String> its = systemParams.keySet().iterator(); its.hasNext(); ) {
            String key = its.next();
            String value = "";
            try {
                value = URLEncoder.encode(systemParams.get(key), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            baseUrl += key + "=" + value + "&";
        }
        baseUrl = baseUrl.endsWith("&") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
        String result = post(baseUrl, taskParams.toString());
        return result;
    }
    @SuppressWarnings("deprecation")
    private static String post(String url, String body) {
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(url);
        method.addRequestHeader("Content-Type", "application/json;charset=UTF-8");
        method.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
        method.setRequestBody(body);
        try {
            client.executeMethod(method);
            return method.getResponseBodyAsString();
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    @SuppressWarnings("deprecation")
    private static String post(String url, String body) {
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(url);
        method.addRequestHeader("Content-Type", "application/json;charset=UTF-8");
        method.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
        method.setRequestBody(body);
        try {
            client.executeMethod(method);
            return method.getResponseBodyAsString();
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 搜索
     * @Title: search
     * @Description:
     * @param searchFilter
     * @return
     * VIPSearchResult 返回类型
     * @throws
     */
    public static VIPSearchResult search(VIPSearchFilter searchFilter) {
        Map<String, String> taskParams = new HashMap<>();
        taskParams.put("keyword", searchFilter.getKeyword());
        taskParams.put("page", searchFilter.getPage() + "");
        taskParams.put("pageSize", searchFilter.getPageSize() + "");
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
        if (searchFilter.getPriceStart() != null)
            taskParams.put("priceStart", searchFilter.getPriceStart());
    /**
     * 搜索
     *
     * @param searchFilter
     * @return VIPSearchResult 返回类型
     * @throws
     * @Title: search
     * @Description:
     */
    public static VIPSearchResult search(VIPSearchFilter searchFilter) {
        Map<String, String> taskParams = new HashMap<>();
        taskParams.put("keyword", searchFilter.getKeyword());
        taskParams.put("page", searchFilter.getPage() + "");
        taskParams.put("pageSize", searchFilter.getPageSize() + "");
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
        if (searchFilter.getPriceStart() != null)
            taskParams.put("priceStart", searchFilter.getPriceStart());
        if (searchFilter.getPriceEnd() != null)
            taskParams.put("priceEnd", searchFilter.getPriceEnd());
        if (searchFilter.getOrder() != null)
            taskParams.put("order", searchFilter.getOrder() + "");
        if (searchFilter.getFieldName() != null)
            taskParams.put("fieldName", searchFilter.getFieldName() + "");
        if (searchFilter.getPriceEnd() != null)
            taskParams.put("priceEnd", searchFilter.getPriceEnd());
        if (searchFilter.getOrder() != null)
            taskParams.put("order", searchFilter.getOrder() + "");
        if (searchFilter.getFieldName() != null)
            taskParams.put("fieldName", searchFilter.getFieldName() + "");
        JSONObject root = new JSONObject();
        root.put("request", JSONObject.fromObject(taskParams));
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", root);
        System.out.println(result);
        List<VIPGoodsInfo> goodsList = new ArrayList<>();
        JSONObject resultJson = JSONObject.fromObject(result);
        Gson gson = new Gson();
        if (resultJson.optInt("returnCode") == 0) {
            resultJson = resultJson.optJSONObject("result");
            int count = resultJson.optInt("total");
            JSONArray array = resultJson.optJSONArray("goodsInfoList");
            if (array != null && array.size() > 0) {
                for (int i = 0; i < array.size(); i++) {
                    JSONObject optJSONObject = array.optJSONObject(i);
                    if (optJSONObject == null) {
                        continue;
                    }
                    VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
                    if (info != null)
                        goodsList.add(info);
                }
            }
            return new VIPSearchResult(goodsList, count);
        }
        return null;
    }
    public static VIPSearchResult getGoodsList(int channelType,int page) {
        Map<String, String> taskParams = new HashMap<>();
        taskParams.put("channelType",channelType+"");
        taskParams.put("page", page+ "");
        taskParams.put("pageSize", 20 + "");
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
        JSONObject root = new JSONObject();
        root.put("request", JSONObject.fromObject(taskParams));
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", root);
        System.out.println(result);
        List<VIPGoodsInfo> goodsList = new ArrayList<>();
        JSONObject resultJson = JSONObject.fromObject(result);
        Gson gson = new Gson();
        if (resultJson.optInt("returnCode") == 0) {
            resultJson = resultJson.optJSONObject("result");
            int count = resultJson.optInt("total");
        JSONObject root = new JSONObject();
        root.put("request", JSONObject.fromObject(taskParams));
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "goodsList", root);
        System.out.println(result);
        List<VIPGoodsInfo> goodsList = new ArrayList<>();
        JSONObject resultJson = JSONObject.fromObject(result);
        Gson gson = new Gson();
        if (resultJson.optInt("returnCode") == 0) {
            resultJson = resultJson.optJSONObject("result");
            int count = resultJson.optInt("total");
            JSONArray array = resultJson.optJSONArray("goodsInfoList");
            for (int i = 0; i < array.size(); i++) {
                VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
                if (info != null)
                    goodsList.add(info);
            }
            return new VIPSearchResult(goodsList, count);
        }
        return null;
    }
            JSONArray array = resultJson.optJSONArray("goodsInfoList");
            if (array != null && array.size() > 0) {
                for (int i = 0; i < array.size(); i++) {
                    JSONObject optJSONObject = array.optJSONObject(i);
                    if (optJSONObject == null) {
                        continue;
                    }
                    VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
                    if (info != null)
                        goodsList.add(info);
                }
            }
    /**
     * 商品ID转链
     *
     * @param goodsId
     */
    public static VIPConvertResultDTO convertLink(String goodsId, String tag) {
        JSONObject taskParams = new JSONObject();
        JSONArray goodsIdArray = new JSONArray();
        goodsIdArray.add(goodsId);
        taskParams.put("goodsIdList", goodsIdArray);
        taskParams.put("chanTag", tag);
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
        String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId",
                JSONObject.fromObject(taskParams));
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        if (resultJSON.optInt("returnCode") == 0) {
            String re = resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).toString();
            return new Gson().fromJson(re, VIPConvertResultDTO.class);
        }
        return null;
    }
            return new VIPSearchResult(goodsList, count);
        }
        return null;
    }
    /**
     * 根据商品ID获取商品详情
     *
     * @param goodsIdList
     * @return
     */
    public static List<VIPGoodsInfo> getGoodsDetail(List<String> goodsIdList) {
        JSONObject params = new JSONObject();
        params.put("goodsIdList", goodsIdList);
        params.put("requestId", UUID.randomUUID());
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIds",
                JSONObject.fromObject(params));
        System.out.println(result);
        JSONObject resultJson = JSONObject.fromObject(result);
        Gson gson = new Gson();
        List<VIPGoodsInfo> goodsList = new ArrayList<>();
        if (resultJson.optInt("returnCode") == 0) {
            JSONArray array = resultJson.optJSONArray("result");
            for (int i = 0; i < array.size(); i++) {
                VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
                if (info != null)
                    goodsList.add(info);
            }
            return goodsList;
        }
        return null;
    }
    /**
     * 获取商品详情
     *
     * @param goodsId
     * @return
     */
    public static VIPGoodsInfo getGoodsDetail(String goodsId) {
        List<String> goodsIdList = new ArrayList<>();
        goodsIdList.add(goodsId);
        List<VIPGoodsInfo> goodsList = getGoodsDetail(goodsIdList);
        if (goodsList == null || goodsList.size() == 0)
            return null;
        return goodsList.get(0);
    }
    public static VIPSearchResult getGoodsList(int channelType, int page) {
        Map<String, String> taskParams = new HashMap<>();
        taskParams.put("channelType", channelType + "");
        taskParams.put("page", page + "");
        taskParams.put("pageSize", 20 + "");
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
    public static VipShopQueryOrderResultDTO getOrderList(VipShopOrderQueryModel query) {
        JSONObject params = JSONObject.fromObject(new Gson().toJson(query));
        params.put("requestId", UUID.randomUUID());
        JSONObject root = new JSONObject();
        root.put("queryModel", params);
        String result = baseRequest("com.vip.adp.api.open.service.UnionOrderService", "orderList", root);
        System.out.println(result);
        JSONObject json = JSONObject.fromObject(result);
        if (json.optInt("returnCode") == 0) {
            JSONObject resultJson = json.optJSONObject("result");
            int total = resultJson.optInt("total");
            JSONArray array = JSONArray.fromObject(resultJson.optJSONArray("orderInfoList"));
            if (array != null) {
                Type type = new TypeToken<ArrayList<VipShopOrder>>() {
                }.getType();
                List<VipShopOrder> orderList = new Gson().fromJson(array.toString(), type);
                return new VipShopQueryOrderResultDTO(orderList, total);
            }
        }
        return null;
    }
        JSONObject root = new JSONObject();
        root.put("request", JSONObject.fromObject(taskParams));
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "goodsList", root);
        System.out.println(result);
        List<VIPGoodsInfo> goodsList = new ArrayList<>();
        JSONObject resultJson = JSONObject.fromObject(result);
        Gson gson = new Gson();
        if (resultJson.optInt("returnCode") == 0) {
            resultJson = resultJson.optJSONObject("result");
            int count = resultJson.optInt("total");
            JSONArray array = resultJson.optJSONArray("goodsInfoList");
            for (int i = 0; i < array.size(); i++) {
                VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
                if (info != null)
                    goodsList.add(info);
            }
            return new VIPSearchResult(goodsList, count);
        }
        return null;
    }
    /**
     * 商品ID转链
     *
     * @param goodsId
     */
    public static VIPConvertResultDTO convertLink(String goodsId, String tag) {
        JSONObject taskParams = new JSONObject();
        JSONArray goodsIdArray = new JSONArray();
        goodsIdArray.add(goodsId);
        taskParams.put("goodsIdList", goodsIdArray);
        taskParams.put("chanTag", tag);
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
        String result = baseRequest("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsId",
                JSONObject.fromObject(taskParams));
        System.out.println(result);
        JSONObject resultJSON = JSONObject.fromObject(result);
        if (resultJSON.optInt("returnCode") == 0) {
            String re = resultJSON.optJSONObject("result").optJSONArray("urlInfoList").optJSONObject(0).toString();
            return new Gson().fromJson(re, VIPConvertResultDTO.class);
        }
        return null;
    }
    /**
     * 根据商品ID获取商品详情
     *
     * @param goodsIdList
     * @return
     */
    public static List<VIPGoodsInfo> getGoodsDetail(List<String> goodsIdList) {
        JSONObject params = new JSONObject();
        params.put("goodsIdList", goodsIdList);
        params.put("requestId", UUID.randomUUID());
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIds",
                JSONObject.fromObject(params));
        System.out.println(result);
        JSONObject resultJson = JSONObject.fromObject(result);
        Gson gson = new Gson();
        List<VIPGoodsInfo> goodsList = new ArrayList<>();
        if (resultJson.optInt("returnCode") == 0) {
            JSONArray array = resultJson.optJSONArray("result");
            for (int i = 0; i < array.size(); i++) {
                VIPGoodsInfo info = gson.fromJson(array.optJSONObject(i).toString(), VIPGoodsInfo.class);
                if (info != null)
                    goodsList.add(info);
            }
            return goodsList;
        }
        return null;
    }
    /**
     * 获取商品详情
     *
     * @param goodsId
     * @return
     */
    public static VIPGoodsInfo getGoodsDetail(String goodsId) {
        List<String> goodsIdList = new ArrayList<>();
        goodsIdList.add(goodsId);
        List<VIPGoodsInfo> goodsList = getGoodsDetail(goodsIdList);
        if (goodsList == null || goodsList.size() == 0)
            return null;
        return goodsList.get(0);
    }
    public static VipShopQueryOrderResultDTO getOrderList(VipShopOrderQueryModel query) {
        JSONObject params = JSONObject.fromObject(new Gson().toJson(query));
        params.put("requestId", UUID.randomUUID());
        JSONObject root = new JSONObject();
        root.put("queryModel", params);
        String result = baseRequest("com.vip.adp.api.open.service.UnionOrderService", "orderList", root);
        System.out.println(result);
        JSONObject json = JSONObject.fromObject(result);
        if (json.optInt("returnCode") == 0) {
            JSONObject resultJson = json.optJSONObject("result");
            int total = resultJson.optInt("total");
            JSONArray array = JSONArray.fromObject(resultJson.optJSONArray("orderInfoList"));
            if (array != null) {
                Type type = new TypeToken<ArrayList<VipShopOrder>>() {
                }.getType();
                List<VipShopOrder> orderList = new Gson().fromJson(array.toString(), type);
                return new VipShopQueryOrderResultDTO(orderList, total);
            }
        }
        return null;
    }
    public static void main(String[] args) {
        convertLink("6919237495414585303","437032");
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsJumpLinkVO.java
File was renamed from fanli/src/main/java/com/yeshi/fanli/vo/pdd/PDDJumpLinkVO.java
@@ -1,11 +1,11 @@
package com.yeshi.fanli.vo.pdd;
package com.yeshi.fanli.vo.goods;
import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO;
/**
 * 拼多多跳转链接
 */
public class PDDJumpLinkVO {
public class GoodsJumpLinkVO {
    private String jumpLink;
    private boolean _native;
    private String nativeJumpLink;
fanli/src/main/java/com/yeshi/fanli/vo/suning/SuningConvertLinkResult.java
New file
@@ -0,0 +1,99 @@
package com.yeshi.fanli.vo.suning;
public class SuningConvertLinkResult {
    /**
     * commCode : 617763437
     * adBookId : 666526
     * mertCode : 0000000000
     * appId : wx681b1e78da02dd16
     * spPageUrl : pages%2Ffourth%2Ffourth%3FproductId%3D617763437%26shop%3D0000000000%26union%3DLjyHdSTX
     * spType : 1
     * wapExtendUrl : https%3A%2F%2Fsugs.suning.com%2Foutstation.htm%3Fp%3DBFpQFQpbDw1CFRBpLy4wXRAZAEpQQi1tZ39bDXhkdHdbSVcNYjlkbhoWGBYZGhkaKRMXaRFCSlxzUR1FVF4CGFhWUEAERUoKWBNaJnh_L1JETFRBUgp-JWEzWxMpJzA2W1xJHHw2ITBDSE8ISkVEBSVXSTpTFw1HcFZRQ1ZcCx1RUktFAg4BDhcXFW1kICcJHgYdD0dVbHpnf1tebGNwa1NKRkBjf2dmEBYcBQoJUnZ3UFIzaxEdATULPVFcMBlxQx8%26sub_user%3D323030
     * isSupportBySp : 1
     * pcExtendUrl : https%3A%2F%2Fsugs.suning.com%2Foutstation.htm%3Fp%3DAFQFEFELUg4XEhBseikxVkUfUEdSEn5oZH1fX3hifCJbSVcNYjlkbhoWGBYZGhkaKRMXaRFCSlxzUR1FVF4CGFhWUEAERUoKWBNaJnt_L1JETFRBUgp-JWEzWxMpJzA2EklJXiI3OzpfRVwIWl9HQztCCD1JGVZYcFZRQ1ZcCx1RTVJCBA4ACxAQEXQiPD4IDgYdUEdVbGtlfVhCcWdpdFhTV0BodmxkGhILBQpRdQggUUsTQxAQHS06Q0k6TmcPHA%26sub_user%3D323030
     */
    private String commCode;
    private String adBookId;
    private String mertCode;
    private String appId;
    private String spPageUrl;
    private String spType;
    private String wapExtendUrl;
    private String isSupportBySp;
    private String pcExtendUrl;
    public String getCommCode() {
        return commCode;
    }
    public void setCommCode(String commCode) {
        this.commCode = commCode;
    }
    public String getAdBookId() {
        return adBookId;
    }
    public void setAdBookId(String adBookId) {
        this.adBookId = adBookId;
    }
    public String getMertCode() {
        return mertCode;
    }
    public void setMertCode(String mertCode) {
        this.mertCode = mertCode;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getSpPageUrl() {
        return spPageUrl;
    }
    public void setSpPageUrl(String spPageUrl) {
        this.spPageUrl = spPageUrl;
    }
    public String getSpType() {
        return spType;
    }
    public void setSpType(String spType) {
        this.spType = spType;
    }
    public String getWapExtendUrl() {
        return wapExtendUrl;
    }
    public void setWapExtendUrl(String wapExtendUrl) {
        this.wapExtendUrl = wapExtendUrl;
    }
    public String getIsSupportBySp() {
        return isSupportBySp;
    }
    public void setIsSupportBySp(String isSupportBySp) {
        this.isSupportBySp = isSupportBySp;
    }
    public String getPcExtendUrl() {
        return pcExtendUrl;
    }
    public void setPcExtendUrl(String pcExtendUrl) {
        this.pcExtendUrl = pcExtendUrl;
    }
}