UserRecharge.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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\UserRechargeServices;
  14. use think\facade\App;
  15. /**
  16. * Class UserRecharge
  17. * @package app\adminapi\controller\v1\finance
  18. */
  19. class UserRecharge extends AuthController
  20. {
  21. /**
  22. * UserRecharge constructor.
  23. * @param App $app
  24. * @param UserRechargeServices $services
  25. */
  26. public function __construct(App $app, UserRechargeServices $services)
  27. {
  28. parent::__construct($app);
  29. $this->services = $services;
  30. }
  31. /**
  32. * 显示资源列表
  33. * @return \think\Response
  34. */
  35. public function index()
  36. {
  37. $where = $this->request->getMore([
  38. ['data', ''],
  39. ['paid', ''],
  40. ['nickname', ''],
  41. ]);
  42. return app('json')->success($this->services->getRechargeList($where));
  43. }
  44. /**
  45. * 删除指定资源
  46. * @param int $id
  47. * @return \think\Response
  48. */
  49. public function delete($id)
  50. {
  51. if (!$id) return app('json')->fail(100100);
  52. return app('json')->success($this->services->delRecharge((int)$id) ? 100002 : 100008);
  53. }
  54. /**
  55. * 获取用户充值数据
  56. * @return array
  57. */
  58. public function user_recharge()
  59. {
  60. $where = $this->request->getMore([
  61. ['data', ''],
  62. ['paid', ''],
  63. ['nickname', ''],
  64. ]);
  65. return app('json')->success($this->services->user_recharge($where));
  66. }
  67. /**
  68. * 退款表单
  69. * @param $id
  70. * @return mixed|void
  71. */
  72. public function refund_edit($id)
  73. {
  74. if (!$id) return app('json')->fail(100026);
  75. return app('json')->success($this->services->refund_edit((int)$id));
  76. }
  77. /**
  78. * 退款操作
  79. * @param $id
  80. * @return mixed
  81. */
  82. public function refund_update($id)
  83. {
  84. $data = $this->request->postMore([
  85. 'refund_price',
  86. ]);
  87. if (!$id) return app('json')->fail(100026);
  88. return app('json')->success($this->services->refund_update((int)$id, $data['refund_price']) ? 100036 : 100037);
  89. }
  90. }