| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace addons\Happiness\common\models;
- use Yii;
- /**
- * This is the model class for table "{{%addons_happiness_pv_wallet}}".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $user_id 用户id
- * @property float $score_value 累加积分
- * @property float $freeze_score_value 冻结积分
- * @property float $active_score_value 释放的积分
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class HappinessPvWallet extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_happiness_pv_wallet}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'score_value', 'freeze_score_value'], 'required'],
- [['mall_id', 'user_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['score_value', 'freeze_score_value', 'active_score_value', 'total_score_value'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'score_value' => 'Score Value',
- 'freeze_score_value' => 'Freeze Score Value',
- 'total_score_value' => 'Total Score Value',
- 'active_score_value' => 'Active Score Value',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData($params)
- {
- try {
- $model = self::findOne(['user_id' => $params['user_id'], 'mall_id' => $params['mall_id']]);
- if (!$model) {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|