TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], ], ], ]; } public function decodeDetail() { $detail = json_decode($this->detail,true); foreach ($detail as &$item) { foreach ($item as &$value) { if (is_numeric($value)) { $value = floatval($value); } } unset($value); } unset($item); return $detail; } public static function setStatus($id = null) { $model = static::findOne([ 'id' => $id, 'is_delete' => 0, 'mall_id' => \Yii::$app->mallId, ]); if (!$model) { throw new ApiException("运费规则不存在"); } else { PostageRules::updateAll(['status' => 0], [ 'mall_id' => \Yii::$app->mallId, ]); $model->status = 1; if ($model->save()) { return []; } else { throw new ApiException($model->errors[0]); } } } }