PHP | <?php
require_once("../WdtClient.php");
$c = new WdtClient;
$c->sid = '';
$c->appkey = '';
$c->appsecret = '';
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/purchase_order_push.php';
$purchase_info = array (
"provider_no" => "2",
"warehouse_no" =>"001",
"outer_no" =>"ghsnsfs01nn",
"is_use_outer_no" =>"0",
"is_check" =>"1",
"contact" =>"旺旺旺",
"telno" =>"1333333333",
"receive_address" =>"天博中润掌上先机",
"logistics_type" =>"4",
"other_fee" =>"100.01",
"post_fee" =>"100.02",
"remark" =>"API测试",
"details_list" => array(
array(
"spec_no" =>"NESTX0002003",
"num" =>1,
"price" =>"10.11",
"discount" =>"10.22",
"tax" =>"0.2",
"remark" =>"API测试",
"prop1" =>"011",
"prop2" =>"022"
)
)
);
$c->putApiParam('purchase_info', json_encode($purchase_info, JSON_UNESCAPED_UNICODE));
$json = $c->wdtOpenApi();
var_dump($json);
?> |
JAVA | package com.wangdian.api.purchase;
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 PurchaseOrderPush {
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> purchase_info = new HashMap<String, Object>();
List<Map<String, Object>> details_list = new ArrayList<Map<String, Object>>();
Map<String, Object> detail_1 = new HashMap<String, Object>();
detail_1.put("spec_no", "qqq");
detail_1.put("num", "2");
detail_1.put("price", 1);
detail_1.put("discount", 2);
detail_1.put("tax", "0.1");
detail_1.put("tax_price", "1.2");
detail_1.put("remark", "API测试");
detail_1.put("prop1", "011");
detail_1.put("prop2", "022");
details_list.add(detail_1);
purchase_info.put("provider_no", "001");
purchase_info.put("warehouse_no", "aiyi2test");
purchase_info.put("outer_no", "ghs2018121001");
purchase_info.put("is_check", "1");
purchase_info.put("contact", "啊啊啊");
purchase_info.put("details_list", details_list);
String purchase_info_json = JSON.toJSONString(purchase_info);
//System.out.println(purchase_info_json);
Map<String, String> params = new HashMap<String, String>();
params.put("purchase_info", purchase_info_json);
try {
String response = client.execute("purchase_order_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 PurchaseOrderPush
{
class PurchaseOrderPush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/purchase_order_push.php";
var purchase_info = new
{
provider_no = "wl00001",
warehouse_no = "001",
outer_no = "34567876543234",
is_use_outer_no = "0",
is_check = "1",
contact = "旺旺",
telno = "1333333333",
receive_address = "天博中润",
logistics_type = "4",
other_fee = "100.01",
post_fee = "100.02",
remark = "测试",
details_list = new[]
{
new
{
spec_no ="1001017308AYS2S",
num ="1",
price ="10.11",
discount ="10.22",
tax ="0.2",
remark ="API测试",
prop1 ="011",
prop2 ="022"
},
new
{
spec_no ="sku002",
num ="1",
price ="10.11",
discount ="10.22",
tax ="0.2",
remark ="API测试",
prop1 ="011",
prop2 ="022"
},
}
};
string json = purchase_info.ToJsonString();
client.putParams("purchase_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/')
purchase_info = {}
details_list = []
details_1 = {}
details_1.update({"spec_no": 'spec_001'})
details_1.update({"spec_code": '12345'})
details_1.update({"barcode": '12345678'})
details_1.update({"spec_name": '规格名称'})
details_1.update({"spec_unit_name": '基本单位'})
details_1.update({"lowest_price": '最低价'})
details_1.update({"retail_price": '零售价'})
details_1.update({"wholesale_price": '批发价'})
details_1.update({"member_price": '会员价'})
details_1.update({"market_price": '市场价'})
details_1.update({"spec_remark": '备注'})
details_list.append(details_1)
purchase_info.update({"provider_no": '001'})
purchase_info.update({"warehouse_no": 'test001'})
purchase_info.update({"outer_no": 'test001'})
purchase_info.update({"is_use_outer_no": '0'})
purchase_info.update({"is_check": '0'})
purchase_info.update({"contact": '收件人姓名'})
purchase_info.update({"purchase_name": '采购员名称'})
purchase_info.update({"telno": '收件人联系电话'})
purchase_info.update({"receive_address": '收货地址'})
purchase_info.update({"other_fee": ''})
purchase_info.update({"post_fee": ''})
purchase_info.update({"remark": '采购单备注'})
purchase_info.update({"prop1": '自定义属性1'})
purchase_info.update({"prop2": '自定义属性2'})
purchase_info.update({"details_list": details_list})
# del(purchase_info[0])
jsonArr = json.dumps(purchase_info, ensure_ascii=False)
params = {}
params.update({"purchase_info": jsonArr})
response = t.execute("purchase_order_push.php", params)
print(response) |