UserExchangeLog.php 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. /**
  5. * 模型
  6. */
  7. class UserExchangeLog extends Model
  8. {
  9. // 开启自动写入时间戳字段
  10. protected $autoWriteTimestamp = 'int';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. /**
  14. * 添加声币兑换记录
  15. */
  16. public function addExchangeLog($user_id, $jewel, $money)
  17. {
  18. if (!$user_id || !$jewel || !$money) {
  19. return false;
  20. }
  21. // $time = time();
  22. // return self::execute("INSERT INTO `hx_user_exchange_log` (`user_id` , `sound_coin` , `money` , `createtime`) VALUES ($user_id , $jewel , $money , $time)");
  23. $data = [
  24. "user_id" => $user_id,
  25. "sound_coin" => $jewel,
  26. "money" => $money,
  27. "createtime" => time()
  28. ];
  29. return $this->insertGetId($data);
  30. }
  31. }