UserRecharge.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /**
  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. *
  34. * @return \think\Response
  35. */
  36. public function index()
  37. {
  38. $where = $this->request->getMore([
  39. ['data', ''],
  40. ['paid', ''],
  41. ['nickname', ''],
  42. ]);
  43. return app('json')->success($this->services->getRechargeList($where));
  44. }
  45. /**
  46. * 删除指定资源
  47. *
  48. * @param int $id
  49. * @return \think\Response
  50. */
  51. public function delete($id)
  52. {
  53. if (!$id) return app('json')->fail('缺少参数');
  54. return app('json')->success($this->services->delRecharge((int)$id) ? '删除成功' : '删除失败');
  55. }
  56. /**
  57. * 获取用户充值数据
  58. * @return array
  59. */
  60. public function user_recharge()
  61. {
  62. $where = $this->request->getMore([
  63. ['data', ''],
  64. ['paid', ''],
  65. ['nickname', ''],
  66. ]);
  67. return app('json')->success($this->services->user_recharge($where));
  68. }
  69. /**退款表单
  70. * @param $id
  71. * @return mixed|void
  72. */
  73. public function refund_edit($id)
  74. {
  75. if (!$id) return app('json')->fail('数据不存在');
  76. return app('json')->success($this->services->refund_edit((int)$id));
  77. }
  78. /**
  79. * 退款操作
  80. * @param $id
  81. */
  82. public function refund_update($id)
  83. {
  84. $data = $this->request->postMore([
  85. 'refund_price',
  86. ]);
  87. if (!$id) return app('json')->fail('数据不存在');
  88. // if (!$data['refund_price']) return app('json')->fail('请输入退款金额');
  89. return app('json')->success($this->services->refund_update((int)$id, $data['refund_price']) ? '退款成功' : '退款失败');
  90. }
  91. }