Преглед на файлове

盘点任务页面调整

haozi преди 5 години
родител
ревизия
dd23942b60
променени са 2 файла, в които са добавени 18 реда и са изтрити 18 реда
  1. 3 3
      app/InventoryAccount.php
  2. 15 15
      app/Services/InventoryAccountService.php

+ 3 - 3
app/InventoryAccount.php

@@ -35,7 +35,7 @@ class InventoryAccount extends Model
     {
         return $this['total'] ? $this['total']-($this['processed']+$this['ignored']):0;
     }
-    public function getProcessedAmount(){
+    public function getProcessedAttribute(){
         return $this->inventoryMissions()->whereIn('checked',['是','确认差异','已复核'])->where('inventory_account_id',$this['id'])->count();
     }
     public function getIgnoredAttribute(){
@@ -47,11 +47,11 @@ class InventoryAccount extends Model
         $re_checked_amount=$this->inventoryMissions()->where('inventory_account_id',$this['id'])->whereNotNull('re_checked_amount')->count();
         return $this['total'] ? $this['total']-$re_checked_amount:null;
     }
-    public function getDifferenceAmount(){
+    public function getDifferenceAttribute(){
         return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('difference_amount','!=',0)->count();
     }
     //复盘归位
-    public function getReturnedAmount(){
+    public function getReturnedAttribute(){
         return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('returned','是')->count();
 
     }

+ 15 - 15
app/Services/InventoryAccountService.php

@@ -346,9 +346,9 @@ class InventoryAccountService
     //盘点修改盘点任务数据
     public function updateInventory($inventoryAccountId){
         $inventoryAccount=InventoryAccount::find($inventoryAccountId);
-        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
-        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
-        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+        $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
+        $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
+        $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
         if($inventoryAccount->status=='待盘点')
             $inventoryAccount->status='盘点中';
         $inventoryAccount->update();
@@ -430,9 +430,9 @@ class InventoryAccountService
             Controller::logS(__METHOD__,"增加盘点人".__FUNCTION__,json_encode($inventoryId));
             $inventoryAccount=InventoryAccount::query()->find($inventoryId);
             $inventoryAccount->total=$inventoryAccount->total+1;
-            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
-            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
-            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
             $inventoryAccount->update();
             Controller::logS(__METHOD__,"修改盘点任务记录".__FUNCTION__,json_encode($inventoryId));
             $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->where('id',$inventoryAccountMission->id)->first();
@@ -539,9 +539,9 @@ class InventoryAccountService
         if ($inventoryAccountMission>0){
             $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
             $inventoryAccount->total=$inventoryAccount->total-1;
-            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
-            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
-            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
             $inventoryAccount->update();
             Controller::logS(__METHOD__,'删除盘点记录时修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
         }
@@ -554,9 +554,9 @@ class InventoryAccountService
         app('LogService')->log(__METHOD__,"跳过盘点记录修改checked状态",json_encode($inventoryAccountMissionId));
         if ($inventoryAccountMission->checked=='跳过'){
             $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
-            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
-            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
-            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
             $inventoryAccount->update();
             Controller::logS(__METHOD__,'跳过盘点记录时修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
         }
@@ -582,9 +582,9 @@ class InventoryAccountService
         }
         app('LogService')->log(__METHOD__,"批量跳过或确认差异",json_encode($checkData));
         $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
-        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
-        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
-        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+        $inventoryAccount->processed=$inventoryAccount->getProcessedAttribute();//已盘点数
+        $inventoryAccount->difference=$inventoryAccount->getDifferenceAttribute();//盘点差异数
+        $inventoryAccount->returned=$inventoryAccount->getReturnedAttribute(); //复盘归位数
         $inventoryAccount->update();
         Controller::logS(__METHOD__,'批量跳过或确认差异修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
         return $inventoryAccountMissions;