feat : wechatPay callback
This commit is contained in:
@@ -72,10 +72,12 @@ class RefundOrder extends Model
|
||||
return $this
|
||||
->where('order_id', $orderId)
|
||||
->where('order_type', $type)
|
||||
->whereIn('refund_status',[
|
||||
RefundCode::WAIT_BY_PAY_TOOL,
|
||||
RefundCode::REFUND_SUCCESS
|
||||
])->sum('refund_money') ?? 0;
|
||||
->where('refund_status',RefundCode::REFUND_SUCCESS)
|
||||
// ->whereIn('refund_status',[
|
||||
// RefundCode::WAIT_BY_PAY_TOOL,
|
||||
// RefundCode::REFUND_SUCCESS
|
||||
// ])
|
||||
->sum('refund_money') ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,6 +97,6 @@ class RefundOrder extends Model
|
||||
*/
|
||||
public function getInfoByOrderSnoAndType(string $orderSno, int $type): \Hyperf\Database\Model\Model|null
|
||||
{
|
||||
return $this->where('order_sno',$orderSno)->where('order_type',$type)->first();
|
||||
return $this->where('refund_order_sno',$orderSno)->where('refund_type',$type)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ class RefundService
|
||||
*/
|
||||
protected function getAllRefundMoneyByOrderId(): void
|
||||
{
|
||||
$this->isRefundMoney = $this->refundOrderModel->getSuccessMoneyByOrderId($this->orderId,$this->type);
|
||||
$this->isRefundMoney = $this->refundOrderModel->getAllMoneyByOrderId($this->orderId,$this->type);
|
||||
}
|
||||
|
||||
// protected function getUser()
|
||||
|
||||
@@ -97,13 +97,13 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
|
||||
{
|
||||
$this->setConfig();
|
||||
|
||||
// $this->callbackData = $this->request->all();
|
||||
try {
|
||||
$this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext'];
|
||||
}catch (Exception $e) {
|
||||
$this->log->debug(__CLASS__.'wxPay回调解密失败'.json_encode($e->getMessage()));
|
||||
throw new ErrException('wxPay回调解密失败');
|
||||
}
|
||||
$this->callbackData = $this->request->all();
|
||||
// try {
|
||||
// $this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext'];
|
||||
// }catch (Exception $e) {
|
||||
// $this->log->debug(__CLASS__.'wxPay回调解密失败'.json_encode($e->getMessage()));
|
||||
// throw new ErrException('wxPay回调解密失败');
|
||||
// }
|
||||
|
||||
if (empty($this->callbackData)) {
|
||||
$this->log->debug(__CLASS__.'wxPay获取回调失败'.json_encode($this->request));
|
||||
|
||||
@@ -34,16 +34,18 @@ trait CheckOrderCallBackTrait
|
||||
public function checkWxRefundCallBackOrder(): void
|
||||
{
|
||||
if (
|
||||
!isset($this->callbackData['return_code']) ||
|
||||
$this->callbackData['return_code']!= 'SUCCESS' ||
|
||||
!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['mch_id']) ||
|
||||
empty($this->callbackData['mch_id'])
|
||||
!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_trade_no'];
|
||||
$this->orderNo = $this->callbackData['out_refund_no'];
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ trait RefundOrderTrait
|
||||
*/
|
||||
protected function checkRefundOrder(): void
|
||||
{
|
||||
$this->refundInfo = $this->refundOrderModel->getInfoByOrderSnoAndType($this->orderNo,self::OrderType);
|
||||
$this->refundInfo = $this->refundOrderModel->getInfoByOrderSnoAndType($this->orderNo,self::PayType);
|
||||
$this->orderInfo = $this->orderModel->getInfoById($this->refundInfo->order_id);
|
||||
$this->payInfo = $this->payOrderModel->getInfoByOrderIdAndTypeAndRType($this->orderInfo->id,self::OrderType,self::PayType);
|
||||
|
||||
@@ -51,6 +51,7 @@ trait RefundOrderTrait
|
||||
$this->refundInfo->refund_time = date('Y-m-d H:i:s');
|
||||
$this->refundInfo->wx_transaction_id = $this->callbackData['transaction_id'];
|
||||
$this->refundInfo->notify_json = json_encode($this->callbackData);
|
||||
$this->refundInfo->remark = '退款成功';
|
||||
|
||||
if (!$this->refundInfo->save()) throw new Exception('更新退款订单失败');
|
||||
|
||||
@@ -72,7 +73,7 @@ trait RefundOrderTrait
|
||||
|
||||
if ($isRefundMoney <= 0) throw new Exception('订单退款金额错误');
|
||||
|
||||
if ($isRefundMoney == $this->orderInfo->actual_price) {
|
||||
if ($isRefundMoney == $this->payInfo->pay_money) {
|
||||
$this->orderInfo->status = OrderCode::FINISH_REFUND;
|
||||
$this->orderInfo->is_refund_all = 1;//todo 感觉可以删除这个值
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user