* @version : HUOSDK-9.0 */ namespace huoIdentify\model; use huo\model\common\CommonModel; use huolib\constant\CacheConst; class IdentifyOrderModel extends CommonModel { protected $name = 'identify_order'; protected $pk = 'id'; /* 开启自动写入时间戳字段 */ protected $autoWriteTimestamp = true; protected $cache_key_prefix = CacheConst::CACHE_IDENTIFY_ORDER_PREFIX; protected $type = [ 'id' => 'integer', 'ai' => 'string', 'mem_id' => 'integer', 'biz_id' => 'string', 'real_name' => 'string', 'id_card' => 'string', 'status' => 'integer', 'create_time' => 'timestamp', 'update_time' => 'timestamp', ]; /** * 获取单条记录缓存key * * @param int $id ID * * @return string :string */ protected function getSingleCacheKey($id) { return $this->cache_key_prefix.$id; } /** * 通过ID获取信息 * * @param int $id 主键ID * * @return array */ public function getInfoById($id) { $_data = parent::getInfoById($id); return $_data; } /** * 加入数据库 * * @param array $data * * @return bool|int */ public function addData($data) { $_data = $data; $_rs = parent::addData($_data); if (empty($_rs)) { return false; } return $_rs; } /** * 更新单条数据 * * @param array $data 数据 * @param int $id ID * * @return bool */ public function updateData($data, $id) { $_data = $data; $_rs = parent::updateData($_data, $id); if (false === $_rs) { return false; } return true; } /** * 获取认证中的ai * * @param $biz_id * @param $mem_id * * @return array|false */ public function getLastInfoByBizIdMem($biz_id, $mem_id) { $_map = [ 'biz_id' => $biz_id, 'mem_id' => $mem_id, ]; $_field = ['ai', 'real_name', 'id_card','status']; $_info = $this->where($_map)->order('id desc')->field($_field)->find(); if (is_object($_info)) { $_info = $_info->toArray(); } return $_info; } /** * 关联玩家 */ public function mem() { $_field = [ 'id', 'username' ]; return $this->belongsTo('\huo\model\member\MemberModel', 'mem_id', 'id')->field($_field); } }