ソースを参照

APP扫码工具优化翻新前端检查

zhangdongming 8 ヶ月 前
コミット
7d603eacac
1 ファイル変更17 行追加8 行削除
  1. 17 8
      Controller/UserDevice/SerialNumberCheckController.py

+ 17 - 8
Controller/UserDevice/SerialNumberCheckController.py

@@ -210,15 +210,24 @@ class SerialNumberView(View):
         else:
             # 更新现有记录
             should_reset = False
-            count = 0
-            operation_count = 0
-
+            # 翻新次数
+            count = 1
+            # 扫码检查次数
+            operation_count = 1
+            # 是否存在前端检查
+            frontend = False
             for log in renovation_logs:
-                should_reset = log.type == 2 and log.count == 1
-                count = log.count if log.type == 1 else 1
-                operation_count = log.operation_count if log.type == 1 else 1
-
-            if should_reset:
+                # 翻新前端==1,翻新入库==2
+                if log.type == 1:
+                    count = log.count
+                    frontend = True
+                    operation_count = log.operation_count
+                elif log.type == 2 and log.count == 1:
+                    should_reset = True
+
+            if not frontend:  # 不存在前端检查新增记录
+                SerialNumberRenovateLog.objects.create(**params)
+            elif should_reset:
                 # 更新操作计数和重置计数
                 SerialNumberRenovateLog.objects.filter(serial_number=params['serial_number'], type=1) \
                     .update(operation_count=1, count=count + 1, updated_time=current_time)