shish 2 місяців тому
батько
коміт
223e77bce2

+ 12 - 1
app-ghs/controllers/OrderController.php

@@ -17,6 +17,7 @@ use bizHd\purchase\services\PurchaseService;
 use bizHd\wx\classes\WxOpenClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\order\classes\OrderClass;
+use bizGhs\order\classes\OrderMergeSnClass;
 use bizGhs\order\services\OrderService;
 use bizHd\saas\services\RegionService;
 use bizGhs\product\classes\ProductClass;
@@ -342,6 +343,16 @@ class OrderController extends BaseController
         $respond = OrderClass::getOrderList($where);
         $respond['shop'] = $this->shop;
         $respond['shopExt'] = $this->shopExt;
+        $respond['shareInfo'] = [];
+        $shareOrder = $respond['list'][0] ?? [];
+        $orderMergeSnId = $mergeInfo->mergeId ?? 0;
+        $mergeSn = !empty($orderMergeSnId) ? OrderMergeSnClass::getById($orderMergeSnId) : [];
+        if (!empty($shareOrder) && !empty($mergeSn)) {
+            $respond['shareInfo'] = [
+                'id' => $shareOrder['id'] ?? 0,
+                'salt' => $mergeSn['salt'] ?? '',
+            ];
+        }
         util::success($respond);
     }
 
@@ -3254,4 +3265,4 @@ class OrderController extends BaseController
         util::complete('修改成功');
     }
 
-}
+}

+ 51 - 6
app-hd/controllers/PurchaseController.php

@@ -10,6 +10,7 @@ use biz\shop\classes\ShopExtClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\express\classes\GhsDeliveryOrderClass;
 use bizGhs\order\classes\OrderClass;
+use bizGhs\order\classes\OrderMergeSnClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseItemClass;
 use bizHd\purchase\services\PurchaseService;
@@ -31,7 +32,7 @@ use common\components\push;
 class PurchaseController extends BaseController
 {
 
-    public $guestAccess = ['detail', 'ali-pay', 'get-ali-pay-code', 'wx-pay'];
+    public $guestAccess = ['detail', 'ali-pay', 'get-ali-pay-code', 'wx-pay', 'merge-order-list'];
 
     //取消采购单 ssh 20250710
     public function actionCancel()
@@ -1047,16 +1048,48 @@ class PurchaseController extends BaseController
         Yii::$app->params['pageSize'] = 9999;
 
         $get = Yii::$app->request->get();
-        $mergeId = $get['mergeId'] ?? 0;
-        $ghsId = $get['ghsId'] ?? 0;
-        if (empty($mergeId)) {
+        $id = $get['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('请选择采购单');
+        }
+        $order = OrderClass::getById($id, true);
+        if (empty($order)) {
+            util::fail('请选择订单');
+        }
+        $ghsMergeId = $order->mergeId ?? 0;
+        if (empty($ghsMergeId)) {
+            util::fail('请选择合并订单');
+        }
+        $ghsMergeSn = OrderMergeSnClass::getById($ghsMergeId, true);
+        if (empty($ghsMergeSn)) {
+            util::fail('请选择合并订单');
+        }
+        $salt = $get['salt'] ?? '';
+        if (empty($this->shopId)) {
+            if (empty($salt)) {
+                util::fail('请求参数错误');
+            }
+            if (empty($ghsMergeSn->salt) || $ghsMergeSn->salt != $salt) {
+                util::fail('找不到订单');
+            }
+        }
+        $purchaseId = $order->purchaseId ?? 0;
+        $purchase = PurchaseClass::getById($purchaseId, true);
+        if (empty($purchase)) {
             util::fail('请选择采购单');
         }
+        $mergeId = $purchase->mergeId ?? 0;
+        $ghsId = $purchase->ghsId ?? 0;
+        if (empty($mergeId)) {
+            util::fail('请选择合并采购单');
+        }
         if (empty($ghsId)) {
             util::fail('请选择供货商');
         }
         $ghsInfo = GhsClass::getGhsInfo($ghsId);
-        GhsClass::valid($ghsInfo, $this->shopId);
+        if (!empty($this->shopId)) {
+            GhsClass::valid($ghsInfo, $this->shopId);
+        }
         $where = [
             'ghsId' => $ghsId,
             'mergeId' => $mergeId,
@@ -1065,7 +1098,7 @@ class PurchaseController extends BaseController
         if (empty($respond['list'])) {
             util::fail('请选择采购单');
         }
-        $respond['shop'] = $this->shop->attributes;
+        $respond['shop'] = !empty($this->shop) ? $this->shop->attributes : [];
         util::success($respond);
     }
 
@@ -1075,6 +1108,18 @@ class PurchaseController extends BaseController
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $info = PurchaseService::getInfo($id, true, true);
+        if (empty($info)) {
+            util::fail('没有找到采购单');
+        }
+        if (empty($this->shopId)) {
+            $salt = $get['salt'] ?? '';
+            if (empty($salt)) {
+                util::fail('请求参数错误');
+            }
+            if (empty($info['salt']) || $info['salt'] != $salt) {
+                util::fail('没有找到采购单');
+            }
+        }
         if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
             //不能注释,分享付款功能要用,客户没有登录也能付款
             //util::fail('无法访问');

+ 2 - 1
biz-ghs/order/classes/OrderClass.php

@@ -1019,6 +1019,7 @@ class OrderClass extends BaseClass
         $localConfirmTime = dict::getDict('local_gys_kd_auto_set_debt_time');
         $currentSet = $currentTime + $localConfirmTime;
         $data['autoSetTime'] = $data['autoSetTime'] ?? date("Y-m-d H:i:s", $currentSet);
+        $data['salt'] = $data['salt'] ?? stringUtil::charsShuffleLowerCase(10);
         $return = self::add($data, true);
 
         return $return;
@@ -3361,4 +3362,4 @@ XL;
         //noticeUtil::push("orderIds = {$sameTimeIdsStr}, sameTimeIdsStr: {$sameTimeIdsStr}");
     }
 
-}
+}

+ 2 - 0
biz-hd/purchase/classes/PurchaseClass.php

@@ -33,6 +33,7 @@ use common\components\IntraCityExpress;
 use common\components\mapUtil;
 use common\components\noticeUtil;
 use common\components\orderSn;
+use common\components\stringUtil;
 use common\components\util;
 use bizHd\base\classes\BaseClass;
 use common\components\lakala\Lakala;
@@ -1200,6 +1201,7 @@ class PurchaseClass extends BaseClass
         $localConfirmTime = dict::getDict('local_gys_kd_auto_set_debt_time');
         $currentSet = $currentTime + $localConfirmTime;
         $data['autoSetTime'] = $data['autoSetTime'] ?? date("Y-m-d H:i:s", $currentSet);
+        $data['salt'] = $data['salt'] ?? stringUtil::charsShuffleLowerCase(10);
         //保存订单
         $respond = self::add($data, true);
 

+ 2 - 0
common/components/orderSn.php

@@ -44,6 +44,7 @@ class orderSn
     public static function getGhsOrderMergeId($data)
     {
         $data['id'] = null;
+        $data['salt'] = $data['salt'] ?? stringUtil::charsShuffleLowerCase(10);
         $respond = OrderMergeSnClass::add($data);
         $id = $respond['id'] ?? 0;
         if (empty($id)) {
@@ -55,6 +56,7 @@ class orderSn
     public static function getCgMergeId($data)
     {
         $data['id'] = null;
+        $data['salt'] = $data['salt'] ?? stringUtil::charsShuffleLowerCase(10);
         $respond = CgMergeSnClass::add($data);
         $id = $respond['id'] ?? 0;
         if (empty($id)) {