Пример #1
0
 def list_product(self):
     """商品列表"""
     args = request.args.to_dict()
     filter_args = []
     if not (is_admin() or is_supplizer()):
         filter_args.append(Product.PRstatus.notin_((ProductStatus.interrupt.value, ProductStatus.reject.value,
                                                     ProductStatus.pending.value)))
     if is_supplizer():
         filter_args.append(Product.SUid == getattr(request, 'user').id)
     prlimited = args.get('prtimelimeted')
     if str(prlimited) in '01':
         filter_args.append(Product.PRtimeLimeted == prlimited)
     products = Product.query.filter(Product.isdelete == false(), *filter_args
                                     ).order_by(func.field(Product.PRstatus, ProductStatus.active.value,
                                                           ProductStatus.ready.value, ProductStatus.over.value),
                                                Product.PRissueStartTime.asc(),
                                                Product.createtime.desc()).all_with_page()
     products_fields = ['PRid', 'PRname', 'PRimg', 'PRlinePrice', 'PRtruePrice', 'PRnum', 'PRtimeLimeted',
                        'PRstatus', 'prstatus_zh', 'apply_num', 'PRissueStartTime', 'PRissueEndTime',
                        'PRuseStartTime', 'PRuseEndTime', 'interrupt', 'apply_num_str', 'buyer_avatar',
                        'start_time_str']
     for product in products:
         self._fill_product(product)
         product.fields = products_fields
         if not product.PRtimeLimeted:
             product.PRnum = '无限量'
     return Success(data=products)
Пример #2
0
 def create_product(self):
     """创建商品"""
     if is_admin():
         product_from = ProductFrom.platform.value
     elif is_supplizer():
         product_from = ProductFrom.supplizer.value
     else:
         raise AuthorityError('当前用户无权进行该操作')
     data = request.json
     product_dict = self._validate_ticket_param(data)
     if Product.query.filter(Product.isdelete == false(), Product.PRname == data.get('prname')).first():
         raise ParamsError('该商品名称已存在')
     with db.auto_commit():
         product_dict.update({'PRid': str(uuid.uuid1()),
                              'CreatorId': getattr(request, 'user').id,
                              'CreatorType': getattr(request, 'user').model,
                              'PRname': data.get('prname'),
                              'PRimg': data.get('primg'),
                              'PRdetails': data.get('prdetails'),
                              # 'PRstatus': ProductStatus.ready.value if product_dict.get(
                              #     'PRtimeLimeted') else ProductStatus.active.value,
                              'PRstatus': ProductStatus.pending.value
                              })
         product = Product.create(product_dict)
         db.session.add(product)
     # 0702 增加审批
     # if product.PRtimeLimeted:  # 限时商品,添加异步任务
     #     add_async_task(func=start_product, start_time=product.PRissueStartTime, func_args=(product.PRid,),
     #                    conn_id='start_product{}'.format(product.PRid))
     #     add_async_task(func=end_product, start_time=product.PRissueEndTime, func_args=(product.PRid,),
     #                    conn_id='end_product{}'.format(product.PRid))
     self.base_approval.create_approval('toshelves', request.user.id, product.PRid, product_from)
     self.base_admin.create_action(AdminActionS.insert.value, 'Product', product.PRid)
     return Success('创建成功', data={'prid': product.PRid})
Пример #3
0
    def set_supplizeraccount(self):
        if not is_supplizer():
            raise AuthorityError
        data = request.json
        cardno = data.get('sacardno')
        cardno = re.sub(r'\s', '', str(cardno))
        self.cuser._CUser__check_card_num(cardno)
        check_res = self.cuser._verify_cardnum(cardno)  # 检验卡号
        if not check_res.data.get('validated'):
            raise ParamsError('请输入正确的银行卡号')
        checked_res = self.cuser._verify_cardnum(data.get('sabankaccount'))
        # if not checked_res.data.get('validated'):
        #     raise ParamsError('请输入正确的开票账户银行卡号')
        checked_name = self.cuser._verify_chinese(data.get('sacardname'))
        if not checked_name or len(checked_name[0]) < 2:
            raise ParamsError('请输入正确的开户人姓名')
        current_app.logger.info('用户输入银行名为:{}'.format(data.get('sabankname')))
        bankname = check_res.data.get('cnbankname')
        try:
            WexinBankCode(bankname)
        except Exception:
            raise ParamsError('系统暂不支持该银行提现,请更换银行后重新保存')
        data['sabankname'] = bankname
        current_app.logger.info('校验后更改银行名为:{}'.format(data.get('sabankname')))

        sa = SupplizerAccount.query.filter(
            SupplizerAccount.SUid == request.user.id,
            SupplizerAccount.isdelete == false()).first()
        if sa:
            for key in sa.__dict__:
                if str(key).lower() in data:
                    if re.match(r'^(said|suid)$', str(key).lower()):
                        continue
                    if str(key).lower() == 'sacardno':
                        setattr(sa, key, cardno)
                        continue
                    setattr(sa, key, data.get(str(key).lower()))
        else:
            sa_dict = {}
            for key in SupplizerAccount.__dict__:

                if str(key).lower() in data:
                    if not data.get(str(key).lower()):
                        continue
                    if str(key).lower() == 'suid':
                        continue
                    if str(key).lower() == 'sacardno':
                        sa_dict.setdefault(key, cardno)
                        continue
                    sa_dict.setdefault(key, data.get(str(key).lower()))
            sa_dict.setdefault('SAid', str(uuid.uuid1()))
            sa_dict.setdefault('SUid', request.user.id)
            sa = SupplizerAccount.create(sa_dict)
            db.session.add(sa)

        return Success('设置供应商账户信息成功')
Пример #4
0
 def validate_suid(self, raw):
     if is_supplizer():
         self.suid.data = request.user.id
     else:
         if not raw.data:
             raise ParamsError('供应商suid不可为空')
     supplizer = Supplizer.query.filter(
         Supplizer.SUid == raw.data,
         Supplizer.isdelete == False).first_('供应商不存在')
     self.supplizer = supplizer
Пример #5
0
 def get_approvalnotes(self):
     """查看审批的所有流程"""
     if not (is_admin() or is_supplizer()):
         raise AuthorityError('权限不足')
     data = parameter_required(('avid', ))
     an_list = ApprovalNotes.query.filter_by_(
         AVid=data.get('avid')).order_by(ApprovalNotes.createtime).all()
     for an in an_list:
         an.fill('anaction', ApprovalAction(an.ANaction).zh_value)
     return Success('获取审批记录成功', data=an_list)
Пример #6
0
    def get_dealing_approval(self):
        """管理员查看自己名下可以处理的审批流 概览"""
        if is_admin():
            admin = Admin.query.filter_by_(
                ADid=request.user.id).first_('管理员账号已被回收')
            if not admin:
                current_app.logger.info('get admin failed id is {0}'.format(
                    admin.ADid))
                raise NotFound("该管理员已被删除")
            # pttype = request.args.to_dict().get('pttypo')
            pt_list = PermissionType.query.filter(
                PermissionType.PTid == Permission.PTid,
                Permission.PIid == AdminPermission.PIid,
                AdminPermission.ADid == admin.ADid,
                PermissionType.isdelete == False,
                AdminPermission.isdelete == False,
                Permission.isdelete == False).order_by(
                    PermissionType.createtime.desc()).all()
            # pi_list = AdminPermission.query.filter_by_(ADid=admin.ADid).all()
            for pt in pt_list:
                ap_num = Approval.query.filter(
                    Approval.PTid == pt.PTid,
                    Approval.AVlevel == Permission.PELevel,
                    Permission.PTid == pt.PTid,
                    Permission.PIid == AdminPermission.PIid,
                    AdminPermission.ADid == admin.ADid,
                    Approval.AVstatus == ApplyStatus.wait_check.value,
                    Approval.isdelete == False, Permission.isdelete == False,
                    AdminPermission.isdelete == False).count()
                pt.fill('approval_num', ap_num)
        elif is_supplizer():
            sup = Supplizer.query.filter_by_(
                SUid=request.user.id).first_('供应商账号已回收')
            pt_list = PermissionType.query.filter(
                PermissionType.PTid == Approval.PTid,
                Approval.AVstartid == sup.SUid,
                Approval.AVstatus == ApplyStatus.wait_check.value,
                PermissionType.isdelete == False,
                Approval.isdelete == False).all()
            if not pt_list:
                pt_list = PermissionType.query.filter_by_(
                    PTid='tointegral').all()
            # todo 供应商的审批类型筛选
            for pt in pt_list:
                ap_num = Approval.query.filter(
                    Approval.AVstartid == sup.SUid, Approval.PTid == pt.PTid,
                    Approval.isdelete == False).count()

                pt.fill('approval_num', ap_num)
        else:
            pt_list = []

        return Success('获取审批流类型成功', data=pt_list)
Пример #7
0
 def history_detail(self):
     if not is_supplizer() and not is_admin():
         raise AuthorityError()
     days = request.args.to_dict().get('days')
     if days:
         days = days.replace(' ', '').split(',')
         days = list(map(lambda x: datetime.strptime(x, '%Y-%m-%d').date(), days))
     else:
         days = []
     suid = request.user.id if is_supplizer() else None
     datas = []
     for day in days:
         data = {
             'day_total': self._history_order('total', day=day,
                                              status=(OrderMain.OMstatus > OrderStatus.pending.value,
                                                      OrderMain.OMpayType == PayType.cash.value),
                                              suid=suid),
             'day_count': self._history_order('count', day=day, suid=suid),
             'wai_pay_count': self._history_order('count', day=day,
                                                  status=(OrderMain.OMstatus == OrderStatus.wait_pay.value,),
                                                  suid=suid),
             # 'in_refund': self._inrefund(day=day, suid=suid),
             'in_refund': 0,
             'day': day
         }
         datas.append(data)
     if not days:
         # 获取系统全部
         data = {
             'day_total': self._history_order('total',
                                              status=(OrderMain.OMstatus > OrderStatus.pending.value,
                                                      OrderMain.OMpayType == PayType.cash.value),
                                              suid=suid),
             'day_count': self._history_order('count', suid=suid),
             'wai_pay_count': 0,
             'in_refund': 0,
             'day': None
         }
         datas.append(data)
     return Success(data=datas)
Пример #8
0
    def get_verifier(self):
        form = GetVerifier().valid_data()
        suid = form.suid.data
        if is_supplizer():
            suid = request.user.id
        if not suid:
            raise ParamsError('未指定供应商')
        tv_list = ProductVerifier.query.filter_by(
            SUid=suid,
            isdelete=False).order_by(ProductVerifier.createtime.desc()).all()

        phone_list = [tv.PVphone for tv in tv_list]
        return Success(data=phone_list)
Пример #9
0
    def _list_ticket_sup():
        sups = Supplizer.query.filter(
            Supplizer.isdelete == false(),
            Supplizer.SUstatus == UserStatus.usual.value,
            Supplizer.SUgrade == SupplizerGrade.ticket.value)
        if is_supplizer():
            sups = sups.filter(Supplizer.SUid == getattr(request, 'user').id)
        sups = sups.all_with_page()

        for sup in sups:
            sup.fields = ['SUid', 'SUname', 'SUgrade', 'SUstatus']
            sup.fill('sustatus_zh', UserStatus(sup.SUstatus).zh_value)
            sup.fill('sugrade_zh', SupplizerGrade(sup.SUgrade).zh_value)
        return Success(data=sups)
Пример #10
0
 def get(self):
     if not is_admin() and not is_supplizer():
         raise AuthorityError()
     form = SupplizerGetForm().valid_data()
     supplizer = form.supplizer
     self._fill_supplizer(supplizer)
     # pbs = ProductBrand.query.filter(
     #     ProductBrand.isdelete == False,
     #     ProductBrand.SUid == supplizer.SUid
     # ).all()
     # for pb in pbs:
     #     if pb:
     #         pb.pbstatus_zh = ProductBrandStatus(pb.PBstatus).zh_value
     #         pb.add('pbstatus_zh')
     supplizer.fill('pbs', [])
     supplizer.fill('SUbaseRate', 0)
     return Success(data=supplizer)
Пример #11
0
    def update(self):
        """更新供应商信息"""
        if not is_admin() and not is_supplizer():
            raise AuthorityError()
        form = SupplizerUpdateForm().valid_data()
        pbids = form.pbids.data
        with db.auto_commit():
            supplizer = Supplizer.query.filter(
                Supplizer.isdelete == False,
                Supplizer.SUid == form.suid.data).first_('供应商不存在')
            supplizer_dict = {
                'SUlinkPhone': form.sulinkphone.data,
                'SUname': form.suname.data,
                'SUlinkman': form.sulinkman.data,
                'SUaddress': form.suaddress.data,
                'SUbanksn': form.subanksn.data,
                'SUbankname': form.subankname.data,
                # 'SUpassword': generate_password_hash(form.supassword.data),  # 暂时去掉
                'SUheader': form.suheader.data,
                'SUcontract': form.sucontract.data,
                'SUbusinessLicense': form.subusinesslicense.data,
                'SUregisteredFund': form.suregisteredfund.data,
                'SUmainCategory': form.sumaincategory.data,
                # 'SUregisteredTime': form.suregisteredtime.data,
                'SUlegalPerson': form.sulegalperson.data,
                'SUemail': form.suemail.data,
                'SUlegalPersonIDcardFront': form.sulegalpersonidcardfront.data,
                'SUlegalPersonIDcardBack': form.sulegalpersonidcardback.data,
            }
            if is_admin():
                # if form.subaserate.data:
                #     supplizer_dict['SUbaseRate'] = form.subaserate.data,
                if isinstance(form.sustatus.data, int):
                    supplizer_dict['SUstatus'] = form.sustatus.data
                    if form.sustatus.data == UserStatus.usual.value and not supplizer.SUpassword:
                        supplizer_dict['SUpassword'] = generate_password_hash(
                            supplizer.SUloginPhone)

            supplizer.update(supplizer_dict, null='dont ignore')
            db.session.add(supplizer)
            if is_admin():
                self.base_admin.create_action(AdminActionS.update.value,
                                              'Supplizer', form.suid.data)
        return Success('更新成功')
Пример #12
0
    def set_verifier(self):
        form = SetVerifier().valid_data()
        if is_admin():
            suid = form.suid.data
            assert suid, '供应商未指定'
        elif is_supplizer():
            suid = request.user.id
        else:
            raise AuthorityError()
        sup = Supplizer.query.filter(
            Supplizer.isdelete == false(),
            Supplizer.SUstatus == UserStatus.usual.value,
            Supplizer.SUid == suid).first_('供应商状态异常')
        if sup.SUgrade != SupplizerGrade.ticket.value:
            raise StatusError('仅虚拟商品供应商可设置核销员')
        phone_list = form.phone_list.data
        tvid_list = []
        instence_list = []
        phone_list = {}.fromkeys(phone_list).keys()
        with db.auto_commit():
            for phone in phone_list:
                User.query.filter(
                    User.isdelete == false(),
                    User.UStelephone == phone).first_(f'没有手机号为 {phone} 用户 ')
                tv = ProductVerifier.query.filter_by(SUid=suid,
                                                     PVphone=phone).first()
                if not tv:
                    tv = ProductVerifier.create({
                        'PVid': str(uuid.uuid1()),
                        'SUid': suid,
                        'PVphone': phone
                    })
                    instence_list.append(tv)
                tvid_list.append(tv.PVid)

            db.session.add_all(instence_list)
            # 删除无效的
            ProductVerifier.query.filter(
                ProductVerifier.isdelete == false(),
                ProductVerifier.SUid == suid,
                ProductVerifier.PVid.notin_(tvid_list)).delete_(
                    synchronize_session=False)
        return Success('修改成功', data=suid)
Пример #13
0
 def change_password(self):
     if not is_supplizer() and not is_admin():
         raise AuthorityError()
     form = SupplizerChangePasswordForm().valid_data()
     old_password = form.oldpassword.data
     supassword = form.supassword.data
     suid = form.suid.data
     with db.auto_commit():
         supplizer = Supplizer.query.filter(
             Supplizer.isdelete == False,
             Supplizer.SUid == suid).first_('不存在的供应商')
         if not is_admin() and not check_password_hash(
                 supplizer.SUpassword, old_password):
             raise AuthorityError('原密码错误')
         supplizer.SUpassword = generate_password_hash(supassword)
         db.session.add(supplizer)
         if is_admin():
             self.base_admin.create_action(AdminActionS.update.value,
                                           'Supplizer', suid)
     return Success('修改成功')
Пример #14
0
    def deal_approval(self):
        """管理员处理审批流"""
        if is_admin():
            admin = Admin.query.filter_by_(
                ADid=request.user.id).first_("该管理员已被删除")
            sup = None
        elif is_supplizer():
            sup = Supplizer.query.filter_by_(
                SUid=request.user.id).first_("账号状态错误,请重新登录")
            admin = None
        else:
            raise AuthorityError('权限不足')

        receive_data = request.json
        with db.auto_commit():
            if isinstance(receive_data, list):
                for data in receive_data:
                    self.deal_single_approval(data, admin, sup)
            else:
                self.deal_single_approval(receive_data, admin, sup)

        return Success("审批操作完成")
Пример #15
0
    def list(self):
        data = parameter_required()
        omstatus = data.get('omstatus')
        filter_args = [OrderMain.isdelete == false()]
        order_by_list = [OrderMain.updatetime.desc(), OrderMain.createtime.desc()]
        if is_user():
            user = self._current_user('请重新登录')

            try:
                omstatus = OrderStatus(int(str(omstatus))).value
            except ValueError:
                current_app.logger.error('omstatus error')
                omstatus = OrderStatus.pending.value
            filter_args.append(OrderMain.USid == user.USid)
            filter_args.append(OrderMain.OMstatus == omstatus)
        else:
            if omstatus:
                try:
                    omstatus = OrderStatus(int(str(omstatus))).value
                except:
                    omstatus = OrderStatus.pending.value
                filter_args.append(OrderMain.OMstatus == omstatus)
            omno = data.get('omno')
            prname = data.get('prname')
            ompaytype = data.get('ompaytype', PayType.cash.value)
            try:
                ompaytype = PayType(int(str(ompaytype))).value
            except:
                ompaytype = PayType.cash.value
            filter_args.append(OrderMain.OMpayType == ompaytype)
            createtime_start = self._check_date(data.get('createtime_start'))
            createtime_end = self._check_date(data.get('createtime_end'))
            if createtime_start:
                filter_args.append(cast(OrderMain.createtime, Date) >= createtime_start)
            if createtime_end:
                filter_args.append(cast(OrderMain.createtime, Date) <= createtime_end)
            if omno:
                filter_args.append(OrderMain.OMno.ilike('%{}%'.format(omno)))
            if prname:
                filter_args.append(OrderMain.PRname.ilike('%{}%'.format(prname)))
            if is_supplizer():
                filter_args.append(OrderMain.PRcreateId == getattr(request, 'user').id)
        omlist = OrderMain.query.filter(*filter_args).order_by(*order_by_list).all_with_page()

        now = datetime.now()

        user_list = db.session.query(User.USid, User.USname, User.USheader).filter(
            User.isdelete == false(), OrderMain.USid == User.USid, *filter_args).all()
        user_dict = {user_info[0]: user_info for user_info in user_list}
        for om in omlist:
            self._fill_ordermain(om)
            if om.OMstatus == OrderStatus.wait_pay.value:
                duration = om.createtime + timedelta(minutes=30) - now
                om.fill('duration', str(duration))
            # todo 填充商品信息
            # 填充用户信息
            user_info = user_dict.get(om.USid)
            # current_app.logger.info('get user info {}'.format(user_info))
            # current_app.logger.info('get user id {}'.format(om.USid))
            # current_app.logger.info('get om id {}'.format(om.OMid))

            om.fill('usname', user_info[1])
            om.fill('USheader', user_info[2])

        return Success(data=omlist)
Пример #16
0
 def validate_suid(self, raw):
     if is_supplizer():
         self.suid.data = request.user.id
Пример #17
0
    def update_product(self):
        """编辑商品"""
        if is_admin():
            product_from = ProductFrom.platform.value
        elif is_supplizer():
            product_from = ProductFrom.supplizer.value
        else:
            raise AuthorityError('当前用户无权进行该操作')
        data = parameter_required('prid')
        product = Product.query.filter(Product.isdelete == false(),
                                       Product.PRid == data.get('prid')).first_('未找到该商品信息')
        if Product.query.filter(Product.isdelete == false(), Product.PRname == data.get('prname'),
                                Product.PRid != Product.PRid, Product.PRstatus != ProductStatus.over.value).first():
            raise ParamsError('该商品名已存在')
        approval_flag = 0
        with db.auto_commit():
            if data.get('delete'):
                if product.PRstatus == ProductStatus.active.value:
                    raise ParamsError('无法直接删除正在发放中的商品')
                if OrderMain.query.filter(OrderMain.isdelete == false(),
                                          OrderMain.OMstatus > OrderStatus.not_won.value,
                                          OrderMain.PRid == product.PRid).first():
                    raise StatusError('暂时无法直接删除已产生购买记录的商品')
                product.update({'isdelete': True})
                # 取消异步任务
                cancel_async_task('start_product{}'.format(product.PRid))
                cancel_async_task('end_product{}'.format(product.PRid))
                self.base_admin.create_action(AdminActionS.delete.value, 'Product', product.PRid)
                # 同时将正在进行的审批流改为取消
                self.base_approval.cancel_approval(product.PRid, request.user.id)
            elif data.get('interrupt'):
                if product.PRstatus > ProductStatus.active.value:
                    raise StatusError('该状态下无法中止')
                product.update({'PRstatus': ProductStatus.interrupt.value})
                cancel_async_task('start_product{}'.format(product.PRid))
                cancel_async_task('end_product{}'.format(product.PRid))
                self.base_admin.create_action(AdminActionS.update.value, 'Product', product.PRid)
                # 同时将正在进行的审批流改为取消
                self.base_approval.cancel_approval(product.PRid, request.user.id)
            else:
                approval_flag = 1
                if product.PRstatus < ProductStatus.interrupt.value:
                    raise ParamsError('仅可编辑已中止发放或已结束的商品')
                product_dict = self._validate_ticket_param(data)
                product_dict.update({'PRname': data.get('prname'),
                                     'PRimg': data.get('primg'),
                                     'PRdetails': data.get('prdetails'),
                                     # 'PRstatus': ProductStatus.ready.value if product_dict.get(
                                     #     'PRtimeLimeted') else ProductStatus.active.value,
                                     'PRstatus': ProductStatus.pending.value
                                     })
                self.base_approval.cancel_approval(product.PRid, request.user.id)  # 同时将正在进行的审批流改为取消
                if product.PRstatus == ProductStatus.interrupt.value:  # 中止的情况
                    current_app.logger.info('edit interrupt ticket')
                    product.update(product_dict, null='not')
                else:  # 已结束的情况,重新发起
                    current_app.logger.info('edit ended ticket')
                    product_dict.update({'PRid': str(uuid.uuid1()),
                                         'CreatorId': getattr(request, 'user').id,
                                         'CreatorType': getattr(request, 'user').model})
                    product = Product.create(product_dict)
                cancel_async_task('start_product{}'.format(product.PRid))
                cancel_async_task('end_product{}'.format(product.PRid))

                self.base_admin.create_action(AdminActionS.insert.value, 'Product', product.PRid)
            db.session.add(product)
        if approval_flag:
            self.base_approval.create_approval('toshelves', request.user.id, product.PRid, product_from)
        return Success('编辑成功', data={'prid': product.PRid})
Пример #18
0
 def validate_suid(self, raw):
     if is_supplizer():
         self.suid.data = request.user.id
     else:
         if not raw.data:
             raise ParamsError('供应商suid不可为空')
Пример #19
0
    def list(self):
        """供应商列表"""
        form = SupplizerListForm().valid_data()
        kw = form.kw.data
        mobile = form.mobile.data
        sustatus = form.sustatus.data
        option = form.option.data
        sugrade = form.sugrade.data
        # if sugrade is not None or sugrade:
        #     sugrade = int(sugrade)
        if str(sugrade).isdigit():
            sugrade = int(sugrade)
        else:
            sugrade = None

        if option == 'ticket':
            return self._list_ticket_sup()
        filter_args = {
            Supplizer.isdelete == false(),
        }
        if sugrade:
            filter_args.add(Supplizer.SUgrade == sugrade)
        if sustatus or sustatus == 0:
            filter_args.add(Supplizer.SUstatus == sustatus)
        if kw:
            filter_args.add(Supplizer.SUname.contains(kw))
        if mobile:
            filter_args.add(Supplizer.SUlinkPhone.contains(mobile))
        if is_supplizer():
            filter_args.add(Supplizer.SUid == getattr(request, 'user').id)
        supplizers = Supplizer.query.filter(*filter_args).order_by(
            Supplizer.createtime.desc()).all_with_page()

        for supplizer in supplizers:
            supplizer.hide('SUpassword')
            if is_admin():
                # pbs = ProductBrand.query.filter(
                #     ProductBrand.isdelete == False,
                #     ProductBrand.SUid == supplizer.SUid
                # ).all()
                # for pb in pbs:
                #     if pb:
                #         pb.pbstatus_zh = ProductBrandStatus(pb.PBstatus).zh_value
                #         pb.add('pbstatus_zh')
                pb = namedtuple('ProductBrand', [
                    'PBid', 'PBlogo', 'PBname', 'PBdesc', 'PBlinks',
                    'PBbackgroud', 'PBstatus', 'SUid', 'PBintegralPayRate',
                    'PBslogan', 'PBthemeColor', 'PBpublicity', 'PBsort'
                ])
                # pbs = [pb('', '', '', '', '', '', 0, '', 0, '', '', '', 1)]
                pbs = []
                supplizer.fill('pbs', pbs)
            # 收益
            favor = UserWallet.query.filter(
                UserWallet.isdelete == False,
                UserWallet.USid == supplizer.SUid,
                UserWallet.CommisionFor == ApplyFrom.supplizer.value).first()
            supplizer.fill('uwbalance', getattr(favor, 'UWbalance', 0))
            supplizer.fill('uwtotal', getattr(favor, 'UWtotal', 0))
            supplizer.fill('uwcash', getattr(favor, 'UWcash', 0))
            supplizer.fill('uwexpect', getattr(favor, 'UWexpect', 0))
            supplizer.fill('subaserate', 0)
            supplizer.fill('sustatus_zh',
                           UserStatus(supplizer.SUstatus).zh_value)
            supplizer.fill('sustatus_en', UserStatus(supplizer.SUstatus).name)
        return Success(data=supplizers)