MoneyListController.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Request;
  6. /**
  7. *
  8. */
  9. class MoneyListController extends Controller {
  10. /**
  11. * @return 资金流水管理
  12. */
  13. function index(Req $req) {
  14. $request=array();
  15. $request['account_name']=isset($req->account_name)?trim($req->account_name):null;
  16. $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
  17. $request['trade_type'] = isset($req->trade_type) ? trim($req->trade_type) : null;
  18. $request['money_small'] = isset($req->money_small) ? trim($req->money_small) : null;
  19. $request['money_big'] = isset($req->money_big) ? trim($req->money_big) : null;
  20. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
  21. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
  22. $request['status']=isset($req->status) ? trim($req->status) : '';
  23. $dt = \App\Lib\DataTable\DataTable::init();
  24. $isuser = !empty(Request::has('isuser')) ? Request::get('isuser') : 2;
  25. $dt->setDataSource('/admin/money/moneyWaterList?account_name=' . $request['account_name'] . '&isuser=' . $isuser);
  26. $dt->setLang('money');
  27. $dt->setPriKey('trade_id');
  28. $dt->addColsFields('id', array('width' => 80));
  29. $dt->addColsFields('account_name', array('templet' => '#usermoneyRecord', 'width' => 110));
  30. $dt->addColsFields('money_time', array('templet' => '#orderid_time','width' => 240));
  31. $dt->addColsFields('change_cash', array('templet' => '#money_aftercash','width' => 290));
  32. $dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort'=>false,'width' => 160));
  33. $dt->addColsFields('trade_desc', array('templet' => '#ordertype','sort'=>false));
  34. $dt->addColsFields('game_view', array('templet' => '#game','width' => 100,'sort'=>false,'align' => 'left'));
  35. return view('admin.moneylist/index', $dt->render($request));
  36. }
  37. /**
  38. * 单用户资金流水列表
  39. * [detail description]
  40. * @return [type] [description]
  41. */
  42. function usermoneyRecord() {
  43. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  44. $dt = \App\Lib\DataTable\DataTable::init();
  45. $dt->setDataSource('/admin/money/moneyWaterList?account_name=' . $account_name . '&sureblur=精确');
  46. $dt->setLang('money');
  47. $dt->setPriKey('trade_id');
  48. $dt->addColsFields('id', array('width' => 100));
  49. $dt->addColsFields('account_name', array('width' => 140));
  50. $dt->addColsFields('money_time', array('width' => 200));
  51. $dt->addColsFields('systemuser_ordertype', array('sort' => false, 'width' => 160));
  52. $dt->addColsFields('money', array('width' => 120));
  53. $dt->addColsFields('reason', array('sort' => false));
  54. $dt->setToolBar(array('view'), array('width' => 80));
  55. return view('admin.view', $dt->render());
  56. }
  57. //查看资金流水
  58. function View(Req $req) {
  59. $order_id = $req->order_id;
  60. if (empty($order_id)) {
  61. abort(404);
  62. }
  63. $money_db = new \App\Models\Money_details;
  64. $bank_db = new \App\Models\Account_bank;
  65. $data = $money_db->getOrderDetails($order_id, 3);
  66. $bank_data = $bank_db->getInfoByUid($data['account_identity']);
  67. $data['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
  68. $data['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
  69. $data['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
  70. $data['money_cash'] = round($data['money_cash'],2);
  71. $data['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
  72. return view('admin.moneylist/view', ['data' => $data]);
  73. }
  74. //获取按照类型统计
  75. function getCount(Req $req) {
  76. $startTime = $req->startTime;
  77. $endTime = $req->endTime;
  78. $type = $req->type;
  79. $res = $this->getSumMoney($startTime, $endTime, $type);
  80. return responseToJson($res);
  81. }
  82. //按照类型统计总金额
  83. function getSumMoney($where, $type = '') {
  84. $db = new \App\Models\Money_details;
  85. $where[]=array('status','=',1);
  86. return $db->totalTypeMoney($where);
  87. }
  88. function getActive($where, $type) {
  89. $db = new \App\Models\Money_details;
  90. return $db->getActiveMoney($where, $type);
  91. }
  92. //统计总数
  93. //统计总数
  94. function allTotal(Req $req) {
  95. $where = $req->where;
  96. if (count($where) == 0) {
  97. return $where=array();
  98. }
  99. $data_odc=$this->getSumMoney($where);
  100. $data = array();
  101. //赋初值
  102. $data['totalMoney']=0;
  103. $data['onlineRecharge']=0;
  104. $data['backstageRecharge']=0;
  105. $data['remit']=0;
  106. $data['rechargePrize']=0;
  107. $data['active_add_money']=0;
  108. $data['active_cut_money']=0;
  109. $data['active_money']=0;
  110. $data['back_water']=0;
  111. $data['return_water']=0;
  112. $data['take_money']=0;
  113. $data['cut_money']=0;
  114. $data['commission_addmoney']=0;
  115. $data['nagentin']=0; //代理充值
  116. $data['nagentout']=0; //代理代充
  117. foreach ($data_odc as $k=>$v){
  118. if($v['trade_type']==6){
  119. $data['onlineRecharge']=round($v['money'],2);
  120. }
  121. if($v['trade_type']==11){
  122. $data['backstageRecharge']=round($v['money'],2);//后台充值
  123. }
  124. if($v['trade_type']==14){
  125. $data['remit']=round($v['money'],2);
  126. }
  127. if($v['trade_type']==13){
  128. $data['rechargePrize']=round($v['money'],2);
  129. }
  130. if($v['trade_type']==12&&$v['money_type']==1){
  131. $data['active_add_money']=round($v['money'],2);
  132. $data['active_money']+= $data['active_add_money'];
  133. }
  134. if($v['trade_type']==12&&$v['money_type']==2){
  135. $data['active_cut_money']=round($v['money'],2);
  136. $data['active_money']+=$data['active_cut_money'];
  137. }
  138. if($v['trade_type']==7){
  139. $data['back_water']=round($v['money'],2);
  140. }
  141. if($v['trade_type']==8){
  142. $data['return_water']=round($v['money'],2);
  143. }
  144. if($v['trade_type']==5){
  145. $data['take_money'] =round($v['money'],2); //5前台提现
  146. }
  147. if($v['trade_type']==9){
  148. $data['cut_money'] = round($v['money'],2); //管理员扣款
  149. }
  150. if($v['trade_type']==16&&$v['money_type']==1){
  151. $data['reward_addmoney']=round($v['money'],2);
  152. }
  153. if($v['trade_type']==16&&$v['money_type']==2){
  154. $data['reward_reducemoney']=round($v['money'],2);
  155. }
  156. if($v['trade_type']==19&&$v['money_type']==1){
  157. $data['conversion_addmoney']=round($v['money'],2);
  158. }
  159. if($v['trade_type']==19&&$v['money_type']==2){
  160. $data['conversion_reducemoney']=round($v['money'],2);
  161. }
  162. if($v['trade_type']==10&&$v['money_type']==1){
  163. $data['commission_addmoney']=round($v['money'],2);
  164. }
  165. if($v['trade_type']==22&&$v['money_type']==2){
  166. $data['nagentout']=round($v['money'],2);
  167. }
  168. if($v['trade_type']==22&&$v['money_type']==1){
  169. $data['nagentin']=round($v['money'],2);
  170. }
  171. $data['totalMoney']+=$v['money'];
  172. }
  173. if(empty($data['reward_addmoney'])){
  174. $data['reward_addmoney'] =0;
  175. }
  176. if(empty($data['reward_reducemoney'])){
  177. $data['reward_reducemoney'] =0;
  178. }
  179. if(empty($data['conversion_addmoney'])){
  180. $data['conversion_addmoney'] =0;
  181. }
  182. if(empty($data['conversion_reducemoney'])){
  183. $data['conversion_reducemoney'] =0;
  184. }
  185. // $data['totalMoney'] = $this->getSumMoney($where);
  186. // $data['onlineRecharge'] = $this->getSumMoney($where, 6); //在线充值
  187. // $data['backstageRecharge'] = $this->getSumMoney($where, 11); //后台充值
  188. // $data['remit'] = $this->getSumMoney($where, 14); //14汇款
  189. // $data['rechargePrize'] = $this->getSumMoney($where, 13); //13充值赠送
  190. //活动金额
  191. // $data['active_cut_money'] = $this->getActive($where, 2); //活动扣除
  192. // $data['active_cut_money']=round($data['active_cut_money'],2);
  193. // $data['totalMoney']+=$data['active_cut_money'];
  194. // $data['active_add_money'] = $this->getActive($where, 1); //活动加款
  195. // $data['active_add_money']=round($data['active_add_money'],2);
  196. // $data['active_money'] = $this->getSumMoney($where, 12); //总活动
  197. // $data['back_water'] = $this->getSumMoney($where, 7); //反水
  198. // $data['return_water'] = $this->getSumMoney($where, 8); //回水
  199. // $data['take_money'] = $this->getSumMoney($where, 5); //5前台提现
  200. // $data['cut_money'] = $this->getSumMoney($where, 9); //管理员扣款
  201. $data['intoTotalMoney'] = $data['onlineRecharge'] + $data['backstageRecharge'] + $data['remit'] + $data['nagentin']; //总入款扣除活动充值赠送
  202. $data['cut_total_money'] = $data['cut_money'] + $data['take_money'] + $data['nagentout']; //扣款总额扣除活动充值赠送
  203. $data['profit'] = $data['intoTotalMoney'] - $data['cut_total_money'];
  204. $data['all_save_money'] = $data['intoTotalMoney'] + $data['active_add_money'] + $data['rechargePrize'] + $data['back_water'] + $data['return_water']; //总存款
  205. $data['all_take_money'] = $data['take_money'] + $data['cut_money'] + $data['active_cut_money'] + $data['nagentout']; //总扣款
  206. // $type= ['totalMoney', 'onlineRecharge', 'backstageRecharge','remit','rechargePrize','active_cut_money','active_add_money','active_money','back_water',
  207. // 'return_water','take_money','cut_money','intoTotalMoney','cut_total_money','profit','all_save_money','all_take_money'];
  208. // $arr = arrayToNum($data,$type);
  209. return responseToJson($data);
  210. }
  211. }
  212. ?>