UserExtract.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\finance;
  12. use app\controller\admin\AuthController;
  13. use app\services\user\UserExtractServices;
  14. use think\facade\App;
  15. use think\Request;
  16. /**
  17. * Class UserExtract
  18. * @package app\controller\admin\v1\finance
  19. */
  20. class UserExtract extends AuthController
  21. {
  22. /**
  23. * UserExtract constructor.
  24. * @param App $app
  25. * @param UserExtractServices $services
  26. */
  27. public function __construct(App $app, UserExtractServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 显示资源列表
  34. *
  35. * @return \think\Response
  36. */
  37. public function index()
  38. {
  39. $where = $this->request->getMore([
  40. ['status', ''],
  41. ['extract_type', ''],
  42. ['nireid', '', '', 'like'],
  43. ['data', '', '', 'time'],
  44. ]);
  45. if(isset($where['extract_type']) && $where['extract_type'] == 'wx'){
  46. $where['extract_type'] = 'weixin';
  47. }
  48. return $this->success($this->services->index($where));
  49. }
  50. /**
  51. * 显示编辑资源表单页.
  52. *
  53. * @param int $id
  54. * @return \think\Response
  55. */
  56. public function edit($id)
  57. {
  58. if (!$id) return $this->fail('数据不存在');
  59. return $this->success($this->services->edit((int)$id));
  60. }
  61. /**
  62. * 保存更新的资源
  63. *
  64. * @param \think\Request $request
  65. * @param int $id
  66. * @return \think\Response
  67. */
  68. public function update(Request $request, $id)
  69. {
  70. if (!$id) return $this->fail('缺少参数!');
  71. $id = (int)$id;
  72. $UserExtract = $this->services->getExtract($id);
  73. if (!$UserExtract) $this->fail('数据不存在');
  74. if ($UserExtract['extract_type'] == 'alipay') {
  75. $data = $this->request->postMore([
  76. 'real_name',
  77. 'mark',
  78. 'extract_price',
  79. 'alipay_code',
  80. ]);
  81. if (!$data['real_name']) return $this->fail('请输入姓名');
  82. if ($data['extract_price'] <= -1) return $this->fail('请输入提现金额');
  83. if (!$data['alipay_code']) return $this->fail('请输入支付宝账号');
  84. } else if ($UserExtract['extract_type'] == 'weixin') {
  85. $data = $this->request->postMore([
  86. 'real_name',
  87. 'mark',
  88. 'extract_price',
  89. 'wechat',
  90. ]);
  91. if ($data['extract_price'] <= -1) return $this->fail('请输入提现金额');
  92. if (!$data['wechat']) return $this->fail('请输入微信账号');
  93. } else {
  94. $data = $this->request->postMore([
  95. 'real_name',
  96. 'extract_price',
  97. 'mark',
  98. 'bank_code',
  99. 'bank_address',
  100. ]);
  101. if (!$data['real_name']) return $this->fail('请输入姓名');
  102. if ($data['extract_price'] <= -1) return $this->fail('请输入提现金额');
  103. if (!$data['bank_code']) return $this->fail('请输入银行卡号');
  104. if (!$data['bank_address']) return $this->fail('请输入开户行');
  105. }
  106. return $this->success($this->services->update($id, $data) ? '修改成功' : '修改失败');
  107. }
  108. /**
  109. * 拒绝
  110. * @param $id
  111. * @return mixed
  112. */
  113. public function refuse($id)
  114. {
  115. if (!$id) $this->fail('缺少参数');
  116. $data = $this->request->postMore([
  117. ['message', '']
  118. ]);
  119. return $this->success($this->services->refuse((int)$id, $data['message']) ? '操作成功' : '操作失败');
  120. }
  121. /**
  122. * 通过
  123. * @param $id
  124. * @return mixed
  125. */
  126. public function adopt($id)
  127. {
  128. if (!$id) $this->fail('缺少参数');
  129. return $this->success($this->services->adopt((int)$id) ? '操作成功' : '操作失败');
  130. }
  131. }