浏览代码

优化序列号重复响应数据结构体

zhangdongming 1 年之前
父节点
当前提交
6691204fa1
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      Controller/UserDevice/SerialNumberCheckController.py

+ 7 - 5
Controller/UserDevice/SerialNumberCheckController.py

@@ -82,15 +82,17 @@ class SerialNumberView(View):
                 return response.json(0, result)
             first_serial_qs = first_serial_qs.filter(type=p_type)
             if first_serial_qs.exists():
-                result = {
-                    "serialNumber": serial_no,
-                    "phoneModel": '',
-                    "createdTime": '',
-                }
                 # APP扫码工具记录+1
                 params = {'serial_number': first_serial, 'created_time': n_time,
                           'full_serial_number': serial_no, 'type': p_type, 'phone_model': phone_model}
                 SerialNumberCheckLog.objects.create(**params)
+                # 返回当前序列号数据结构
+                log_dict = {'fullSerialNumber': first_serial_qs[0].full_serial_number,
+                            'count': first_serial_qs[0].count, 'type': first_serial_qs[0].type,
+                            'createdTime': first_serial_qs[0].created_time,
+                            'stationName': dict_type[str(first_serial_qs[0].type)],
+                            'phoneModel': first_serial_qs[0].phone_model}
+                result = {'logs': [log_dict]}
                 return response.json(174, result)
             else:
                 params = {'serial_number': first_serial, 'created_time': n_time,