SignLists.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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\sign;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\lists\ListsExcelInterface;
  22. use app\common\lists\ListsSearchInterface;
  23. use app\common\model\SignLog;
  24. use app\common\service\FileService;
  25. /**
  26. * 签到记录列表
  27. * Class SignLists
  28. * @package app\adminapi\lists\sign
  29. */
  30. class SignLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
  31. {
  32. /**
  33. * @notes 导出字段
  34. * @return array
  35. * @author Tab
  36. * @date 2021/8/16 19:45
  37. */
  38. public function setExcelFields(): array
  39. {
  40. return [
  41. 'nickname' => '用户昵称',
  42. 'integral' => '每日签到奖励',
  43. 'continuous_integral' => '连续签到奖励',
  44. 'days' => '连续签到天数',
  45. 'create_time' => '签到时间',
  46. ];
  47. }
  48. /**
  49. * @notes 导出表名
  50. * @return string
  51. * @author Tab
  52. * @date 2021/8/16 19:45
  53. */
  54. public function setFileName(): string
  55. {
  56. return '签到记录表';
  57. }
  58. /**
  59. * @notes 设置搜索
  60. * @return array
  61. * @author Tab
  62. * @date 2021/8/16 19:33
  63. */
  64. public function setSearch(): array
  65. {
  66. return [
  67. '=' => ['u.sn', 'u.mobile'],
  68. '%like%' => ['u.nickname'],
  69. 'between_time' => 'sl.create_time'
  70. ];
  71. }
  72. /**
  73. * @notes 签到记录列表
  74. * @return array
  75. * @author Tab
  76. * @date 2021/8/16 19:35
  77. */
  78. public function lists(): array
  79. {
  80. $field = 'sl.id,sl.integral,sl.continuous_integral,sl.days,sl.create_time';
  81. $field .= ',u.avatar,u.nickname';
  82. $lists = SignLog::alias('sl')
  83. ->leftJoin('user u', 'u.id = sl.user_id')
  84. ->field($field)
  85. ->where($this->searchWhere)
  86. ->order('sl.id','desc')
  87. ->limit($this->limitOffset, $this->limitLength)
  88. ->select()
  89. ->toArray();
  90. foreach($lists as &$item) {
  91. $item['avatar'] = FileService::getFileUrl($item['avatar']);
  92. }
  93. return $lists;
  94. }
  95. /**
  96. * @notes 签到记录数量
  97. * @return int
  98. * @author Tab
  99. * @date 2021/8/16 19:41
  100. */
  101. public function count(): int
  102. {
  103. $count = SignLog::alias('sl')
  104. ->leftJoin('user u', 'u.id = sl.user_id')
  105. ->where($this->searchWhere)
  106. ->count();
  107. return $count;
  108. }
  109. }