123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- /**
- * IdentifyQueue.php UTF-8
- * 实名认证队列
- *
- * @date : 2021/4/28 11:49
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @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;
- }
- }
|