예제 #1
0
class Searchall(StaffAuthorizedApi):
    """手机设备列表"""
    request = with_metaclass(RequestFieldSet)
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {

    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '手机设备列表', fmt = DictField(desc = "手机列表", conf = {
        'id': IntField(desc = "id"),
        'code': CharField(desc = "手机设备编码"),
    }))

    @classmethod
    def get_desc(cls):
        return "手机设备全部列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        mobile_devices_list = MobileDevicesServer.searchall(**request.search_info)

        return mobile_devices_list

    def fill(self, response, mobile_devices_list):
        response.data_list = [{
            'id': mobile_devices.id,
            'code': mobile_devices.code,
        } for mobile_devices in mobile_devices_list]
        return response
예제 #2
0
class Add(StaffAuthorizedApi):
    """添加手机设备"""
    request = with_metaclass(RequestFieldSet)
    request.mobile_devices_info = RequestField(DictField, desc = "手机设备信息", conf = {
        'code': CharField(desc = "手机设备编码"),
        'brand': CharField(desc = "手机品牌", is_required = False),
        'model': CharField(desc = "手机型号", is_required = False),
        'price': IntField(desc = "购买价格/分", is_required = False),
        'imei': CharField(desc = "手机imei号", is_required = False),
        'status': CharField(desc = "手机设备状态(normal:正常,scrap:报废,idle:闲置,other:其它)", is_required = False),
        'remark': CharField(desc = "备注", is_required = False),
    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "添加手机设备"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        MobileDevicesServer.is_code_exist(request.mobile_devices_info["code"])
        MobileDevicesServer.generate(**request.mobile_devices_info)

    def fill(self, response):
        return response
예제 #3
0
class List(StaffAuthorizedApi):
    """获取权限列表"""
    request = with_metaclass(RequestFieldSet)

    response = with_metaclass(ResponseFieldSet)
    response.rule_list = ResponseField(ListField, desc = '权限列表', fmt = DictField(desc = "权限", conf = {
        'flag': CharField(desc = "权限标示"),
        'desc': CharField(desc = "权限描述"),
    }))

    @classmethod
    def get_desc(cls):
        return "获取权限列表"

    @classmethod
    def get_author(cls):
        return "Roy"

    def execute(self, request):
        rule_mapping = rule_register.get_rule_mapping()
        return rule_mapping

    def fill(self, response, rule_mapping):
        keys = list(rule_mapping.keys())
        keys.sort()
        data_list = [{
            'flag': rule_mapping[key].all_key,
            'desc': rule_mapping[key].desc,
        } for key in keys]
        response.rule_list = data_list
        return response
예제 #4
0
class Add(StaffAuthorizedApi):
    """添加店铺"""
    request = with_metaclass(RequestFieldSet)
    request.shop_info = RequestField(DictField, desc = "店铺详情", conf = {
        'name': CharField(desc = "店铺名称"),
        'freight': IntField(desc = "运费/分", is_required = False),
        'single_repair_money': IntField(desc = "单次补单金额/分", is_required = False),
        'single_point_money': IntField(desc = "单次扣点金额/分", is_required = False),
        'is_distribution': BooleanField(desc = "是否为分销店铺(0否,1是)", is_required = False, choices = [(0, "是"), (1, "否")]),
        'channel_id': IntField(desc = "店铺渠道id", is_required = False),
        'remark': CharField(desc = "备注", is_required = False),
    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "店铺添加接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        ShopServer.is_name_exist(request.shop_info['name'])
        channel = ChannelServer.get(request.shop_info['channel_id'])
        request.shop_info.update({'channel': channel})
        ShopServer.generate(**request.shop_info)

    def fill(self, response):
        return response
예제 #5
0
class Add(StaffAuthorizedApi):
    """添加跟踪记录"""
    request = with_metaclass(RequestFieldSet)
    request.track_event_info = RequestField(DictField,
                                            desc="跟踪记录",
                                            conf={
                                                'customer_id':
                                                CharField(desc="客户id"),
                                                'remark':
                                                CharField(desc="备注说明"),
                                            })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "跟踪记录添加接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        staff = self.auth_user
        customer = CustomerServer.get(request.track_event_info['customer_id'])
        request.track_event_info.update({'staff': staff, 'customer': customer})
        TrackEventServer.generate(**request.track_event_info)

    def fill(self, response):
        return response
예제 #6
0
class Upload(StaffAuthorizedApi):
    """客户注册数据导入接口"""
    request = with_metaclass(RequestFieldSet)
    request._upload_files = RequestField(FileField, desc = "上传文件")

    response = with_metaclass(ResponseFieldSet)
    response.total = ResponseField(IntField, desc = "数据总数")
    response.error_list = ResponseField(ListField, desc = '错误列表', fmt = CharField(desc = "错误列表"))

    @classmethod
    def get_desc(cls):
        return "客户注册数据导入接口"

    @classmethod
    def get_author(cls):
        return "Roy"

    def execute(self, request):
        import_list, error_list = [], []
        for file_name, file_io in request._upload_files.items():
            print(file_name)
            # print(file_name, file_io.read())
            data_list, errors = import_register_middleware.import_register(file_io.read())
            import_list.extend(data_list)
            error_list.extend(errors)
        return import_list, error_list

    def fill(self, response, import_list, error_list):
        response.total = len(import_list)
        response.error_list = error_list
        return response
예제 #7
0
class Match(StaffAuthorizedApi):
    request = with_metaclass(RequestFieldSet)
    request.keyword = RequestField(CharField, desc = "匹配信息(店铺名称)")
    request.size = RequestField(IntField, desc = "返回数量")

    response = with_metaclass(ResponseFieldSet)
    response.match_list = ResponseField(ListField, desc = '店铺列表', fmt = DictField(desc = "店铺列表", conf = {
        'id': IntField(desc = "店铺id"),
        'name': CharField(desc = "店铺名称"),
    }))

    @classmethod
    def get_desc(cls):
        return "通过店铺渠道名称匹配渠道基础信息"

    @classmethod
    def get_author(cls):
        return "Fsy"

    def execute(self, request):
        shop_list = ShopServer.match(request.keyword, request.size)
        return shop_list

    def fill(self, response, shop_list):
        response.match_list = [{
            'id': shop.id,
            'name': shop.name,
        } for shop in shop_list]
        return response
예제 #8
0
class Renew(NoAuthrizedApi):
    """续签token"""
    request = with_metaclass(RequestFieldSet)
    request.auth_token = RequestField(CharField, desc="用户访问令牌")
    request.renew_flag = RequestField(CharField, desc="续签访问令牌标识")

    response = with_metaclass(ResponseFieldSet)
    response.auth_token = ResponseField(CharField, desc="用户访问令牌")
    response.renew_flag = ResponseField(CharField, desc="续签访问令牌标识")

    @classmethod
    def get_desc(cls):
        return "续签访问令牌"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        token = UserServer.renew_token(request.auth_token, request.renew_flag)
        return token

    def fill(self, response, token):
        response.auth_token = token.auth_token
        response.renew_flag = token.renew_flag
        return response
예제 #9
0
class Add(StaffAuthorizedApi):
    """添加员工绩效"""
    request = with_metaclass(RequestFieldSet)
    request.measure_staff_info = RequestField(DictField, desc = "员工绩效", conf = {
        'staff_id': IntField(desc = "客服id"),
        'new_number': IntField(desc = "当日新分数据,", is_required = False),
        'exhale_number': IntField(desc = "当日呼出数", is_required = False),
        'call_number': IntField(desc = "当日接通数", is_required = False),
        'wechat_number': IntField(desc = "添加微信数", is_required = False),
        'report_date': DateField(desc = "报表日期"),
        'remark': CharField(desc = "备注", is_required = False),
    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "员工绩效添加接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        record_staff = self.auth_user
        staff = StaffServer.get(request.measure_staff_info["staff_id"])
        request.measure_staff_info.update({'record': record_staff, 'staff':staff})
        MeasureStaffServer.generate(**request.measure_staff_info)

    def fill(self, response):
        return response
예제 #10
0
class Update(StaffAuthorizedApi):
    """编辑销售机会"""
    request = with_metaclass(RequestFieldSet)
    request.sale_chance_id = RequestField(IntField, desc="销售机会id")
    request.sale_chance_info = RequestField(DictField,
                                            desc="员工绩效详情",
                                            conf={
                                                'end_time':
                                                DateField(desc="截至时间",
                                                          is_required=False),
                                            })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "编辑销售机会接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        page_list = SaleChanceServer.update(request.sale_chance_id,
                                            **request.sale_chance_info)

    def fill(self, response, page_list):

        return response
예제 #11
0
class Match(StaffAuthorizedApi):
    request = with_metaclass(RequestFieldSet)
    request.keyword = RequestField(CharField, desc = "匹配信息(商品名称)")
    request.size = RequestField(IntField, desc = "返回数量")

    response = with_metaclass(ResponseFieldSet)
    response.match_list = ResponseField(ListField, desc = '商品列表', fmt = DictField(desc = "商品列表", conf = {
        'id': IntField(desc = "商品id"),
        'name': CharField(desc = "商品名称"),
    }))

    @classmethod
    def get_desc(cls):
        return "通过商品名称匹配商品基础信息"

    @classmethod
    def get_author(cls):
        return "Fsy"

    def execute(self, request):
        goods_list = GoodsServer.match(request.keyword, request.size)
        return goods_list

    def fill(self, response, goods_list):
        response.match_list = [{
            'id': goods.id,
            'name': goods.name,
        } for goods in goods_list]
        return response
예제 #12
0
class Update(StaffAuthorizedApi):
    """修改设备注册信息"""
    request = with_metaclass(RequestFieldSet)
    request.equipment_register_id = RequestField(IntField, desc = '设备注册id')
    request.equipment_register_info = RequestField(DictField, desc = "设备注册详情", conf = {
        'name': CharField(desc = "注册姓名"),
        'phone': CharField(desc = "注册手机号"),
    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "修改设备注册信息接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
       equipment_register = EquipmentRegisterServer.get(request.equipment_register_id)
       EquipmentRegisterServer.update(equipment_register, **request.equipment_register_info)
       if not ("*" in request.equipment_register_info["name"] or "*" in request.equipment_register_info["phone"]):
           service_item = ServiceItemServer.get_serviceitem_byequipment(equipment_register.equipment)
           print("----------")
           if service_item is not None:
               print("----------111111")
               ServiceItemServer.update(service_item, dsinfo_status = "green")

    def fill(self, response):
        return response
예제 #13
0
class Generate(StaffAuthorizedApi):
    """给员工生成账号"""
    request = with_metaclass(RequestFieldSet)
    request.staff_id = RequestField(IntField, desc = '员工id')
    request._ip = RequestField(CharField, desc = "IP")
    request.account_info = RequestField(DictField, desc = "账号详情", conf = {
        'username': CharField(desc = "账号"),
        'password': CharField(desc = "密码", is_required = False),
        'status': CharField(desc = "账号状态(enable:启用,lock:锁定,disable:禁用,notactive:待激活)"),
    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "给员工生成账号或修改接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        staff = StaffServer.get(request.staff_id)

        StaffAccountServer.register_account_bystaff(staff, request._ip, **request.account_info)

    def fill(self, response):
        return response
예제 #14
0
class Update(StaffAuthorizedApi):
    """设备入库数据修改"""
    request = with_metaclass(RequestFieldSet)
    request.equipment_in_id = RequestField(IntField, desc='设备入库信息id')
    request.equipment_in_info = RequestField(DictField,
                                             desc="设备入库信息详情",
                                             conf={
                                                 'min_number':
                                                 IntField(desc="起始号段",
                                                          is_required=False),
                                                 'max_number':
                                                 IntField(desc="终止号段",
                                                          is_required=False),
                                             })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "设备入库数据修改接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        import_equipment_in_middleware.update(request.equipment_in_id,
                                              **request.equipment_in_info)

    def fill(self, response):
        return response
예제 #15
0
class Update(StaffAuthorizedApi):
    """修改员工绩效信息"""
    request = with_metaclass(RequestFieldSet)
    request.measure_staff_id = RequestField(IntField, desc = '员工绩效id')
    request.measure_staff_info = RequestField(DictField, desc = "员工绩效详情", conf = {
        'staff_id': IntField(desc = "客服id"),
        'new_number': IntField(desc = "当日新分数据,", is_required = False),
        'exhale_number': IntField(desc = "当日呼出数", is_required = False),
        'call_number': IntField(desc = "当日接通数", is_required = False),
        'wechat_number': IntField(desc = "添加微信数", is_required = False),
        'report_date': DateField(desc = "报表日期"),
        'remark': CharField(desc = "备注", is_required = False),
    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "修改员工绩效接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
       MeasureStaffServer.update(request.measure_staff_id, **request.measure_staff_info)

    def fill(self, response):
        return response
예제 #16
0
class Add(StaffAuthorizedApi):
    """添加部门"""
    request = with_metaclass(RequestFieldSet)
    request.department_info = RequestField(DictField,
                                           desc="部门详情",
                                           conf={
                                               'name':
                                               CharField(desc="部门名称"),
                                               'parent_id':
                                               IntField(desc="上级部门id"),
                                               'describe':
                                               CharField(desc="部门描述",
                                                         is_required=False),
                                           })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "添加部门接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        DepartmentServer.is_name_exist(request.department_info['name'])
        DepartmentServer.add(**request.department_info)

    def fill(self, response):
        return response
예제 #17
0
class Update(StaffAuthorizedApi):
    """修改店铺信息"""
    request = with_metaclass(RequestFieldSet)
    request.shop_id = RequestField(IntField, desc = '店铺id')
    request.shop_info = RequestField(DictField, desc = "店铺详情", conf = {
        'name': CharField(desc = "店铺名称"),
        'freight': IntField(desc = "运费/分", is_required = False),
        'channel_id': IntField(desc = "店铺渠道id", is_required = False),
        'single_repair_money': CharField(desc = "单次补单金额/分", is_required = False),
        'single_point_money': CharField(desc = "单次扣点金额/分", is_required = False),
        'is_distribution': BooleanField(desc = "是否为分销店铺(0否,1是)", is_required = False),
        'remark': CharField(desc = "备注", is_required = False),

    })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "修改店铺接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        shop = ShopServer.get(request.shop_id)
        ShopServer.is_name_exist(request.shop_info["name"], shop)

        if 'channel_id' in request.shop_info:
            channel = ChannelServer.get(request.shop_info['channel_id'])
            request.shop_info.update({'channel': channel})
        ShopServer.update(shop, **request.shop_info)
    def fill(self, response):
        return response
예제 #18
0
class Search(StaffAuthorizedApi):
    """产品搜索列表"""
    request = with_metaclass(RequestFieldSet)
    #request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField,
                                       desc='搜索条件',
                                       conf={
                                           'id':
                                           CharField(desc="产品id",
                                                     is_required=False),
                                       })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(
        ListField,
        desc='产品列表',
        fmt=DictField(desc="产品列表",
                      conf={
                          'id':
                          IntField(desc="产品型号Id"),
                          'name':
                          CharField(desc="型号名称"),
                          'rate':
                          CharField(desc="默认费率表", is_required=False),
                          'remark':
                          CharField(desc="备注", is_required=False),
                          'stock':
                          CharField(desc="商品库存", is_required=False),
                          'create_time':
                          DatetimeField(desc="创建时间", is_required=False),
                      }))
    #response.total = ResponseField(IntField, desc = "数据总数")
    #response.total_page = ResponseField(IntField, desc = "总页码数")

    @classmethod
    def get_desc(cls):
        return "产品列表接口"

    @classmethod
    def get_author(cls):
        return "djd"

    def execute(self, request):
        #product_model_pages = ProductModelServer.search(request.current_page, **request.search_info)
        product_model_list = ProductModelServer.search(**request.search_info)
        return product_model_list

    def fill(self, response, product_model_list):
        response.data_list = [{
            'id': product.id,
            'name': product.name,
            'rate': product.rate,
            'remark': product.remark,
            'stock': product.stock,
            'create_time': product.create_time,
        } for product in product_model_list]
        #response.total = product_model_pages.total
        #response.total_page = product_model_pages.total_page
        return response
예제 #19
0
class Update(StaffAuthorizedApi):
    """修改产品详情"""
    request = with_metaclass(RequestFieldSet)
    request.product_info = RequestField(DictField,
                                        desc="用户详情",
                                        conf={
                                            'id':
                                            IntField(desc="商品ID"),
                                            'name':
                                            CharField(desc="商品名称",
                                                      is_required=False),
                                            'alias':
                                            CharField(desc="商品别名",
                                                      is_required=False),
                                            'introduction':
                                            CharField(desc="商品简介",
                                                      is_required=False),
                                            'details':
                                            CharField(desc="商品详情",
                                                      is_required=False),
                                            'thumbnail':
                                            CharField(desc="商品缩略图",
                                                      is_required=False),
                                            'images':
                                            CharField(desc="商品banner图",
                                                      is_required=False),
                                            'postage':
                                            IntField(desc="商品邮费/分",
                                                     is_required=False),
                                            'rebate_money':
                                            IntField(desc="返利金额/分",
                                                     is_required=False),
                                            'p_type':
                                            CharField(desc="类型",
                                                      is_required=False),
                                            'code':
                                            CharField(desc="编号",
                                                      is_required=False),
                                            'provider':
                                            CharField(desc="供应商",
                                                      is_required=False),
                                        })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "产品修改接口"

    @classmethod
    def get_author(cls):
        return "djd"

    def execute(self, request):
        ProductOperateServer.update(**request.product_info)

    def fill(self, response):
        return response
예제 #20
0
class Search(StaffAuthorizedApi):
    """客户注册数据列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'code': CharField(desc = "客户编码", is_required = False),
        'device_code': CharField(desc = "设备编码", is_required = False),
        'status': CharField(desc = "执行状态(初始化:init,执行中:excutting,已完成:finish,失败:failed)", is_required = False),
        'create_time_start': DatetimeField(desc = "上传开始时间", is_required = False),
        'create_time_end': DatetimeField(desc = "上传终止时间", is_required = False),
    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '客户注册数据列表', fmt = DictField(desc = "客户注册数据列表", conf = {
        'id': IntField(desc = "id"),
        'agent_name': CharField(desc = "代理商名称"),
        'code': CharField(desc = "客户编码"),
        'phone': CharField(desc = "注册手机号"),
        'name': CharField(desc = "客户姓名"),
        'register_time': DatetimeField(desc = "注册时间"),
        'bind_time': DatetimeField(desc = "绑定时间"),
        'device_code': CharField(desc = "设备编码"),
        'status': CharField(desc = "执行状态"),
        'create_time': DatetimeField(desc = "创建时间"),
        'error_text': CharField(desc = "错误提示"),
    }))
    response.total = ResponseField(IntField, desc = "数据总数")
    response.total_page = ResponseField(IntField, desc = "总页码数")

    @classmethod
    def get_desc(cls):
        return "客户注册数据列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        page_list = import_register_middleware.search(request.current_page, **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': register.id,
            'agent_name': register.agent_name,
            'code': register.code,
            'phone': register.phone,
            'name': register.name,
            'register_time': register.register_time,
            'bind_time': register.bind_time,
            'device_code': register.device_code,
            'status': register.status,
            'create_time': register.create_time,
            'error_text': register.error_text
        } for register in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
예제 #21
0
class Search(StaffAuthorizedApi):
    """商品列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'name': CharField(desc = "商品名称", is_required = False)
    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '商品列表', fmt = DictField(desc = "商品列表", conf = {
        'id': IntField(desc = "商品id"),
        'name': CharField(desc = "商品名称"),
        'alias': CharField(desc = "商品别名"),
        'code': CharField(desc = "商品编码"),
        'price': IntField(desc = "商品价格/分"),
        'rate': CharField(desc = "商品费率"),
        'introduction': CharField(desc = "商品简介"),
        'thumbnail': CharField(desc = "商品缩略图"),
        're_num': IntField(desc = "商品限购数量"),
        'shop_id': IntField(desc = "店铺id"),
        'shop_name': CharField(desc = "店铺名称"),
        'create_time': DatetimeField(desc = "创建时间"),
    }))
    response.total = ResponseField(IntField, desc = "数据总数")
    response.total_page = ResponseField(IntField, desc = "总页码数")

    @classmethod
    def get_desc(cls):
        return "商品列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        goods_page = GoodsServer.search(request.current_page, **request.search_info)

        return goods_page

    def fill(self, response, goods_page):
        response.data_list = [{
            'id': goods.id,
            'name': goods.name,
            'alias': goods.alias,
            'code': goods.code,
            'price': goods.price,
            'rate': goods.rate,
            'introduction': goods.introduction,
            'thumbnail': goods.thumbnail,
            're_num': goods.re_num,
            'shop_id': goods.shop.id if goods.shop else "",
            'shop_name': goods.shop.name if goods.shop else "",
            'create_time': goods.create_time,
        } for goods in goods_page.data]
        response.total = goods_page.total
        response.total_page = goods_page.total_page
        return response
예제 #22
0
class Test(NoAuthrizedApi):
    request = with_metaclass(RequestFieldSet)
    request.yrk = RequestField(CharField, desc = "hahahah110", choices = [('a',"account"), ('b',
                                                                                            'bass')])
    request.test = RequestField(CharField, desc = "hahahah110", choices = [('a',1), ('b', 2)])
    request.data = RequestField(DictField, desc = "hahahah110", conf = {
        'c1': CharField(desc="天天"),
        'c2': IntField(desc="数据"),
        'c3': DictField(desc="test", conf = {
            'test': IntField(desc="test")
         }),
    })
    request.data_list = RequestField(ListField, desc ='data_list110', fmt = IntField(desc = 'char list 2'))
    request.data_list_1 = RequestField(ListField, desc ='data_list110', fmt = DictField(desc = "hahahah110", conf = {
        'c1': CharField(desc="天天"),
        'c2': IntField(desc="数据")
    }))


    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc ='data_list110', fmt = IntField(desc = 'char list 2'))
    response.data2_list = ResponseField(ListField, desc ='data_list110', fmt = DictField(desc = "", conf ={
        'c1':IntField(desc = 'char list 2'),
        'c2':IntField(desc = 'char list 2')
    }))

    def execute(self, request):
        from tuoen.sys.log.base import logger
        logger.info(request.yrk)
        print(request.yrk)
        print(request.yrk___desc)
        print(request.data)
        print(request.data.c2)
        print(request.data_list)
        print(request.data_list_1)
        print(request.data_list_1[1].c2)
        data_list = ['1','2','3']
        data2_list = [
            {
                'c1':'123',
                'c2':'234',
            },
            {
                'c1':'51231',
                'c2':13412.12,
            }
        ]
        return data_list, data2_list

    def fill(self, response, data_list, data2_list):
        response.data_list = data_list
        response.data2_list = data2_list
        print(response.data_list)
        print(response.data2_list)
        print(response.data2_list[0].c1)
        return response
예제 #23
0
class Search(StaffAuthorizedApi):
    """店铺列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'name': CharField(desc = "关键字", is_required = False),
        'channel_id': IntField(desc = "店铺渠道id", is_required = False)
    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '店铺列表', fmt = DictField(desc = "店铺列表", conf = {
        'id': IntField(desc = "店铺id"),
        'name': CharField(desc = "店铺名称"),
        'freight': IntField(desc = "运费/分", is_required = False),
        'single_repair_money': IntField(desc = "单次补单金额/分"),
        'single_point_money': IntField(desc = "单次扣点金额/分"),
        'is_distribution': IntField(desc = "是否为分销店铺(0否,1是)"),
        'channel_id': CharField(desc = "渠道id"),
        'channel_name': CharField(desc = "渠道名称"),
        'remark': CharField(desc = "备注"),
        'update_time': DatetimeField(desc = "更新时间"),
        'create_time': DatetimeField(desc = "创建时间"),
    }))
    response.total = ResponseField(IntField, desc = "数据总数")
    response.total_page = ResponseField(IntField, desc = "总页码数")

    @classmethod
    def get_desc(cls):
        return "店铺列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        shop_page = ShopServer.search(request.current_page, **request.search_info)

        return shop_page

    def fill(self, response, shop_page):
        response.data_list = [{
            'id': shop.id,
            'name': shop.name,
            'freight': shop.freight,
            'single_repair_money': shop.single_repair_money,
            'single_point_money': shop.single_point_money,
            'is_distribution': shop.is_distribution,
            'channel_id': shop.channel.id if shop.channel else "",
            'channel_name': shop.channel.name if shop.channel else "",
            'remark': shop.remark,
            'update_time': shop.update_time,
            'create_time': shop.create_time,
        } for shop in shop_page.data]
        response.total = shop_page.total
        response.total_page = shop_page.total_page
        return response
예제 #24
0
class Search(StaffAuthorizedApi):
    """跟踪列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前查询页码")
    request.search_info = RequestField(
        DictField,
        desc='搜索条件',
        conf={'customer_id': IntField(desc="客户id", is_required=False)})

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField,
                                       desc='跟踪列表',
                                       fmt=DictField(
                                           desc="跟踪列表",
                                           conf={
                                               'id':
                                               IntField(desc="id"),
                                               'staff_id':
                                               IntField(desc="客服id"),
                                               'staff_name':
                                               CharField(desc="客服姓名"),
                                               'remark':
                                               CharField(desc="备注"),
                                               'create_time':
                                               DatetimeField(desc="记录时间"),
                                           }))
    response.total = ResponseField(IntField, desc="数据总数")
    response.total_page = ResponseField(IntField, desc="总页码数")

    @classmethod
    def get_desc(cls):
        return "跟踪列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        page_list = TrackEventServer.search(request.current_page,
                                            **request.search_info)

        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': track_event.id,
            'staff_id': track_event.staff.id,
            'staff_name': track_event.staff.name,
            'remark': track_event.remark,
            'create_time': track_event.create_time,
        } for track_event in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page

        return response
예제 #25
0
class Update(StaffAuthorizedApi):
    """手机号导入数据修改"""
    request = with_metaclass(RequestFieldSet)
    request.mobile_phone_id = RequestField(IntField, desc='手机号导入数据id')
    request.mobile_phone_info = RequestField(DictField,
                                             desc="手机号信息详情",
                                             conf={
                                                 'name':
                                                 CharField(desc="姓名",
                                                           is_required=False),
                                                 'identity':
                                                 CharField(desc="身份证号",
                                                           is_required=False),
                                                 'phone_number':
                                                 CharField(desc="手机号",
                                                           is_required=False),
                                                 'department':
                                                 CharField(desc="部门",
                                                           is_required=False),
                                                 'is_working':
                                                 CharField(desc="在职情况",
                                                           is_required=False),
                                                 'card_password':
                                                 CharField(desc="手机卡密码",
                                                           is_required=False),
                                                 'operator':
                                                 CharField(desc="运营商",
                                                           is_required=False),
                                                 'rent':
                                                 IntField(desc="月租",
                                                          is_required=False),
                                                 'phone_status':
                                                 CharField(desc="手机号状态",
                                                           is_required=False),
                                                 'phone_remark':
                                                 CharField(desc="手机号备注",
                                                           is_required=False),
                                             })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "手机号导入数据修改接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        import_mobile_phone_middleware.update(request.mobile_phone_id,
                                              **request.mobile_phone_info)

    def fill(self, response):
        return response
예제 #26
0
class Statistics(StaffAuthorizedApi):
    """员工绩效统计"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {

    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '员工绩效统计列表', fmt = DictField(desc = "员工绩效统计列表", conf = {
        'calculation_date': CharField(desc = "计算日期"),
        'new_number': IntField(desc = "当日新分数据"),
        'exhale_number': IntField(desc = "当日呼出数"),
        'call_number': IntField(desc = "当日接通数"),
        'call_rate': CharField(desc = "当日接通率"),
        'wechat_number': IntField(desc = "当日添加微信数"),
        'volume': IntField(desc = "当日成交量"),
        'conversion_rate': CharField(desc = "当日转化率"),
        'open_number': IntField(desc = "当日开通人数"),
        'open_rate': CharField(desc = "当日开通率"),
        'activation_number': IntField(desc = "当日激活人数"),
        'activation_rate': CharField(desc = "当日激活率"),
    }))

    @classmethod
    def get_desc(cls):
        return "员工绩效统计列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        staff = self.auth_user
        staff_list = StaffPermiseServer.get_all_children_staff(staff)
        staff_list.append(staff)

    def fill(self, response, statistics_list):

        response.data_list = [{
            'calculation_date':item["calculation_date"],
            'new_number':item["new_number"],
            'exhale_number': item["exhale_number"],
            'call_number': item["call_number"],
            'call_rate': item["call_rate"],
            'wechat_number': item["wechat_number"],
            'volume': item["volume"],
            'conversion_rate': item["conversion_rate"],
            'open_number': item["open_number"],
            'open_rate': item["open_rate"],
            'activation_number': item["activation_number"],
            'activation_rate': item["activation_rate"]
        } for item in statistics_list]
        return response
예제 #27
0
class SearchAll(StaffAuthorizedApi):
    """商品列表"""
    request = with_metaclass(RequestFieldSet)
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {

    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '商品列表', fmt = DictField(desc = "商品列表", conf = {
        'id': IntField(desc = "商品id"),
        'name': CharField(desc = "商品名称"),
        'alias': CharField(desc = "商品别名"),
        'code': CharField(desc = "商品编码"),
        'price': IntField(desc = "商品价格/分"),
        'rate': CharField(desc = "商品费率"),
        'introduction': CharField(desc = "商品简介"),
        'thumbnail': CharField(desc = "商品缩略图"),
        're_num': IntField(desc = "商品限购数量"),
        'shop_id': IntField(desc = "店铺id"),
        'shop_name': CharField(desc = "店铺名称"),
        'create_time': DatetimeField(desc = "创建时间"),
    }))

    @classmethod
    def get_desc(cls):
        return "搜索全部商品列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        goods_list = GoodsServer.search_all()

        return goods_list

    def fill(self, response, goods_list):

        response.data_list = [{
            'id': goods.id,
            'name': goods.name,
            'alias': goods.alias,
            'code': goods.code,
            'price': goods.price,
            'rate': goods.rate,
            'introduction': goods.introduction,
            'thumbnail': goods.thumbnail,
            're_num': goods.re_num,
            'shop_id': goods.shop.id if goods.shop else "",
            'shop_name': goods.shop.name if goods.shop else "",
            'create_time': goods.create_time,
        } for goods in goods_list]
        return response
예제 #28
0
class Update(StaffAuthorizedApi):
    """修改客户信息"""
    request = with_metaclass(RequestFieldSet)
    request.customer_id = RequestField(IntField, desc='客户id')
    request.customer_info = RequestField(DictField,
                                         desc="客户详情",
                                         conf={
                                             'name':
                                             CharField(desc="姓名",
                                                       is_required=False),
                                             'gender':
                                             CharField(desc="性别",
                                                       is_required=False),
                                             'birthday':
                                             CharField(desc="出身年月",
                                                       is_required=False),
                                             'email':
                                             CharField(desc="邮箱",
                                                       is_required=False),
                                             'phone':
                                             CharField(desc="手机号",
                                                       is_required=False),
                                             'wechat':
                                             CharField(desc="微信号",
                                                       is_required=False),
                                             'nick':
                                             CharField(desc="微信昵称",
                                                       is_required=False),
                                             'city':
                                             CharField(desc="城市",
                                                       is_required=False),
                                             'address':
                                             CharField(desc="详细地址",
                                                       is_required=False),
                                         })

    response = with_metaclass(ResponseFieldSet)

    @classmethod
    def get_desc(cls):
        return "修改客户信息接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        customer = CustomerServer.get(request.customer_id)
        CustomerServer.update(customer, **request.customer_info)

    def fill(self, response):
        return response
예제 #29
0
class Search(StaffAuthorizedApi):
    """手机设备列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'code': CharField(desc = "手机设备编码", is_required = False)
    })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField, desc = '手机设备列表', fmt = DictField(desc = "手机列表", conf = {
        'id': IntField(desc = "id"),
        'code': CharField(desc = "手机设备编码"),
        'brand': CharField(desc = "手机品牌"),
        'model': CharField(desc = "手机型号"),
        'price': IntField(desc = "购买价格/分"),
        'status': CharField(desc = "手机设备状态"),
        'imei': CharField(desc = "手机imei号"),
        'remark': CharField(desc = "备注"),
        'create_time': DatetimeField(desc = "添加时间"),
    }))
    response.total = ResponseField(IntField, desc = "数据总数")
    response.total_page = ResponseField(IntField, desc = "总页码数")

    @classmethod
    def get_desc(cls):
        return "手机设备列表接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        mobile_devices_page = MobileDevicesServer.search(request.current_page, **request.search_info)

        return mobile_devices_page

    def fill(self, response, mobile_devices_page):
        response.data_list = [{
            'id': mobile_devices.id,
            'code': mobile_devices.code,
            'brand': mobile_devices.brand,
            'model': mobile_devices.model,
            'price': mobile_devices.price,
            'status': mobile_devices.status,
            'imei': mobile_devices.imei,
            'remark': mobile_devices.remark,
            'create_time': mobile_devices.create_time,
        } for mobile_devices in mobile_devices_page.data]
        response.total = mobile_devices_page.total
        response.total_page = mobile_devices_page.total_page
        return response
예제 #30
0
class Get(StaffAuthorizedApi):
    """获取店铺绩效详情"""
    request = with_metaclass(RequestFieldSet)
    request.report_id = RequestField(IntField, desc='店铺绩效id')

    response = with_metaclass(ResponseFieldSet)
    response.report_info = ResponseField(DictField,
                                         desc="店铺绩效详情",
                                         conf={
                                             'id':
                                             IntField(desc="报表id"),
                                             'shop_id':
                                             IntField(desc="店铺id"),
                                             'total_sales':
                                             IntField(desc="销售总数"),
                                             'add_order_number':
                                             IntField(desc="补单数量"),
                                             'through_number':
                                             IntField(desc="直通车成交单数"),
                                             'through_money':
                                             IntField(desc="直通车总花费/分"),
                                             'record_date':
                                             DateField(desc="报表日期"),
                                             'remark':
                                             CharField(desc="备注"),
                                         })

    @classmethod
    def get_desc(cls):
        return "店铺绩效详情接口"

    @classmethod
    def get_author(cls):
        return "fsy"

    def execute(self, request):
        report = MeasureShopServer.get(request.report_id)
        return report

    def fill(self, response, report):
        response.report_info = {
            'id': report.id,
            'shop_id': report.shop.id,
            'total_sales': report.total_sales,
            'add_order_number': report.add_order_number,
            'through_number': report.through_number,
            'through_money': report.through_money,
            'record_date': report.record_date,
            'remark': report.remark,
        }
        return response