IdentifyQueue.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * IdentifyQueue.php UTF-8
  4. * 实名认证队列
  5. *
  6. * @date : 2021/4/28 11:49
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK-IDENTITY 1.0
  11. */
  12. namespace huoIdentify\lib\queue\controller;
  13. use huoIdentify\controller\Common;
  14. use huoIdentify\controller\Identify;
  15. use huoIdentify\lib\queue\constant\ClassConst;
  16. use huoIdentify\lib\queue\constant\JobConst;
  17. use huoIdentify\model\IdentifyInQueueModel;
  18. use huolib\status\IdentifyStatus;
  19. use think\Config;
  20. class IdentifyQueue extends Common {
  21. /**
  22. * 入队列处理
  23. *
  24. * @param $mem_id
  25. * @param $id_card
  26. * @param $real_name
  27. * @param $app_id
  28. * @param $identify_pi
  29. *
  30. * @return bool
  31. */
  32. public function addInQueueData($mem_id, $id_card, $real_name, $app_id, $identify_pi) {
  33. $_queue_status = Config::get('IDENTIFY_QUEUE');
  34. if (false === $_queue_status) {
  35. return false;
  36. }
  37. if (empty($mem_id) || empty($id_card) || empty($real_name)) {
  38. return false;
  39. }
  40. $_iiq_model = new IdentifyInQueueModel();
  41. $_id = $_iiq_model->getIdByUidCodeCard($mem_id, 0, $id_card);
  42. if (!empty($_id)) {
  43. /* 已入库不处理 */
  44. return true;
  45. }
  46. $_data = [
  47. 'app_id' => $app_id,
  48. 'uid' => $mem_id,
  49. 'real_name' => $real_name,
  50. 'id_card' => $id_card,
  51. 'channel_code' => 0,
  52. 'identify_pi' => $identify_pi,
  53. ];
  54. $_id = $_iiq_model->addData($_data);
  55. if (empty($_id)) {
  56. return false;
  57. }
  58. $_queue_data = [
  59. 'iiq_id' => $_id,
  60. 'identify_class' => ClassConst::CLASS_IDENTIFY_CLASS,
  61. ];
  62. $_queue_class = new Queue();
  63. $_queue_class->setJobClass(ClassConst::CLASS_IDENTIFY_FIRE);
  64. $_queue_class->setJobName(JobConst::JOB_IDENTIFY);
  65. $_queue_class->setParam($_queue_data);
  66. $_queue_class->pushQueue();
  67. return true;
  68. }
  69. /**
  70. * 队列处理实名认证信息
  71. *
  72. * @param $iiq_id
  73. *
  74. * @return bool
  75. */
  76. public function checkFromQueue($iiq_id) {
  77. $_iiq_model = new IdentifyInQueueModel();
  78. $_data = $_iiq_model->getInfoById($iiq_id);
  79. if (empty($_data)) {
  80. return true;
  81. }
  82. $_mem_id = get_val($_data, 'uid');
  83. $_id_card = get_val($_data, 'id_card');
  84. $_real_name = get_val($_data, 'real_name');
  85. $_app_id = get_val($_data, 'app_id');
  86. $_rs = (new Identify($_app_id))->getReportIdentity($_mem_id, 1, $_real_name, $_id_card, $_app_id, true);
  87. if (IdentifyStatus::MEM_IDENTIFY_IN_PROGRESS == $_rs['code']) {
  88. /* 认证中,需要重复入队列 */
  89. return false;
  90. }
  91. if (IdentifyStatus::NO_ERROR != $_rs['code']) {
  92. $_result = $_rs;
  93. $_step = 0;
  94. $_other = 0;
  95. \huolib\tool\Log::outErrorLog(debug_backtrace(false, 1)[0], $_result, $_step, $_other);
  96. }
  97. $_iiq_model->deleteData($iiq_id);
  98. return true;
  99. }
  100. }