跳转到内容
返回官网

创建运费模板

一、请求参数

请求URL:

POST https://kf.fw199.com/gateway/dd/freighttemplate/create

公共参数

参数名称参数类型是否必须示例值参数描述
appidString合作伙伴AppId
timestampString1657525936当前Unix时间戳,秒
seller_nickString38173182抖店的账号,对应蜂巢授权返回doudianseller字段
signString

业务参数

参数名称参数类型是否必须示例值参数描述
+templateStruct-运费模板信息
- template_nameString测试运费模板模板名称
- product_provinceInt6432发货省份id
- product_cityInt64320100发货城市id
- calculate_typeInt641计价方式: 1.按重量 2.按数量;模板类型为1、2、3时,计价类型传2
- transfer_typeInt641快递方式: 1.快递 目前仅支持1
- rule_typeInt640模板类型: 0.阶梯计价 1.固定运费 2.卖家包邮 3.货到付款
- fixed_amountInt641固定运费金额(单位:分) 固定运费模板必填 1-9900之间的整数
+columnsList-运费模板规则信息;每种类型模板可创建的规则类型: 阶梯计价模板-默认规则,普通计价规则,包邮规则,限运规则;固定运费模板-包邮规则,限运规则;固定运费模板-包邮规则,限运规则;包邮模板-限运规则;货到付款模板-限运规则
- first_weightDouble0.1首重(单位:kg) 按重量计价必填 0.1-999.9之间的小数,小数点后一位
- first_weight_priceDouble0.01首重价格(单位:元) 按重量计价必填 0.00-100.00之间的小数,小数点后两位
- first_numInt641首件数量(单位:个) 按数量计价必填 1-999的整数
- first_num_priceDouble0.01首件价格(单位:元)按数量计价必填 0.00-100.00之间的小数,小数点后两位
- add_weightDouble0.1续重(单位:kg) 按重量计价必填 0.1-999.9之间的小数,小数点后一位
- add_weight_priceDouble0.01续重价格(单位:元) 按重量计价必填 0.00-100.00之间的小数,小数点后两位
- add_numInt641续件(单位:个) 按数量计价必填 1-999的整数
- add_num_priceDouble0.01续件价格(单位:元) 按数量计价必填 0.00-100.00之间的小数,小数点后两位
- is_defaultInt641是否默认计价方式(1:是;0:不是)
- is_limitedBoolfalse是否限运规则
- rule_addressString{“11”:…}当前规则生效的地址,非默认规则必填。map<i64, map<i64, map<i64, list>>>的json格式,省->市->区->街道,填至选择到的层级即可,仅限售规则支持四级街道
- is_over_freeBoolfalse是否包邮规则
- over_weightDouble0.1满xx重量包邮(单位:kg)0.1-10.0之间的小数,小数点后一位
- over_amountInt6410满xx金额包邮(单位:分)10-99900的整数
- over_numInt641满xx件包邮 1-10之间的整数
- min_sku_amountInt64100最小金额限制,单位分,不限制填-1
- max_sku_amountInt64500最大金额限制,单位分,不限制填-1
-+ province_infosList-当前规则生效的地址,统一以List结构返回,该结构为嵌套结构。对应的json格式为[{“id”:”32”,”children”:[{“id”:”320500”,”children”:[{“id”:”320508”,”children”:[{“id”:”320508014”},{“id”:”320508004”}]}]}]}] 注意:返回的为最新的四级地址版本(地址存储升级变更的可能,以最新的返回)
- - idInt6422地址id,第一级是省份、第二级是城市、第三级是区、第四级是街道
- -+ childrenList-下一级地址信息
— idInt642222地址id,第一级是省份、第二级是城市、第三级是区、第四级是街道
—+ childrenList-下一级地址信息
—- idInt6422222地址id,第一级是省份、第二级是城市、第三级是区、第四级是街道
—-+ childrenList-下一级地址信息
—– idInt64222222地址id,第一级是省份、第二级是城市、第三级是区、第四级是街道

二、请求示例代码

Java

请求示例代码

@Test
public void DDReightTemplateCreate() throws Exception {
Map<String, Object> data = new HashMap<String, Object>();
data.put("appid", Config.AppId);
Long timestamp = System.currentTimeMillis() / 1000;
data.put("timestamp", timestamp.toString());
data.put("seller_nick", Config.DDSellerNick);
data.put("template", "{\n" +
" \"template_name\": \"测试运费模板123\",\n" +
" \"product_province\": \"32\",\n" +
" \"product_city\": \"320100\",\n" +
" \"calculate_type\": \"2\",\n" +
" \"transfer_type\": \"1\",\n" +
" \"rule_type\": \"1\",\n" +
" \"fixed_amount\": \"1\"\n" +
" }");
// data.put("columns", "[\n" +
// " {\n" +
// " \"first_weight\": \"0.1\",\n" +
// " \"first_weight_price\": \"0.01\",\n" +
// " \"first_num\": \"1\",\n" +
// " \"first_num_price\": \"0.01\",\n" +
// " \"add_weight\": \"0.1\",\n" +
// " \"add_weight_price\": \"0.01\",\n" +
// " \"add_num\": \"1\",\n" +
// " \"add_num_price\": \"0.01\",\n" +
// " \"is_default\": \"1\",\n" +
// " \"is_limited\": \"false\",\n" +
// " \"rule_address\": \"{\\\"11\\\":{\\\"110000\\\":{\\\"110114\\\":[110114116,110114007]}}}\",\n" +
// " \"is_over_free\": \"false\",\n" +
// " \"over_weight\": \"0.1\",\n" +
// " \"over_amount\": \"10\",\n" +
// " \"over_num\": \"1\",\n" +
// " \"min_sku_amount\": \"100\",\n" +
// " \"max_sku_amount\": \"500\",\n" +
// " \"province_infos\": [\n" +
// " {\n" +
// " \"id\": \"22\",\n" +
// " \"children\": [\n" +
// " {\n" +
// " \"id\": \"2222\",\n" +
// " \"children\": [\n" +
// " {\n" +
// " \"id\": \"22222\",\n" +
// " \"children\": [\n" +
// " {\n" +
// " \"id\": \"222222\"\n" +
// " }\n" +
// " ]\n" +
// " }\n" +
// " ]\n" +
// " }\n" +
// " ]\n" +
// " }\n" +
// " ]\n" +
// " }\n" +
// " ]");
data.put("sign", Sign(data,Config.AppSecret));
// 调用服务API
String resp = doHttpRequest(Config.DDFreightTemplateCreate, data);
System.out.println(resp);
}

template 对象

{
"template_name": "测试运费模板123",
"product_province": "32",
"product_city": "320100",
"calculate_type": "2",
"transfer_type": "1",
"rule_type": "1",
"fixed_amount": "1"
}

columns 对象

[
{
"first_weight": "0.1",
"first_weight_price": "0.01",
"first_num": "1",
"first_num_price": "0.01",
"add_weight": "0.1",
"add_weight_price": "0.01",
"add_num": "1",
"add_num_price": "0.01",
"is_default": "1",
"is_limited": "false",
"rule_address": {"11":{"110000":{"110114":[110114116,110114007]}}},
"is_over_free": "false",
"over_weight": "0.1",
"over_amount": "10",
"over_num": "1",
"min_sku_amount": "100",
"max_sku_amount": "500",
"province_infos": [
{
"id": "22",
"children": [
{
"id": "2222",
"children": [
{
"id": "22222",
"children": [
{
"id": "222222"
}
]
}
]
}
]
}
]
}
]

三、返回结果

{"code":0,"message":"ok","data":{"template_id":372559970}}

说明: code为0表示成功,非0为失败,message会包含失败原因。返回字段说明见文档 https://op.jinritemai.com/docs/api-docs/16/1661