diff --git a/app/data/controller/api/Auth.php b/app/data/controller/api/Auth.php index 41e769d90..25a06765c 100644 --- a/app/data/controller/api/Auth.php +++ b/app/data/controller/api/Auth.php @@ -43,11 +43,16 @@ abstract class Auth extends Controller */ protected function initialize() { - // 接口数据类型 - $this->type = $this->request->header('api-name') ?: input('api'); + // 接收接口类型 + $this->type = $this->request->request('api'); + $this->type = $this->type ?: $this->request->header('api-name'); $this->type = $this->type ?: $this->request->header('api-type'); - if (empty($this->type) || empty(UserAdminService::TYPES[$this->type])) { - $this->error("接口支付未定义!"); + // 检查接口类型 + if (empty($this->type)) { + $this->error("未获取到接口类型字段!"); + } + if (isset(UserAdminService::TYPES[$this->type])) { + $this->error("接口类型[{$this->type}]未定义!"); } // 获取用户数据 $this->user = $this->getUser(); @@ -84,7 +89,7 @@ abstract class Auth extends Controller protected function checkUserStatus() { if (empty($this->user['status'])) { - $this->error('抱歉,账户已被冻结!'); + $this->error('账户已经被冻结!'); } } diff --git a/app/data/controller/api/auth/Address.php b/app/data/controller/api/auth/Address.php index e9a8f4db8..0171f1f59 100644 --- a/app/data/controller/api/auth/Address.php +++ b/app/data/controller/api/auth/Address.php @@ -45,7 +45,7 @@ class Address extends Auth unset($data['code']); $count = $this->app->db->name($this->table)->where($data)->count(); if ($count > 0) $this->error('抱歉,该地址已经存在!'); - $data['code'] = CodeExtend::uniqidDate(12, 'A'); + $data['code'] = CodeExtend::uniqidDate(20, 'A'); if ($this->app->db->name($this->table)->insert($data) === false) { $this->error('添加地址失败!'); } @@ -78,7 +78,7 @@ class Address extends Auth } /** - * 修改收货地址状态 + * 修改地址状态 * @throws \think\db\exception\DbException */ public function state() @@ -124,7 +124,7 @@ class Address extends Auth } /** - * 获取指定的收货地址 + * 获取指定的地址 * @param string $code * @return null|array * @throws \think\db\exception\DataNotFoundException diff --git a/app/data/controller/api/auth/Center.php b/app/data/controller/api/auth/Center.php index e9a6529ba..78b7cecc2 100644 --- a/app/data/controller/api/auth/Center.php +++ b/app/data/controller/api/auth/Center.php @@ -37,9 +37,7 @@ class Center extends Auth 'base_weight.default' => '', 'base_birthday.default' => '', ]); - foreach ($data as $key => $vo) { - if ($vo === '') unset($data[$key]); - } + foreach ($data as $key => $vo) if ($vo === '') unset($data[$key]); if (empty($data)) $this->error('没有修改的数据!'); if ($this->app->db->name($this->table)->where(['id' => $this->uuid])->update($data) !== false) { $this->success('更新资料成功!', $this->getUser()); diff --git a/vendor/services.php b/vendor/services.php index 6abe68aa6..23fd37f64 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library',