UserRecharge.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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\UserRechargeServices;
  14. use think\facade\App;
  15. class UserRecharge extends AuthController
  16. {
  17. /**
  18. * UserRecharge constructor.
  19. * @param App $app
  20. * @param UserRechargeServices $services
  21. */
  22. public function __construct(App $app, UserRechargeServices $services)
  23. {
  24. parent::__construct($app);
  25. $this->services = $services;
  26. }
  27. /**
  28. * 显示资源列表
  29. *
  30. * @return \think\Response
  31. */
  32. public function index()
  33. {
  34. $where = $this->request->getMore([
  35. ['data', ''],
  36. ['paid', ''],
  37. ['nickname', ''],
  38. ]);
  39. return app('json')->success($this->services->getRechargeList($where));
  40. }
  41. /**
  42. * 删除指定资源
  43. *
  44. * @param int $id
  45. * @return \think\Response
  46. */
  47. public function delete($id)
  48. {
  49. if (!$id) return app('json')->fail('缺少参数');
  50. return app('json')->success($this->services->delRecharge((int)$id) ? '删除成功' : '删除失败');
  51. }
  52. /**
  53. * 获取用户充值数据
  54. * @return array
  55. */
  56. public function user_recharge()
  57. {
  58. $where = $this->request->getMore([
  59. ['data', ''],
  60. ['paid', ''],
  61. ['nickname', ''],
  62. ]);
  63. return app('json')->success($this->services->user_recharge($where));
  64. }
  65. /**退款表单
  66. * @param $id
  67. * @return mixed|void
  68. */
  69. public function refund_edit($id)
  70. {
  71. if (!$id) return app('json')->fail('数据不存在');
  72. return app('json')->success($this->services->refund_edit((int)$id));
  73. }
  74. /**
  75. * 退款操作
  76. * @param $id
  77. */
  78. public function refund_update($id)
  79. {
  80. $data = $this->request->postMore([
  81. 'refund_price',
  82. ]);
  83. if (!$id) return app('json')->fail('数据不存在');
  84. // if (!$data['refund_price']) return app('json')->fail('请输入退款金额');
  85. return app('json')->success($this->services->refund_update((int)$id, $data['refund_price']) ? '退款成功' : '退款失败');
  86. }
  87. }