多商品下单 API 接口使用指南
多商品下单入口,进入结算页,API 接口地址 https://doc.youzanyun.com/doc#/content/API/1-368/detail/api/0/480
该接口的详细使用说明如下:
DefaultYZClient yzClient = new DefaultYZClient();
TokenParameter tokenParameter = TokenParameter.self()
.clientId("")
.clientSecret("xxxx")
.grantId("4xxx267")
.refresh(true)
.build();
OAuthToken oAuthToken = yzClient.getOAuthToken(tokenParameter);
Token token = new Token( oAuthToken.getAccessToken());
System.out.println(token.getAccessToken());
// 传入参数
JSONObject jsonObject = new JSONObject();
jsonObject.put("goods_id",609186196);
jsonObject.put("num",1);
YouzanTradeBillGoodsUrlGet youzanTradeBillGoodsUrlGet = new YouzanTradeBillGoodsUrlGet();
//创建参数对象,并设置参数
YouzanTradeBillGoodsUrlGetParams youzanTradeBillGoodsUrlGetParams = new YouzanTradeBillGoodsUrlGetParams();
youzanTradeBillGoodsUrlGetParams.setKdtId(4xxxx267L);
youzanTradeBillGoodsUrlGetParams.setOrderFrom("cart");
youzanTradeBillGoodsUrlGetParams.setOrderType(0);
System.out.println(jsonObject.toJSONString());
JSONArray jsonArray = new JSONArray();
jsonArray.add(jsonObject);
youzanTradeBillGoodsUrlGetParams.setItemList(jsonArray.toJSONString());
youzanTradeBillGoodsUrlGet.setAPIParams(youzanTradeBillGoodsUrlGetParams);
YouzanTradeBillGoodsUrlGetResult result = yzClient.invoke(youzanTradeBillGoodsUrlGet, token, YouzanTradeBillGoodsUrlGetResult.class);
JSONObject jsonObject1 = JSON.parseObject(JSON.toJSONString(result.getData()));
System.out.println(jsonObject1);
说明:
-
如果 token 没有 refresh 参数,则需要更新 SDK,参考文档 https://doc.youzanyun.com/doc#/content/27032/27651
-
传入的参数是可选的,比如 sku 信息,如果没有可以不传
- 该接口需要在有赞云后台类目能力 中去申请