コード例 #1
0
ファイル: manager.py プロジェクト: GSIL-Monitor/xxw
    def get(self):
        # 刷新商户经理获取抢单列表
        logger.info("[D] [功能 刷新商户经理获取抢单列表]")
        req = self.validate_data
        logger_req(req)
        manager = request.current_user
        refresh_face_sign(manager.code)
        # 筛选条件
        time_start = req.get("time_start", "")
        time_end = req.get("time_end", "")
        address_code = req.get("address_code", "")
        orderby_time = req.get("orderby_time", "")

        a = TbFaceSignUser.merchant_code == manager.merchant_code  # 商户编码
        b = (TbFaceSignUser.order_time >= time_start
             ) if time_start else True  # 预约起始起始时间
        c = (TbFaceSignUser.order_time <= time_end
             ) if time_end else True  # 预约结束时间
        d = (TbFaceSignUser.order_address_code.op("regexp")(
            r"^" +
            re_address_code(address_code))) if address_code else True  # 省市区筛选
        e = TbFaceSignUser.status == 0  # 状态为待面签条件
        f = (TbFaceSignUser.update_time) if orderby_time == "1" else (
            -TbFaceSignUser.update_time)  # 时间正反序
        ke = [a, b, c, d, e]
        facesign = TbFaceSignUser.query.filter(*ke).order_by(f)

        return get_data(
            facesign,
            TbFaceSignUser,
            exclude=["id", "manager_code", "manager_name", "extend"])
コード例 #2
0
ファイル: public.py プロジェクト: GSIL-Monitor/xxw
 def put(self):
     """更新产品信息"""
     schema = Schema({
         "production_code": And(str),
         "appkey": And(str),
         "appid": And(str),
         "sign": And(str)
     })
     req, error = validate_schema(schema, request.json)
     if error:
         return error, 400
     production = TbProduction.query.filter_by(
         code=req["production_code"]).first()
     if not production:
         return Msg.PRODUCTION_NOT_EXIST, 400
     production.sms_appkey = req["appkey"]
     production.sms_appid = req["appid"]
     production.sms_sign = req["sign"]
     msg = "SUPPORT | B_USER | UPDATE_PRODUCTION | SUCCESS | EDITOR: {} {} | PRODUCTION: {} {} | MERCHANT: {} {}".\
         format(request.current_user.code, request.current_user.name, production.code, production.name,
                production.merchant.code, production.merchant.name)
     operation = TbOperation(operator_code=request.current_user.code,
                             content=msg,
                             category="PRODUCTION",
                             type="EDIT")
     db.session.add(operation)
     db.session.commit()
     logger.info(msg)
     return {}, 200
コード例 #3
0
ファイル: model_resource.py プロジェクト: GSIL-Monitor/xxw
 def dispatch_request(self, *args, **kwargs):
     req = None
     schema = None
     if request.method == "GET":
         schema = self.validate_schemas.get("get")
         req = request.args.to_dict()
     else:
         schema = self.validate_schemas.get(request.method.lower())
         req = request.json
     if isinstance(schema, Schema):
         data, errors = validate_schema(schema, move_space(req))
         if errors:
             logger.info(str(errors))
             return str(errors), 400
         self.validate_data = data
     try:
         ret = super().dispatch_request(*args, **kwargs)
         return ret
     except NotUniqueError:
         logger.warn(traceback.format_exc())
         return Msg.DATA_EXIST, 400
     except ValidationError as e:
         logger.warn(traceback.format_exc())
         return str(e), 400
     except DoesNotExist:
         logger.warn(traceback.format_exc())
         return Msg.NO_DATA, 400
     except AttributeError as e:
         logger.warn(traceback.format_exc())
         return str(e), 400
     except Exception as e:
         logger.warn(traceback.format_exc())
         return str(e), 400
コード例 #4
0
 def put(self):
     schema = Schema({
         "id": And(str),
         "businessId": And(str),
         "path": And(str, len),
         "name": And(str, len),
         "visible": And(bool)
     })
     req, error = validate_schema(schema, request.json)
     if error:
         return error, 400
     menu = TbMenu.query.filter_by(code=req["id"]).first()
     if not menu:
         return Msg.MENU_NOT_EXIST, 400
     business = TbBusiness.query.filter_by(code=req["businessId"]).first()
     if not business:
         return Msg.BUSINESS_NOT_EXIST, 400
     menu.name = req["name"]
     menu.path = req["path"]
     menu.business_code = business.code
     menu.visible = req.get("visible")
     msg = "SUPPORT | B_USER | EDIT_MENU | SUCCESS | USER: {} {} | MENU: {} {} {}".format(
         request.current_user.code, request.current_user.name, menu.code, menu.name, menu.path)
     operation = TbOperation(operator_code=request.current_user.code, content=msg, category="MENU", type="EDIT")
     db.session.add(operation)
     db.session.commit()
     logger.info(msg)
     return {}, 200
コード例 #5
0
ファイル: user.py プロジェクト: GSIL-Monitor/xxw
 def post(self):
     req = add_user.parse_args(strict=True)
     merchant = TbMerchant.query.filter_by(code=req["merchantId"]).first()
     if not TbMerchant:
         return Msg.MERCHANT_NOT_EXIST, 400
     phone = req["mobile"]
     if len(phone) != 11 or TbUser.query.filter_by(phone=phone).first():
         return Msg.PHONE_USED, 400
     user = TbUser(
         phone=phone,
         name=req.get("name"),
         sex=req.get("sex"),
         wechat=req.get("wechat"),
         qq=req.get("qq"),
         mail=req.get("mail"),
         address=req.get("address"),
         merchant_code=merchant.code,
     )
     user.generate_password("123456")
     merchant.users.append(user)
     db.session.add(user)
     db.session.commit()
     user.code = str(1000000000 + user.id)
     msg = "SUPPORT | B_USER | EDIT_USER | SUCCESS | EDITOR: {} {} | USER: {} {} | MERCHANT: {} {}".format(
         request.current_user.code, request.current_user.name, user.code,
         user.name, merchant.code, merchant.name)
     operation = TbOperation(operator_code=user.code,
                             content=msg,
                             category="USER_MANAGE",
                             type="ADD")
     db.session.add(operation)
     db.session.commit()
     logger.info(msg)
     return {}, 200
コード例 #6
0
 def post(self):
     instance, errors = self.detail_schema.load(request.json)
     if errors:
         logger.info(str(errors))
         return str(errors), 400
     instance.save()
     return self.detail_schema.dump(instance).data
コード例 #7
0
ファイル: user.py プロジェクト: GSIL-Monitor/xxw
    def put(self):
        """
        修改用户密码
        """

        req = modify_password.parse_args(strict=True)
        if req["newPassword"] != req["verifyPassword"]:
            return Msg.PARAMS_ERROR, 400
        user = request.current_user
        if user.verify_password(req["oldPassword"]):
            user.generate_password(req["newPassword"])
            db.session.commit()
            key = "support_jwt_{}".format(request.current_user.code)
            redis_delete(key)
            msg = "SUPPORT | B_USER | MODIFY_PASSOWRD | SUCCESS | USER_CODE: {} | USER_NAME: {}".format(
                user.code, user.name)
            operation = TbOperation(operator_code=user.code,
                                    content=msg,
                                    category="USER",
                                    type="EDIT")
            db.session.add(operation)
            db.session.commit()
            logger.info(msg)
            return {}, 200
        return Msg.OLD_PASSWORD_ERROR, 400
コード例 #8
0
 def put(self):
     schema = Schema({
         "id": And(str),
         "businessId": And(str),
         "path": And(str, len),
         "method": And(str, len),
         "name": And(str, len),
         "visible": And(bool)
     })
     req, error = validate_schema(schema, request.json)
     if error:
         return error, 400
     interface = TbInterface.query.filter_by(code=req["id"]).first()
     if not interface:
         return Msg.INTERFACE_NOT_EXIST, 400
     business = TbBusiness.query.filter_by(code=req["businessId"]).first()
     if not business:
         return Msg.BUSINESS_NOT_EXIST, 400
     interface.name = req["name"]
     interface.path = req["path"]
     interface.method = req["method"]
     interface.business_code = business.code
     interface.visible = req["visible"]
     msg = "SUPPORT | B_USER | EDIT_INTERFACE | SUCCESS | USER: {} {} | INTERFACE: {} {} {}".format(
         request.current_user.code, request.current_user.name, interface.code, interface.name, interface.path)
     operation = TbOperation(operator_code=request.current_user.code, content=msg, category="INTERFACE", type="EDIT")
     db.session.add(operation)
     db.session.commit()
     logger.info(msg)
     return {}, 200
コード例 #9
0
    def get(self):
        logger.info("[D] [功能 案件信息展示]")
        req = self.validate_data
        logger_req(req)
        phone = req.get("phone","") 
        name = req.get("name","") 
        case_type = req.get("case_type")
        id_card = req.get("id_card")  
        merchant_code = req.get("merchant_code")              
        time_start = req.get("time_start","") 
        time_end = req.get("time_end","")
        trx = req.get("trx","")
        production_code = req.get("production_code","") 

        #筛选
        a = LogCase.merchant_code == merchant_code if merchant_code else True  # 商户编码
        b = LogCase.phone == phone if phone else True # 电话号码
        c = LogCase.name.contains(name) if name else True # 用户姓名模糊查询
        d = LogCase.case_type == case_type if case_type else True # 事件类型
        e = LogCase.id_card == id_card if id_card else True # 身份证
        f = (LogCase.trigger_time >= time_start) if time_start else True  # 起始起始时间
        g = (LogCase.trigger_time <= time_end) if time_end else True  # 结束时间  
        h = (LogCase.trx == trx) if trx else True  # 单号查询
        i = (LogCase.production_code == production_code) if production_code else True  # 产品号查询
        ke = [a, b, c, d, e, f, g, h,i]
        case  = LogCase.query.filter(*ke).order_by(-LogCase.trigger_time)

        return get_data(case, LogCase, exclude=["id","data"])
コード例 #10
0
    def get(self):
        self.reqparse.add_argument("trx",
                                   type=str,
                                   required=True,
                                   nullable=False,
                                   code=1014010001,
                                   desc="事务ID")
        self.reqparse.add_argument("type",
                                   type=str,
                                   required=False,
                                   code=1014010001,
                                   desc="数据类型")
        rq_args = self.reqparse.parse_args(strict=True)
        trx = rq_args.get("trx", "")
        search_type = rq_args.get("type", "")
        search_list = self.verification_search_type(search_type)

        if not trx:
            raise RequestsError(code=1014010001, message=',事务ID不能为空')

        # 查询所有接口配置信息
        self.interface_dict = self.get_interfaces()

        ret_data = dict()
        for tp in search_list:
            ret_data[tp] = eval('self.{0}'.format(tp))(trx)
        logger.info(
            "success queried credit detail information,query parameters are %s"
            % json.dumps(rq_args))
        return ret_data
コード例 #11
0
def read_config_from_mongo(app):
    # 读取 mongodb 里面的配置
    config = support_config_db.find_one()
    if not config:
        logger.info("NO CONFIG IN MONGODB")
    else:
        logger.info("READING CONFIG FROM MONGODB | CONFIG: {}".format(config))
        app.config.update(config if config else {})
コード例 #12
0
ファイル: mongo_resource.py プロジェクト: GSIL-Monitor/xxw
 def post(self):
     instance = self.model(**request.json)
     try:
         instance.save()
     except Exception as e:
         logger.info(str(e))
         return str(e), 400
     return instance.to_dict()
コード例 #13
0
def push_merchant(merchant) -> tuple:
    """
    推送商户信息
    """
    url = zk.loan_mng_hosts
    if not url:
        return False, "未找到信贷核心地址"
    params = {
        "ctrlData": {
            "servcId": "AS_BANK_ACCOUNT_UPDATE",
            "servcScn": "01",
            "sysIndicator": "000001",
            "reqTime": time.strftime("%Y-%m-%d %H:%M:%S"),
            "transMedium": "00000000",
            "bizTrackNo": "{}".format(time.time() * 10000000),
            "transSeqNo": "{}".format(time.time() * 10000000),
            "hostIp": ip,
        },
        "body": {
            "reqHead": {
                "bankNo": merchant.code,
                "custId": merchant.code
            },
            "bankName": merchant.name,
            "openFlag": "1",
            "acctSelfInd": "1",
            "merchNo": merchant.xw_code,
            "loanAcctNo": merchant.iba_loan_no,
            "loanAcctName": merchant.iba_loan_name,
            "deduAcctNo": merchant.iba_collection_no,
            "deduAcctName": merchant.iba_collection_name,
            "preAcctNo": merchant.iba_pre_deposit_no,
            "preAcctName": merchant.iba_pre_deposit_name,
            "assetsImpairmentNum": "90",
            "orgNo": merchant.org_no
        }
    }
    if merchant.push_flag == 0:
        params["body"].update({"operType": "1"})
    else:
        params["body"].update({"operType": "2"})
    try:
        res = requests.post(url + "/loan_mng/handle", json=params).json()
        code = res["respData"]["code"]
        if code == "00000000":
            merchant.push_flag = 1
            db.session.commit()
            logger.info("PUSH MERCHANT SUCCESS!")
            return True, ""
        else:
            logger.warn(
                "push merchant info failed, failed info {}".format(res))
            return False, res.get("respData", {}).get("message") or str(res)
    except Exception as e:
        logger.warn("push merchant info failed, failed info {}".format(str(e)))
        return False, "网络错误"
コード例 #14
0
ファイル: schedurun_mgr.py プロジェクト: GSIL-Monitor/xxw
    def get(self):
        list_fields = [
            'trx', 'cmd_id', 'rule_id', 'phone', 'merchant_code',
            'production_code', 'exec_way', 'recover_index', 'can_recover',
            'message', 'operate_status', 'operator', 'operator_id', 'stime',
            'state'
        ]
        data = self.validate_data
        start_time = data.get('start_time')
        end_time = data.get('end_time')
        page = data.pop('page')
        page_size = data.pop('page_size')
        index_suffix = data.pop('index_suffix')
        index = 'schedurun' + index_suffix
        filters = []
        if start_time:
            filters.append({"range": {"stime": {"gte": start_time}}})
            data.pop('start_time')
        if end_time:
            filters.append({"range": {"stime": {"lte": end_time}}})
            data.pop('end_time')

        # 精确搜索text字段使用keyword(建索引的时候指定了该字段为keyword)
        data = {
            "%s.keyword" % k if isinstance(v, str) else k: str(v)
            for k, v in data.items()
        }

        query = [Q("term", **{k: v}) for k, v in data.items()]
        filters.extend(query)
        search = ScheduRun.search(using=es_client, index=index).query(
            'bool', filter=filters).source(list_fields).sort('-stime.keyword')

        logger.info("ES query: %s" % search.to_dict())

        total = search.count()
        page_search = search[(page - 1) * page_size:page * page_size]
        page_results = page_search.execute(ignore_cache=True)
        results = []
        for ret in page_results:
            tmp = dict()
            ret_dict = ret.to_dict(include_meta=True)
            tmp = ret_dict['_source']
            tmp['id'] = ret_dict['_id']
            tmp['index'] = ret_dict['_index']
            tmp['operate_status'] = ret.operate_status
            tmp['operator'] = ret.operator
            tmp['operator_id'] = ret.operator_id
            results.append(tmp)
        return {
            "total": total,
            "pages": math.ceil(total / page_size),
            "page": page,
            "page_size": page_size,
            "results": results
        }
コード例 #15
0
 def get_config(self, category):
     path = ConfigNameMap.zk_path[category]
     if not self.zk.exists(path):
         self.zk.create(path, json.dumps({}).encode())
     try:
         data = json.loads(self.zk.get(path)[0].decode())
         return data
     except Exception as e:
         logger.info("ZK | GET CONFIG | FAILED | CATEGORY: {}| ERROR: {}".format(category, str(e)))
         return {}
コード例 #16
0
ファイル: credit_merchant.py プロジェクト: GSIL-Monitor/xxw
 def get(self):
     """
     获取租户对应产品所拥有征信源
     :return: 租户对应产品所拥有征信源详情
     """
     # 里面更新征信源的可用状态将自动更新interface_status
     self.reqparse.add_argument("merchant_code",
                                type=str,
                                required=True,
                                location=["json", "args"],
                                code=1014010001,
                                desc="租户id")
     self.reqparse.add_argument("production_code",
                                type=str,
                                required=True,
                                location=["json", "args"],
                                code=1014010001,
                                desc="产品id")
     self.reqparse.add_argument("interface_status",
                                type=int,
                                location=["json", "args"],
                                code=1014010002,
                                desc="三方接口可用状态")
     rq_args = self.reqparse.parse_args(strict=True)
     query_dict = {
         "merchant_code": rq_args.get("merchant_code", ""),
         "production_code": rq_args.get("production_code", ""),
         "interface_status": rq_args.get("interface_status", ""),
     }
     type_orm = {"third_zx": "三方征信", "rh_zx": "人行征信"}
     query_dict = {k: v for k, v in query_dict.items() if v is not None}
     query_dict["is_delete"] = 0
     full_merchant_list = self.get_interface_mysql(query_dict)
     full_interface_dict = self.mongo_full_interface()
     interface_merchant_list, wait_update_list = self.format_data(
         full_interface_dict, full_merchant_list, query_dict)
     if wait_update_list:
         self.to_post_put(TbMerchantCredit, wait_update_list)
     ret_dict = {}
     for data in interface_merchant_list.values():
         for k, v in data.items():
             if v != 0 and not v:  # 此处value可能为0
                 data.update({k: ""})
         type_zx = type_orm.get(data["type"], data["type"])
         if type_zx in ret_dict:
             ret_dict[type_zx].append(data)
         else:
             ret_dict[type_zx] = [data]
     log_data = "SUPPORT | MARCHANT_CREDIT | GET_MARCHANT_CREDIIT | SUCCESS | MERCHANT:{} | PRODUCT: {}".\
         format(query_dict["merchant_code"], query_dict["production_code"])
     logger.info(log_data)
     return {
         "total": len(ret_dict),
         "results": json.loads(json.dumps(ret_dict))
     }
コード例 #17
0
 def get_os_center_hosts(self, *args):
     try:
         children = self.zk.get_children(self.os_center_node)
         node = children[0]
         data = self.zk.get(self.os_center_node+"/"+node)[0].decode()
         host = "http://{}".format(data)
         logger.info("ZK | GET OS_CENTER HOSTS | SUCCESS | HOST: {}".format(host))
         return host
     except Exception as e:
         logger.info("ZK | GET OS_CENTER HOSTS | FAILED | ERROR: {}".format(str(e)))
         return ""
コード例 #18
0
 def write_config(self, category, config):
     path = ConfigNameMap.zk_path[category]
     try:
         self.zk.ensure_path(path)
         if not self.zk.exists(path):
             self.zk.create(path, json.dumps({}).encode())
         self.zk.set(path, json.dumps(config).encode())
         return True
     except Exception as e:
         logger.info("ZK | SYNC CONFIG | FAILED | CATEGORY: {}| ERROR: {}".format(category, str(e)))
         return False
コード例 #19
0
 def get_loan_mng_hosts(self, *args):
     try:
         data = json.loads(self.zk.get(self.node)[0])
         ip = data["node_list"][0]["ip"]
         port = data["node_list"][0]["port"]
         host = "http://{}:{}".format(ip, port)
         logger.info("ZK | GET LOAN_MNG HOSTS | SUCCESS | HOST: {}".format(host))
         self.loan_mng_hosts = host
         return host
     except Exception as e:
         logger.info("ZK | GET LOAN_MNG HOSTS | FAILED | ERROR: {}".format(str(e)))
         self.loan_mng_hosts = ""
コード例 #20
0
    def put(self):
        schema = Schema({
            "id": And(str),
            "name": And(str, len),
            "businessId": And(str),
            "interface": [str],
            "menu": [str]})
        req, error = validate_schema(schema, request.json)
        if error:
            return error, 400
        user = request.current_user
        code = req["id"]
        name = req.get("name")
        business_code = req.get("businessId")
        interface = req.get("interface")
        menu = req.get("menu")
        condition = [TbRole.name == name, TbRole.code != code, TbRole.business_code == business_code]
        if user.merchant:
            condition.append(TbRole.merchant_code == user.merchant_code)
        else:
            condition.append(TbRole.merchant_code == None)
        dup_role = TbRole.query.filter(*condition).first()
        if dup_role:
            return Msg.ROLE_NAME_ALREADY_EXIST, 400

        biz = TbBusiness.query.filter_by(code=business_code).first()
        if not biz:
            return Msg.BUSINESS_NOT_EXIST, 400
        role = TbRole.query.filter_by(code=code).first()
        # 只允许 admin 用户修改用户中心角色
        if not user.is_admin and role.business.appid == app.config["USER_CENTER"]:
            msg = "SUPPORT | B_USER | EDIT_ROLE | FAILED | USER: {} {} | ROLE: {} {} | REASON | {}".format(
                    user.code, user.name, role.code, role.name, "user has not permission to edit role")
            logger.info(msg)
            return Msg.PARAMS_ERROR, 400
        if not role:
            return Msg.ROLE_NOT_EXIST, 400
        role.name = name
        role.interface.clear()
        role.menu.clear()
        role.business = biz
        data = role_insert(role, interface, menu)
        if data == {}:
            msg = "SUPPORT | B_USER | EDIT_ROLE | SUCCESS | USER: {} {} | ROLE: {} {}".format(
                user.code, user.name, role.code, role.name)
            operation = TbOperation(operator_code=user.code, content=msg, category="ROLE", type="ADD")
            db.session.add(operation)
            db.session.commit()
            logger.info(msg)
            return data, 200
        else:
            db.session.rollback()
            return data, 400
コード例 #21
0
ファイル: manager.py プロジェクト: GSIL-Monitor/xxw
 def put(self):
     # 修改当前客户经理相关信息
     logger.info("[D] [功能 修改当前客户经理相关信息]")
     req = self.validate_data
     logger_req(req)
     manager = request.current_user
     manager.address = req.get("address", manager.address)
     manager.head_img = req.get("head_img", manager.head_img)
     db.session.commit()
     logger.info("[T] [Update tb_manager where manager_code= {}]".format(
         manager.code))
     return ""
コード例 #22
0
ファイル: task.py プロジェクト: GSIL-Monitor/xxw
 def get(self):
     """
     获取任务分配待审核数量,未分配数量, 已分配数量
     """
     evt_type = self.validate_data.get("evt_type")
     queryset = Evt.objects(evt_type=evt_type)
     un_allot_cnt = queryset(operator_id=None).count()
     writing_audit_cnt = queryset(status__in=[0, 4]).count()
     total_count = queryset.count()
     allot_cnt = total_count - un_allot_cnt
     logger.info("获取%s任务分配数量 待审核数量:%s , 未分配数量:%s, 已分配数量:%s" %
                 (evt_type, writing_audit_cnt, un_allot_cnt, allot_cnt))
     return {"un_allot_cnt": un_allot_cnt, "allot_cnt": allot_cnt, "writing_audit_cnt": writing_audit_cnt}
コード例 #23
0
ファイル: regional_control.py プロジェクト: GSIL-Monitor/xxw
    def put(self):
        _id = request.json.pop("id")
        instance = self.model.objects().filter(id=_id).first()

        if not instance:
            return Msg.NO_DATA, 400
        exclude_fields = set(request.json.keys()) & set(
            self.update_exclude_fields)
        include_fields = set(request.json.keys()) - set(
            self.update_include_fields)
        if self.update_include_fields and include_fields:
            logger.info("Not Allowed To Update " + str(include_fields))
            return "Not allowed to update " + str(include_fields), 400
        if exclude_fields:
            logger.info("Not Allowed To Update " + str(exclude_fields))
            return "Not allowed to update " + str(exclude_fields), 400

        status = request.json.get("status")
        if status:
            regional_total = RegionalControl.objects.filter(
                production_code=instance.production_code, status=True).count()
            if regional_total >= self.regional_total:
                logger.info(
                    f"living regional_control can not more than {self.regional_total}"
                )
                return f"living regional_control can not more than {self.regional_total}", 400
        instance.update_time = int(datetime.utcnow().timestamp())
        try:
            instance.update(**request.json)
            instance.save()
        except Exception as e:
            logger.info(str(e))
            return str(e), 400
        return instance.to_dict()
コード例 #24
0
 def delete(self):
     req = delete_menu.parse_args(strict=True)
     menu = TbMenu.query.filter_by(code=req["id"]).first()
     msg = "SUPPORT | B_USER | DELETE_MENU | SUCCESS | USER: {} {} | MENU: {} {} {}".format(
         request.current_user.code, request.current_user.name, menu.code, menu.name, menu.path)
     operation = TbOperation(operator_code=request.current_user.code, content=msg, category="MENU", type="DELETE")
     db.session.add(operation)
     logger.info(msg)
     try:
         db.session.delete(menu)
         db.session.commit()
     except Exception as e:
         pass
     finally:
         return {}, 200
コード例 #25
0
 def post(self):
     schema = Schema({
         "businessId": And(str),
         "interface": [{
             "path": And(str, len),
             "method": And(str, len),
             "name": And(str, len),
             "visible": And(bool)
         }]
     })
     req, error = validate_schema(schema, request.json)
     if error:
         return error, 400
     user = request.current_user
     biz = TbBusiness.query.filter_by(code=req["businessId"]).first()
     if not biz:
         return Msg.BUSINESS_NOT_EXIST, 400
     inters = []
     for i in req["interface"]:
         inter = TbInterface.query.filter_by(business_code=biz.code,
                                             path=i["path"],
                                             method=i["method"]).first()
         if inter:
             # 通过 path 和 method 来确定一个接口,用户就是对这个接口进行修改
             inter.name = i["name"]
             inter.visible = i["visible"]
         else:
             interface = TbInterface(
                 name=i["name"],
                 path=i["path"],
                 method=i["method"],
                 visible=i["visible"],
                 creator_code=user.code,
                 business_code=biz.code,
             )
             biz.interface.append(interface)
             db.session.add(interface)
             inters.append(interface)
     db.session.commit()
     for i in inters:
         i.code = str(1400000000 + i.id)
     msg = "SUPPORT | B_USER | ADD_INTERFACE | SUCCESS | USER: {} {} | INTERFACE: {}".format(
         user.code, user.name, [i.name for i in inters])
     operation = TbOperation(operator_code=user.code, content=msg, category="INTERFACE", type="ADD")
     db.session.add(operation)
     db.session.commit()
     logger.info(Msg)
     return {}, 200
コード例 #26
0
ファイル: credit_conf.py プロジェクト: GSIL-Monitor/xxw
 def delete(self):
     """
     删除征信配置
     """
     self.reqparse.add_argument("interface",
                                type=str,
                                required=True,
                                location=['json', 'args'],
                                code=1014010001,
                                desc="接口编号")
     self.reqparse.add_argument("operator_id",
                                type=str,
                                location=['json', 'args'],
                                required=True,
                                code=1014010001,
                                desc="操作人ID")
     raw_args_dict = self.reqparse.parse_args(strict=True)
     if not CreditConf.objects(interface=raw_args_dict["interface"],
                               is_delete=0).count() == 1:
         return 1014010004  # 接口编码错误
     try:
         de_data = CreditConf.objects(interface=raw_args_dict["interface"],
                                      is_delete=0)
         de_data.update(set__is_delete=int(1))
         msg = self.create_log_msg(operator_id=raw_args_dict["operator_id"],
                                   interface=raw_args_dict["interface"],
                                   data=json.dumps(raw_args_dict,
                                                   ensure_ascii=False),
                                   status="SUCCESS")
         self.operator_log(operator_id=raw_args_dict["operator_id"],
                           log_data=msg,
                           method="DELETE")
         logger.info(msg)
         return 0
     except Exception as e:
         msg = self.create_log_msg(operator_id=raw_args_dict["operator_id"],
                                   interface=raw_args_dict["interface"],
                                   data=json.dumps(raw_args_dict,
                                                   ensure_ascii=False),
                                   status="FAILED")
         self.operator_log(operator_id=raw_args_dict["operator_id"],
                           log_data=msg,
                           method="DELETE")
         logger.error(msg)
         return 1014020001  # 数据格式错误
コード例 #27
0
ファイル: manager.py プロジェクト: GSIL-Monitor/xxw
 def get(self):
     logger.info("[D] [功能 商户经理面签单审核占比获取]")
     req = self.validate_data
     logger_req(req)
     days = req.get("days") or 30
     time_start = utc_timestamp() - (days * 24 * 60 * 60)
     time_end = utc_timestamp()
     manager = request.current_user
     # 面签审核条件
     a = TbFaceSignUser.manager_code == manager.code  # 商户编码
     b = (TbFaceSignUser.update_time >= time_start)  # 预约起始起始时间
     c = (TbFaceSignUser.update_time <= time_end)  # 预约结束时间
     d = TbFaceSignUser.status.in_([2, 3, 4])  # 审核总数
     e = TbFaceSignUser.status == 3  # 面签成功
     e_f = TbFaceSignUser.status == 4
     # 扫码量条件
     f = LogLoading.manager_id == manager.code
     g = LogLoading.load_time >= time_start  # 起始时间
     h = LogLoading.load_time >= time_start  # 结束时间
     # 注册量条件
     i = LogRegister.manager_id == manager.code
     j = LogRegister.reg_time >= time_start
     k = LogRegister.reg_time >= time_start
     # 面签总数
     ke = [a, b, c, d]
     all_facesign = TbFaceSignUser.query.filter(*ke).count()
     # 面签审核成功
     ke_p = [a, b, c, e]
     pass_facesign = TbFaceSignUser.query.filter(*ke_p).count()
     # 面签审核失败
     ke_p = [a, b, c, e_f]
     refuse_facesign = TbFaceSignUser.query.filter(*ke_p).count()
     # 扫码量
     ke_sc = [f, g, h]
     scan_code = LogLoading.query.filter(*ke_sc).count()
     # 注册量
     ke_r = [i, j, k]
     register = LogRegister.query.filter(*ke_r).count()
     return {
         "all_number": all_facesign,
         "pass_number": pass_facesign,
         "refuse_number": refuse_facesign,
         "scan_code_number": scan_code,
         "register_number": register
     }
コード例 #28
0
ファイル: user.py プロジェクト: GSIL-Monitor/xxw
 def put(self):
     req = reset_pwd.parse_args(strict=True)
     user = TbUser.query.filter_by(code=req["id"]).first()
     if not user:
         return Msg.USER_NOT_EXISTS, 400
     user.generate_password("123456")
     msg = "SUPPORT | B_USER | RESET_PASSWORD | SUCCESS | EDITOR: {} {} | USER: {} {}".format(
         request.current_user.code, request.current_user.name, user.code,
         user.name)
     operation = TbOperation(operator_code=user.code,
                             content=msg,
                             category="USER_MANAGE",
                             type="EDIT")
     db.session.add(operation)
     db.session.commit()
     redis.delete("support_jwt_{}".format(user.code))
     logger.info(msg)
     return {}, 200
コード例 #29
0
ファイル: task.py プロジェクト: GSIL-Monitor/xxw
 def post(self):
     """
     分配审核任务
     """
     evt_type = self.validate_data.get("evt_type")
     operator = self.validate_data.get("operator")
     operator_id = self.validate_data.get("operator_id")
     count = self.validate_data.get("count")
     queryset = Evt.objects(operator_id=None, evt_type=evt_type)
     res_list = queryset.order_by("time")[:count]
     for evt in res_list:
         evt.operator = operator
         evt.operator_id = operator_id
         evt.save()
         logger.info("已分配审核任务 evt_id:%s , rxt(serial_no):%s , 审核类型:%s , 审核人:%s , 审核人id: %s " %
                     (evt.id, evt.serial_no, evt.evt_type, evt.operator, evt.operator_id))
     logger.info("分配成功数量:%s" % len(res_list))
     return {"cnt": len(res_list)}
コード例 #30
0
 def post(self):
     schema = Schema({
         "businessId": And(str),
         "menu": [{
             "path": And(str, len),
             "name": And(str, len),
             "visible": And(bool)
         }]
     })
     req, error = validate_schema(schema, request.json)
     if error:
         return error, 400
     biz = TbBusiness.query.filter_by(code=req["businessId"]).first()
     if not biz:
         return Msg.BUSINESS_NOT_EXIST, 400
     menus = []
     for i in req["menu"]:
         menu = TbMenu.query.filter_by(business_code=biz.code, path=i["path"]).first()
         if menu:
             # 通过 path 来确定一个菜单,用户就是对这个接口进行修改
             menu.name = i["name"]
             menu.visible = i["visible"]
         else:
             menu = TbMenu(
                 name=i["name"],
                 path=i["path"],
                 creator_code=request.current_user.code,
                 business_code=biz.code,
                 visible=i["visible"],
             )
             biz.menu.append(menu)
             menus.append(menu)
     db.session.add_all(menus)
     db.session.commit()
     for menu in menus:
         menu.code = str(1500000000 + menu.id)
     msg = "SUPPORT | B_USER | ADD_MENU | SUCCESS | USER: {} {} | MENU: {}".format(
         request.current_user.code, request.current_user.name, [i.name for i in menus])
     operation = TbOperation(operator_code=request.current_user.code, content=msg, category="MENU", type="ADD")
     db.session.add(operation)
     db.session.commit()
     logger.info(msg)
     return {}, 200