RechargeOrderLists.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 think\db\Query;
  19. /**
  20. * RechargeOrder列表
  21. * Class RechargeOrderLists
  22. * @package app\adminapi\listsorders
  23. */
  24. class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterface
  25. {
  26. /**
  27. * @notes 设置搜索条件
  28. * @return \string[][]
  29. * @author likeadmin
  30. * @date 2024/07/10 14:53
  31. */
  32. public function setSearch(): array
  33. {
  34. return [
  35. '=' => ['sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id'],
  36. ];
  37. }
  38. public function queryWhere():array
  39. {
  40. $where = [];
  41. if(isset($this->params['create_time']) && !empty($this->params['create_time'])){
  42. $time = [strtotime($this->params['create_time'][0]), strtotime($this->params['create_time'][1])];
  43. $where[] = ['create_time', 'between', $time];
  44. }
  45. if(isset($this->params['update_time']) && !empty($this->params['update_time'])){
  46. $time = [strtotime($this->params['update_time'][0]), strtotime($this->params['update_time'][1])];
  47. $where[] = ['update_time', 'between', $time];
  48. }
  49. return $where;
  50. }
  51. /**
  52. * @notes 获取列表
  53. * @return array
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\DbException
  56. * @throws \think\db\exception\ModelNotFoundException
  57. * @author likeadmin
  58. * @date 2024/07/10 14:53
  59. */
  60. public function lists(): array
  61. {
  62. return RechargeOrder::with(['orderGoods'=>function(Query $query){
  63. $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']);
  64. }])->where($this->searchWhere)
  65. ->where($this->queryWhere())
  66. ->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'])
  67. ->limit($this->limitOffset, $this->limitLength)
  68. ->order(['id' => 'desc'])
  69. ->select()
  70. ->toArray();
  71. }
  72. /**
  73. * @notes 获取数量
  74. * @return int
  75. * @author likeadmin
  76. * @date 2024/07/10 14:53
  77. */
  78. public function count(): int
  79. {
  80. return RechargeOrder::where($this->searchWhere)->where($this->queryWhere())->count();
  81. }
  82. }