Finance.php 5.4 KB

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