where(['id'=>intval($express_id)])->value('name'); } /** * 快递列表 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2018-09-19 * @desc description * @param [array] $params [输入参数] */ public static function ExpressList($params = []) { $where = []; if(isset($params['is_enable'])) { $where['is_enable'] = intval($params['is_enable']); } $data = Db::name('Express')->where($where)->field('id,icon,name,sort,is_enable')->order('sort asc')->select(); if(!empty($data) && is_array($data)) { foreach($data as &$v) { $v['icon_old'] = $v['icon']; $v['icon'] = ResourcesService::AttachmentPathViewHandle($v['icon']); } } return $data; } /** * 获取快递节点数据 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2018-12-16T23:54:46+0800 * @param [array] $params [输入参数] */ public static function ExpressNodeSon($params = []) { // id $id = isset($params['id']) ? intval($params['id']) : 0; // 获取数据 $field = 'id,pid,icon,name,sort,is_enable'; $data = Db::name('Express')->field($field)->where(['pid'=>$id])->order('sort asc')->select(); if(!empty($data)) { foreach($data as &$v) { $v['is_son'] = (Db::name('Express')->where(['pid'=>$v['id']])->count() > 0) ? 'ok' : 'no'; $v['ajax_url'] = MyUrl('admin/express/getnodeson', array('id'=>$v['id'])); $v['delete_url'] = MyUrl('admin/express/delete'); $v['icon_url'] = ResourcesService::AttachmentPathViewHandle($v['icon']); $v['json'] = json_encode($v); } return DataReturn('操作成功', 0, $data); } return DataReturn('没有相关数据', -100); } /** * 快递保存 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2018-12-17T01:04:03+0800 * @param [array] $params [输入参数] */ public static function ExpressSave($params = []) { // 请求参数 $p = [ [ 'checked_type' => 'length', 'key_name' => 'name', 'checked_data' => '2,16', 'error_msg' => '名称格式 2~16 个字符', ], ]; $ret = ParamsChecked($params, $p); if($ret !== true) { return DataReturn($ret, -1); } // 其它附件 $data_fields = ['icon']; $attachment = ResourcesService::AttachmentParams($params, $data_fields); if($attachment['code'] != 0) { return $attachment; } // 数据 $data = [ 'name' => $params['name'], 'pid' => isset($params['pid']) ? intval($params['pid']) : 0, 'sort' => isset($params['sort']) ? intval($params['sort']) : 0, 'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0, 'icon' => $attachment['data']['icon'], ]; // 添加 if(empty($params['id'])) { $data['add_time'] = time(); if(Db::name('Express')->insertGetId($data) > 0) { return DataReturn('添加成功', 0); } return DataReturn('添加失败', -100); } else { $data['upd_time'] = time(); if(Db::name('Express')->where(['id'=>intval($params['id'])])->update($data)) { return DataReturn('编辑成功', 0); } return DataReturn('编辑失败', -100); } } /** * 快递删除 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2018-12-17T02:40:29+0800 * @param [array] $params [输入参数] */ public static function ExpressDelete($params = []) { // 请求参数 $p = [ [ 'checked_type' => 'empty', 'key_name' => 'id', 'error_msg' => '删除数据id有误', ], [ 'checked_type' => 'empty', 'key_name' => 'admin', 'error_msg' => '用户信息有误', ], ]; $ret = ParamsChecked($params, $p); if($ret !== true) { return DataReturn($ret, -1); } // 开始删除 if(Db::name('Express')->where(['id'=>intval($params['id'])])->delete()) { return DataReturn('删除成功', 0); } return DataReturn('删除失败', -100); } } ?>