Переглянути джерело

Merge branch 'master' into dev

shish 2 тижнів тому
батько
коміт
202b3f2180

+ 134 - 9
app-ghs/controllers/OrderController.php

@@ -611,19 +611,144 @@ class OrderController extends BaseController
         util::checkRepeatCommit($id, 3);
 
         $order = OrderClass::getById($id, true);
-        if (empty($order)) {
+        OrderClass::valid($order, $this->shopId);
+        if ($order->payStatus == 1) {
             util::success(['returnStatus' => 'SUCCESS']);
+        }else {
+            util::success(['returnStatus' => 'unPay']);
         }
-        if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) {
-            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('没有找到采购单');
         }
-        if ($order->status == OrderClass::ORDER_STATUS_CANCEL) {
-            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,];
+            $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('支付失败');
         }
-        if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) {
-            util::complete('订单不是待付款状态');
+    }
+
+    //微信和支付宝付款码支付复查 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 = $get['id'] ?? 0;
+
+        util::checkRepeatCommit($id, 3);
+
+        $order = OrderClass::getById($id, true);
+        if (empty($order)) {
+            util::complete('没有找到订单呢');
         }
         OrderClass::valid($order, $this->shopId);
+        if ($order->payStatus == 1) {
+            util::success(['returnStatus' => 'SUCCESS']);
+        } else {
+            util::success(['returnStatus' => 'unPay']);
+        }
         $cgId = $order->purchaseId ?? 0;
         $cg = PurchaseClass::getById($cgId, true);
         $orderSn = $cg->orderSn ?? '';
@@ -723,10 +848,10 @@ class OrderController extends BaseController
                     }
                     util::success(['returnStatus' => 'SUCCESS']);
                 } else {
-                    util::complete('未知状态..');
+                    util::success(['returnStatus' => 'PENDING'], '等待支付中...');
                 }
             } else {
-                util::complete('未知状态....');
+                util::success(['returnStatus' => 'PENDING'], '等待支付中...');
             }
         } catch (\Exception $e) {
             $transaction->rollBack();

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

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

+ 103 - 11
app-hd/controllers/OrderController.php

@@ -279,8 +279,8 @@ class OrderController extends BaseController
     public function actionBatchFetch()
     {
         $where = ["status" => 2, "sendType" => 1, "shopId" => $this->shopId];
-        $orderList = OrderService::getLimitList("id",$where,500,"id desc");
-        $ids = ArrayHelper::getColumn($orderList,"id");
+        $orderList = OrderService::getLimitList("id", $where, 500, "id desc");
+        $ids = ArrayHelper::getColumn($orderList, "id");
         OrderService::updateByIds($ids, ["status" => 4]);
         util::complete($ids);
     }
@@ -351,14 +351,10 @@ class OrderController extends BaseController
         OrderClass::valid($order, $this->mainId);
         $orderSn = $order->orderSn ?? '';
         $totalFee = $order->mainPay ?? 0;
-        if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) {
+        if ($order->payStatus == 1) {
             util::success(['returnStatus' => 'SUCCESS']);
-        }
-        if ($order->status == OrderClass::ORDER_STATUS_CANCEL) {
-            util::complete('订单已取消');
-        }
-        if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) {
-            util::complete('订单不是待付款状态');
+        } else {
+            util::success(['returnStatus' => 'unPay']);
         }
 
         $connection = Yii::$app->db;
@@ -437,6 +433,102 @@ 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 = $get['id'] ?? 0;
+
+        util::checkRepeatCommit($id, 3);
+
+        $order = OrderClass::getById($id, true);
+        OrderClass::valid($order, $this->mainId);
+        $orderSn = $order->orderSn ?? '';
+        $totalFee = $order->mainPay ?? 0;
+        if ($order->payStatus == 1) {
+            util::success(['returnStatus' => 'SUCCESS']);
+        } else {
+            util::success(['returnStatus' => 'unPay']);
+        }
+
+        $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,];
+            $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::success(['returnStatus' => 'PENDING'], '等待支付中...');
+                }
+            }
+            util::success(['returnStatus' => 'PENDING'], '等待支付中...');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            util::complete('支付失败');
+        }
+    }
+
     /**
      * 微信和支付宝付款码支付
      * 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态(零售端)
@@ -870,7 +962,7 @@ class OrderController extends BaseController
                         if ($hasPay != dict::getDict('hasPay', 'balance')) {
                             util::fail('用红包要用余额支付');
                         } else {
-                            if($custom->balance < $post['modifyPrice']) {
+                            if ($custom->balance < $post['modifyPrice']) {
                                 util::fail('用红包要用余额支付(您的余额不足)');
                             }
                         }
@@ -1361,7 +1453,7 @@ class OrderController extends BaseController
         }
         $list = OrderService::getOrderList($where);
         $list['shop'] = $this->shop->attributes ?? [];
-        
+
         util::success($list);
     }
 

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

@@ -237,8 +237,8 @@
             const downloadUrls = {
                 'xiaohuabao': 'https://api.shop.hzghd.com/1312.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];
             if (url && url !== '#') {