PointsLog.php 986 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model\user;
  3. use app\common\model\BaseModel;
  4. /**
  5. * 用户积分变动明细模型
  6. * Class PointsLog
  7. * @package app\common\model\user
  8. */
  9. class PointsLog extends BaseModel
  10. {
  11. protected $name = 'user_points_log';
  12. protected $updateTime = false;
  13. /**
  14. * 关联会员记录表
  15. * @return \think\model\relation\BelongsTo
  16. */
  17. public function user()
  18. {
  19. $module = self::getCalledModule() ?: 'common';
  20. return $this->belongsTo("app\\{$module}\\model\\User");
  21. }
  22. /**
  23. * 新增记录
  24. * @param $data
  25. */
  26. public static function add($data)
  27. {
  28. $static = new static;
  29. $static->save(array_merge(['wxapp_id' => $static::$wxapp_id], $data));
  30. }
  31. /**
  32. * 新增记录 (批量)
  33. * @param $saveData
  34. * @return array|false
  35. * @throws \Exception
  36. */
  37. public function onBatchAdd($saveData)
  38. {
  39. return $this->isUpdate(false)->saveAll($saveData);
  40. }
  41. }