ScoreBonusUserWeightLog.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace addons\ScoreBonus\common\models;
  3. use common\models\user\User;
  4. use Exception;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_addons_score_bonus_user_weight_log".
  8. *
  9. * @property int $id id
  10. * @property int $mall_id 商城id
  11. * @property int $user_id 商城id
  12. * @property int $before_weight 修改前权重
  13. * @property int $after_weight 修改后权重
  14. * @property int $status 状态
  15. * @property int|null $created_at 添加时间
  16. * @property int|null $updated_at 修改时间
  17. */
  18. class ScoreBonusUserWeightLog extends \common\models\base\BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'qimall_addons_score_bonus_user_weight_log';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id', 'user_id'], 'required'],
  34. [['desc'], 'safe'],
  35. [['mall_id', 'user_id', 'before_weight', 'change_weight', 'after_weight', 'status', 'created_at', 'updated_at'], 'integer'],
  36. ];
  37. }
  38. public function getUser()
  39. {
  40. return $this->hasOne(User::class, ['id' => 'user_id']);
  41. }
  42. public static function setData(array $params)
  43. {
  44. try {
  45. $model = new self();
  46. $model->loadDefaultValues();
  47. if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
  48. return $model;
  49. } catch (Exception $e) {
  50. self::$static_error = $e->getMessage();
  51. return false;
  52. }
  53. }
  54. }