GroupUserOrderLists.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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\adminapi\lists\group_activity;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\model\group_activity\GroupUserOrder;
  18. /**
  19. * 拼团订单列表
  20. * Class GroupUserOrderLists
  21. * @package app\adminapi\listsgroup_activity
  22. */
  23. class GroupUserOrderLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2025/03/13 10:31
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['a.status','a.pay_status','a.pay_way','a.refund_status','a.group_activity_id','a.user_equity_id','a.group_order_id','c.sn','d.mobile'],
  35. ];
  36. }
  37. public function queryWhere(){
  38. $where = [];
  39. if(!empty($this->params['area'])){
  40. $where[] = ['a.area', 'like', '%'.$this->params['area'].'%'];
  41. }
  42. if(!empty($this->params['title'])){
  43. $where[] = ['b.title', 'like', '%'.$this->params['title'].'%'];
  44. }
  45. if (isset($this->params['group_order_status'])) {
  46. $where[] = ['c.status', '=', $this->params['group_order_status']];
  47. }
  48. return $where;
  49. }
  50. /**
  51. * @notes 获取拼团订单列表
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @author likeadmin
  57. * @date 2025/03/13 10:31
  58. */
  59. public function lists(): array
  60. {
  61. $list = GroupUserOrder::alias('a')
  62. ->leftJoin('group_activity b', 'b.id = a.group_activity_id')
  63. ->leftJoin('group_order c', 'c.id = a.group_order_id')
  64. ->leftJoin('user d', 'd.id = a.user_id')
  65. ->where($this->searchWhere)
  66. ->where($this->queryWhere())
  67. ->field(['a.*', 'b.title','b.image','c.sn as group_order_sn','c.status as group_order_status','d.mobile'])
  68. ->append(['group_order_status_text','status_text','pay_status_text','pay_way_text','refund_status_text'])
  69. ->limit($this->limitOffset, $this->limitLength)
  70. ->order(['a.id' => 'desc'])
  71. ->select()
  72. ->toArray();
  73. return $list;
  74. }
  75. /**
  76. * @notes 获取拼团活动数量
  77. * @return int
  78. * @author likeadmin
  79. * @date 2025/03/13 10:31
  80. */
  81. public function count(): int
  82. {
  83. return GroupUserOrder::alias('a')
  84. ->leftJoin('group_activity b', 'b.id = a.group_activity_id')
  85. ->leftJoin('group_order c', 'c.id = a.group_order_id')
  86. ->leftJoin('user d', 'd.id = a.user_id')
  87. ->where($this->searchWhere)
  88. ->where($this->queryWhere())
  89. ->count();
  90. }
  91. public function setExcelComplexFields(): array
  92. {
  93. $zh_cn_fields = [
  94. '订单ID','活动标题', '拼团编号','拼团状态','用户ID','手机号','小区','详细地址','订单状态','应付金额','已付金额','支付方式','支付状态','支付时间','退款状态','下单时间'
  95. ];
  96. $data_fields = ['id','title','group_order_sn','group_order_status_text','user_id','mobile','area','address','status_text','order_amount','paid_amount','pay_way_text','pay_status_text','pay_time','refund_status_text','create_time'];
  97. return [
  98. 'zh_cn_fields' => $zh_cn_fields,
  99. 'data_fields' => $data_fields
  100. ];
  101. }
  102. }