UserExchange.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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\UserExchangeServices;
  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 UserExchange extends AuthController
  22. {
  23. /**
  24. * UserExtract constructor.
  25. * @param App $app
  26. * @param UserExchangeServices $services
  27. */
  28. public function __construct(App $app, UserExchangeServices $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. ['nireid', '', '', 'like'],
  43. ['data', '', '', 'time'],
  44. ]);
  45. return $this->success($this->services->index($where));
  46. }
  47. /**
  48. * 显示编辑资源表单页.
  49. *
  50. * @param int $id
  51. * @return \think\Response
  52. */
  53. public function edit($id)
  54. {
  55. if (!$id) return $this->fail('数据不存在');
  56. return $this->success($this->services->edit((int)$id));
  57. }
  58. /**
  59. * 保存更新的资源
  60. *
  61. * @param \think\Request $request
  62. * @param int $id
  63. * @return \think\Response
  64. */
  65. public function update(Request $request, $id)
  66. {
  67. if (!$id) return $this->fail('缺少参数!');
  68. $id = (int)$id;
  69. $UserExtract = $this->services->getExtract($id);
  70. if (!$UserExtract) $this->fail('数据不存在');
  71. $data = $this->request->postMore([
  72. 'real_name',
  73. 'account',
  74. 'extract_price',
  75. 'extract_num',
  76. 'exchange_num',
  77. 'mark',
  78. 'bank_code',
  79. 'bank_address',
  80. ]);
  81. if (!$data['real_name']) return $this->fail('请输入姓名');
  82. if ($data['extract_num'] <= 0) return $this->fail('请输入转换能量');
  83. if ($data['extract_price'] <= 0) return $this->fail('请输入股份价格');
  84. if ($data['exchange_num'] <= 0) return $this->fail('请输入转换股份');
  85. if (!$data['bank_code']) return $this->fail('请输入银行卡号');
  86. if (!$data['bank_address']) return $this->fail('请输入开户行');
  87. if (!$data['account']) return $this->fail('请输入账号');
  88. return $this->success($this->services->update($id, $data) ? '修改成功' : '修改失败');
  89. }
  90. /**
  91. * 拒绝
  92. * @param $id
  93. * @return mixed
  94. */
  95. public function refuse($id)
  96. {
  97. if (!$id) $this->fail('缺少参数');
  98. $data = $this->request->postMore([
  99. ['message', '']
  100. ]);
  101. return $this->success($this->services->refuse((int)$id, $data['message']) ? '操作成功' : '操作失败');
  102. }
  103. /**
  104. * 通过
  105. * @param $id
  106. * @return mixed
  107. */
  108. public function adopt($id)
  109. {
  110. if (!$id) $this->fail('缺少参数');
  111. return $this->success($this->services->adopt((int)$id) ? '操作成功' : '操作失败');
  112. }
  113. public function getOrderList()
  114. {
  115. list($status, $page, $limit) = $this->request->getMore([
  116. ['status', 0],
  117. ['page', 1],
  118. ['limit', 10],
  119. ], true);
  120. return $this->success(WithdrawService::init()::getOrderList($status, $page, $limit));
  121. }
  122. public function getOrderExt($id)
  123. {
  124. list($page, $limit) = $this->request->getMore([
  125. ['page', 1],
  126. ['limit', 10],
  127. ], true);
  128. return $this->success(WithdrawService::init()::getOrderExt($id, $page, $limit));
  129. }
  130. public function getOrderTemplate($id)
  131. {
  132. return $this->success(WithdrawService::init()::getOrderTemplate($id));
  133. }
  134. public function changeOrderStatusForm($id)
  135. {
  136. return $this->success($this->services->changeOrderStatusForm($id));
  137. }
  138. public function changeOrderStatus($id)
  139. {
  140. list($apply_img, $seal_img, $status, $remarks) = $this->request->postMore([
  141. ['icon', ''],
  142. ['image', ''],
  143. ['status', 1],
  144. ['remarks', ''],
  145. ], true);
  146. return $this->success(WithdrawService::init()::changeOrderStatus($id, $apply_img, $seal_img, $status, $remarks));
  147. }
  148. }