ServiceOrderLists.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 ServiceOrderLists extends BaseApiDataLists
  24. {
  25. protected $count = 0;
  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. */
  33. public function lists(): array
  34. {
  35. $lists = RechargeOrder::with(['order_goods'=>function ($query) {
  36. $query->visible(['goods_name','goods_image','goods_number','good_unit']);
  37. },'service_work'=>function ($query) {
  38. $query->visible(['service_status']);
  39. }])
  40. ->visible(['id','sn','order_total','order_amount','pay_status','create_time'])
  41. ->where([
  42. 'order_type' => 0,
  43. 'user_id' => $this->userId,
  44. ])
  45. ->limit($this->limitOffset, $this->limitLength)
  46. ->group('work_id')
  47. ->order('id', 'desc')
  48. ->select()
  49. ->toArray();
  50. $this->count = RechargeOrder::where([
  51. 'order_type' => 0,
  52. 'user_id' => $this->userId,
  53. ])
  54. ->group('work_id')
  55. ->count();
  56. return $lists;
  57. }
  58. /**
  59. * @notes 获取数量
  60. * @return int
  61. */
  62. public function count(): int
  63. {
  64. return $this->count;
  65. }
  66. }