success('请求成功'); } /** * 获取客户信息 * * @ApiMethod GET * */ public function getCustom(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $field = 'rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称'; $list = db('产品_基本资料')->where('客户名称','not null')->distinct(true)->field($field)->order('客户编号 asc')->select(); $Ydata = []; $Jdata = []; foreach ($list as $key => $value){ if (substr($value['客户编号'],0,1) == 'Y'){ array_push($Ydata,$value); }else{ array_push($Jdata,$value); } } $data['印刷产品'] = $Ydata; $data['糊盒产品'] = $Jdata; $this->success('请求成功',$data); } /** * 客户资料管理 * * @ApiMethod GET * */ public function getCustomInfo(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); if (!isset($params['class'])){ $this->error('参数错误'); } $class = ''; if ($params['class'] == 1){ $class = '客户'; }else{ $class = '供应商'; } $search = $params['search']; $limit = $params['limit']; if (empty($limit)){ $limit = 15; } $pages = $params['page']; if (empty($pages)){ $pages = 1; } $where['类型'] = $class; if (!empty($search)){ $where['编号|名称|地址|联系人|业务员'] = array('like','%'.$search.'%'); } $field = 'rtrim(编号) as 编号,rtrim(名称) as 名称,rtrim(简称) as 简称,rtrim(地址) as 地址,rtrim(联系人) as 联系人,rtrim(电话) as 电话,业务员,rtrim(币种) as 币种,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqId'; $list = db('erp_客户供应商')->where($where)->field($field)->limit($limit)->page($pages)->select(); $total = db('erp_客户供应商')->where($where)->count(); $data['data'] = $list; $data['total'] = $total; $this->success('请求成功',$data); } /** * 供应商资料查改 * * @ApiMethod POST * @params array data */ public function edit(){ if (Request::instance()->isPost() == false){ $this->error('非法请求'); } $params = Request::instance()->post(); if (empty($params) || !isset($params['UniqId'])){ $this->error('参数不能为空'); } $data = []; if (!empty($params['code'])){ $data['编号'] = $params['code']; } if (!empty($params['name'])){ $data['名称'] = $params['name']; } if (!empty($params['refer'])){ $data['简称'] = $params['refer']; } if (!empty($params['add'])){ $data['地址'] = $params['add']; } if (!empty($params['department_code'])){ $data['对口部门'] = $params['department_code']; } if (!empty($params['contacts'])){ $data['联系人'] = $params['contacts']; } if (!empty($params['phone'])){ $data['电话'] = $params['phone']; } if (!empty($params['salesman'])){ $data['业务员'] = $params['salesman']; } if (!empty($params['currency'])){ $data['币种'] = $params['currency']; } $sql = db('erp_客户供应商')->where('UniqId',$params['UniqId'])->fetchSql(true)->update($data); $res = Db::query($sql); if ($res !== false){ $this->success('更新成功'); }else{ $this->error('更新失败'); } } }