GiftCardLists.php 3.1 KB

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