Recharge.php 2.4 KB

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