PointsLog.php 1.1 KB

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