TimestampBehavior::class, 'value' => time() ] ]; } public function rules() { return [ [['id', 'from_id', 'to_id', 'from_store_id', 'to_store_id'], 'integer'], [['type'], 'string'], [['create_at', 'update_at'], 'safe'], ]; } public function attributeLabels() { return [ 'id' => '', 'from_id' => '原店铺内容id', 'to_id' => '新店铺内容id', 'from_store_id' => '原店铺id', 'to_store_id' => '新店铺id', 'type' => '类型 代码中给示例值', 'created_at' => '', 'updated_at' => '' ]; } public static function handleData($from_store_id, $to_store_id, $from_id, $to_id, $type = self::TYPE_PRODUCT) { $storeSyncExtLog = self::findOne([ 'from_store_id' => $from_store_id, 'to_store_id' => $to_store_id, 'from_id' => $from_id, 'type' => $type ]) ?: new self(); $storeSyncExtLog->from_id = $from_id; $storeSyncExtLog->type = $type; $storeSyncExtLog->to_id = $to_id; $storeSyncExtLog->from_store_id = $from_store_id; $storeSyncExtLog->to_store_id = $to_store_id; if (!$storeSyncExtLog->save()) { //debug_log(['storeSyncExtLog' => $storeSyncExtLog->errors], 'goods_job.log'); }; } }