'OP00002119', 'serial_no' => '018b08cfddbd', 'merchant_no' => $shop->lklSjNo, 'term_no' => $shop->lklScanTermNo, 'merchantPrivateKeyPath' => $merchantPrivateKeyPath, 'lklCertificatePath' => $lklCertificatePath, ]; $laResource = new Lakala($params); $orderSn = 'KD_CS61235138'; $cashParams = [ 'out_order_no' => $orderSn, ]; $response = $laResource->cashierQuery($cashParams); if (isset($response['code']) == false || $response['code'] != '000000') { util::fail('支付失败了'); } $postData = $response['resp_data'] ?? []; $orderTradeInfoList = $postData['order_trade_info_list'] ?? []; if (empty($orderTradeInfoList)) { util::fail('数据错误'); } $orderTradeInfo = current($orderTradeInfoList); $payMode = $orderTradeInfo['pay_mode'] ?? null; if (empty($payMode)) { noticeUtil::push('收银台支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347'); util::end(); } $trade_amount = $orderTradeInfo['trade_amount'] ?? 0; $totalFee = $trade_amount / 100; $orderStatus = $postData['order_status']; $transactionId = $postData['pay_order_no'] ?? 0; $tradeType = $orderTradeInfo['trade_type'] ?? ''; if ($tradeType != 'PAY') { noticeUtil::push('收银台支付回调验证失败了,不是消费的回调,orderSn:' . $orderSn, '15280215347'); util::end(); } $capitalType = dict::getDict('capitalType', 'xhOrder', '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(); //打印小票和语音播报 $order = OrderClass::getByCondition(['orderSn' => $orderSn], true); ShopExtClass::hdGatheringReport($order); OrderClass::onlinePrint($order); $shopId = $order->shopId ?? 0; $shop = ShopClass::getById($shopId, true); if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) { //您有新的收入提醒 WxMessageClass::gatheringIncomeInform($shop, $order); } if ($order->fromType == dict::getDict("fromType", "mall")) { //来自商城的新订单微信通知 WxMessageClass::hdNewOrderInform($shop, $order); } } //请不要修改 echo "SUCCESS"; exit(); } catch (\Exception $e) { $transaction->rollBack(); Yii::error("失败原因:" . $e->getMessage()); } } }