TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'] ] ] ]; } public function beforeSave($insert) { if (parent::beforeSave($insert)) { //$this->dirtyAttributes 改动的项目 if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) { $this->is_platform_audit = 0; } return true; } return false; } /** * @inheritdoc */ public function rules() { return [ [['id', 'start_time', 'end_time', 'self_limit_num', 'order_limit_num', 'is_use_coupon', 'is_delete', 'store_id', 'status', 'is_platform', 'is_platform_audit'], 'integer'], [['name'], 'string'], [['created_at', 'updated_at'], 'safe'] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => '活动名称', 'start_time' => '开始时间', 'end_time' => '结束时间', 'self_limit_num' => '个人限购', 'order_limit_num' => '订单限购', 'is_use_coupon' => '是否使用优惠券', 'created_at' => '创建时间', 'updated_at' => '修改时间', 'is_delete' => 'is_delete', 'store_id' => 'Store Id', 'status' => '状态' ]; } public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_SECKILL, [$this->id]); } }