修改会员用户查询机制

This commit is contained in:
Anyon 2020-09-12 16:40:35 +08:00
parent 82deeda59c
commit ca216e1e8a
2 changed files with 9 additions and 10 deletions

View File

@ -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']];

View File

@ -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);
}
/**