RechargeLists.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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::field('order_amount,create_time')
  37. ->where([
  38. 'user_id' => $this->userId,
  39. 'pay_status' => PayEnum::ISPAID
  40. ])
  41. ->order('id', 'desc')
  42. ->select()
  43. ->toArray();
  44. foreach($lists as &$item) {
  45. $item['tips'] = '充值' . format_amount($item['order_amount']) . '元';
  46. }
  47. return $lists;
  48. }
  49. /**
  50. * @notes 获取数量
  51. * @return int
  52. * @author 段誉
  53. * @date 2023/2/23 18:43
  54. */
  55. public function count(): int
  56. {
  57. return RechargeOrder::where([
  58. 'user_id' => $this->userId,
  59. 'pay_status' => PayEnum::ISPAID
  60. ])
  61. ->count();
  62. }
  63. }