口腔客户管理系统
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. class Examine extends BaseController
  5. {
  6. protected $noNeedLogin = [''];
  7. protected $noSize = ['*'];
  8. protected $noSecure = [//格式:'请求方式' => ['请求方法' => ['字段1','字段2'],],
  9. // 'post' => ['add' => ['data']]
  10. ];
  11. // public function read()
  12. // {
  13. // try {
  14. // $Examine_model = new \app\admin\model\Examine();
  15. // $result = $Examine_model->read($_GET);
  16. // tojson(200, '请求成功', $result);
  17. // } catch (\Exception $e) {
  18. // tojson(10000, $e->getMessage());
  19. // } catch (\Throwable $e) {
  20. // tojson(10000, $e->getMessage());
  21. // }
  22. // }
  23. public function getAll()
  24. {
  25. try {
  26. $Examine_model = new \app\admin\model\Examine();
  27. $result = $Examine_model->getAll($_GET, $this->request->page, $this->request->pageSize);
  28. tojson(200, '请求成功', $result);
  29. } catch (\Exception $e) {
  30. tojson(10000, $e->getMessage());
  31. } catch (\Throwable $e) {
  32. tojson(10000, $e->getMessage());
  33. }
  34. }
  35. public function save()
  36. {
  37. try {
  38. $Collection_model = new \app\admin\model\Collection();
  39. $check = $Collection_model->where($Collection_model->getPk(), $_POST['collection_id'])->field('appoint_id,customer_id')->find();
  40. if (!$check) {
  41. tojson(10000, '记录不存在');
  42. }
  43. if ($_POST['status'] == 1) {
  44. if (!isset($_POST['reason']) || empty($_POST['reason'])) {
  45. tojson(10000, 'reason不存在');
  46. }
  47. }
  48. $_POST['user_id'] = $this->userInfo['id'];
  49. $Examine_model = new \app\admin\model\Examine();
  50. $_POST = array_merge($check->toArray(), $_POST);
  51. $check = $Examine_model->where('collection_id', $_POST['collection_id'])->value($Examine_model->getPk());
  52. if ($check) {
  53. $result = $Examine_model->save($_POST, ['collection_id' => $_POST['collection_id']]);
  54. } else {
  55. $result = $Examine_model->save($_POST);
  56. }
  57. if ($result) {
  58. tojson(200, '添加成功');
  59. } else {
  60. tojson(10000, '添加失败');
  61. }
  62. } catch (\Exception $e) {
  63. tojson(10000, $e->getMessage());
  64. } catch (\Throwable $e) {
  65. tojson(10000, $e->getMessage());
  66. }
  67. }
  68. public function update()
  69. {
  70. try {
  71. $Examine_model = new \app\admin\model\Examine();
  72. $check = $Examine_model->where('collection_id', $this->param['collection_id'])->value($Examine_model->getPk());
  73. if (!$check) {
  74. tojson(10000, '记录不存在');
  75. }
  76. if ($this->param['status'] == 1) {
  77. if (!isset($this->param['reason']) || empty($this->param['reason'])) {
  78. tojson(10000, 'reason不存在');
  79. }
  80. }
  81. $this->param['user_id'] = $this->userInfo['id'];
  82. unset($this->param['appoint_id']);
  83. unset($this->param['customer_id']);
  84. unset($this->param['id']);
  85. $result = $Examine_model->save($this->param, [$Examine_model->getPk() => $this->param['collection_id']]);
  86. if ($result) {
  87. tojson(200, '修改成功');
  88. } else {
  89. tojson(10000, '修改失败');
  90. }
  91. } catch (\Exception $e) {
  92. tojson(10000, $e->getMessage());
  93. } catch (\Throwable $e) {
  94. tojson(10000, $e->getMessage());
  95. }
  96. }
  97. // public function delete()
  98. // {
  99. // try {
  100. // $Examine_model = new \app\admin\model\Examine();
  101. // $check = $Examine_model->where($Examine_model->getPk(), $this->param[$Examine_model->getPk()])->value($Examine_model->getPk());
  102. // if (!$check) {
  103. // tojson(10000, '记录不存在');
  104. // }
  105. // $result = $Examine_model->where($Examine_model->getPk(), $this->param[$Examine_model->getPk()])->delete();
  106. // if ($result) {
  107. // tojson(200, '删除成功');
  108. // } else {
  109. // tojson(10000, '删除失败');
  110. // }
  111. // } catch (\Exception $e) {
  112. // tojson(10000, $e->getMessage());
  113. // } catch (\Throwable $e) {
  114. // tojson(10000, $e->getMessage());
  115. // }
  116. // }
  117. }