Custom.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use \think\Request;
  5. use \think\Db;
  6. /**
  7. * 客户管理接口
  8. */
  9. class Custom extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 首页
  15. *
  16. */
  17. public function index()
  18. {
  19. $this->success('请求成功');
  20. }
  21. /**
  22. * 获取客户信息
  23. *
  24. * @ApiMethod GET
  25. *
  26. */
  27. public function getCustom(){
  28. if (Request::instance()->isGet() == false){
  29. $this->error('非法请求');
  30. }
  31. $field = 'rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称';
  32. $list = Db::name('产品_基本资料')->distinct(true)->field($field)->order('客户编号 asc')->select();
  33. $this->success('请求成功',$list);
  34. }
  35. /**
  36. * 客户资料管理
  37. *
  38. * @ApiMethod GET
  39. *
  40. */
  41. public function getCustomInfo(){
  42. if (Request::instance()->isGet() == false){
  43. $this->error('非法请求');
  44. }
  45. $params = Request::instance()->param();
  46. if (!isset($params['class'])){
  47. $this->error('参数错误');
  48. }
  49. $class = '';
  50. if ($params['class'] == 1){
  51. $class = '客户';
  52. }else{
  53. $class = '供应商';
  54. }
  55. $limit = $params['limit'];
  56. if (empty($limit)){
  57. $limit = 15;
  58. }
  59. $pages = $params['page'];
  60. if (empty($pages)){
  61. $pages = 1;
  62. }
  63. $where['类型'] = $class;
  64. $field = 'rtrim(编号) as 编号,rtrim(名称) as 名称,rtrim(简称) as 简称,rtrim(地址) as 地址,rtrim(联系人),rtrim(电话),业务员,rtrim(币种) as 币种,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqId';
  65. $list = Db::name('erp_客户供应商')->where($where)->field($field)->limit($limit)->page($pages)->select();
  66. $total = Db::name('erp_客户供应商')->where($where)->count();
  67. $data['data'] = $list;
  68. $data['total'] = $total;
  69. $this->success('请求成功',$data);
  70. }
  71. }