@@ -7,7 +7,7 @@ from jsonfield import JSONField  | 
            ||
| 7 | 7 | 
                from TimeConvert import TimeConvert as tc  | 
            
| 8 | 8 | 
                 | 
            
| 9 | 9 | 
                from kodo.basemodels import LensmanTypeBoolMixin  | 
            
| 10 | 
                -from mch.models import MaintenancemanInfo, SaleclerkInfo, ConsumeInfoSubmitLogInfo  | 
            |
| 10 | 
                +from mch.models import ConsumeInfoSubmitLogInfo, MaintenancemanInfo, SaleclerkInfo  | 
            |
| 11 | 11 | 
                from sales.models import SalesResponsibilityInfo  | 
            
| 12 | 12 | 
                 | 
            
| 13 | 13 | 
                 | 
            
                @@ -542,7 +542,7 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin):  | 
            ||
| 542 | 542 | 
                'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d %H:%M:%S'),  | 
            
| 543 | 543 | 
                'code_version': self.code_version,  | 
            
| 544 | 544 | 
                 | 
            
| 545 | 
                - #商品信息  | 
            |
| 545 | 
                + # 商品信息  | 
            |
| 546 | 546 | 
                'models': list(models),  | 
            
| 547 | 547 | 
                 | 
            
| 548 | 548 | 
                # 会员信息  | 
            
                @@ -16,9 +16,9 @@ from TimeConvert import TimeConvert as tc  | 
            ||
| 16 | 16 | 
                from account.models import UserInfo  | 
            
| 17 | 17 | 
                from coupon.models import UserCouponInfo  | 
            
| 18 | 18 | 
                from integral.models import SaleclerkSubmitLogInfo  | 
            
| 19 | 
                -from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, ModelInfo, DistributorInfo  | 
            |
| 20 | 
                -from member.models import GoodsOrderInfo  | 
            |
| 21 | 19 | 
                from logs.models import MchInfoEncryptLogInfo  | 
            
| 20 | 
                +from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo  | 
            |
| 21 | 
                +from member.models import GoodsOrderInfo  | 
            |
| 22 | 22 | 
                from statistic.models import ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo  | 
            
| 23 | 23 | 
                from utils.error.errno_utils import (AdministratorStatusCode, ProductBrandStatusCode, ProductCouponStatusCode,  | 
            
| 24 | 24 | 
                ProductMachineStatusCode, UserStatusCode)  | 
            
                @@ -238,7 +238,7 @@ def query_userinfo(request):  | 
            ||
| 238 | 238 | 
                 | 
            
| 239 | 239 | 
                if sex:  | 
            
| 240 | 240 | 
                userinfos = userinfos.filter(sex=sex)  | 
            
| 241 | 
                -  | 
            |
| 241 | 
                +  | 
            |
| 242 | 242 | 
                if province:  | 
            
| 243 | 243 | 
                userinfos = userinfos.filter(province_name=province)  | 
            
| 244 | 244 | 
                 | 
            
                @@ -407,7 +407,7 @@ def statistic_distributor(request):  | 
            ||
| 407 | 407 | 
                 | 
            
| 408 | 408 | 
                model_logs = SaleclerkSubmitLogInfo.objects.raw(model_sql)  | 
            
| 409 | 409 | 
                         model_logs = [{'model_uni_name': log.model_uni_name, 'num': log.num, 'code1': log.code1, 'code2': log.code2, 'has_code1_scan_num': log.has_code1_scan_num, 'has_code2_scan_num': log.has_code2_scan_num} for log in model_logs]
               | 
            
| 410 | 
                -  | 
            |
| 410 | 
                +  | 
            |
| 411 | 411 | 
                distributor_logs = []  | 
            
| 412 | 412 | 
                if distributor_name == '':  | 
            
| 413 | 413 | 
                         distributor_sql = 'select id, distributor_name, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s GROUP BY distributor_name;' % (start_time, end_time, ('AND model_uni_name="%s"' % (model_name)) if model_name else '')
               | 
            
                @@ -497,7 +497,7 @@ def statistic_consumer(request):  | 
            ||
| 497 | 497 | 
                 | 
            
| 498 | 498 | 
                model_logs = ConsumeInfoSubmitLogInfo.objects.raw(model_sql)  | 
            
| 499 | 499 | 
                         model_logs = [{'model_uni_name': log.model_uni_name, 'num': log.num, 'code1': log.code1, 'code2': log.code2} for log in model_logs]
               | 
            
| 500 | 
                -  | 
            |
| 500 | 
                +  | 
            |
| 501 | 501 | 
                     province_sql = 'select id, province, Count(id) AS num, Count(code_version=1 or NULL) AS code1, Count(code_version=2 or NULL) AS code2 FROM mch_consumeinfosubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND status=True %s GROUP BY province ORDER BY num desc;' % (start_time, end_time, ('AND model_uni_name="%s"' % (model_name)) if model_name else '')
               | 
            
| 502 | 502 | 
                 | 
            
| 503 | 503 | 
                province_logs = ConsumeInfoSubmitLogInfo.objects.raw(province_sql)  | 
            
                @@ -647,6 +647,7 @@ def record_sale(request):  | 
            ||
| 647 | 647 | 
                'left': left  | 
            
| 648 | 648 | 
                })  | 
            
| 649 | 649 | 
                 | 
            
| 650 | 
                +  | 
            |
| 650 | 651 | 
                def model_list(request):  | 
            
| 651 | 652 | 
                     brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
               | 
            
| 652 | 653 | 
                     admin_id = request.POST.get('admin_id', '')
               | 
            
                @@ -664,7 +665,8 @@ def model_list(request):  | 
            ||
| 664 | 665 | 
                     return response(200, 'Get Model List Success', u'获取型号列表成功', data={
               | 
            
| 665 | 666 | 
                'models': infos  | 
            
| 666 | 667 | 
                })  | 
            
| 667 | 
                -  | 
            |
| 668 | 
                +  | 
            |
| 669 | 
                +  | 
            |
| 668 | 670 | 
                def distributor_list(request):  | 
            
| 669 | 671 | 
                     brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
               | 
            
| 670 | 672 | 
                     admin_id = request.POST.get('admin_id', '')
               | 
            
                @@ -682,7 +684,8 @@ def distributor_list(request):  | 
            ||
| 682 | 684 | 
                     return response(200, 'Get Model List Success', u'获取经销商列表成功', data={
               | 
            
| 683 | 685 | 
                'distributors': infos  | 
            
| 684 | 686 | 
                })  | 
            
| 685 | 
                -  | 
            |
| 687 | 
                +  | 
            |
| 688 | 
                +  | 
            |
| 686 | 689 | 
                def member_goods_order(request):  | 
            
| 687 | 690 | 
                     brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
               | 
            
| 688 | 691 | 
                     admin_id = request.POST.get('admin_id', '')
               | 
            
                @@ -714,6 +717,7 @@ def member_goods_order(request):  | 
            ||
| 714 | 717 | 
                'count': count  | 
            
| 715 | 718 | 
                })  | 
            
| 716 | 719 | 
                 | 
            
| 720 | 
                +  | 
            |
| 717 | 721 | 
                def member_goods_order_update(request):  | 
            
| 718 | 722 | 
                     brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
               | 
            
| 719 | 723 | 
                     admin_id = request.POST.get('admin_id', '')
               | 
            
                @@ -732,6 +736,7 @@ def member_goods_order_update(request):  | 
            ||
| 732 | 736 | 
                 | 
            
| 733 | 737 | 
                return response(200, 'Get Member Goods Order Update Success', u'获取会员商品订单修改成功')  | 
            
| 734 | 738 | 
                 | 
            
| 739 | 
                +  | 
            |
| 735 | 740 | 
                def record_warehouse(request):  | 
            
| 736 | 741 | 
                     brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
               | 
            
| 737 | 742 | 
                     admin_id = request.POST.get('admin_id', '')
               | 
            
                @@ -749,17 +754,17 @@ def record_warehouse(request):  | 
            ||
| 749 | 754 | 
                administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)  | 
            
| 750 | 755 | 
                except AdministratorInfo.DoesNotExist:  | 
            
| 751 | 756 | 
                return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)  | 
            
| 752 | 
                -  | 
            |
| 757 | 
                +  | 
            |
| 753 | 758 | 
                     models = ModelInfo.objects.filter(model_name__icontains=model_name, status=True).values_list('pk', flat=True)
               | 
            
| 754 | 759 | 
                logs = MchInfoEncryptLogInfo.objects.filter(model_pk__in=models, sn__icontains=sn, status=True)  | 
            
| 755 | 760 | 
                 | 
            
| 756 | 761 | 
                if start_time and end_time:  | 
            
| 757 | 762 | 
                start_time = datetime.strptime(start_time, '%Y%m%d')  | 
            
| 758 | 
                - end_time = datetime.strptime(end_time+' 23:59:59', '%Y%m%d %H:%M:%S')  | 
            |
| 763 | 
                + end_time = datetime.strptime(end_time + ' 23:59:59', '%Y%m%d %H:%M:%S')  | 
            |
| 759 | 764 | 
                logs = logs.filter(created_at__range=(start_time, end_time))  | 
            
| 760 | 
                -  | 
            |
| 765 | 
                +  | 
            |
| 761 | 766 | 
                     logs = logs.order_by('-created_at')
               | 
            
| 762 | 
                -  | 
            |
| 767 | 
                +  | 
            |
| 763 | 768 | 
                count = logs.count()  | 
            
| 764 | 769 | 
                logs, left = pagination(logs, page, num)  | 
            
| 765 | 770 | 
                logs = [log.admindata for log in logs]  | 
            
                @@ -292,7 +292,7 @@ def consumer_info_api(request):  | 
            ||
| 292 | 292 | 
                during_activity = False  | 
            
| 293 | 293 | 
                else:  | 
            
| 294 | 294 | 
                during_activity = True if activities else False  | 
            
| 295 | 
                -  | 
            |
| 295 | 
                +  | 
            |
| 296 | 296 | 
                # 更新销售员提交的表  | 
            
| 297 | 297 | 
                SaleclerkSubmitLogInfo.objects.filter(code=serialNo, model_pk=model.pk, status=True).update(has_scan=True)  | 
            
| 298 | 298 | 
                 | 
            
                @@ -355,10 +355,8 @@ def consumer_info_api(request):  | 
            ||
| 355 | 355 | 
                submit_pk=log.pk,  | 
            
| 356 | 356 | 
                )  | 
            
| 357 | 357 | 
                 | 
            
| 358 | 
                -  | 
            |
| 359 | 358 | 
                if not user.test_user and not dupload:  | 
            
| 360 | 359 | 
                # TODO: Make statistic async  | 
            
| 361 | 
                -  | 
            |
| 362 | 360 | 
                cusi, _ = ConsumeUserStatisticInfo.objects.get_or_create(  | 
            
| 363 | 361 | 
                brand_id=brand.brand_id,  | 
            
| 364 | 362 | 
                ymd=ymd,  | 
            
                @@ -1,19 +1,18 @@  | 
            ||
| 1 | 1 | 
                # -*- coding: utf-8 -*-  | 
            
| 2 | 2 | 
                 | 
            
| 3 | 3 | 
                from django.conf import settings  | 
            
| 4 | 
                -from django.contrib.admin.views.decorators import staff_member_required  | 
            |
| 5 | 4 | 
                from django.db import transaction  | 
            
| 6 | 5 | 
                from django_logit import logit  | 
            
| 7 | 6 | 
                from django_response import response  | 
            
| 8 | 7 | 
                 | 
            
| 9 | 
                -from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo  | 
            |
| 10 | 
                -from mch.models import BrandInfo, DistributorInfo, ModelInfo, SaleclerkInfo, ConsumeInfoSubmitLogInfo, ActivityInfo  | 
            |
| 11 | 
                -from staff.models import StaffDeleteClerkSaleSubmitLogInfo  | 
            |
| 12 | 
                -from coupon.models import CouponInfo, UserCouponInfo  | 
            |
| 13 | 8 | 
                from account.models import UserInfo  | 
            
| 9 | 
                +from coupon.models import CouponInfo, UserCouponInfo  | 
            |
| 10 | 
                +from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo  | 
            |
| 11 | 
                +from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, SaleclerkInfo  | 
            |
| 14 | 12 | 
                from member.models import RightInfo  | 
            
| 15 | 
                -from statistic.models import (DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo,  | 
            |
| 16 | 
                - SaleclerkSaleStatisticInfo, SaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeDistributorSaleStatisticInfo, ConsumeModelSaleStatisticInfo, ConsumeProvinceSaleStatisticInfo, ConsumeUserStatisticInfo)  | 
            |
| 13 | 
                +from statistic.models import (ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo,  | 
            |
| 14 | 
                + DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo,  | 
            |
| 15 | 
                + SaleclerkSaleStatisticInfo, SaleStatisticInfo)  | 
            |
| 17 | 16 | 
                 | 
            
| 18 | 17 | 
                 | 
            
| 19 | 18 | 
                def exec_del_clerk_sale_submit(pk):  | 
            
                @@ -52,15 +51,15 @@ def exec_del_clerk_sale_submit(pk):  | 
            ||
| 52 | 51 | 
                ymd = str(ssli.ymd)  | 
            
| 53 | 52 | 
                 | 
            
| 54 | 53 | 
                if not clerk.test_user and not ssli.dupload:  | 
            
| 55 | 
                - #删除积分  | 
            |
| 56 | 
                -  | 
            |
| 54 | 
                + # 删除积分  | 
            |
| 57 | 55 | 
                try:  | 
            
| 58 | 56 | 
                income = SaleclerkIntegralIncomeExpensesInfo.objects.select_for_update().get(model_id=model.model_id, code=ssli.code, clerk_id=ssli.clerk_id)  | 
            
| 59 | 
                - income.status = False  | 
            |
| 60 | 
                - income.save()  | 
            |
| 61 | 57 | 
                except SaleclerkIntegralIncomeExpensesInfo.DoesNotExist:  | 
            
| 62 | 58 | 
                return response()  | 
            
| 63 | 
                -  | 
            |
| 59 | 
                +  | 
            |
| 60 | 
                + income.status = False  | 
            |
| 61 | 
                + income.save()  | 
            |
| 62 | 
                +  | 
            |
| 64 | 63 | 
                integral = model.integral  | 
            
| 65 | 64 | 
                 | 
            
| 66 | 65 | 
                clerk.num -= 1  | 
            
                @@ -221,6 +220,7 @@ def del_clerk_sale_submit_api(request):  | 
            ||
| 221 | 220 | 
                 | 
            
| 222 | 221 | 
                return response(200, 'Del Success', u'删除成功')  | 
            
| 223 | 222 | 
                 | 
            
| 223 | 
                +  | 
            |
| 224 | 224 | 
                def exec_del_consumer_submit(pk):  | 
            
| 225 | 225 | 
                try:  | 
            
| 226 | 226 | 
                ssli = ConsumeInfoSubmitLogInfo.objects.select_for_update().get(pk=pk)  | 
            
                @@ -236,7 +236,7 @@ def exec_del_consumer_submit(pk):  | 
            ||
| 236 | 236 | 
                ssli.save()  | 
            
| 237 | 237 | 
                 | 
            
| 238 | 238 | 
                ConsumeInfoSubmitLogInfo.objects.filter(serialNo=sn, model_id=ssli.model_id, dupload=True, status=True).update(status=False)  | 
            
| 239 | 
                -  | 
            |
| 239 | 
                +  | 
            |
| 240 | 240 | 
                if ssli.dupload:  | 
            
| 241 | 241 | 
                return response()  | 
            
| 242 | 242 | 
                 | 
            
                @@ -255,7 +255,7 @@ def exec_del_consumer_submit(pk):  | 
            ||
| 255 | 255 | 
                except UserInfo.DoesNotExist:  | 
            
| 256 | 256 | 
                return response()  | 
            
| 257 | 257 | 
                 | 
            
| 258 | 
                - #消除用户劵  | 
            |
| 258 | 
                + # 消除用户劵  | 
            |
| 259 | 259 | 
                if user.shots_num <= 5:  | 
            
| 260 | 260 | 
                rights = RightInfo.objects.filter(is_send_coupon=True, status=True)  | 
            
| 261 | 261 | 
                for right in rights:  | 
            
                @@ -285,12 +285,12 @@ def exec_del_consumer_submit(pk):  | 
            ||
| 285 | 285 | 
                             user_coupons = UserCouponInfo.objects.filter(user_id=user.user_id, coupon_id=coupon_id, coupon_from='MEMBER_BENEFITS', status=True, has_used=False).values_list('pk', flat=True)
               | 
            
| 286 | 286 | 
                # 防止用户部分劵已使用,不够消除  | 
            
| 287 | 287 | 
                UserCouponInfo.objects.filter(pk__in=list(user_coupons)[0:min(coupon_num, len(user_coupons))]).update(status=False)  | 
            
| 288 | 
                -  | 
            |
| 288 | 
                +  | 
            |
| 289 | 289 | 
                # 消除活动劵  | 
            
| 290 | 290 | 
                if ssli.submit_during_activity:  | 
            
| 291 | 291 | 
                UserCouponInfo.objects.filter(user_id=user.user_id, coupon_from='PROMOTION', submit_pk=ssli.pk).update(status=False)  | 
            
| 292 | 292 | 
                 | 
            
| 293 | 
                - #消除积分及会员等级  | 
            |
| 293 | 
                + # 消除积分及会员等级  | 
            |
| 294 | 294 | 
                integral = model.shot_member_integral  | 
            
| 295 | 295 | 
                 | 
            
| 296 | 296 | 
                if user.shots_num <= 5:  | 
            
                @@ -327,7 +327,6 @@ def exec_del_consumer_submit(pk):  | 
            ||
| 327 | 327 | 
                ssi.num -= 1  | 
            
| 328 | 328 | 
                ssi.save()  | 
            
| 329 | 329 | 
                 | 
            
| 330 | 
                -  | 
            |
| 331 | 330 | 
                # 日用户统计  | 
            
| 332 | 331 | 
                ussi, _ = ConsumeUserStatisticInfo.objects.select_for_update().get_or_create(  | 
            
| 333 | 332 | 
                brand_id=brand.brand_id,  | 
            
                @@ -44,14 +44,14 @@ class Command(CompatibilityBaseCommand):  | 
            ||
| 44 | 44 | 
                try:  | 
            
| 45 | 45 | 
                upload_file_path(ssli.image.path, key=ssli.image.name, bucket='tamron')  | 
            
| 46 | 46 | 
                os.remove(ssli.image.path)  | 
            
| 47 | 
                - except:  | 
            |
| 47 | 
                + except Exception:  | 
            |
| 48 | 48 | 
                pass  | 
            
| 49 | 49 | 
                 | 
            
| 50 | 50 | 
                if ssli.code_image:  | 
            
| 51 | 51 | 
                try:  | 
            
| 52 | 52 | 
                upload_file_path(ssli.code_image.path, key=ssli.code_image.name, bucket='tamron')  | 
            
| 53 | 53 | 
                os.remove(ssli.code_image.path)  | 
            
| 54 | 
                - except:  | 
            |
| 54 | 
                + except Exception:  | 
            |
| 55 | 55 | 
                pass  | 
            
| 56 | 56 | 
                 | 
            
| 57 | 57 | 
                ssli.is_upload_qiniu = True  | 
            
                @@ -21,6 +21,6 @@ class Command(CompatibilityBaseCommand):  | 
            ||
| 21 | 21 | 
                 | 
            
| 22 | 22 | 
                for ssli in sslis:  | 
            
| 23 | 23 | 
                             r.rpushjson(QINIU_UPLOAD_LIST, {
               | 
            
| 24 | 
                - 'model': 'SaleclerkSubmitLogInfo',  | 
            |
| 25 | 
                - 'pk': ssli.pk,  | 
            |
| 24 | 
                + 'model': 'SaleclerkSubmitLogInfo',  | 
            |
| 25 | 
                + 'pk': ssli.pk,  | 
            |
| 26 | 26 | 
                })  | 
            
                @@ -1,3 +1,3 @@  | 
            ||
| 1 | 1 | 
                #!/bin/bash  | 
            
| 2 | 2 | 
                 | 
            
| 3 | 
                -isort -rc -sp . .  | 
            |
| 3 | 
                +isort .  | 
            
                @@ -44,15 +44,16 @@ def DJANGO_WE_MESSAGE_CALLBACK_FUNC(request, data, decrypted=None):  | 
            ||
| 44 | 44 | 
                 | 
            
| 45 | 45 | 
                def DJANGO_WE_COMPONENT_CALLBACK_FUNC(request, appid, data, decrypted=None):  | 
            
| 46 | 46 | 
                """ WeChat Component Message Callback Func """  | 
            
| 47 | 
                - from account.models import UserInfo  | 
            |
| 48 | 47 | 
                from django_we.models import SubscribeUserInfo  | 
            
| 49 | 48 | 
                from pywe_component_authorizer_token import authorizer_access_token  | 
            
| 50 | 49 | 
                from pywe_custom_message import send_custom_card_message  | 
            
| 51 | 50 | 
                from pywe_event_message import parse_eventkey  | 
            
| 52 | 51 | 
                from pywe_storage import RedisStorage  | 
            
| 53 | 52 | 
                from pywe_user import get_user_info  | 
            
| 53 | 
                +  | 
            |
| 54 | 
                + from account.models import UserInfo  | 
            |
| 54 | 55 | 
                from utils.redis.connect import r  | 
            
| 55 | 
                - from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST, MEMBERCARD_USERINFO_LIST  | 
            |
| 56 | 
                + from utils.redis.rkeys import MEMBERCARD_USERINFO_LIST, SUBSCRIBE_USERINFO_LIST  | 
            |
| 56 | 57 | 
                 | 
            
| 57 | 58 | 
                logger.info(appid)  | 
            
| 58 | 59 | 
                logger.info(data)  | 
            
                @@ -202,6 +203,7 @@ def DJANGO_FILE_UPLOAD_CALLBACK_FUNC(request, file_path=None, file_url=None):  | 
            ||
| 202 | 203 | 
                     zbar = int(request.POST.get('zbar', 0))
               | 
            
| 203 | 204 | 
                if zbar:  | 
            
| 204 | 205 | 
                import os  | 
            
| 206 | 
                +  | 
            |
| 205 | 207 | 
                from utils.zbar.zbar import zbar  | 
            
| 206 | 208 | 
                 | 
            
| 207 | 209 | 
                file_path = os.path.join(settings.MEDIA_ROOT, file_path)  | 
            
                @@ -214,6 +216,7 @@ def DJANGO_FILE_UPLOAD_CALLBACK_FUNC(request, file_path=None, file_url=None):  | 
            ||
| 214 | 216 | 
                     zbar2 = int(request.POST.get('zbar2', 0))
               | 
            
| 215 | 217 | 
                if zbar:  | 
            
| 216 | 218 | 
                import os  | 
            
| 219 | 
                +  | 
            |
| 217 | 220 | 
                from utils.zbar.zbar2 import zbar2  | 
            
| 218 | 221 | 
                 | 
            
| 219 | 222 | 
                file_path = os.path.join(settings.MEDIA_ROOT, file_path)  | 
            
                @@ -3,10 +3,11 @@  | 
            ||
| 3 | 3 | 
                from django.db import models  | 
            
| 4 | 4 | 
                from django.utils.translation import ugettext_lazy as _  | 
            
| 5 | 5 | 
                from django_models_ext import BaseModelMixin, upload_file_url, upload_path  | 
            
| 6 | 
                -from mch.models import ModelInfo, OperatorInfo  | 
            |
| 7 | 6 | 
                from shortuuidfield import ShortUUIDField  | 
            
| 8 | 7 | 
                from TimeConvert import TimeConvert as tc  | 
            
| 9 | 8 | 
                 | 
            
| 9 | 
                +from mch.models import ModelInfo, OperatorInfo  | 
            |
| 10 | 
                +  | 
            |
| 10 | 11 | 
                 | 
            
| 11 | 12 | 
                class MchInfoEncryptLogInfo(BaseModelMixin):  | 
            
| 12 | 13 | 
                plaintext = models.CharField(_(u'plaintext'), max_length=64, blank=True, null=True, help_text=u'待加密字符串', db_index=True, unique=True)  | 
            
                @@ -36,13 +37,13 @@ class MchInfoEncryptLogInfo(BaseModelMixin):  | 
            ||
| 36 | 37 | 
                 | 
            
| 37 | 38 | 
                def __unicode__(self):  | 
            
| 38 | 39 | 
                return unicode(self.pk)  | 
            
| 39 | 
                -  | 
            |
| 40 | 
                +  | 
            |
| 40 | 41 | 
                @property  | 
            
| 41 | 42 | 
                def admindata(self):  | 
            
| 42 | 43 | 
                model = ModelInfo.objects.get(pk=self.model_pk, status=True)  | 
            
| 43 | 44 | 
                try:  | 
            
| 44 | 45 | 
                operator_name = OperatorInfo.objects.get(operator_id=self.operator_id).name  | 
            
| 45 | 
                - except:  | 
            |
| 46 | 
                + except OperatorInfo.DoesNotExist:  | 
            |
| 46 | 47 | 
                operator_name = '深圳捷成'  | 
            
| 47 | 48 | 
                 | 
            
| 48 | 49 | 
                         return {
               | 
            
                @@ -135,7 +135,7 @@ class GoodsOrderInfo(BaseModelMixin):  | 
            ||
| 135 | 135 | 
                 | 
            
| 136 | 136 | 
                def __unicode__(self):  | 
            
| 137 | 137 | 
                return unicode(self.pk)  | 
            
| 138 | 
                -  | 
            |
| 138 | 
                +  | 
            |
| 139 | 139 | 
                @property  | 
            
| 140 | 140 | 
                def admindata(self):  | 
            
| 141 | 141 | 
                good = GoodsInfo.objects.get(good_id=self.good_id)  | 
            
                @@ -312,7 +312,6 @@ class MemberActivityInfo(BaseModelMixin):  | 
            ||
| 312 | 312 | 
                 | 
            
| 313 | 313 | 
                position = models.IntegerField(_(u'position'), default=1, help_text=u'排序', db_index=True)  | 
            
| 314 | 314 | 
                 | 
            
| 315 | 
                -  | 
            |
| 316 | 315 | 
                is_signup = models.BooleanField(_(u'is_signup'), default=True, help_text=u'是否有报名功能', db_index=True)  | 
            
| 317 | 316 | 
                 | 
            
| 318 | 317 | 
                class Meta:  | 
            
                @@ -156,14 +156,15 @@ def mini_login_api(request):  | 
            ||
| 156 | 156 | 
                user.appid = appId  | 
            
| 157 | 157 | 
                if unionid:  | 
            
| 158 | 158 | 
                user.unionid = unionid  | 
            
| 159 | 
                -  | 
            |
| 159 | 
                +  | 
            |
| 160 | 160 | 
                # 同步销售员手机号  | 
            
| 161 | 161 | 
                try:  | 
            
| 162 | 162 | 
                saleclerk = SaleclerkInfo.objects.get(unionid=unionid, is_auth=True, status=True)  | 
            
| 163 | 
                - user.phone = saleclerk.clerk_phone  | 
            |
| 164 | 163 | 
                except SaleclerkInfo.DoesNotExist:  | 
            
| 165 | 
                - saleclerk = None  | 
            |
| 164 | 
                + saleclerk = None  | 
            |
| 166 | 165 | 
                 | 
            
| 166 | 
                + if saleclerk:  | 
            |
| 167 | 
                + user.phone = saleclerk.clerk_phone  | 
            |
| 167 | 168 | 
                user.user_status = UserInfo.ACTIVATED  | 
            
| 168 | 169 | 
                user.signup_ip = client_ip(request)  | 
            
| 169 | 170 | 
                user.signup_at = tc.utc_datetime()  | 
            
                @@ -24,7 +24,7 @@ elif django.VERSION >= (1, 8):  | 
            ||
| 24 | 24 | 
                name='simditor_upload'),  | 
            
| 25 | 25 | 
                ]  | 
            
| 26 | 26 | 
                else:  | 
            
| 27 | 
                - from django.conf.urls import patterns # pylint disable=C0411  | 
            |
| 27 | 
                + from django.conf.urls import patterns # pylint disable=C0411  | 
            |
| 28 | 28 | 
                 | 
            
| 29 | 29 | 
                # pylint disable=C0103  | 
            
| 30 | 30 | 
                urlpatterns = patterns(  | 
            
                @@ -25,7 +25,7 @@ try:  | 
            ||
| 25 | 25 | 
                from django.forms.utils import flatatt  | 
            
| 26 | 26 | 
                except ImportError:  | 
            
| 27 | 27 | 
                # Django <1.7  | 
            
| 28 | 
                - from django.forms.util import flatatt # pylint disable=E0611, E0401  | 
            |
| 28 | 
                + from django.forms.util import flatatt # pylint disable=E0611, E0401  | 
            |
| 29 | 29 | 
                 | 
            
| 30 | 30 | 
                 | 
            
| 31 | 31 | 
                class LazyEncoder(DjangoJSONEncoder):  | 
            
                @@ -2,7 +2,6 @@  | 
            ||
| 2 | 2 | 
                 | 
            
| 3 | 3 | 
                from django.conf import settings  | 
            
| 4 | 4 | 
                from PIL import Image, ImageEnhance  | 
            
| 5 | 
                -  | 
            |
| 6 | 5 | 
                from pyzbar import pyzbar  | 
            
| 7 | 6 | 
                 | 
            
| 8 | 7 | 
                 |