| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request as Req;
- use Request;
- /**
- *
- */
- class FundController extends Controller {
- /**
- * @return 财务管理
- */
- function index(Req $req) {
- $request=array();
- $request['account_name']=isset($req->account_name)?trim($req->account_name):null;
- $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
- $request['trade_type'] = isset($req->trade_type) ? trim($req->trade_type) : null;
- $request['money_small'] = isset($req->money_small) ? trim($req->money_small) : null;
- $request['money_big'] = isset($req->money_big) ? trim($req->money_big) : null;
- $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : trans('status.default_time.atime');
- $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
- $request['status'] = isset($req->status) ? trim($req->status) : '';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/money/moneyList?account_name=' . $request['account_name'] );
- $dt->setLang('money');
- $dt->setPriKey('trade_id');
- $dt->addColsFields('id', array('width' => 90));
- $dt->addColsFields('account_name', array('sort' => false, 'templet' => '#usermoneyRecord', 'width' => 130));
- $dt->addColsFields('money_time', array('templet' => '#orderid_time','width' => 240));
- $dt->addColsFields('change_cash', array('templet' => '#money_aftercash','width' => 280));
- //$dt->addColsFields('sysetem_user', array('templet' => '#sysetem_user','width' => 280));
- $dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort' => false, 'width' => 170));
- $dt->addColsFields('trade_desc', array('templet' => '#ordertype','sort' => false));
- $dt->setToolBar(array('view'), array('width' => 100,'align' => 'left'));
- return view('admin.Fund/index', $dt->render($request));
- }
- /**
- * 单用户存/取/反水列表
- * [detail description]
- * @return [type] [description]
- */
- function usermoneyRecord() {
- $account_name = Request::has('account_name') ? Request::get('account_name') : '';
- $dt = \App\Lib\DataTable\DataTable::init();
- $dt->setDataSource('/admin/money/moneyList?account_name=' . $account_name . '&sureblur=精确');
- $dt->setLang('money');
- $dt->setPriKey('trade_id');
- $dt->addColsFields('id', array('width' => 100));
- $dt->addColsFields('account_name', array('sort' => false, 'width' => 140));
- $dt->addColsFields('money_time', array('width' => 220));
- $dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort' => false, 'width' => 160));
- $dt->addColsFields('money', array('width' => 120));
- $dt->addColsFields('reason', array('sort' => false));
- $dt->setToolBar(array('view'), array('width' => 100));
- return view('admin.Fund/usermoneyRecord', $dt->render());
- }
- //查看存取反水
- function View(Req $req) {
- $order_id = $req->trade_id;
- if (empty($order_id)) {
- abort(404);
- }
- $money_db = new \App\Models\Money_details;
- $bank_db = new \App\Models\Account_bank;
- $data = $money_db->getOrderDetails($order_id, 3);
- $bank_data = $bank_db->getInfoByUid($data['account_identity']);
- $data['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
- $data['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
- $data['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
- $data['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
- return view('admin.Fund/view', ['data' => $data]);
- }
- //获取按照类型统计
- function getCount(Req $req) {
- $startTime = $req->startTime;
- $endTime = $req->endTime;
- $type = $req->type;
- $res = $this->getSumMoney($startTime, $endTime, $type);
- return responseToJson($res);
- }
- //按照类型统计总金额
- function getSumMoney($where, $type = '') {
- $db = new \App\Models\Money_details;
- $where[]=array('status','=',1);
- return $db->totalTypeMoney($where);
- }
- //入款汇总
- function getMoneySum($where, $type = '') {
- $db = new \App\Models\Money_details;
- $where = array();
- if ($type) {
- $where[] = array('trade_type', '=', $type);
- } else {
- //获取总存取反水金额
- return $db->getIntoTotal($where);
- }
- //规定的类型总数
- return $db->sumIntoMoney($where);
- }
- function getActive($where, $type) {
- $db = new \App\Models\Money_details;
- return $db->getActiveMoney($where, $type);
- }
- //统计总数
- function allTotal(Req $req) {
- $where = $req->where;
- if (count($where) == 0) {
- $where=array();
- }
- $data_odc=$this->getSumMoney($where);
- $data = array();
- //赋初值
- $data['totalMoney']=0;
- $data['onlineRecharge']=0;
- $data['backstageRecharge']=0;
- $data['remit']=0;
- $data['rechargePrize']=0;
- $data['active_add_money']=0;
- $data['active_cut_money']=0;
- $data['active_money']=0;
- $data['back_water']=0;
- $data['return_water']=0;
- $data['take_money']=0;
- $data['cut_money']=0;
- $data['commission_addmoney']=0;
- $data['nagentin'] = 0; //代理代充充值
- $data['nagentout'] = 0; //代理代充
- foreach ($data_odc as $k=>$v){
- if($v['trade_type']==6){
- $data['onlineRecharge']=round($v['money'],2);
- }
- if($v['trade_type']==11){
- $data['backstageRecharge']=round($v['money'],2);//后台充值
- }
- if($v['trade_type']==14){
- $data['remit']=round($v['money'],2);
- }
- if($v['trade_type']==13){
- $data['rechargePrize']=round($v['money'],2);
- }
- if($v['trade_type']==12&&$v['money_type']==1){
- $data['active_add_money']=round($v['money'],2);
- $data['active_money']+= $data['active_add_money'];
- }
- if($v['trade_type']==12&&$v['money_type']==2){
- $data['active_cut_money']=round($v['money'],2);
- $data['active_money']+=$data['active_cut_money'];
- }
- if($v['trade_type']==7){
- $data['back_water']=round($v['money'],2);
- }
- if($v['trade_type']==8){
- $data['return_water']=round($v['money'],2);
- }
- if($v['trade_type']==5){
- $data['take_money'] =round($v['money'],2); //5前台提现
- }
- if($v['trade_type']==9){
- $data['cut_money'] = round($v['money'],2); //管理员扣款
- }
- if($v['trade_type']==16&&$v['money_type']==1){
- $data['reward_addmoney']=round($v['money'],2);
- }
- if($v['trade_type']==16&&$v['money_type']==2){
- $data['reward_reducemoney']=round($v['money'],2);
- }
- if($v['trade_type']==19&&$v['money_type']==1){
- $data['conversion_addmoney']=round($v['money'],2);
- }
- if($v['trade_type']==19&&$v['money_type']==2){
- $data['conversion_reducemoney']=round($v['money'],2);
- }
- if($v['trade_type']==10&&$v['money_type']==1){
- $data['commission_addmoney']=round($v['money'],2);
- }
- if($v['trade_type']==22&&$v['money_type']==1){
- $data['nagentin']=round($v['money'],2);
- }
- if($v['trade_type']==22&&$v['money_type']==2){
- $data['nagentout']=round($v['money'],2);
- }
- $data['totalMoney']+=$v['money'];
- }
- if(empty($data['reward_addmoney'])){
- $data['reward_addmoney'] =0;
- }
- if(empty($data['reward_reducemoney'])){
- $data['reward_reducemoney'] =0;
- }
- if(empty($data['conversion_addmoney'])){
- $data['conversion_addmoney'] =0;
- }
- if(empty($data['conversion_reducemoney'])){
- $data['conversion_reducemoney'] =0;
- }
- // $data['totalMoney'] = $this->getSumMoney($where);
- // $data['onlineRecharge'] = $this->getSumMoney($where, 6); //在线充值
- // $data['backstageRecharge'] = $this->getSumMoney($where, 11); //后台充值
- // $data['remit'] = $this->getSumMoney($where, 14); //14汇款
- // $data['rechargePrize'] = $this->getSumMoney($where, 13); //13充值赠送
- //活动金额
- // $data['active_cut_money'] = $this->getActive($where, 2); //活动扣除
- // $data['active_cut_money']=round($data['active_cut_money'],2);
- // $data['totalMoney']+=$data['active_cut_money'];
- // $data['active_add_money'] = $this->getActive($where, 1); //活动加款
- // $data['active_add_money']=round($data['active_add_money'],2);
- // $data['active_money'] = $this->getSumMoney($where, 12); //总活动
- // $data['back_water'] = $this->getSumMoney($where, 7); //反水
- // $data['return_water'] = $this->getSumMoney($where, 8); //回水
- // $data['take_money'] = $this->getSumMoney($where, 5); //5前台提现
- // $data['cut_money'] = $this->getSumMoney($where, 9); //管理员扣款
- $data['intoTotalMoney'] = $data['onlineRecharge'] + $data['backstageRecharge'] + $data['remit'] + $data['nagentin']; //总入款扣除活动充值赠送
- $data['cut_total_money'] = $data['cut_money'] + $data['take_money'] + $data['nagentout']; //扣款总额扣除活动充值赠送
- $data['profit'] = $data['intoTotalMoney'] - $data['cut_total_money'];
- $data['all_save_money'] = $data['intoTotalMoney'] + $data['active_add_money'] + $data['rechargePrize'] + $data['back_water'] + $data['return_water']; //总存款
- $data['all_take_money'] = $data['take_money'] + $data['cut_money'] + $data['active_cut_money'] + $data['nagentout']; //总扣款
- // $type= ['totalMoney', 'onlineRecharge', 'backstageRecharge','remit','rechargePrize','active_cut_money','active_add_money','active_money','back_water',
- // 'return_water','take_money','cut_money','intoTotalMoney','cut_total_money','profit','all_save_money','all_take_money'];
- // $arr = arrayToNum($data,$type);
- return responseToJson($data);
- }
- }
- ?>
|