From 25814edcff4cc8378d412969c51d8b1960c0b35d Mon Sep 17 00:00:00 2001 From: Billy <641833868@qq.com> Date: Mon, 27 Oct 2025 19:03:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=90=8D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/controller/Ccbpayment.php | 4 --- .../library/ccblife/CcbPaymentService.php | 30 +++++++++---------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/addons/shopro/controller/Ccbpayment.php b/addons/shopro/controller/Ccbpayment.php index 3516043..c2e8582 100644 --- a/addons/shopro/controller/Ccbpayment.php +++ b/addons/shopro/controller/Ccbpayment.php @@ -123,10 +123,6 @@ class Ccbpayment extends Common } // 5. 生成支付串(步骤3:调用收银台) - // ⚠️ 注意: generatePaymentString()内部已经完成了以下操作: - // - 更新订单的ccb_pay_flow_id字段(幂等操作,重复更新不影响) - // - 记录支付日志到ccb_payment_log表 - // 控制器不应该重复操作,否则会导致数据重复写入! $result = $this->paymentService->generatePaymentString($orderId, $payFlowId); if (!$result['status']) { diff --git a/addons/shopro/library/ccblife/CcbPaymentService.php b/addons/shopro/library/ccblife/CcbPaymentService.php index 856c5dd..5314719 100644 --- a/addons/shopro/library/ccblife/CcbPaymentService.php +++ b/addons/shopro/library/ccblife/CcbPaymentService.php @@ -122,22 +122,11 @@ class CcbPaymentService $macParams['REFERER'] = ''; // 商户URL(空字符串) - // ⚠️ 关键修复:INSTALLNUM必须在THIRDAPPINFO之前(严格按照文档4.1表格顺序) - // 1.3 可选参数(按文档表格顺序,有值才参与MAC) - // 注意:根据文档4.2,橙色字段有值时才参与MAC,空值不参与 - - // 分期期数(在REFERER之后,THIRDAPPINFO之前) - if (!empty($this->config['install_num'])) { - $macParams['INSTALLNUM'] = $this->config['install_num']; - } - + // ✅ 修复:严格按照文档4.1表格顺序添加必填字段 + // THIRDAPPINFO必须在INSTALLNUM之前(第17位基础字段) $macParams['THIRDAPPINFO'] = 'comccbpay1234567890cloudmerchant'; // 客户端标识(固定值) - // 记录关键参数 - Log::info('[建行支付] 关键参数 order_id:' . $orderId . ' pay_flow_id:' . $payFlowId . ' user_orderid:' . $order['order_sn'] . ' payment:' . $payment); - Log::info('[建行支付] 商户信息 merchant_id:' . ($macParams['MERCHANTID'] ?? 'N/A') . ' pos_id:' . ($macParams['POSID'] ?? 'N/A') . ' branch_id:' . ($macParams['BRANCHID'] ?? 'N/A')); - - // 超时时间 + // 超时时间(第18位基础字段,必填) if (!empty($this->config['timeout'])) { $macParams['TIMEOUT'] = $this->config['timeout']; } else { @@ -145,6 +134,18 @@ class CcbPaymentService $macParams['TIMEOUT'] = date('YmdHis', strtotime('+30 minutes')); } + // 记录关键参数 + Log::info('[建行支付] 关键参数 order_id:' . $orderId . ' pay_flow_id:' . $payFlowId . ' user_orderid:' . $order['order_sn'] . ' payment:' . $payment); + Log::info('[建行支付] 商户信息 merchant_id:' . ($macParams['MERCHANTID'] ?? 'N/A') . ' pos_id:' . ($macParams['POSID'] ?? 'N/A') . ' branch_id:' . ($macParams['BRANCHID'] ?? 'N/A')); + + // ========== ✅ 以下为可选参数(第19+位),按文档表格顺序添加 ========== + // 注意:根据文档4.2,橙色字段有值时才参与MAC,空值不参与 + + // 分期期数(第19位,可选参数) + if (!empty($this->config['install_num'])) { + $macParams['INSTALLNUM'] = $this->config['install_num']; + } + // 中国建设银行App环境参数 // if (!empty($this->config['user_id'])) { // $macParams['USERID'] = $this->config['user_id']; @@ -329,7 +330,6 @@ class CcbPaymentService 'message' => '支付串生成成功', 'data' => [ 'payment_string' => $finalPaymentString, -// 'payment_string' => 'MERCHANTID=105003953998037&POSID=068295530&BRANCHID=340650000&ORDERID=PAY20251027163247893442&USER_ORDERID=202504324734011387001000&PAYMENT=2999.00&CURCODE=01&TXCODE=520100&REMARK1=&REMARK2=YS44000009001853&TYPE=1&GATEWAY=0&CLIENTIP=®INFO=&PROINFO=Apple%u0020Watch%u0020Series%u00207%u0020%u667A%u80FD%u624B%u8868GPS%u6B3E41%u0020%u6BEB%u7C73%u661F%u5149%u8272%u94DD%u91D1%u5C5E%u8868%u58F3%u661F%u5149%u8272%u8FD0%u52A8%u578B%u8868%u5E26&REFERER=&THIRDAPPINFO=comccbpay1234567890cloudmerchant&TIMEOUT=20251027172350&PLATFORMPUB=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6yZj5rUHz+plEbTMSxF6iRy5XTd82LpKGkcRtJcNiHXAvOh/QvW6xc+GJSfvfM9pnRCyWkFrvFViOGnLUrjyoB0wa/TEqWootEEKXSDacFyQ/QIJSK0+zMYTC2Md6gGA4YylJQuYZ1lWDoOLBt9pP93Qnm0R2PEQ5a11HxwdvlQIDAQAB', 'mac' => $mac, 'order_sn' => $order['order_sn'], 'pay_flow_id' => $payFlowId,