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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
class Get(StaffAuthorizedApi): """获取店铺渠道详情""" request = with_metaclass(RequestFieldSet) request.channel_id = RequestField(IntField, desc='店铺渠道id') response = with_metaclass(ResponseFieldSet) response.channel_info = ResponseField(DictField, desc="店铺渠道详情", conf={ 'id': IntField(desc="店铺渠道id"), 'name': CharField(desc="店铺渠道名称"), 'freight': IntField(desc="运费/分"), 'single_repair_money': IntField(desc="单次补单金额/分"), 'single_point_money': IntField(desc="单次扣点金额/分"), 'remark': CharField(desc="备注"), 'update_time': DatetimeField(desc="更新时间"), 'create_time': DatetimeField(desc="创建时间"), }) @classmethod def get_desc(cls): return "店铺渠道详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): channel = ChannelServer.get(request.channel_id) return channel def fill(self, response, channel): response.channel_info = { 'id': channel.id, 'name': channel.name, 'single_repair_money': channel.single_repair_money, 'single_point_money': channel.single_point_money, 'remark': channel.remark, 'update_time': channel.update_time, 'create_time': channel.create_time, } return response
class Get(StaffAuthorizedApi): """角色详情""" request = with_metaclass(RequestFieldSet) request.role_id = RequestField(IntField, desc='角色id') response = with_metaclass(ResponseFieldSet) response.role_info = ResponseField(DictField, desc="角色信息", conf={ 'id': IntField(desc="角色id"), 'name': CharField(desc="角色名称"), 'parent_id': IntField(desc="上级角色id"), 'describe': CharField(desc="角色描述"), 'status': BooleanField(desc="角色状态(0, 1)"), 'is_show_data': BooleanField(desc="是否显示下级数据(0, 1)"), 'rules': CharField(desc="权限") }) @classmethod def get_desc(cls): return "角色详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): role = role_middleware.get_self(request.role_id) return role def fill(self, response, role): response.role_info = { 'id': role.id, 'name': role.name, 'parent_id': role.parent_id, 'describe': role.describe, 'status': role.status, 'is_show_data': role.is_show_data, 'rules': role.rules } return response
class SearchAllFaker(StaffAuthorizedApi): """员工列表""" request = with_metaclass(RequestFieldSet) request.search_info = RequestField(DictField, desc='搜索条件', conf={ 'keyword': CharField(desc="关键词", is_required=False), 'is_working': 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="姓名"), 'number': CharField(desc="员工工号"), })) @classmethod def get_desc(cls): return "员工列表接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): cur_user = self.auth_user user_pro = UserRightServer(cur_user) request.search_info.update({"id__in": user_pro._staff_id_list}) staff_list = StaffServer.search_all(**request.search_info) return staff_list def fill(self, response, staff_list): response.data_list = [{ 'id': staff.id, 'name': staff.name, 'number': staff.number, } for staff in staff_list] return response
class SearchByTrack(StaffAuthorizedApi): """根据销售机会查询跟踪列表""" request = with_metaclass(RequestFieldSet) request.sale_chance_id = RequestField(IntField, desc="销售机会id") 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="记录时间"), })) @classmethod def get_desc(cls): return "根据销售机会查询跟踪列表" @classmethod def get_author(cls): return "fsy" def execute(self, request): sale_chance = SaleChanceServer.get(request.sale_chance_id) track_list = TrackEventServer.search_by_sale_chance(sale_chance) return track_list def fill(self, response, track_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 track_list] return response
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="店铺渠道名称"), 'freight': IntField(desc="运费/分"), 'single_repair_money': IntField(desc="单次补单金额/分"), 'single_point_money': IntField(desc="单次扣点金额/分"), })) @classmethod def get_desc(cls): return "搜索全部店铺渠道列表接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): channel_list = ChannelServer.search_all(**request.search_info) return channel_list def fill(self, response, channel_list): response.data_list = [{ 'id': channel.id, 'name': channel.name, 'freight': channel.freight, 'single_repair_money': channel.single_repair_money, 'single_point_money': channel.single_point_money, } for channel in channel_list] return response
class Get(StaffAuthorizedApi): """获取店铺详情""" request = with_metaclass(RequestFieldSet) request.shop_id = RequestField(IntField, desc = '店铺id') response = with_metaclass(ResponseFieldSet) response.shop_info = ResponseField(DictField, desc = "店铺详情", conf = { 'id': IntField(desc = "店铺id"), 'name': CharField(desc = "店铺名称"), 'freight': IntField(desc = "运费/分"), 'single_repair_money': IntField(desc = "单次补单金额/分"), 'single_point_money': IntField(desc = "单次扣点金额/分"), 'is_distribution': IntField(desc = "是否为分销店铺(0否,1是)"), 'channel_name': CharField(desc = "渠道名称"), 'remark': CharField(desc = "备注"), 'update_time': DatetimeField(desc = "更新时间"), 'create_time': DatetimeField(desc = "创建时间"), }) @classmethod def get_desc(cls): return "店铺详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): shop = ShopServer.get(request.shop_id) return shop def fill(self, response, shop): response.shop_info = { 'id': shop.id, 'name': shop.name, 'single_repair_money': shop.single_repair_money, 'single_point_money': shop.single_point_money, 'is_distribution': shop.is_distribution, 'channel_name': shop.channel.name, 'remark': shop.remark, 'update_time': shop.update_time, 'create_time': shop.create_time, } return response
class Get(StaffAuthorizedApi): """获取员工绩效详情""" request = with_metaclass(RequestFieldSet) request.measure_staff_id = RequestField(IntField, desc = '员工绩效id') response = with_metaclass(ResponseFieldSet) response.measure_staff_info = ResponseField(DictField, desc = "员工绩效详情", conf = { 'id':IntField(desc = "绩效id"), 'staff_id': IntField(desc = "员工id"), 'staff_name': CharField(desc = "员工姓名"), 'new_number': IntField(desc = "当日新分数据"), 'exhale_number': IntField(desc = "当日呼出数"), 'call_number': IntField(desc = "当日接通数"), 'wechat_number': IntField(desc = "添加微信数"), 'report_date': DateField(desc = "报表日期"), 'remark': CharField(desc = "备注"), }) @classmethod def get_desc(cls): return "员工绩效详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): measure_staff = MeasureStaffServer.get(request.measure_staff_id) return measure_staff def fill(self, response, measure_staff): response.measure_staff_info = { 'id':measure_staff.id, 'staff_id': measure_staff.staff.id, 'staff_name': measure_staff.staff.name, 'new_number': measure_staff.new_number, 'exhale_number': measure_staff.exhale_number, 'call_number': measure_staff.call_number, 'wechat_number': measure_staff.wechat_number, 'report_date': measure_staff.report_date, 'remark': measure_staff.remark, } return response
class List(StaffAuthorizedApi): """获取部门列表""" request = with_metaclass(RequestFieldSet) response = with_metaclass(ResponseFieldSet) response.data_list = ResponseField( ListField, desc='部门列表', fmt=DictField(desc="部门列表", conf={ 'id': IntField(desc="部门id"), 'name': CharField(desc="部门名称"), 'parent_id': IntField(desc="上级部门id"), 'parent_name': CharField(desc="上级部门名称"), 'describe': CharField(desc="部门描述"), 'status': BooleanField(desc="部门状态(0, 1)"), 'update_time': DatetimeField(desc="部门最后一次编辑时间"), })) @classmethod def get_desc(cls): return "部门列表接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): department_list = department_middleware.get_all_list() return department_list def fill(self, response, department_list): data_list = [{ 'id': department.id, 'name': department.name, 'parent_id': department.parent_id, 'parent_name': department.parent_id, 'describe': department.describe, 'status': department.status, 'update_time': department.update_time, } for department in department_list] response.data_list = data_list return response
class Get(StaffAuthorizedApi): """获取手机设备详情""" request = with_metaclass(RequestFieldSet) request.mobile_devices_id = RequestField(IntField, desc = '手机id') response = with_metaclass(ResponseFieldSet) response.mobile_devices_info = ResponseField(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 = "备注"), }) @classmethod def get_desc(cls): return "手机设备详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): mobile_devices = MobileDevicesServer.get(request.mobile_devices_id) return mobile_devices def fill(self, response, mobile_devices): response.mobile_devices_info = { '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, } return response
class Get(StaffAuthorizedApi): """获取个人中心详情""" request = with_metaclass(RequestFieldSet) response = with_metaclass(ResponseFieldSet) response.user_info = ResponseField(DictField, desc="用户详情", conf={ 'name': CharField(desc="姓名"), 'identity': CharField(desc="身份证"), 'gender': CharField(desc="性别"), 'birthday': CharField(desc="生日"), 'phone': CharField(desc="电话"), 'email': CharField(desc="邮箱"), 'number': CharField(desc="员工工号"), 'is_admin': BooleanField(desc="是否是管理员"), }) @classmethod def get_desc(cls): return "员工个人中心详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): return self.auth_user def fill(self, response, staff): response.user_info = { 'name': staff.name, 'identity': staff.identity, 'gender': staff.gender, 'birthday': staff.birthday, 'phone': staff.phone, 'email': staff.email, 'number': staff.number, 'is_admin': staff.is_admin } return response
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="店铺渠道名称"), 'single_repair_money': IntField(desc="单次补单金额/分"), 'single_point_money': IntField(desc="单次扣点金额/分"), })) @classmethod def get_desc(cls): return "通过店铺渠道名称匹配渠道基础信息" @classmethod def get_author(cls): return "Fsy" def execute(self, request): channel_list = ChannelServer.match(request.keyword, request.size) return channel_list def fill(self, response, channel_list): response.match_list = [{ 'id': channel.id, 'name': channel.name, 'single_repair_money': channel.name, 'single_point_money': channel.name, } for channel in channel_list] return response
class List(StaffAuthorizedApi): """获取角色列表""" request = with_metaclass(RequestFieldSet) response = with_metaclass(ResponseFieldSet) response.data_list = ResponseField( ListField, desc='角色列表', fmt=DictField(desc="角色列表", conf={ 'id': IntField(desc="角色id"), 'name': CharField(desc="角色名称"), 'parent_id': IntField(desc="上级角色id"), 'describe': CharField(desc="角色描述"), 'status': BooleanField(desc="角色状态(0, 1)"), 'update_time': DatetimeField(desc="角色最后一次编辑时间"), })) @classmethod def get_desc(cls): return "角色列表接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): role_list = role_middleware.get_all_list() return role_list def fill(self, response, role_list): data_list = [{ 'id': role.id, 'name': role.name, 'parent_id': role.parent_id, 'describe': role.describe, 'status': role.status, 'update_time': role.update_time, } for role in role_list] response.data_list = data_list return response
class Match(StaffAuthorizedApi): request = with_metaclass(RequestFieldSet) request.keyword = RequestField(CharField, desc="匹配信息") request.size = RequestField(IntField, desc="返回数量", is_required=False) response = with_metaclass(ResponseFieldSet) response.match_list = ResponseField(ListField, desc='账号列表', fmt=DictField( desc="账号列表", conf={ 'id': IntField(desc="员工id"), 'name': CharField(desc="姓名"), 'gender': CharField(desc="性别"), 'number': CharField(desc="工号"), 'phone': CharField(desc="手机号"), })) @classmethod def get_desc(cls): return "通过员工部分姓名匹配员工基础信息" @classmethod def get_author(cls): return "Roy" def execute(self, request): staff_list = StaffServer.match(request.keyword, request.size) return staff_list def fill(self, response, staff_list): response.match_list = [{ 'id': staff.id, 'name': staff.name, 'gender': staff.gender, 'number': staff.number, 'phone': staff.phone, 'email': staff.email, } for staff in staff_list] return response
class Get(StaffAuthorizedApi): """部门详情""" request = with_metaclass(RequestFieldSet) request.department_id = RequestField(IntField, desc='部门id') response = with_metaclass(ResponseFieldSet) response.department_info = ResponseField(DictField, desc="部门信息", conf={ 'id': IntField(desc="部门id"), 'name': CharField(desc="部门名称"), 'parent_id': IntField(desc="上级部门id"), 'describe': CharField(desc="部门描述"), }) @classmethod def get_desc(cls): return "部门详情接口" @classmethod def get_author(cls): return "fsy" def execute(self, request): department = department_middleware.get_self(request.department_id) return department def fill(self, response, department): response.department_info = { 'id': department.id, 'name': department.name, 'parent_id': department.parent_id, 'describe': department.describe, } return response