|
|
@@ -369,4 +369,106 @@ class NoticeController extends PublicController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //收银台支付回调
|
|
|
+ public function actionCashPayCallback()
|
|
|
+ {
|
|
|
+ header("Content-type: text/html; charset=utf-8");
|
|
|
+
|
|
|
+ Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'mall');
|
|
|
+
|
|
|
+ $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'] ?? '';
|
|
|
+ $payer_amount = $postData['total_amount'] ?? 0;
|
|
|
+ $payMode = $postData['pay_mode'] ?? '';
|
|
|
+ if (empty($payMode)) {
|
|
|
+ noticeUtil::push('收银台支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $totalFee = $payer_amount / 100;
|
|
|
+ $transactionId = $postData['pay_order_no'] ?? 0;
|
|
|
+
|
|
|
+ if ($return == false) {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $orderStatus = $postData['order_status'];
|
|
|
+ $tradeType = $postData['trade_type'];
|
|
|
+ if ($tradeType != 'PAY') {
|
|
|
+ noticeUtil::push('收银台支付回调验证失败了,不是消费的回调,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+ $capitalType = isset($capitalType) ? $capitalType : null;
|
|
|
+
|
|
|
+
|
|
|
+ if (isset($capitalType) == false) {
|
|
|
+ Yii::warning('capitalType empty, orderSn:' . $orderSn);
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+ $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";
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::error("失败原因:" . $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|