RechargeOrderLists.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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\orders;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\orders\RechargeOrder;
  17. use app\common\lists\ListsSearchInterface;
  18. use app\common\model\property\PropertyOrder;
  19. use think\db\Query;
  20. /**
  21. * RechargeOrder列表
  22. * Class RechargeOrderLists
  23. * @package app\adminapi\listsorders
  24. */
  25. class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterface
  26. {
  27. /**
  28. * 获取数据权限
  29. * $this->adminInfo['data_rules']
  30. * province city admin_id sale_group_id sale_id property_head_id
  31. */
  32. public function queryDataWhere(){
  33. $where = [];
  34. $data_rules = $this->adminInfo['data_rules'];
  35. /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
  36. $where[] = ['province','in' ,$data_rules['province']];
  37. }
  38. if (isset($data_rules['city']) && !empty($data_rules['city'])) {
  39. $where[] = ['city','in' ,$data_rules['city']];
  40. }*/
  41. if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
  42. $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
  43. $where[] = ['work_id','in' ,$work_ids];
  44. }
  45. if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
  46. $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
  47. $where[] = ['work_id','in' ,$work_ids];
  48. }
  49. if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
  50. $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
  51. $where[] = ['work_id','in' ,$work_ids];
  52. }
  53. return $where;
  54. }
  55. /**
  56. * @notes 设置搜索条件
  57. * @return \string[][]
  58. * @author likeadmin
  59. * @date 2024/07/10 14:53
  60. */
  61. public function setSearch(): array
  62. {
  63. return [
  64. '=' => ['sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id'],
  65. ];
  66. }
  67. public function queryWhere():array
  68. {
  69. $where = [];
  70. if(isset($this->params['create_time']) && !empty($this->params['create_time'])){
  71. $time = [strtotime($this->params['create_time'][0]), strtotime($this->params['create_time'][1])];
  72. $where[] = ['create_time', 'between', $time];
  73. }
  74. if(isset($this->params['update_time']) && !empty($this->params['update_time'])){
  75. $time = [strtotime($this->params['update_time'][0]), strtotime($this->params['update_time'][1])];
  76. $where[] = ['update_time', 'between', $time];
  77. }
  78. return $where;
  79. }
  80. /**
  81. * @notes 获取列表
  82. * @return array
  83. * @throws \think\db\exception\DataNotFoundException
  84. * @throws \think\db\exception\DbException
  85. * @throws \think\db\exception\ModelNotFoundException
  86. * @author likeadmin
  87. * @date 2024/07/10 14:53
  88. */
  89. public function lists(): array
  90. {
  91. return RechargeOrder::with(['orderGoods'=>function(Query $query){
  92. $query->field('id,sn,goods_id,goods_name,goods_image,goods_number,good_unit,goods_size,goods_type,goods_brand,base_service_fee,service_total,service_fee')->order(['id'=>'desc']);
  93. }])->where($this->searchWhere)
  94. ->where($this->queryDataWhere())
  95. ->where($this->queryWhere())
  96. ->field(['id', 'sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_total', 'order_amount', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id', 'create_time', 'update_time'])
  97. ->limit($this->limitOffset, $this->limitLength)
  98. ->order(['id' => 'desc'])
  99. ->select()
  100. ->toArray();
  101. }
  102. /**
  103. * @notes 获取数量
  104. * @return int
  105. * @author likeadmin
  106. * @date 2024/07/10 14:53
  107. */
  108. public function count(): int
  109. {
  110. return RechargeOrder::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
  111. }
  112. }