Account.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. namespace app\admin\controller;
  3. //采销端管理供应商账号
  4. use app\abutment\logic\Account as AccountLogic;
  5. use app\abutment\model\SupplierUser;
  6. use think\facade\Validate;
  7. class Account extends Base
  8. {
  9. //获取供应商账号列表
  10. public function getAccountList()
  11. {
  12. $param = $this->request->filter('trim')->only(['supplierNo' => '', 'keyword' => '', 'status' => '', 'page' => 1, 'size' => 15], 'post');
  13. $val = Validate::rule([
  14. 'supplierNo|供应商编码' => 'alphaNum|length:18',
  15. 'keyword|关键字' => 'chsDash|max:100',
  16. 'status|状态' => 'number|in:' . SupplierUser::$status_disabled . ',' . SupplierUser::$status_normal,
  17. 'page|页码' => 'require|number|gt:0',
  18. 'size|每页数量' => 'require|number|elt:100',
  19. ]);
  20. if (!$val->check($param)) return json_show(1004, $val->getError());
  21. return AccountLogic::getAccountList($param);
  22. }
  23. //修改供应商账号密码
  24. public function changePassword()
  25. {
  26. $param = $this->request->filter('trim')->only(['uid', 'password'], 'post');
  27. $val = Validate::rule([
  28. 'uid|用户ID' => 'require|number|gt:0',
  29. 'password|密码' => 'require|min:6|max:200',
  30. ]);
  31. if (!$val->check($param)) return json_show(1004, $val->getError());
  32. return AccountLogic::changePassword($param);
  33. }
  34. //读取供应商账号账号信息
  35. public function readAccount()
  36. {
  37. $param = $this->request->filter('trim')->only(['uid'], 'post');
  38. $val = Validate::rule(['uid|用户ID' => 'require|number|gt:0']);
  39. if (!$val->check($param)) return json_show(1004, $val->getError());
  40. return AccountLogic::readAccount($param);
  41. }
  42. //添加供应商账号
  43. public function addAccount()
  44. {
  45. $param = $this->request->filter('trim')->only(['supplierNo', 'nickname', 'mobile', 'email' => ''], 'post');
  46. $val = Validate::rule([
  47. 'nickname|姓名' => 'require|max:255',
  48. 'mobile|手机号' => 'require|number|length:11|mobile',
  49. 'email|邮箱' => 'email',
  50. 'supplierNo|供应商编码' => 'require|array|max:100',
  51. ]);
  52. if (!$val->check($param)) return json_show(1004, $val->getError());
  53. $token = $this->request->filter('trim')->post('token');
  54. return AccountLogic::addAccount($param, $token);
  55. }
  56. //修改供应商账号
  57. public function editAccount()
  58. {
  59. $param = $this->request->filter('trim')->only(['token', 'uid', 'nickname', 'mobile', 'email' => '', 'supplier_list' => []], 'post');
  60. $val = Validate::rule([
  61. 'uid|用户ID' => 'require|number|gt:0',
  62. 'nickname|姓名' => 'require|max:255',
  63. 'mobile|手机号' => 'require|number|length:11|mobile',
  64. 'email|邮箱' => 'email',
  65. 'supplier_list|供应商列表' => 'array|max:100',
  66. ]);
  67. if (!$val->check($param)) return json_show(1004, $val->getError());
  68. return AccountLogic::editAccount($param);
  69. }
  70. //启/禁用 供应商账号
  71. public function statusAccount()
  72. {
  73. $param = $this->request->filter('trim')->only(['uid', 'status'], 'post');
  74. $val = Validate::rule([
  75. 'uid|用户ID' => 'require|number|gt:0',
  76. 'status|状态' => 'require|number|in:' . \app\abutment\model\SupplierUser::$status_normal . ',' . \app\abutment\model\SupplierUser::$status_disabled,
  77. ]);
  78. if (!$val->check($param)) return json_show(1004, $val->getError());
  79. return AccountLogic::statusAccount($param);
  80. }
  81. //删除供应商账号
  82. public function deleteAccount()
  83. {
  84. $uid = $this->request->filter('trim')->post('uid/d', 0);
  85. return AccountLogic::deleteAccount($uid);
  86. }
  87. }