121 lines
3.7 KiB
PHP
Raw Permalink Normal View History

2024-09-29 15:43:18 +08:00
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\channel\controller;
use think\admin\Controller;
use app\channel\service\AccountService;
use app\channel\service\ChannelService;
use think\admin\Exception;
/**
* 渠道资金管理
* Class Merchant
* @package app\merchant\controller
*/
class Account extends Controller
{
/**
* 绑定数据表
* @var string
*/
public $table = 'ChannelAccount';
/**
* 充值信息列表
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$this->title = '渠道对账数据';
$this->day = date('Y-m-d');
$query = $this->_query($this->table);
$query->equal('cid')->dateBetween('create_at');
$field = '*,(replace(day, "-", "")+0) as day_num';
$order = 'day_num desc,id desc';
$query->field($field);
// 列表排序并显示
if (input('output') === 'json') {
$result = $query->order($order)->page(true, false);
$this->success('获取数据列表成功', $result);
} else {
$query->order($order)->page();
}
}
/**
* 表单数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function _form_filter(&$data)
{
$this->channels = $this->app->db->name('ChannelList')->where(['is_deleted' => 0, 'status' => 1])->select()->toArray();
$this->day = date('Y-m-d');
}
/**
* 列表数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function _index_page_filter(array &$data)
{
$this->channels = $this->app->db->name('ChannelList')->where(['is_deleted' => 0, 'status' => 1])->select()->toArray();
foreach ($data as $k => $v) {
$data[$k]['channel'] = ChannelService::instance()->getInfo($v['cid']);
}
}
/**
* 添加商户
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws Exception
*/
public function add()
{
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 编辑商户
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws Exception
*/
public function edit()
{
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
}