UserExtract.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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\adminapi\controller\v1\finance;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\user\UserExtractServices;
  14. use think\facade\App;
  15. use think\Request;
  16. class UserExtract extends AuthController
  17. {
  18. /**
  19. * UserExtract constructor.
  20. * @param App $app
  21. * @param UserExtractServices $services
  22. */
  23. public function __construct(App $app, UserExtractServices $services)
  24. {
  25. parent::__construct($app);
  26. $this->services = $services;
  27. }
  28. /**
  29. * 显示资源列表
  30. *
  31. * @return \think\Response
  32. */
  33. public function index()
  34. {
  35. $where = $this->request->getMore([
  36. ['status', ''],
  37. ['extract_type', ''],
  38. ['nireid', '', '', 'like'],
  39. ['data', '', '', 'time'],
  40. ]);
  41. if(isset($where['extract_type']) && $where['extract_type'] == 'wx'){
  42. $where['extract_type'] = 'weixin';
  43. }
  44. return app('json')->success($this->services->index($where));
  45. }
  46. /**
  47. * 显示编辑资源表单页.
  48. *
  49. * @param int $id
  50. * @return \think\Response
  51. */
  52. public function edit($id)
  53. {
  54. if (!$id) return app('json')->fail('数据不存在');
  55. return app('json')->success($this->services->edit((int)$id));
  56. }
  57. /**
  58. * 保存更新的资源
  59. *
  60. * @param \think\Request $request
  61. * @param int $id
  62. * @return \think\Response
  63. */
  64. public function update(Request $request, $id)
  65. {
  66. if (!$id) return app('json')->fail('缺少参数!');
  67. $id = (int)$id;
  68. $UserExtract = $this->services->getExtract($id);
  69. if (!$UserExtract) app('json')->fail('数据不存在');
  70. if ($UserExtract['extract_type'] == 'alipay') {
  71. $data = $this->request->postMore([
  72. 'real_name',
  73. 'mark',
  74. 'extract_price',
  75. 'alipay_code',
  76. ]);
  77. if (!$data['real_name']) return app('json')->fail('请输入姓名');
  78. if ($data['extract_price'] <= -1) return app('json')->fail('请输入提现金额');
  79. if (!$data['alipay_code']) return app('json')->fail('请输入支付宝账号');
  80. } else if ($UserExtract['extract_type'] == 'weixin') {
  81. $data = $this->request->postMore([
  82. 'real_name',
  83. 'mark',
  84. 'extract_price',
  85. 'wechat',
  86. ]);
  87. if ($data['extract_price'] <= -1) return app('json')->fail('请输入提现金额');
  88. if (!$data['wechat']) return app('json')->fail('请输入微信账号');
  89. } else {
  90. $data = $this->request->postMore([
  91. 'real_name',
  92. 'extract_price',
  93. 'mark',
  94. 'bank_code',
  95. 'bank_address',
  96. ]);
  97. if (!$data['real_name']) return app('json')->fail('请输入姓名');
  98. if ($data['extract_price'] <= -1) return app('json')->fail('请输入提现金额');
  99. if (!$data['bank_code']) return app('json')->fail('请输入银行卡号');
  100. if (!$data['bank_address']) return app('json')->fail('请输入开户行');
  101. }
  102. return app('json')->success($this->services->update($id, $data) ? '修改成功' : '修改失败');
  103. }
  104. /**
  105. * 拒绝
  106. * @param $id
  107. * @return mixed
  108. */
  109. public function refuse($id)
  110. {
  111. if (!$id) app('json')->fail('缺少参数');
  112. $data = $this->request->postMore([
  113. ['message', '']
  114. ]);
  115. return app('json')->success($this->services->refuse((int)$id, $data['message']) ? '操作成功' : '操作失败');
  116. }
  117. /**
  118. * 通过
  119. * @param $id
  120. * @return mixed
  121. */
  122. public function adopt($id)
  123. {
  124. if (!$id) app('json')->fail('缺少参数');
  125. return app('json')->success($this->services->adopt((int)$id) ? '操作成功' : '操作失败');
  126. }
  127. }