RechargeLists.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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\agricultural_machinery\UserService;
  18. use app\common\model\recharge\RechargeOrder;
  19. /**
  20. * 充值记录列表
  21. * Class RechargeLists
  22. * @package app\api\lists\recharge
  23. */
  24. class RechargeLists extends BaseApiDataLists
  25. {
  26. /**
  27. * @notes 获取列表
  28. * @return array
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. * @author 段誉
  33. * @date 2023/2/23 18:43
  34. */
  35. public function lists(): array
  36. {
  37. $lists = RechargeOrder::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. $user_service = UserService::where(['order_id'=>$item['id']])->find();
  46. $type = 0;
  47. if($user_service){
  48. $type = $user_service['type'];
  49. }
  50. $type_name = '';
  51. switch ($type){
  52. case 1:
  53. $type_name='认证农机手服务';
  54. break;
  55. case 2:
  56. $type_name='认证烘干服务';
  57. break;
  58. case 3:
  59. $type_name='认证飞防服务';
  60. break;
  61. default:
  62. $type_name='认证服务';
  63. break;
  64. }
  65. $item['tips'] = $type_name.'费用' . format_amount($item['order_amount']) . '元';
  66. }
  67. return $lists;
  68. }
  69. /**
  70. * @notes 获取数量
  71. * @return int
  72. * @author 段誉
  73. * @date 2023/2/23 18:43
  74. */
  75. public function count(): int
  76. {
  77. return RechargeOrder::where([
  78. 'user_id' => $this->userId,
  79. 'pay_status' => PayEnum::ISPAID
  80. ])
  81. ->count();
  82. }
  83. }