| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use \think\Request;
- use \think\Db;
- /**
- * 客户管理接口
- */
- class Custom extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 首页
- *
- */
- public function index()
- {
- $this->success('请求成功');
- }
- /**
- * 获取客户信息
- *
- * @ApiMethod GET
- *
- */
- public function getCustom(){
- if (Request::instance()->isGet() == false){
- $this->error('非法请求');
- }
- $field = 'rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称';
- $list = Db::name('产品_基本资料')->distinct(true)->field($field)->order('客户编号 asc')->select();
- $this->success('请求成功',$list);
- }
- /**
- * 客户资料管理
- *
- * @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 = '供应商';
- }
- $limit = $params['limit'];
- if (empty($limit)){
- $limit = 15;
- }
- $pages = $params['page'];
- if (empty($pages)){
- $pages = 1;
- }
- $where['类型'] = $class;
- $field = 'rtrim(编号) as 编号,rtrim(名称) as 名称,rtrim(简称) as 简称,rtrim(地址) as 地址,rtrim(联系人),rtrim(电话),业务员,rtrim(币种) as 币种,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqId';
- $list = Db::name('erp_客户供应商')->where($where)->field($field)->limit($limit)->page($pages)->select();
- $total = Db::name('erp_客户供应商')->where($where)->count();
- $data['data'] = $list;
- $data['total'] = $total;
- $this->success('请求成功',$data);
- }
- }
|