Driver.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * Driver.php UTF-8
  4. * 实名认证接口驱动
  5. *
  6. * @date : 2019/12/2 16:31
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.5
  11. */
  12. namespace huoIdentify\identifyDriver;
  13. use huolib\constant\IdentifyConst;
  14. use huolib\status\CommonStatus;
  15. abstract class Driver {
  16. protected $config = []; //配置信息
  17. protected $identify_from = 'alipay'; //认证来源 支付宝 alipay 微信 wxpay
  18. protected $identify_type = IdentifyConst::ITYPE_MAINLAND; //认证证件类型 1 身份证
  19. protected $mem_id = 0; //当前玩家id
  20. protected $real_name = ''; //真实姓名
  21. protected $id_card = ''; //证件号
  22. protected $mg_mem_id = 0; //当前玩家小号id--提供给游戏方的id可能与玩家id一致
  23. protected $pf = 0; //平台标识 1 安卓 2 IOS
  24. protected $pi = ''; //中宣部的pi
  25. protected $user_token = ''; //用户标识
  26. public function __construct($config = []) {
  27. $this->config = $config;
  28. }
  29. /**
  30. * 移动APP支付函数
  31. *
  32. * @access public
  33. *
  34. */
  35. abstract public function identify();
  36. /**
  37. * 返回错误信息
  38. *
  39. * @param int $code
  40. * @param string $msg
  41. * @param array $data
  42. *
  43. * @return array
  44. */
  45. public function huoError($code = 400, $msg = '', $data = []) {
  46. return $this->huoSuccess($code, $msg, $data);
  47. }
  48. /**
  49. * 逻辑处理返回信息
  50. *
  51. * @param int $code
  52. * @param string $msg
  53. * @param array $data
  54. *
  55. * @return array
  56. */
  57. public function huoSuccess($code = 200, $msg = '', $data = []) {
  58. $_rdata['code'] = $code;
  59. $_rdata['msg'] = $msg;
  60. $_rdata['data'] = $data;
  61. return $_rdata;
  62. }
  63. /**
  64. * @param mixed $_data
  65. */
  66. public function huoReturn($_data) {
  67. return $this->huoSuccess($_data['code'], $_data['msg'], $_data['data']);
  68. }
  69. /**
  70. * @return string
  71. */
  72. public function getIdentifyFrom() {
  73. return $this->identify_from;
  74. }
  75. /**
  76. * @param string $identify_from
  77. */
  78. public function setIdentifyFrom($identify_from) {
  79. $this->identify_from = $identify_from;
  80. }
  81. /**
  82. * @return int
  83. */
  84. public function getIdentifyType() {
  85. return $this->identify_type;
  86. }
  87. /**
  88. * @param int $identify_type
  89. */
  90. public function setIdentifyType($identify_type) {
  91. $this->identify_type = $identify_type;
  92. }
  93. /**
  94. * @return string
  95. */
  96. public function getRealName() {
  97. return $this->real_name;
  98. }
  99. /**
  100. * @param string $real_name
  101. */
  102. public function setRealName($real_name) {
  103. $this->real_name = $real_name;
  104. }
  105. /**
  106. * @return string
  107. */
  108. public function getIdCard() {
  109. return $this->id_card;
  110. }
  111. /**
  112. * @param string $id_card
  113. */
  114. public function setIdCard($id_card) {
  115. $this->id_card = strtoupper($id_card);
  116. }
  117. /**
  118. * @return int
  119. */
  120. public function getMemId() {
  121. return $this->mem_id;
  122. }
  123. /**
  124. * @param int $mem_id
  125. */
  126. public function setMemId($mem_id) {
  127. $this->mem_id = $mem_id;
  128. }
  129. public function loginBehavior($identify_pi) {
  130. $_code = CommonStatus::NO_ERROR;
  131. return $this->huoSuccess($_code, CommonStatus::getMsg($_code));
  132. }
  133. public function logoutBehavior($identify_pi) {
  134. $_code = CommonStatus::NO_ERROR;
  135. return $this->huoSuccess($_code, CommonStatus::getMsg($_code));
  136. }
  137. /**
  138. * @return int
  139. */
  140. public function getMgMemId() {
  141. return $this->mg_mem_id;
  142. }
  143. /**
  144. * @param int $mg_mem_id
  145. */
  146. public function setMgMemId($mg_mem_id) {
  147. $this->mg_mem_id = $mg_mem_id;
  148. }
  149. /**
  150. * @return int
  151. */
  152. public function getPf() {
  153. return $this->pf;
  154. }
  155. /**
  156. * @param int $pf
  157. */
  158. public function setPf($pf) {
  159. $this->pf = $pf;
  160. }
  161. /**
  162. * @return string
  163. */
  164. public function getPi() {
  165. return $this->pi;
  166. }
  167. /**
  168. * @param string $pi
  169. */
  170. public function setPi($pi) {
  171. $this->pi = $pi;
  172. }
  173. /**
  174. * @return string
  175. */
  176. public function getUserToken() {
  177. return $this->user_token;
  178. }
  179. /**
  180. * @param string $user_token
  181. */
  182. public function setUserToken($user_token) {
  183. $this->user_token = $user_token;
  184. }
  185. }