增加 consumer_model_list,获取型号列表用以补登申请。

FFIB 4 years ago
parent
commit
2e66887f4a
3 changed files with 36 additions and 2 deletions
  1. 19 0
      api/mch_views.py
  2. 2 1
      api/urls.py
  3. 15 1
      mch/models.py

+ 19 - 0
api/mch_views.py

@@ -487,3 +487,22 @@ def consumer_snlist_api(request):
487 487
     return response(200, 'Get Consumer Submit List Success', u'获取消费者提交列表成功', {
488 488
         'logs': logs,
489 489
     })
490
+
491
+@logit(res=True)
492
+@transaction.atomic
493
+def consumer_model_list(request):
494
+    user_id = request.POST.get('user_id', '')
495
+
496
+    # 校验用户是否存在
497
+    try:
498
+        user = UserInfo.objects.get(user_id=user_id)
499
+    except UserInfo.DoesNotExist:
500
+        return response(UserStatusCode.USER_NOT_FOUND)
501
+    
502
+    #返回型号列表
503
+    models = ModelInfo.objects.filter(shot_type_id__isnull=False, status=True).order_by('-shot_member_name')
504
+    models = [model.consumer_shot_data for model in models]
505
+    
506
+    return response(200, 'Get Model List Success', u'获取型号列表成功', {
507
+        'models': models,
508
+    })

+ 2 - 1
api/urls.py

@@ -56,7 +56,8 @@ urlpatterns += [
56 56
 urlpatterns += [
57 57
     url(r'^consumer_phone$', mch_views.consumer_phone_api, name='consumer_phone_api'),
58 58
     url(r'^consumer_info$', mch_views.consumer_info_api, name='consumer_info_api'),
59
-    url(r'^consumer_snlist$', mch_views.consumer_snlist_api, name='consumer_snlist_api'),
59
+    url(r'^consumer_snlist$', mch_views.consumer_model_list, name='consumer_model_list'),
60
+    url(r'^consumer_model_list$', mch_views.consumer_model_list, name='consumer_model_list')
60 61
 ]
61 62
 
62 63
 urlpatterns += [

+ 15 - 1
mch/models.py

@@ -11,7 +11,6 @@ from TimeConvert import TimeConvert as tc
11 11
 
12 12
 from coupon.models import CouponInfo
13 13
 
14
-
15 14
 class AdministratorInfo(BaseModelMixin):
16 15
     ADMINISTRATOR = 0
17 16
     MAINTENANCE = 1
@@ -260,7 +259,22 @@ class ModelInfo(BaseModelMixin):
260 259
             'shot_image': self.shot_member_image_url,
261 260
             'integral': self.shot_member_integral,
262 261
         }
262
+    
263
+    @property
264
+    def consumer_shot_data(self):
265
+        from member.models import ShotTypeInfo
263 266
 
267
+        shot_type = ShotTypeInfo.objects.get(shot_type_id=self.shot_type_id)
268
+        return {
269
+            'model_id': self.model_id,
270
+            'model_name': self.model_name,
271
+            'model_uni_name': self.model_uni_name,
272
+            'model_full_name': self.model_full_name,
273
+            'model_desc': self.model_descr,
274
+            'shot_type': self.shot_type_id,
275
+            'shot_name': self.shot_member_name,
276
+            'shot_type_name': shot_type.shot_type_name
277
+        }
264 278
 
265 279
 class ModelImageInfo(BaseModelMixin):
266 280
     model_id = models.CharField(_(u'model_id'), max_length=32, blank=True, null=True, help_text=u'型号唯一标识', db_index=True)