Explorar el Código

定制客户模块 APP扫码添加数量返回

linhaohong hace 1 año
padre
commit
feb9a4e5df
Se han modificado 1 ficheros con 12 adiciones y 2 borrados
  1. 12 2
      Controller/CustomCustomer/CustomCustomerController.py

+ 12 - 2
Controller/CustomCustomer/CustomCustomerController.py

@@ -50,7 +50,13 @@ class CustomCustomerView(View):
             custom_customer = CustomCustomerOrderInfo.objects.filter(order_number=order_number).first()
             if not custom_customer:
                 return response.json(173)
-            custom_customer_data = {'cId': custom_customer.id}
+            device_count = CustomCustomerDevice.objects.filter(c_id=custom_customer.id).count()
+            custom_customer_data = {
+                'cId': custom_customer.id,
+                'quantity': custom_customer.quantity,
+                'existsDeviceCount': device_count,
+                'unexistsDeviceCount': custom_customer.quantity - device_count
+            }
             return response.json(0, custom_customer_data)
         except Exception as e:
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
@@ -126,7 +132,11 @@ class CustomCustomerView(View):
                 created_time=int(time.time()),
                 updated_time=int(time.time())
             )
-            return response.json(0)
+            device_count = CustomCustomerDevice.objects.filter(c_id=c_id).count()
+            return response.json(0, {
+                'existsDeviceCount': device_count,
+                'unexistsDeviceCount': custom_customer.quantity - device_count
+            })
         except Exception as e:
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))