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, + ], // 更多的数据库配置信息 ], ];