RechargeLists.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\lists\recharge;
  15. use app\api\lists\BaseApiDataLists;
  16. use app\common\enum\PayEnum;
  17. use app\common\model\recharge\RechargeOrder;
  18. /**
  19. * 充值记录列表
  20. * Class RechargeLists
  21. * @package app\api\lists\recharge
  22. */
  23. class RechargeLists extends BaseApiDataLists
  24. {
  25. /**
  26. * @notes 获取列表
  27. * @return array
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @author 段誉
  32. * @date 2023/2/23 18:43
  33. */
  34. public function lists(): array
  35. {
  36. $lists = RechargeOrder::where([
  37. 'user_id' => $this->userId,
  38. // 'pay_status' => PayEnum::ISPAID
  39. ])
  40. ->order('id', 'desc')
  41. ->select()
  42. ->toArray();
  43. foreach($lists as &$item) {
  44. $item['tips'] = '费用' . format_amount($item['order_amount']) . '元';
  45. }
  46. return $lists;
  47. }
  48. /**
  49. * @notes 获取数量
  50. * @return int
  51. * @author 段誉
  52. * @date 2023/2/23 18:43
  53. */
  54. public function count(): int
  55. {
  56. return RechargeOrder::where([
  57. 'user_id' => $this->userId,
  58. 'pay_status' => PayEnum::ISPAID
  59. ])
  60. ->count();
  61. }
  62. }