IntegralOrderLists.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\lists\integral;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\model\IntegralOrder;
  22. use app\common\service\FileService;
  23. class IntegralOrderLists extends BaseAdminDataLists
  24. {
  25. /**
  26. * @notes 搜索条件
  27. * @return array
  28. * @author ljj
  29. * @date 2022/3/30 5:12 下午
  30. */
  31. public function setSearch(): array
  32. {
  33. $where = [];
  34. $params = $this->params;
  35. //列表状态
  36. if (isset($params['status']) && $params['status'] != '') {
  37. $where[] = ['order_status', '=', $params['status']];
  38. }
  39. //兑换单号
  40. if (isset($params['sn']) && $params['sn'] != '') {
  41. $where[] = ['sn', 'like', '%' . $params['sn'] . '%'];
  42. }
  43. //商品名称
  44. if (isset($params['goods_name']) && $params['goods_name'] != '') {
  45. $where[] = ['goods_snap->name', 'like', '%' . $params['goods_name'] . '%'];
  46. }
  47. //兑换类型
  48. if (isset($params['exchange_type']) && $params['exchange_type'] != '') {
  49. $where[] = ['exchange_type', '=', intval($params['exchange_type'])];
  50. }
  51. //订单状态
  52. if (isset($params['order_status']) && $params['order_status'] != '') {
  53. $where[] = ['order_status', '=', $params['order_status']];
  54. }
  55. //下单时间
  56. if (isset($params['start_time']) && $params['start_time'] != '') {
  57. $where[] = ['create_time', '>=', strtotime($params['start_time'])];
  58. }
  59. if (isset($params['end_time']) && $params['end_time'] != '') {
  60. $where[] = ['create_time', '<=', strtotime($params['end_time'])];
  61. }
  62. return $where;
  63. }
  64. /**
  65. * @notes 兑换订单列表
  66. * @return array
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\DbException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. * @author ljj
  71. * @date 2022/3/30 5:40 下午
  72. */
  73. public function lists(): array
  74. {
  75. $lists = IntegralOrder::withoutField(['transaction_id', 'update_time', 'delete_time'])
  76. ->with(['user'])
  77. ->where($this->setSearch())
  78. ->append(['pay_status_text', 'delivery_address', 'order_status_desc', 'exchange_type_desc', 'admin_btns'])
  79. ->limit($this->limitOffset, $this->limitLength)
  80. ->order('id', 'desc')
  81. ->select()
  82. ->toArray();
  83. foreach ($lists as &$list) {
  84. $list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
  85. }
  86. return $lists;
  87. }
  88. /**
  89. * @notes 兑换订单数量
  90. * @return int
  91. * @author ljj
  92. * @date 2022/3/30 5:40 下午
  93. */
  94. public function count(): int
  95. {
  96. return IntegralOrder::where($this->setSearch())->count();
  97. }
  98. }