Change to use clerk's distributor_id

Brightcells 6 anos atrás
pai
commit
e7306d6105
5 arquivos alterados com 103 adições e 106 exclusões
  1. 5 6
      api/clerk_views.py
  2. 39 38
      api/mch_views.py
  3. 5 6
      page/oauth_views.py
  4. 43 45
      page/sale_views.py
  5. 11 11
      page/templates/page/clerk_oauth.html

+ 5 - 6
api/clerk_views.py

@@ -23,16 +23,15 @@ def clerk_add(request):
23 23
     except AdministratorInfo.DoesNotExist:
24 24
         return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
25 25
 
26
-    # try:
27
-    #     distributor = DistributorInfo.objects.get(distributor_id=distributor_id, status=True)
28
-    # except DistributorInfo.DoesNotExist:
29
-    #     return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
26
+    try:
27
+        distributor = DistributorInfo.objects.get(distributor_id=distributor_id, status=True)
28
+    except DistributorInfo.DoesNotExist:
29
+        return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
30 30
 
31 31
     SaleclerkInfo.objects.create(
32 32
         brand_id=administrator.brand_id,
33 33
         distributor_id=distributor_id,
34
-        # distributor_name=distributor.distributor_name,
35
-        distributor_name='',
34
+        distributor_name=distributor.distributor_name,
36 35
         clerk_name=clerk_name,
37 36
         clerk_phone=clerk_phone,
38 37
     )

+ 39 - 38
api/mch_views.py

@@ -268,7 +268,8 @@ def consumer_info_api(request):
268 268
         if ConsumeInfoSubmitLogInfo.objects.filter(
269 269
             brand_id=brand.brand_id,
270 270
             model_id=model.model_id,
271
-            distributor_id=distributor.distributor_id,
271
+            # distributor_id=distributor.distributor_id,
272
+            distributor_id='',
272 273
             serialNo=serialNo,
273 274
             verifyResult=1,
274 275
             test_user=False,
@@ -302,42 +303,42 @@ def consumer_info_api(request):
302 303
             mssi2.num += 1
303 304
             mssi2.save()
304 305
 
305
-            # 经销商销量统计
306
-            dssi, _ = ConsumeDistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
307
-                brand_id=brand.brand_id,
308
-                distributor_id=distributor.distributor_id,
309
-                ymd=ymd,
310
-            )
311
-            dssi.distributor_name = distributor.distributor_name
312
-            dssi.num += 1
313
-            dssi.save()
314
-
315
-            dssi2, _ = ConsumeDistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
316
-                brand_id=brand.brand_id,
317
-                distributor_id=distributor.distributor_id,
318
-                ymd=0,
319
-            )
320
-            dssi2.distributor_name = distributor.distributor_name
321
-            dssi2.num += 1
322
-            dssi2.save()
323
-
324
-            # 省份销量统计
325
-            pssi, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
326
-                brand_id=brand.brand_id,
327
-                province_code=distributor.distributor_province_code,
328
-                ymd=ymd,
329
-            )
330
-            pssi.province_name = distributor.distributor_province_name
331
-            pssi.num += 1
332
-            pssi.save()
333
-
334
-            pssi2, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
335
-                brand_id=brand.brand_id,
336
-                province_code=distributor.distributor_province_code,
337
-                ymd=0,
338
-            )
339
-            pssi2.province_name = distributor.distributor_province_name
340
-            pssi2.num += 1
341
-            pssi2.save()
306
+            # # 经销商销量统计
307
+            # dssi, _ = ConsumeDistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
308
+            #     brand_id=brand.brand_id,
309
+            #     distributor_id=distributor.distributor_id,
310
+            #     ymd=ymd,
311
+            # )
312
+            # dssi.distributor_name = distributor.distributor_name
313
+            # dssi.num += 1
314
+            # dssi.save()
315
+            #
316
+            # dssi2, _ = ConsumeDistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
317
+            #     brand_id=brand.brand_id,
318
+            #     distributor_id=distributor.distributor_id,
319
+            #     ymd=0,
320
+            # )
321
+            # dssi2.distributor_name = distributor.distributor_name
322
+            # dssi2.num += 1
323
+            # dssi2.save()
324
+            #
325
+            # # 省份销量统计
326
+            # pssi, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
327
+            #     brand_id=brand.brand_id,
328
+            #     province_code=distributor.distributor_province_code,
329
+            #     ymd=ymd,
330
+            # )
331
+            # pssi.province_name = distributor.distributor_province_name
332
+            # pssi.num += 1
333
+            # pssi.save()
334
+            #
335
+            # pssi2, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
336
+            #     brand_id=brand.brand_id,
337
+            #     province_code=distributor.distributor_province_code,
338
+            #     ymd=0,
339
+            # )
340
+            # pssi2.province_name = distributor.distributor_province_name
341
+            # pssi2.num += 1
342
+            # pssi2.save()
342 343
 
343 344
     return response(200, 'Submit Consumer Info Success', u'提交消费者信息成功')

+ 5 - 6
page/oauth_views.py

@@ -94,15 +94,14 @@ def clerk_submit_api(request):
94 94
     if SaleclerkInfo.objects.filter(clerk_phone=phone).exclude(unionid=unionid).exists():
95 95
         return response(SaleclerkStatusCode.CLERK_PHONE_ALREADY_EXISTS)
96 96
 
97
-    # try:
98
-    #     distributor = DistributorInfo.objects.get(distributor_id=distributor_id)
99
-    # except DistributorInfo.DoesNotExist:
100
-    #     return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
97
+    try:
98
+        distributor = DistributorInfo.objects.get(distributor_id=distributor_id)
99
+    except DistributorInfo.DoesNotExist:
100
+        return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
101 101
 
102 102
     fields = {
103 103
         'distributor_id': distributor_id,
104
-        # 'distributor_name': distributor.distributor_name,
105
-        'distributor_name': '',
104
+        'distributor_name': distributor.distributor_name,
106 105
         'clerk_name': request.POST.get('name', ''),
107 106
         'clerk_sex': int(request.POST.get('sex', 1)),
108 107
         'clerk_phone': phone,

+ 43 - 45
page/sale_views.py

@@ -62,18 +62,18 @@ def clerk_sale_submit_api(request):
62 62
     except ValueError:
63 63
         return response(ProductModelStatusCode.MODEL_NOT_FOUND)
64 64
 
65
-    # try:
66
-    #     distributor = DistributorInfo.objects.get(pk=distributorID)
67
-    # except DistributorInfo.DoesNotExist:
68
-    #     return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
69
-    # except ValueError:
70
-    #     return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
71
-
72 65
     try:
73 66
         clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, unionid=user.unionid, status=True)
74 67
     except SaleclerkInfo.DoesNotExist:
75 68
         return response(SaleclerkStatusCode.CLERK_NOT_FOUND)
76 69
 
70
+    try:
71
+        distributor = DistributorInfo.objects.get(distributor_id=clerk.distributor_id)
72
+    except DistributorInfo.DoesNotExist:
73
+        return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
74
+    except ValueError:
75
+        return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND)
76
+
77 77
     # 店员提交记录
78 78
     ssli = SaleclerkSubmitLogInfo.objects.create(
79 79
         clerk_id=clerk.clerk_id,
@@ -123,10 +123,8 @@ def clerk_sale_submit_api(request):
123 123
         brand_name=brand.brand_name,
124 124
         model_id=model.model_id,
125 125
         model_name=model.model_name,
126
-        # distributor_id=distributor.distributor_id,
127
-        # distributor_name=distributor.distributor_name,
128
-        distributor_id='',
129
-        distributor_name='',
126
+        distributor_id=distributor.distributor_id,
127
+        distributor_name=distributor.distributor_name,
130 128
         code=serialNo,
131 129
         consumer_name=consumer_name,
132 130
         consumer_phone=consumer_phone,
@@ -170,42 +168,42 @@ def clerk_sale_submit_api(request):
170 168
         mssi2.save()
171 169
 
172 170
         # 经销商销量统计
173
-        # dssi, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
174
-        #     brand_id=brand.brand_id,
175
-        #     distributor_id=distributor.distributor_id,
176
-        #     ymd=ymd,
177
-        # )
178
-        # dssi.distributor_name = distributor.distributor_name
179
-        # dssi.num += 1
180
-        # dssi.save()
181
-        #
182
-        # dssi2, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
183
-        #     brand_id=brand.brand_id,
184
-        #     distributor_id=distributor.distributor_id,
185
-        #     ymd=0,
186
-        # )
187
-        # dssi2.distributor_name = distributor.distributor_name
188
-        # dssi2.num += 1
189
-        # dssi2.save()
171
+        dssi, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
172
+            brand_id=brand.brand_id,
173
+            distributor_id=distributor.distributor_id,
174
+            ymd=ymd,
175
+        )
176
+        dssi.distributor_name = distributor.distributor_name
177
+        dssi.num += 1
178
+        dssi.save()
179
+
180
+        dssi2, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create(
181
+            brand_id=brand.brand_id,
182
+            distributor_id=distributor.distributor_id,
183
+            ymd=0,
184
+        )
185
+        dssi2.distributor_name = distributor.distributor_name
186
+        dssi2.num += 1
187
+        dssi2.save()
190 188
 
191 189
         # 省份销量统计
192
-        # pssi, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
193
-        #     brand_id=brand.brand_id,
194
-        #     province_code=distributor.distributor_province_code,
195
-        #     ymd=ymd,
196
-        # )
197
-        # pssi.province_name = distributor.distributor_province_name
198
-        # pssi.num += 1
199
-        # pssi.save()
200
-        #
201
-        # pssi2, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
202
-        #     brand_id=brand.brand_id,
203
-        #     province_code=distributor.distributor_province_code,
204
-        #     ymd=0,
205
-        # )
206
-        # pssi2.province_name = distributor.distributor_province_name
207
-        # pssi2.num += 1
208
-        # pssi2.save()
190
+        pssi, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
191
+            brand_id=brand.brand_id,
192
+            province_code=distributor.distributor_province_code,
193
+            ymd=ymd,
194
+        )
195
+        pssi.province_name = distributor.distributor_province_name
196
+        pssi.num += 1
197
+        pssi.save()
198
+
199
+        pssi2, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
200
+            brand_id=brand.brand_id,
201
+            province_code=distributor.distributor_province_code,
202
+            ymd=0,
203
+        )
204
+        pssi2.province_name = distributor.distributor_province_name
205
+        pssi2.num += 1
206
+        pssi2.save()
209 207
 
210 208
     return response(200, data={
211 209
         'integral': integral,

+ 11 - 11
page/templates/page/clerk_oauth.html

@@ -16,16 +16,16 @@
16 16
         <div class="container" >
17 17
             <div class="weui_cells_title">基本信息</div>
18 18
             <div class="weui_cells weui_cells_form">
19
-{#                <div class="weui_cell weui_cell_select weui_select_after">#}
20
-{#                    <div class="weui_cell_hd"><label for="" class="weui_label">经销商</label></div>#}
21
-{#                    <div class="weui_cell_bd weui_cell_primary">#}
22
-{#                        <select id="distributor" class="weui_select" name="select" {% if not modified %}disabled{% endif %}>#}
23
-{#                            {% for distributor in distributors %}#}
24
-{#                            <option value="{{ distributor.distributor_id }}" {% ifequal distributor.distributor_id clerk_info.distributor_id %}selected{% endifequal %}>{{ distributor.distributor_name }}</option>#}
25
-{#                            {% endfor %}#}
26
-{#                        </select>#}
27
-{#                    </div>#}
28
-{#                </div>#}
19
+                <div class="weui_cell weui_cell_select weui_select_after">
20
+                    <div class="weui_cell_hd"><label for="" class="weui_label">经销商</label></div>
21
+                    <div class="weui_cell_bd weui_cell_primary">
22
+                        <select id="distributor" class="weui_select" name="select" {% if not modified %}disabled{% endif %}>
23
+                            {% for distributor in distributors %}
24
+                            <option value="{{ distributor.distributor_id }}" {% ifequal distributor.distributor_id clerk_info.distributor_id %}selected{% endifequal %}>{{ distributor.distributor_name }}</option>
25
+                            {% endfor %}
26
+                        </select>
27
+                    </div>
28
+                </div>
29 29
                 <div class="weui_cell">
30 30
                     <div class="weui_cell_hd"><label for="" class="weui_label">姓名</label></div>
31 31
                     <div class="weui_cell_bd weui_cell_primary">
@@ -137,7 +137,7 @@
137 137
                         unionid: unionid,
138 138
                         openid: '{{ request.GET.openid }}',
139 139
                         brand_id: '{{ request.GET.brand_id }}',
140
-{#                        distributor_id: $('#distributor option:checked').val(),#}
140
+                        distributor_id: $('#distributor option:checked').val(),
141 141
                         name: name,
142 142
                         sex: $('#sex option:checked').val(),
143 143
                         phone: phone,