修改微信支付类,新增检测订单获取支付数据

This commit is contained in:
2023-08-01 11:18:20 +08:00
parent ac9c3dee38
commit a1b0d6556c
3 changed files with 91 additions and 21 deletions
+10 -4
View File
@@ -28,7 +28,7 @@ class WechatPay
/**
* @param string $user_type 用户类型(1:患者端 2:专家端 3:药师端)
* @param int $order_type 订单类型(1:问诊订单 2:药品订单)
* @param int $order_type 订单类型(1:问诊订单 2:药品订单 3:检测订单
*/
public function __construct(string $user_type,int $order_type)
{
@@ -46,7 +46,7 @@ class WechatPay
throw new BusinessException("系统配置错误", HttpEnumCode::SERVER_ERROR);
}
if (!in_array($order_type,[1,2])){
if (!in_array($order_type,[1,2,3])){
throw new BusinessException("订单类型错误", HttpEnumCode::SERVER_ERROR);
}
@@ -60,6 +60,11 @@ class WechatPay
$this->refund_notify_url = $this->config['product_refund_notify_url'];
}
if ($order_type == 3){
$this->pay_notify_url = $this->config['detection_pay_notify_url'];
$this->refund_notify_url = $this->config['detection_refund_notify_url'];
}
$app_env = config('app_env','dev');
if ($app_env == "prod"){
$this->domain_name = env('DOMAIN_NAME_PROD','https://prod.hospital.applets.igandanyiyuan.com/');
@@ -122,11 +127,12 @@ class WechatPay
* @param string $out_trade_no 商户系统内部订单号
* @param int $total 支付金额(实际金额x100
* @param string $openid
* @param string $description 备注
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getJsapiPrepayId(string $out_trade_no,int $total,string $openid): array
public function getJsapiPrepayId(string $out_trade_no,int $total,string $openid,string $description): array
{
$app = $this->createApp();
@@ -134,7 +140,7 @@ class WechatPay
"mchid" => $this->pay_config['mch_id'], // <---- 商户号
"out_trade_no" => $out_trade_no, // 商户系统内部订单号
"appid" => $this->config['app_id'],
"description" => "问诊服务",
"description" => $description,
"notify_url" => $this->domain_name . $this->pay_notify_url,
"amount" => [
"total" => $total,//订单总金额,单位为分。