]
urlpatterns += [
+ url(r'^sr/list$', sr_views.sr_list, name='sr_list'),
+]
+
+urlpatterns += [
url(r'^screen/admin/loginqr$', screen_views.screen_admin_loginqr, name='screen_admin_loginqr'),
url(r'^screen/admin/loginrst$', screen_views.screen_admin_loginrst, name='screen_admin_loginrst'),
]
@@ -298,3 +303,13 @@ urlpatterns += [
urlpatterns += [
url(r'^refresh/phone$', refresh_views.phone, name='phone'),
]
+
+urlpatterns += [
+ url(r'^sr/submit', sales_views.sr_submit_api, name='sr_submit_api'),
+ url(r'^sr/distributor/list$', sales_views.sr_distributor_list, name='sr_distributor_list'),
+ url(r'^sr/distributor/tj$', sales_views.sr_distributor_tj, name='sr_distributor_tj'),
+]
+
+urlpatterns += [
+ url(r'^supersr/sr/tj$', sales_views.supersr_sr_tj, name='supersr_sr_tj'),
+]
@@ -65,6 +65,7 @@ INSTALLED_APPS = ( |
||
65 | 65 |
'pay', |
66 | 66 |
'photo', |
67 | 67 |
'pre', |
68 |
+ 'sales', |
|
68 | 69 |
'server', |
69 | 70 |
'shells', |
70 | 71 |
'statistic', |
@@ -411,6 +412,8 @@ KODO_CLERK_AUTH_URL = 'http://pai.ai/w/o?r=http%3A%2F%2Fkodo.xfoto.com.cn%2Fp%2F |
||
411 | 412 |
KODO_SCREEN_AUTH_URL = 'http://pai.ai/w/o?r=http%3A%2F%2Fkodo.xfoto.com.cn%2Fp%2Fscreen%2Fadmin%2Foauth%3Fbrand_id%3D{0}' |
412 | 413 |
KODO_SCREEN_LOGIN_URL = 'http://pai.ai/w/o?s=snsapi_base&r=http%3A%2F%2Fkodo.xfoto.com.cn%2Fp%2Fscreen%2Fadmin%2Flogin%3Fbrand_id%3D{0}%26token%3D{1}' |
413 | 414 |
|
415 |
+KODO_SUPERSR_AUTH_URL = 'http://pai.ai/w/o?r=http%3A%2F%2Fkodo.xfoto.com.cn%2Fp%2Fsupersr%2Foauth%3Fbrand_id%3D{0}' |
|
416 |
+ |
|
414 | 417 |
# 经纬度 |
415 | 418 |
GIS_2_ADMINISTRATIVE_DIVISION = 'http://116.196.105.215:1234/gis?auth_user=freevip&latitude={0}&longitude={1}' |
416 | 419 |
PHONE_2_ADMINISTRATIVE_DIVISION = 'https://www.baifubao.com/callback?cmd=1059&callback=phone&phone={0}' |
@@ -173,6 +173,8 @@ class ModelInfo(BaseModelMixin): |
||
173 | 173 |
|
174 | 174 |
display = models.BooleanField(_(u'display'), default=True, help_text=_(u'Display'), db_index=True) |
175 | 175 |
|
176 |
+ is_important = models.BooleanField(_(u'is_important'), default=True, help_text=_(u'是否重要型号'), db_index=True) |
|
177 |
+ |
|
176 | 178 |
class Meta: |
177 | 179 |
verbose_name = _(u'型号信息') |
178 | 180 |
verbose_name_plural = _(u'型号信息') |
@@ -282,6 +284,7 @@ class ModelInfo(BaseModelMixin): |
||
282 | 284 |
'model_imgs2': self.images2, |
283 | 285 |
'factory_yuan': self.factory_yuan, |
284 | 286 |
'integral': self.integral, |
287 |
+ 'is_important': self.is_important, |
|
285 | 288 |
} |
286 | 289 |
|
287 | 290 |
fulldata = admindata |
@@ -327,6 +330,8 @@ class DistributorInfo(BaseModelMixin): |
||
327 | 330 |
distributor_province_code = models.CharField(_(u'distributor_province_code'), max_length=6, blank=True, null=True, help_text=u'经销商所在省份编码') |
328 | 331 |
distributor_province_name = models.CharField(_(u'distributor_province_name'), max_length=3, choices=ProvinceShortModelMixin.PROVINCE_NAME_TUPLE, default=ProvinceShortModelMixin.PROVINCE_DEFAULT_NAME, blank=True, null=True, help_text=u'经销商所在省份名称') |
329 | 332 |
|
333 |
+ sr_id = models.CharField(_(u'sr_id'), max_length=32, blank=True, null=True, help_text=u'销售担当唯一标识', db_index=True) |
|
334 |
+ |
|
330 | 335 |
position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
331 | 336 |
|
332 | 337 |
class Meta: |
@@ -354,6 +359,7 @@ class DistributorInfo(BaseModelMixin): |
||
354 | 359 |
'distributor_descr': self.distributor_descr, |
355 | 360 |
'province_code': self.distributor_province_code, |
356 | 361 |
'province_name': self.distributor_province_name, |
362 |
+ 'sr_id': self.sr_id, |
|
357 | 363 |
} |
358 | 364 |
|
359 | 365 |
|
@@ -0,0 +1,31 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+from django.conf import settings |
|
4 |
+from django_logit import logit |
|
5 |
+from json_render import json_render |
|
6 |
+ |
|
7 |
+from sales.models import SalesResponsibilityInfo |
|
8 |
+ |
|
9 |
+ |
|
10 |
+@logit |
|
11 |
+def supersr_oauthqr(request): |
|
12 |
+ brand_id = request.GET.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
|
13 |
+ |
|
14 |
+ return json_render(request, 'page/supersr_oauth_qrcode.html', unjsondumpsdict={ |
|
15 |
+ 'qr': settings.KODO_SUPERSR_AUTH_URL.format(brand_id) |
|
16 |
+ }) |
|
17 |
+ |
|
18 |
+ |
|
19 |
+@logit |
|
20 |
+def supersr_oauth(request): |
|
21 |
+ brand_id = request.GET.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
|
22 |
+ unionid = request.GET.get('unionid', '') |
|
23 |
+ |
|
24 |
+ SalesResponsibilityInfo.objects.update_or_create(brand_id=brand_id, unionid=unionid, defaults={ |
|
25 |
+ 'user_status': SalesResponsibilityInfo.ACTIVATED, |
|
26 |
+ 'is_auth': True, |
|
27 |
+ 'is_super': True, |
|
28 |
+ }) |
|
29 |
+ |
|
30 |
+ return json_render(request, 'page/supersr_oauth_success.html', unjsondumpsdict={ |
|
31 |
+ }) |
@@ -0,0 +1,64 @@ |
||
1 |
+{% load staticfiles %} |
|
2 |
+ |
|
3 |
+<!DOCTYPE html> |
|
4 |
+<html lang="zh-CN"> |
|
5 |
+ <head> |
|
6 |
+ <meta charset="utf-8"> |
|
7 |
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|
8 |
+ <meta name="format-detection" content="telephone=no,email=no,address=no"> |
|
9 |
+ <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"> |
|
10 |
+ <title>超级销售担当授权二维码</title> |
|
11 |
+ |
|
12 |
+ <link href="//res.wx.qq.com/open/libs/weui/0.4.3/weui.min.css" rel="stylesheet" type="text/css" /> |
|
13 |
+ |
|
14 |
+ <style> |
|
15 |
+ input:required:invalid { |
|
16 |
+ color: #E64340; |
|
17 |
+ } |
|
18 |
+ input:required:valid { |
|
19 |
+ color: rgb(0, 0, 0); |
|
20 |
+ } |
|
21 |
+ .hidden { |
|
22 |
+ display: none; |
|
23 |
+ } |
|
24 |
+ .qr { |
|
25 |
+ position: fixed; |
|
26 |
+ left: 50%; |
|
27 |
+ top: 50%; |
|
28 |
+ margin-left: -100px; |
|
29 |
+ margin-top: -100px; |
|
30 |
+ padding: 5px 5px 0 5px; |
|
31 |
+ border: 1px solid #000; |
|
32 |
+ border-radius: 5px; |
|
33 |
+ } |
|
34 |
+ </style> |
|
35 |
+ </head> |
|
36 |
+ <body> |
|
37 |
+ <div class="container" > |
|
38 |
+ <img id="qr_logo" class="hidden" src="{% static 'kodo/img/paiai_96_96.png' %}"> |
|
39 |
+ <div id="qr" class="qr"></div> |
|
40 |
+ </div> |
|
41 |
+ |
|
42 |
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
|
43 |
+ <script src="//cdnjs.cloudflare.com/ajax/libs/lrsjng.jquery-qrcode/0.14.0/jquery-qrcode.min.js"></script> |
|
44 |
+ <script> |
|
45 |
+ $("#qr").empty().qrcode({ |
|
46 |
+ render: 'canvas', |
|
47 |
+ mode: 0, |
|
48 |
+ text: '{{ qr }}' |
|
49 |
+ }); |
|
50 |
+ </script> |
|
51 |
+ <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> |
|
52 |
+ <script type="text/javascript" src="{% static 'kodo/js/jswe-0.0.4.js' %}"></script> |
|
53 |
+ <script> |
|
54 |
+ V.initWxData({ |
|
55 |
+ imgUrl: "http://pai.ai/static/kodo/img/paiai_96_96.png", |
|
56 |
+ link: 'http://pai.ai/w/o?r=http%3A%2F%2Fpai.ai%2Fp%2Floginqr', |
|
57 |
+ desc: "授权登录", |
|
58 |
+ title: "授权登录", |
|
59 |
+ timeLine: "" |
|
60 |
+ }, true); |
|
61 |
+ V.hideOptionMenu(); |
|
62 |
+ </script> |
|
63 |
+ </body> |
|
64 |
+</html> |
@@ -0,0 +1,13 @@ |
||
1 |
+<!DOCTYPE html> |
|
2 |
+<html lang="en"> |
|
3 |
+<head> |
|
4 |
+ <meta charset="UTF-8"> |
|
5 |
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
6 |
+ <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
|
7 |
+ <title>授权成功</title> |
|
8 |
+</head> |
|
9 |
+<body> |
|
10 |
+ <div class="" style="text-align:center;margin-top:100px;font-size:25px;">授权成功</div> |
|
11 |
+ <div class="" style="text-align:center;font-size:15px;">您已成为超级销售担当</div> |
|
12 |
+</body> |
|
13 |
+</html> |
@@ -4,7 +4,7 @@ from django.conf.urls import url |
||
4 | 4 |
|
5 | 5 |
from account import tourguide_views |
6 | 6 |
from group import lensman_views |
7 |
-from page import info_views, oauth_views, page_views, preauth_views, sale_views, screen_views |
|
7 |
+from page import info_views, oauth_views, page_views, preauth_views, sale_views, screen_views, supersr_views |
|
8 | 8 |
|
9 | 9 |
|
10 | 10 |
urlpatterns = [ |
@@ -45,3 +45,9 @@ urlpatterns += [ |
||
45 | 45 |
url(r'^screen/admin/oauth$', screen_views.screen_admin_oauth, name='screen_admin_oauth'), |
46 | 46 |
url(r'^screen/admin/login$', screen_views.screen_admin_login, name='screen_admin_login'), |
47 | 47 |
] |
48 |
+ |
|
49 |
+# 超级销售担当 |
|
50 |
+urlpatterns += [ |
|
51 |
+ url(r'^supersr$', supersr_views.supersr_oauthqr, name='supersr_oauthqr'), # 授权二维码 |
|
52 |
+ url(r'^supersr/oauth$', supersr_views.supersr_oauth, name='supersr_oauth'), # 授权成功 |
|
53 |
+] |
@@ -0,0 +1,6 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.contrib import admin |
|
5 |
+ |
|
6 |
+# Register your models here. |
@@ -0,0 +1,8 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.apps import AppConfig |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class SalesConfig(AppConfig): |
|
8 |
+ name = 'sales' |
@@ -0,0 +1,145 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+from django.db import models |
|
4 |
+from django.utils.translation import ugettext_lazy as _ |
|
5 |
+from django_models_ext import BaseModelMixin, upload_file_url, upload_path |
|
6 |
+from shortuuidfield import ShortUUIDField |
|
7 |
+ |
|
8 |
+ |
|
9 |
+class SalesResponsibilityInfo(BaseModelMixin): |
|
10 |
+ REFUSED = -1 |
|
11 |
+ UNVERIFIED = 0 |
|
12 |
+ ACTIVATED = 1 |
|
13 |
+ DISABLED = 2 |
|
14 |
+ DELETED = 3 |
|
15 |
+ ASSIGN = 10 |
|
16 |
+ |
|
17 |
+ USER_STATUS_TUPLE = ( |
|
18 |
+ (REFUSED, u'已拒绝'), |
|
19 |
+ (UNVERIFIED, u'未验证'), |
|
20 |
+ (ACTIVATED, u'已激活'), |
|
21 |
+ (DISABLED, u'已禁用'), |
|
22 |
+ (DELETED, u'已删除'), |
|
23 |
+ (ASSIGN, u'已分配'), |
|
24 |
+ ) |
|
25 |
+ |
|
26 |
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
|
27 |
+ brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
|
28 |
+ |
|
29 |
+ sr_id = ShortUUIDField(_(u'sr_id'), max_length=32, blank=True, null=True, help_text=u'销售担当唯一标识', db_index=True, unique=True) |
|
30 |
+ |
|
31 |
+ user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) |
|
32 |
+ unionid = models.CharField(_(u'unionid'), max_length=32, blank=True, null=True, help_text=u'微信 UnionID', db_index=True) |
|
33 |
+ openid = models.CharField(_(u'openid'), max_length=32, blank=True, null=True, help_text=u'微信 OpenID', db_index=True) |
|
34 |
+ |
|
35 |
+ name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'销售担当姓名') |
|
36 |
+ phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'销售担当联系电话') |
|
37 |
+ |
|
38 |
+ user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS_TUPLE, default=UNVERIFIED, help_text=u'用户状态', db_index=True) |
|
39 |
+ refused_reason = models.TextField(_(u'refused_reason'), blank=True, null=True, help_text=u'审核拒绝原因') |
|
40 |
+ |
|
41 |
+ is_auth = models.BooleanField(_(u'is_auth'), default=False, help_text=_(u'是否已授权'), db_index=True) |
|
42 |
+ |
|
43 |
+ is_super = models.BooleanField(_(u'is_super'), default=True, help_text=_(u'是否超级销售担当'), db_index=True) |
|
44 |
+ |
|
45 |
+ class Meta: |
|
46 |
+ verbose_name = _(u'销售担当信息') |
|
47 |
+ verbose_name_plural = _(u'销售担当信息') |
|
48 |
+ |
|
49 |
+ unique_together = ( |
|
50 |
+ ('brand_id', 'sr_id'), |
|
51 |
+ ) |
|
52 |
+ |
|
53 |
+ def __unicode__(self): |
|
54 |
+ return u'{}-{}'.format(self.name, self.phone) |
|
55 |
+ |
|
56 |
+ @property |
|
57 |
+ def admindata(self): |
|
58 |
+ return { |
|
59 |
+ 'brand_id': self.brand_id, |
|
60 |
+ 'brand_name': self.brand_name, |
|
61 |
+ 'sr_id': self.sr_id, |
|
62 |
+ 'name': self.name, |
|
63 |
+ 'phone': self.phone, |
|
64 |
+ 'status': self.user_status, |
|
65 |
+ 'refused_reason': self.refused_reason, |
|
66 |
+ 'is_auth': self.is_auth, |
|
67 |
+ } |
|
68 |
+ |
|
69 |
+ data = admindata |
|
70 |
+ |
|
71 |
+ |
|
72 |
+class SalesResponsibilityInfoModelsSaleStatisticInfo(BaseModelMixin): |
|
73 |
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
|
74 |
+ |
|
75 |
+ # 经销商 |
|
76 |
+ distributor_id = models.CharField(_(u'distributor_id'), max_length=32, help_text=u'经销商唯一标识', db_index=True) |
|
77 |
+ distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称') |
|
78 |
+ |
|
79 |
+ # 型号 |
|
80 |
+ model_id = models.CharField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True) |
|
81 |
+ model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称', db_index=True) |
|
82 |
+ is_important = models.BooleanField(_(u'is_important'), default=True, help_text=_(u'是否重要型号'), db_index=True) |
|
83 |
+ |
|
84 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
85 |
+ |
|
86 |
+ today_num = models.IntegerField(_(u'today_num'), default=0, help_text=u'支数(今日)') |
|
87 |
+ yesterday_num = models.IntegerField(_(u'yesterday_num'), default=0, help_text=u'支数(昨日)') |
|
88 |
+ current_month = models.IntegerField(_(u'current_month'), default=0, help_text=u'支数(本月)') |
|
89 |
+ last_month = models.IntegerField(_(u'last_month'), default=0, help_text=u'支数(上月)') |
|
90 |
+ |
|
91 |
+ position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
|
92 |
+ |
|
93 |
+ class Meta: |
|
94 |
+ verbose_name = _(u'[销售担当]型号销量统计') |
|
95 |
+ verbose_name_plural = _(u'[销售担当]型号销量统计') |
|
96 |
+ |
|
97 |
+ def __unicode__(self): |
|
98 |
+ return unicode(self.pk) |
|
99 |
+ |
|
100 |
+ @property |
|
101 |
+ def data(self): |
|
102 |
+ return { |
|
103 |
+ 'model_id': self.model_id, |
|
104 |
+ 'model_name': self.model_name, |
|
105 |
+ 'is_important': self.is_important, |
|
106 |
+ 'today_num': self.today_num, |
|
107 |
+ 'yesterday_num': self.yesterday_num, |
|
108 |
+ 'current_month': self.current_month, |
|
109 |
+ 'last_month': self.last_month, |
|
110 |
+ } |
|
111 |
+ |
|
112 |
+ |
|
113 |
+class SuperSalesResponsibilityInfoModelsSaleStatisticInfo(BaseModelMixin): |
|
114 |
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
|
115 |
+ |
|
116 |
+ # 销售担当 |
|
117 |
+ sr_id = models.CharField(_(u'sr_id'), max_length=32, help_text=u'销售担当唯一标识', db_index=True) |
|
118 |
+ sr_name = models.CharField(_(u'sr_name'), max_length=255, blank=True, null=True, help_text=u'销售担当名称') |
|
119 |
+ |
|
120 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
121 |
+ |
|
122 |
+ today_num = models.IntegerField(_(u'today_num'), default=0, help_text=u'支数(今日)') |
|
123 |
+ yesterday_num = models.IntegerField(_(u'yesterday_num'), default=0, help_text=u'支数(昨日)') |
|
124 |
+ current_month = models.IntegerField(_(u'current_month'), default=0, help_text=u'支数(本月)') |
|
125 |
+ last_month = models.IntegerField(_(u'last_month'), default=0, help_text=u'支数(上月)') |
|
126 |
+ |
|
127 |
+ position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
|
128 |
+ |
|
129 |
+ class Meta: |
|
130 |
+ verbose_name = _(u'[超级销售担当]销售担当销量统计') |
|
131 |
+ verbose_name_plural = _(u'[超级销售担当]销售担当销量统计') |
|
132 |
+ |
|
133 |
+ def __unicode__(self): |
|
134 |
+ return unicode(self.pk) |
|
135 |
+ |
|
136 |
+ @property |
|
137 |
+ def data(self): |
|
138 |
+ return { |
|
139 |
+ 'sr_id': self.sr_id, |
|
140 |
+ 'sr_name': self.sr_name, |
|
141 |
+ 'today_num': self.today_num, |
|
142 |
+ 'yesterday_num': self.yesterday_num, |
|
143 |
+ 'current_month': self.current_month, |
|
144 |
+ 'last_month': self.last_month, |
|
145 |
+ } |
@@ -0,0 +1,6 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.test import TestCase |
|
5 |
+ |
|
6 |
+# Create your tests here. |
@@ -0,0 +1,82 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+from __future__ import division |
|
4 |
+ |
|
5 |
+from django.conf import settings |
|
6 |
+from django_logit import logit |
|
7 |
+from django_response import response |
|
8 |
+from TimeConvert import TimeConvert as tc |
|
9 |
+ |
|
10 |
+from mch.models import DistributorInfo |
|
11 |
+from sales.models import SalesResponsibilityInfo, SalesResponsibilityInfoModelsSaleStatisticInfo, SuperSalesResponsibilityInfoModelsSaleStatisticInfo |
|
12 |
+from utils.error.errno_utils import SalesResponsibilityStatusCode |
|
13 |
+ |
|
14 |
+ |
|
15 |
+@logit |
|
16 |
+def sr_submit_api(request): |
|
17 |
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
|
18 |
+ user_id = request.POST.get('user_id', '') |
|
19 |
+ unionid = request.POST.get('unionid', '') |
|
20 |
+ openid = request.POST.get('openid', '') |
|
21 |
+ phone = request.POST.get('phone', '') |
|
22 |
+ |
|
23 |
+ if SalesResponsibilityInfo.objects.filter(brand_id=brand_id, phone=phone).exclude(user_id=user_id).exists(): |
|
24 |
+ return response(SalesResponsibilityStatusCode.SR_PHONE_ALREADY_EXISTS) |
|
25 |
+ |
|
26 |
+ SalesResponsibilityInfo.objects.update_or_create(brand_id=brand_id, user_id=user_id, defaults={ |
|
27 |
+ 'name': request.POST.get('name', ''), |
|
28 |
+ 'phone': request.POST.get('phone', ''), |
|
29 |
+ 'unionid': unionid, |
|
30 |
+ 'openid': openid, |
|
31 |
+ 'user_status': SalesResponsibilityInfo.UNVERIFIED, |
|
32 |
+ 'status': True, |
|
33 |
+ }) |
|
34 |
+ |
|
35 |
+ return response(200, 'Submit Success', u'提交成功', {}) |
|
36 |
+ |
|
37 |
+ |
|
38 |
+@logit |
|
39 |
+def sr_distributor_list(request): |
|
40 |
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
|
41 |
+ user_id = request.POST.get('user_id', '') |
|
42 |
+ sr_id = request.POST.get('sr_id', '') |
|
43 |
+ |
|
44 |
+ # if not sr_id: |
|
45 |
+ # try: |
|
46 |
+ # sr = SalesResponsibilityInfo.objects.get(brand_id=brand_id, user_id=user_id) |
|
47 |
+ # except SalesResponsibilityInfo.DoesNotExist: |
|
48 |
+ # return response(SalesResponsibilityStatusCode.SR_NOT_FOUND) |
|
49 |
+ # sr_id = sr.sr_id |
|
50 |
+ |
|
51 |
+ distributors = DistributorInfo.objects.filter(brand_id=brand_id, sr_id=sr_id, status=True) |
|
52 |
+ distributors = [d.admindata for d in distributors] |
|
53 |
+ |
|
54 |
+ return response(data={ |
|
55 |
+ 'distributors': distributors, |
|
56 |
+ }) |
|
57 |
+ |
|
58 |
+ |
|
59 |
+@logit |
|
60 |
+def sr_distributor_tj(request): |
|
61 |
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
|
62 |
+ distributor_id = request.POST.get('distributor_id', '') |
|
63 |
+ |
|
64 |
+ sales = SalesResponsibilityInfoModelsSaleStatisticInfo.objects.filter(brand_id=brand_id, distributor_id=distributor_id, ymd=tc.local_string(format='%Y%m%d'), status=True).order_by('-is_important') |
|
65 |
+ sales = [sale.data for sale in sales] |
|
66 |
+ |
|
67 |
+ return response(data={ |
|
68 |
+ 'sales': sales, |
|
69 |
+ }) |
|
70 |
+ |
|
71 |
+ |
|
72 |
+@logit |
|
73 |
+def supersr_sr_tj(request): |
|
74 |
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
|
75 |
+ sr_id = request.POST.get('sr_id', '') |
|
76 |
+ |
|
77 |
+ sales = SuperSalesResponsibilityInfoModelsSaleStatisticInfo.objects.filter(brand_id=brand_id, sr_id=sr_id, ymd=tc.local_string(format='%Y%m%d'), status=True).order_by('-is_important') |
|
78 |
+ sales = [sale.data for sale in sales] |
|
79 |
+ |
|
80 |
+ return response(data={ |
|
81 |
+ 'sales': sales, |
|
82 |
+ }) |
@@ -16,6 +16,13 @@ class SaleclerkStatusCode(BaseStatusCode): |
||
16 | 16 |
DUPLICATE_SUBMIT = StatusCodeField(500199, 'Duplicate Submit', description=u'重复提交') |
17 | 17 |
|
18 | 18 |
|
19 |
+class SalesResponsibilityStatusCode(BaseStatusCode): |
|
20 |
+ """ 销售担当相关错误码 5002xx """ |
|
21 |
+ SR_NOT_FOUND = StatusCodeField(500201, 'SR Not Found', description=u'销售担当不存在') |
|
22 |
+ # 手机号 |
|
23 |
+ SR_PHONE_ALREADY_EXISTS = StatusCodeField(500205, 'SR Phone Already Exists', description=u'手机号已经存在') |
|
24 |
+ |
|
25 |
+ |
|
19 | 26 |
class ProductBrandStatusCode(BaseStatusCode): |
20 | 27 |
""" 品牌相关错误码 5010xx """ |
21 | 28 |
BRAND_NOT_FOUND = StatusCodeField(501001, 'Brand Not Found', description=u'品牌不存在') |