|
|
@@ -28,7 +28,82 @@ class NoticeController extends PublicController
|
|
|
//收银台的回调通知 ssh 20231229
|
|
|
public function actionCashPayCallback()
|
|
|
{
|
|
|
- noticeUtil::push('收到回调了', '15280215347');
|
|
|
+ header("Content-type: text/html; charset=utf-8");
|
|
|
+ Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
|
|
|
+ $postStr = file_get_contents('php://input');//接收微信服务器返回的xml消息体
|
|
|
+ if (empty($postStr)) {
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+ $headers = Yii::$app->getRequest()->getHeaders();
|
|
|
+ $Authorization = $headers->get('Authorization');
|
|
|
+
|
|
|
+ $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
+ $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
+ $params = [
|
|
|
+ 'appid' => 'OP00002119',
|
|
|
+ 'serial_no' => '018b08cfddbd',
|
|
|
+ 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
|
|
|
+ 'lklCertificatePath' => $lklCertificatePath,
|
|
|
+ ];
|
|
|
+ $laResource = new Lakala($params);
|
|
|
+ $return = $laResource->signatureVerification($Authorization, $postStr);
|
|
|
+
|
|
|
+ $postData = json_decode($postStr, true);
|
|
|
+ $orderSn = $postData['out_order_no'] ?? '';
|
|
|
+ $orderTradeInfo = $postData['order_trade_info'] ?? [];
|
|
|
+ $payMode = $orderTradeInfo['pay_mode'] ?? null;
|
|
|
+ if (empty($payMode)) {
|
|
|
+ noticeUtil::push('收银台支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $thirdLogNo = $orderTradeInfo['log_no'] ?? '';
|
|
|
+ $trade_amount = $orderTradeInfo['trade_amount'] ?? 0;
|
|
|
+ $totalFee = $trade_amount / 100;
|
|
|
+ if ($totalFee <= 0) {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,金额错误,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $transactionId = $orderTradeInfo['trade_no'] ?? 0;
|
|
|
+
|
|
|
+ if ($return == false) {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $orderStatus = $postData['order_status'];
|
|
|
+ $tradeType = $orderTradeInfo['trade_type'] ?? '';
|
|
|
+ if ($tradeType != 'PAY') {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,不是消费的回调,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ if ($orderStatus == 2) {
|
|
|
+ $payWayType = null;
|
|
|
+ if ($payMode == 'ALIPAY') {
|
|
|
+ $payWayType = dict::getDict('payWay', 'alipay');
|
|
|
+ }
|
|
|
+ if ($payMode == 'WECHAT') {
|
|
|
+ $payWayType = dict::getDict('wxPay', 'alipay');
|
|
|
+ }
|
|
|
+ if (isset($payWayType) == false) {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,没有找到支付方式,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $attach = '';
|
|
|
+ payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
|
|
|
+ $transaction->commit();
|
|
|
+ }
|
|
|
+ //请不要修改
|
|
|
+ echo "SUCCESS";
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::error("失败原因:" . $e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//拉卡拉回调通知 ssh 20231009
|