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