Forráskód Böngészése

通知新花材需要分类

shish 2 éve
szülő
commit
1edd475b74

+ 6 - 6
biz-ghs/product/classes/ProductClass.php

@@ -21,6 +21,7 @@ use bizGhs\order\traits\OrderTrait;
 use bizGhs\shop\classes\ShopAdminClass;
 use bizGhs\stock\classes\StockRecordClass;
 use bizGhs\stock\services\StockRecordService;
+use bizHd\notify\classes\NotifyClass;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\noticeUtil;
@@ -1660,20 +1661,17 @@ class ProductClass extends BaseClass
         return $data;
     }
 
-
     //供货商的productId => 零售端的productId  ,不存在的补productId(放在默认分类)
     //productList [{"productId":"113","bigNum":1,"smallNum":0,"classId":"-2","itemId":1}]
-    public static function toggleProductList($productList, $hdShopId, $hdSjId, $hdMainId)
+    public static function toggleProductList($productList, $hdShopId, $hdSjId, $hdMainId, $ghs)
     {
         $itemIds = array_column($productList, "itemId");
         $hdProductData = self::getProductInfoByItemIds($itemIds, $hdMainId);
         $hdProductData = array_column($hdProductData, null, "itemId");
-        //获取默认分类ID
         $defaultClassId = ItemClassClass::getDefaultClassId($hdMainId);
         if (empty($defaultClassId)) {
             util::fail('没有找到花材的默认分类');
         }
-
         foreach ($productList as $k => $v) {
             $itemId = $v['itemId'] ?? 0;
             $ghsProductId = $v['productId'] ?? 0;
@@ -1690,19 +1688,21 @@ class ProductClass extends BaseClass
                 $productData['classId'] = $defaultClassId;
                 unset($productData['id']);
                 $productData['rank'] = 'A';
-                //计算价格
                 $cost = $v['cost'] ?? 0;
                 $addPrice = $v['addPrice'] ?? 0;
                 $productData['price'] = bcadd($cost, $addPrice, 2);
                 $addProduct = ProductClass::addBaseData($productData);
                 $hdProductId = $addProduct->id ?? 0;
+
+                //通知新花材需要分类
+                NotifyClass::cgGetNewProduct($addProduct, $hdMainId, $hdShopId, $ghs);
+
             } else {
                 $hdProductId = $hdProductData[$itemId]['id'];
             }
             $productList[$k]['productId'] = $hdProductId;
             $productList[$k]['ghsProductId'] = $ghsProductId;
         }
-
         return $productList;
     }
 

+ 0 - 22
biz-hd/cg/services/CgRefundService.php

@@ -226,26 +226,4 @@ class CgRefundService extends BaseService
 
     }
 
-    //供货商productId 转 hdProductId [{productId:1,...}]
-    public static function toggleProductList($ghsItemInfo, $hdShopId, $hdSjId, $mainId)
-    {
-        $productIds = array_column($ghsItemInfo, "productId");
-        $productData = ProductClass::getProductByIds($productIds);
-        $itemIds = [];
-        $productMap = [];
-        foreach ($productData as $v) {
-            $itemIds[] = $v['itemId'];
-            $productMap[$v['id']] = $v['itemId'];
-        }
-
-        $hdProductData = ProductClass::getProductInfoByItemIds($itemIds, $mainId);
-        $hdProductData = array_column($hdProductData, null, "itemId");
-
-        foreach ($ghsItemInfo as $k => $v) {
-            $itemId = $productMap[$v['productId']];
-            $hdProductId = $hdProductData[$itemId]['id'];
-            $ghsItemInfo[$k]['hdProductId'] = $hdProductId;
-        }
-        return $ghsItemInfo;
-    }
 }

+ 49 - 0
biz-hd/notify/classes/NotifyClass.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace bizHd\notify\classes;
+
+use bizHd\admin\classes\ShopAdminClass;
+use bizHd\base\classes\BaseClass;
+use Yii;
+
+class NotifyClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\notify\models\Notify';
+
+    public static function getNotifyList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        return $data;
+    }
+
+    //采购获取新花材通知 ssh 20231119
+    public static function cgGetNewProduct($newProduct, $mainId, $shopId, $ghs)
+    {
+        $ghsName = $ghs['name'] ?? '';
+        $productName = $newProduct->name ?? '';
+        $id = $newProduct->id ?? 0;
+        $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
+        if (!empty($staffList)) {
+            foreach ($staffList as $staff) {
+                $staffId = $staff->id;
+                $data = [
+                    'mainId' => $mainId,
+                    'shopId' => $shopId,
+                    'staffId' => $staffId,
+                    'title' => '新花材需要归类',
+                    'type' => 0,
+                    'targetId' => $id,
+                    'read' => 0,
+                    'content' => $ghsName . '采购的' . $productName . ',当前在默认分类',
+                    'page' => '/admin/item/detail?from=1&id=' . $id,
+                ];
+                self::add($data);
+                $notifyNum = bcadd($staff->notifyNum, 1);
+                $staff->notifyNum = $notifyNum;
+                $staff->save();
+            }
+        }
+    }
+
+}

+ 13 - 0
biz-hd/notify/models/Notify.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizHd\notify\models;
+use bizHd\base\models\Base;
+
+class Notify extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhGhsNotify';
+	}
+
+}

+ 1 - 1
biz-hd/purchase/classes/PurchaseClass.php

@@ -537,7 +537,7 @@ class PurchaseClass extends BaseClass
 
         if ($live == 1) {
             //花店真实向批发店采购花材,因为拿的供货商的ID,所以需要转化花店的id
-            $productList = ProductClass::toggleProductList($productList, $shopId, $sjId, $mainId);
+            $productList = ProductClass::toggleProductList($productList, $shopId, $sjId, $mainId, $ghs);
             $ghsProductData = self::getProductMapData($productList, "ghsProductId");
         } else {
             //虚拟采购用的自己的ID所以不需要转化