123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use think\Db;
- class Moneylog extends Backend
- {
-
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Moneylog;
- }
- public function import()
- {
- parent::import();
- }
-
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-
- $gh_map = [];
-
- $list = $this->model
- ->with(['user', 'otheruser'])
- ->where($where)
- ->where($gh_map)
- ->order($sort, $order)
- ->paginate($limit);
- $wallet_logtype = config('wallet.logtype');
- $mt_user_match_video_log = Db::name('user_match_video_log');
- $mt_user_match_audio_log = Db::name('user_match_audio_log');
- foreach ($list as $row) {
-
- $row->getRelation('user')->visible(['username', 'nickname']);
- $row->getRelation('otheruser')->visible(['username', 'nickname']);
- $row['log_type_text'] = isset($wallet_logtype[$row['log_type']]) ? $wallet_logtype[$row['log_type']] : '';
- $row['call_minutes'] = '';
- if ($row['log_type'] == 21) {
- $row['call_minutes'] = $mt_user_match_video_log->where(['id' => $row['table_id']])->value('call_minutes');
- } elseif ($row['log_type'] == 22) {
- $row['call_minutes'] = $mt_user_match_audio_log->where(['id' => $row['table_id']])->value('call_minutes');
- }
- }
- $sum_money = db('user_money_log')->alias('moneylog')->join('user','moneylog.user_id = user.id','LEFT')->where($where)->where($gh_map)->field('sum(moneylog.change_value) as sum_money')->find();
- $result = array("total" => $list->total(), "rows" => $list->items(),
- 'extend' => [
- 'sum_money' => $sum_money['sum_money'],
- ]
- );
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|