PHP | <?php
require_once '../WdtClient.php';
$c = new WdtClient();
$c->sid = '';
$c->appkey = '';
$c->appsecret = '';
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/stockin_refund_push.php';
$stockin_refund_info = array (
"refund_no" => "TK1608030001",
"outer_no" => "ghs",
"warehouse_no" => "xy001",
"logistics_code" => "yjwl04",
"detail_list" => array( array(
"spec_no" => "33412",
"stockin_num" => 2,
"batch_no" => "20160601",
"stockin_price" => "0.01"
)
)
);
$c->putApiParam('stockin_refund_info', json_encode($stockin_refund_info, JSON_UNESCAPED_UNICODE));
$json = $c->wdtOpenApi();
var_dump($json);
?> |
JAVA | package com.wangdian.api.refund;
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 StockinRefundPush {
@SuppressWarnings("unchecked")
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> stockin_refund_info = new HashMap<String, Object>();
List<Map<String, Object>> detail_list = new ArrayList<Map<String, Object>>();
Map<String, Object> detail_1 = new HashMap<String, Object>();
detail_1.put("spec_no", "ghs201812070212123");
detail_1.put("stockin_num", 2);
detail_1.put("stockin_price", 0.01);
detail_list.add(detail_1);
stockin_refund_info.put("refund_no", "TK1812110002");
stockin_refund_info.put("outer_no","gjs1121");
stockin_refund_info.put("warehouse_no", "ghs2test");
stockin_refund_info.put("logistics_code", "1213");
stockin_refund_info.put("is_created_batch", 1);
stockin_refund_info.put("detail_list", detail_list);
//通过第三方json解析工具类fastjson将map解析成json
String stockin_refund_info_json = JSON.toJSONString(stockin_refund_info);
//System.out.println(goods_list_json);
Map<String, String> params = new HashMap<String, String>();
params.put("stockin_refund_info", stockin_refund_info_json);
try {
String response = client.execute("stockin_refund_push.php", params);
System.out.println(response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WdtSdk;
namespace StockinRefundPush
{
class StockinRefundPush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/stockin_refund_push.php";
var stockin_refund_info = new
{
refund_no = "TK1901090001",
outer_no = "234567898765432",
warehouse_no = "api_test",
logistics_code = "SMWL001",
logistics_no = "6787654321234",
detail_list = new[]
{
new{
spec_no = "6521478635",
stockin_num = "1",
stockin_price = "11.11",
}
}
};
string json = stockin_refund_info.ToJsonString();
client.putParams("stockin_refund_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/')
stockin_refund_info = {}
detail_list = []
order_1 = {}
order_1.update({"spec_no": 'test001'})
order_1.update({"position_no": ''})
order_1.update({"batch_no": '批次号'})
order_1.update({"batch_remark": '批次备注'})
order_1.update({"stockin_num": '入库数量'})
order_1.update({"stockin_price": '单价'})
order_1.update({"production_date": '2021-01-01 00:00:00'})
order_1.update({"expire_date": '2021-01-02 00:00:00'})
order_1.update({"tax": ''})
order_1.update({"remark": '备注'})
order_1.update({"is_enable_sn": '0'})
order_1.update({"sn_list": ''})
detail_list.append(order_1)
refund_1 = {}
refund_1.update({"refund_no": 'TK001'})
refund_1.update({"outer_no": '12345678'})
refund_1.update({"warehouse_no": 'ceshi2'})
refund_1.update({"logistics_no": '物流单号'})
refund_1.update({"logistics_code": '物流公司编号'})
refund_1.update({"post_fee": '邮费'})
refund_1.update({"other_fee": '其他费用'})
refund_1.update({"is_check": '1'})
refund_1.update({"is_create_batch": '0'})
refund_1.update({"remark": '备注'})
refund_1.update({"detail_list": detail_list})
stockin_refund_info.append(refund_1)
# del(stockin_refund_info[0])
jsonArr = json.dumps(stockin_refund_info, ensure_ascii=False)
params = {}
params.update({"stockin_refund_info": jsonArr})
response = t.execute("stockin_refund_push.php", params)
print(response) |