add clerk/model/list

FFIB 5 years ago
parent
commit
cbb06886a1
2 changed files with 35 additions and 0 deletions
  1. 1 0
      api/urls.py
  2. 34 0
      page/sale_views.py

+ 1 - 0
api/urls.py

@@ -224,6 +224,7 @@ urlpatterns += [
224 224
     url(r'^clerk/submit$', oauth_views.clerk_submit_api, name='clerk_submit_api'),  # 店员信息提交
225 225
     url(r'^clerk/sale/submit$', sale_views.clerk_sale_submit_api, name='clerk_sale_submit'),  # 店员销售信息提交
226 226
     url(r'^clerk/integral/list$', sale_views.clerk_integral_list_api, name='clerk_integral_list_api'),  # 店员销售积分列表
227
+    url(r'^clerk/model/list$', sale_views.clerk_model_list_api, name='clerk_model_list_api'),
227 228
 ]
228 229
 
229 230
 urlpatterns += [

+ 34 - 0
page/sale_views.py

@@ -355,3 +355,37 @@ def clerk_integral_list_api(request):
355 355
         'total_integral': sum([i.get('integral', 0) for i in integrals]),
356 356
         'left_integral': clerk.integral,
357 357
     })
358
+
359
+@logit
360
+def clerk_model_list_api(request):
361
+    brandID = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_PK)
362
+    user_id = request.POST.get('user_id', '')
363
+    try:
364
+        user = UserInfo.objects.get(user_id=user_id, status=True)
365
+    except UserInfo.DoesNotExist:
366
+        return response(SaleclerkStatusCode.CLERK_NOT_FOUND)
367
+
368
+    try:
369
+        brand = BrandInfo.objects.get(pk=brandID)
370
+    except BrandInfo.DoesNotExist:
371
+        brand = None
372
+    except ValueError:
373
+        brand = None
374
+
375
+    if not brand:
376
+        try:
377
+            brand = BrandInfo.objects.get(brand_id=brandID)
378
+        except BrandInfo.DoesNotExist:
379
+            return response(ProductBrandStatusCode.BRAND_NOT_FOUND)
380
+
381
+    try:
382
+        clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, unionid=user.unionid, status=True)
383
+    except SaleclerkInfo.DoesNotExist:
384
+        return response(SaleclerkStatusCode.CLERK_NOT_FOUND)
385
+
386
+    models = ModelInfo.objects.filter(status=True).order_by('position')
387
+    models = [model.data for model in models]
388
+
389
+    return response(200, data={
390
+        'models': models,
391
+    })