[ 'creator' => ['type' => 'keyword'], 'create' => [ 'type' => 'object', 'properties' => [ 'means' => ['type' => 'keyword'], 'fix_amount' => [ 'type' => 'object', 'properties' => [ 'period' => ['type' => 'long'], 'amount' => ['type' => 'long'] ] ], 'left_proportion' => [ 'type' => 'object', 'properties' => [ 'period' => ['type' => 'long'], 'tenThousandth' => ['type' => 'long'] ] ], 'total_count' => ['type' => 'long'], 'start_time' => ['type' => 'long'], 'asset_symbol' => ['type' => 'string'], 'asset_exec' => ['type' => 'string'] ] ], 'unfreeze_id' => ['type' => 'keyword'], 'block' => [ 'type' => 'object', 'properties' => [ 'hash' => ['type' => 'keyword'], 'height' => ['type' => 'long'], 'ts' => ['type' => 'long'], 'index' => ['type' => 'long'] ] ], 'action_type' => ['type' => 'long'], 'beneficiary' => ['type' => 'keyword'], 'success' => ['type' => 'boolean'], 'withdraw' => [ 'type' => 'object', 'properties' => [ 'amount' => 'long' ] ], 'terminate' => [ 'type' => 'object', 'properties' => [ 'amount_left' => 'long', 'amount_back' => 'long' ] ] ] ]; } public static function mapping() { return [ static::type() => self::mapConfig(), ]; } /** * 设置(更新)此模型的映射 */ public static function updateMapping() { $db = self::getDb(); $command = $db->createCommand(); if (!$command->indexExists(self::index())) { $command->createIndex(self::index()); } $command->setMapping(self::index(), self::type(), self::mapping()); } //获取此模型的映射 public static function getMapping() { $db = self::getDb(); $command = $db->createCommand(); return $command->getMapping(); } /** * Delete this model's index */ public static function deleteIndex() { $db = static::getDb(); $command = $db->createCommand(); $command->deleteIndex(static::index(), static::type()); } public static function updateRecord($book_id, $columns) { try { $record = self::get($book_id); foreach ($columns as $key => $value) { $record->$key = $value; } return $record->update(); } catch (\Exception $e) { //handle error here return false; } } return false; } } }