GiftCardLists.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\gift_card;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\model\IntegralOrder;
  22. use app\common\model\GiftCard;
  23. use app\common\service\FileService;
  24. class GiftCardLists extends BaseAdminDataLists
  25. {
  26. /**
  27. * @notes 搜索条件
  28. * @return array
  29. * @author ljj
  30. * @date 2022/3/30 5:12 下午
  31. */
  32. public function setSearch(): array
  33. {
  34. $where = [];
  35. $params = $this->params;
  36. //下单时间
  37. if (isset($params['start_time']) && $params['start_time'] != '') {
  38. $where[] = ['create_time', '>=', strtotime($params['start_time'])];
  39. }
  40. if (isset($params['end_time']) && $params['end_time'] != '') {
  41. $where[] = ['create_time', '<=', strtotime($params['end_time'])];
  42. }
  43. return $where;
  44. }
  45. /**
  46. * @notes 礼品卡批次列表
  47. * @return array
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\DbException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @author ljj
  52. * @date 2022/3/30 5:40 下午
  53. */
  54. public function lists(): array
  55. {
  56. $lists = GiftCard::where($this->setSearch())
  57. ->limit($this->limitOffset, $this->limitLength)
  58. ->order('id', 'desc')
  59. ->select()
  60. ->toArray();
  61. // foreach ($lists as &$list) {
  62. //// $list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
  63. // }
  64. return $lists;
  65. }
  66. /**
  67. * @notes 兑换订单数量
  68. * @return int
  69. * @author ljj
  70. * @date 2022/3/30 5:40 下午
  71. */
  72. public function count(): int
  73. {
  74. return GiftCard::where($this->setSearch())->count();
  75. }
  76. }