feat: 新增地址选择插件及订阅消息等多项功能优化
- 新增地址选择插件,支持地图位置选择并返回地址和经纬度 - 新增微信订阅消息发送功能,支持审核结果、提现通知等场景 - 新增订单支付状态查询、提现收款人姓名保存等接口 - 新增服务区域管理,支持按省市区划分并同步到信息发布 - 新增资金流水和营收报表导出功能 - 新增可用优惠券查询、订单退款拆分处理等功能 - 优化后台角标显示、首页数据统计、UI配置下发等 - 修复订单支付并发问题、地区管理逻辑等
这个提交包含在:
@@ -4,34 +4,52 @@ namespace app\api\library;
|
||||
|
||||
use Exception;
|
||||
use think\exception\Handle;
|
||||
use think\Log;
|
||||
|
||||
/**
|
||||
* 自定义API模块的错误显示
|
||||
* API 模块统一异常输出
|
||||
*
|
||||
* 契约与 V1 基类保持一致:{"code":<非0>,"message":"...","data":null}
|
||||
* 说明:业务失败一律 HTTP 200 + code!=0(前端 request.js 只在 code===0/200 时视为成功),
|
||||
* 否则前端会把 500 显示成「网络异常(500)」,真实原因被吞掉。
|
||||
* 仅 401/403/404 等 HTTP 语义异常保留原始状态码。
|
||||
*/
|
||||
class ExceptionHandle extends Handle
|
||||
{
|
||||
|
||||
public function render(Exception $e)
|
||||
{
|
||||
// 在生产环境下返回code信息
|
||||
if (!\think\Config::get('app_debug')) {
|
||||
$statuscode = $code = 500;
|
||||
$msg = 'An error occurred';
|
||||
// 验证异常
|
||||
if ($e instanceof \think\exception\ValidateException) {
|
||||
$code = 0;
|
||||
$statuscode = 200;
|
||||
$msg = $e->getError();
|
||||
}
|
||||
// Http异常
|
||||
if ($e instanceof \think\exception\HttpException) {
|
||||
$statuscode = $code = $e->getStatusCode();
|
||||
}
|
||||
return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode);
|
||||
// ok()/fail() 抛出的 HttpResponseException 由框架直接输出,不走这里
|
||||
if ($e instanceof \think\exception\HttpResponseException) {
|
||||
return parent::render($e);
|
||||
}
|
||||
|
||||
//其它此交由系统处理
|
||||
return parent::render($e);
|
||||
}
|
||||
$status = 200;
|
||||
$code = 500;
|
||||
$message = '服务器开小差了,请稍后再试';
|
||||
|
||||
if ($e instanceof \think\exception\ValidateException) {
|
||||
$code = 1;
|
||||
$message = $e->getError();
|
||||
} elseif ($e instanceof \think\exception\HttpException) {
|
||||
$status = $e->getStatusCode();
|
||||
$code = $status;
|
||||
$message = $e->getMessage() ?: '请求异常';
|
||||
}
|
||||
|
||||
// 详细信息只写日志,不回传给客户端(避免泄露路径/SQL)
|
||||
Log::record(
|
||||
'API异常:' . get_class($e) . ' ' . $e->getMessage() . "\n" . $e->getTraceAsString(),
|
||||
'error'
|
||||
);
|
||||
|
||||
if (\think\Config::get('app_debug')) {
|
||||
$message .= ' [' . $e->getMessage() . ' @ ' . basename($e->getFile()) . ':' . $e->getLine() . ']';
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => $code,
|
||||
'message' => $message,
|
||||
'data' => null,
|
||||
], $status);
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户