Example #1
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
Example #2
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
Example #3
0
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
Example #4
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
Example #5
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
Example #6
0
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
Example #7
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
Example #8
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
Example #9
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
Example #10
0
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
Example #11
0
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
Example #12
0
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
Example #13
0
class Update(StaffAuthorizedApi):
    """客户购买数据修改"""
    request = with_metaclass(RequestFieldSet)
    request.buyinfo_id = RequestField(IntField, desc = '购买信息id')
    request.buyinfo_info = RequestField(DictField, desc = "购买详情", conf = {
        'order_sn': CharField(desc = "订单编号"),
        'goods_sn': CharField(desc = "商品编号"),
        'buy_number': IntField(desc = "购买数量"),
        'buy_money': IntField(desc = "订单金额/分"),
        'pay_time': DatetimeField(desc = "付款时间"),
        'shop_name': CharField(desc = "网点名称"),
        'buy_name': CharField(desc = "买家姓名"),
        'province': CharField(desc = "省"),
        'city': CharField(desc = "市"),
        'area': CharField(desc = "区"),
        'address': CharField(desc = "详细地址"),
        'logistics_company': CharField(desc = "物流公司"),
        'logistics_code': CharField(desc = "物流单号"),
        'buy_phone': CharField(desc = "联系方式"),
        'buy_nick': CharField(desc = "卖家账号"),
        'remark': CharField(desc = "客服备注", is_required = False),
        'device_code': 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_buyinfo_middleware.update(request.buyinfo_id, **request.buyinfo_info)

    def fill(self, response):
        return response
Example #14
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),
            '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="代理商名称"),
                                               'service_code':
                                               CharField(desc="服务编码"),
                                               'code':
                                               CharField(desc="客户编码"),
                                               'phone':
                                               CharField(desc="手机号"),
                                               'transaction_year':
                                               DateField(desc="交易日期"),
                                               'transaction_day':
                                               CharField(desc="交易时间"),
                                               'transaction_code':
                                               CharField(desc="流水编号"),
                                               'transaction_money':
                                               IntField(desc="交易金额"),
                                               'fee':
                                               IntField(desc="手续费/分"),
                                               'rate':
                                               IntField(desc="客户费率"),
                                               'other_fee':
                                               IntField(desc="其他手续费/分"),
                                               'transaction_status':
                                               CharField(desc="交易状态"),
                                               'type':
                                               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_transaction_middleware.search(
            request.current_page, **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': transaction.id,
            'agent_name': transaction.agent_name,
            'service_code': transaction.service_code,
            'code': transaction.code,
            'phone': transaction.phone,
            'transaction_year': transaction.transaction_year,
            'transaction_day': transaction.transaction_day,
            'transaction_code': transaction.transaction_code,
            'transaction_money': transaction.transaction_money,
            'fee': transaction.fee,
            'rate': transaction.rate,
            'other_fee': transaction.other_fee,
            'transaction_status': transaction.transaction_status,
            'type': transaction.type,
            'status': transaction.status,
            'create_time': transaction.create_time,
            'error_text': transaction.error_text,
        } for transaction in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #15
0
class Search(StaffAuthorizedApi):
    """设备入库数据列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前查询页码")
    request.search_info = RequestField(
        DictField,
        desc='搜索条件',
        conf={
            'add_time':
            DateField(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"),
                                               'add_time':
                                               CharField(desc="添加时间"),
                                               'agent_name':
                                               CharField(desc="代理商名称"),
                                               'product_type':
                                               CharField(desc="产品类型"),
                                               'product_model':
                                               CharField(desc="产品型号"),
                                               'min_number':
                                               CharField(desc="起始号段"),
                                               'max_number':
                                               CharField(desc="终止号段"),
                                               'quantity':
                                               CharField(desc="入库数量"),
                                               'status':
                                               CharField(desc="状态"),
                                               'remark':
                                               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_equipment_in_middleware.search(
            request.current_page, **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': equipmentin.id,
            'add_time': equipmentin.add_time,
            'agent_name': equipmentin.agent_name,
            'product_type': equipmentin.product_type,
            'product_model': equipmentin.product_model,
            'min_number': equipmentin.min_number,
            'max_number': equipmentin.max_number,
            'quantity': equipmentin.quantity,
            'status': equipmentin.status,
            'remark': equipmentin.remark,
            'create_time': equipmentin.create_time,
            'error_text': equipmentin.error_text
        } for equipmentin in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #16
0
class Search(StaffAuthorizedApi):
    """手机设备导入数据列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'mobile_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"),
        'group_leader': CharField(desc = "组长姓名"),
        'mobile_code': CharField(desc = "手机编号"),
        'group_member': CharField(desc = "组员姓名"),
        'wechat_nick': CharField(desc = "微信昵称"),
        'wechat_number': CharField(desc = "微信号"),
        'wechat_password': CharField(desc = "微信密码"),
        'pay_password': CharField(desc = "微信支付密码"),
        'wechat_remark': CharField(desc = "微信号备注"),
        'department': CharField(desc = "部门"),
        'phone_number': CharField(desc = "手机号"),
        'operator': CharField(desc = "运营商"),
        'real_name': CharField(desc = "实名人姓名"),
        'phone_remark': CharField(desc = "手机号备注"),
        'flow_card_number': CharField(desc = "流量卡号"),
        'imei': CharField(desc = "手机imei号"),
        'brand': CharField(desc = "手机品牌"),
        'model': CharField(desc = "手机型号"),
        'price': IntField(desc = "购买价格/分"),
        'mobile_status': CharField(desc = "手机设备状态"),
        'mobile_remark': CharField(desc = "手机设备备注"),
        'phone_change': 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_mobile_devices_middleware.search(request.current_page, **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': mobile_devices.id,
            'group_leader': mobile_devices.group_leader,
            'mobile_code': mobile_devices.mobile_code,
            'group_member': mobile_devices.group_member,
            'wechat_nick': mobile_devices.wechat_nick,
            'wechat_number': mobile_devices.wechat_number,
            'wechat_password': mobile_devices.wechat_password,
            'pay_password': mobile_devices.pay_password,
            'wechat_remark': mobile_devices.wechat_remark,
            'department': mobile_devices.department,
            'phone_number': mobile_devices.phone_number,
            'operator': mobile_devices.operator,
            'real_name': mobile_devices.real_name,
            'phone_remark': mobile_devices.phone_remark,
            'flow_card_number': mobile_devices.flow_card_number,
            'imei': mobile_devices.imei,
            'brand': mobile_devices.brand,
            'model': mobile_devices.model,
            'price': mobile_devices.price,
            'mobile_status': mobile_devices.mobile_status,
            'mobile_remark': mobile_devices.mobile_remark,
            'phone_change': mobile_devices.phone_change,
            'status': mobile_devices.status,
            'create_time': mobile_devices.create_time,
            'error_text': mobile_devices.error_text,
        } for mobile_devices in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #17
0
class Search(StaffAuthorizedApi):
    """员工搜索列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前查询页码")
    request.search_info = RequestField(DictField,
                                       desc='搜索条件',
                                       conf={
                                           'keyword':
                                           CharField(desc="关键词",
                                                     is_required=False),
                                           'department':
                                           IntField(desc="部门查询",
                                                    is_required=False),
                                           'role':
                                           IntField(desc="角色查询",
                                                    is_required=False),
                                           'is_working':
                                           BooleanField(desc="是否在职",
                                                        is_required=False),
                                       })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(
        ListField,
        desc='员工列表',
        fmt=DictField(desc="员工列表",
                      conf={
                          'id':
                          IntField(desc="员工id"),
                          'username':
                          CharField(desc="账号"),
                          'name':
                          CharField(desc="姓名"),
                          'gender':
                          CharField(desc="性别"),
                          'number':
                          CharField(desc="工号"),
                          'phone':
                          CharField(desc="手机号"),
                          'email':
                          CharField(desc="邮箱"),
                          'status':
                          CharField(desc="账号状态"),
                          'birthday':
                          DateField(desc="生日"),
                          'identity':
                          CharField(desc="身份证"),
                          'address':
                          CharField(desc="家庭住址"),
                          'emergency_contact':
                          CharField(desc="紧急联系人"),
                          'emergency_phone':
                          CharField(desc="紧急联系人电话"),
                          'entry_time':
                          DateField(desc="入职时间"),
                          'education':
                          CharField(desc="学历"),
                          'bank_number':
                          CharField(desc="招行卡号"),
                          'contract_b':
                          CharField(desc="合同编号(必)"),
                          'contract_l':
                          CharField(desc="合同编号(立)"),
                          'expire_time':
                          DateField(desc="到期时间"),
                          'quit_time':
                          DateField(desc="离职时间"),
                          'is_working':
                          IntField(desc="是否在职(0离职,1在职)"),
                          'last_login_time':
                          DatetimeField(desc="最后登陆时间"),
                          'last_login_ip':
                          CharField(desc="最后登陆ip"),
                          'role_list':
                          ListField(desc='所属角色',
                                    fmt=DictField(desc="角色信息",
                                                  conf={
                                                      'role_id':
                                                      IntField(desc="角色id"),
                                                      'role_name':
                                                      CharField(desc="角色名称"),
                                                  })),
                          'department_list':
                          ListField(desc='所属部门',
                                    fmt=DictField(desc="部门信息",
                                                  conf={
                                                      'department_id':
                                                      IntField(desc="部门id"),
                                                      'department_name':
                                                      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):
        cur_user = self.auth_user
        user_pro = UserRightServer(cur_user)
        request.search_info['cur_user'] = user_pro
        staff_pages = StaffServer.search(request.current_page,
                                         **request.search_info)
        staff_list = StaffPermiseServer.hung_permise_forstaffs(
            staff_pages.data)
        staff_list = StaffAccountServer.hung_account_forstaffs(staff_list)
        staff_pages.data = staff_list
        return staff_pages

    def fill(self, response, staff_pages):
        response.data_list = [{
            'id':
            staff.id,
            'username':
            staff.account.username if staff.account else "",
            'name':
            staff.name,
            'gender':
            staff.gender,
            'number':
            staff.number,
            'phone':
            staff.phone,
            'email':
            staff.email,
            'status':
            staff.account.status if staff.account else "",
            'birthday':
            staff.birthday if staff.birthday else "",
            'identity':
            staff.identity,
            'emergency_contact':
            staff.emergency_contact,
            'emergency_phone':
            staff.emergency_phone,
            'address':
            staff.address,
            'entry_time':
            staff.entry_time if staff.entry_time else "",
            'education':
            staff.education,
            'bank_number':
            staff.bank_number,
            'contract_b':
            staff.contract_b,
            'contract_l':
            staff.contract_l,
            'expire_time':
            staff.expire_time if staff.expire_time else "",
            'quit_time':
            staff.quit_time if staff.quit_time else "",
            'is_working':
            staff.is_working,
            'last_login_time':
            staff.account.last_login_time
            if staff.account and staff.account.last_login_time else "",
            'last_login_ip':
            staff.account.last_login_ip if staff.account else "",
            'role_list': [{
                'role_id': role.id,
                'role_name': role.name
            } for role in staff.role_list],
            'department_list': [{
                'department_id': department.id,
                'department_name': department.name
            } for department in staff.department_list]
        } for staff in staff_pages.data]
        response.total = staff_pages.total
        response.total_page = staff_pages.total_page
        return response
Example #18
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),
            '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_id':
                                               CharField(desc="代理商ID"),
                                               'agent_name':
                                               CharField(desc="代理商名称"),
                                               'code':
                                               CharField(desc="客户编码"),
                                               'name':
                                               CharField(desc="客户名称"),
                                               'phone':
                                               CharField(desc="注册手机号"),
                                               'activity_type':
                                               CharField(desc="活动类型"),
                                               'device_code':
                                               CharField(desc="设备编码"),
                                               'register_time':
                                               DatetimeField(desc="注册时间"),
                                               'bind_time':
                                               DatetimeField(desc="绑定时间"),
                                               'month':
                                               DateField(desc="交易月份"),
                                               'transaction_amount':
                                               IntField(desc="交易金额/分"),
                                               'effective_amount':
                                               IntField(desc="有效金额/分"),
                                               'accumulate_amount':
                                               IntField(desc="当月累计交易金额/分"),
                                               'history_amount':
                                               IntField(desc="历史累计交易金额/分"),
                                               'type':
                                               CharField(desc="号段类型"),
                                               'is_rebate':
                                               CharField(desc="是否返利"),
                                               'status':
                                               CharField(desc="状态"),
                                               'remark':
                                               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_rebate_middleware.search(request.current_page,
                                                    **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': rebate.id,
            'agent_id': rebate.agent_id,
            'agent_name': rebate.agent_name,
            'code': rebate.code,
            'name': rebate.name,
            'phone': rebate.phone,
            'activity_type': rebate.activity_type,
            'device_code': rebate.device_code,
            'register_time': rebate.register_time,
            'bind_time': rebate.bind_time,
            'month': rebate.month,
            'transaction_amount': rebate.transaction_amount,
            'effective_amount': rebate.effective_amount,
            'accumulate_amount': rebate.accumulate_amount,
            'history_amount': rebate.history_amount,
            'type': rebate.type,
            'is_rebate': rebate.is_rebate,
            'status': rebate.status,
            'remark': rebate.remark,
            'create_time': rebate.create_time,
            'error_text': rebate.error_text,
        } for rebate in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #19
0
class Search(StaffAuthorizedApi):
    """员工绩效列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'staff_name': CharField(desc = "员工姓名", is_required = False),
        'begin_time': DateField(desc = "开始时间", is_required = False),
        'end_time': DateField(desc = "结束时间", is_required = False),
    })

    response = with_metaclass(ResponseFieldSet)
    response.sum_data = ResponseField(DictField, desc = "员工绩效统计", conf = {
        'new_number': IntField(desc = "当日新分数据"),
        'exhale_number': IntField(desc = "当日呼出数"),
        'call_number': IntField(desc = "当日接通数"),
        'wechat_number': IntField(desc = "添加微信数"),
        'call_rate': CharField(desc = "当日接通率"),
        'volume': IntField(desc = "当日成交量"),
        'conversion_rate': CharField(desc = "当日转化率"),
        'open_number': IntField(desc = "当日开通人数"),
        'open_rate': CharField(desc = "当日开通率"),
        'activation_number': IntField(desc = "当日激活人数"),
        'activation_rate': CharField(desc = "当日激活率"),
    })
    response.data_list = ResponseField(ListField, desc = '员工绩效列表', fmt = DictField(desc = "员工绩效列表", conf = {
        'id':IntField(desc = "绩效id"),
        'staff_id': IntField(desc = "员工id"),
        'staff_name': CharField(desc = "员工姓名"),
        'record_id': IntField(desc = "记录人id"),
        'record_name': CharField(desc = "记录人姓名"),
        'new_number': IntField(desc = "当日新分数据"),
        'exhale_number': IntField(desc = "当日呼出数"),
        'call_number': IntField(desc = "当日接通数"),
        'call_rate': CharField(desc = "当日接通率"),
        'wechat_number': IntField(desc = "添加微信数"),
        'report_date': DateField(desc = "报表日期"),
        'create_time': DatetimeField(desc = "添加日期"),
        'remark': CharField(desc = "备注"),
        'volume': IntField(desc = "当日成交量"),
        'conversion_rate': CharField(desc = "当日转化率"),
        'open_number': IntField(desc = "当日开通人数"),
        'open_rate': CharField(desc = "当日开通率"),
        'activation_number': IntField(desc = "当日激活人数"),
        'activation_rate': 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):
        if "staff_name" in request.search_info:
            staff_name = request.search_info.pop("staff_name")
            staff_list = StaffServer.search_all(name = staff_name)
            request.search_info.update({"staff__in":staff_list})
        cur_user = self.auth_user
        user_pro = UserRightServer(cur_user)
        request.search_info['cur_user'] = user_pro
        measure_staff_qs = MeasureStaffServer.search_qs(**request.search_info)
        sum_data = MeasureStaffServer.summing(measure_staff_qs)

        page_list = MeasureStaffServer.search(request.current_page, measure_staff_qs)

        MeasureStaffServer.calculation(page_list.data)

        sum_measure_data = ServiceItemServer.summing(sum_data, **request.search_info)
        ServiceItemServer.huang_serviceitem_rate(page_list.data)

        return sum_data, sum_measure_data, page_list

    def fill(self, response, sum_data, sum_measure_data, page_list):
        response.sum_data = {
             'new_number': sum_data.new_number,
             'exhale_number': sum_data.exhale_number,
             'call_number': sum_data.call_number,
             'wechat_number': sum_data.wechat_number,
             'call_rate': sum_data.call_rate,
             'volume': sum_measure_data.volume_total,
             'conversion_rate': sum_measure_data.conversion_rate_total,
             'open_number': sum_measure_data.open_number_total,
             'open_rate': sum_measure_data.open_rate_total,
             'activation_number': sum_measure_data.activation_number_total,
             'activation_rate': sum_measure_data.activation_rate_total,
        }
        response.data_list = [{
            'id':measure_staff.id,
            'staff_id': measure_staff.staff.id if measure_staff.staff else 0,
            'staff_name': measure_staff.staff.name if measure_staff.staff else "",
            'record_id': measure_staff.record.id if measure_staff.record else 0,
            'record_name': measure_staff.record.name if measure_staff.record else "",
            'new_number': measure_staff.new_number,
            'exhale_number': measure_staff.exhale_number,
            'call_number': measure_staff.call_number,
            'call_rate': measure_staff.call_rate,
            'wechat_number': measure_staff.wechat_number,
            'report_date': measure_staff.report_date,
            'create_time': measure_staff.create_time,
            'remark': measure_staff.remark,
            'volume': measure_staff.volume,
            'conversion_rate': measure_staff.conversion_rate,
            'open_number': measure_staff.open_number,
            'open_rate': measure_staff.open_rate,
            'activation_number': measure_staff.activation_number,
            'activation_rate': measure_staff.activation_rate,
        } for measure_staff in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #20
0
class Get(StaffAuthorizedApi):
    """获取客户详情"""
    request = with_metaclass(RequestFieldSet)
    request.customer_id = RequestField(IntField, desc='客户id')

    response = with_metaclass(ResponseFieldSet)
    response.customer_info = ResponseField(DictField,
                                           desc="客户详情",
                                           conf={
                                               'id':
                                               IntField(desc="id"),
                                               'name':
                                               CharField(desc="姓名"),
                                               'gender':
                                               CharField(desc="性别"),
                                               'birthday':
                                               CharField(desc="出身年月"),
                                               'email':
                                               CharField(desc="邮箱"),
                                               'phone':
                                               CharField(desc="手机号"),
                                               'wechat':
                                               CharField(desc="微信号"),
                                               'city':
                                               CharField(desc="城市"),
                                               'address':
                                               CharField(desc="详细地址"),
                                               'mobilephone':
                                               CharField(desc="设备编码"),
                                               'create_time':
                                               DatetimeField(desc="进入时间"),
                                           })

    @classmethod
    def get_desc(cls):
        return "客户详情接口"

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

    def execute(self, request):
        customer = CustomerServer.get(request.customer_id)
        # 挂载跟踪行为

        return customer

    def fill(self, response, customer):
        response.customer_info = {
            'id':
            customer.id,
            'name':
            customer.name,
            'gender':
            customer.gender,
            'birthday':
            customer.birthday,
            'email':
            customer.email,
            'phone':
            customer.phone,
            'wechat':
            customer.wechat,
            'city':
            customer.city,
            'address':
            customer.address,
            'mobilephone':
            customer.mobiledevices.code if customer.mobiledevices else "",
            'create_time':
            customer.create_time,
        }
        return response
Example #21
0
class Search(StaffAuthorizedApi):
    """订单列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前查询页码")
    request.search_info = RequestField(
        DictField,
        desc='搜索条件',
        conf={
            'order_sn':
            CharField(desc="订单号", is_required=False),
            'status':
            CharField(
                desc=
                "订单状态(unpaid:未支付,submit:已下单,payed:已支付,sended:已发货,finished:已完成)",
                is_required=False),
        })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(
        ListField,
        desc='订单列表',
        fmt=DictField(desc="订单列表",
                      conf={
                          'id':
                          IntField(desc="id"),
                          'order_sn':
                          CharField(desc="订单编号"),
                          'shop_name':
                          CharField(desc="店铺名称"),
                          'consignee':
                          CharField(desc="收货人"),
                          'nick_name':
                          CharField(desc="昵称"),
                          'status':
                          CharField(desc="订单状态"),
                          'create_time':
                          DatetimeField(desc="添加时间"),
                          'order_items':
                          ListField(desc='订单详情',
                                    fmt=DictField(desc="订单详情",
                                                  conf={
                                                      'name':
                                                      CharField(desc="商品名称"),
                                                      'thumbnail':
                                                      CharField(desc="商品缩略图"),
                                                      'rate':
                                                      CharField(desc="商品费率"),
                                                      'quantity':
                                                      IntField(desc="商品数量"),
                                                      'type':
                                                      CharField(desc="商品分类"),
                                                      'brand_name':
                                                      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):
        staff = self.auth_user
        user_pro = UserRightServer(staff)
        request.search_info['cur_user'] = user_pro
        if staff.is_admin == 1:
            page_list = OrderServer.search(request.current_page,
                                           **request.search_info)
        else:

            staff_list = StaffPermiseServer.get_all_children_staff(staff)
            staff_list.append(staff)
            page_list = ServiceServer.search(request.current_page,
                                             seller__in=staff_list,
                                             cur_user=user_pro)
            order_list = OrderServer.get_order_byservice(page_list.data)
            page_list.data = order_list

        page_list.data = OrderItemServer.hung_item_fororders(page_list.data)

        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id':
            order.id,
            'order_sn':
            order.order_sn,
            'shop_name':
            order.shop.name,
            'consignee':
            order.consignee,
            'nick_name':
            order.customer.nick,
            'status':
            order.status,
            'create_time':
            order.create_time,
            'order_items': [{
                'name':
                order_item.name,
                'thumbnail':
                order_item.thumbnail,
                'rate':
                order_item.rate,
                'quantity':
                order_item.quantity,
                'type':
                order_item.type,
                'brand_name':
                order_item.goods.product_model.name
                if order_item.goods and order_item.goods.product_model else "",
            } for order_item in order.items]
        } for order in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #22
0
class Get(StaffAuthorizedApi):
    """获取订单详情"""
    request = with_metaclass(RequestFieldSet)
    request.order_id = RequestField(IntField, desc='订单id')

    response = with_metaclass(ResponseFieldSet)
    response.order_info = ResponseField(
        DictField,
        desc="订单详情",
        conf={
            'id':
            IntField(desc="id"),
            'order_sn':
            CharField(desc="订单编号"),
            'consignee':
            CharField(desc="收货人"),
            'nick_name':
            CharField(desc="昵称"),
            'phone':
            CharField(desc="收货人电话"),
            'city':
            CharField(desc="城市"),
            'address':
            CharField(desc="详细地址"),
            'messages':
            CharField(desc="买家留言"),
            'paytype':
            CharField(desc="支付类型"),
            'pay_time':
            CharField(desc="付款时间"),
            'transaction_id':
            CharField(desc="第三方支付id"),
            'total_price':
            IntField(desc="订单金额"),
            'channel_name':
            CharField(desc="渠道名称"),
            'shop_name':
            CharField(desc="店铺名称"),
            'create_time':
            CharField(desc="创建时间"),
            'remark':
            CharField(desc="卖家备注"),
            'order_items':
            ListField(desc='订单详情',
                      fmt=DictField(desc="订单详情",
                                    conf={
                                        'name': CharField(desc="商品名称"),
                                        'thumbnail': CharField(desc="商品缩略图"),
                                        'rate': CharField(desc="商品费率"),
                                        'price': IntField(desc="商品单价"),
                                        'type': CharField(desc="商品类型"),
                                        'brand_name': CharField(desc="商品型号"),
                                        'quantity': IntField(desc="商品数量"),
                                    })),
            'logistics':
            ListField(desc='物流列表',
                      fmt=DictField(
                          desc="物流列表",
                          conf={
                              'company':
                              CharField(desc="物流公司"),
                              'number':
                              CharField(desc="物流单号"),
                              'total_quantity':
                              IntField(desc="发货数量"),
                              'create_time':
                              DatetimeField(desc="发货时间"),
                              'logistics_items':
                              ListField(
                                  desc="订单详情",
                                  fmt=DictField(
                                      desc="订单详情",
                                      conf={
                                          'name':
                                          CharField(desc="商品名称"),
                                          'thumbnail':
                                          CharField(desc="商品缩略图"),
                                          'quantity':
                                          IntField(desc="商品数量"),
                                          'equipment_codes':
                                          ListField(
                                              desc="设备编码列表",
                                              fmt=DictField(
                                                  desc="设备编码列表",
                                                  conf={
                                                      'code':
                                                      CharField(desc="设备编码"),
                                                  })),
                                      })),
                          })),
        })

    @classmethod
    def get_desc(cls):
        return "订单详情接口"

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

    def execute(self, request):
        order = OrderServer.get(request.order_id)
        OrderItemServer.hung_item_fororder(order)
        LogisticsServer.hung_item_fororser(order)

        EquipmentServer.hung_code_bylogistics(order.logistics)

        return order

    def fill(self, response, order):
        response.order_info = {
            'id':
            order.id,
            'order_sn':
            order.order_sn,
            'consignee':
            order.consignee,
            'nick_name':
            order.customer.nick,
            'phone':
            order.phone,
            'city':
            order.city,
            'address':
            order.address,
            'messages':
            order.messages,
            'paytype':
            order.paytype,
            'pay_time':
            order.pay_time,
            'transaction_id':
            order.transaction_id,
            'total_price':
            order.total_price,
            'channel_name':
            order.shop.channel.name if order.shop.channel else "",
            'shop_name':
            order.shop.name,
            'create_time':
            order.create_time,
            'remark':
            order.remark,
            'order_items': [{
                'name':
                orderitem.name,
                'thumbnail':
                orderitem.thumbnail,
                'rate':
                orderitem.rate,
                'price':
                orderitem.price,
                'type':
                orderitem.type,
                'brand_name':
                orderitem.goods.product_model.name
                if orderitem.goods and orderitem.goods.product_model else "",
                'quantity':
                orderitem.quantity,
            } for orderitem in order.items],
            'logistics': [{
                'company':
                logistics.company,
                'number':
                logistics.number,
                'total_quantity':
                logistics.total_quantity,
                'create_time':
                logistics.create_time,
                'logistics_items': [{
                    'name':
                    logisticsitem.order_item.name,
                    'thumbnail':
                    logisticsitem.order_item.thumbnail,
                    'quantity':
                    logisticsitem.quantity,
                    'equipment_codes': [{
                        'code': equipment.code,
                    } for equipment in logisticsitem.equipment_list]
                } for logisticsitem in logistics.items]
            } for logistics in order.logistics]
        }
        return response
Example #23
0
class Search(StaffAuthorizedApi):
    """客户购买数据列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc = "当前查询页码")
    request.search_info = RequestField(DictField, desc = '搜索条件', conf = {
        'order_sn': CharField(desc = "订单编号", is_required = False),
        'goods_sn': 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"),
        'serial_number': IntField(desc = "序号"),
        'order_sn': CharField(desc = "订单编号"),
        'goods_sn': CharField(desc = "商品编号"),
        'buy_number': IntField(desc = "购买数量"),
        'buy_money': IntField(desc = "订单金额/分"),
        'pay_time': DatetimeField(desc = "付款时间"),
        'shop_name': CharField(desc = "网点名称"),
        'buy_name': CharField(desc = "买家姓名"),
        'province': CharField(desc = "省"),
        'city': CharField(desc = "市"),
        'area': CharField(desc = "区"),
        'address': CharField(desc = "详细地址"),
        'logistics_company': CharField(desc = "物流公司"),
        'logistics_code': CharField(desc = "物流单号"),
        'buy_phone': CharField(desc = "联系方式"),
        'status': CharField(desc = "状态"),
        'remark': CharField(desc = "客服备注"),
        'buy_nick': CharField(desc = "卖家账号"),
        'device_code': 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_buyinfo_middleware.search(request.current_page, **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': buyinfo.id,
            'serial_number': buyinfo.serial_number,
            'order_sn': buyinfo.order_sn,
            'goods_sn': buyinfo.goods_sn,
            'buy_number': buyinfo.buy_number,
            'buy_money': buyinfo.buy_money,
            'pay_time': buyinfo.pay_time,
            'shop_name': buyinfo.shop_name,
            'buy_name': buyinfo.buy_name,
            'province': buyinfo.province,
            'city': buyinfo.city,
            'area': buyinfo.area,
            'address': buyinfo.address,
            'logistics_company': buyinfo.logistics_company,
            'logistics_code': buyinfo.logistics_code,
            'buy_phone': buyinfo.buy_phone,
            'status': buyinfo.status,
            'remark': buyinfo.remark,
            'buy_nick': buyinfo.buy_nick,
            'device_code': buyinfo.device_code,
            'create_time':buyinfo.create_time,
            'error_text':buyinfo.error_text,
        } for buyinfo in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #24
0
class Search(StaffAuthorizedApi):
    """售后服务单产品列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前查询页码")
    request.search_info = RequestField(DictField,
                                       desc='搜索条件',
                                       conf={
                                           "equipment_code":
                                           CharField(desc="设备编码",
                                                     is_required=False),
                                           "seller_staff_id":
                                           IntField(desc="售前客服id",
                                                    is_required=False),
                                           "server_staff_id":
                                           IntField(desc="售后客服id",
                                                    is_required=False),
                                           "shop_id":
                                           CharField(desc="店铺id",
                                                     is_required=False),
                                           "buy_date_start":
                                           DateField(desc="购买起始时间",
                                                     is_required=False),
                                           "buy_date_end":
                                           DateField(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="购买人"),
                                               'phone':
                                               CharField(desc="购买人电话"),
                                               'code':
                                               CharField(desc="SN码"),
                                               'pre_id':
                                               IntField(desc="售前客服id"),
                                               'pre_name':
                                               CharField(desc="售前客服"),
                                               'after_id':
                                               IntField(desc="售后客服id"),
                                               'after_name':
                                               CharField(desc="售后客服"),
                                               'shop_id':
                                               IntField(desc="店铺id"),
                                               'shop_name':
                                               CharField(desc="店铺名称"),
                                               'buy_time':
                                               DatetimeField(desc="购买时间"),
                                               'create_time':
                                               DatetimeField(desc="录入时间"),
                                               'buyinfo_status':
                                               CharField(desc="购买信息状态"),
                                               'dsinfo_status':
                                               CharField(desc="电刷信息状态"),
                                               'rebate_status':
                                               CharField(desc="激活信息状态"),
                                               'sn_status':
                                               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):
        cur_user = self.auth_user
        user_pro = UserRightServer(cur_user)
        request.search_info.update(
            {"service__seller_id__in": user_pro._staff_id_list})

        page_list = ServiceItemServer.search(request.current_page,
                                             **request.search_info)

        # 挂载售前售后客服
        ServiceServer.hung_staff_forservice(page_list.data)
        # 挂载店铺
        OrderServer.hung_shop_forservice(page_list.data)

        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id':
            service_item.id,
            'name':
            service_item.customer.name if service_item.customer else "",
            'phone':
            service_item.customer.phone if service_item.customer else "",
            'code':
            service_item.equipment.code,
            'pre_id':
            service_item.pre_staff.id if service_item.pre_staff else 0,
            'pre_name':
            service_item.pre_staff.name if service_item.pre_staff else "",
            'after_id':
            service_item.after_staff.id if service_item.after_staff else 0,
            'after_name':
            service_item.after_staff.name if service_item.after_staff else "",
            'shop_id':
            service_item.shop.id if service_item.shop else 0,
            'shop_name':
            service_item.shop.name if service_item.shop else "",
            'buy_time':
            service_item.order.pay_time if service_item.order else "",
            'create_time':
            service_item.create_time,
            'buyinfo_status':
            service_item.buyinfo_status,
            'dsinfo_status':
            service_item.dsinfo_status,
            'rebate_status':
            service_item.rebate_status,
            'sn_status':
            service_item.sn_status,
        } for service_item in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #25
0
class Get(StaffAuthorizedApi):
    """售后服务单产品信息"""
    request = with_metaclass(RequestFieldSet)
    request.service_item_id = RequestField(IntField, desc="售后服务单id")

    response = with_metaclass(ResponseFieldSet)
    response.service_item_info = ResponseField(DictField,
                                               desc='售后服务单产品信息',
                                               conf={
                                                   'customer_id':
                                                   IntField(desc="客户id"),
                                                   'customer_name':
                                                   CharField(desc="客户姓名"),
                                                   'customer_phone':
                                                   CharField(desc="客户联系方式"),
                                                   'device_code':
                                                   CharField(desc="设备编码"),
                                                   'buy_date':
                                                   DatetimeField(desc="购买时间"),
                                                   'wechat':
                                                   CharField(desc="微信号"),
                                                   'nick':
                                                   CharField(desc="微信昵称"),
                                                   'remark':
                                                   CharField(desc="备注"),
                                                   'register_id':
                                                   IntField(desc="id"),
                                                   'register_phone':
                                                   CharField(desc="注册手机号"),
                                                   'register_name':
                                                   CharField(desc="注册姓名"),
                                               })

    @classmethod
    def get_desc(cls):
        return "售后服务单产品信息接口"

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

    def execute(self, request):
        service_item = ServiceItemServer.get(request.service_item_id)
        service = None
        if service_item.service:
            service = ServiceServer.get(service_item.service.id)
        equipment_register = EquipmentRegisterServer.get_register_byequipment(
            service_item.equipment)
        return service_item, service, equipment_register

    def fill(self, response, service_item, service, equipment_register):
        response.service_item_info = {
            'customer_id':
            service_item.customer.id if service_item.customer else 0,
            'customer_name':
            service_item.customer.name if service_item.customer else "",
            'customer_phone':
            service_item.customer.phone if service_item.customer else "",
            'device_code':
            service_item.equipment.code,
            'buy_date':
            service.order.pay_time if service_item.order else "",
            'wechat':
            service_item.customer.wechat if service_item.customer else "",
            'nick':
            service_item.customer.nick if service_item.customer else "",
            'remark':
            service.order.remark if service_item.order else "",
            'register_id':
            equipment_register.id if equipment_register else 0,
            'register_phone':
            equipment_register.phone if equipment_register else "",
            'register_name':
            equipment_register.name if equipment_register else "",
        }
        return response
Example #26
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),
            '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"),
                                               'name':
                                               CharField(desc="姓名"),
                                               'position':
                                               CharField(desc="职位"),
                                               'department':
                                               CharField(desc="部门"),
                                               'phone':
                                               CharField(desc="手机号"),
                                               'gender':
                                               CharField(desc="性别"),
                                               'identity':
                                               CharField(desc="身份证号"),
                                               'birthday':
                                               DateField(desc="生日"),
                                               'age':
                                               IntField(desc="年龄"),
                                               'emergency_contact':
                                               CharField(desc="紧急联系人"),
                                               'emergency_phone':
                                               CharField(desc="紧急联系人电话"),
                                               'address':
                                               CharField(desc="详细地址"),
                                               'entry_time':
                                               DateField(desc="入职时间"),
                                               'education':
                                               CharField(desc="学历"),
                                               'bank_number':
                                               CharField(desc="招行卡号"),
                                               'contract_b':
                                               CharField(desc="合同编号(必)"),
                                               'contract_l':
                                               CharField(desc="合同编号(立)"),
                                               'expire_time':
                                               DateField(desc="到期时间"),
                                               'is_on_job':
                                               CharField(desc="是否在职"),
                                               'quit_time':
                                               DateField(desc="离职时间"),
                                               'status':
                                               CharField(desc="状态"),
                                               'remark':
                                               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_staff_middleware.search(request.current_page,
                                                   **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': staff.id,
            'name': staff.name,
            'position': staff.position,
            'department': staff.department,
            'phone': staff.phone,
            'gender': staff.gender,
            'identity': staff.identity,
            'birthday': staff.birthday,
            'age': staff.age,
            'emergency_contact': staff.emergency_contact,
            'emergency_phone': staff.emergency_phone,
            'address': staff.address,
            'entry_time': staff.entry_time,
            'education': staff.education,
            'bank_number': staff.bank_number,
            'contract_b': staff.contract_b,
            'contract_l': staff.contract_l,
            'expire_time': staff.expire_time,
            'is_on_job': staff.is_on_job,
            'quit_time': staff.quit_time,
            'status': staff.status,
            'remark': staff.remark,
            'create_time': staff.create_time,
            'error_text': staff.error_text,
        } for staff in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #27
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="姓名"),
                                               'gender':
                                               CharField(desc="性别"),
                                               'birthday':
                                               CharField(desc="出身年月"),
                                               'email':
                                               CharField(desc="邮箱"),
                                               'phone':
                                               CharField(desc="手机号"),
                                               'wechat':
                                               CharField(desc="微信号"),
                                               'city':
                                               CharField(desc="城市"),
                                               'address':
                                               CharField(desc="详细地址"),
                                               'mobilephone':
                                               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 = CustomerServer.search(request.current_page,
                                          **request.search_info)
        # MobileDevicesServer.hung_devices_byphone(page_list.data)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id':
            customer.id,
            'name':
            customer.name,
            'gender':
            customer.gender,
            'birthday':
            customer.birthday,
            'email':
            customer.email,
            'phone':
            customer.phone,
            'wechat':
            customer.wechat,
            'city':
            customer.city,
            'address':
            customer.address,
            'mobilephone':
            customer.mobiledevices.code if customer.mobiledevices else "",
            'create_time':
            customer.create_time,
        } for customer in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page

        return response
Example #28
0
class Search(StaffAuthorizedApi):
    """手机号导入数据列表"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前查询页码")
    request.search_info = RequestField(
        DictField,
        desc='搜索条件',
        conf={
            'phone_number':
            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"),
                                               'name':
                                               CharField(desc="姓名"),
                                               'identity':
                                               CharField(desc="身份证号"),
                                               'phone_number':
                                               CharField(desc="手机号"),
                                               'department':
                                               CharField(desc="部门"),
                                               'is_working':
                                               CharField(desc="在职情况"),
                                               'card_password':
                                               CharField(desc="手机卡密码"),
                                               'operator':
                                               CharField(desc="运营商"),
                                               'rent':
                                               IntField(desc="月租"),
                                               'phone_status':
                                               CharField(desc="手机号状态"),
                                               'phone_remark':
                                               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_mobile_phone_middleware.search(
            request.current_page, **request.search_info)
        return page_list

    def fill(self, response, page_list):
        response.data_list = [{
            'id': mobile_phone.id,
            'name': mobile_phone.name,
            'identity': mobile_phone.identity,
            'phone_number': mobile_phone.phone_number,
            'department': mobile_phone.department,
            'is_working': mobile_phone.is_working,
            'card_password': mobile_phone.card_password,
            'operator': mobile_phone.operator,
            'rent': mobile_phone.rent,
            'phone_status': mobile_phone.phone_status,
            'phone_remark': mobile_phone.phone_remark,
            'status': mobile_phone.status,
            'create_time': mobile_phone.create_time,
            'error_text': mobile_phone.error_text,
        } for mobile_phone in page_list.data]
        response.total = page_list.total
        response.total_page = page_list.total_page
        return response
Example #29
0
class Search(StaffAuthorizedApi):
    """日志搜索"""
    request = with_metaclass(RequestFieldSet)
    request.current_page = RequestField(IntField, desc="当前页码")
    request.search_info = RequestField(DictField,
                                       desc="日志搜索条件",
                                       conf={
                                           'active_name':
                                           CharField(desc="搜索主动方名称",
                                                     is_required=False),
                                           'active_type':
                                           CharField(desc="搜索主动方类型",
                                                     is_required=False),
                                           'passive_name':
                                           CharField(desc="搜索被动方名称",
                                                     is_required=False),
                                           'passive_type':
                                           CharField(desc="搜索被动方类型",
                                                     is_required=False),
                                           'journal_type':
                                           CharField(desc="搜索日志类型",
                                                     is_required=False),
                                           'start_time':
                                           DateField(desc="搜索开始时间",
                                                     is_required=False),
                                           'end_time':
                                           DateField(desc="搜搜结束时间",
                                                     is_required=False)
                                       })

    response = with_metaclass(ResponseFieldSet)
    response.data_list = ResponseField(ListField,
                                       desc='日志列表',
                                       fmt=DictField(
                                           desc="日志数据",
                                           conf={
                                               'id':
                                               IntField(desc="日志id"),
                                               'active_name':
                                               CharField(desc="主动方名称"),
                                               'active_type':
                                               CharField(desc="主动方类型"),
                                               'passive_name':
                                               CharField(desc="被动方名称"),
                                               'passive_type':
                                               CharField(desc="被动方类型"),
                                               'journal_type':
                                               CharField(desc="日志类型"),
                                               'record_detail':
                                               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):
        if 'start_time' in request.search_info:
            start_time = request.search_info.pop('start_time')
            request.search_info['create_time__gte'] = start_time
        if 'end_time' in request.search_info:
            end_time = request.search_info.pop('end_time')
            request.search_info['create_time__lt'] = end_time
        journal_pages = JournalMiddleware.search(request.current_page,
                                                 **request.search_info)

        return journal_pages

    def fill(self, response, journal_pages):
        data_list = [{
            'id': journal.id,
            'active_name': journal.active_name,
            'active_type': journal.active_type,
            'passive_name': journal.passive_name,
            'passive_type': journal.passive_type,
            'journal_type': journal.journal_type,
            'record_detail': journal.record_detail,
            'create_time': journal.create_time,
        } for journal in journal_pages.data]
        response.data_list = data_list
        response.total = journal_pages.total
        response.total_page = journal_pages.total_page
        return response
Example #30
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="店铺渠道名称"),
                                               'shop_num':
                                               IntField(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="创建时间"),
                                           }))
    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):
        channel_page = ChannelServer.search(request.current_page,
                                            **request.search_info)
        # 挂载店铺数量
        ShopServer.hung_shopnum_bychannel(channel_page.data)
        return channel_page

    def fill(self, response, channel_page):
        response.data_list = [{
            'id': channel.id,
            'name': channel.name,
            'shop_num': channel.shop_num,
            'freight': channel.freight,
            '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,
        } for channel in channel_page.data]
        response.total = channel_page.total
        response.total_page = channel_page.total_page
        return response