|
@@ -4,8 +4,11 @@ namespace App\Http\Controllers\QuickApp\User;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\QuickApp\BaseController;
|
|
use App\Http\Controllers\QuickApp\BaseController;
|
|
|
|
+use App\Libs\AliSMS;
|
|
use App\Modules\Subscribe\Services\YearOrderService;
|
|
use App\Modules\Subscribe\Services\YearOrderService;
|
|
|
|
+use App\Modules\User\Services\QappUserService;
|
|
use App\Modules\User\Services\UserSignService;
|
|
use App\Modules\User\Services\UserSignService;
|
|
|
|
+use Redis;
|
|
|
|
|
|
class UserController extends BaseController
|
|
class UserController extends BaseController
|
|
{
|
|
{
|
|
@@ -110,4 +113,68 @@ class UserController extends BaseController
|
|
}
|
|
}
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @apiVersion 1.0.0
|
|
|
|
+ * @apiDescription 发送验证码
|
|
|
|
+ * @api {GET} sendCode 发送验证码
|
|
|
|
+ * @apiHeader {String} [Authorization] token
|
|
|
|
+ * @apiGroup User
|
|
|
|
+ * @apiName sendCode
|
|
|
|
+ * @apiSuccess {String} phone 手机号
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ *
|
|
|
|
+ * {
|
|
|
|
+ * "code": 0,
|
|
|
|
+ * "msg": "",
|
|
|
|
+ * "data": {}
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
|
|
+ public function sendCode(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $phone = $request->post('phone');
|
|
|
|
+ $code = random_int(1000, 9999);
|
|
|
|
+ Redis::setex('quser_code:' . $phone, 120, $code);
|
|
|
|
+ AliSMS::send($phone, 'quickapp_user_bind_phone', ['code' => $code]);
|
|
|
|
+ return response()->success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @apiVersion 1.0.0
|
|
|
|
+ * @apiDescription 绑定手机号
|
|
|
|
+ * @api {GET} bindPhone 绑定手机号
|
|
|
|
+ * @apiHeader {String} [Authorization] token
|
|
|
|
+ * @apiGroup User
|
|
|
|
+ * @apiName bindPhone
|
|
|
|
+ * @apiSuccess {String} phone 手机号
|
|
|
|
+ * @apiSuccess {String} code 验证码
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ *
|
|
|
|
+ * {
|
|
|
|
+ * "code": 0,
|
|
|
|
+ * "msg": "",
|
|
|
|
+ * "data": {}
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
|
|
+ public function bindPhone(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $code = $request->post('code');
|
|
|
|
+ $phone = $request->post('phone');
|
|
|
|
+ $old = Redis::get('quser_code:' . $phone);
|
|
|
|
+ if ($old && $old == $code) {
|
|
|
|
+ try {
|
|
|
|
+ Redis::del('quser_code:' . $phone);
|
|
|
|
+ $result = QappUserService::bindPhoneStatic($this->uid, $phone);
|
|
|
|
+ if (!$result) {
|
|
|
|
+ return response()->error('WAP_BIND_PHONE_EXIST');
|
|
|
|
+ } else {
|
|
|
|
+ return response()->success();
|
|
|
|
+ }
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ return response()->error();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return response()->error('WAP_SEND_CODE_ERROR');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|