@@ -95,8 +95,9 @@ def bmd_infos(request): |
||
95 | 95 |
brands = BrandInfo.objects.filter(brand_id=operator.brand_id, status=True).order_by('position') |
96 | 96 |
brands = [brand.data for brand in brands] |
97 | 97 |
|
98 |
- models = ModelInfo.objects.filter(brand_id=operator.brand_id, status=True).order_by('position') |
|
99 |
- models = [model.data for model in models] |
|
98 |
+ tmpmodels = ModelInfo.objects.filter(brand_id=operator.brand_id, display=True, status=True).order_by('position') |
|
99 |
+ models = [model.data for model in tmpmodels] |
|
100 |
+ jancodes = {model.jancode: model.data for model in tmpmodels} |
|
100 | 101 |
|
101 | 102 |
distributors = DistributorInfo.objects.filter(brand_id=operator.brand_id, status=True).order_by('position') |
102 | 103 |
distributors = [distributor.data for distributor in distributors] |
@@ -105,6 +106,7 @@ def bmd_infos(request): |
||
105 | 106 |
'optor_id': operator.operator_id, |
106 | 107 |
'brands': brands, |
107 | 108 |
'models': models, |
109 |
+ 'jancodes': jancodes, |
|
108 | 110 |
'distributors': distributors, |
109 | 111 |
}) |
110 | 112 |
|
@@ -13,12 +13,17 @@ from utils.error.errno_utils import AdministratorStatusCode, ProductModelStatusC |
||
13 | 13 |
|
14 | 14 |
@logit |
15 | 15 |
def model_add(request): |
16 |
+ jancode = request.POST.get('jancode', '') |
|
16 | 17 |
model_name = request.POST.get('model_name', '') |
18 |
+ model_uni_name = request.POST.get('model_uni_name', '') |
|
17 | 19 |
model_full_name = request.POST.get('model_full_name', '') |
18 | 20 |
image_path = request.POST.get('image_path', '') |
19 | 21 |
factory_yuan = request.POST.get('factory_yuan', 1000) |
20 | 22 |
integral = int(request.POST.get('integral', 100)) |
21 | 23 |
|
24 |
+ category = request.POST.get('category', '') |
|
25 |
+ warehouse = request.POST.get('warehouse', '') |
|
26 |
+ |
|
22 | 27 |
admin_id = request.session.get('admin_id') |
23 | 28 |
|
24 | 29 |
try: |
@@ -28,8 +33,12 @@ def model_add(request): |
||
28 | 33 |
|
29 | 34 |
ModelInfo.objects.create( |
30 | 35 |
brand_id=administrator.brand_id, |
36 |
+ jancode=jancode, |
|
31 | 37 |
model_name=model_name, |
38 |
+ model_uni_name=model_uni_name, |
|
32 | 39 |
model_full_name=model_full_name, |
40 |
+ category=category, |
|
41 |
+ warehouse=warehouse, |
|
33 | 42 |
image=image_path, |
34 | 43 |
factory_yuan=factory_yuan, |
35 | 44 |
factory_fee=monetary.Yuan2Fen(factory_yuan), |
@@ -63,13 +72,18 @@ def model_delete(request): |
||
63 | 72 |
|
64 | 73 |
@logit |
65 | 74 |
def model_update(request): |
75 |
+ jancode = request.POST.get('jancode', '') |
|
66 | 76 |
model_id = request.POST.get('model_id', '') |
67 | 77 |
model_name = request.POST.get('model_name', '') |
78 |
+ model_uni_name = request.POST.get('model_uni_name', '') |
|
68 | 79 |
model_full_name = request.POST.get('model_full_name', '') |
69 | 80 |
image_path = request.POST.get('image_path', '') |
70 | 81 |
factory_yuan = request.POST.get('factory_yuan', 1000) |
71 | 82 |
integral = int(request.POST.get('integral', 100)) |
72 | 83 |
|
84 |
+ category = request.POST.get('category', '') |
|
85 |
+ warehouse = request.POST.get('warehouse', '') |
|
86 |
+ |
|
73 | 87 |
admin_id = request.session.get('admin_id') |
74 | 88 |
|
75 | 89 |
try: |
@@ -82,10 +96,18 @@ def model_update(request): |
||
82 | 96 |
except ModelInfo.DoesNotExist: |
83 | 97 |
return response(ProductModelStatusCode.MODEL_NOT_FOUND) |
84 | 98 |
|
99 |
+ if jancode: |
|
100 |
+ modelObj.jancode = jancode |
|
85 | 101 |
if model_name: |
86 | 102 |
modelObj.model_name = model_name |
103 |
+ if model_uni_name: |
|
104 |
+ modelObj.model_uni_name = model_uni_name |
|
87 | 105 |
if model_full_name: |
88 | 106 |
modelObj.model_full_name = model_full_name |
107 |
+ if category: |
|
108 |
+ modelObj.category = category |
|
109 |
+ if warehouse: |
|
110 |
+ modelObj.warehouse = warehouse |
|
89 | 111 |
if image_path: |
90 | 112 |
modelObj.distributor_province_name = image_path |
91 | 113 |
if factory_yuan: |
@@ -194,9 +194,9 @@ urlpatterns += [ |
||
194 | 194 |
] |
195 | 195 |
|
196 | 196 |
urlpatterns += [ |
197 |
- url(r'^brands$', mch_views.brands_list, name='brands_list'), |
|
198 |
- url(r'^models$', mch_views.models_list, name='models_list'), |
|
199 |
- url(r'^distributors$', mch_views.distributors_list, name='distributors_list'), |
|
197 |
+ # url(r'^brands$', mch_views.brands_list, name='brands_list'), |
|
198 |
+ # url(r'^models$', mch_views.models_list, name='models_list'), |
|
199 |
+ # url(r'^distributors$', mch_views.distributors_list, name='distributors_list'), |
|
200 | 200 |
url(r'^infos$', mch_views.bmd_infos, name='bmd_infos'), |
201 | 201 |
|
202 | 202 |
url(r'^log/upload$', file_views.file_upload, name='log_upload'), |
@@ -381,6 +381,7 @@ DEBUG_STATISTIC_DATA_FLAG = False |
||
381 | 381 |
|
382 | 382 |
KODO_DEFAULT_BRAND_PK = 0 |
383 | 383 |
KODO_DEFAULT_BRAND_ID = '' |
384 |
+KODO_DEFAULT_BRAND_NAME = '' |
|
384 | 385 |
KODO_DEFAULT_BRAND_DOMAIN = '' |
385 | 386 |
|
386 | 387 |
KODO_CLERK_AUTH_URL = 'http://pai.ai/w/o?r=http%3A%2F%2Fkodo.xfoto.com.cn%2Fp%2Fclerk%3Fbrand_id%3D{0}' |
@@ -63,10 +63,10 @@ class BrandInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
||
63 | 63 |
|
64 | 64 |
|
65 | 65 |
class ModelInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
66 |
- list_display = ('brand_id', 'brand_name', 'model_id', 'model_name', 'model_full_name', 'model_descr', 'image', 'url', 'factory_yuan', 'integral', 'position', 'status', 'created_at', 'updated_at') |
|
67 |
- list_filter = ('brand_name', 'status') |
|
66 |
+ list_display = ('brand_id', 'brand_name', 'jancode', 'model_id', 'model_uni_name', 'model_name', 'model_full_name', 'model_descr', 'category', 'warehouse', 'image', 'url', 'factory_yuan', 'integral', 'position', 'display', 'status', 'created_at', 'updated_at') |
|
67 |
+ list_filter = ('brand_name', 'category', 'warehouse', 'display', 'status') |
|
68 | 68 |
readonly_fields = ('brand_name', 'factory_fee') |
69 |
- search_fields = ('brand_id', 'brand_name', 'model_id', 'model_name', 'model_full_name', 'model_descr') |
|
69 |
+ search_fields = ('brand_id', 'brand_name', 'jancode', 'model_id', 'model_uni_name', 'model_name', 'model_full_name', 'model_descr', 'category', 'warehouse') |
|
70 | 70 |
|
71 | 71 |
def save_model(self, request, obj, form, change): |
72 | 72 |
obj.brand_id = strip(obj.brand_id) |
@@ -0,0 +1,45 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.15 on 2018-08-25 20:48 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('mch', '0022_auto_20180522_1355'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='modelinfo', |
|
17 |
+ name='category', |
|
18 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u578b\u53f7\u7c7b\u522b', max_length=32, null=True, verbose_name='category'), |
|
19 |
+ ), |
|
20 |
+ migrations.AddField( |
|
21 |
+ model_name='modelinfo', |
|
22 |
+ name='display', |
|
23 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Display', verbose_name='display'), |
|
24 |
+ ), |
|
25 |
+ migrations.AddField( |
|
26 |
+ model_name='modelinfo', |
|
27 |
+ name='jancode', |
|
28 |
+ field=models.CharField(blank=True, db_index=True, help_text='JAN_CODE', max_length=16, null=True, verbose_name='jancode'), |
|
29 |
+ ), |
|
30 |
+ migrations.AddField( |
|
31 |
+ model_name='modelinfo', |
|
32 |
+ name='model_uni_name', |
|
33 |
+ field=models.CharField(blank=True, help_text='\u578b\u53f7\u7edf\u4e00\u540d\u79f0', max_length=32, null=True, verbose_name='model_uni_name'), |
|
34 |
+ ), |
|
35 |
+ migrations.AddField( |
|
36 |
+ model_name='modelinfo', |
|
37 |
+ name='warehouse', |
|
38 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u6240\u5c5e\u4ed3\u5e93', max_length=32, null=True, verbose_name='warehouse'), |
|
39 |
+ ), |
|
40 |
+ migrations.AlterField( |
|
41 |
+ model_name='modelinfo', |
|
42 |
+ name='model_name', |
|
43 |
+ field=models.CharField(blank=True, help_text='\u578b\u53f7\u540d\u79f0', max_length=32, null=True, verbose_name='model_name'), |
|
44 |
+ ), |
|
45 |
+ ] |
@@ -122,11 +122,17 @@ class ModelInfo(BaseModelMixin): |
||
122 | 122 |
brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
123 | 123 |
brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
124 | 124 |
|
125 |
+ jancode = models.CharField(_(u'jancode'), max_length=16, blank=True, null=True, help_text=u'JAN_CODE', db_index=True) |
|
126 |
+ |
|
125 | 127 |
model_id = ShortUUIDField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True, unique=True) |
126 |
- model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称') |
|
128 |
+ model_name = models.CharField(_(u'model_name'), max_length=32, blank=True, null=True, help_text=u'型号名称') |
|
129 |
+ model_uni_name = models.CharField(_(u'model_uni_name'), max_length=32, blank=True, null=True, help_text=u'型号统一名称') |
|
127 | 130 |
model_full_name = models.CharField(_(u'model_full_name'), max_length=255, blank=True, null=True, help_text=u'型号全名称') |
128 | 131 |
model_descr = models.TextField(_(u'model_descr'), max_length=255, blank=True, null=True, help_text=u'型号描述') |
129 | 132 |
|
133 |
+ category = models.CharField(_(u'category'), max_length=32, blank=True, null=True, help_text=u'型号类别', db_index=True) |
|
134 |
+ warehouse = models.CharField(_(u'warehouse'), max_length=32, blank=True, null=True, help_text=u'所属仓库', db_index=True) |
|
135 |
+ |
|
130 | 136 |
image = models.ImageField(_(u'image'), upload_to=upload_path, blank=True, null=True, help_text=u'图片') |
131 | 137 |
url = models.CharField(_(u'url'), max_length=255, blank=True, null=True, help_text=u'链接') |
132 | 138 |
|
@@ -137,6 +143,8 @@ class ModelInfo(BaseModelMixin): |
||
137 | 143 |
|
138 | 144 |
position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
139 | 145 |
|
146 |
+ display = models.BooleanField(_(u'display'), default=True, help_text=_(u'Display'), db_index=True) |
|
147 |
+ |
|
140 | 148 |
class Meta: |
141 | 149 |
verbose_name = _(u'型号信息') |
142 | 150 |
verbose_name_plural = _(u'型号信息') |
@@ -176,9 +184,13 @@ class ModelInfo(BaseModelMixin): |
||
176 | 184 |
@property |
177 | 185 |
def admindata(self): |
178 | 186 |
return { |
187 |
+ 'jancode': self.jancode, |
|
179 | 188 |
'model_id': self.model_id, |
180 | 189 |
'model_name': self.model_name, |
190 |
+ 'model_uni_name': self.model_uni_name, |
|
181 | 191 |
'model_full_name': self.model_full_name, |
192 |
+ 'category': self.category, |
|
193 |
+ 'warehouse': self.warehouse, |
|
182 | 194 |
'image_path': self.image_path, |
183 | 195 |
'image_url': self.image_url, |
184 | 196 |
'factory_yuan': self.factory_yuan, |
@@ -2,6 +2,10 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+import xlrd |
|
6 |
+from django.conf import settings |
|
7 |
+from pysnippets.strsnippets import strip |
|
8 |
+ |
|
5 | 9 |
from mch.models import BrandInfo, DistributorInfo, ModelInfo |
6 | 10 |
from statistic.models import (ConsumeDistributorSaleStatisticInfo, ConsumeModelSaleStatisticInfo, |
7 | 11 |
ConsumeProvinceSaleStatisticInfo, DistributorSaleStatisticInfo, ModelSaleStatisticInfo, |
@@ -91,3 +95,44 @@ def pre_all(): |
||
91 | 95 |
pre_provinces() |
92 | 96 |
pre_models() |
93 | 97 |
pre_distributors() |
98 |
+ |
|
99 |
+ |
|
100 |
+# In [55]: cv |
|
101 |
+# Out[55]: 991000295147.0 |
|
102 |
+# |
|
103 |
+# In [56]: str(cv) |
|
104 |
+# Out[56]: '9.91000295147e+11' |
|
105 |
+# |
|
106 |
+# In [57]: repr(cv) |
|
107 |
+# Out[57]: '991000295147.0' |
|
108 |
+def convert_to_str(cv): |
|
109 |
+ if isinstance(cv, (int, float)): |
|
110 |
+ cv = repr(cv)[:-2] if repr(cv).endswith('.0') else repr(cv) |
|
111 |
+ if isinstance(cv, str): |
|
112 |
+ cv = cv.strip() |
|
113 |
+ return cv |
|
114 |
+ |
|
115 |
+ |
|
116 |
+def pre_new_models(fpath='./pre/static/models_20180816.xls'): |
|
117 |
+ workbook = xlrd.open_workbook(fpath) |
|
118 |
+ # sheet = workbook.sheet_by_name('SMR') |
|
119 |
+ sheets = workbook.sheets() |
|
120 |
+ sheet = sheets[0] |
|
121 |
+ nrows = sheet.nrows |
|
122 |
+ for idx in range(1, nrows): |
|
123 |
+ rvals = sheet.row_values(idx) |
|
124 |
+ print rvals |
|
125 |
+ |
|
126 |
+ jancode = strip(rvals[0]) |
|
127 |
+ if not jancode: |
|
128 |
+ continue |
|
129 |
+ |
|
130 |
+ mdl, _ = ModelInfo.objects.get_or_create(jancode=jancode) |
|
131 |
+ mdl.brand_id = settings.KODO_DEFAULT_BRAND_ID |
|
132 |
+ mdl.brand_name = settings.KODO_DEFAULT_BRAND_NAME |
|
133 |
+ mdl.model_name = strip(rvals[1]) |
|
134 |
+ mdl.model_uni_name = strip(rvals[2]) |
|
135 |
+ mdl.category = strip(rvals[3]) |
|
136 |
+ mdl.model_full_name = strip(rvals[4]) |
|
137 |
+ mdl.warehouse = strip(rvals[5]) |
|
138 |
+ mdl.save() |