Przeglądaj źródła

支付宝通知

shish 3 lat temu
rodzic
commit
f3cac34411
1 zmienionych plików z 36 dodań i 2 usunięć
  1. 36 2
      app-hd/controllers/NoticeController.php

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

@@ -258,9 +258,43 @@ class NoticeController extends PublicController
                 //支付成功后续流程
                 payUtil::thirdPay($aliPay, $capitalType, $orderSn, $totalFee, $attach, $tradeNo);
                 $transaction->commit();
+                //请不要修改
+                echo "success";
+
+                //解决重复通知
+                $cacheKey = 'pay_success_notice_' . $orderSn;
+                $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                if (!empty($has)) {
+                    Yii::$app->end();
+                }
+                Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
+
+                //零售采购结账通知
+                if ($capitalType == dict::getDict('capitalType', 'xhPurchase', 'id')) {
+                    $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
+                    if (!empty($cg) && $cg->payStatus == 1) {
+                        //微信通知
+                        $saleId = $cg->saleId ?? 0;
+                        $order = OrderClass::getById($saleId, true);
+                        if (!empty($order)) {
+                            //订单生成时唤起在线打印
+                            if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
+                                OrderClass::onlinePrint($order);
+                                $order->printNum += 1;
+                                $order->save();
+                            }
+                            $shopId = $order->shopId ?? 0;
+                            $shop = ShopClass::getById($shopId, true);
+                            if (!empty($shop)) {
+                                WxMessageClass::ghsHasNewOrderInform($shop, $order);
+                            }
+                            //花店采购供货商端收到通知
+                            NoticeClass::ghsNewOrderNotice($order);
+                        }
+                    }
+                }
+
             }
-            //请不要修改
-            echo "success";
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::error("失败原因:" . $e->getMessage());