SystemAwardHistory.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\admin\controller\system;
  3. use app\admin\controller\AuthController;
  4. use crmeb\services\{UtilService, JsonService as Json};
  5. use app\models\system\SystemAwardHistory as SystemAwardHistoryModel;
  6. /**
  7. * 活动奖励记录
  8. */
  9. class SystemAwardHistory extends AuthController
  10. {
  11. public function index()
  12. {
  13. return $this->fetch();
  14. }
  15. public function getAwardHistory()
  16. {
  17. $where = UtilService::getMore([
  18. ['page', 1],
  19. ['limit', 20],
  20. ['activity', ''],
  21. ['period', ''],
  22. ]);
  23. $model = SystemAwardHistoryModel::page(intval($where['page']), intval($where['limit']));
  24. if ($where['activity']) {
  25. $model = $model->where('activity', $where['activity']);
  26. }
  27. if ($where['period']) {
  28. list($startTime, $endTime) = explode(' - ', $where['period']);
  29. $model = $model->where('ts', '>', strtotime($startTime));
  30. $model = $model->where('ts', '<', strtotime($endTime) + 24 * 3600);
  31. }
  32. $list = $model->field('*, FROM_UNIXTIME(ts, "%Y-%m-%d %H:%i:%s") as stime')->order('ts desc')->select();
  33. $count = $model->count();
  34. return Json::successlayui(['count'=>$count, 'data'=>$list]);
  35. }
  36. }