|
@@ -38,7 +38,6 @@ class CompanyView(View):
|
|
|
# return response.json(309)
|
|
|
|
|
|
id = request_dict.get('id', None)
|
|
|
- p2p = request_dict.get('p2p', None)
|
|
|
quantity = request_dict.get('quantity', None)
|
|
|
|
|
|
if not all([id, quantity]):
|
|
@@ -48,23 +47,22 @@ class CompanyView(View):
|
|
|
if not company_qs.exists():
|
|
|
return response.json(444)
|
|
|
|
|
|
- p2p_sum_Serial = SerialNumberModel.objects.filter(p2p=p2p).count()
|
|
|
- p2p_sum_Serial_company = CompanySerialModel.objects.filter(p2p=p2p).count()
|
|
|
- p2p_sum_bind = p2p_sum_Serial - p2p_sum_Serial_company # 剩余可绑定的序列号
|
|
|
- if int(quantity) > int(p2p_sum_bind):
|
|
|
+ sum_Serial = SerialNumberModel.objects.filter().count()
|
|
|
+ sum_Serial_company = CompanySerialModel.objects.filter().count()
|
|
|
+ sum_bind = sum_Serial - sum_Serial_company # 剩余可绑定的序列号
|
|
|
+ if int(quantity) > int(sum_bind):
|
|
|
return response.json(10041)
|
|
|
|
|
|
try:
|
|
|
company = company_qs[0]
|
|
|
- start_1 = p2p_sum_Serial_company
|
|
|
+ start_1 = sum_Serial_company
|
|
|
end_1 = int(start_1) + int(quantity)
|
|
|
- serial_qs = SerialNumberModel.objects.filter(p2p=p2p)[start_1:end_1]
|
|
|
+ serial_qs = SerialNumberModel.objects.filter()[start_1:end_1]
|
|
|
if serial_qs.exists():
|
|
|
company_serial_bulk = []
|
|
|
now_time = int(time.time())
|
|
|
for item in serial_qs:
|
|
|
company_serial_bulk.append(CompanySerialModel(
|
|
|
- p2p=p2p,
|
|
|
status=1,
|
|
|
add_time=now_time,
|
|
|
update_time=now_time,
|