GiftCardInfoLists.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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\GiftCardInfo;
  22. use app\common\service\FileService;
  23. class GiftCardInfoLists 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['start_time']) && $params['start_time'] != '') {
  37. $where[] = ['create_time', '>=', strtotime($params['start_time'])];
  38. }
  39. if (isset($params['end_time']) && $params['end_time'] != '') {
  40. $where[] = ['create_time', '<=', strtotime($params['end_time'])];
  41. }
  42. $where[]=['gc_id','=',$params['id']];
  43. if(isset($params['card_no'])){
  44. $where[] = ['card_no', 'like', '%' . $params['card_no'] . '%'];
  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 ljj
  55. * @date 2022/3/30 5:40 下午
  56. */
  57. public function lists(): array
  58. {
  59. $lists = GiftCardInfo::where($this->setSearch())
  60. ->with(['giftCard','user'])
  61. ->append(['is_used_desc'])
  62. ->limit($this->limitOffset, $this->limitLength)
  63. ->order('id', 'desc')
  64. ->select()
  65. ->toArray();
  66. foreach ($lists as &$list) {
  67. // $list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
  68. }
  69. return $lists;
  70. }
  71. /**
  72. * @notes 兑换订单数量
  73. * @return int
  74. * @author ljj
  75. * @date 2022/3/30 5:40 下午
  76. */
  77. public function count(): int
  78. {
  79. return GiftCardInfo::where($this->setSearch())->count();
  80. }
  81. /**
  82. * @notes 设置excel表名
  83. * @return string
  84. * @author cjhao
  85. * @date 2021/9/23 9:52
  86. */
  87. public function setFileName(): string
  88. {
  89. return '礼品卡列表';
  90. }
  91. /**
  92. * @notes 设置导出字段
  93. * @return array
  94. * @author cjhao
  95. * @date 2021/9/23 9:59
  96. */
  97. public function setExcelFields(): array
  98. {
  99. return [
  100. 'gc_id' => '批次',
  101. 'card_no' => '礼品卡卡号',
  102. 'card_pass' => '礼品卡密码',
  103. 'card_money' => '礼品卡价值',
  104. 'is_used' => '是否使用',
  105. 'used_id' => '使用人',
  106. 'used_time' => '使用时间',
  107. 'create_time'=> '创建时间',
  108. ];
  109. }
  110. }