Explorar o código

Merge branch 'master' into zhongqi-delivery

shish hai 6 meses
pai
achega
6a39d796e5

+ 49 - 2
app-ghs/controllers/ItemController.php

@@ -542,7 +542,7 @@ class ItemController extends BaseController
         } elseif ($requestType == 'changeStock') {
             $list = ProductClass::changeStockGroup($list, $level);
         } elseif ($requestType == 'kd') {
-            $list = ProductClass::kdItemGroup($list, $level,$custom);
+            $list = ProductClass::kdItemGroup($list, $level, $custom);
         } elseif ($requestType == 'book') {
             $list = ProductClass::bookItemGroup($list, $level);
         } elseif ($requestType == 'itemList') {
@@ -658,12 +658,31 @@ class ItemController extends BaseController
         util::success($respond);
     }
 
+    //全部花材取消隐藏 ssh 20260201
+    public function actionCancelAllItemHide()
+    {
+        $mainId = $this->mainId;
+        ItemClass::updateByCondition(['mainId' => $mainId, 'frontHide' => 1], ['frontHide' => 0, 'frontUse' => 0]);
+        util::complete('操作成功');
+    }
+
+    //分类下的花材取消隐藏 sssh 20260201
+    public function actionCancelClassItemHide()
+    {
+        $get = Yii::$app->request->get();
+        $classId = $get['classId'] ?? 0;
+        $mainId = $this->mainId;
+        ItemClass::updateByCondition(['mainId' => $mainId, 'classId' => $classId, 'frontHide' => 1], ['frontHide' => 0, 'frontUse' => 0]);
+        util::complete('操作成功');
+    }
+
+    //单个花材的显示和隐藏 ssh 20260201
     public function actionChangeFrontHide()
     {
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $status = $get['status'] ?? '';
-        if (is_numeric($status) == false) {
+        if (!is_numeric($status)) {
             util::fail('请选择方式');
         }
         $info = ItemClass::getById($id, true);
@@ -674,10 +693,38 @@ class ItemController extends BaseController
             util::fail('无法操作');
         }
         $info->frontHide = $status;
+        $info->frontUse = $status;
         $info->save();
         util::complete();
     }
 
+    //批量隐藏和显示花材 ssh 20260131
+    public function actionBatchChangeFrontHide()
+    {
+        $post = Yii::$app->request->post();
+        $ids = $post['ids'] ?? 0;
+        $ids = trim($ids);
+        if (empty($ids)) {
+            util::fail('请选花材');
+        }
+        $frontHide = $post['frontHide'] ?? 0;
+        $arr = json_decode($ids, true);
+        if (empty($arr)) {
+            util::fail('请选花材呢');
+        }
+        $list = ItemClass::getAllByCondition(['id' => ['in', $arr]], null, 'id,frontHide,mainId', null, true);
+        if (!empty($list)) {
+            foreach ($list as $key => $currentItem) {
+                if ($currentItem->mainId == $this->mainId) {
+                    $currentItem->frontHide = $frontHide;
+                    $currentItem->frontUse = $frontHide;
+                    $currentItem->save();
+                }
+            }
+        }
+        util::complete('操作成功');
+    }
+
     //检测是否要刷新
     public function actionCheckRefresh()
     {

+ 49 - 39
app-ghs/controllers/OrderController.php

@@ -2446,50 +2446,60 @@ class OrderController extends BaseController
         if (empty($date)) {
             util::fail('请选择日期');
         }
-        $order = OrderClass::getById($id, true);
-        if (empty($order)) {
-            util::fail('没有找到订单');
-        }
-        if ($order->mainId != $this->mainId) {
-            util::fail('不是你的订单');
-        }
-        if ($order->payStatus == 0) {
-            util::fail('没有确认的订单');
-        }
-        $mainId = $this->mainId;
-        //超管或者约定的人可以修改日期
-        if (getenv('YII_ENV') == 'production') {
-            if (in_array($mainId, [23390])) {
-                if (!in_array($this->adminId, [24586, 23960, 24043])) {
-                    util::fail('你不能修改哦');
-                }
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();//开启事务
+        try {
+            $order = OrderClass::getById($id, true);
+            if (empty($order)) {
+                util::fail('没有找到订单');
             }
-        } else {
-            if (in_array($mainId, [644])) {
-                if (!in_array($this->adminId, [919])) {
+            if ($order->mainId != $this->mainId) {
+                util::fail('不是你的订单');
+            }
+            if ($order->payStatus == 0) {
+                util::fail('没有确认的订单');
+            }
+            $mainId = $this->mainId;
+            //超管或者约定的人可以修改日期
+            if (getenv('YII_ENV') == 'production') {
+                if (in_array($mainId, [23390])) {
+                    if (!in_array($this->adminId, [24586, 23960, 24043])) {
+                        util::fail('你不能修改哦');
+                    }
                 }
             }
-        }
 
-        $payTime = $order->payTime;
-        $time = strtotime($payTime);
-        $after = date("H:i:s", $time);
-        $new = $date . ' ' . $after;
-        $cgId = $order->purchaseId ?? 0;
-        $cg = PurchaseClass::getById($cgId, true);
-        if (empty($cg)) {
-            util::fail('没有找到订单信息');
-        }
-        if (strtotime($new) > time()) {
-            util::fail('不能修改成未来时间');
+            $payTime = $order->payTime;
+            $timeArr = explode(' ', $payTime);
+            $dateStr = $timeArr[0];
+            if ($dateStr == $date) {
+                util::fail('日期没变');
+            }
+
+            $after = $timeArr[1];
+            $new = $date . ' ' . $after;
+            $cgId = $order->purchaseId ?? 0;
+            $cg = PurchaseClass::getById($cgId, true);
+            if (empty($cg)) {
+                util::fail('没有找到订单信息');
+            }
+            $order->payTime = $new;
+            $order->save();
+            $cg->payTime = $new;
+            $cg->save();
+            //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词 to_change_custom_debt_pay_time
+            CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $id], ['payTime' => $new]);
+
+            //找到当前订单客户的账单日期为 $date 的所有订单,然后更新同天内的所有订单的 sameTimeIds(加此次要改变的订单的订单号$id),有多处调用,关键词 update_same_ids
+            OrderClass::updateSameTimeIds($order, $date);
+
+            $transaction->commit();
+            util::complete('修改成功');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            util::fail('修改失败');
         }
-        $order->payTime = $new;
-        $order->save();
-        $cg->payTime = $new;
-        $cg->save();
-        //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词to_change_custom_debt_pay_time
-        CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $id], ['payTime' => $new]);
-        util::complete('修改成功');
     }
 
     //应收款统计 ssh 20240528

+ 7 - 1
app-ghs/controllers/ProductController.php

@@ -322,7 +322,9 @@ class ProductController extends BaseController
                 $where['name'] = ['like', $name];
             }
         }
-
+        if($requestType == 'hideItem'){
+            $where['frontHide'] = 1;
+        }
         //客户等级
         $customId = Yii::$app->request->get('customId', 0);
         $level = 1;
@@ -344,6 +346,10 @@ class ProductController extends BaseController
                     $itemInfoData[$key]['shortCover'] = $shortCover;
                 }
             }
+        } elseif ($requestType == 'hideItem') {
+            //隐藏花材列表
+            $field = 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,onStock,cost,avCost,addPrice,hjAddPrice,skMore';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
         } elseif ($requestType == 'changePrice') {
             $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,skMore,hjAddPrice,addPrice,variety,price,hjPrice,stock,onStock,presell,frontHide,reachNum,reachNumDiscount';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);

+ 3 - 3
app-ghs/controllers/TestController.php

@@ -970,7 +970,7 @@ class TestController extends BaseController
     //交易查询 ssh 20231021
     public function actionTradeQuery()
     {
-        $shopId = 7855;
+        $shopId = 72366;
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
             util::stop('没有找到门店,编号677230');
@@ -986,7 +986,7 @@ class TestController extends BaseController
             'lklCertificatePath' => $lklCertificatePath,
         ];
         $laResource = new Lakala($params);
-        $orderSn = 'CG29953307';
+        $orderSn = 'CG30185958';
         $tradeNo = '';
         $queryParams = [
             'orderSn' => $orderSn,
@@ -995,7 +995,7 @@ class TestController extends BaseController
         $response = $laResource->query($queryParams, 0);
         echo "<pre>";
         print_r($response);
-        util::stop();
+        //util::stop();
         if (isset($response['code']) && $response['code'] == 'BBS00000') {
             $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
             $connection = Yii::$app->db;

+ 0 - 6
biz-ghs/cg/services/CgRefundService.php

@@ -237,11 +237,6 @@ class CgRefundService extends BaseService
         if (empty($ghs)) {
             util::fail('没有找到供货商');
         }
-        $ghsAddDebtKey = 'ghs_change_debt_' . $ghsId;
-        $lock = util::lock($ghsAddDebtKey);
-        if (!$lock) {
-            util::fail("系统繁忙,请重试");
-        }
         $ghs->debtAmount = bcsub($ghs->debtAmount, $refundPrice, 2);
         $ghs->save();
 
@@ -262,7 +257,6 @@ class CgRefundService extends BaseService
             'shopId' => $shopId,
         ];
         GhsDebtRecordClass::add($debtData);
-        util::unlock($ghsAddDebtKey);
 
         return $refund;
     }

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

@@ -2963,7 +2963,7 @@ XL;
         $shortRemark = stringUtil::subStringUtf8($remark, 8);
 
         $wlName = $custom->wlName ?? '';
-        if(empty($wlName)){
+        if (empty($wlName)) {
             $wlName = $shortRemark;
         }
 
@@ -3021,4 +3021,49 @@ XL;
         return true;
     }
 
+    // 更新同天内的所有订单的 sameTimeIds
+    public static function updateSameTimeIds($order, $date)
+    {
+        $id = $order->id ?? 0;
+        $customId = $order->customId ?? 0;
+        $mainId = $order->mainId ?? 0;
+        $oldSameTimeIds = $order->sameTimeIds ?? '';
+
+        //找到当前订单客户的账单日期为 $date 的所有订单,然后更新同天内的所有订单的 sameTimeIds(加此次要改变的订单的订单号$id)
+        $startTime = $date . ' 00:00:00';
+        $endTime = $date . ' 23:59:59';
+        $dayOrders = self::getAllByCondition([
+            'mainId' => $mainId,
+            'customId' => $customId,
+            'payTime' => ['between', [$startTime, $endTime]]
+        ], 'id ASC', 'id, sameTimeIds');
+
+        $ids = [];
+        if (!empty($dayOrders)) {
+            $ids = array_column($dayOrders, 'id');
+        }
+        // 确保当前订单ID在列表中
+        if (!in_array($id, $ids)) {
+            $ids[] = $id;
+        }
+        // 排序并去重
+        sort($ids);
+        $ids = array_unique($ids);
+        $sameTimeIdsStr = implode(',', $ids);
+        // 更新所有相关订单
+        if (!empty($ids)) {
+            self::updateByIds($ids, ['sameTimeIds' => $sameTimeIdsStr]);
+        }
+
+        //从原先同天内的订单中删除此次要改变的订单的订单号$id
+        $oldSameTimeIdsArr = explode(',', $oldSameTimeIds);
+        if (in_array($id, $oldSameTimeIdsArr)) {
+            $oldSameTimeIdsArr = array_diff($oldSameTimeIdsArr, [$id]);
+            $oldSameTimeIdsStr = implode(',', $oldSameTimeIdsArr);
+            if (!empty($oldSameTimeIdsArr)) {
+                self::updateByIds($oldSameTimeIdsArr, ['sameTimeIds' => $oldSameTimeIdsStr]);
+            }
+        }
+    }
+
 }

+ 0 - 7
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -688,12 +688,6 @@ class PurchaseOrderClass extends BaseClass
         }
 
         //锁定当前增加资产的运作,有多处,请搜索关键词 ghsAddDebtAction
-        $ghsAddDebtKey = 'ghs_change_debt_' . $ghsId;
-        $lock = util::lock($ghsAddDebtKey);
-        if (!$lock) {
-            util::fail("系统繁忙,请重试");
-        }
-
         $ghs->debt = GhsClass::DEBT_YES;
         $ghs->debtAmount = bcadd($ghs->debtAmount, $currentPrice, 2);
 
@@ -719,7 +713,6 @@ class PurchaseOrderClass extends BaseClass
             'shopId' => $shopId,
         ];
         GhsDebtRecordClass::add($debtData);
-        util::unlock($ghsAddDebtKey);
 
         //采购统计
         $cgNum = $order->itemNum ?? 0;

+ 4 - 1
biz-ghs/order/services/OrderService.php

@@ -302,8 +302,11 @@ class OrderService extends BaseService
                 $purchase->save();
                 $returnOrder->payTime = $currentPayTime;
                 $returnOrder->save();
-                //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词to_change_custom_debt_pay_time
+                //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词 to_change_custom_debt_pay_time
                 CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $returnOrder->id], ['payTime' => $currentPayTime]);
+
+                //找到当前订单客户的账单日期为 $date 的所有订单,然后更新同天内的所有订单的 sameTimeIds(加此次要改变的订单的订单号$id),有多处调用,关键词 update_same_ids
+                OrderClass::updateSameTimeIds($returnOrder, $historyDate);
             }
 
             //不是预订单,并且供货商不是源花汇、小明鲜花、淄博花超、云漫梦金鹏、海翔,则订单直接完成掉。是预订单,则确认发货时直接完成掉。有多个地方要修改,请搜索关键词zjFinish

+ 1 - 1
biz-ghs/stat/classes/StatSaleClass.php

@@ -753,7 +753,7 @@ class StatSaleClass extends BaseClass
         $p = bcsub($e, $s);
         $xx = bcmul(86400, 90);
         if ($p > $xx) {
-            util::fail('查询时间不能超过三个月,编号780');
+            //util::fail('查询时间不能超过三个月,编号780');
         }
 
         $classList = ItemClassClass::getAllByCondition(['mainId' => $mainId], null, 'id,name', 'id');

+ 2 - 0
common/components/rabbitmq/notifyConsumer.php

@@ -162,6 +162,8 @@ class notifyConsumer implements ConsumerInterface
         ];
         $push = new push('hd', push::MSG_TYPE_ORDER);
         $push->pushByCloud($cids, $title, $content, $payload);
+        //$str = implode(',', $cids);
+        //noticeUtil::push("需要通知:" . $content . ' ' . $str, '15280215347');
         return true;
     }