예제 #1
0
파일: help.py 프로젝트: cash2one/FundTray
    def post(self, account, **kwargs):
        accept_help = AcceptHelpMgr().get_unfinish(account.id)

        if not accept_help:
            accept_help_req = AcceptHelpReqMgr().get_unfinish(account.id)
            return {"result": error_code.ERROR_SUCCESS,
                    "accept_help": accept_help_req_2_accept_help(accept_help_req),
                    "apply_help_ls": []}

        apply_help_ls =[]

        # 获取申请帮助子订单信息
        apply_help_pays = ApplyHelpPayMgr().get_datas_by_accept_order(accept_help['accept_order'])
        for apply_help_pay_dic in apply_help_pays:
            apply_help_dic = ApplyHelpMgr().get_data_by_order(apply_help_pay_dic['apply_order'])

            # 申请帮助信息
            apply_info = sub_dict(apply_help_dic, ['apply_order','apply_uid','apply_stime',])
            apply_info.update(sub_dict(apply_help_pay_dic, ['apply_sorder', 'apply_pmoney', 'apply_mtime', 'apply_pstat', 'apply_piture', 'apply_message']))

            # 申请帮助账号信息
            account_obj = AccountMgr().get_data_by_id(apply_help_dic['apply_uid'])
            apply_info['bank_name'] = account_obj.bank_name

            apply_help_ls.append(apply_info)
        return {"result": error_code.ERROR_SUCCESS,
                "accept_help": accept_help,
                "apply_help_ls": apply_help_ls}
예제 #2
0
파일: help.py 프로젝트: cash2one/FundTray
    def post(self, account, **kwargs):
        apply_helps = ApplyHelpMgr().get_datas_by_uid(account.id)

        if not apply_helps:
            # 将申请帮助请求信息转化成申请帮助信息
            apply_help_req = ApplyHelpReqMgr().get_unfinish(account.id)
            apply_help = apply_help_req_2_apply_help(apply_help_req)
            logger.info("cur_apply_help Success!!, not apply_helps:%s, apply_help_req:%s" % (apply_helps, apply_help_req))
            return {"result": error_code.ERROR_SUCCESS,
                    "apply_help_ls": [],
                    "apply_help": apply_help}

        assert len(apply_helps) == 1
        cur_apply_help = apply_helps[0]
        cur_apply_help_pay_ls = ApplyHelpPayMgr().get_datas_by_apply_order(cur_apply_help['apply_order'])

        apply_help_ls = []
        for apply_help_pay_dic in cur_apply_help_pay_ls:
            # 获取申请帮助信息
            apply_res_dic = sub_dict(cur_apply_help, ['apply_order', 'apply_uid', 'apply_stime',])
            apply_res_dic.update(sub_dict(apply_help_pay_dic, ['apply_sorder', 'apply_pmoney', 'apply_mtime', 'apply_pstat', 'apply_piture', 'apply_message']))

            # 获取接受帮助信息
            accept_info = AcceptHelpMgr().get_data_by_order(apply_help_pay_dic['accept_order'])
            apply_res_dic['accept_uid'] = accept_info['accept_uid']

            # 获取接受帮助账号信息
            account_obj = AccountMgr().get_data_by_id(accept_info['accept_uid'])
            apply_res_dic['bank_name'] = account_obj.bank_name

            apply_help_ls.append(apply_res_dic)

        return {"result": error_code.ERROR_SUCCESS,
                "apply_help": cur_apply_help,
                "apply_help_ls": apply_help_ls}
예제 #3
0
 def filter(data_dic):
     """
     过滤处理
     :param data_dic: 原有字典数据
     :return: 过滤后的字典数据
     """
     return sub_dict(data_dic, ["user_name", "password", "des", "jid", "jid_pwd", "device_type", "type"], "")
예제 #4
0
    def test_http_rpc_reset_server_setting_not_json_nomal(self):
        update_key_set = CAN_UPDAET_KEY_SET - JSON_KEY_SET
        before_server_settings = all_server_setting(MMMDAHttpRpcClt,
                                                    admin0d_id,
                                                    admin01_access_token)
        self.assertTrue(update_key_set == update_key_set
                        & set(before_server_settings.keys()))

        upd_keys = random.sample(list(update_key_set),
                                 random.randint(1, len(update_key_set)))
        print "upd_keys,", upd_keys
        upd_settins_dic = dict(
            (upd_key, random.randint(1, 10)) for upd_key in upd_keys)
        print "upd_settins_dic,", upd_settins_dic

        reset_res0 = reset_server_setting(MMMDAHttpRpcClt, admin0d_id,
                                          admin01_access_token,
                                          upd_settins_dic)
        print "reset_res0,", reset_res0
        self.assertTrue(upd_settins_dic == sub_dict(reset_res0, upd_keys))

        reset_res1 = reset_server_setting(MMMDAHttpRpcClt, admin0d_id,
                                          admin01_access_token,
                                          before_server_settings)
        print "reset_res1,", reset_res1
        self.assertTrue(reset_res1 == before_server_settings)
예제 #5
0
    def init(self, data_ls):
        assert data_ls
        self.__dict__ = data_ls[0]
        self.ddp = DirtyDictProcess([])

        self.pay_reward_dic = ujson.loads(self.pay_reward_dic)
        self.cfmd_reward_dic = ujson.loads(self.cfmd_reward_dic)
        logger.warn("ServerInfoMgr::init __dict__:%s" %
                    sub_dict(self.__dict__, KEY_SET))
예제 #6
0
    def test_http_rpc_reset_server_setting_json_nomal(self):
        update_key_set = JSON_KEY_SET
        before_server_settings = all_server_setting(MMMDAHttpRpcClt,
                                                    admin0d_id,
                                                    admin01_access_token)
        self.assertTrue(update_key_set == update_key_set
                        & set(before_server_settings.keys()))
        print "before_server_settings,", before_server_settings

        upd_keys = random.sample(list(update_key_set),
                                 random.randint(1, len(update_key_set)))
        print "upd_keys,", upd_keys

        def random_dic():
            return dict((i, round(random.random(), 2))
                        for i in random.sample(xrange(1, 100), 2))

        upd_settings_dic = dict(
            (upd_key, random_dic()) for upd_key in upd_keys)
        print "upd_settings_dic,", upd_settings_dic

        upd_settings_json_dic = dict(
            (k, ujson.dumps(v)) for k, v in upd_settings_dic.items())
        reset_res0 = reset_server_setting(MMMDAHttpRpcClt, admin0d_id,
                                          admin01_access_token,
                                          upd_settings_json_dic)
        print "reset_res0,", reset_res0
        print "sub_dict(reset_res0, upd_keys),", sub_dict(reset_res0, upd_keys)
        self.assertTrue(
            ujson.loads(ujson.dumps(upd_settings_dic)) == sub_dict(
                reset_res0, upd_keys))

        before_server_settings_json = copy.deepcopy(before_server_settings)
        [
            before_server_settings_json.update(
                {jkey: ujson.dumps(before_server_settings_json[jkey])})
            for jkey in JSON_KEY_SET
        ]
        reset_res1 = reset_server_setting(MMMDAHttpRpcClt, admin0d_id,
                                          admin01_access_token,
                                          before_server_settings_json)
        print "reset_res1,", reset_res1
        self.assertTrue(before_server_settings == reset_res1)
예제 #7
0
    def view_tp_service(tp_name=None):
        """
        查看第三方服务
        :param tp_name:第三方服务名称
        :return:服务字典, 服务个数字典
        """
        all_tp_services = ServicePuller().all_tp_services

        if tp_name and tp_name not in all_tp_services.keys():
            return {}, {}

        viewed_services = sub_dict(all_tp_services, [tp_name]) if tp_name else all_tp_services

        viewed_count_dic = dict((tp, len(tp_services)) for tp, tp_services in viewed_services.items())
        return viewed_services, viewed_count_dic
예제 #8
0
    def view_tp_service(tp_name=None):
        """
        查看第三方服务
        :param tp_name:第三方服务名称
        :return:服务字典, 服务个数字典
        """
        all_tp_services = ServicePuller().all_tp_services

        if tp_name and tp_name not in all_tp_services.keys():
            return {}, {}

        viewed_services = sub_dict(all_tp_services,
                                   [tp_name]) if tp_name else all_tp_services

        viewed_count_dic = dict((tp, len(tp_services))
                                for tp, tp_services in viewed_services.items())
        return viewed_services, viewed_count_dic
예제 #9
0
    def get(self, user_name, password, verify_code=None, type=None, param_sign=None, proxy_sign=None):
        """
        登陆
        :param verify_code: 客户端验证码
        :param user_name: 用户名
        :param password: 密码
        :param type:用户类型,1:控制端,2:设备端
        :param param_sign: 参数签名,用户调过验证码, 签名参数=verify_code, user_name, password
        :param proxy_sign: 代理签名,用于代理服务器的签名设置
        :return:
        """
        if not user_name\
                or not password\
                or not int(type) in enum.USER_TYPE_LS if type else False:
            return {'result': error_code.ERROR_PARAMS_ERROR}

        # 如果有param_sign,可使用验证param_sign越过验证码
        is_privilege = Signer().check_sign(param_sign, verify_code, user_name, password) \
            if param_sign \
            else False

        # 不使用验证码
        if type and int(type) in enum.NOT_VERIFY_CODE_USER_LS:
            is_privilege = True

        if not is_privilege:
            if not cookie.check_cookie(self, "register_verify_code", verify_code):
                logger.error("LoginHandle check_cookie failed!!!, verify_code:%s\n,param_sign:%s\n, HTTP_SGIN:%s"
                             % (verify_code, param_sign, HTTP_SIGN))
                return {'result': error_code.ERROR_VERIFY_CODE_ERROR}

        rgst_da_tcp = ServiceMgrCacher().get_connection(US_REGISTER_DA, RT_HASH_RING, user_name)
        user_info = get_user_info(rgst_da_tcp, user_name)
        if not user_info or user_info['password'] != password:
            return {'result': error_code.ERROR_USER_NAME_OR_PASSWORD_ERROR}
        elif type and int(user_info['type']) != int(type):
            return {'result': error_code.ERROR_PARAMS_ERROR}

        result = {"result": error_code.ERROR_SUCCESS,
                  "user_info": sub_dict(user_info, ["user_name", "jid", "jid_pwd", "type", "des"], ""),
                  "access_token": TokenMgr.generate_access_token(user_name)}

        if ArgumentParser().args.use_sign:
            result['sign'] = proxy_sign if proxy_sign else HTTP_SIGN
        return result
예제 #10
0
    def view_grp_service(service_grp=None):
        """
        查看逻辑服务
        :param service_grp:逻辑服务组
        :return:服务字典, 服务个数字典
        """
        all_grp_services = ServicePuller().all_grp_services

        if service_grp and service_grp not in all_grp_services.keys():
            return {}, {}

        view_grp_services = sub_dict(all_grp_services, [service_grp]) if service_grp else all_grp_services

        view_services = {}
        for grp, grp_service in view_grp_services.items():
            for service in grp_service:
                copy_service = copy.deepcopy(service)
                view_services.setdefault(grp, []).append(copy_service)

        view_count_dic = dict((grp, len(grp_service)) for grp, grp_service in view_services.items())
        return view_services, view_count_dic
예제 #11
0
    def view_grp_service(service_grp=None):
        """
        查看逻辑服务
        :param service_grp:逻辑服务组
        :return:服务字典, 服务个数字典
        """
        all_grp_services = ServicePuller().all_grp_services

        if service_grp and service_grp not in all_grp_services.keys():
            return {}, {}

        view_grp_services = sub_dict(
            all_grp_services,
            [service_grp]) if service_grp else all_grp_services

        view_services = {}
        for grp, grp_service in view_grp_services.items():
            for service in grp_service:
                copy_service = copy.deepcopy(service)
                view_services.setdefault(grp, []).append(copy_service)

        view_count_dic = dict((grp, len(grp_service))
                              for grp, grp_service in view_services.items())
        return view_services, view_count_dic
예제 #12
0
 def get_info_dic(self):
     """
     获取所有信息
     :return:
     """
     return sub_dict(self.__dict__, KEY_SET)