数据库: - db/schema_phase1.sql 16 张业务表(类目/服务/地址/师傅/订单/流水/取证/报价/评价/券/钱包/提现/结算/消息) - db/seed_phase1.sql 15 类目 + 32 服务项目 + 新人券(幂等) 后端 API (application/api/controller): - Base/Auth/Home/Address/Order/Master/Review - app/common/library/OrderStatus 11 状态机 + 流转矩阵 - application/api/common.php PHP 8.5 兼容垫片(E_DEPRECATED 不再升级为异常) 测试: - tests/e2e_flow.js 用户下单→支付→师傅抢单→履约→验收→结算→评价 全链路 65 项断言 - 含异常用例:越权/重复操作/非法状态流转/2h 未联系自动回流
164 行
4.9 KiB
PHP
可执行文件
164 行
4.9 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
use app\common\model\User;
|
|
|
|
/**
|
|
* 验证接口
|
|
*/
|
|
class Validate extends Api
|
|
{
|
|
protected $noNeedLogin = '*';
|
|
protected $layout = '';
|
|
protected $error = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
}
|
|
|
|
/**
|
|
* 检测邮箱
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
|
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
|
*/
|
|
public function check_email_available()
|
|
{
|
|
$email = $this->request->post('email');
|
|
$id = (int)$this->request->post('id');
|
|
$count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
|
|
if ($count > 0) {
|
|
$this->error(__('邮箱已经被占用'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测用户名
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="username", type="string", required=true, description="用户名")
|
|
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
|
*/
|
|
public function check_username_available()
|
|
{
|
|
$username = $this->request->post('username');
|
|
$id = (int)$this->request->post('id');
|
|
$count = User::where('username', '=', $username)->where('id', '<>', $id)->count();
|
|
if ($count > 0) {
|
|
$this->error(__('用户名已经被占用'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测昵称
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="nickname", type="string", required=true, description="昵称")
|
|
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
|
*/
|
|
public function check_nickname_available()
|
|
{
|
|
$nickname = $this->request->post('nickname');
|
|
$id = (int)$this->request->post('id');
|
|
$count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count();
|
|
if ($count > 0) {
|
|
$this->error(__('昵称已经被占用'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测手机
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
|
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
|
*/
|
|
public function check_mobile_available()
|
|
{
|
|
$mobile = $this->request->post('mobile');
|
|
$id = (int)$this->request->post('id');
|
|
$count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
|
|
if ($count > 0) {
|
|
$this->error(__('该手机号已经占用'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测手机
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
|
*/
|
|
public function check_mobile_exist()
|
|
{
|
|
$mobile = $this->request->post('mobile');
|
|
$count = User::where('mobile', '=', $mobile)->count();
|
|
if (!$count) {
|
|
$this->error(__('手机号不存在'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测邮箱
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
|
*/
|
|
public function check_email_exist()
|
|
{
|
|
$email = $this->request->post('email');
|
|
$count = User::where('email', '=', $email)->count();
|
|
if (!$count) {
|
|
$this->error(__('邮箱不存在'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测手机验证码
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
|
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
|
* @ApiParams (name="event", type="string", required=true, description="事件")
|
|
*/
|
|
public function check_sms_correct()
|
|
{
|
|
$mobile = $this->request->post('mobile');
|
|
$captcha = $this->request->post('captcha');
|
|
$event = $this->request->post('event');
|
|
if (!\app\common\library\Sms::check($mobile, $captcha, $event)) {
|
|
$this->error(__('验证码不正确'));
|
|
}
|
|
$this->success();
|
|
}
|
|
|
|
/**
|
|
* 检测邮箱验证码
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
|
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
|
* @ApiParams (name="event", type="string", required=true, description="事件")
|
|
*/
|
|
public function check_ems_correct()
|
|
{
|
|
$email = $this->request->post('email');
|
|
$captcha = $this->request->post('captcha');
|
|
$event = $this->request->post('event');
|
|
if (!\app\common\library\Ems::check($email, $captcha, $event)) {
|
|
$this->error(__('验证码不正确'));
|
|
}
|
|
$this->success();
|
|
}
|
|
}
|