From ca216e1e8ad89a86e4cb1a5288ee1926f1b69c02 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 12 Sep 2020 16:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=9A=E5=91=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=9F=A5=E8=AF=A2=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/api/auth/Address.php | 5 ++--- app/data/service/UserService.php | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/data/controller/api/auth/Address.php b/app/data/controller/api/auth/Address.php index 4019fa2c9..7266c2223 100644 --- a/app/data/controller/api/auth/Address.php +++ b/app/data/controller/api/auth/Address.php @@ -60,7 +60,6 @@ class Address extends Auth $this->success('添加收货地址成功!', $this->_getAddress($data['code'])); } - /** * 获取收货地址 * @throws \think\db\exception\DataNotFoundException @@ -83,9 +82,9 @@ class Address extends Auth { $data = $this->_vali([ 'mid.value' => $this->mid, - 'code.require' => '地址编号不能为空!', - 'type.require' => '地址状态不能为空!', 'type.in:0,1' => '地址状态不在范围!', + 'type.require' => '地址状态不能为空!', + 'code.require' => '地址编号不能为空!', ]); // 检查地址是否存在 $map = ['mid' => $data['mid'], 'code' => $data['code']]; diff --git a/app/data/service/UserService.php b/app/data/service/UserService.php index 2794530d9..3836c3c8d 100644 --- a/app/data/service/UserService.php +++ b/app/data/service/UserService.php @@ -43,7 +43,7 @@ class UserService extends Service /** * 刷新会员授权 TOKEN - * @param int $mid 会员MID + * @param mixed $mkey 会员标识 * @param array $data 额外数据 * @return array * @throws \think\Exception @@ -51,17 +51,17 @@ class UserService extends Service * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function token(int $mid, array $data = []): array + public function token($mkey, array $data = []): array { // 生成新的接口令牌 - do $update = ['token' => md5(uniqid("{$mid}#", true) . rand(100, 999))]; - while ($this->app->db->name($this->table)->where($update)->count() > 0); + do $set = ['token' => md5(uniqid("{$mkey}#", true) . rand(100, 999))]; + while ($this->app->db->name($this->table)->where($set)->count() > 0); // 更新账号授权令牌 - $this->app->db->name($this->table)->where(['id' => $mid, 'deleted' => 0])->update([ - 'token' => $update['token'], 'tokenv' => $this->buildTokenVerify(), + $this->app->db->name($this->table)->where(['id|token' => $mkey, 'deleted' => 0])->update([ + 'token' => $set['token'], 'tokenv' => $this->buildTokenVerify(), ]); // 获取新的会员数据 - return $this->get($update['token'], $data); + return $this->get($set['token'], $data); } /**