ShopOrdersLists.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\shops;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\shops\ShopOrders;
  17. use app\common\lists\ListsSearchInterface;
  18. use think\db\Query;
  19. /**
  20. * ShopOrders列表
  21. * Class ShopOrdersLists
  22. * @package app\adminapi\listsshops
  23. */
  24. class ShopOrdersLists extends BaseAdminDataLists implements ListsSearchInterface
  25. {
  26. /**
  27. * @notes 设置搜索条件
  28. * @return \string[][]
  29. * @author likeadmin
  30. * @date 2024/08/04 13:49
  31. */
  32. public function setSearch(): array
  33. {
  34. return [
  35. '=' => ['shop_order_type', 'worker_id', 'real_name', 'mobile', 'pay_status', 'pay_sn', 'paw_way', 'order_terminal', 'transaction_id', 'refund_status'],
  36. '%like%' => ['sn', 'refund_transaction_id'],
  37. ];
  38. }
  39. public function querySearch():array
  40. {
  41. $where = [];
  42. if(isset($this->params['pay_time']) && !empty($this->params['pay_time'])){
  43. $time = [strtotime($this->params['pay_time'][0]), strtotime($this->params['pay_time'][1])];
  44. $where[] = ['pay_time', 'between', $time];
  45. }
  46. return $where;
  47. }
  48. /**
  49. * @notes 获取列表
  50. * @return array
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\DbException
  53. * @throws \think\db\exception\ModelNotFoundException
  54. * @author likeadmin
  55. * @date 2024/08/04 13:49
  56. */
  57. public function lists(): array
  58. {
  59. return ShopOrders::with([
  60. 'worker'=>function(Query $query) {
  61. $query->field("id,worker_number,real_name");
  62. },])
  63. ->where($this->searchWhere)
  64. ->where($this->querySearch())
  65. ->field(['id', 'shop_order_type', 'worker_id', 'sn', 'real_name', 'mobile', 'address', 'pay_time', 'pay_status', 'pay_sn', 'paw_way', 'order_terminal', 'amount_total', 'order_amount', 'transaction_id', 'refund_status', 'refund_transaction_id'])
  66. ->limit($this->limitOffset, $this->limitLength)
  67. ->order(['id' => 'desc'])
  68. ->select()
  69. ->toArray();
  70. }
  71. /**
  72. * @notes 获取数量
  73. * @return int
  74. * @author likeadmin
  75. * @date 2024/08/04 13:49
  76. */
  77. public function count(): int
  78. {
  79. return ShopOrders::where($this->searchWhere)->where($this->querySearch())->count();
  80. }
  81. }