PHP | <?php
require_once ('../WdtClient.php');
$c = new WdtClient();
$c->sid = '';
$c->appkey = '';
$c->appsecret = '';
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/stockout_transfer_push.php';
$stockout_info = array (
'src_order_no' => 'TF201809030011',
'warehouse_no' => 'xy001',
'goods_list' => array (
array (
'spec_no' => 'test-ptsd-00001',
'num' => '1'
)
)
);
$c->putApiParam('stockout_info', json_encode($stockout_info, JSON_UNESCAPED_UNICODE));
$json = $c->wdtOpenApi();
var_dump($json);
?> |
JAVA | package com.wangdian.api.stock;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.wangdian.api.WdtClient;
public class StockoutTransferPush {
public static void main(String[] args) {
// TODO Auto-generated method stub
WdtClient client = new WdtClient("传入sid", "传入appkey", "传入appsecret", "传入url");
//测试环境sid、appkey、密钥请到旺店通开放平台-自助对接-申请测试环境内查看,测试环境url=https://sandbox.wangdian.cn/openapi2/
//调用正式环境时请将sid、appkey、appsecret切换为实际参数,参数在旺店通开放平台-自助对接-应用管理内应用状态为已上线的应用中查看,调用正式环境注意切换正式环境url=https://api.wangdian.cn/openapi2/
Map<String, Object> stockout_info = new HashMap<String, Object>();
List<Map<String, Object>> goods_list = new ArrayList<Map<String, Object>>();
Map<String, Object> goods_1 = new HashMap<String, Object>();
goods_1.put("spec_no", "ghs201812070212123");
goods_1.put("num", "1");
goods_list.add(goods_1);
stockout_info.put("warehouse_no", "ghs2test");
stockout_info.put("src_order_no", "TF201812110002");
stockout_info.put("goods_list", goods_list);
String stockout_info_json = JSON.toJSONString(stockout_info);
Map<String, String> params = new HashMap<String, String>();
params.put("stockout_info", stockout_info_json);
try {
String response = client.execute("stockout_transfer_push.php", params);
System.out.println(response);
} catch (IOException e) {
e.printStackTrace();
}
}
} |
C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WdtSdk;
namespace StockoutTransferPush
{
class StockoutTransferPush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/stockout_transfer_push.php";
var stockout_info = new
{
src_order_no = "TF201901170004",
warehouse_no = "api_test",
goods_list = new[]
{
new{
spec_no = "test-ptsd-00002",
num = "1"
},
new{
spec_no = "test-ptsd-00001",
num = "1"
}
}
};
string json = stockout_info.ToJsonString();
client.putParams("stockout_info", json);
string result = client.wdtOpenapi();
Console.WriteLine(result);
Console.ReadKey();
}
}
} |
python
| import WdtClient
import json
t = WdtClient.WdtClient('appkey', 'appsecret', 'sid', 'http://sandbox.wangdian.cn/openapi2/')
stockout_info = {}
goods_list = []
goods_1 = {}
goods_1.update({"spec_no": 'spec_001'})
goods_1.update({"is_enable_sn": '0'})
goods_1.update({"sn_list": ''})
goods_1.update({"num": '5'})
goods_1.update({"remark": '备注'})
goods_list.append(goods_1)
stockout_info.update({"src_order_no": '12345678'})
stockout_info.update({"is_check": '0'})
stockout_info.update({"warehouse_no": '001'})
stockout_info.update({"logistics_code": ''})
stockout_info.update({"logistics_no": ''})
stockout_info.update({"post_cost": ''})
stockout_info.update({"remark": ''})
stockout_info.update({"flag_name": ''})
stockout_info.update({"goods_list": goods_list})
# del(stockout_info[0])
jsonArr = json.dumps(stockout_info, ensure_ascii=False)
params = {}
params.update({"stockout_info": jsonArr})
response = t.execute("stockout_transfer_push.php", params)
print(response) |