ServiceOrderLists.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /**
  26. * @notes 获取列表
  27. * @return array
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. */
  32. public function lists(): array
  33. {
  34. $lists = RechargeOrder::with(['order_goods'=>function ($query) {
  35. $query->visible(['goods_name','goods_image','goods_number','good_unit']);
  36. },'service_work'=>function ($query) {
  37. $query->visible(['service_status']);
  38. }])
  39. ->visible(['id','sn','order_total','order_amount','pay_status','create_time'])
  40. ->where([
  41. 'order_type' => 0,
  42. 'user_id' => $this->userId,
  43. ])
  44. ->order('id', 'desc')
  45. ->select()
  46. ->toArray();
  47. return $lists;
  48. }
  49. /**
  50. * @notes 获取数量
  51. * @return int
  52. */
  53. public function count(): int
  54. {
  55. return RechargeOrder::where([
  56. 'order_type' => 0,
  57. 'user_id' => $this->userId,
  58. ])
  59. ->count();
  60. }
  61. }