Browse Source

员工业绩

shish 4 years ago
parent
commit
1b4e663eb9

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

@@ -748,7 +748,8 @@ class OrderService extends BaseService
             $shopAdmin->kdAmount = bcadd($shopAdmin->kdAmount, $amount, 2);
             $shopAdmin->save();
         }
-        StatYjClass::addYj($order);
+        $yjAmount = $order->orderPrice ?? 0;
+        StatYjClass::addYj($main, $shop, $shopAdminId, $yjAmount);
 
         //客户资产变化
         if ($payWay == dict::getDict('payWay', 'debtPay')) {

+ 8 - 13
biz-ghs/stat/classes/StatYjClass.php

@@ -51,26 +51,21 @@ class StatYjClass extends BaseClass
     }
 
     //增加业绩 ssh 2021.3.20
-    public static function addYj($order, $date = null)
+    public static function addYj($main, $shop, $shopAdminId, $amount, $date = null)
     {
-        $shopAdminId = $order->shopAdminId ?? 0;
-        if (empty($shopAdminId)) {
-            return false;
-        }
-        $admin = ShopAdminClass::getById($shopAdminId);
-        $sjId = $admin['sjId'] ?? 0;
-        $shopId = $admin['shopId'] ?? 0;
+        $sjId = $shop->sjId ?? 0;
+        $mainId = $main->id ?? 0;
         $date = isset($date) ? $date : date("Ymd");
-        $stat = self::getByCondition(['shopAdminId' => $shopAdminId, 'time' => $date], true);
+        $stat = self::getByCondition(['shopAdminId' => $shopAdminId, 'mainId' => $mainId, 'sjId' => $sjId, 'time' => $date], true);
         if (empty($stat)) {
-            $stat = self::add(['sjId' => $sjId, 'shopId' => $shopId, 'shopAdminId' => $shopAdminId, 'time' => $date], true);
+            $stat = self::add(['sjId' => $sjId, 'shopAdminId' => $shopAdminId, 'mainId' => $mainId, 'time' => $date], true);
         }
         $stat->num += 1;
         $stat->totalNum += 1;
-        $stat->amount = bcadd($order->actPrice, $stat->amount, 2);
-        $stat->totalAmount = bcadd($order->actPrice, $stat->totalAmount, 2);
+        $stat->amount = bcadd($amount, $stat->amount, 2);
+        $stat->totalAmount = bcadd($amount, $stat->totalAmount, 2);
         $stat->save();
-        StatYjMonthClass::addYj($order);
+        StatYjMonthClass::addYj($main, $shop, $shopAdminId, $amount);
     }
 
 }

+ 7 - 12
biz-ghs/stat/classes/StatYjMonthClass.php

@@ -13,24 +13,19 @@ class StatYjMonthClass extends BaseClass
     public static $baseFile = '\bizGhs\stat\models\StatYjMonth';
 
     //增加业绩 ssh 2021.3.15
-    public static function addYj($order, $month = null)
+    public static function addYj($main, $shop, $shopAdminId, $amount, $month = null)
     {
-        $shopAdminId = $order->shopAdminId ?? 0;
-        if (empty($shopAdminId)) {
-            return false;
-        }
-        $admin = ShopAdminClass::getById($shopAdminId);
-        $sjId = $admin['sjId'] ?? 0;
-        $shopId = $admin['shopId'] ?? 0;
+        $sjId = $shop->sjId ?? 0;
+        $mainId = $main->id ?? 0;
         $month = isset($month) ? $month : date("Ym");
-        $stat = self::getByCondition(['sjId' => $sjId, 'time' => $month], true);
+        $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'time' => $month], true);
         if (empty($stat)) {
-            $stat = self::add(['sjId' => $sjId, 'time' => $month, 'shopId' => $shopId, 'shopAdminId' => $shopAdminId], true);
+            $stat = self::add(['sjId' => $sjId, 'time' => $month, 'mainId' => $mainId, 'shopAdminId' => $shopAdminId], true);
         }
         $stat->num += 1;
         $stat->totalNum += 1;
-        $stat->amount = bcadd($order->actPrice, $stat->amount, 2);
-        $stat->totalAmount = bcadd($order->actPrice, $stat->totalAmount, 2);
+        $stat->amount = bcadd($amount, $stat->amount, 2);
+        $stat->totalAmount = bcadd($amount, $stat->totalAmount, 2);
         $stat->save();
         $stat->save();
     }