Просмотр исходного кода

手持收货状态判断修改

haozi 4 лет назад
Родитель
Сommit
53c1e9e746
2 измененных файлов с 17 добавлено и 25 удалено
  1. 0 18
      app/Http/Controllers/TestController.php
  2. 17 7
      app/Services/HandInStorageService.php

+ 0 - 18
app/Http/Controllers/TestController.php

@@ -350,22 +350,4 @@ sql;
             }
         }
     }
-
-    public function testDocOrder()
-    {
-        $now=Carbon::now()->toDateTimeString();
-        $before=Carbon::now()->subMinutes(30)->toDateTimeString();
-//        dd($now,$before);
-        $orders=OracleDOCOrderHeader::query()
-            ->whereIn('sostatus',['40','50','60','61'])
-//            ->where('edittime','>=',$before)
-//            ->where('edittime','<=',$now)
-            ->whereNotNull('soreference5')
-            ->where('manualflag','N')
-            ->whereIn('customerid',['BAOSHI']) //指定货主
-            ->where('releasestatus','!=','H')
-            ->get();
-//            ->update(['manualflag'=>'N','edittime'=>$now]);
-        dd($orders);
-    }
 }

+ 17 - 7
app/Services/HandInStorageService.php

@@ -616,21 +616,32 @@ sql;
             if ($asnDetail['asnno'] == $info['asnno'] &&
                 $asnDetail['asnlineno'] == $info['asnlineno'] &&
                 $asnDetail['customerid'] == $info['customerid'] &&
-                $asnDetail['sku'] == $info['sku']) $receiveAsn = $asnDetail;
+                $asnDetail['sku'] == $info['sku'] ){
+                $receiveAsn = $asnDetail;
+                break;
+            }
         }
-//        return $db->transaction(function () use ($db, $info, $receiveAsn, $invlotatt, $time, $who, $asn) {
-        if ($receiveAsn && (int)$receiveAsn['receivedqty'] + (int)$info['amount'] < (int)$receiveAsn['expectedqty']) {
-            //asn_detail 收货数量+已收数量<预期数量
+
+        if (!$receiveAsn) return true;
+
+        $receivedQty = (int)($receiveAsn['receivedqty']??$receiveAsn['receivedqty_each']);  // 已收货数量
+        $amount = (int) $info['amount'];                    // 当前收货数量
+        $expectedQty = (int)$receiveAsn['expectedqty'];     // 预期数量
+
+        if ($receivedQty + $amount < $expectedQty) {
+            // 已收货数量+当前收货数量 < 预期数量
             $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty = receivedqty + ?,receivedqty_each = receivedqty_each + ?,linestatus = '30',holdrejectcode ='OK',
                 reserve_flag ='Y',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),receivedtime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,
              lotatt01 =?,lotatt02 =?,lotatt03 =?,lotatt04 =?,lotatt05 =?,lotatt06 =?,lotatt07 =?,lotatt08=? WHERE asnno = ? and asnlineno = ?"),
                 [(int)$info['amount'], (int)$info['amount'], $time, $time, $who, $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
                     $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $info['asnno'], $info['asnlineno']]);
+
             //asn_header 部分收货状态
             $db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '30',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
                 [$time, $who, $info['asnno']]);
-        } elseif ($receiveAsn && (int)$receiveAsn['receivedqty'] + (int)$info['amount'] == (int)$receiveAsn['expectedqty']) {
-            //asn_detail 收货数量+已收数量=预期数量
+
+        } elseif ($receivedQty + $amount == $expectedQty) {
+            // 已收货数量+当前收货数量 = 预期数量
             $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty=receivedqty+?,receivedqty_each=receivedqty_each+?,linestatus = '40',
                 edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),receivedtime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,holdrejectcode='OK',
                 reserve_flag='Y',lotatt01=?,lotatt02=?,lotatt03=?,lotatt04=?,lotatt05=?,lotatt06=?,lotatt07=?,lotatt08=? WHERE asnno = ? and asnlineno = ?"),
@@ -647,7 +658,6 @@ sql;
             }
         }
         return true;
-//        });
     }
 
     /**