PointsLog.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model\user;
  13. use app\common\model\BaseModel;
  14. /**
  15. * 用户积分变动明细模型
  16. * Class PointsLog
  17. * @package app\common\model\user
  18. */
  19. class PointsLog extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'user_points_log';
  23. // 定义主键
  24. protected $pk = 'log_id';
  25. protected $updateTime = false;
  26. /**
  27. * 关联会员记录表
  28. * @return \think\model\relation\BelongsTo
  29. */
  30. public function user()
  31. {
  32. $module = self::getCalledModule();
  33. return $this->belongsTo("app\\{$module}\\model\\User");
  34. }
  35. /**
  36. * 新增记录
  37. * @param $data
  38. */
  39. public static function add($data)
  40. {
  41. $static = new static;
  42. $static->save(array_merge(['store_id' => $static::$storeId], $data));
  43. }
  44. /**
  45. * 新增记录 (批量)
  46. * @param $saveData
  47. * @return bool
  48. */
  49. public function onBatchAdd($saveData)
  50. {
  51. return $this->addAll($saveData) !== false;
  52. }
  53. }