PHP | <?php
require_once('../WdtClient.php');
$c = new WdtClient;
$c->sid ='';
$c->appkey ='';
$c->appsecret ="";
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/trade_push.php';
$trade_list[] = array
(
'tid' => 'LxTestTid'.time(),
'trade_status' => 30,
'delivery_term' => 1,
'pay_status' => 2,
'trade_time' => '0000-00-00 00:00:00',
'pay_time' => '0000-00-00 00:00:00', // 未付款情况下为0000-00-00 00:00:00
'buyer_nick' => '',
'buyer_email' => '123456234533@mail.com',
'receiver_mobile' => '13233456110',
'receiver_telno' => '1234563567',
'receiver_zip' => '0000000',
'receiver_province'=>'北京',
'receiver_name' =>'亚历山大',
'receiver_city' =>'北京市',
'receiver_district'=>'海淀区',
'receiver_address' =>'海淀',
'logistics_type' => 4, // ems
'invoice_kind' => 0,
'invoice_title' => '',
'invoice_content' => '发票内容+',
'buyer_message' => '发最好&&&的+',
'remark' => '测试专用',
'remark_flag' => 1,
'post_amount' => 10, //邮费
'paid' => 409, //已支付金额
'cod_amount' => '0',
'ext_cod_fee' => '0',
'order_list' => array(
array
(
'oid' => 'LxTestOid'.time(),
'status' => 30,
'refund_status' => 0,
'goods_id' => 'E166D18BAAEA420CB132E105B3B6128A',
'spec_id' => '',
'goods_no' => '',
'spec_no' => '9787533951092',
'goods_name' => '情商是什么?——关于生活智慧的44个故事',
'spec_name' => '',
'num' => 1,
'price' => 399,
'adjust_amount' => '0', //手工调整,特别注意:正的表示加价,负的表示减价
'discount' => 0, //子订单折扣
'share_discount' => '0', //分摊优惠
'cid' => '13',
)
)
);
$c->putApiParam('shop_no','api_test');
$c->putApiParam('switch',0);
$c->putApiParam('trade_list',json_encode($trade_list, JSON_UNESCAPED_UNICODE));
$json = $c->wdtOpenApi();
var_dump($json);
?> |
JAVA | package com.wangdian.api.trade;
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 TradePush {
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/
List<Map<String, Object>> trade_list = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> order_list = new ArrayList<Map<String, Object>>();
Map<String, Object> order_1 = new HashMap<String, Object>();
order_1.put("oid", "ghsTest121101");
order_1.put("num", 1);
order_1.put("price", 12);
order_1.put("status", 30);
order_1.put("refund_status", 0);
order_1.put("goods_id", "18344");
order_1.put("spec_id", "18656");
order_1.put("goods_no", "ghs2");
order_1.put("spec_no", "ghs201812070212123");
order_1.put("goods_name", "123");
order_1.put("discount", 0); //子订单折扣
order_1.put("adjust_amount", 0); //手工调整,特别注意:正的表示加价,负的表示减价
order_1.put("share_discount", 0);
order_list.add(order_1);
Map<String, Object> trade_1 = new HashMap<String, Object>();
trade_1.put("tid", "AT201812110002");
trade_1.put("trade_status", 20);
trade_1.put("pay_status", "1");
trade_1.put("delivery_term", 2);
trade_1.put("trade_time", "2018-12-11 14:21:00");
trade_1.put("buyer_nick", "三国杀");
trade_1.put("receiver_province", "河南省");
trade_1.put("receiver_city", "周口市");
trade_1.put("receiver_district", "川汇区");
trade_1.put("receiver_mobile", "26283920011");
trade_1.put("receiver_name", "123");
trade_1.put("receiver_address", "123");
trade_1.put("logistics_type", 4);
trade_1.put("post_amount", 12);
trade_1.put("cod_amount", 2);
trade_1.put("ext_cod_fee", 0);
trade_1.put("other_amount", 1);
trade_1.put("paid", 0);
trade_1.put("order_list", order_list);
trade_list.add(trade_1);
String trade_list_json = JSON.toJSONString(trade_list);
//System.out.println(purchase_info_json);
Map<String, String> params = new HashMap<String, String>();
params.put("shop_no", "ghs2test");
params.put("trade_list", trade_list_json);
try {
String response = client.execute("trade_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 TradePush
{
class TradePush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/trade_push.php";
var trade_list = new[]
{
new
{
tid = "TestTid45235678987654",
trade_status = "30",
delivery_term = "1",
trade_time = "0000-00-00 00:00:00",
pay_time = "0000-00-00 00:00:00",
buyer_nick = "ceshi",
buyer_email = "123456234533@mail.com",
receiver_mobile = "13233456110",
receiver_telno = "1234563567",
receiver_zip = "0000000",
receiver_province= "北京",
receiver_name = "亚历山大",
receiver_city = "北京市",
receiver_district= "海淀区",
receiver_address = "乌鲁木齐市新疆乌鲁木齐市西山路82号009信箱",
logistics_type = "4",
invoice_kind = "0",
invoice_title = "",
invoice_content = "发票内容+",
buyer_message = "发最好&&&的+",
remark = "测试专用",
remark_flag = "1",
paid = "399",
post_amount = "0",
cod_amount = "0",
ext_cod_fee = "0",
order_list = new[]
{
new{
oid = "TestOid3456789876543",
status = "30",
refund_status = "0",
goods_id = "E166D18BAAEA420CB132E105B3B6128A",
spec_id = "567898765",
goods_no = "",
spec_no = "9787533951092",
goods_name = "情商是什么?——关于生活智慧的44个故事",
spec_name = "",
num = "1",
price = "399",
adjust_amount = "0",
discount = "0",
share_discount = "0",
cid = "13",
remark = "ceshiceshiceshi"
}
}
}
};
String json = trade_list.ToJsonString();
client.putParams("trade_list", json);
client.putParams("shop_no", "api_test");
client.putParams("switch", "0");
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/')
trade_list = []
order_list = []
order_1 = {}
order_1.update({"oid": 'ghsTest121101'})
order_1.update({"num": 1})
order_1.update({"price": 12})
order_1.update({"status": 30})
order_1.update({"refund_status": 0})
order_1.update({"goods_id": '18344'})
order_1.update({"spec_id": '18656'})
order_1.update({"goods_no": 'ghs2'})
order_1.update({"spec_no": 'ghs201812070212123'})
order_1.update({"goods_name": '123'})
order_1.update({"discount": 0})
order_1.update({"adjust_amount": 0})
order_1.update({"share_discount": 0})
order_list.append(order_1)
trade_1 = {}
trade_1.update({"tid": 'AT201812110002'})
trade_1.update({"trade_status": 20})
trade_1.update({"pay_status": '1'})
trade_1.update({"delivery_term": 2})
trade_1.update({"trade_time": '2018-12-11 14:21:00'})
trade_1.update({"buyer_nick": '三国杀'})
trade_1.update({"receiver_name": '亚历山大'})
trade_1.update({"receiver_province": '河南省'})
trade_1.update({"receiver_city": '周口市'})
trade_1.update({"receiver_district": '川汇区'})
trade_1.update({"receiver_address": '123'})
trade_1.update({"logistics_type": 4})
trade_1.update({"post_amount": 12})
trade_1.update({"cod_amount": 2})
trade_1.update({"ext_cod_fee": 0})
trade_1.update({"other_amount": 1})
trade_1.update({"paid": 0})
trade_1.update({"order_list": order_list})
trade_list.append(trade_1)
# del(trade_list[0])
jsonArr = json.dumps(trade_list, ensure_ascii=False)
params = {}
params.update({"shop_no": 'test111'})
params.update({"trade_list": jsonArr})
response = t.execute("trade_push.php", params)
print(response) |