SystemAwardHistory.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\models\system;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. class SystemAwardHistory extends BaseModel
  6. {
  7. use ModelTrait;
  8. public static function InsertNew($activity, $result, $order_num, $winner_num, $total_paid, $diff_paid, $profit, $rate)
  9. {
  10. self::create([
  11. 'activity' => $activity,
  12. 'result' => $result,
  13. 'ts' => time(),
  14. 'order_num' => $order_num,
  15. 'winner_num' => $winner_num,
  16. 'total_paid' => $total_paid,
  17. 'diff_paid' => $diff_paid,
  18. 'profit' => $profit,
  19. 'rate' => $rate,
  20. ]);
  21. }
  22. /**
  23. * 获取开奖结果
  24. *
  25. * @return array
  26. */
  27. public static function getList($activity, $startTime, $stopTime, $page, $limit)
  28. {
  29. $model = new self();
  30. $model = $model::where('1=1');
  31. if ($activity) {
  32. $model = $model->where('activity', 'in', $activity);
  33. }
  34. if ($startTime) {
  35. $model = $model->where('ts', '>=', $startTime);
  36. }
  37. if ($stopTime) {
  38. $model = $model->where('ts', '<=', $stopTime);
  39. }
  40. if ($page && $limit) {
  41. $model = $model->page(intval($page), intval($limit));
  42. }
  43. $model = $model->field('FROM_UNIXTIME(ts, "%Y-%m-%d %H:%i:%s") as ts, activity, result')->order('ts desc');
  44. return $model->select()->toArray();
  45. }
  46. }