diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index e50a1665e..085401c84 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -1057,3 +1057,12 @@ function showNumPercent($num) } } +//优化子站点实例化方法 +function SM($name='', $tablePrefix='tab_') +{ + $tableName = strtolower($tablePrefix.$name); + if(in_array($tableName,C('SUBSITE_TABLE')) && IS_SUBSITE){ + return M($name, $tablePrefix,SUBSITE_DB); + } + return M($name, $tablePrefix); +} diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php index e45f7d8cc..ff9f5af47 100644 --- a/Application/Admin/Conf/config.php +++ b/Application/Admin/Conf/config.php @@ -103,7 +103,7 @@ return array( /* SESSION 和 COOKIE 配置 */ 'SESSION_PREFIX' => 'onethink_admin', //session前缀 - 'SESSION_COOKIE_PATH' => '/admin.php', + 'SESSION_COOKIE_PATH' => '/'.SUBSITE_INDEX, 'COOKIE_PREFIX' => 'onethink_admin_', // Cookie前缀 避免冲突 'VAR_SESSION_ID' => 'session_id', //修复uploadify插件无法传递session_id的bug @@ -113,5 +113,9 @@ return array( 'TMPL_EXCEPTION_FILE' => MODULE_PATH.'View/Public/exception.html',// 异常页面的模板文件 /*默认公司名称*/ 'DEFAULT_COMPANY'=>"海南万盟天下科技有限公司", - 'OFFICIEL_CHANNEL'=>"江息网络" + 'OFFICIEL_CHANNEL'=>"江息网络", + /*分库的表格*/ + 'SUBSITE_TABLE'=>[ + "tab_spend" + ] ); \ No newline at end of file diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 15416f9c9..a9fca7d3e 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -137,23 +137,21 @@ class SpendController extends ThinkController $this->checkListOrCountAuthRestMap($map,["extend", "pay_order_number", "user_account"]); $map1 = $map; $map1['pay_status'] = 1; - $total = null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); - $ttotal = null_to_0(D(self::model_name)->where('pay_time' . total(1))->where(array('pay_status' => 1))->sum('pay_amount')); - $ytotal = null_to_0(D(self::model_name)->where('pay_time' . total(5))->where(array('pay_status' => 1))->sum('pay_amount')); + $total = null_to_0(SM(self::model_name)->where($map1)->sum('pay_amount')); $this->assign('total', $total); - $this->assign('ttotal', $ttotal); - $this->assign('ytotal', $ytotal); $this->meta_title = $this->m_title = '游戏充值'; $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Spend/lists', 'status' => 1])->find()); - - $data = D(self::model_name)->lists($_GET["p"], $map, $order); - $adminUsernameList = getAdminUsernameList(array_column($data['data'], 'market_admin_id')); - foreach ($data['data'] as $key=>&$value ) { - ($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):''; - $value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无'; - $value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']]; + $data = D(self::model_name)->lists($_GET["p"], $map, $order); + if(!empty($data['data'])){ + $adminUsernameList = getAdminUsernameList(array_column($data['data'], 'market_admin_id')); + foreach ($data['data'] as $key=>&$value ) { + ($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):''; + $value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无'; + $value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']]; + } } + $this->assign('showMarketAdmin', session('user_auth')['show_market_admin']); $this->assign('showPromote', session('user_auth')['show_promote']); $this->assign('isMarketAdmin', $isMarketAdmin); diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 3153c7efc..40204893b 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -796,12 +796,12 @@ class SpendModel extends Model } else { $row = 10; } - $list = $this + $list = $this->db(1) ->where($map) ->page($page, $row) ->order($order ? $order : 'pay_time desc') ->select(); - $count = $this->where($map)->count(); + $count = $this->db(1)->where($map)->count(); $data['data'] = $list; $page = set_pagination($count, $row); if ($page) { diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index 1ce4f4ede..b0c5c84ef 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -377,14 +377,10 @@