ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### 发布与编辑商品接口 >[warning]调用该接口前,请确保发布商品的店铺可以正常发布商品。发布商品前店铺需要设置售卖区域,运费模板,如果有规格的话需要编辑规格值。 ~~~[api] get:/index.php?ctl=Api_Goods_Goods&met=AddOrEditGoodsApi&typ=json int:common_id#商品common_id。发布商品不用填写,编辑商品需要填写 string:name#商品名称 row:spec#规格商品信息 string:code#商家货号 string:action#发布商品不用传值,编辑时传值为‘edit’ int:shop_id#店铺id int:cat_id#商品分类id row:sgcate_id#店铺分类 string:cat_name#商品分类名称,需要完整分类等级,例如“一级类目 > 二级分类 > 三级分类” int:brand_id#品牌id string:promotion_tips#副标题 string:imagePath#商品主图 string:viedoPath#商品视频 float:price#商品价格,精确到两位小数 float:market_price#市场价格 float:coet_price#成本价格 int:stock#商品库存 int:alarm#库存预警值 int:formatid_top#顶部关联版式 int:formatid_bottom#底部关联版式 float:cubage=1#商品重量,默认为1 int:is_return#7天无理由退货 1-退货 0-不退 string:service#售后服务 string:packing_list#包装清单 int:state=1#商品状态,0下架,1正常,10违规(禁售) string:is_recommend#是否推荐 1-不推荐 2-推荐 row:property#商品属性 string:spec_name#规格名称 int:transport_area_id#选择售卖区域id int:is_gv#是否是虚拟商品,0-不是 1-是 int:g_vindate#虚拟商品有效期(2019-04-24) int:g_vinvalidrefund#支持过期退款 0-不支持 1-支持 string:starttime#定期发布商品(年-月-日) string:hour#定时发布商品-时 string:minute#定时发布商品-分 row:spec_val#规格值 string:body#内容详情 int:is_limit#商品是否限购 #0-不限购 row:fenxiao#分销分佣比例 <<< success Array ( [cmd_id] => -140 [status] => 200 [msg] => success [data] => Array ( [common_id] => 43 //新增成功后的商品common_id ) ) <<< error Array ( [cmd_id] => -140 [status] => 250 [msg] => '含有违禁词' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '商品发布数量超出平台限制!' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '市场价不能低于供货价格' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '市场价不能低于商品价格' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '售后服务信息最多输入200个字符' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '售卖区域有误' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '请设置售卖区域' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '请设置运费模板' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '发布时间不能小于当前时间' [data] => Array ( ) ) Array ( [cmd_id] => -140 [status] => 250 [msg] => '最高零售价格不能低于最低零售价格' [data] => Array ( ) ) ~~~ ``` $fenxiao = Array ( [0] => 3.00 //一级佣金比例 [1] => 2.00 //二级佣金比例 [2] => 1.00 //三级佣金比例 ) $property = Array ( [property_151] => Array ( [0] => 测试属性1 //属性名称 [1] => 390 //属性值id [2] => select //显示类型 [3] => 151 //属性id ) ) $spec_name = Array ( [10] => 测试规格1 //主键为规格id,值为规格名称 [11] => 测试规格2 ) $spec_val => Array ( [10] => Array //主键为规格id ( [45] => S //主键为规格值id,值为规格值名称 [46] => M ) [11] => Array ( [47] => 10 ) ) $spec => Array ( [i_4547] => Array //主键为'i_'拼接规格值id,规格值id由小到大排序 ( [goods_id] => [sp_value] => Array ( [45] => S //主键为规格值id,值为规格值名称 [47] => 10 ) [market_price] => 200.3 //市场价 [price] => 152.3 //商品价格 [stock] => 1000 //库存 [alarm] => 10 //库存预警值 [sku] => A001 //商家货号 ) [i_4647] => Array ( [goods_id] => [sp_value] => Array ( [46] => M [47] => 10 ) [market_price] => 200.3 [price] => 152.3 [stock] => 2000 [alarm] => 20 [sku] => A002 ) ) $sgcate_id => Array ( [0] => 2 //店铺分类id ) ``` #### 编辑图片 ~~~[api] get:/index.php?ctl=Api_Goods_Goods&met=saveGoodsImage&typ=json *int:common_id#商品common_id *row:image#商品图片信息 int:is_color#是否含有颜色规格 1-有,不含有颜色规格不传值 <<< success {     "cmd_id":-140,     "status":200,     "msg":"success",     "data":[         [             {                 "name":"[http://localhost/bbc/shop/image.php/shop/data/upload/media/421aa90e079fa326b6494f812ad13e79/10018/4/image/20190419/1555661347887530.png]", //图片地址                 "default":"1", //默认主题,1是,0否                 "displayorder":"0" //排序             },             {                 "name":"",                 "default":"",                 "displayorder":"0"             },             {                 "name":"",                 "default":"",                 "displayorder":"0"             },             {                 "name":"",                 "default":"",                 "displayorder":"0"             },             {                 "name":"",                 "default":"",                 "displayorder":"0"             }         ]     ] } <<< error {     "cmd_id":-140,     "status":250,     "msg":"缺少common_id",     "data":[ ] } {     "cmd_id":-140,     "status":250,     "msg":"缺少图片信息",     "data":[ ] } ~~~ ``` ~~~ $image => Array ( [53] => Array //有颜色规格则主键为颜色规格id ,没有颜色规格则主键为0 ( [0] => Array ( [name] => http://localhost/bbc/shop/image.php/shop/data/upload/media/421aa90e079fa326b6494f812ad13e79/10018/4/image/20190419/1555661347887530.png //图片地址 [default] => 1 //默认主题,1是,0否 [displayorder] => 0 //排序 ) [1] => Array ( [name] => [default] => 0 [displayorder] => 0 ) [2] => Array ( [name] => [default] => 0 [displayorder] => 0 ) [3] => Array ( [name] => [default] => 0 [displayorder] => 0 ) [4] => Array ( [name] => [default] => 0 [displayorder] => 0 ) ) [165] => Array ( [0] => Array ( [name] => http://localhost/bbc/shop/image.php/shop/data/upload/media/421aa90e079fa326b6494f812ad13e79/10018/4/image/20190507/1557208836124082.png [default] => [displayorder] => 0 ) [1] => Array ( [name] => http://localhost/bbc_jiheng/shop/image.php/shop/data/upload/media/421aa90e079fa326b6494f812ad13e79/10018/4/image/20190507/1557208894771000.png [default] => [displayorder] => 0 ) [2] => Array ( [name] => [default] => [displayorder] => 0 ) [3] => Array ( [name] => [default] => [displayorder] => 0 ) [4] => Array ( [name] => [default] => [displayorder] => 0 ) ) ) ~~~ ```