Finance.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /**
  3. *
  4. * User: anyluck
  5. * Date: 2020/6/2
  6. * Time: 17:43
  7. */
  8. namespace app\admin\controller;
  9. use app\common\controller\Backend;
  10. use app\common\controller\Orde;
  11. use app\common\model\Bond;
  12. use app\common\model\GeneralFinance;
  13. use think\facade\Request;
  14. use think\facade\View;
  15. class Finance extends Backend
  16. {
  17. // 财务管理
  18. /**
  19. * 财务统计
  20. */
  21. public function tongji()
  22. {
  23. if (Request::isPost()) {
  24. $name = input("name");
  25. $page = input("page") ?: 1;
  26. $limit = input("limit") ?: 10;
  27. $where = [];
  28. // if ($name){
  29. // $where["name"]=["like","% $name %"];
  30. // }
  31. $where["daili"]=0;
  32. $list = \app\common\model\Finance::where($where)->order("id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) {
  33. $user = \app\common\model\User::where(["id" => $item["user_id"]])->field("name")->find();
  34. $item["user_name"] = $user->name;
  35. return $item;
  36. })->toArray();
  37. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0];
  38. }
  39. return View::fetch();
  40. }
  41. /**
  42. * 充值审核
  43. */
  44. public function shenhe()
  45. {
  46. if (Request::isPost()) {
  47. $name = input("name");
  48. $page = input("page") ?: 1;
  49. $limit = input("limit") ?: 10;
  50. $where = [];
  51. // if ($name){
  52. // $where["name"]=["like","% $name %"];
  53. // }
  54. // $where["type"]=0;
  55. $list = GeneralFinance::where($where)->order("status asc,id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) {
  56. $user = \app\common\model\User::where(["id" => $item["user_id"]])->field("name")->find();
  57. $item["user_name"] = $user->name;
  58. $item["add_time"]=date("Y-m-d H:i:s",$item["add_time"]);
  59. if ($item["status"]==0){
  60. $item["status"]="审核中";
  61. }elseif($item["status"]==1){
  62. $item["status"]="已通过";
  63. }else{
  64. $item["status"]="已拒绝";
  65. }
  66. return $item;
  67. })->toArray();
  68. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0];
  69. }
  70. return View::fetch();
  71. }
  72. // 审核拒绝general_finance
  73. public function jujue()
  74. {
  75. $id=input("id");
  76. GeneralFinance::update(["status"=>2],["id"=>$id]);
  77. json_result(200,"设置成功");
  78. }
  79. // 充值成功
  80. public function czcg()
  81. {
  82. $id=input("id");
  83. $bond=GeneralFinance::where(["id"=>$id])->find();
  84. // 给用户加钱
  85. $user=\app\common\model\User::where(["id"=>$bond->user_id])->find();
  86. $money=$user->money+$bond->actual_money;
  87. \app\common\model\User::update(["money"=>$money],["id"=>$bond->user_id]);
  88. GeneralFinance::update(["status"=>1],["id"=>$id]);
  89. // 添加财务日记
  90. Orde::Finance($bond->user_id,"您的充值申请审核通过",$bond->actual_money,0);
  91. json_result(200,"设置成功");
  92. }
  93. /**
  94. * 代理收入
  95. */
  96. public function daili()
  97. {
  98. if (Request::isPost()) {
  99. $name = input("name");
  100. $page = input("page") ?: 1;
  101. $limit = input("limit") ?: 10;
  102. $where = [];
  103. // if ($name){
  104. // $where["name"]=["like","% $name %"];
  105. // }
  106. $where["daili"]=1;
  107. $list = \app\common\model\Finance::where($where)->order("id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) {
  108. $user = \app\common\model\User::where(["id" => $item["user_id"]])->field("name")->find();
  109. $item["user_name"] = $user->name;
  110. return $item;
  111. })->toArray();
  112. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0];
  113. }
  114. return View::fetch();
  115. }
  116. /**
  117. * 赠送记录
  118. */
  119. public function zhengshon()
  120. {
  121. if (Request::isPost()) {
  122. $name = input("name");
  123. $page = input("page") ?: 1;
  124. $limit = input("limit") ?: 10;
  125. $where = [];
  126. // if ($name){
  127. // $where["name"]=["like","% $name %"];
  128. // }
  129. $where["daili"]=2;
  130. $list = \app\common\model\Finance::where($where)->order("id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) {
  131. $user = \app\common\model\User::where(["id" => $item["user_id"]])->field("name")->find();
  132. $item["user_name"] = $user->name;
  133. return $item;
  134. })->toArray();
  135. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0];
  136. }
  137. return View::fetch();
  138. }
  139. }