UserExtract.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 crmeb\services\WithdrawService;
  15. use think\facade\App;
  16. use think\Request;
  17. /**
  18. * Class UserExtract
  19. * @package app\controller\admin\v1\finance
  20. */
  21. class UserExtract extends AuthController
  22. {
  23. /**
  24. * UserExtract constructor.
  25. * @param App $app
  26. * @param UserExtractServices $services
  27. */
  28. public function __construct(App $app, UserExtractServices $services)
  29. {
  30. parent::__construct($app);
  31. $this->services = $services;
  32. }
  33. /**
  34. * 显示资源列表
  35. *
  36. * @return \think\Response
  37. */
  38. public function index()
  39. {
  40. $where = $this->request->getMore([
  41. ['status', ''],
  42. ['extract_type', ''],
  43. ['nireid', '', '', 'like'],
  44. ['data', '', '', 'time'],
  45. ]);
  46. if (isset($where['extract_type']) && $where['extract_type'] == 'wx') {
  47. $where['extract_type'] = 'weixin';
  48. }
  49. return $this->success($this->services->index($where));
  50. }
  51. /**
  52. * 显示编辑资源表单页.
  53. *
  54. * @param int $id
  55. * @return \think\Response
  56. */
  57. public function edit($id)
  58. {
  59. if (!$id) return $this->fail('数据不存在');
  60. return $this->success($this->services->edit((int)$id));
  61. }
  62. /**
  63. * 保存更新的资源
  64. *
  65. * @param \think\Request $request
  66. * @param int $id
  67. * @return \think\Response
  68. */
  69. public function update(Request $request, $id)
  70. {
  71. if (!$id) return $this->fail('缺少参数!');
  72. $id = (int)$id;
  73. $UserExtract = $this->services->getExtract($id);
  74. if (!$UserExtract) $this->fail('数据不存在');
  75. if ($UserExtract['extract_type'] == 'alipay') {
  76. $data = $this->request->postMore([
  77. 'real_name',
  78. 'mark',
  79. 'extract_price',
  80. 'alipay_code',
  81. ]);
  82. if (!$data['real_name']) return $this->fail('请输入姓名');
  83. if ($data['extract_price'] <= -1) return $this->fail('请输入提现金额');
  84. if (!$data['alipay_code']) return $this->fail('请输入支付宝账号');
  85. } else if ($UserExtract['extract_type'] == 'weixin') {
  86. $data = $this->request->postMore([
  87. 'real_name',
  88. 'mark',
  89. 'extract_price',
  90. 'wechat',
  91. ]);
  92. if ($data['extract_price'] <= -1) return $this->fail('请输入提现金额');
  93. if (!$data['wechat']) return $this->fail('请输入微信账号');
  94. } else {
  95. $data = $this->request->postMore([
  96. 'real_name',
  97. 'extract_price',
  98. 'mark',
  99. 'bank_code',
  100. 'bank_address',
  101. ]);
  102. if (!$data['real_name']) return $this->fail('请输入姓名');
  103. if ($data['extract_price'] <= -1) return $this->fail('请输入提现金额');
  104. if (!$data['bank_code']) return $this->fail('请输入银行卡号');
  105. if (!$data['bank_address']) return $this->fail('请输入开户行');
  106. }
  107. return $this->success($this->services->update($id, $data) ? '修改成功' : '修改失败');
  108. }
  109. /**
  110. * 拒绝
  111. * @param $id
  112. * @return mixed
  113. */
  114. public function refuse($id)
  115. {
  116. if (!$id) $this->fail('缺少参数');
  117. $data = $this->request->postMore([
  118. ['message', '']
  119. ]);
  120. return $this->success($this->services->refuse((int)$id, $data['message']) ? '操作成功' : '操作失败');
  121. }
  122. /**
  123. * 通过
  124. * @param $id
  125. * @return mixed
  126. */
  127. public function adopt($id)
  128. {
  129. if (!$id) $this->fail('缺少参数');
  130. return $this->success($this->services->adopt((int)$id) ? '操作成功' : '操作失败');
  131. }
  132. public function getOrderList()
  133. {
  134. list($status, $page, $limit) = $this->request->getMore([
  135. ['status', 0],
  136. ['page', 1],
  137. ['limit', 10],
  138. ], true);
  139. return $this->success(WithdrawService::init()::getOrderList($status, $page, $limit));
  140. }
  141. public function getOrderExt($id)
  142. {
  143. list($page, $limit) = $this->request->getMore([
  144. ['page', 1],
  145. ['limit', 10],
  146. ], true);
  147. return $this->success(WithdrawService::init()::getOrderExt($id, $page, $limit));
  148. }
  149. public function getOrderTemplate($id)
  150. {
  151. return $this->success(WithdrawService::init()::getOrderTemplate($id));
  152. }
  153. public function changeOrderStatusForm($id)
  154. {
  155. return $this->success($this->services->changeOrderStatusForm($id));
  156. }
  157. public function changeOrderStatus($id)
  158. {
  159. list($apply_img, $seal_img, $status, $remarks) = $this->request->postMore([
  160. ['icon', ''],
  161. ['image', ''],
  162. ['status', 1],
  163. ['remarks', ''],
  164. ], true);
  165. return $this->success(WithdrawService::init()::changeOrderStatus($id, $apply_img, $seal_img, $status, $remarks));
  166. }
  167. }