Преглед изворни кода

Merge branch 'master' into dev

shish пре 1 месец
родитељ
комит
b56fee2c46

+ 136 - 0
app-ghs/controllers/OrderController.php

@@ -735,6 +735,142 @@ class OrderController extends BaseController
         }
         }
     }
     }
 
 
+    //微信和支付宝付款码支付验证(带付款码) ssh 20260716
+    public function actionCodePayVerify()
+    {
+        ini_set('date.timezone', 'Asia/Shanghai');
+        header("Content-type: text/html; charset=utf-8");
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) ? $get['id'] : 0;
+        $authCode = isset($get['authCode']) ? $get['authCode'] : '';
+
+        util::checkRepeatCommit($id, 3);
+
+        $order = OrderClass::getById($id, true);
+        if (empty($order)) {
+            util::success(['returnStatus' => 'SUCCESS']);
+        }
+        if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) {
+            util::complete('订单已付款');
+        }
+        if ($order->status == OrderClass::ORDER_STATUS_CANCEL) {
+            util::complete('订单已取消');
+        }
+        if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) {
+            util::complete('订单不是待付款状态');
+        }
+        OrderClass::valid($order, $this->shopId);
+        $cgId = $order->purchaseId ?? 0;
+        $cg = PurchaseClass::getById($cgId, true);
+        $orderSn = $cg->orderSn ?? '';
+        $totalFee = $cg->actPrice ?? 0;
+        if (empty($orderSn)) {
+            util::complete('没有找到采购单');
+        }
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+
+            $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
+
+            $shop = $this->shop;
+
+            $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',
+                'merchant_no' => $shop->lklSjNo,
+                'term_no' => $shop->lklScanTermNo,
+                'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
+                'lklCertificatePath' => $lklCertificatePath,
+            ];
+            $laResource = new Lakala($params);
+            $scanParams = ['orderSn' => $orderSn, 'authCode' => $authCode];
+            $response = $laResource->query($scanParams);
+
+            if (isset($response['code']) && $response['code'] == 'BBS00000') {
+                if (isset($response['resp_data']['trade_state']) && $response['resp_data']['trade_state'] == 'SUCCESS') {
+                    //支付成功
+                    $transactionId = $response['resp_data']['trade_no'] ?? '';
+                    $openId = '';
+                    $aliUserId = '';
+
+                    $cg->onlinePay = dict::getDict('onlinePay', 'yes');
+                    $cg->codePay = 1;
+                    $cg->payOpenId = $openId;
+                    $cg->aliUserId = $aliUserId;
+                    //自取订单
+                    $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
+                    $cg->save();
+
+                    $order->onlinePay = dict::getDict('onlinePay', 'yes');
+                    $order->codePay = 1;
+                    //自取订单
+                    $order->sendType = OrderClass::SEND_TYPE_NO;
+                    $order->save();
+
+                    $payWayType = dict::getDict('payWay', 'wxPay');
+                    $account_type = $response['resp_data']['account_type'] ?? '';
+                    if ($account_type == 'WECHAT') {
+                        $payWayType = dict::getDict('payWay', 'wxPay');
+                    }
+                    if ($account_type == 'ALIPAY') {
+                        $payWayType = dict::getDict('payWay', 'alipay');
+                    }
+                    $order->payWay = $payWayType;
+                    $order->save();
+                    $cg->payWay = $payWayType;
+                    $cg->save();
+
+                    $attach = '';
+                    payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
+                    $transaction->commit();
+
+                    $saleId = $order->id ?? 0;
+                    $order = OrderClass::getById($saleId, true);
+                    if (!empty($order)) {
+
+                        //解决扫码付重复打印问题
+                        $cacheKey = 'scan_pay_print_order_' . $orderSn;
+                        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                        if (!empty($has)) {
+                            return false;
+                        }
+                        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 1, 'has']);
+
+                        //订单生成时唤起在线打印
+                        if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
+                            if ($order->status != 1 && $order->status != 5) {
+                                OrderClass::onlinePrint($order);
+                                $ext = $this->shopExt;
+                                if (isset($ext->printSn) && !empty($ext->printSn)) {
+                                    $order->printNum += 1;
+                                    $order->save();
+                                }
+                            }
+                        }
+
+                        //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                        GhsDeliveryOrderClass::payAfter($order);
+
+                        ShopExtClass::ghsGatheringReport($order);
+                    }
+                    util::success(['returnStatus' => 'SUCCESS']);
+                } else {
+                    util::complete('未知状态..');
+                }
+            } else {
+                util::complete('未知状态....');
+            }
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            noticeUtil::push('查询订单状态失败:' . $e->getMessage(), '15280215347');
+            util::fail('支付失败');
+        }
+    }
+
     /**
     /**
      * 微信和支付宝付款码支付
      * 微信和支付宝付款码支付
      * 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态
      * 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态

+ 2 - 2
app-hd/controllers/NoticeController.php

@@ -226,7 +226,7 @@ class NoticeController extends PublicController
 
 
                                 if (getenv('YII_ENV') == 'production') {
                                 if (getenv('YII_ENV') == 'production') {
                                     //福州我要花、花路鲜花批发、小齐鲜花、花镜打二次小票,有多处要修改搜索关键词tow_print
                                     //福州我要花、花路鲜花批发、小齐鲜花、花镜打二次小票,有多处要修改搜索关键词tow_print
-                                    $needTwoPrint = [7538, 36707, 76796];
+                                    $needTwoPrint = [7538, 36707, 76796, 94589];
                                 } else {
                                 } else {
                                     $needTwoPrint = [644];
                                     $needTwoPrint = [644];
                                 }
                                 }
@@ -451,7 +451,7 @@ class NoticeController extends PublicController
 
 
                                 if (getenv('YII_ENV') == 'production') {
                                 if (getenv('YII_ENV') == 'production') {
                                     //福州我要花、花路鲜花批发、花镜打二次小票,有多处要修改搜索关键词tow_print
                                     //福州我要花、花路鲜花批发、花镜打二次小票,有多处要修改搜索关键词tow_print
-                                    $needTwoPrint = [7538, 36707, 76796];
+                                    $needTwoPrint = [7538, 36707, 76796, 94589];
                                 } else {
                                 } else {
                                     $needTwoPrint = [];
                                     $needTwoPrint = [];
                                 }
                                 }

+ 101 - 0
app-hd/controllers/OrderController.php

@@ -437,6 +437,107 @@ class OrderController extends BaseController
         }
         }
     }
     }
 
 
+    //微信和支付宝付款码支付验证(带付款码) ssh 20260716
+    public function actionCodePayVerify()
+    {
+        ini_set('date.timezone', 'Asia/Shanghai');
+        header("Content-type: text/html; charset=utf-8");
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) ? $get['id'] : 0;
+        $authCode = isset($get['authCode']) ? $get['authCode'] : '';
+
+        util::checkRepeatCommit($id, 3);
+
+        $order = OrderClass::getById($id, true);
+        OrderClass::valid($order, $this->mainId);
+        $orderSn = $order->orderSn ?? '';
+        $totalFee = $order->mainPay ?? 0;
+        if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) {
+            util::success(['returnStatus' => 'SUCCESS']);
+        }
+        if ($order->status == OrderClass::ORDER_STATUS_CANCEL) {
+            util::complete('订单已取消');
+        }
+        if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) {
+            util::complete('订单不是待付款状态');
+        }
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+
+            $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
+
+            $shop = $this->shop;
+            $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',
+                'merchant_no' => $shop->lklSjNo,
+                'term_no' => $shop->lklScanTermNo,
+                'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
+                'lklCertificatePath' => $lklCertificatePath,
+            ];
+            $laResource = new Lakala($params);
+            $scanParams = ['orderSn' => $orderSn, 'authCode' => $authCode];
+            $response = $laResource->query($scanParams);
+
+            if (isset($response['code']) && $response['code'] == 'BBS00000') {
+                if (isset($response['resp_data']['trade_state']) && $response['resp_data']['trade_state'] == 'SUCCESS') {
+
+                    $payWayType = dict::getDict('payWay', 'wxPay');
+                    $account_type = $response['resp_data']['account_type'] ?? '';
+                    if ($account_type == 'WECHAT') {
+                        $payWayType = dict::getDict('payWay', 'wxPay');
+                    }
+                    if ($account_type == 'ALIPAY') {
+                        $payWayType = dict::getDict('payWay', 'alipay');
+                    }
+
+                    $transactionId = $response['resp_data']['trade_no'] ?? '';
+                    $order->onlinePay = dict::getDict('onlinePay', 'yes');
+                    $order->save();
+                    $attach = '';
+                    payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
+                    $transaction->commit();
+
+                    //解决重复通知
+                    $cacheKey = 'hd_shop_order_pay_check_' . $orderSn;
+                    $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                    if (empty($has)) {
+                        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 'has']);
+
+                        //打印小票和语音播报
+                        $newOrder = OrderClass::getById($id, true);
+                        OrderClass::onlinePrint($newOrder);
+                        ShopExtClass::hdGatheringReport($newOrder);
+
+                        //到店自取订单,并且是待取货状态,则自动完成取货,多处要同步修改,关键词 reach_shop_fetch_goods
+                        if ($newOrder->getGoods == 1 && $newOrder->sendType == 1 && $newOrder->status == 2) {
+                            $newOrder->status = 4;
+                            $newOrder->save();
+                        }
+
+                        HdDeliveryOrderClass::payAfter($newOrder);
+
+                        $shopId = $newOrder->shopId ?? 0;
+                        $shop = ShopClass::getById($shopId, true);
+                        WxMessageClass::gatheringIncomeInform($shop, $newOrder);
+                    }
+
+                    util::success(['returnStatus' => 'SUCCESS']);
+                } else {
+                    util::complete('未知状态..');
+                }
+            }
+            util::complete('未知状态..');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            util::complete('支付失败');
+        }
+    }
+
     /**
     /**
      * 微信和支付宝付款码支付
      * 微信和支付宝付款码支付
      * 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态(零售端)
      * 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态(零售端)

+ 2 - 2
app-pt/views/main/app.php

@@ -237,8 +237,8 @@
             const downloadUrls = {
             const downloadUrls = {
                 'xiaohuabao': 'https://api.shop.hzghd.com/1312.apk', // 销花宝APP下载链接
                 'xiaohuabao': 'https://api.shop.hzghd.com/1312.apk', // 销花宝APP下载链接
                 'huazhanggui': 'https://api.shop.hzghd.com/246.apk', // 花掌柜APP下载链接
                 'huazhanggui': 'https://api.shop.hzghd.com/246.apk', // 花掌柜APP下载链接
-                'huazhanggui_cashier': 'https://api.shop.hzghd.com/209.apk', // 花掌柜收银下载链接
-                'xiaohuabao_cashier': 'https://api.shop.hzghd.com/168.apk' // 销花宝收银下载链接
+                'huazhanggui_cashier': 'https://api.shop.hzghd.com/215.apk', // 花掌柜收银下载链接
+                'xiaohuabao_cashier': 'https://api.shop.hzghd.com/175.apk' // 销花宝收银下载链接
             };
             };
             const url = downloadUrls[appType];
             const url = downloadUrls[appType];
             if (url && url !== '#') {
             if (url && url !== '#') {