FundController.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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 FundController 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) : trans('status.default_time.atime');
  21. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
  22. $request['status'] = isset($req->status) ? trim($req->status) : '';
  23. $dt = \App\Lib\DataTable\DataTable::init();
  24. $dt->setDataSource('/admin/money/moneyList?account_name=' . $request['account_name'] );
  25. $dt->setLang('money');
  26. $dt->setPriKey('trade_id');
  27. $dt->addColsFields('id', array('width' => 90));
  28. $dt->addColsFields('account_name', array('sort' => false, 'templet' => '#usermoneyRecord', 'width' => 130));
  29. $dt->addColsFields('money_time', array('templet' => '#orderid_time','width' => 240));
  30. $dt->addColsFields('change_cash', array('templet' => '#money_aftercash','width' => 280));
  31. //$dt->addColsFields('sysetem_user', array('templet' => '#sysetem_user','width' => 280));
  32. $dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort' => false, 'width' => 170));
  33. $dt->addColsFields('trade_desc', array('templet' => '#ordertype','sort' => false));
  34. $dt->setToolBar(array('view'), array('width' => 100,'align' => 'left'));
  35. return view('admin.Fund/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/moneyList?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('sort' => false, 'width' => 140));
  50. $dt->addColsFields('money_time', array('width' => 220));
  51. $dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','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' => 100));
  55. return view('admin.Fund/usermoneyRecord', $dt->render());
  56. }
  57. //查看存取反水
  58. function View(Req $req) {
  59. $order_id = $req->trade_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['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
  71. return view('admin.Fund/view', ['data' => $data]);
  72. }
  73. //获取按照类型统计
  74. function getCount(Req $req) {
  75. $startTime = $req->startTime;
  76. $endTime = $req->endTime;
  77. $type = $req->type;
  78. $res = $this->getSumMoney($startTime, $endTime, $type);
  79. return responseToJson($res);
  80. }
  81. //按照类型统计总金额
  82. function getSumMoney($where, $type = '') {
  83. $db = new \App\Models\Money_details;
  84. $where[]=array('status','=',1);
  85. return $db->totalTypeMoney($where);
  86. }
  87. //入款汇总
  88. function getMoneySum($where, $type = '') {
  89. $db = new \App\Models\Money_details;
  90. $where = array();
  91. if ($type) {
  92. $where[] = array('trade_type', '=', $type);
  93. } else {
  94. //获取总存取反水金额
  95. return $db->getIntoTotal($where);
  96. }
  97. //规定的类型总数
  98. return $db->sumIntoMoney($where);
  99. }
  100. function getActive($where, $type) {
  101. $db = new \App\Models\Money_details;
  102. return $db->getActiveMoney($where, $type);
  103. }
  104. //统计总数
  105. function allTotal(Req $req) {
  106. $where = $req->where;
  107. if (count($where) == 0) {
  108. $where=array();
  109. }
  110. $data_odc=$this->getSumMoney($where);
  111. $data = array();
  112. //赋初值
  113. $data['totalMoney']=0;
  114. $data['onlineRecharge']=0;
  115. $data['backstageRecharge']=0;
  116. $data['remit']=0;
  117. $data['rechargePrize']=0;
  118. $data['active_add_money']=0;
  119. $data['active_cut_money']=0;
  120. $data['active_money']=0;
  121. $data['back_water']=0;
  122. $data['return_water']=0;
  123. $data['take_money']=0;
  124. $data['cut_money']=0;
  125. $data['commission_addmoney']=0;
  126. $data['nagentin'] = 0; //代理代充充值
  127. $data['nagentout'] = 0; //代理代充
  128. foreach ($data_odc as $k=>$v){
  129. if($v['trade_type']==6){
  130. $data['onlineRecharge']=round($v['money'],2);
  131. }
  132. if($v['trade_type']==11){
  133. $data['backstageRecharge']=round($v['money'],2);//后台充值
  134. }
  135. if($v['trade_type']==14){
  136. $data['remit']=round($v['money'],2);
  137. }
  138. if($v['trade_type']==13){
  139. $data['rechargePrize']=round($v['money'],2);
  140. }
  141. if($v['trade_type']==12&&$v['money_type']==1){
  142. $data['active_add_money']=round($v['money'],2);
  143. $data['active_money']+= $data['active_add_money'];
  144. }
  145. if($v['trade_type']==12&&$v['money_type']==2){
  146. $data['active_cut_money']=round($v['money'],2);
  147. $data['active_money']+=$data['active_cut_money'];
  148. }
  149. if($v['trade_type']==7){
  150. $data['back_water']=round($v['money'],2);
  151. }
  152. if($v['trade_type']==8){
  153. $data['return_water']=round($v['money'],2);
  154. }
  155. if($v['trade_type']==5){
  156. $data['take_money'] =round($v['money'],2); //5前台提现
  157. }
  158. if($v['trade_type']==9){
  159. $data['cut_money'] = round($v['money'],2); //管理员扣款
  160. }
  161. if($v['trade_type']==16&&$v['money_type']==1){
  162. $data['reward_addmoney']=round($v['money'],2);
  163. }
  164. if($v['trade_type']==16&&$v['money_type']==2){
  165. $data['reward_reducemoney']=round($v['money'],2);
  166. }
  167. if($v['trade_type']==19&&$v['money_type']==1){
  168. $data['conversion_addmoney']=round($v['money'],2);
  169. }
  170. if($v['trade_type']==19&&$v['money_type']==2){
  171. $data['conversion_reducemoney']=round($v['money'],2);
  172. }
  173. if($v['trade_type']==10&&$v['money_type']==1){
  174. $data['commission_addmoney']=round($v['money'],2);
  175. }
  176. if($v['trade_type']==22&&$v['money_type']==1){
  177. $data['nagentin']=round($v['money'],2);
  178. }
  179. if($v['trade_type']==22&&$v['money_type']==2){
  180. $data['nagentout']=round($v['money'],2);
  181. }
  182. $data['totalMoney']+=$v['money'];
  183. }
  184. if(empty($data['reward_addmoney'])){
  185. $data['reward_addmoney'] =0;
  186. }
  187. if(empty($data['reward_reducemoney'])){
  188. $data['reward_reducemoney'] =0;
  189. }
  190. if(empty($data['conversion_addmoney'])){
  191. $data['conversion_addmoney'] =0;
  192. }
  193. if(empty($data['conversion_reducemoney'])){
  194. $data['conversion_reducemoney'] =0;
  195. }
  196. // $data['totalMoney'] = $this->getSumMoney($where);
  197. // $data['onlineRecharge'] = $this->getSumMoney($where, 6); //在线充值
  198. // $data['backstageRecharge'] = $this->getSumMoney($where, 11); //后台充值
  199. // $data['remit'] = $this->getSumMoney($where, 14); //14汇款
  200. // $data['rechargePrize'] = $this->getSumMoney($where, 13); //13充值赠送
  201. //活动金额
  202. // $data['active_cut_money'] = $this->getActive($where, 2); //活动扣除
  203. // $data['active_cut_money']=round($data['active_cut_money'],2);
  204. // $data['totalMoney']+=$data['active_cut_money'];
  205. // $data['active_add_money'] = $this->getActive($where, 1); //活动加款
  206. // $data['active_add_money']=round($data['active_add_money'],2);
  207. // $data['active_money'] = $this->getSumMoney($where, 12); //总活动
  208. // $data['back_water'] = $this->getSumMoney($where, 7); //反水
  209. // $data['return_water'] = $this->getSumMoney($where, 8); //回水
  210. // $data['take_money'] = $this->getSumMoney($where, 5); //5前台提现
  211. // $data['cut_money'] = $this->getSumMoney($where, 9); //管理员扣款
  212. $data['intoTotalMoney'] = $data['onlineRecharge'] + $data['backstageRecharge'] + $data['remit'] + $data['nagentin']; //总入款扣除活动充值赠送
  213. $data['cut_total_money'] = $data['cut_money'] + $data['take_money'] + $data['nagentout']; //扣款总额扣除活动充值赠送
  214. $data['profit'] = $data['intoTotalMoney'] - $data['cut_total_money'];
  215. $data['all_save_money'] = $data['intoTotalMoney'] + $data['active_add_money'] + $data['rechargePrize'] + $data['back_water'] + $data['return_water']; //总存款
  216. $data['all_take_money'] = $data['take_money'] + $data['cut_money'] + $data['active_cut_money'] + $data['nagentout']; //总扣款
  217. // $type= ['totalMoney', 'onlineRecharge', 'backstageRecharge','remit','rechargePrize','active_cut_money','active_add_money','active_money','back_water',
  218. // 'return_water','take_money','cut_money','intoTotalMoney','cut_total_money','profit','all_save_money','all_take_money'];
  219. // $arr = arrayToNum($data,$type);
  220. return responseToJson($data);
  221. }
  222. }
  223. ?>