SystemAwardHistory.php 1.4 KB

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