user_game_logModel.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. *
  4. */
  5. class user_game_logModel extends NewModel
  6. {
  7. public function multiAddLog($game_log_id, $result, $times, $podcast_id)
  8. {
  9. $create_time = NOW_TIME;
  10. $create_date = to_date($create_time, 'Y-m-d H:i:s');
  11. $table = DB_PREFIX . 'user_game_log';
  12. self::$sql =
  13. "INSERT INTO $table (
  14. `game_log_id`,
  15. `user_id`,
  16. `money`,
  17. `bet`,
  18. `podcast_id`,
  19. `create_time`,
  20. `create_date`,
  21. `type`
  22. ) SELECT
  23. '$game_log_id' AS `game_log_id`,
  24. `user_id`,
  25. (SUM(l.`money`) * $times) AS `money`,
  26. '0' AS `bet`,
  27. '$podcast_id' AS `podcast_id`,
  28. '$create_time' AS `create_time`,
  29. '$create_date' AS `create_date`,
  30. '2' AS `type`
  31. FROM
  32. $table AS l
  33. WHERE
  34. l.type = 1
  35. AND `game_log_id` = $game_log_id
  36. AND `bet` = $result
  37. GROUP BY
  38. `user_id`";
  39. return Connect::exec(self::$sql);
  40. }
  41. public function addLog($game_log_id, $podcast_id, $money, $user_id = false, $bet = 0, $type = 2)
  42. {
  43. $create_time = NOW_TIME;
  44. $create_date = to_date($create_time, 'Y-m-d H:i:s');
  45. if ($user_id === false) {
  46. $user_id = $podcast_id;
  47. }
  48. $data = array(
  49. 'game_log_id' => $game_log_id,
  50. 'user_id' => $user_id,
  51. 'podcast_id' => $podcast_id,
  52. 'money' => $money,
  53. 'bet' => $bet,
  54. 'create_time' => $create_time,
  55. 'create_date' => $create_date,
  56. 'type' => $type,
  57. );
  58. return $this->insert($data);
  59. }
  60. }