数据库: - 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 未联系自动回流
85 行
2.5 KiB
PHP
可执行文件
85 行
2.5 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace app\admin\controller\general;
|
|
|
|
use app\admin\model\Admin;
|
|
use app\common\controller\Backend;
|
|
use fast\Random;
|
|
use think\Session;
|
|
use think\Validate;
|
|
|
|
/**
|
|
* 个人配置
|
|
*
|
|
* @icon fa fa-user
|
|
*/
|
|
class Profile extends Backend
|
|
{
|
|
|
|
protected $searchFields = 'id,title';
|
|
|
|
/**
|
|
* 查看
|
|
*/
|
|
public function index()
|
|
{
|
|
//设置过滤方法
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
if ($this->request->isAjax()) {
|
|
$this->model = model('AdminLog');
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
$list = $this->model
|
|
->where($where)
|
|
->where('admin_id', $this->auth->id)
|
|
->order($sort, $order)
|
|
->paginate($limit);
|
|
|
|
$result = array("total" => $list->total(), "rows" => $list->items());
|
|
|
|
return json($result);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 更新个人信息
|
|
*/
|
|
public function update()
|
|
{
|
|
if ($this->request->isPost()) {
|
|
$this->token();
|
|
$params = $this->request->post("row/a");
|
|
$params = array_filter(array_intersect_key(
|
|
$params,
|
|
array_flip(array('email', 'nickname', 'password', 'avatar'))
|
|
));
|
|
unset($v);
|
|
if (!Validate::is($params['email'], "email")) {
|
|
$this->error(__("Please input correct email"));
|
|
}
|
|
if (isset($params['password'])) {
|
|
if (!Validate::is($params['password'], "/^[\S]{6,30}$/")) {
|
|
$this->error(__("Please input correct password"));
|
|
}
|
|
$params['salt'] = Random::alnum();
|
|
$params['password'] = md5(md5($params['password']) . $params['salt']);
|
|
}
|
|
$exist = Admin::where('email', $params['email'])->where('id', '<>', $this->auth->id)->find();
|
|
if ($exist) {
|
|
$this->error(__("Email already exists"));
|
|
}
|
|
if ($params) {
|
|
$admin = Admin::get($this->auth->id);
|
|
$admin->save($params);
|
|
//因为个人资料面板读取的Session显示,修改自己资料后同时更新Session
|
|
Session::set("admin", $admin->toArray());
|
|
Session::set("admin.safecode", $this->auth->getEncryptSafecode($admin));
|
|
$this->success();
|
|
}
|
|
$this->error();
|
|
}
|
|
return;
|
|
}
|
|
}
|