2019-10-25 15:20:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
2020-03-05 12:41:49 +08:00
|
|
|
namespace wchat\qq;
|
2019-10-25 15:20:09 +08:00
|
|
|
|
2020-08-10 11:19:52 +08:00
|
|
|
use Exception;
|
2020-03-05 12:41:49 +08:00
|
|
|
use wchat\common\Help;
|
2019-10-25 15:20:09 +08:00
|
|
|
|
2020-08-10 11:17:42 +08:00
|
|
|
/**
|
|
|
|
|
* Class Notify
|
|
|
|
|
* @package wchat\qq
|
|
|
|
|
*/
|
2019-11-11 18:14:47 +08:00
|
|
|
class Notify extends SmallProgram
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
public $appid = null;
|
|
|
|
|
public $mch_id = null;
|
|
|
|
|
public $nonce_str = null;
|
|
|
|
|
public $sign = null;
|
|
|
|
|
public $device_info = null;
|
|
|
|
|
public $trade_type = null;
|
|
|
|
|
public $trade_state = null;
|
|
|
|
|
public $bank_type = null;
|
|
|
|
|
public $fee_type = null;
|
|
|
|
|
public $total_fee = null;
|
|
|
|
|
public $cash_fee = null;
|
|
|
|
|
public $coupon_fee = null;
|
|
|
|
|
public $transaction_id = null;
|
|
|
|
|
public $out_trade_no = null;
|
|
|
|
|
public $attach = null;
|
|
|
|
|
public $time_end = null;
|
|
|
|
|
public $openid = null;
|
2019-10-25 15:20:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
* 判断是否完成支付
|
|
|
|
|
*/
|
|
|
|
|
public function isSuccess()
|
|
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->getTradeState() === 'SUCCESS';
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $params
|
|
|
|
|
* @return $this
|
2020-08-10 11:19:52 +08:00
|
|
|
* @throws Exception
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function setPayNotifyData(array $params)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->validation($params)) {
|
2020-08-10 11:19:52 +08:00
|
|
|
throw new Exception('签名错误!');
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
foreach ($params as $key => $val) {
|
|
|
|
|
if (!property_exists($this, $key)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$this->$key = $val;
|
|
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $params
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function validation(array $params)
|
|
|
|
|
{
|
|
|
|
|
$sign = $params['sign'];
|
|
|
|
|
unset($params['sign']);
|
|
|
|
|
|
|
|
|
|
$signType = $this->config->getSignType();
|
|
|
|
|
$privateKey = $this->config->getKey();
|
|
|
|
|
$nowSign = Help::sign($params, $privateKey, $signType);
|
|
|
|
|
if ($sign === $nowSign) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getAppid()
|
|
|
|
|
{
|
|
|
|
|
return $this->appid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $appid
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setAppid($appid)
|
|
|
|
|
{
|
|
|
|
|
$this->appid = $appid;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getMchId()
|
|
|
|
|
{
|
|
|
|
|
return $this->mch_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $mch_id
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setMchId($mch_id)
|
|
|
|
|
{
|
|
|
|
|
$this->mch_id = $mch_id;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getNonceStr()
|
|
|
|
|
{
|
|
|
|
|
return $this->nonce_str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $nonce_str
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setNonceStr($nonce_str)
|
|
|
|
|
{
|
|
|
|
|
$this->nonce_str = $nonce_str;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getSign()
|
|
|
|
|
{
|
|
|
|
|
return $this->sign;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $sign
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setSign($sign)
|
|
|
|
|
{
|
|
|
|
|
$this->sign = $sign;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function getDeviceInfo()
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->device_info;
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $device_info
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function setDeviceInfo($device_info)
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
$this->device_info = $device_info;
|
2019-10-25 15:20:09 +08:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getTradeType()
|
|
|
|
|
{
|
|
|
|
|
return $this->trade_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $trade_type
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setTradeType($trade_type)
|
|
|
|
|
{
|
|
|
|
|
$this->trade_type = $trade_type;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function getTradeState()
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->trade_state;
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $trade_state
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function setTradeState($trade_state)
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
$this->trade_state = $trade_state;
|
2019-10-25 15:20:09 +08:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function getBankType()
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->bank_type;
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $bank_type
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function setBankType($bank_type)
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
$this->bank_type = $bank_type;
|
2019-10-25 15:20:09 +08:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getFeeType()
|
|
|
|
|
{
|
|
|
|
|
return $this->fee_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $fee_type
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setFeeType($fee_type)
|
|
|
|
|
{
|
|
|
|
|
$this->fee_type = $fee_type;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function getTotalFee()
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->total_fee;
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $total_fee
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function setTotalFee($total_fee)
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
$this->total_fee = $total_fee;
|
2019-10-25 15:20:09 +08:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function getCashFee()
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->cash_fee;
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $cash_fee
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function setCashFee($cash_fee)
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
$this->cash_fee = $cash_fee;
|
2019-10-25 15:20:09 +08:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getCouponFee()
|
|
|
|
|
{
|
|
|
|
|
return $this->coupon_fee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $coupon_fee
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setCouponFee($coupon_fee)
|
|
|
|
|
{
|
|
|
|
|
$this->coupon_fee = $coupon_fee;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getTransactionId()
|
|
|
|
|
{
|
|
|
|
|
return $this->transaction_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $transaction_id
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setTransactionId($transaction_id)
|
|
|
|
|
{
|
|
|
|
|
$this->transaction_id = $transaction_id;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getOutTradeNo()
|
|
|
|
|
{
|
|
|
|
|
return $this->out_trade_no;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $out_trade_no
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setOutTradeNo($out_trade_no)
|
|
|
|
|
{
|
|
|
|
|
$this->out_trade_no = $out_trade_no;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getAttach()
|
|
|
|
|
{
|
|
|
|
|
return $this->attach;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $attach
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setAttach($attach)
|
|
|
|
|
{
|
|
|
|
|
$this->attach = $attach;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
|
|
|
|
public function getTimeEnd()
|
|
|
|
|
{
|
|
|
|
|
return $this->time_end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $time_end
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
|
|
|
|
public function setTimeEnd($time_end)
|
|
|
|
|
{
|
|
|
|
|
$this->time_end = $time_end;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @return null
|
2019-10-25 15:20:09 +08:00
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function getOpenid()
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
return $this->openid;
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-10 11:17:42 +08:00
|
|
|
* @param null $openid
|
2019-10-25 15:20:09 +08:00
|
|
|
* @return Notify
|
|
|
|
|
*/
|
2020-08-10 11:17:42 +08:00
|
|
|
public function setOpenid($openid)
|
2019-10-25 15:20:09 +08:00
|
|
|
{
|
2020-08-10 11:17:42 +08:00
|
|
|
$this->openid = $openid;
|
2019-10-25 15:20:09 +08:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 11:17:42 +08:00
|
|
|
|
2019-10-25 15:20:09 +08:00
|
|
|
}
|