Salesman.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace app\admin\controller\medical;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\medical\SalesmanServer;
  5. class Salesman extends BaseController
  6. {
  7. /**
  8. * Notes:获取预约服务业务员列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/9/27
  12. */
  13. public function getSalesmanList()
  14. {
  15. [$page,$limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = SalesmanServer::getSalesmanList($page,$limit,$keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:修改业务员
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/9/27
  25. */
  26. public function updateSalesman()
  27. {
  28. $salesman_id = $this->request->post('salesman_id');
  29. $salesman_shop_id = $this->request->post('salesman_shop_id','');
  30. $salesman_name = $this->request->post('salesman_name','');
  31. $salesman_pwd = $this->request->post('salesman_pwd','');
  32. $again_salesman_pwd = $this->request->post('again_salesman_pwd','');
  33. $salesman_phone = $this->request->post('salesman_phone','');
  34. $salesman_resale_name = $this->request->post('salesman_resale_name','');
  35. $salesman_status = $this->request->post('salesman_status','');
  36. if (!empty($salesman_pwd) && !empty($again_salesman_pwd)){
  37. $salf = $this->passwordSalf(6);
  38. $salesman_pwd = md5(sha1($salesman_pwd.$salf));
  39. }elseif (!empty($salesman_pwd) && empty($again_salesman_pwd)){
  40. throw new \Exception('请输入确认密码!');
  41. }elseif (empty($salesman_pwd) && !empty($again_salesman_pwd)){
  42. throw new \Exception('请输入密码!');
  43. }
  44. $admin_id = $this->request->admin_id;
  45. $this->validateCheck('medical\SalesmanValidate', ['salesman_id'=>$salesman_id], 'update');
  46. $result = SalesmanServer::updateSalesman($salesman_id, $salesman_shop_id, $salesman_name, $salesman_pwd, $salesman_phone, $salesman_resale_name, $salesman_status, $salf, $admin_id);
  47. return json_success($result, '修改成功');
  48. }
  49. /**
  50. * Notes:删除业务员
  51. * @return \support\Response
  52. * User: ZQ
  53. * Date: 2022/9/27
  54. */
  55. public function delSalesman()
  56. {
  57. $salesman_id = $this->request->get('salesman_id');
  58. $admin_id = $this->request->admin_id;
  59. $this->validateCheck('medical\SalesmanValidate', ['salesman_id' => $salesman_id], 'info');
  60. $result = SalesmanServer::delSalesman($salesman_id, $admin_id);
  61. if ($result){
  62. return json_success($result, '删除成功');
  63. }else{
  64. throw new \Exception('删除失败!');
  65. }
  66. }
  67. /**
  68. * Notes:添加业务员
  69. * @return \support\Response
  70. * User: ZQ
  71. * Date: 2022/9/27
  72. */
  73. public function addSalesman()
  74. {
  75. $salesman_shop_id = $this->request->post('salesman_shop_id');
  76. $salesman_name = $this->request->post('salesman_name');
  77. $salesman_pwd = $this->request->post('salesman_pwd');
  78. $again_salesman_pwd = $this->request->post('again_salesman_pwd','');
  79. $salesman_phone = $this->request->post('salesman_phone');
  80. $salesman_resale_name = $this->request->post('salesman_resale_name');
  81. $salesman_status = $this->request->post('salesman_status');
  82. $salf = $this->passwordSalf(6);
  83. $admin_id = $this->request->admin_id;
  84. $this->validateCheck('medical\SalesmanValidate', ['salesman_shop_id' => $salesman_shop_id, 'salesman_name' => $salesman_name, 'salesman_pwd' => $salesman_pwd, 'again_salesman_pwd' => $again_salesman_pwd, 'salesman_phone' => $salesman_phone, 'salesman_resale_name' => $salesman_resale_name, 'salesman_status' => $salesman_status], 'create');
  85. if ($salesman_pwd !== $again_salesman_pwd){
  86. throw new \Exception('两次密码输入不一致!');
  87. }
  88. $salesman_pwd = md5(sha1($salesman_pwd.$salf));
  89. $result = SalesmanServer::insertSalesman($salesman_shop_id, $salesman_name, $salesman_pwd, $salesman_phone, $salesman_resale_name, $salesman_status, $salf, $admin_id);
  90. return json_success($result, '添加成功');
  91. }
  92. /**
  93. * Notes:查询业务员详情
  94. * @return \support\Response
  95. * User: ZQ
  96. * Date: 2022/9/27
  97. */
  98. public function salesmanInfo()
  99. {
  100. $salesman_id = $this->request->get('salesman_id');
  101. $this->validateCheck('medical\SalesmanValidate', ['salesman_id' => $salesman_id], 'info');
  102. $result = SalesmanServer::salesmanInfo($salesman_id);
  103. if (!empty($result))
  104. return json_success($result, '成功');
  105. }
  106. /**
  107. * Notes:修改业务员状态
  108. * @return \support\Response
  109. * User: ZQ
  110. * Date: 2022/9/14
  111. */
  112. public function updateStatus()
  113. {
  114. $salesman_id = $this->request->get('salesman_id');
  115. $salesman_status = $this->request->get('salesman_status');
  116. $admin_id = $this->request->admin_id;
  117. $this->validateCheck('medical\SalesmanValidate', ['salesman_id'=>$salesman_id], 'info');
  118. $result = SalesmanServer::updateStatus($salesman_id, $salesman_status, $admin_id);
  119. return json_success($result, '修改成功');
  120. }
  121. }