Usertakecash.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 用户提现申请
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Usertakecash extends Backend
  11. {
  12. /**
  13. * Usertakecash模型对象
  14. * @var \app\admin\model\Usertakecash
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Usertakecash;
  21. $this->view->assign("typeList", $this->model->getTypeList());
  22. $this->view->assign("statusList", $this->model->getStatusList());
  23. }
  24. /**
  25. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  26. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  27. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  28. */
  29. /**
  30. * 查看
  31. */
  32. public function index()
  33. {
  34. //当前是否为关联查询
  35. $this->relationSearch = true;
  36. //设置过滤方法
  37. $this->request->filter(['strip_tags', 'trim']);
  38. if ($this->request->isAjax()) {
  39. //如果发送的来源是Selectpage,则转发到Selectpage
  40. if ($this->request->request('keyField')) {
  41. return $this->selectpage();
  42. }
  43. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  44. $list = $this->model
  45. ->with(['user'])
  46. ->where($where)
  47. ->order($sort, $order)
  48. ->paginate($limit);
  49. foreach ($list as $row) {
  50. $row->getRelation('user')->visible(['username','nickname','mobile']);
  51. }
  52. $result = array("total" => $list->total(), "rows" => $list->items());
  53. return json($result);
  54. }
  55. return $this->view->fetch();
  56. }
  57. /**
  58. * 审核
  59. */
  60. public function audit(){
  61. $id = input('id');
  62. $info = Db::name('user_take_cash')
  63. ->where('id',$id)
  64. ->find();
  65. if ($this->request->isPost()) {
  66. $status = input('status',0);
  67. $data = [
  68. 'status' => $status,
  69. 'auditremark' => input('auditremark',''),
  70. 'audittime' => strtotime(input('audittime','')),
  71. 'updatetime' => time(),
  72. ];
  73. Db::startTrans();
  74. $rs = Db::name('user_take_cash')->where('id',$id)->update($data);
  75. if($status == 1){
  76. $remark = '提现(成功)';
  77. Db::name('user_money_log')->where('table','user_take_cash')->where('table_id',$id)->update(['remark'=>$remark]);
  78. }elseif($status == 2){
  79. $remark = '提现(驳回)';
  80. Db::name('user_money_log')->where('table','user_take_cash')->where('table_id',$id)->update(['remark'=>$remark]);
  81. //还钱
  82. $wallet_rs = model('wallet')->lockChangeAccountRemain($info['user_id'],'money',$info['money'],22,'提现被拒返回:'.$info['money'],'user_take_cash',$id);
  83. if($wallet_rs['status'] === false){
  84. Db::rollback();
  85. $this->error($wallet_rs['msg']);
  86. }
  87. }
  88. Db::commit();
  89. $this->success('审核完成');
  90. }
  91. $account_info = json_decode($info['acount_json'],true);
  92. if($info['type'] == 2){
  93. $info['account_info'] = '姓名:'.$account_info['realname'].',账号:'.$account_info['bank_no'].',开户行:'.$account_info['open_bank'];
  94. }elseif($info['type'] == 1){
  95. $info['account_info'] = '姓名:'.$account_info['realname'].',账号:'.$account_info['pay_no'];
  96. }else{
  97. $info['account_info'] = '姓名:'.$account_info['realname'].',账号:'.$account_info['pay_no'];
  98. }
  99. $this->assign('row',$info);
  100. return $this->view->fetch();
  101. }
  102. }