WxPayOpenId.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yunzhong
  5. * Date: 2019/10/8
  6. * Time: 16:41
  7. */
  8. namespace app\common\services\wechat\lib;
  9. use app\common\services\wechat\lib\WxPayConfig;
  10. use app\common\services\wechat\lib\WxPayDataBase;
  11. class WxPayOpenId extends WxPayDataBase
  12. {
  13. public function __construct(WxPayConfig $config)
  14. {
  15. $this->values['appid'] = $config->GetAppId();
  16. $this->values["mch_id"] = $config->GetMerchantId();
  17. if ($config->GetSubAppId()) {
  18. $this->values['sub_appid'] = $config->GetSubAppId();
  19. }
  20. if ($config->GetSubMerchantId()) {
  21. $this->values["sub_mch_id"] = $config->GetSubMerchantId();
  22. }
  23. }
  24. /**
  25. * 设置随机字符串,不长于32位。推荐随机数生成算法
  26. * @param string $value
  27. **/
  28. public function SetNonce_str($value)
  29. {
  30. $this->values['nonce_str'] = $value;
  31. }
  32. /**
  33. * 获取随机字符串,不长于32位。推荐随机数生成算法的值
  34. * @return 值
  35. **/
  36. public function GetNonce_str()
  37. {
  38. return $this->values['nonce_str'];
  39. }
  40. /**
  41. * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在
  42. * @return true 或 false
  43. **/
  44. public function IsNonce_strSet()
  45. {
  46. return array_key_exists('nonce_str', $this->values);
  47. }
  48. public function GetOpenid()
  49. {
  50. return $this->values['openid'];
  51. }
  52. public function GetSubOpenid()
  53. {
  54. return $this->values['sub_openid'];
  55. }
  56. /**
  57. * 设置扫码支付授权码,设备读取用户微信中的条码或者二维码信息
  58. * @param string $value
  59. **/
  60. public function SetAuth_code($value)
  61. {
  62. $this->values['auth_code'] = $value;
  63. }
  64. /**
  65. * 获取扫码支付授权码,设备读取用户微信中的条码或者二维码信息的值
  66. * @return 值
  67. **/
  68. public function GetAuth_code()
  69. {
  70. return $this->values['auth_code'];
  71. }
  72. /**
  73. * 判断扫码支付授权码,设备读取用户微信中的条码或者二维码信息是否存在
  74. * @return true 或 false
  75. **/
  76. public function IsAuth_codeSet()
  77. {
  78. return array_key_exists('auth_code', $this->values);
  79. }
  80. }