PHP | <?php
require_once ('../WdtClient.php');
$c = new WdtClient();
$c->sid = '';
$c->appkey = '';
$c->appsecret = '';
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/stock_transfer_push.php';
$transfer_info = array (
'outer_no' => 'ghs_001',
'from_warehouse_no' => '001',
'to_warehouse_no' => '001',
'skus' => array (
array (
'spec_no' => 'NESTX0002003',
'num' => '1'
)
)
);
$c->putApiParam('transfer_info', json_encode($transfer_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 StockTransferPush {
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> transfer_info = new HashMap<String, Object>();
List<Map<String, Object>> skus = new ArrayList<Map<String, Object>>();
Map<String, Object> sku_1 = new HashMap<String, Object>();
sku_1.put("spec_no", "ghs201812070212123");
sku_1.put("num", "1");
skus.add(sku_1);
transfer_info.put("from_warehouse_no", "ghs2test");
transfer_info.put("to_warehouse_no", "lx2test");
transfer_info.put("outer_no", "ghs201812101205");
transfer_info.put("skus", skus);
String transfer_info_json = JSON.toJSONString(transfer_info);
//System.out.println(purchase_info_json);
Map<String, String> params = new HashMap<String, String>();
params.put("transfer_info", transfer_info_json);
try {
String response = client.execute("stock_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 StockTransferPush
{
class StockTransferPush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/stock_transfer_push.php";
var transfer_info = new
{
outer_no = "5678765432345",
from_warehouse_no = "api_test",
to_warehouse_no = "wh002",
skus = new[]
{
new{
spec_no = "test-ptsd-00002",
num = "1"
},
new{
spec_no = "test-ptsd-00001",
num = "1"
}
}
};
string json = transfer_info.ToJsonString();
client.putParams("transfer_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/')
transfer_info = {}
skus = []
skus_1 = {}
skus_1.update({"spec_no": 'spec_001'})
skus_1.update({"from_position_no": ''})
skus_1.update({"to_position_no": ''})
skus_1.update({"num": '5'})
skus_1.update({"remark": '备注'})
skus.append(skus_1)
transfer_info.update({"outer_no": '12345678'})
transfer_info.update({"from_warehouse_no": '001'})
transfer_info.update({"to_warehouse_no": '002'})
transfer_info.update({"address": ''})
transfer_info.update({"contact": ''})
transfer_info.update({"telno": ''})
transfer_info.update({"remark": '备注'})
transfer_info.update({"transfer_type": '1'})
transfer_info.update({"mode": '0'})
transfer_info.update({"autocheck": '0'})
transfer_info.update({"skus": skus})
# del(transfer_info[0])
jsonArr = json.dumps(transfer_info, ensure_ascii=False)
params = {}
params.update({"transfer_info": jsonArr})
response = t.execute("stock_transfer_push.php", params)
print(response) |