Files
kiri-wchat/wchat/common/Config.php
T

538 lines
6.7 KiB
PHP
Raw Normal View History

2019-07-17 17:17:37 +08:00
<?php
2020-03-05 12:41:49 +08:00
namespace wchat\common;
2019-07-17 17:17:37 +08:00
class Config
{
/**
* @var string
*
* 小程序ID
*/
private $appid = '';
/**
* @var string
*
* 商户号ID
*/
private $mch_id = '';
/**
* @var string
*
* 设备号
*/
private $device_info = 'WEB';
2019-11-11 18:14:47 +08:00
private $token;
private $encodingAesKey;
2019-07-17 17:17:37 +08:00
/**
* @var string
*
* 随机字符串
*/
private $nonce_str = '';
/**
* @var string
*
* 商品简单描述
*/
private $body = '好友默契Pk充值!';
/**
* @var string
*
* 商户订单号
*/
private $out_trade_no = "";
/**
* @var int
*
* 金额
*/
private $total_fee = 0;
/**
* @var string
*
* 终端IP
*/
private $spbill_create_ip = "";
/**
* @var string
*
* 异步回调地址
*/
2019-07-17 17:27:31 +08:00
private $notify_url = "";
2019-07-17 17:17:37 +08:00
/**
* @var string
*
* 交易类型
*/
private $trade_type = 'JSAPI';
/**
* @var string
*
* 签名方式
*/
private $sign_type = 'MD5';
/**
* @var string
*
* 商户接口地址
*/
private $mch_host = 'https://api.mch.weixin.qq.com';
/**
* @var string
*/
private $appsecret = '';
private $remote_addr = '127.0.0.1';
private $ssl_cert = '';
private $ssl_key = '';
2020-04-03 17:18:21 +08:00
private $ssl_ca = '';
private $port = '';
2019-07-17 17:17:37 +08:00
/**
* @var string
*/
private $key = '';
2019-07-17 17:27:31 +08:00
private $access_token = '';
2019-09-19 18:58:46 +08:00
private $agent = '';
2020-01-07 11:44:45 +08:00
private $usrSwoole = false;
2020-04-03 17:18:21 +08:00
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getSslCa()
2020-04-03 17:18:21 +08:00
{
return $this->ssl_ca;
}
/**
2021-04-06 15:20:39 +08:00
* @param $ssl_ca
2020-04-03 17:18:21 +08:00
* @return Config
*/
2021-04-06 15:20:39 +08:00
public function setSslCa($ssl_ca): Config
2020-04-03 17:18:21 +08:00
{
$this->ssl_ca = $ssl_ca;
return $this;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getPort()
2020-04-03 17:18:21 +08:00
{
return $this->port;
}
/**
2021-04-06 15:20:39 +08:00
* @param $port
2020-04-03 17:18:21 +08:00
* @return Config
*/
2021-04-06 15:20:39 +08:00
public function setPort($port): Config
2020-04-03 17:18:21 +08:00
{
$this->port = $port;
return $this;
}
2020-01-07 11:44:45 +08:00
/**
* @return bool
*/
2021-04-06 15:15:37 +08:00
public function isUsrSwoole()
2020-01-07 11:44:45 +08:00
{
return $this->usrSwoole;
}
/**
* @param bool $usrSwoole
* @return Config
*/
public function setUsrSwoole(bool $usrSwoole): Config
{
$this->usrSwoole = $usrSwoole;
return $this;
}
2019-09-19 18:58:46 +08:00
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getAgent()
2019-09-19 18:58:46 +08:00
{
return $this->agent;
}
/**
2021-04-06 15:20:39 +08:00
* @param $agent
2019-09-19 18:58:46 +08:00
* @return Config
*/
2021-04-06 15:20:39 +08:00
public function setAgent($agent): Config
2019-09-19 18:58:46 +08:00
{
$this->agent = $agent;
return $this;
}
2019-11-11 18:14:47 +08:00
/**
* @return mixed
*/
public function getToken()
{
return $this->token;
}
/**
* @param mixed $token
* @return Config
*/
public function setToken($token)
{
$this->token = $token;
return $this;
}
2019-09-19 18:58:46 +08:00
2019-11-11 18:14:47 +08:00
/**
* @return mixed
*/
public function getEncodingAesKey()
{
return $this->encodingAesKey;
}
/**
* @param mixed $encodingAesKey
* @return Config
*/
public function setEncodingAesKey($encodingAesKey)
{
$this->encodingAesKey = $encodingAesKey;
return $this;
}
2019-07-17 17:27:31 +08:00
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getAccessToken()
2019-07-17 17:27:31 +08:00
{
return $this->access_token;
}
/**
2021-04-06 15:20:39 +08:00
* @param $access_token
2019-07-17 17:27:31 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setAccessToken($access_token)
2019-07-17 17:27:31 +08:00
{
$this->access_token = $access_token;
}
2019-07-17 17:17:37 +08:00
/**
2021-04-06 15:20:39 +08:00
* @param $remote_addr
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setRemoteAddr($remote_addr)
2019-07-17 17:17:37 +08:00
{
$this->remote_addr = $remote_addr;
}
/**
2021-04-06 15:20:39 +08:00
* @param $appid
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setAppid($appid)
2019-07-17 17:17:37 +08:00
{
$this->appid = $appid;
}
/**
2021-04-06 15:20:39 +08:00
* @param $mch_id
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setMchId($mch_id)
2019-07-17 17:17:37 +08:00
{
$this->mch_id = $mch_id;
}
/**
2021-04-06 15:20:39 +08:00
* @param $device_info
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setDeviceInfo($device_info)
2019-07-17 17:17:37 +08:00
{
$this->device_info = $device_info;
}
/**
2021-04-06 15:20:39 +08:00
* @param $nonce_str
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setNonceStr($nonce_str)
2019-07-17 17:17:37 +08:00
{
$this->nonce_str = $nonce_str;
}
/**
2021-04-06 15:20:39 +08:00
* @param $body
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setBody($body)
2019-07-17 17:17:37 +08:00
{
$this->body = $body;
}
/**
2021-04-06 15:20:39 +08:00
* @param $out_trade_no
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setOutTradeNo($out_trade_no)
2019-07-17 17:17:37 +08:00
{
$this->out_trade_no = $out_trade_no;
}
/**
* @param int $total_fee
*/
public function setTotalFee(int $total_fee)
{
$this->total_fee = $total_fee;
}
/**
2021-04-06 15:20:39 +08:00
* @param $spbill_create_ip
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setSpbillCreateIp($spbill_create_ip)
2019-07-17 17:17:37 +08:00
{
$this->spbill_create_ip = $spbill_create_ip;
}
/**
2021-04-06 15:20:39 +08:00
* @param $notify_url
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setNotifyUrl($notify_url)
2019-07-17 17:17:37 +08:00
{
$this->notify_url = $notify_url;
}
/**
2021-04-06 15:20:39 +08:00
* @param $trade_type
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setTradeType($trade_type)
2019-07-17 17:17:37 +08:00
{
$this->trade_type = $trade_type;
}
/**
2021-04-06 15:20:39 +08:00
* @param $sign_type
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setSignType($sign_type)
2019-07-17 17:17:37 +08:00
{
$this->sign_type = $sign_type;
}
/**
2021-04-06 15:20:39 +08:00
* @param $mch_host
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setMchHost($mch_host)
2019-07-17 17:17:37 +08:00
{
$this->mch_host = $mch_host;
}
/**
2021-04-06 15:20:39 +08:00
* @param $appsecret
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setAppsecret($appsecret)
2019-07-17 17:17:37 +08:00
{
$this->appsecret = $appsecret;
}
/**
2021-04-06 15:20:39 +08:00
* @param $ssl_cert
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setSslCert($ssl_cert)
2019-07-17 17:17:37 +08:00
{
$this->ssl_cert = $ssl_cert;
}
/**
2021-04-06 15:20:39 +08:00
* @param $ssl_key
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setSslKey($ssl_key)
2019-07-17 17:17:37 +08:00
{
$this->ssl_key = $ssl_key;
}
/**
2021-04-06 15:20:39 +08:00
* @param $key
2019-07-17 17:17:37 +08:00
*/
2021-04-06 15:20:39 +08:00
public function setKey($key)
2019-07-17 17:17:37 +08:00
{
$this->key = $key;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getAppid()
2019-07-17 17:17:37 +08:00
{
return $this->appid;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getMchId()
2019-07-17 17:17:37 +08:00
{
return $this->mch_id;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getDeviceInfo()
2019-07-17 17:17:37 +08:00
{
return $this->device_info;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getNonceStr()
2019-07-17 17:17:37 +08:00
{
return $this->nonce_str;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getBody()
2019-07-17 17:17:37 +08:00
{
return $this->body;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getOutTradeNo()
2019-07-17 17:17:37 +08:00
{
return $this->out_trade_no;
}
/**
* @return int
*/
2021-04-06 15:15:37 +08:00
public function getTotalFee()
2019-07-17 17:17:37 +08:00
{
return $this->total_fee;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getSpbillCreateIp()
2019-07-17 17:17:37 +08:00
{
return $this->spbill_create_ip;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getNotifyUrl()
2019-07-17 17:17:37 +08:00
{
return $this->notify_url;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getTradeType()
2019-07-17 17:17:37 +08:00
{
return $this->trade_type;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getSignType()
2019-07-17 17:17:37 +08:00
{
return $this->sign_type;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getMchHost()
2019-07-17 17:17:37 +08:00
{
return $this->mch_host;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getAppsecret()
2019-07-17 17:17:37 +08:00
{
return $this->appsecret;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getRemoteAddr()
2019-07-17 17:17:37 +08:00
{
return $this->remote_addr;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getSslCert()
2019-07-17 17:17:37 +08:00
{
return $this->ssl_cert;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getSslKey()
2019-07-17 17:17:37 +08:00
{
return $this->ssl_key;
}
/**
* @return string
*/
2021-04-06 15:15:37 +08:00
public function getKey()
2019-07-17 17:17:37 +08:00
{
return $this->key;
}
2019-07-19 18:09:42 +08:00
/**
* @param array $configs
* @return $this
*/
public function setConfigs(array $configs)
{
2019-07-19 18:09:58 +08:00
if (empty($configs)) {
return $this;
}
2019-07-19 18:09:42 +08:00
foreach ($configs as $key => $val) {
if (empty($val) || is_array($val)) {
continue;
}
if (!property_exists($this, $key)) {
continue;
}
$this->$key = $val;
}
return $this;
}
2019-07-17 17:17:37 +08:00
}