添加忽略

This commit is contained in:
sunday 2023-11-26 17:32:40 +08:00
parent 4fc0c29601
commit 3985642e24
9 changed files with 139 additions and 65 deletions

View File

@ -214,9 +214,9 @@ class VueOperationController extends BaseController
throw new AppException("订单已锁定,无法继续操作");
}
if ($this->order->hasOneRefundApply && $this->order->hasOneRefundApply->isRefunding()) {
throw new AppException('订单有售后记录待处理,无法继续操作');
}
// if ($this->order->hasOneRefundApply && $this->order->hasOneRefundApply->isRefunding()) {
// throw new AppException('订单有售后记录待处理,无法继续操作');
// }
\app\backend\modules\refund\services\RefundOperationService::orderCloseAndRefund($this->order);

View File

@ -129,6 +129,7 @@ class PayType extends BaseModel
const T_H5= 207; // 微信直连H5支付
const T_APP= 208; // 微信APP支付只支持直连
const T_NATIVE= 209; // 微信正扫(只支持直连)
const T_dNATIVE= 127; // 微信正扫(只支持直连)
/**

View File

@ -35,8 +35,6 @@ class RefundPayAdapter
{
$this->pay_type_id = $pay_type_id;
var_dump($pay_type_id);die;
$this->pay = PayFactory::create($this->pay_type_id);
}

View File

@ -61,6 +61,7 @@ class RefundService
}
}
//必须保证请求支付退款接口成功才能改变售后状态
//如果先改变退款状态会触发退款成功监听,实际请求支付退款接口失败了
switch ($this->refundApply->order->pay_type_id) {
@ -209,6 +210,19 @@ class RefundService
case PayType::HUIBEI_CODE:
$result=$this->HuibeiPayRefund();
break;
case 127 :
case PayType::T_JSAPI:
case PayType::A_NATIVE:
case PayType::T_MINIAPP:
case PayType::A_JSAPI:
case PayType::U_NATIVE:
case PayType::U_JSAPI:
case PayType::D_NATIVE:
case PayType::T_H5:
case PayType::T_APP:
case PayType::T_NATIVE:
$this->HftxPay();
break;
default:
$result = $this->unknownPay();
}
@ -216,6 +230,22 @@ class RefundService
return $result;
}
private function HftxPay(){
\Log::debug('------售后确认退款支付类型无对应退款方法--'.$this->refundApply->order->pay_type_id,[$this->refundApply->order->order_sn]);
$payAdapter = new \app\common\modules\refund\RefundPayAdapter($this->refundApply->order->pay_type_id);
$result = $payAdapter->pay($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->created_at, $this->refundApply->price);
if ($result['resp_code']!=='00000000') {
throw new AdminException('HftxPay退款失败');
}
//微信退款 同步改变退款和订单状态
RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
return true;
}
private function unknownPay()
{
\Log::debug('------售后确认退款支付类型无对应退款方法--'.$this->refundApply->order->pay_type_id,[$this->refundApply->order->order_sn]);

View File

@ -44,9 +44,9 @@ class AliPay extends Pay
// 应用公钥证书路径
'app_cert_public_key' => $pay['alipay_app_public_cert'],
// 支付宝根证书路径
'alipay_root_cert' => $pay['alipay_root_cert'],
'alipay_root_cert' => $pay['alipay_root_cert'],
// 公钥证书
'ali_public_key' => $pay['alipay_public_cert'],
'ali_public_key' => $pay['alipay_public_cert'],
];
$this->payService = \Yansongda\Pay\Pay::alipay($config);
} else {
@ -91,7 +91,8 @@ class AliPay extends Pay
\Log::debug('支付宝扫码支付');
return $this->payService->scan($order)->qr_code;
}
return $this->payService->wap($order)->getTargetUrl(); }
return $this->payService->wap($order)->getTargetUrl();
}
public function doRefund($out_trade_no, $totalmoney, $refundmoney = '0')
{

View File

@ -1127,6 +1127,7 @@ class PayFactory
case self::T_H5:
case self::T_APP:
case self::T_NATIVE:
case 127:
case 'T_JSAPI':
case 'T_MINIAPP':
case 'A_JSAPI':

View File

@ -339,7 +339,6 @@ class MergePayController extends ApiController
$orders = Order::whereIn('id', $orderPay->order_ids)->get();
event($event = new AfterOrderPaidRedirectEvent($orders,$orderPay->id));
$data['redirect'] = $event->getData()['redirect']?:$redirect;
var_dump($data);die;
return $this->successJson('成功', $data);
}

View File

@ -8,6 +8,9 @@
namespace app\payment\controllers;
use app\common\events\order\AfterOrderPaidRedirectEvent;
use app\common\models\Order;
use app\common\models\OrderPay;
use app\frontend\modules\payType\BasePayType;
use app\payment\PaymentController;
use app\common\services\Pay;
@ -41,7 +44,8 @@ class HfpayController extends PaymentController
public function preAction()
{
// $_POST=json_decode(file_get_contents('1700912948pay.txt'),true);
// $_POST=json_decode(file_get_contents('1700982737pay.txt'),true);
// var_dump($_POST);die;
parent::preAction();
if (empty(\YunShop::app()->uniacid)) {
$this->jsonData=json_decode($_POST['resp_data'],true);
@ -59,7 +63,6 @@ class HfpayController extends PaymentController
if($verify_result){
$resp_data=$this->jsonData;
$this->pay_type_id = BasePayType::where('code','=',$resp_data['trade_type'])->value('id');
// var_dump($resp_data);
$data = [
'total_fee' => $resp_data['trans_amt'],
'out_trade_no' => $resp_data['req_seq_id'],
@ -68,7 +71,6 @@ class HfpayController extends PaymentController
'pay_type' => '汇付'.$this->payTpye[$resp_data['trade_type']],
'pay_type_id' => $this->pay_type_id
];
// var_dump($data);die;
$this->payResutl($data);
echo "success";
}else{
@ -82,9 +84,13 @@ class HfpayController extends PaymentController
public function refundUrl()
{
file_put_contents(time().'refundUrl.txt',json_encode($_POST));
$out_trade_no='';
$orderPay = OrderPay::where('pay_sn', $out_trade_no)->first();
if (!is_null($orderPay)) {
$orders = Order::whereIn('id', $orderPay->order_ids)->get();
event($event = new AfterOrderPaidRedirectEvent($orders, $orderPay->id));
}
echo "success";
}

View File

@ -1,55 +1,64 @@
<?php
namespace Yunshop\HftxPay\services;
use app\common\exceptions\AppException;
use app\common\helpers\Url;
use app\common\models\Member;
use app\common\models\PayOrder;
use app\common\services\Pay;
use BsPaySdk\core\BsPay;
use BsPaySdk\core\BsPayClient;
use BsPaySdk\request\V2TradePaymentJspayRequest;
use BsPaySdk\request\V2TradePaymentScanpayRefundRequest;
# SDK 初始化文件加载
require_once dirname(__FILE__) . "/../BsPaySdk/init.php";
require_once dirname(__FILE__). "/../BsPaySdk/request/V2TradePaymentJspayRequest.php";
require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradePaymentJspayRequest.php";
require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradePaymentScanpayRefundRequest.php";
class HfPay extends Pay
{
protected $notify_url;
protected $paySet;
protected $TradeType;
public $codeId='';
public $codeId = '';
public $payTpye = [
200=>'T_JSAPI',
201=>'A_NATIVE',
202=>'T_MINIAPP',
203=>'A_JSAPI',
204=>'U_NATIVE',
205=>'U_JSAPI',
206=>'D_NATIVE',
207=>'T_H5',
208=>'T_APP',
209=>'T_NATIVE',
'T_JSAPI'=> '微信公众号',
'T_MINIAPP'=> '微信小程序',
'A_JSAPI'=> '支付宝JS',
'A_NATIVE'=> '支付宝正扫',
'U_NATIVE'=> '银联正扫',
'U_JSAPI'=> '银联JS',
'D_NATIVE'=> '数字人民币正扫',
'T_H5'=> '微信直连H5支付',
'T_APP'=> '微信APP支付只支持直连',
'T_NATIVE'=> '微信正扫(只支持直连)'
200 => 'T_JSAPI',
201 => 'A_NATIVE',
202 => 'T_MINIAPP',
203 => 'A_JSAPI',
204 => 'U_NATIVE',
205 => 'U_JSAPI',
206 => 'D_NATIVE',
207 => 'T_H5',
208 => 'T_APP',
209 => 'T_NATIVE',
127 => '',
'T_JSAPI' => '微信公众号',
'T_MINIAPP' => '微信小程序',
'A_JSAPI' => '支付宝JS',
'A_NATIVE' => '支付宝正扫',
'U_NATIVE' => '银联正扫',
'U_JSAPI' => '银联JS',
'D_NATIVE' => '数字人民币正扫',
'T_H5' => '微信直连H5支付',
'T_APP' => '微信APP支付只支持直连',
'T_NATIVE' => '微信正扫(只支持直连)'
];
/**
* WechatH5Pay constructor.
* @throws AppException
*/
public function __construct($type = '')
{
if(is_numeric($type)){
$this->codeId=$type;
$this->TradeType=$this->payTpye[$type];
}else{
$this->TradeType=$type;
if (is_numeric($type)) {
$this->codeId = $type;
$this->TradeType = $this->payTpye[$type];
} else {
$this->TradeType = $type;
}
$this->paySet = \Setting::get('shop.pay');
$config = [
@ -67,7 +76,11 @@ class HfPay extends Pay
*/
public function doPay($data)
{
$this->notify_url= Url::shopSchemeUrl('payment/hfpay/notifyUrl.php');
$op = "{$this->payTpye[$this->TradeType]}订单支付 订单号:" . $data['order_no'];
$this->log($data['extra']['type'], $this->payTpye[$this->TradeType], $data['amount'], $op, $data['order_no'], Pay::ORDER_STATUS_NON, \YunShop::app()->getMemberId());
$this->notify_url = Url::shopSchemeUrl('payment/hfpay/notifyUrl.php');
// 2.组装请求参数
$request = new V2TradePaymentJspayRequest();
// 请求日期
@ -76,9 +89,9 @@ class HfPay extends Pay
$request->setReqSeqId($data['order_no']);
// 商户号
$request->setHuifuId($this->paySet['sys_id']);
// 交易类型
// 交易类型
$request->setTradeType($this->TradeType);
// 交易金额
// 交易金额
$request->setTransAmt($data['amount']);
// 商品描述
$request->setGoodsDesc($data['body']);
@ -89,13 +102,13 @@ class HfPay extends Pay
$client = new BsPayClient();
$result = $client->postRequest($request);
if (!$result || $result->isError()) { //失败处理
$data['msg']=$result->getErrorInfo();
$data['msg'] = $result->getErrorInfo();
} else { //成功处理
$data=$result->getRspDatas()['data'];
if($data['resp_code']!='00000100'){
$data['msg']=$data['resp_desc'];
}else{
$data['mode']=$this->codeId;
$data = $result->getRspDatas()['data'];
if ($data['resp_code'] != '00000100') {
$data['msg'] = $data['resp_desc'];
} else {
$data['mode'] = $this->codeId;
}
return $data;
}
@ -108,11 +121,34 @@ class HfPay extends Pay
* @param $refundmoney
* @return void
*/
public function doRefund($out_trade_no, $totalmoney, $refundmoney)
public function doRefund($out_trade_no, $OrgReqDate, $refundmoney, $org_req_seq_id = '')
{
$this->notify_url= Url::shopSchemeUrl('payment/hfpay/returnUrl.php');
$this->notify_url = Url::shopSchemeUrl('payment/hfpay/returnUrl.php');
// 2.组装请求参数
$request = new V2TradePaymentScanpayRefundRequest();
// 请求日期
$request->setReqDate(date("Ymd"));
// 请求流水号
$request->setReqSeqId($out_trade_no);
// 商户号
$request->setHuifuId($this->paySet['sys_id']);
var_dump($out_trade_no, $totalmoney, $refundmoney);die;
$request->setOrgReqDate(date('Ymd', $OrgReqDate)); //原交易日
// 交易金额
$request->setOrdAmt($refundmoney);
// 设置非必填字段
$extendInfoMap = $this->getExtendInfos();
$extendInfoMap['org_req_seq_id'] = PayOrder::getPayOrderInfo($out_trade_no)->value('trade_no');
$request->setExtendInfo($extendInfoMap);
// 3. 发起API调用
$client = new BsPayClient();
$result = $client->postRequest($request);
if (!$result || $result->isError()) { //失败处理
$data['msg'] = $result->getErrorInfo();
} else { //成功处理
$data = $result->getRspDatas()['data'];
return $data;
}
}
@ -120,26 +156,28 @@ class HfPay extends Pay
* 获取扩展参数
* @return array
*/
public function getExtendInfos(){
$data['notify_url']=$this->notify_url;
$data['remark']= \YunShop::app()->uniacid;
switch ($this->TradeType){
public function getExtendInfos()
{
$data['notify_url'] = $this->notify_url;
$data['remark'] = \YunShop::app()->uniacid;
switch ($this->TradeType) {
case 'T_JSAPI':
case 'T_MINIAPP':
case 'T_H5':
$openid = Member::getOpenIdForType(\YunShop::app()->getMemberId());
$data['wx_data']=[
'openid'=>$openid
];
break;
$openid = Member::getOpenIdForType(\YunShop::app()->getMemberId());
$data['wx_data'] = [
'openid' => $openid
];
break;
case 'A_JSAPI':
$data['alipay_data']=[
'buyer_id'=>''
$data['alipay_data'] = [
'buyer_id' => ''
];
break;
}
return $data;
}
/**
* 提现
*