ScoreExpansionInvertLog.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace addons\ScoreExpansion\common\models;
  3. use common\enums\StatusEnum;
  4. use Exception;
  5. use RuntimeException;
  6. use Yii;
  7. /**
  8. * This is the model class for table "qimall_addons_score_expansion_invert_log".
  9. *
  10. * @property int $id
  11. * @property int $mall_id 商城ID
  12. * @property string $addons_name 插件(哪个插件奖励的积分被转化)
  13. * @property string $source_table 来源表
  14. * @property int $source_table_id 来源ID
  15. * @property int $score_log_id 来源ID
  16. * @property int $status 状态[-1:删除;0:禁用;1启用]
  17. * @property int $created_at
  18. * @property int $updated_at
  19. */
  20. class ScoreExpansionInvertLog extends \common\models\base\BaseActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return 'qimall_addons_score_expansion_invert_log';
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['mall_id', 'source_table_id', 'score_log_id', 'status', 'created_at', 'updated_at'], 'integer'],
  36. [['addons_name', 'source_table'], 'string', 'max' => 100],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => 'Mall ID',
  47. 'addons_name' => 'Addons Name',
  48. 'source_table' => 'Source Table',
  49. 'source_table_id' => 'Source Table ID',
  50. 'score_log_id' => 'Score Log Id',
  51. 'status' => 'Status',
  52. 'created_at' => 'Created At',
  53. 'updated_at' => 'Updated At',
  54. ];
  55. }
  56. /**
  57. * @param array $params
  58. *
  59. * @return bool|self
  60. */
  61. public static function setData(array $params)
  62. {
  63. try {
  64. $model = new static();
  65. $model->loadDefaultValues();
  66. if (!$model->load($params, '')) {
  67. throw new RuntimeException($model->getErrorMessage());
  68. }
  69. if (!$model->save()) {
  70. throw new RuntimeException($model->getErrorMessage());
  71. }
  72. return $model;
  73. } catch (Exception $e) {
  74. static::$static_error = $e->getMessage();
  75. return false;
  76. }
  77. }
  78. }