* @version : HUOSDK-IDENTITY 1.0 */ namespace huoIdentify\lib\queue\controller; use huoIdentify\controller\Common; use huoIdentify\controller\Identify; use huoIdentify\lib\queue\constant\ClassConst; use huoIdentify\lib\queue\constant\JobConst; use huoIdentify\model\IdentifyInQueueModel; use huolib\status\IdentifyStatus; use think\Config; class IdentifyQueue extends Common { /** * 入队列处理 * * @param $mem_id * @param $id_card * @param $real_name * @param $app_id * @param $identify_pi * * @return bool */ public function addInQueueData($mem_id, $id_card, $real_name, $app_id, $identify_pi) { $_queue_status = Config::get('IDENTIFY_QUEUE'); if (false === $_queue_status) { return false; } if (empty($mem_id) || empty($id_card) || empty($real_name)) { return false; } $_iiq_model = new IdentifyInQueueModel(); $_id = $_iiq_model->getIdByUidCodeCard($mem_id, 0, $id_card); if (!empty($_id)) { /* 已入库不处理 */ return true; } $_data = [ 'app_id' => $app_id, 'uid' => $mem_id, 'real_name' => $real_name, 'id_card' => $id_card, 'channel_code' => 0, 'identify_pi' => $identify_pi, ]; $_id = $_iiq_model->addData($_data); if (empty($_id)) { return false; } $_queue_data = [ 'iiq_id' => $_id, 'identify_class' => ClassConst::CLASS_IDENTIFY_CLASS, ]; $_queue_class = new Queue(); $_queue_class->setJobClass(ClassConst::CLASS_IDENTIFY_FIRE); $_queue_class->setJobName(JobConst::JOB_IDENTIFY); $_queue_class->setParam($_queue_data); $_queue_class->pushQueue(); return true; } /** * 队列处理实名认证信息 * * @param $iiq_id * * @return bool */ public function checkFromQueue($iiq_id) { $_iiq_model = new IdentifyInQueueModel(); $_data = $_iiq_model->getInfoById($iiq_id); if (empty($_data)) { return true; } $_mem_id = get_val($_data, 'uid'); $_id_card = get_val($_data, 'id_card'); $_real_name = get_val($_data, 'real_name'); $_app_id = get_val($_data, 'app_id'); $_rs = (new Identify($_app_id))->getReportIdentity($_mem_id, 1, $_real_name, $_id_card, $_app_id, true); if (IdentifyStatus::MEM_IDENTIFY_IN_PROGRESS == $_rs['code']) { /* 认证中,需要重复入队列 */ return false; } if (IdentifyStatus::NO_ERROR != $_rs['code']) { $_result = $_rs; $_step = 0; $_other = 0; \huolib\tool\Log::outErrorLog(debug_backtrace(false, 1)[0], $_result, $_step, $_other); } $_iiq_model->deleteData($iiq_id); return true; } }