-code nl-47 ol-47"> 47
+class MachineSupportPrebookInfo(CreateUpdateMixin):
48
+    MALE = 1
49
+    FEMALE = 0
50
+
51
+    SEX_TYPE = (
52
+        (MALE, u'男'),
53
+        (FEMALE, u'女'),
54
+    )
55
+
56
+    SLICE0 = 0
57
+    SLICE1 = 1
58
+    SLICE2 = 2
59
+    SLICE3 = 3
60
+
61
+    TIME_SLICE = (
62
+        (SLICE0, u'09:00 - 12:00'),
63
+        (SLICE1, u'12:00 - 14:00'),
64
+        (SLICE2, u'14:00 - 18:00'),
65
+        (SLICE3, u'18:00 - 21:00'),
66
+    )
67
+
68
+    NOT_HANDLE = 0
69
+    HAS_CONTACTED = 1
70
+    HAS_HANDLED = 10
71
+
72
+    HANDLE_STATUS = (
73
+        (NOT_HANDLE, u'未处理'),
74
+        (HAS_CONTACTED, u'已联系'),
75
+        (HAS_HANDLED, u'已处理'),
76
+    )
77
+
78
+    user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
79
+    name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'用户姓名')
80
+    sex = models.IntegerField(_(u'sex'), choices=SEX_TYPE, default=MALE, help_text=u'用户性别')
81
+    phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'用户电话', db_index=True)
82
+    weekday = models.IntegerField(_(u'weekday'), default=0, help_text=u'周几:周日为0', db_index=True)
83
+    timeslice = models.IntegerField(_(u'timeslice'), default=SLICE0, choices=TIME_SLICE, help_text=u'时间段', db_index=True)
84
+    body = models.ForeignKey(MachineBodyInfo, verbose_name=_(u'body'), blank=True, null=True, help_text=u'机身')
85
+    back = models.ForeignKey(MachineBackInfo, verbose_name=_(u'back'), blank=True, null=True, help_text=u'机背')
86
+
87
+    handle_status = models.IntegerField(_(u'handle_status'), choices=HANDLE_STATUS, default=NOT_HANDLE, help_text=u'处理状态')
88
+
89
+    class Meta:
90
+        verbose_name = _(u'machinesupportprebookinfo')
91
+        verbose_name_plural = _(u'machinesupportprebookinfo')
92
+
93
+    def __unicode__(self):
94
+        return unicode(self.pk)

+ 7 - 0
support/tests.py

@@ -0,0 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.test import TestCase
5
+
6
+
7
+# Create your tests here.

+ 57 - 0
support/views.py

@@ -0,0 +1,57 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from logit import logit
5
+
6
+from support.models import MachineBackInfo, MachineBodyInfo, MachineSupportPrebookInfo
7
+from utils.error.errno_utils import MachineStatusCode
8
+from utils.error.response_utils import response
9
+
10
+
11
+@logit
12
+def support_info_api(request):
13
+    bodys = MachineBodyInfo.objects.filter(status=True).order_by('position')
14
+    bodys = [body.data for body in bodys]
15
+
16
+    backs = MachineBackInfo.objects.filter(status=True).order_by('position')
17
+    backs = [back.data for back in backs]
18
+
19
+    return response(200, 'Get Support Info Success', u'获取支持信息成功', {
20
+        'bodys': bodys,
21
+        'backs': backs,
22
+    })
23
+
24
+
25
+@logit
26
+def support_prebook_submit_api(request):
27
+    user_id = request.POST.get('user_id', '')
28
+    name = request.POST.get('name', '')
29
+    sex = int(request.POST.get('sex', 0))
30
+    phone = request.POST.get('phone', '')
31
+    weekday = int(request.POST.get('weekday', 0))
32
+    timeslice = int(request.POST.get('timeslice', 0))
33
+    body = int(request.POST.get('body', 0))
34
+    back = int(request.POST.get('back', 0))
35
+
36
+    try:
37
+        body = MachineBodyInfo.objects.get(pk=body)
38
+    except MachineBodyInfo.DoesNotExist:
39
+        return response(MachineStatusCode.MACHINE_BODY_NOT_FOUND)
40
+
41
+    try:
42
+        back = MachineBackInfo.objects.get(pk=back)
43
+    except MachineBackInfo.DoesNotExist:
44
+        return response(MachineStatusCode.MACHINE_BACK_NOT_FOUND)
45
+
46
+    MachineSupportPrebookInfo.objects.create(
47
+        user_id=user_id,
48
+        name=name,
49
+        sex=sex,
50
+        phone=phone,
51
+        weekday=weekday,
52
+        timeslice=timeslice,
53
+        body=body,
54
+        back=back,
55
+    )
56
+
57
+    return response(200, 'Submit Support Info Success', u'提交支持信息成功')

+ 0 - 0
utils/__init__.py


+ 0 - 0
utils/error/__init__.py


+ 43 - 0
utils/error/errno_utils.py

@@ -0,0 +1,43 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from StatusCode import BaseStatusCode, StatusCodeField
4
+
5
+
6
+class ProfileStatusCode(BaseStatusCode):
7
+    """ 用户相关错误码 4001xx """
8
+    PROFILE_NOT_FOUND = StatusCodeField(400101, 'Profile Not Found', description=u'用户不存在')
9
+    # 手机号
10
+    PHONE_ALREADY_EXISTS = StatusCodeField(400105, 'Phone Already Exists', description=u'手机号已经存在')
11
+
12
+
13
+class MachineStatusCode(BaseStatusCode):
14
+    """ 机器相关错误码 4021xx """
15
+    MACHINE_BODY_NOT_FOUND = StatusCodeField(402101, 'Machine Body Not Found', description=u'机身不存在')
16
+    MACHINE_BACK_NOT_FOUND = StatusCodeField(402102, 'Machine Back Not Found', description=u'机背不存在')
17
+
18
+
19
+class OrderStatusCode(BaseStatusCode):
20
+    """ 订单/支付相关错误码 4040xx """
21
+    UNIFIED_ORDER_FAIL = StatusCodeField(404000, 'Unified Order Fail', description=u'统一下单失败')
22
+    ORDER_NOT_FOUND = StatusCodeField(404001, 'Order Not Found', description=u'订单不存在')
23
+    # 订单支付状态
24
+    ORDER_NOT_PAY = StatusCodeField(404011, 'Order Not Pay', description=u'订单未支付')
25
+    ORDER_PAYING = StatusCodeField(404012, 'Order Paying', description=u'订单支付中')
26
+    ORDER_PAY_FAIL = StatusCodeField(404013, 'Order Pay Fail', description=u'微信支付失败')
27
+    # 通知校验状态
28
+    SIGN_CHECK_FAIL = StatusCodeField(404090, 'Sign Check Fail', description=u'签名校验失败')
29
+    FEE_CHECK_FAIL = StatusCodeField(404091, 'FEE Check Fail', description=u'金额校验失败')
30
+
31
+
32
+class PayStatusCode(BaseStatusCode):
33
+    """ 支付相关错误码 4041xx """
34
+
35
+
36
+class WithdrawStatusCode(BaseStatusCode):
37
+    """ 提现相关错误码 4042xx """
38
+    BALANCE_INSUFFICIENT = StatusCodeField(404200, 'Balance Insufficient', description=u'提现金额不足')
39
+
40
+
41
+class TokenStatusCode(BaseStatusCode):
42
+    """ 票据相关错误码 4090xx """
43
+    TOKEN_NOT_FOUND = StatusCodeField(409901, 'Token Not Found', description=u'票据不存在')

+ 18 - 0
utils/error/response_utils.py

@@ -0,0 +1,18 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.http import JsonResponse
4
+from StatusCode import StatusCodeField
5
+
6
+
7
+def response_data(status_code=200, message=None, description=None, data={}, **kwargs):
8
+    return dict({
9
+        'status': status_code,
10
+        'message': message,
11
+        'description': description,
12
+        'data': data,
13
+    }, **kwargs)
14
+
15
+
16
+def response(status_code=200, message=None, description=None, data={}, **kwargs):
17
+    message, description = (message or status_code.message, description or status_code.description) if isinstance(status_code, StatusCodeField) else (message, description)
18
+    return JsonResponse(response_data(status_code, message, description, data, **kwargs), safe=False)

+ 0 - 0
utils/redis/__init__.py


+ 6 - 0
utils/redis/connect.py

@@ -0,0 +1,6 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.conf import settings
4
+
5
+
6
+r = settings.REDIS_CACHE

+ 1 - 0
utils/redis/rkeys.py

@@ -0,0 +1 @@
1
+# -*- coding: utf-8 -*-

+ 7 - 0
utils/url_utils.py

@@ -0,0 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.conf import settings
4
+
5
+
6
+def upload_file_url(file_path):
7
+    return file_path and ('{}{}'.format(settings.DOMAIN, file_path.url)) or ''

kodo - Gogs: Go Git Service

Geen omschrijving

Brightcells: d28dca92ff CreateUpdateMixin => BaseModelMixin 8 jaren geleden
..
migrations a6195fa70d Add outtake lensman 8 jaren geleden
__init__.py e184e7dd5b add api group_create/group_join 10 jaren geleden
admin.py 3b92e37156 Add field has_watermark for GroupPhotoInfo 8 jaren geleden
grouppage_views.py 840173dc6b Filter photo_id use photo_id field in group_photo_detail 9 jaren geleden
groupuser_views.py 1ecd4f276f Remove status code NO_XX_PERMISSION 9 jaren geleden
lensman_views.py 8665f2ebd4 Fix Bug: ValueError: invalid literal for int() with base 10: '' 8 jaren geleden
models.py d28dca92ff CreateUpdateMixin => BaseModelMixin 8 jaren geleden
serializers.py f72ccb1875 isort import 10 jaren geleden
tests.py fabef63211 set line_length=200 for isort 10 jaren geleden
tourguidegroup_views.py e38c2defaf Upload photo to qiniu 8 jaren geleden
tourguidegroupadmin_views.py 9e4ac4fd3b Add admin_status for GroupUserInfo 9 jaren geleden
tourguidegroupuser_views.py 8483f90163 Return group info for api tgu_group_user_is_joined_api 9 jaren geleden
views.py f3cf68f957 Add PAI2_HOME_WX_API for request.weixin 8 jaren geleden