Browse Source

总金额

shish 2 months ago
parent
commit
dc31013aaf
2 changed files with 23 additions and 11 deletions
  1. 14 8
      app-ghs/controllers/OrderController.php
  2. 9 3
      app-hd/controllers/PurchaseController.php

+ 14 - 8
app-ghs/controllers/OrderController.php

@@ -347,14 +347,20 @@ class OrderController extends BaseController
         $respond = OrderClass::getOrderList($where);
         $respond['shop'] = $this->shop;
         $respond['shopExt'] = $this->shopExt;
-        $respond['shareInfo'] = [];
-        if (!empty($mergeInfo)) {
-            $respond['shareInfo'] = [
-                'id' => $mergeInfo->cgMergeId ?? 0,
-                'mergeId' => $mergeInfo->cgMergeId ?? 0,
-                'salt' => $mergeInfo->cgSalt ?? '',
-            ];
-        }
+        $totalPrice = 0;
+        if (!empty($respond['list'])) {
+            foreach ($respond['list'] as $order) {
+                $actPrice = $order['actPrice'] ?? 0;
+                $totalPrice = bcadd($totalPrice, $actPrice, 2);
+            }
+        }
+        $totalPrice = floatval($totalPrice);
+        $respond['shareInfo'] = [
+            'id' => $mergeInfo->cgMergeId ?? 0,
+            'mergeId' => $mergeInfo->cgMergeId ?? 0,
+            'salt' => $mergeInfo->cgSalt ?? '',
+            'totalPrice' => $totalPrice,
+        ];
         util::success($respond);
     }
 

+ 9 - 3
app-hd/controllers/PurchaseController.php

@@ -1075,9 +1075,15 @@ class PurchaseController extends BaseController
             'mergeId' => $mergeId,
         ];
         $respond = PurchaseService::getPurchaseList($where);
-        if (empty($respond['list'])) {
-            util::fail('请选择采购单');
+        $totalPrice = 0;
+        if (!empty($respond['list'])) {
+            foreach ($respond['list'] as $one) {
+                $actPrice = $one['actPrice'] ?? 0;
+                $totalPrice = bcadd($totalPrice, $actPrice, 2);
+            }
         }
+        $totalPrice = floatval($totalPrice);
+        $respond['totalPrice'] = $totalPrice;
         $respond['shop'] = !empty($this->shop) ? $this->shop->attributes : [];
         util::success($respond);
     }
@@ -1100,7 +1106,7 @@ class PurchaseController extends BaseController
                 util::fail('没有找到采购单');
             }
         }
-        if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
+        if ($info->mainId != $this->mainId) {
             //不能注释,分享付款功能要用,客户没有登录也能付款
             //util::fail('无法访问');
         }