java sdk使用及下载

 

   Java接口调用方式:使用提供的b2b2c-java-sdk.jar,进行接口调用,具体调用例子见各接口描述。sdk依赖以下jar包,请导入到项目依赖中。sdk最新版本下载

如果使用maven添加如下项目依赖

  <properties>

      <httpcomponents-core.version>4.0.1</httpcomponents-core.version>

       <httpcomponents-client.version>4.0.1</httpcomponents-client.version>

      <log4j.version>1.2.16</log4j.version>

      <commons-logging.version>1.1.1</commons-logging.version>

       <alibaba-fastjson.version>1.1.15</alibaba-fastjson.version>

      </properties>

  <dependencies>

      <dependency>

         <groupId>commons-logging</groupId>

         <artifactId>commons-logging</artifactId>

         <version>${commons-logging.version}</version>

      </dependency>

     

      <dependency>

         <groupId>org.apache.httpcomponents</groupId>

         <artifactId>httpcomponents-core</artifactId>

         <version>${httpcomponents-core.version}</version>

      </dependency>

     

      <dependency>

         <groupId>org.apache.httpcomponents</groupId>

         <artifactId>httpcomponents-client</artifactId>

         <version>${httpcomponents-client.version}</version>

      </dependency>

     

      <dependency>

         <groupId>com.alibaba</groupId>

         <artifactId>fastjson</artifactId>

         <version>${alibaba-fastjson.version}</version>

      </dependency>

     

      <dependency>

         <groupId>log4j</groupId>

         <artifactId>log4j</artifactId>

         <version>${log4j.version}</version>

      </dependency>

   </dependencies>

 

    商品信息查询接口sdk调用示例如下,其他接口调用见b2b2c接口列表-具体接口

    //DefaultClient请使用单例

    DefaultClient client = new          DefaultClient("http://119.97.231.228:2010/b2b2c/rest","10000003","aadfaadjfweoizmkjagaiangnajglaagadgd","TEST");

   ProductInfoQueryRequest productInfoQueryRequest = new ProductInfoQueryRequest();
      productInfoQueryRequest.setFields("productBasicInfo,tabDetail,productAttribute,productPicList");
   productInfoQueryRequest.setPageSize(20);
   productInfoQueryRequest.setPageIndex(1);
   productInfoQueryRequest.setUpdateTime(1403511166000L);
   ProductInfoQueryResponse productInfoQueryResponse =          client.execute(productInfoQueryRequest);
 
 

可下单参数:

{"trade":{"invoiceTitleType":0,"isNeedInvoice":0,"receiver":{"address":"浦东大道48","city":"上海市","county":"浦东新区","mobile":"XXXXXXX","name":"XXX","phone":"XXXXXX","province":"上海"},"tradeItemList":[{"discountFee":0,"itemId":"1945","num":1,"price":62.32,"totalFee":62.32,"yhdProductId":1945},{"discountFee":0,"itemId":"1976","num":1,"price":2.49,"totalFee":2.49,"yhdProductId":1976},{"discountFee":0,"itemId":"2945","num":1,"price":10.00,"totalFee":10.00,"yhdProductId":2945}]}}

 

拆单参数:

"trade":{"invoiceContent":"纽海信息技术(上海)有限公司","invoiceName":"zhangsan","orderDiscount":7,"paymentAmount":22,"productAmount":20,"receiver":{"address":"浦东大道","city":"上海市","cityId":100000,"county":"浦东新区","countyId":100044,"id":10000,"mobile":"18087895621","name":"zhangsan","phone":"010-51680666","province":"上海","provinceId":100000,"userNo":"18087895621"},"thirdOrderCode":"TEST1111","tradeItemList":[{"discountFee":0,"itemId":"item11","num":1,"outerCode":"","price":18.00,"skuId":"","totalFee":18.00,"yhdProductId":30892},{"discountFee":0,"itemId":"item12","num":1,"outerCode":"","price":7.5,"skuId":"","totalFee":7.5,"yhdProductId":23728},{"discountFee":0,"itemId":"item13","num":1,"outerCode":"","price":18.80,"skuId":"","totalFee":18.80,"yhdProductId":1799723}]}

 

拆单有运费参数:

{"trade":{"invoiceTitleType":0,"isNeedInvoice":0,"receiver":{"address":"Shanghai","city":"上海市","county":"黄浦区","id":10000,"mobile":"","name":"zhangsan","phone":"13131313131","province":"上海"},"tradeItemList":[{"discountFee":0,"itemId":"","num":1,"outerCode":"","price":18.0,"skuId":"","totalFee":18.0,"yhdProductId":30892},{"discountFee":0,"itemId":"","num":1,"outerCode":"","price":28.62,"skuId":"","totalFee":28.62,"yhdProductId":29396}]}}

 

测试环境有图片商品ID:2945

提示

关闭