51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Service\ServiceTrait\Api;
|
|
|
|
use App\Exception\ErrException;
|
|
|
|
trait CheckOrderCallBackTrait
|
|
{
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function checkWxCallBackOrder(): void
|
|
{
|
|
if (
|
|
!isset($this->callbackData['trade_state']) ||
|
|
$this->callbackData['trade_state'] != 'SUCCESS' ||
|
|
!isset($this->callbackData['amount']['total']) ||
|
|
$this->callbackData['amount']['total'] <= 0 ||
|
|
!isset($this->callbackData['out_trade_no']) ||
|
|
empty($this->callbackData['out_trade_no']) ||
|
|
// !isset($this->callbackData['mch_id']) ||
|
|
// empty($this->callbackData['mch_id']) ||
|
|
!in_array($this->callbackData['trade_type'],['APP','JSAPI'])
|
|
){
|
|
throw new ErrException('此订单回调异常');
|
|
}
|
|
|
|
$this->orderNo = $this->callbackData['out_trade_no'];
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function checkWxRefundCallBackOrder(): void
|
|
{
|
|
if (
|
|
!isset($this->callbackData['refund_status']) ||
|
|
$this->callbackData['refund_status']!= 'SUCCESS' ||
|
|
!isset($this->callbackData['out_trade_no']) ||
|
|
empty($this->callbackData['out_trade_no']) ||
|
|
!isset($this->callbackData['out_refund_no']) ||
|
|
empty($this->callbackData['out_refund_no']) ||
|
|
!isset($this->callbackData['amount']['total']) ||
|
|
$this->callbackData['amount']['total'] <= 0
|
|
) {
|
|
throw new ErrException('此订单回调异常');
|
|
}
|
|
|
|
$this->orderNo = $this->callbackData['out_refund_no'];
|
|
}
|
|
} |