package com.bjtdba.thirdPartWares.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bjtdba.entity.thirdPartyWares.*;
import com.bjtdba.thirdPartWares.dao.SystemConfigValueDao;
import com.bjtdba.thirdPartWares.dao.ThirdPartyGoodsDao;
import com.bjtdba.thirdPartWares.dao.UserThirdDao;
import com.bjtdba.thirdPartWares.service.TaobaoService;
import com.bjtdba.utils.HttpUtils;
import com.bjtdba.utils.ResponseUtil;
import com.bjtdba.utils.SignMD5Util;
import com.bjtdba.utils.SignTop;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.math.BigDecimal;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
@Slf4j
public class TaobaoServiceImpl implements TaobaoService {

    @Value("${DTK.APPSECRET}")
    private String dtkAppSecret;

    @Value("${DTK.APPKEY}")
    private String dtkAppKey;

    @Value("${DTK.HOST}")
    private String dtkHost;

    @Value("${DTK.PID}")
    private String pid;

    @Value("${TB.APPSECRET}")
    private String tbkAppSecret;

    @Value("${TB.APPKEY}")
    private String tbAppKey;

    @Value("${TB.HOST}")
    private String tbHost;

    @Value("${TB.ADZONEID}")
    private String adzoneId;

    @Value("${TB.REDIRECTURI}")
    private String redirecturi;

    @Autowired
    private UserThirdDao userThirdDao;

    @Autowired
    private SystemConfigValueDao systemConfigValueDao;

    @Autowired
    private ThirdPartyGoodsDao thirdPartyGoodsDao;


    public Object selectTaobaoWaresListNew(String pageNum, String pageSize,String keyWords,String cid) {
        Map<String, Object> data = new HashMap<>();
        PageHelper.startPage(Integer.parseInt(pageNum),Integer.parseInt(pageSize));

        ThirdPartyGoods thirdPartyGoods=new ThirdPartyGoods();
        thirdPartyGoods.setJson(keyWords);
        if(cid!=null&&!cid.equals("")){
            thirdPartyGoods.setCid(Integer.parseInt(cid));
        }
        List<ThirdPartyGoods> thirdPartyGoodsList=thirdPartyGoodsDao.queryAllByLimit(thirdPartyGoods);
        List<Object> list=new ArrayList<Object>();
        for (int i = 0; i < thirdPartyGoodsList.size(); i++) {
            JSONObject jsonObject= JSONObject.parseObject(thirdPartyGoodsList.get(i).getJson());
//            System.out.println("====================="+jsonObject.get("commission"));
            String str= (String) jsonObject.get("commission");
            BigDecimal decimal = new BigDecimal(str);
            BigDecimal pv=null;//新增pv值  pv=佣金*50%
            BigDecimal yanglaojin=null; //养老金=pv

            String valueStr=systemConfigValueDao.selectConfigValueByKey("sanfangfenpei");
            JSONObject jsonObjectValue= JSONObject.parseObject(valueStr);
            BigDecimal fenPV=new BigDecimal(jsonObjectValue.get("pv")+"");
            BigDecimal fenyanglaojin=new BigDecimal(jsonObjectValue.get("yanglaojin")+"");
            pv=thirdPartyGoodsList.get(i).getPension().multiply(fenPV).setScale(2,BigDecimal.ROUND_HALF_UP);//四舍五入
            yanglaojin=thirdPartyGoodsList.get(i).getPension().multiply(fenyanglaojin).setScale(2,BigDecimal.ROUND_HALF_UP);//四舍五入;//四舍五入

            String trimmedValue = decimal.toPlainString();
//            pv=trimmedValue.toString();

            jsonObject.put("commission",trimmedValue);
            jsonObject.put("pv",pv);
            jsonObject.put("yanglaojin",yanglaojin);
//            String pretty =JSON.parseObject(jsonObject+"");
            list.add(jsonObject);

        }
        data.put("thirdPartyWaresList",list);
        return  ResponseUtil.ok(data);


    }
    @Override
    public List<ThirdPartyWares> selectTaobaoWaresList(String pageNum, String pageSize,String keyWords) {
        Map<String,Object> data=new HashMap<String,Object>();
        TreeMap<String,String> paraMap = new TreeMap<>();
        String url ="";
        JSONArray jsonArray = null;
        if(keyWords==null){
            //列表接口
            url = dtkHost+"/api/goods/get-goods-list";
            paraMap.put("version","v1.2.4");
            paraMap.put("appKey",dtkAppKey);
            paraMap.put("pageId",pageNum);
            paraMap.put("pageSize",pageSize);
            paraMap.put("sign", SignMD5Util.getSignStr(paraMap,dtkAppSecret));
//            System.out.println("列表接口提交"+paraMap);
            String sendGet = HttpUtils.sendGet(url, paraMap);
//            System.out.println("列表接口提交"+sendGet);
            jsonArray = JSONArray.parseArray(JSONObject.parseObject(JSONObject.parseObject(sendGet).get("data").toString()).get("list").toString());
            log.info("淘宝接口返回数据111==="+jsonArray);
        }else{
            //搜索接口
            url = dtkHost+"/api/tb-service/get-tb-service";
            paraMap.put("version","v2.1.0");
            paraMap.put("appKey",dtkAppKey);
            paraMap.put("pageNo",pageNum);
            paraMap.put("pageSize",pageSize);
            paraMap.put("keyWords",keyWords);
//            paraMap.put("sort","4");
            paraMap.put("sign", SignMD5Util.getSignStr(paraMap,dtkAppSecret));
            System.out.println("搜索接口提交"+paraMap);
            String sendGet = HttpUtils.sendGet(url, paraMap);
            System.out.println("搜索接口返回"+sendGet);
            jsonArray = JSONArray.parseArray(JSONObject.parseObject(sendGet).get("data").toString());
            log.info("淘宝接口返回数据222==="+jsonArray);
        }
        List<ThirdPartyWares> thirdPartyWaresList = new ArrayList<>();
        for(int i = 0; i < jsonArray.size(); i++) {
            JSONObject obj = jsonArray.getJSONObject(i);

            ThirdPartyWares thirdPartyWares = new ThirdPartyWares();
            thirdPartyWares.setType(5);
            Number commissionRate = obj.get("commissionRate")!=null?(Number)obj.get("commissionRate"):(((Number)obj.get("commission_rate")).doubleValue()*0.01);
            thirdPartyWares.setCommission_rate(commissionRate);//佣金比例

            Number market_price = obj.get("originalPrice") != null ? (Number)obj.get("originalPrice") : new Double(obj.get("zk_final_price").toString());
            thirdPartyWares.setMarket_price(market_price);  //原价
            String id = obj.get("goodsSign")!=null?(String)obj.get("goodsSign"):(String)obj.get("item_id");
            thirdPartyWares.setId(id);//商品ID
            String thumb = obj.get("mainPic")!=null?(String)obj.get("mainPic"):(String)obj.get("pict_url");
            thirdPartyWares.setThumb(thumb);//商品主图链接
            thirdPartyWares.setName((String)obj.get("title"));//名称
            Number sales = obj.get("dailySales")!=null?(Number)obj.get("dailySales"):(Number)obj.get("volume");
            thirdPartyWares.setSales(sales);//当天销量
            thirdPartyWares.setCommission_type(obj.get("commissionType")!=null?(Integer)obj.get("commissionType"):0);
            thirdPartyWares.setCoupon_share_url(obj.get("couponLink")!=null?(String)obj.get("couponLink"):"");
            Number actualPrice = (Number)obj.get("actualPrice");
            if(obj.get("actualPrice")==null){
                //搜索
                double coupon = 0.00;
                if(obj.get("coupon_amount")!=null){
                    coupon =new Double(obj.get("coupon_amount").toString());
                }
                actualPrice = new Double(obj.get("zk_final_price").toString()) - coupon;
            }
            thirdPartyWares.setPrice(actualPrice);//卷后价格
            double yongjin = actualPrice.doubleValue() * commissionRate.doubleValue()/100;
            log.info("计算佣金="+yongjin);
            String yanglaojing = yanglaojing(yongjin);
            thirdPartyWares.setCommission(yongjin+"");
            Number coupon_money = (obj.get("couponPrice"))!=null?((Number)obj.get("couponPrice")):(obj.get("coupon_amount")!=null?new Double((String)obj.get("coupon_amount")):0.00);//new Double((String)obj.get("coupon_amount"))
            thirdPartyWares.setCoupon_money(coupon_money);
            thirdPartyWares.setCid(obj.get("cid")!=null?(Number)obj.get("cid"):0);
            log.info("===============cid="+thirdPartyWares.getCid());
            thirdPartyWares.setShopType(obj.get("shopType")!=null?(Number)obj.get("shopType"):0);
            thirdPartyWares.setShopName(obj.get("shopName")!=null?(String)obj.get("shopName"):"");
            thirdPartyWares.setMonthSales(obj.get("monthSales")!=null?(Number)obj.get("monthSales"):0);
            thirdPartyWaresList.add(thirdPartyWares);
        }


//        data.put("thirdPartyWaresList",thirdPartyWaresList);

//        return ResponseUtil.ok(data);
        return thirdPartyWaresList;
    }


     public Object saveThirdPartGood(){
        //定时执行180次3.6万条数据存入数据库
        int aa=1;
        for(int i=1;i<=1800;i++){
            log.info("=================================开始循环第"+i+"次=========================");
            List<ThirdPartyWares> thirdPartyWaresList =selectTaobaoWaresList(i+"",200+"",null);
            //用来接收json的值
            JSONArray jsonArray = new JSONArray();
//            jsonArray.add(object);
//            JSONObject jsonObj=new JSONObject();
//            jsonObject.getJSONObject(object.toString());
            List<ThirdPartyGoods> thirdPartyGoodsList=new ArrayList<ThirdPartyGoods>();
            if(thirdPartyWaresList!=null&&thirdPartyWaresList.size()!=0){
                for(int y = 0; y < thirdPartyWaresList.size();y++){
                    //再将你取出来的list值重新赋值给JSONObject
                    JSONObject json = (JSONObject)JSONObject.toJSON(thirdPartyWaresList.get(y));

                    //然后直接用jsonObj.getString("属性名")就可以调取到你要的属性值
//                String commission = jsonObj.getString("commission");

                    //然后就可以取到list里的name属性的值
                    aa=aa+1;
                    System.out.println("commission"+aa+"="+json.get("commission"));
                    ThirdPartyGoods thirdPartyGoods=new ThirdPartyGoods();
                    thirdPartyGoods.setJson(json.toString());
                    thirdPartyGoods.setType(1);
                    thirdPartyGoods.setPension(new BigDecimal(json.get("commission").toString().trim()));
                    thirdPartyGoods.setCid((Integer) json.get("cid"));
                    thirdPartyGoodsList.add(thirdPartyGoods);
                }
                thirdPartyGoodsDao.insertBatch(thirdPartyGoodsList);
            }




         }

        return ResponseUtil.ok();

     }





    /**
     * 养老金计算方法
     * @param price
     * @return
     */
    public String yanglaojing(double price){
       String extension_bili =  systemConfigValueDao.selectConfigValueByKey("extension_tao_rate");
       String yanglaojin_admin = systemConfigValueDao.selectConfigValueByKey("yanglaojin_admin");
        String yanglao_Meeting = systemConfigValueDao.selectConfigValueByKey("yanglao_Meeting");
        double yanglao = 0.0;

        if(Integer.parseInt(extension_bili)>0){
            double yanglao1 = price*new Double(extension_bili)/100;
            double yanglao2 = yanglao1*(new Double(yanglaojin_admin)/100);
            yanglao = yanglao2-yanglao2*(new Double(yanglao_Meeting)/100);

        }
        return String.format("%.2f", yanglao);
    }

    @Override
    public Object taobaoWaresDetail(String id) throws ParseException {
        Map<String,Object> data=new HashMap<String,Object>();
        TreeMap<String,String> paraMap = new TreeMap<>();
        String url = dtkHost+"/api/goods/get-goods-details";
        paraMap.put("version","v1.2.3");
        paraMap.put("appKey",dtkAppKey);
        paraMap.put("id","");
        paraMap.put("goodsId",id);
        paraMap.put("sign", SignMD5Util.getSignStr(paraMap,dtkAppSecret));
        String str_detail=HttpUtils.sendGet(url,paraMap);
//        System.err.println(JSONObject.parseObject(str_detail));
        if(JSONObject.parseObject(str_detail).get("code").toString().equals("400")){
            return ResponseUtil.fail(JSONObject.parseObject(str_detail).get("msg").toString());
        }

        JSONObject jsonObjects = JSONObject.parseObject(JSONObject.parseObject(str_detail).get("data").toString());
        log.info("=================jsonObjects============="+jsonObjects);
        WaresDetail waresDetail = new WaresDetail();
        waresDetail.setTitle((String) jsonObjects.get("title"));
        waresDetail.setPict_url((String) jsonObjects.get("mainPic"));
        waresDetail.setReserve_price((Number) jsonObjects.get("originalPrice"));
        waresDetail.setZk_final_price((Number) jsonObjects.get("actualPrice"));
//        waresDetail.setSmall_images((String[]) jsonObjects.get("detailPics"));
        JSONArray jsonArray =null;
        if(JSONArray.parseArray(jsonObjects.get("detailPics").toString())!=null){
            jsonArray = JSONArray.parseArray(jsonObjects.get("detailPics").toString());
        }else {
            waresDetail.setSmall_images(jsonObjects.get("imgs").toString().split(","));
        }
        if(jsonArray!=null){
            int size = jsonArray.size();
            String[] arr = new String[size];
            for(int i = 0; i < jsonArray.size(); i++) {
                JSONObject obj = jsonArray.getJSONObject(i);
                String ig = (String)obj.get("img");
                String substring = ig.substring(0, 4);
                String img = "";
                if(substring.equals("http")){
                    img = (String)obj.get("img");
                }else{
                    img ="http:"+obj.get("img");
                }
                arr[i] =img;
            }
            waresDetail.setSmall_images(arr);
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Object couponStartTime1 = jsonObjects.get("couponStartTime");
        if("".equals(couponStartTime1)){
            waresDetail.setCouponStartTime(dateFormat.format(new Date()));
            waresDetail.setCouponEndTime(dateFormat.format(new Date()));
        }else{
            waresDetail.setCouponStartTime(dateFormat.format(dateFormat.parse((String)jsonObjects.get("couponStartTime"))));
            waresDetail.setCouponEndTime(dateFormat.format(dateFormat.parse((String) jsonObjects.get("couponEndTime"))));
        }
        //佣金 已经
        double yongjin = waresDetail.getZk_final_price().doubleValue() * Double.parseDouble(jsonObjects.get("commissionRate").toString())/100;
        BigDecimal pv=null;//新增pv值  pv=佣金=养老金
        BigDecimal yanglaojin=null; //养老金=pv
        BigDecimal yongjin_obj=new BigDecimal(yongjin).setScale(2,BigDecimal.ROUND_HALF_UP);
//        BigDecimal yongjin_bb=yongjin_obj.setScale(2,BigDecimal.ROUND_HALF_UP);
//        pv=yongjin_obj.multiply(BigDecimal.valueOf(0.5)).setScale(2,BigDecimal.ROUND_HALF_UP);//四舍五入
//        yanglaojin=pv;//四舍五入
        String valueStr=systemConfigValueDao.selectConfigValueByKey("sanfangfenpei");
        JSONObject jsonObjectValue= JSONObject.parseObject(valueStr);
        BigDecimal fenPV=new BigDecimal(jsonObjectValue.get("pv")+"");
        BigDecimal fenyanglaojin=new BigDecimal(jsonObjectValue.get("yanglaojin")+"");
        pv=yongjin_obj.multiply(fenPV).setScale(2,BigDecimal.ROUND_HALF_UP);//四舍五入
        yanglaojin=yongjin_obj.multiply(fenyanglaojin).setScale(2,BigDecimal.ROUND_HALF_UP);//四舍五入;//四舍五入

        waresDetail.setYanglao(yanglaojin);
        waresDetail.setGongxian(pv);
        waresDetail.setJifen(pv);
        waresDetail.setPv(pv);
        log.info("=================jsonObjects============="+data.toString());


        data.put("waresDetail",waresDetail);
        return ResponseUtil.ok(data);
    }

    /**
     * 高效转链
     * @param
     * @param
     * @throws
     * @throws IOException
     */
    public Object dtkchangeLink(String id, String uid) {
        Map<String,Object> data=new HashMap<String,Object>();
        /**
         * 判断该用户是否已经授权淘宝  rrx_user_third
         */
        String type = "5";
        //changeLink(id,"");
        Map<String,Object> dtkchangeLink = null;
        String channelId = userThirdDao.selectPidByUidType(uid,type);
        log.info("channerId=="+channelId);
        if(channelId != null){
            //高效转链
            TreeMap<String,String> paraMap = new TreeMap<>();
            String url = dtkHost+"/api/tb-service/get-privilege-link";
            paraMap.put("version","v1.3.1");
            paraMap.put("appKey",dtkAppKey);
            paraMap.put("goodsId",id);
            paraMap.put("pid",pid);//推广位置ID
            paraMap.put("channelId",channelId);//数据库的pid
            paraMap.put("sign", SignMD5Util.getSignStr(paraMap,dtkAppSecret));
            String sendGet = HttpUtils.sendGet(url, paraMap);
            System.out.println(sendGet);
            JSONObject returnObjects = JSONObject.parseObject(JSONObject.parseObject(sendGet).toString());
            if(returnObjects.get("msg").equals("根据联盟政策要求，不允许数字id转链，请使用新商品id")){
                return ResponseUtil.fail("该商品已下架或不存在~");
            }
            JSONObject jsonObjects = JSONObject.parseObject(JSONObject.parseObject(sendGet).get("data").toString());
            Raw raw = new Raw();
            raw.setCouponEndTime((String) jsonObjects.get("couponEndTime"));
            raw.setCouponInfo((String) jsonObjects.get("couponInfo"));
            raw.setCouponStartTime((String) jsonObjects.get("couponStartTime"));
            raw.setLongTpwd((String) jsonObjects.get("longTpwd"));
            raw.setTpwd((String) jsonObjects.get("tpwd"));
            data.put("link", jsonObjects.get("shortUrl"));
            data.put("code",1);
        }else{
            //走淘宝获取pid接口  https://oauth.taobao.com/authorize?response_type=code&client_id=CLIENTID&redirect_uri=REDIRECTURI&state=STATE&view=web
            String link = tbHost.replace("CLIENTID",tbAppKey).replace("REDIRECTURI",redirecturi).replace("STATE",uid);
            data.put("link",link);
            data.put("code",0);
        }
        return ResponseUtil.ok(data);
    }

    @Override
    public void getTaobaoAuthorizedLoginToken(String code, String state) throws IOException {
        Map<String, String> params = new HashMap<String, String>();
        // 公共参数
        params.put("method", "taobao.top.auth.token.create");
        params.put("app_key", tbAppKey);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        params.put("timestamp", df.format(new Date()));
        params.put("format", "json");
        params.put("v", "2.0");
        params.put("sign_method", "hmac");
        params.put("code", code);
        params.put("sign", SignTop.signTopRequest(params, tbkAppSecret, "hmac"));
        String a = SignTop.callApi(new URL("https://eco.taobao.com/router/rest"), params);
        JSONObject jsonObjects = JSONObject.parseObject(a);
        Object token = JSONObject.parseObject(JSONObject.parseObject(jsonObjects.get("top_auth_token_create_response").toString()).get("token_result").toString()).get("access_token");
        //备案
        demo(token.toString(),state);
    }
    //备案
    private void demo(String token,String state) throws IOException {
        Map<String, String> params = new HashMap<String, String>();
        // 公共参数
        params.put("method", "taobao.tbk.sc.publisher.info.save");
        params.put("app_key", tbAppKey);
        params.put("session", token);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        params.put("timestamp", df.format(new Date()));
        params.put("format", "json");
        params.put("v", "2.0");
        params.put("sign_method","hmac");
        // 业务参数
        params.put("inviter_code","E7LRL8");
        params.put("info_type","1");
        params.put("note","储_"+state);
        // 签名参数
        params.put("sign", SignTop.signTopRequest(params, tbkAppSecret, "hmac"));
        // 请用API
        System.out.println(params.toString());
        String callApi = SignTop.callApi(new URL("https://eco.taobao.com/router/rest"), params);
        JSONObject jsonObjects = JSONObject.parseObject(callApi);
        String data = JSONObject.parseObject(jsonObjects.get("tbk_sc_publisher_info_save_response").toString()).get("data").toString();
        Object account_name = JSONObject.parseObject(data).get("account_name");
        Object relation_id = JSONObject.parseObject(data).get("relation_id");
        UserThird userThird = new UserThird();
        userThird.setUid(state);
        userThird.setPid(relation_id.toString());
        userThird.setPid_name(account_name.toString());
        userThird.setCreate_time(new Date().getTime()+"");
        userThird.setType("5");
        userThirdDao.inster(userThird);
        System.out.println(jsonObjects);
        //return s;

    }

    /**
     * 淘宝的商品列表and淘宝的商品收缩列表
     * @param
     * @param
     * @throws
     * @throws
     */
    public Object selectWaresList(String pageNum, String pageSize,String keyWords) throws IOException {
        Map<String, String> params = new HashMap<String, String>();
        // 公共参数
        params.put("method", "taobao.tbk.dg.material.optional");
        params.put("app_key", tbAppKey);
        //params.put("session", "");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        params.put("timestamp", df.format(new Date()));
        params.put("format", "json");
        params.put("v", "2.0");
        params.put("sign_method", "hmac");
        // 业务参数
        params.put("adzone_id",adzoneId);
        params.put("page_no",pageNum);
        params.put("page_size",pageSize);
        params.put("cat","16");
        params.put("platform","2");
        // 签名参数
        params.put("sign", SignTop.signTopRequest(params, tbkAppSecret, "hmac"));
        String a = SignTop.callApi(new URL("https://eco.taobao.com/router/rest"), params);
        JSONObject jsonObjects = JSONObject.parseObject(a);
        System.out.println(jsonObjects);

        //String demo = demo(o.toString(),state);
        return null;
    }

    /**
     * 淘宝的商品详情
     * @param id
     * @param goodsId
     * @param uid
     * @return
     */
    @Override
    public Object selectWaresDetail(String id, String goodsId, String uid) throws IOException {
        Map<String, String> params = new HashMap<String, String>();
        // 公共参数
        params.put("method", "taobao.tbk.item.info.get");
        params.put("app_key", tbAppKey);
        //params.put("session", "");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        params.put("timestamp", df.format(new Date()));
        params.put("format", "json");
        params.put("v", "2.0");
        params.put("sign_method", "hmac");
        // 业务参数
        params.put("num_iids",id);
        params.put("platform","2");
        // 签名参数
        params.put("sign", SignTop.signTopRequest(params, tbkAppSecret, "hmac"));
        String a = SignTop.callApi(new URL("https://eco.taobao.com/router/rest"), params);
        JSONObject jsonObjects = JSONObject.parseObject(a);
        System.out.println(jsonObjects);
        changeLink(uid,id);
        return null;
    }

    /**
     * 获取商品的返利信息更具uid查询pid
     */
    public void changeLink(String uid,String id) throws IOException {
        Map<String, String> params = new HashMap<String, String>();
        // 公共参数
        params.put("method", "taobao.tbk.item.convert");
        params.put("app_key", tbAppKey);
        //params.put("session", "");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        params.put("timestamp", df.format(new Date()));
        params.put("format", "json");
        params.put("v", "2.0");
        params.put("sign_method", "hmac");
        // 业务参数
        params.put("fields","num_iid,click_url");
        params.put("num_iids",id);
        params.put("adzone_id","2674884996");//数据库中的pid
        params.put("platform","2");
        // 签名参数
        params.put("sign", SignTop.signTopRequest(params, tbkAppSecret, "hmac"));
        String a = SignTop.callApi(new URL("https://eco.taobao.com/router/rest"), params);
        JSONObject jsonObjects = JSONObject.parseObject(a);
        System.out.println(jsonObjects);
    }




}
