@@ -2,11 +2,13 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+from django.db import transaction |
|
5 | 6 |
from django_logit import logit |
6 | 7 |
from django_response import response |
8 |
+from paginator import pagination |
|
7 | 9 |
|
8 | 10 |
from logs.models import ComplementCodeLogInfo |
9 |
-from paginator import pagination |
|
11 |
+from utils.error.errno_utils import ComplementCodeStatusCode |
|
10 | 12 |
|
11 | 13 |
|
12 | 14 |
@logit(res=True) |
@@ -50,3 +52,25 @@ def complement_code_list(request): |
||
50 | 52 |
'logs': logs, |
51 | 53 |
'left': left, |
52 | 54 |
}) |
55 |
+ |
|
56 |
+ |
|
57 |
+@transaction.atomic |
|
58 |
+def complement_code_audit(request): |
|
59 |
+ log_id = request.POST.get('log_id', '') |
|
60 |
+ audit_status = int(request.POST.get('audit_status', 0)) # -1 审核不通过, 1 审核通过 |
|
61 |
+ |
|
62 |
+ if audit_status not in [ComplementCodeLogInfo.AUDIT_REFUSED, ComplementCodeLogInfo.AUDIT_PASS]: |
|
63 |
+ return response(ComplementCodeStatusCode.COMPLEMENT_CODE_STATUS_INVALID) |
|
64 |
+ |
|
65 |
+ try: |
|
66 |
+ log = ComplementCodeLogInfo.objects.select_for_update().get(log_id=log_id, status=True) |
|
67 |
+ except ComplementCodeLogInfo.DoesNotExist: |
|
68 |
+ return response(ComplementCodeStatusCode.COMPLEMENT_CODE_NOT_FOUND) |
|
69 |
+ |
|
70 |
+ if log.audit_status != ComplementCodeLogInfo.AUDIT_TODO: |
|
71 |
+ return response(ComplementCodeStatusCode.COMPLEMENT_CODE_HAS_AUDITED) |
|
72 |
+ |
|
73 |
+ log.audit_status = audit_status |
|
74 |
+ log.save() |
|
75 |
+ |
|
76 |
+ return response() |
@@ -242,4 +242,5 @@ urlpatterns += [ |
||
242 | 242 |
urlpatterns += [ |
243 | 243 |
url(r'^complement/code$', complement_views.complement_code, name='complement_code'), |
244 | 244 |
url(r'^complement/code/list$', complement_views.complement_code_list, name='complement_code_list'), |
245 |
+ url(r'^complement/code/audit$', complement_views.complement_code_audit, name='complement_code_audit'), |
|
245 | 246 |
] |
@@ -28,7 +28,7 @@ class MchSearchModelAndCameraLogInfoAdmin(admin.ModelAdmin): |
||
28 | 28 |
|
29 | 29 |
|
30 | 30 |
class ComplementCodeLogInfoAdmin(admin.ModelAdmin): |
31 |
- list_display = ('user_id', 'log_id', 'name', 'phone', 'model_id', 'model_name', 'sn', 'shot_image', 'invoice_image', 'status', 'created_at', 'updated_at') |
|
31 |
+ list_display = ('user_id', 'log_id', 'name', 'phone', 'model_id', 'model_name', 'sn', 'shot_image', 'invoice_image', 'audit_status', 'status', 'created_at', 'updated_at') |
|
32 | 32 |
list_filter = ('model_id', 'status') |
33 | 33 |
|
34 | 34 |
|
@@ -59,6 +59,13 @@ class ProductCouponStatusCode(BaseStatusCode): |
||
59 | 59 |
COUPON_HAS_EXPIRED = StatusCodeField(501411, 'Coupon Has Expired', description=u'优惠券已过期') |
60 | 60 |
|
61 | 61 |
|
62 |
+class ComplementCodeStatusCode(BaseStatusCode): |
|
63 |
+ """ 补码相关错误码 5016xx """ |
|
64 |
+ COMPLEMENT_CODE_NOT_FOUND = StatusCodeField(501601, 'Complement Code Not Found', description=u'补码记录不存在') |
|
65 |
+ COMPLEMENT_CODE_HAS_AUDITED = StatusCodeField(501605, 'Complement Code Has Audited', description=u'补码记录已审核') |
|
66 |
+ COMPLEMENT_CODE_STATUS_INVALID = StatusCodeField(501611, 'Complement Code Status Invalid', description=u'补码记录状态不合法') |
|
67 |
+ |
|
68 |
+ |
|
62 | 69 |
class ProductStatusCode(BaseStatusCode): |
63 | 70 |
""" 产品相关错误码 5020xx """ |
64 | 71 |
PRODUCT_NOT_FOUND = StatusCodeField(502001, 'Product Not Found', description=u'产品不存在') |