Identify.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Identify.php UTF-8
  4. *
  5. *
  6. * @date : 2018/4/27 16:48
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\member;
  13. use huo\controller\common\Base;
  14. use huo\controller\integral\MemIa;
  15. use huolib\constant\IaConst;
  16. use huolib\status\IdentifyStatus;
  17. use huolib\status\MemberStatus;
  18. use huolib\utils\IdentifyUtils;
  19. class Identify extends Base {
  20. /**
  21. * @param $mem_id
  22. * @param int $type
  23. * @param $real_name
  24. * @param $id_card
  25. *
  26. * @return mixed
  27. */
  28. public function update($mem_id, $type = 1, $real_name, $id_card) {
  29. $_mem_data = MemCache::ins()->getInfoById($mem_id);
  30. if (empty($_mem_data)) {
  31. return $this->huoSuccess(MemberStatus::LOGIN_IS_OUT, MemberStatus::getMsg(MemberStatus::LOGIN_IS_OUT));
  32. }
  33. $_chk_rs = IdentifyUtils::checkIdentify($type, $real_name, $id_card);
  34. if (IdentifyStatus::NO_ERROR != $_chk_rs) {
  35. return $this->retErrMsg($_chk_rs);
  36. }
  37. $_old_id_card = $_mem_data['id_card'];
  38. $_mem_data['real_name'] = $real_name;
  39. $_mem_data['id_card'] = $id_card;
  40. $_mem_data['identify_type'] = $type;
  41. $_rs = MemCache::ins()->updateMem($mem_id, $_mem_data);
  42. if (false == $_rs) {
  43. return $this->huoSuccess(MemberStatus::INNER_ERROR, MemberStatus::getMsg(MemberStatus::INNER_ERROR));
  44. }
  45. /* 实名认证成功获取积分 */
  46. if (empty($_old_id_card)) {
  47. (new MemIa($mem_id))->doItgAct(IaConst::IA_IDENTIFY);
  48. }
  49. return $this->retSucMsg(IdentifyStatus::NO_ERROR);
  50. }
  51. /**
  52. * @param int $code
  53. * @param array $data
  54. *
  55. * @return array
  56. */
  57. protected function retSucMsg($code, $data = []) {
  58. $_msg = IdentifyStatus::getMsg($code);
  59. return $this->huoSuccess($code, $_msg, $data);
  60. }
  61. /**
  62. * @param $code
  63. *
  64. * @return mixed
  65. */
  66. protected function retErrMsg($code) {
  67. $_err_msg = IdentifyStatus::getMsg($code);
  68. return $this->huoError($code, $_err_msg);
  69. }
  70. }