GiftCardInfoLists.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\lists\gift_card;
  20. use app\adminapi\{
  21. lists\BaseAdminDataLists,
  22. };
  23. use app\common\{
  24. lists\ListsExcelInterface,
  25. lists\ListsExtendInterface,
  26. model\GiftCardInfo};
  27. /**
  28. * 批次礼品卡信息列表接口
  29. * Class GoodsLists
  30. * @package app\adminapi\lists\goods
  31. */
  32. class GiftCardInfoLists extends BaseAdminDataLists implements ListsExtendInterface,ListsExcelInterface
  33. {
  34. /**
  35. * @notes 搜索条件
  36. * @return array
  37. * @author cjhao
  38. * @date 2021/7/22 10:51
  39. */
  40. public function setSearch(): array
  41. {
  42. $where = [];
  43. $params = $this->params;
  44. //下单时间
  45. if (isset($params['start_time']) && $params['start_time'] != '') {
  46. $where[] = ['create_time', '>=', strtotime($params['start_time'])];
  47. }
  48. if (isset($params['end_time']) && $params['end_time'] != '') {
  49. $where[] = ['create_time', '<=', strtotime($params['end_time'])];
  50. }
  51. $where[]=['gc_id','=',$params['id']];
  52. if(isset($params['card_no'])){
  53. $where[] = ['card_no', 'like', '%' . $params['card_no'] . '%'];
  54. }
  55. return $where;
  56. }
  57. /**
  58. * @notes 统计信息
  59. * @return array
  60. * @throws \think\db\exception\DataNotFoundException
  61. * @throws \think\db\exception\DbException
  62. * @throws \think\db\exception\ModelNotFoundException
  63. * @author cjhao
  64. * @date 2021/7/22 10:51
  65. */
  66. public function extend(): array
  67. {
  68. return [];
  69. }
  70. /**
  71. * @notes 礼品卡列表
  72. * @return array
  73. * @throws \think\db\exception\DataNotFoundException
  74. * @throws \think\db\exception\DbException
  75. * @throws \think\db\exception\ModelNotFoundException
  76. * @author cjhao
  77. * @date 2021/7/21 18:31
  78. */
  79. public function lists(): array
  80. {
  81. $lists = GiftCardInfo::where($this->setSearch())
  82. ->with(['user'])
  83. ->append(['is_used_desc','used_user_name','batch_no'])
  84. ->limit($this->limitOffset, $this->limitLength)
  85. ->order('id', 'desc')
  86. ->select()
  87. ->toArray();
  88. // foreach ($lists as &$list) {
  89. //// $list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
  90. // }
  91. return $lists;
  92. }
  93. /**
  94. * @notes 总数
  95. * @return int
  96. * @author cjhao
  97. * @date 2021/7/21 18:32
  98. */
  99. public function count(): int
  100. {
  101. return GiftCardInfo::where($this->setSearch())->count();
  102. }
  103. /**
  104. * @notes 设置excel表名
  105. * @return string
  106. * @author cjhao
  107. * @date 2021/9/23 9:52
  108. */
  109. public function setFileName(): string
  110. {
  111. return '礼品卡列表';
  112. }
  113. /**
  114. * @notes 设置导出字段
  115. * @return array
  116. * @author cjhao
  117. * @date 2021/9/23 9:59
  118. */
  119. public function setExcelFields(): array
  120. {
  121. return [
  122. 'batch_no' => '批次',
  123. 'card_no' => '礼品卡卡号',
  124. 'card_pass' => '礼品卡密码',
  125. 'card_money' => '礼品卡价值',
  126. 'is_used_desc' => '是否使用',
  127. 'used_user_name' => '使用人',
  128. 'used_time' => '使用时间',
  129. 'create_time'=> '创建时间',
  130. ];
  131. }
  132. }