企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 商品 #### 发布与编辑商品接口 > 调用该接口前,请确保发布商品的店铺可以正常发布商品。发布商品前店铺需要设置售卖区域,运费模板,如果有规格的话需要编辑规格值。 ``` <pre class="calibre14">``` 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 ( ) ) ``` ``` ``` <pre class="calibre14">``` $fenxiao <span class="token">=</span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">3.00</span> <span class="token5">//一级佣金比例</span> <span class="token1">[</span><span class="token6">1</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">2.00</span> <span class="token5">//二级佣金比例</span> <span class="token1">[</span><span class="token6">2</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">1.00</span> <span class="token5">//三级佣金比例</span> <span class="token1">)</span> $property <span class="token">=</span> Array <span class="token1">(</span> <span class="token1">[</span>property_151<span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> 测试属性<span class="token6">1</span> <span class="token5">//属性名称</span> <span class="token1">[</span><span class="token6">1</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">390</span> <span class="token5">//属性值id</span> <span class="token1">[</span><span class="token6">2</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> select <span class="token5">//显示类型</span> <span class="token1">[</span><span class="token6">3</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">151</span> <span class="token5">//属性id</span> <span class="token1">)</span> <span class="token1">)</span> $spec_name <span class="token">=</span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">10</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> 测试规格<span class="token6">1</span> <span class="token5">//主键为规格id,值为规格名称</span> <span class="token1">[</span><span class="token6">11</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> 测试规格<span class="token6">2</span> <span class="token1">)</span> $spec_val <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">10</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token5">//主键为规格id</span> <span class="token1">(</span> <span class="token1">[</span><span class="token6">45</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> S <span class="token5">//主键为规格值id,值为规格值名称</span> <span class="token1">[</span><span class="token6">46</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> M <span class="token1">)</span> <span class="token1">[</span><span class="token6">11</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">47</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">10</span> <span class="token1">)</span> <span class="token1">)</span> $spec <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>i_4547<span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token5">//主键为'i_'拼接规格值id,规格值id由小到大排序</span> <span class="token1">(</span> <span class="token1">[</span>goods_id<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>sp_value<span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">45</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> S <span class="token5">//主键为规格值id,值为规格值名称</span> <span class="token1">[</span><span class="token6">47</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">10</span> <span class="token1">)</span> <span class="token1">[</span>market_price<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">200.3</span> <span class="token5">//市场价</span> <span class="token1">[</span>price<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">152.3</span> <span class="token5">//商品价格</span> <span class="token1">[</span>stock<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">1000</span> <span class="token5">//库存</span> <span class="token1">[</span>alarm<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">10</span> <span class="token5">//库存预警值</span> <span class="token1">[</span>sku<span class="token1">]</span> <span class="token">=</span><span class="token">></span> A001 <span class="token5">//商家货号</span> <span class="token1">)</span> <span class="token1">[</span>i_4647<span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>goods_id<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>sp_value<span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">46</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> M <span class="token1">[</span><span class="token6">47</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">10</span> <span class="token1">)</span> <span class="token1">[</span>market_price<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">200.3</span> <span class="token1">[</span>price<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">152.3</span> <span class="token1">[</span>stock<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">2000</span> <span class="token1">[</span>alarm<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">20</span> <span class="token1">[</span>sku<span class="token1">]</span> <span class="token">=</span><span class="token">></span> A002 <span class="token1">)</span> <span class="token1">)</span> $sgcate_id <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">2</span> <span class="token5">//店铺分类id</span> <span class="token1">)</span> ``` ``` #### 编辑图片 ``` <pre class="calibre14">``` 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":[ ] } ``` ``` ``` <pre class="calibre15">``` <span class="token">~</span><span class="token">~</span><span class="token">~</span> $image <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">53</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token5">//有颜色规格则主键为颜色规格id ,没有颜色规格则主键为0</span> <span class="token1">(</span> <span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> http<span class="token1">:</span><span class="token">/</span><span class="token">/</span>localhost<span class="token">/</span>bbc<span class="token">/</span>shop<span class="token">/</span>image<span class="token1">.</span>php<span class="token">/</span>shop<span class="token">/</span>data<span class="token">/</span>upload<span class="token">/</span>media<span class="token">/</span><span class="token6">421</span>aa90e079fa326b6494f812ad13e79<span class="token">/</span><span class="token6">10018</span><span class="token">/</span><span class="token6">4</span><span class="token">/</span>image<span class="token">/</span><span class="token6">20190419</span><span class="token">/</span><span class="token6">1555661347887530.</span>png <span class="token5">//图片地址</span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">1</span> <span class="token5">//默认主题,1是,0否</span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token5">//排序</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">1</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">2</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">3</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">4</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">165</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> http<span class="token1">:</span><span class="token">/</span><span class="token">/</span>localhost<span class="token">/</span>bbc<span class="token">/</span>shop<span class="token">/</span>image<span class="token1">.</span>php<span class="token">/</span>shop<span class="token">/</span>data<span class="token">/</span>upload<span class="token">/</span>media<span class="token">/</span><span class="token6">421</span>aa90e079fa326b6494f812ad13e79<span class="token">/</span><span class="token6">10018</span><span class="token">/</span><span class="token6">4</span><span class="token">/</span>image<span class="token">/</span><span class="token6">20190507</span><span class="token">/</span><span class="token6">1557208836124082.</span>png <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">1</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> http<span class="token1">:</span><span class="token">/</span><span class="token">/</span>localhost<span class="token">/</span>bbc_jiheng<span class="token">/</span>shop<span class="token">/</span>image<span class="token1">.</span>php<span class="token">/</span>shop<span class="token">/</span>data<span class="token">/</span>upload<span class="token">/</span>media<span class="token">/</span><span class="token6">421</span>aa90e079fa326b6494f812ad13e79<span class="token">/</span><span class="token6">10018</span><span class="token">/</span><span class="token6">4</span><span class="token">/</span>image<span class="token">/</span><span class="token6">20190507</span><span class="token">/</span><span class="token6">1557208894771000.</span>png <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">2</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">3</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">[</span><span class="token6">4</span><span class="token1">]</span> <span class="token">=</span><span class="token">></span> Array <span class="token1">(</span> <span class="token1">[</span>name<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>default<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token1">[</span>displayorder<span class="token1">]</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span> <span class="token1">)</span> <span class="token1">)</span> <span class="token1">)</span> <span class="token">~</span><span class="token">~</span><span class="token">~</span> ``` ```