:art: Fix Brand Not Found

huangqimin 5 年 前
コミット
e9c2b67222
共有1 個のファイルを変更した5 個の追加5 個の削除を含む
  1. 5 5
      api/mch_views.py

+ 5 - 5
api/mch_views.py

@@ -209,7 +209,7 @@ def consumer_info_api(request):
209 209
     encryptedData = request.POST.get('encryptedData', '')
210 210
     lat = request.POST.get('lat', .0)
211 211
     lon = request.POST.get('lon', .0)
212
-    brandID = request.POST.get('BrandID', '')
212
+    brandID = request.POST.get('brand_id', '') or request.POST.get('BrandID', '')
213 213
     modelID = request.POST.get('ModelID', '')
214 214
     distributorID = request.POST.get('DistributorID', '')
215 215
     serialNo = request.POST.get('SerialNo', '')
@@ -235,17 +235,17 @@ def consumer_info_api(request):
235 235
     # user.save()
236 236
 
237 237
     try:
238
-        brand = BrandInfo.objects.get(pk=brandID)
238
+        brand = BrandInfo.objects.get(brand_id=brandID)
239 239
     except BrandInfo.DoesNotExist:
240 240
         brand = None
241
-    except ValueError:
242
-        brand = None
243 241
 
244 242
     if not brand:
245 243
         try:
246
-            brand = BrandInfo.objects.get(brand_id=brandID)
244
+            brand = BrandInfo.objects.get(pk=brandID)
247 245
         except BrandInfo.DoesNotExist:
248 246
             return response(ProductBrandStatusCode.BRAND_NOT_FOUND)
247
+        except ValueError:
248
+            return response(ProductBrandStatusCode.BRAND_NOT_FOUND)
249 249
 
250 250
     try:
251 251
         model = ModelInfo.objects.get(pk=modelID)