20], [['change_type'], 'string', 'max' => 12], [['desc', 'source_table', 'from_type'], 'string', 'max' => 255], [['order_no'], 'string', 'max' => 100], [['addon_name'], 'string', 'max' => 64], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'wallet_type' => 'Wallet Type', 'change_type' => 'Change Type', 'change_num' => 'Change Num', 'after_num' => 'After Num', 'desc' => 'Desc', 'source_table' => 'Source Table', 'source_table_id' => 'Source Table ID', 'from_type' => 'From Type', 'status' => 'Status', 'order_no' => 'Order No', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'addon_name' => 'Addon Name', ]; } public static function setData($params) { try { if (isset($params['id']) && !empty($params['id'])) { $model = self::findOne(['id' => $params['id']]); if (!$model) { throw new \Exception( self::tableName() . '记录不存在'); } } else { $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; } } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } }