当前位置: API文档

sales_refund_push.php(创建原始退款单)

¥标准

1.接口说明

1.1 接口描述:销售订单(包括发货前和发货后)退款或退货单据推送至ERP。注:销售订单的售后换货订单此接口推送“退货类型”退款单,换出订单“trade_push.php”推送  
1.2 适用版本:客户端 V2.4.5.0及以上版本            
1.3 调用建议:批量推送的退款单据,每次不超过10单

1.4 注意事项:推送的原始退款单对应的销售订单必须在旺店通ERP内已经存在,否则无法生成系统售后单并进行处理。 注:仅支持自有/其他平台店铺     

2.调用场景

   2.1 自研商城、分销系统、全渠道等系统对接

3.请求参数说明

   3.1 请求地址

环境HTTP地址
测试环境https://sandbox.wangdian.cn/openapi2/sales_refund_push.php
正式环境https://api.wangdian.cn/openapi2/sales_refund_push.php

   3.2 公共请求参数

名称字段类型长度
必须描述
卖家账号sidString
购买ERP时由旺店通分配给ERP购买方,请从ERP购买方获取。
接口账号appkeyString
本开放平台“自助对接”功能模块内自助申请,获取方式点击这里
时间戳timestampint
北京时间1970-01-01 08:00:00起至现在的总秒数,10位int值,旺店通企业版API服务端允许请求最大时间误差为5min,date.timezone = Asia/Shanghai。
签名signString
API输入参数签名结果,签名算法介绍单击这里

   3.3 业务请求参数

名称字段类型长度
必须描述
退款单节点api_refund_listdata[ ]
请求参数的1级数据节点,包含平台售后订单所有属性信息的数据节点,节点下数据字段详见下述“api_refund_list”

    api_refund_list

名称字段
类型长度
必须描述
平台IDplatform_idsmallint6
输入固定值127
店铺编号shop_novarchar
代表店铺所有属性的唯一编码,用于店铺区分,ERP内支持自定义(ERP店铺界面设置),用于推送指定店铺原始退款单据信息
平台销售订单号tidvarchar
平台订单单号(与推送trade_push的tid保持一致,对应旺店通ERP内原始单号)
平台退款/退货单号
refund_novarchar40平台退款/退货单单号,保证唯一
平台售后类型typeint
type=1:退款(未发货退款);type=2:退款不退货;type=3:退货
平台售后状态statusvarchar

可选值:wait_seller_agree(申请退款),  seller_refuse(拒绝退款) , closed(退款关闭) ,goods_returning(待退货) goods_receiving(待收货),success(退款成功)

退款金额refund_feedecimal19,4退款金额
买家昵称buyer_nickvarchar100买家昵称(不传该字段,默认取原始订单上客户网名)
单据创建时间refund_timedatetime
单据创建时间,时间格式:yyyy-MM-dd HH:mm:ss
退款原因reasonvarchar255退款原因
备注descvarchar255备注
物流单号
logistics_novarchar40物流单号(如需维护退货物流单号,与logistics_name物流公司名称同时使用)
物流公司名称logistics_namevarchar40物流公司名称
售后子订单order_listdata[]
售后子订单

   order_list

名称字段类型长度必须描述
平台订单子订单编号oidvarchar40平台订单子订单编号(与推送trade_push的oid保持一致,对应旺店通ERP内原始子订单编号)可推送部分子订单
退货货品数量numdecimal(19,4)退货货品数量(如果是type=1 退款   2 退款不退货类型,此处代表退款数量)


4.响应参数

   4.1 公共响应参数

名称字段
类型长度
必须描述
错误码
codeint
返回码,0成功,非0失败
错误信息messagevarchar
返回信息
新增条数
new_countint
新增条数
更新条数chg_countint
更新条数

   4.2 业务响应参数


5.请求示例

PHP
<?php
    require_once("../WdtClient.php");
    $c = new WdtClient;
    $c->sid = '';
    $c->appkey = '';
    $c->appsecret = '';
    $c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/sales_refund_push.php';

    $api_refund_list = array( array(
            "tid" => "test00053120009-3",
            "shop_no" => "api_test",
            "platform_id" => 127,
            "refund_no" => "6",
            "type" => "2",
            "status" => "success",
            "refund_fee" => "",
            "alipay_no" => "mytest",
            "buyer_nick" => "",
            "refund_time" => "2023-04-12 16:24:08",
            "reason" => "测试者",
            "desc" => "北京",
            "refund_version" => "北京市",
            "order_list" => array(
                array(
                    "oid" => "test0005-01-03",
                    "num" => 2
                )
            )
        )
    );

    $c->putApiParam('api_refund_list',json_encode($api_refund_list,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 SalesRefundPush {

    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>> api_refund_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", "AD201812110009");
        order_1.put("num", "1");
        order_list.add(order_1);
        
        Map<String, Object> api_refund_1 = new HashMap<String, Object>();
        api_refund_1.put("tid", "AT201812110001");
        api_refund_1.put("platform_id", "127");
        api_refund_1.put("shop_no", "ghs2test");
        api_refund_1.put("refund_no", "sgsh1221g124");
        api_refund_1.put("type", 3);
        api_refund_1.put("status", "success");
        api_refund_1.put("buyer_nick", "ghs");
        api_refund_1.put("refund_time", "2023-04-12 16:24:08");
        api_refund_1.put("order_list", order_list);
        

        api_refund_list.add(api_refund_1);
        
        String api_refund_list_json = JSON.toJSONString(api_refund_list);
        //System.out.println(purchase_info_json);
        
        Map<String, String> params = new HashMap<String, String>();
        params.put("api_refund_list", api_refund_list_json);
        try {
            String response = client.execute("sales_refund_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 salesRefundPush
{
    class salesRefundPush
    {
        static void Main(string[] args)
        {
            WdtClient client = new WdtClient();
            client.sid = "";
            client.appkey = "";
            client.appsecret = "";
            client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/sales_refund_push.php";

           var api_refund_list = new[]
            {
                new
                {
                    platform_id="127",
                    shop_no="api_test",
                    tid="202202070001",
                     refund_no="202202070001",
                     type="1",
                     status="success",
                     refund_time="2023-04-12 16:24:08",
                     buyer_nick="1",
                     type="1",
                    order_list=new[]
                    {
                        new
                        {
                            oid="-1",
                            num= "1"
                        }
 
                    }
                }
            };
             
            string json = api_refund_list.ToJsonString();
            client.putParams("api_refund_list", 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/')
api_refund_list = []
order_list = []
order_1 = {}
order_1.update({"oid": 'ghsTest121101'})
order_1.update({"num": 1})
order_list.append(order_1)
refund_1 = {}
refund_1.update({"platform_id": '127'})
refund_1.update({"shop_no": 'test2-ot'})
refund_1.update({"tid": '12345678'})
refund_1.update({"refund_no": '12345678'})
refund_1.update({"type": '3'})
refund_1.update({"status": 'goods_returning'})
refund_1.update({"refund_fee": '10'})
refund_1.update({"buyer_nick": 'ceshi'})
refund_1.update({"refund_time": '2021-01-01 00:00:00'})
refund_1.update({"reason": '退款原因'})
refund_1.update({"desc": '备注'})
refund_1.update({"logistics_no": '物流单号'})
refund_1.update({"logistics_name": '物流公司名称'})
refund_1.update({"order_list": order_list})
api_refund_list.append(refund_1)
# del(api_refund_list[0])
jsonArr = json.dumps(api_refund_list, ensure_ascii=False)
params = {}
params.update({"api_refund_list": jsonArr})
response = t.execute("sales_refund_push.php", params)
print(response)

6.响应示例

   6.1 正常响应示例 

JSON
           
{
    'code': 0,
    'message': "OK",
}
           

   6.2 异常响应示例

JSON
           
{
    "code": 1007,
    "message": "接口appkey已停用【解决办法:联系商务人员,重新开启接口appkey】 "
}
           



常用工具