| @@ -20,6 +20,7 @@ from utils.error.errno_utils import (AdministratorStatusCode, OperatorStatusCode | ||
| 20 | 20 | ProductDistributorStatusCode, ProductModelStatusCode, SaleclerkStatusCode, | 
| 21 | 21 | UserStatusCode) | 
| 22 | 22 | from utils.redis.connect import r | 
| 23 | +from utils.redis.rkeys import MINI_PROGRAM_GIS_LIST | |
| 23 | 24 |  | 
| 24 | 25 |  | 
| 25 | 26 | WECHAT = settings.WECHAT | 
| @@ -266,7 +267,7 @@ def consumer_info_api(request): | ||
| 266 | 267 | # return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND) | 
| 267 | 268 |  | 
| 268 | 269 | # 记录用户信息提交记录 | 
| 269 | - ConsumeInfoSubmitLogInfo.objects.create( | |
| 270 | + log = ConsumeInfoSubmitLogInfo.objects.create( | |
| 270 | 271 | user_id=user_id, | 
| 271 | 272 | phone=purePhoneNumber, | 
| 272 | 273 | iv=iv, | 
| @@ -349,6 +350,13 @@ def consumer_info_api(request): | ||
| 349 | 350 | mssi.num += 1 | 
| 350 | 351 | mssi.save() | 
| 351 | 352 |  | 
| 353 | +            r.rpushjson(MINI_PROGRAM_GIS_LIST, { | |
| 354 | + 'brand_id': log.brand_id, | |
| 355 | + 'lat': log.lat, | |
| 356 | + 'lon': log.lon, | |
| 357 | + 'ymd': ymd, | |
| 358 | + }) | |
| 359 | + | |
| 352 | 360 | # mssi2, _ = ConsumeModelSaleStatisticInfo.objects.select_for_update().get_or_create( | 
| 353 | 361 | # brand_id=brand.brand_id, | 
| 354 | 362 | # model_id=model.model_id, | 
| @@ -219,24 +219,19 @@ def ymdtj(brand_id, ymd, lastymd): | ||
| 219 | 219 | # 与上个统计周期数据的用户人数比例 | 
| 220 | 220 | user_count_increase_pct = '%.2f' % (scan_user_count * 100.0 / last_scan_user_count) if last_scan_user_count != 0 else 0 | 
| 221 | 221 |  | 
| 222 | - # [经销商维度] 周期内镜头销售支数 | |
| 223 | - try: | |
| 224 | - sell_volume_count = SaleStatisticInfo.objects.get(brand_id=brand_id, ymd=ymd).num | |
| 225 | - except SaleStatisticInfo.DoesNotExist: | |
| 226 | - sell_volume_count = 0 | |
| 222 | + # [消费者维度] 统计周期内型号扫描排行数据,请按顺序返回 | |
| 223 | +    current_models = ConsumeModelSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=ymd, status=True).order_by('-num') | |
| 224 | + models = [m.data for m in current_models[:20]] | |
| 227 | 225 |  | 
| 228 | - try: | |
| 229 | - last_sell_volume_count = SaleStatisticInfo.objects.get(brand_id=brand_id, ymd=lastymd).num | |
| 230 | - except SaleStatisticInfo.DoesNotExist: | |
| 231 | - last_sell_volume_count = 0 | |
| 226 | + # [消费者维度] 周期内镜头销售支数 | |
| 227 | +    sell_volume_count = sum([m.get('num', 0) for m in current_models]) | |
| 228 | + | |
| 229 | +    last_models = ConsumeModelSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=lastymd, status=True).order_by('-num') | |
| 230 | + last_sell_volume_count = sum([m.num for m in last_models]) | |
| 232 | 231 |  | 
| 233 | 232 | # 与上个统计周期数据的销售支数比例 | 
| 234 | 233 | volume_count_increase_pct = '%.2f' % (sell_volume_count * 100.0 / last_sell_volume_count) if last_sell_volume_count != 0 else 0 | 
| 235 | 234 |  | 
| 236 | - # [消费者维度] 统计周期内型号扫描排行数据,请按顺序返回 | |
| 237 | -    models = ConsumeModelSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=ymd, status=True).order_by('-num')[:20] | |
| 238 | - models = [m.data for m in models] | |
| 239 | - | |
| 240 | 235 | # [经销商维度] 统计周期内销售员排行数据,请按顺序返回 | 
| 241 | 236 |      salesmen = SaleclerkSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=ymd, status=True).order_by('-num')[:20] | 
| 242 | 237 | salesmen = [s.data for s in salesmen] |