Bank.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 客户收益管理
  7. */
  8. namespace app\green\controller;
  9. use app\common\model\SystemUserBank;
  10. use app\common\model\SystemUser;
  11. use app\green\model\GreenBankCash;
  12. use app\green\model\GreenConfig;
  13. use app\green\model\GreenUser;
  14. class Bank extends Common{
  15. public function initialize(){
  16. parent::initialize();
  17. if(!$this->founder){
  18. $this->error('您无权限操作');
  19. }
  20. $this->assign('pathMaps', [['name'=>'财务管理','url'=>url("bank/cash")]]);
  21. }
  22. /**
  23. * 客户提现
  24. */
  25. public function cash($types = 0){
  26. $keyword = trim(input('get.keyword','','htmlspecialchars'));
  27. $condition = [];
  28. $condition['GreenBankCash.member_miniapp_id'] = $this->member_miniapp_id;
  29. switch ($types) {
  30. case 1:
  31. $state = -1;
  32. break;
  33. case 2:
  34. $state = 1;
  35. break;
  36. default:
  37. $state = 0;
  38. break;
  39. }
  40. $condition['state'] = $state;
  41. $view['list'] = GreenBankCash::hasWhere('user', function($query) use ($keyword){
  42. $query->where('phone_uid', 'like', '%'.$keyword.'%');
  43. })->where($condition)->order('id desc')->paginate(20,false,['query' => ['types' => $types]]);
  44. $view['now_money'] = GreenBankCash::where(['member_miniapp_id' =>$this->member_miniapp_id,'state' => 0])->sum('money');
  45. $view['realmoney'] = GreenBankCash::where(['member_miniapp_id' =>$this->member_miniapp_id,'state' => 1])->sum('realmoney');
  46. $view['back_money'] = GreenBankCash::where(['member_miniapp_id' =>$this->member_miniapp_id,'state' => -1])->sum('money');
  47. $view['keyword'] = $keyword;
  48. $view['types'] = $types;
  49. $view['pathMaps'] = [['name'=>' 提现管理','url' => url("bank/cash")]];
  50. return view()->assign($view);
  51. }
  52. /**
  53. * 客户审核
  54. */
  55. public function cashpass(int $id){
  56. if(request()->isAjax()){
  57. $data = [
  58. 'id' => input('post.id/d'),
  59. 'ispass' => input('post.ispass/d'),
  60. 'miniapp_id' => $this->member_miniapp_id,
  61. 'realmoney' => input('post.realmoney/f')
  62. ];
  63. $validate = $this->validate($data,'Bank.cash');
  64. if(true !== $validate){
  65. return json(['code'=>0,'msg'=>$validate]);
  66. }
  67. $result = GreenBankCash::isPass($data,$this->member_miniapp_id);
  68. return json($result);
  69. }else{
  70. $cash = GreenBankCash::where(['member_miniapp_id' => $this->member_miniapp_id,'id' => $id])->find();;
  71. if(empty($cash)){
  72. $this->error('未找到到申请提现内容');
  73. }
  74. $setting = GreenConfig::where(['member_miniapp_id' => $this->member_miniapp_id])->find();
  75. $view['cash'] = $cash;
  76. $view['realmoney'] = $cash->money;
  77. $view['bank'] = GreenUser::where(['uid' => $cash->user_id])->find();
  78. $view['info'] = SystemUserBank::where(['user_id' => $cash->user_id])->find();
  79. $view['wechat'] = User::where(['id' => $cash->user_id])->field('id,miniapp_uid,phone_uid,official_uid')->find();
  80. $view['config'] = $setting ;
  81. return view()->assign($view);
  82. }
  83. }
  84. }