Pārlūkot izejas kodu

糊盒工资计算

unknown 2 dienas atpakaļ
vecāks
revīzija
f220398ec9
1 mainītis faili ar 40 papildinājumiem un 3 dzēšanām
  1. 40 3
      application/service/GluSalaryCalculationService.php

+ 40 - 3
application/service/GluSalaryCalculationService.php

@@ -144,6 +144,31 @@ class GluSalaryCalculationService
         return stripos((string)$jtbh, 'SG') !== false;
     }
 
+    /**
+     * 判断是否皮壳机台(机台编号含 PK)
+     * @param string $jtbh
+     * @return bool
+     */
+    protected function isShellMachine($jtbh)
+    {
+        return stripos((string)$jtbh, 'PK') !== false;
+    }
+
+    /**
+     * 皮壳机机长工资系数
+     * @param float $wage
+     * @param string $jtbh
+     * @param int $slotIndex 班组序号,1 为机长
+     * @return float
+     */
+    protected function applyShellCaptainWageBonus($wage, $jtbh, $slotIndex)
+    {
+        if ((int)$slotIndex === 1 && $this->isShellMachine($jtbh)) {
+            return floatval(number_format((float)$wage * 1.1, 2, '.', ''));
+        }
+        return $wage;
+    }
+
     /**
      * 员工编号是否参与工资计算(仅纯数字编号)
      * @param mixed $bh
@@ -165,6 +190,7 @@ class GluSalaryCalculationService
     {
         $wageList = [];
         $salary = (float)$report['产量'] * (float)$report['price'];
+        $jtbh = $report['sczl_jtbh'] ?? '';
 
         for ($i = 1; $i <= 30; $i++) {
             $bh = trim($classResult['bh' . $i] ?? '');
@@ -172,11 +198,14 @@ class GluSalaryCalculationService
                 continue;
             }
 
+            $wage = floatval(number_format($salary * (float)$classResult['rate' . $i], 2, '.', ''));
+            $wage = $this->applyShellCaptainWageBonus($wage, $jtbh, $i);
+
             $wageList[] = [
                 'bh' => $bh,
                 'name' => $classResult['员工姓名' . $i] ?? '',
                 'rate' => $classResult['rate' . $i] ?? '',
-                'wage' => floatval(number_format($salary * (float)$classResult['rate' . $i], 2, '.', '')),
+                'wage' => $wage,
             ];
         }
 
@@ -192,6 +221,7 @@ class GluSalaryCalculationService
     protected function calculateManualPieceWages(array $report, array $classResult)
     {
         $employees = [];
+        $jtbh = $report['sczl_jtbh'] ?? '';
         for ($i = 1; $i <= 30; $i++) {
             $bh = trim($classResult['bh' . $i] ?? '');
             if (!$this->isValidEmployeeBh($bh)) {
@@ -201,6 +231,7 @@ class GluSalaryCalculationService
                 'bh' => $bh,
                 'name' => $classResult['员工姓名' . $i] ?? '',
                 'rate' => $classResult['rate' . $i] ?? '',
+                'slot' => $i,
             ];
         }
 
@@ -251,11 +282,13 @@ class GluSalaryCalculationService
                 ? max(0, ($totalOutput - $dailyQuota * $totalCount) * $unitPrice / $totalCount)
                 : 0;
             foreach ($employees as $employee) {
+                $wage = floatval(number_format($overPerPerson, 2, '.', ''));
+                $wage = $this->applyShellCaptainWageBonus($wage, $jtbh, $employee['slot']);
                 $wageList[] = [
                     'bh' => $employee['bh'],
                     'name' => $employee['name'],
                     'rate' => $employee['rate'],
-                    'wage' => floatval(number_format($overPerPerson, 2, '.', '')),
+                    'wage' => $wage,
                 ];
             }
             return $wageList;
@@ -284,7 +317,11 @@ class GluSalaryCalculationService
                 'bh' => $employee['bh'],
                 'name' => $employee['name'],
                 'rate' => $employee['rate'],
-                'wage' => floatval(number_format($wage, 2, '.', '')),
+                'wage' => $this->applyShellCaptainWageBonus(
+                    floatval(number_format($wage, 2, '.', '')),
+                    $jtbh,
+                    $employee['slot']
+                ),
             ];
         }