企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 获取唯一码商品的库存状态 **位置:** Common\Common\function.php **参数:** * @param int $status 库存状态 * @param int $type 是否HTML样式 默认1是,2否 **调用:** > Controller 控制器调用: > get_inventory ($goods['inventory_status']) > View 模版调用: > {$goods['inventory_status']|get_inventory} **完整代码:** ~~~ /** * 获取唯一码商品的库存状态 * jig 2018-07-25 * * @param int $status 库存状态 * @param int $type 是否HTML样式 默认1是,2否 * * @return string */ function get_inventory ($status, $type = 1) { switch ($status) { case 0: echo $type == 1 ? '<span class="label label-danger">不可售</span>' : '不可售'; break; case 1: echo $type == 1 ? '<span class="label label-info">可销售</span>' : '可销售'; break; case 2: echo $type == 1 ? '<span class="label label-info">门店可售</span>' : '门店可售'; break; case 3: echo $type == 1 ? '<span class="label label-info">网店可售</span>' : '网店可售'; break; case 4: echo $type == 1 ? '<span class="label label-success">已销售</span>' : '已销售'; break; case 5: echo $type == 1 ? '<span class="label label-warning">已下架</span>' : '已下架'; break; case 6: echo $type == 1 ? '<span class="label label-warning">已锁库</span>' : '已锁库'; break; default: echo $type == 1 ? '<span class="label label-default">未知数</span>' : '未知数'; } } ~~~