From c678d95e4d14c2807b7cab69011c8aed1fc9786a Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 22 Jan 2024 15:13:22 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=A6=96=E5=8D=95=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/UserController.php | 7 +++++- config/database.php | 36 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php index 092f6cae..86f2f2fa 100644 --- a/app/api/controller/UserController.php +++ b/app/api/controller/UserController.php @@ -322,10 +322,15 @@ class UserController extends BaseApiController { $page = $this->request->param('page_no', 1); $limit = $this->request->param('page_size', 15); - $firstOrderLogList = Db::name('user_invite_first_order_log')->where('user_id', $this->userId)->page($page, $limit)->select(); + $firstOrderLogList = Db::name('user_invite_first_order_log')->where('user_id', $this->userId)->page($page, $limit)->select()->toArray(); + + foreach ($firstOrderLogList as &$item) { + $item['order_info'] = Db::connect('mysql2')->name('store_order')->alias('o')->field('o.total_num,p.store_name,p.image')->leftJoin('store_order_product op', 'o.order_id=op.order_id')->leftJoin('store_product p', 'op.product_id = p.product_id')->where('o.order_sn', $item['order_no'])->select(); + } $data = [ 'lists' => $firstOrderLogList, 'count' => Db::name('user_invite_first_order_log')->where('user_id', $this->userId)->count(), + 'total_money' => Db::name('user_invite_first_order_log')->where('user_id', $this->userId)->sum('order_money'), 'page_no' => $page, 'page_size' => $limit, ]; diff --git a/config/database.php b/config/database.php index bfc14de4..23b54e45 100644 --- a/config/database.php +++ b/config/database.php @@ -56,7 +56,43 @@ return [ // 开启字段缓存 'fields_cache' => false, ], + 'mysql2' => [ + // 数据库类型 + 'type' => env('database2.type', 'mysql'), + // 服务器地址 + 'hostname' => env('database2.hostname', '127.0.0.1'), + // 数据库名 + 'database' => env('database2.database', ''), + // 用户名 + 'username' => env('database2.username', 'root'), + // 密码 + 'password' => env('database2.password', ''), + // 端口 + 'hostport' => env('database2.hostport', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => env('database2.charset', 'utf8'), + // 数据库表前缀 + 'prefix' => env('database2.prefix', ''), + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 是否需要断线重连 + 'break_reconnect' => false, + // 监听SQL + 'trigger_sql' => env('app_debug', true), + // 开启字段缓存 + 'fields_cache' => false, + ], // 更多的数据库配置信息 ], ];