123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace app\admin\controller;
- //采销端管理供应商账号
- use app\abutment\logic\Account as AccountLogic;
- use app\abutment\model\SupplierUser;
- use think\facade\Validate;
- class Account extends Base
- {
- //获取供应商账号列表
- public function getAccountList()
- {
- $param = $this->request->filter('trim')->only(['supplierNo' => '', 'keyword' => '', 'status' => '', 'page' => 1, 'size' => 15], 'post');
- $val = Validate::rule([
- 'supplierNo|供应商编码' => 'alphaNum|length:18',
- 'keyword|关键字' => 'chsDash|max:100',
- 'status|状态' => 'number|in:' . SupplierUser::$status_disabled . ',' . SupplierUser::$status_normal,
- 'page|页码' => 'require|number|gt:0',
- 'size|每页数量' => 'require|number|elt:100',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- return AccountLogic::getAccountList($param);
- }
- //修改供应商账号密码
- public function changePassword()
- {
- $param = $this->request->filter('trim')->only(['uid', 'password'], 'post');
- $val = Validate::rule([
- 'uid|用户ID' => 'require|number|gt:0',
- 'password|密码' => 'require|min:6|max:200',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- return AccountLogic::changePassword($param);
- }
- //读取供应商账号账号信息
- public function readAccount()
- {
- $param = $this->request->filter('trim')->only(['uid'], 'post');
- $val = Validate::rule(['uid|用户ID' => 'require|number|gt:0']);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- return AccountLogic::readAccount($param);
- }
- //添加供应商账号
- public function addAccount()
- {
- $param = $this->request->filter('trim')->only(['supplierNo', 'nickname', 'mobile', 'email' => ''], 'post');
- $val = Validate::rule([
- 'nickname|姓名' => 'require|max:255',
- 'mobile|手机号' => 'require|number|length:11|mobile',
- 'email|邮箱' => 'email',
- 'supplierNo|供应商编码' => 'require|array|max:100',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- $token = $this->request->filter('trim')->post('token');
- return AccountLogic::addAccount($param, $token);
- }
- //修改供应商账号
- public function editAccount()
- {
- $param = $this->request->filter('trim')->only(['token', 'uid', 'nickname', 'mobile', 'email' => '', 'supplier_list' => []], 'post');
- $val = Validate::rule([
- 'uid|用户ID' => 'require|number|gt:0',
- 'nickname|姓名' => 'require|max:255',
- 'mobile|手机号' => 'require|number|length:11|mobile',
- 'email|邮箱' => 'email',
- 'supplier_list|供应商列表' => 'array|max:100',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- return AccountLogic::editAccount($param);
- }
- //启/禁用 供应商账号
- public function statusAccount()
- {
- $param = $this->request->filter('trim')->only(['uid', 'status'], 'post');
- $val = Validate::rule([
- 'uid|用户ID' => 'require|number|gt:0',
- 'status|状态' => 'require|number|in:' . \app\abutment\model\SupplierUser::$status_normal . ',' . \app\abutment\model\SupplierUser::$status_disabled,
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- return AccountLogic::statusAccount($param);
- }
- //删除供应商账号
- public function deleteAccount()
- {
- $uid = $this->request->filter('trim')->post('uid/d', 0);
- return AccountLogic::deleteAccount($uid);
- }
- }
|