Exemple #1
0
def init_cron_job():
    """
    初始化系统cron job
    :return:
    """
    apply_req = ArgumentParser().args.apply_req
    match = ArgumentParser().args.match
    apply_pay = ArgumentParser().args.apply_pay
    accept_req = ArgumentParser().args.accept_req
    apply_wait = ArgumentParser().args.apply_wait

    # init
    AcceptApplyMatcher().init(AcceptHelpMgr().match_ls,
                              ApplyHelpMgr().match_ls,
                              AcceptHelpMgr().do_accept,
                              ApplyHelpMgr().do_apply,
                              ServerInfoMgr().make_unique_id)

    Jobs().add_cron_job(ApplyReqFilter().filter,
                        **{apply_req.split('_')[0]: int(apply_req.split('_')[1])})
    Jobs().add_cron_job(AcceptApplyMatcher().match,
                        **{match.split('_')[0]: int(match.split('_')[1])})

    if ArgumentParser().args.enable_pay_check:
        Jobs().add_cron_job(ApplyPayFilter().filter,
                            **{apply_pay.split('_')[0]: int(apply_pay.split('_')[1])})

    Jobs().add_cron_job(AcceptReqFilter().filter,
                        **{accept_req.split('_')[0]: int(accept_req.split('_')[1])})
    Jobs().add_cron_job(ApplyWaitFilter().filter,
                        **{apply_wait.split('_')[0]: int(apply_wait.split('_')[1])})
    [logger.warn("cron job:%s" % {"cron": cron_job.cron, "func": cron_job.func}) for cron_job in Jobs().cron_job]
Exemple #2
0
    def do_deny_pay(self, apply_sorder):
        """
        拒绝支付处理
        :param apply_sorder: 申请帮助子订单id
        :return:
        """
        from mmm_da.lib.help.control import ApplyHelpMgr, AcceptHelpMgr
        apply_help_pay_dic = self.get_data_by_sorder(apply_sorder)
        assert apply_help_pay_dic

        apply_help_dic = ApplyHelpMgr().get_data_by_order(
            apply_help_pay_dic['apply_order'])

        # 封号
        account = AccountMgr().get_data_by_id(apply_help_dic['apply_uid'])
        account.attr_stat = SEALED

        # 接受帮助/申请帮助恢复
        AcceptHelpMgr().do_recover(apply_help_pay_dic['accept_order'],
                                   apply_help_pay_dic['apply_pmoney'])
        ApplyHelpMgr().do_recover(apply_help_pay_dic['apply_order'],
                                  apply_help_pay_dic['apply_pmoney'])

        # 未支付奖金处理
        BonusMgr().on_apply_cancel(apply_help_dic['apply_uid'],
                                   apply_help_pay_dic['apply_pmoney'])

        upd_dic = {
            "apply_sorder": apply_sorder,
            "apply_pstat": APYS_PAY_REFUSE
        }
        self.update_dic(apply_sorder, upd_dic)
Exemple #3
0
    def get(self, account, apply_uid, accept_uid, apply_money, **kwargs):
        apply_money = int(apply_money)

        if not AccountMgr().is_id_exist(apply_uid):
            logger.info(
                "AutoMatchHandler ERROR_UID_NOT_EXIST, apply_uid not existed, %s"
                % apply_uid)
            self.set_status(error_code.ERROR_UID_NOT_EXIST, 'Parameter Error')
            return error_code.ERROR_UID_NOT_EXIST

        if not AccountMgr().is_id_exist(accept_uid):
            logger.info(
                "AutoMatchHandler ERROR_UID_NOT_EXIST, id not existed, %s" %
                accept_uid)
            self.set_status(error_code.ERROR_UID_NOT_EXIST, 'Parameter Error')
            return error_code.ERROR_UID_NOT_EXIST

        # 获取申请帮助信息
        apply_help_dic = ApplyHelpMgr().get_unfinish(apply_uid)
        if not apply_help_dic:
            # 判断是否有申请帮助请求在排队,如果有,直接进入匹配模式
            apply_help_req = ApplyHelpReqMgr().get_unfinish(apply_uid)
            if not apply_help_req:
                logger.info(
                    "AutoMatchHandler ERROR_LOGIC, not apply_help_dic, apply_uid:%s"
                    % apply_uid)
                self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
                return error_code.ERROR_LOGIC

            ApplyHelpReqMgr().do_match(apply_help_req['id'])
            apply_help_dic = ApplyHelpMgr().get_unfinish(apply_uid)
            assert apply_help_dic

        # 获取接受帮助信息
        accept_help_dic = AcceptHelpMgr().get_unfinish(accept_uid)
        if not accept_help_dic:
            accept_help_req = AcceptHelpReqMgr().get_unfinish(accept_uid)
            if not accept_help_req:
                logger.info(
                    "AutoMatchHandler ERROR_LOGIC, not accept_help_dic, accept_uid:%s"
                    % accept_uid)
                self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
                return error_code.ERROR_LOGIC

            AcceptHelpReqMgr().do_match(accept_help_req['id'])
            accept_help_dic = AcceptHelpMgr().get_unfinish(accept_uid)
            assert accept_help_dic

        # 接受帮助金额判定
        apply_money = min(apply_money, apply_help_dic['apply_lmoney'],
                          accept_help_dic['accept_lmoney'])

        # 手动匹配
        accept_matched_ls = [{
            "accept_order": accept_help_dic['accept_order'],
            "apply_money": apply_money
        }]
        AcceptApplyMatcher().matched_proc(apply_help_dic, accept_matched_ls)
        return error_code.ERROR_SUCCESS
Exemple #4
0
    def do_finish(self, apply_sorder):
        """
        申请帮助完成
        :param apply_sorder: 申请帮助子订单id
        :return:
        """
        upd_dic = {
            "apply_sorder": apply_sorder,
            "apply_pstat": APYS_PAY_FINISH
        }
        self.update_dic(apply_sorder, upd_dic)

        from mmm_da.lib.help.control import ApplyHelpMgr
        apply_help_pay_dic = self.get_data_by_sorder(apply_sorder)
        apply_help = ApplyHelpMgr().get_data_by_order(
            apply_help_pay_dic['apply_order'])

        # 删除支付截图
        if apply_help_pay_dic['apply_piture']:
            file_name = apply_help_pay_dic['apply_piture'].split("/")[-1]
            pic_store_path = "%s/%s" % (ArgumentParser().args.pic_store_path,
                                        file_name)

            logger.info("ApplyHelpMgr::do_finish del pic_store_path:%s " %
                        pic_store_path)
            rm_pay_pic(pic_store_path)

        # 订单完成奖励
        BonusMgr().on_apply_finish(apply_help['apply_uid'],
                                   apply_help_pay_dic['apply_pmoney'])

        # 内存删除完成订单
        self.__del_data_2_mem(apply_help_pay_dic)
Exemple #5
0
    def do_confirm(self, apply_sorder):
        """
        确定收款处理, 订单完成
        :param apply_sorder: 申请帮助子订单id
        :return:
        """
        from mmm_da.lib.help.control import ApplyHelpMgr
        upd_dic = {"apply_sorder": apply_sorder, "apply_pstat": APYS_PAY_CFRM}
        self.update_dic(apply_sorder, upd_dic)

        # 确认奖励处理
        BonusMgr().on_confirm_pay(apply_sorder)

        apply_help_pay_dic = self.get_data_by_sorder(apply_sorder)

        # 添加马夫罗到钱包余额
        apply_help_dic = ApplyHelpMgr().get_data_by_order(
            apply_help_pay_dic['apply_order'])

        assert apply_help_dic
        account = AccountMgr().get_data_by_id(apply_help_dic['apply_uid'])

        account.attr_mafuluo += BonusMgr().on_extract_pi(apply_sorder)

        # 排单币返还成钱包余额
        account.attr_mafuluo += BonusMgr().match_coin_back(apply_sorder)

        # 订单完成
        self.do_finish(apply_sorder)
Exemple #6
0
    def on_extract_pi(self, apply_sorder):
        """
        计算本息: 计息间隔:申请帮助开始时间到申请帮助匹配时间
        :param apply_sorder: 申请帮助子订单id
        :return:
        """
        from mmm_da.lib.help_pay.control import ApplyHelpPayMgr
        from mmm_da.lib.help.control import ApplyHelpMgr

        assert ApplyHelpPayMgr().is_confirmed(apply_sorder)
        apply_help_pay_dic = ApplyHelpPayMgr().get_data_by_sorder(apply_sorder)
        apply_help_dic = ApplyHelpMgr().get_data_by_order(apply_help_pay_dic['apply_order'])

        # apply_req_time 就是申请帮助请求时间
        # apply_stime 就是申请帮助请求匹配时间,也即申请帮助开始时间
        pi = calc_pi(apply_help_pay_dic['apply_pmoney'],
                     apply_help_pay_dic['apply_interest'],
                     apply_help_dic['apply_stime'],
                     apply_help_pay_dic['apply_mtime'])
        assert pi
        logger.info("BonusMgr::on_extract_pi apply_money:%s apply_interest:%s days_diff:%s pi:%s" %
                    (apply_help_pay_dic['apply_pmoney'],
                     apply_help_pay_dic['apply_interest'],
                     apply_help_dic['apply_stime'] - apply_help_pay_dic['apply_mtime'],
                     pi))
        return pi
Exemple #7
0
    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}
Exemple #8
0
    def post(self, account, apply_sorder, **kwargs):
        # 获取申请帮助子订单信息
        apply_help_pay = ApplyHelpPayMgr().get_data_by_sorder(apply_sorder)
        if not apply_help_pay:
            logger.info("accept_help_confirm ERROR_LOGIC, not apply_help!!!, apply_sorder:%s" % apply_sorder)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        accept_order = apply_help_pay['accept_order']
        apply_order = apply_help_pay['apply_order']
        accept_help = AcceptHelpMgr().get_data_by_order(accept_order)

        if not accept_help:
            logger.info("accept_help_confirm ERROR_LOGIC, not accept_help!!!, accept_order:%s" % accept_order)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        if accept_help['accept_uid'] != account.id:
            logger.info("accept_help_confirm ERROR_LOGIC, apply_sorder's accept uid not the account!!!, uid:%s, account:%s" % (accept_help['accept_uid'], account.id))
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 申请帮助支付订单确认
        ApplyHelpPayMgr().do_confirm(apply_sorder)

        # 申请帮助订单确认
        ApplyHelpMgr().do_confirm(apply_order)

        # 接受帮助订单确认
        AcceptHelpMgr().do_confirm(accept_order)
        return {"result": error_code.ERROR_SUCCESS}
Exemple #9
0
    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}
Exemple #10
0
    def post(self,
             account,
             apply_sorder,
             pay_msg="",
             file_path="",
             file_name="",
             **kwargs):
        """
        nginx文件上传回调
        :param account: 上传账号
        :param apply_sorder: 上传的子申请帮助订单id
        :param pay_msg:  支付消息
        :param file_path: 上传的文件路径
        :param file_name: 上传的文件名
        :param kwargs:  其他参数
        :return:
        """
        apply_help_pay_dic = ApplyHelpPayMgr().get_data_by_sorder(apply_sorder)
        apply_help_dic = ApplyHelpMgr().get_data_by_order(
            apply_help_pay_dic['apply_order'])
        if apply_help_dic['apply_uid'] != account.id:
            logger.info(
                "apply_help_paid ERROR_LOGIC, apply_uid not valid, apply_uid:%s, id:%s"
                % (apply_help_dic['apply_uid'], account.id))
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        if apply_help_pay_dic['apply_pstat'] != APYS_PAY_WAIT:
            logger.warn(
                "apply_help_paid ERROR_LOGIC, apply stat is not APYS_PAY_WAIT, apply_uid:%s, id:%s"
                % (apply_help_dic['apply_uid'], account.id))
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        if file_path:
            suffix = file_name.split(".")[1]

            new_file_name = "%s_%s.%s" % (
                account.id,
                urllib2.quote(
                    time.strftime("%Y_%m_%d_%H_%M_%S",
                                  time.localtime(time.time()))), suffix)

            # 将nginx临时上传文件移动到存储路径
            mv_pay_pic(file_path, new_file_name,
                       ArgumentParser().args.pic_store_path)

            cur_piture_link_path = ArgumentParser(
            ).args.pic_download_path + new_file_name
        else:
            cur_piture_link_path = ""
        ApplyHelpPayMgr().do_pay(apply_sorder, cur_piture_link_path, pay_msg)
        return {
            "result": error_code.ERROR_SUCCESS,
            "apply_help": {
                "apply_sorder": apply_sorder,
                "apply_pstat": apply_help_pay_dic['apply_pstat']
            }
        }
Exemple #11
0
    def post(self, account, apply_sorder, **kwargs):
        # 获取申请帮助支付信息
        apply_help_pay = ApplyHelpPayMgr().get_data_by_sorder(apply_sorder)
        if not apply_help_pay:
            logger.info("apply_help_refuse ERROR_LOGIC, not apply_help!!!, apply_sorder:%s" % apply_sorder)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 获取申请帮助信息
        apply_help = ApplyHelpMgr().get_data_by_order(apply_help_pay['apply_order'])

        if apply_help['apply_uid'] != account.id:
            logger.info("apply_help_refuse ERROR_LOGIC, apply_sorder's apply uid not the account!!!, apply_uid:%s, id:%s" % (apply_help['apply_uid'], account.id))
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        ApplyHelpMgr().do_deny_pay(apply_help_pay['apply_order'])
        ApplyHelpPayMgr().do_deny_pay(apply_sorder)
        return {"result": error_code.ERROR_SUCCESS}
Exemple #12
0
    def on_confirm_pay(self, apply_sorder):
        """
        确认支付奖励处理
        :param apply_sorder: 申请帮助子订单id
        :return:
        """
        from mmm_da.lib.server_info import ServerInfoMgr, daysdiff
        from mmm_da.lib.help_pay.control import ApplyHelpPayMgr
        from mmm_da.lib.help.control import ApplyHelpMgr
        apply_help_pay_dic = ApplyHelpPayMgr().get_data_by_sorder(apply_sorder)
        apply_help_dic = ApplyHelpMgr().get_data_by_order(apply_help_pay_dic['apply_order'])

        days2confirm = daysdiff(time.time(), apply_help_dic['apply_stime'])
        for reward_hour, reward_int in ServerInfoMgr().attr_cfmd_reward_dic.items():
            reward_hour = float(reward_hour)
            if days2confirm <= reward_hour:
                upd_dic = {"apply_sorder": apply_sorder,
                           "apply_interest": apply_help_pay_dic['apply_interest'] + reward_int}
                ApplyHelpPayMgr().update_dic(apply_sorder, upd_dic)
                logger.warn("BonusMgr::on_confirm_pay reward!!!, reward_hour:%s,reward_int:%s "
                            % (reward_hour, reward_int))
                break
Exemple #13
0
    def do_match(self, id):
        """
        进入匹配队列处理
        :param id: id
        :return:
        """
        # upd data
        upd_dic = {'id': id, 'apply_req_stat': APYRS_FINISH}

        self.__update_dic(id, upd_dic)

        # 请求队列个数减少
        ServerInfoMgr().attr_total_apply_cnt -= 1

        # 加入申请帮助管理器,进入匹配队列
        apply_req_dic = self.get_data_by_id(id)
        ApplyHelpMgr().add_apply_help(apply_req_dic['id'],
                                      apply_req_dic['apply_req_uid'],
                                      apply_req_dic['apply_req_money'],
                                      apply_req_dic['apply_req_time'])

        # 从匹配队列删除
        self.__del_data_2_mem(self.get_data_by_id(id))
Exemple #14
0
    def do_req(self, account, apply_money):
        """
        请求处理
        :param account:
        :param apply_money:
        :return: error_code
        """
        apply_money = int(apply_money)
        if apply_money < MIN_APPLY_HELP_MONEY or apply_money > MAX_APPLY_HELP_MONEY:
            logger.info(
                "apply_help ERROR_LOGIC, not valid apply_money:%s must > %s and < %s"
                % (apply_money, MIN_APPLY_HELP_MONEY, MAX_APPLY_HELP_MONEY))
            return error_code.ERROR_LOGIC

        # 投资必须为1000的整数倍
        if apply_money % 1000 != 0:
            logger.info("apply_help ERROR_LOGIC, not times of 1000:%s" %
                        apply_money)
            return error_code.ERROR_LOGIC

        # 还在请求处理,
        if ApplyHelpReqMgr().get_unfinish(account.id):
            logger.info(
                "apply_help ERROR_LOGIC, has ApplyHelpReqMgr!!!, id:%s" %
                account.id)
            return error_code.ERROR_LOGIC

        # 还在匹配处理
        if ApplyHelpMgr().get_datas_by_uid(account.id):
            logger.info("apply_help ERROR_LOGIC, has ApplyHelpMgr!!!, id:%s" %
                        account.id)
            return error_code.ERROR_LOGIC

        # 投资额必须大于等于之前累计投资额
        if apply_money < account.attr_max_apply_money:
            logger.info(
                "apply_help ERROR_LOGIC, apply_money:%s must big than max_apply_money:%s!!!, id:%s"
                % (apply_money, account.attr_max_apply_money, account.id))
            return error_code.ERROR_MAX_APPLY_HELP_LESS

        # 排单币不够
        must_match_coin = calc_match_coin(apply_money)
        if account.attr_match_coin <= must_match_coin:
            logger.info(
                "apply_help ERROR_LOGIC, not enouth match coin!!!, id:%s, match_coin:%s, must_match_coin:%s, apply_money:%s"
                % (account.id, account.attr_match_coin, must_match_coin,
                   apply_money))
            return error_code.EEROR_MATCH_COIN_LACK

        # 添加申请帮助请求
        self.add_req(account.id, apply_money)

        # 设置最大投资额
        account.attr_max_apply_money = apply_money

        # 扣除排单币
        account.attr_match_coin -= must_match_coin

        # 判断是否有等待申请帮助,如果有则删除对应等待
        from mmm_da.lib.help_wait.control import ApplyHelpWaitMgr
        ApplyHelpWaitMgr().del_wait(account.id)

        return error_code.ERROR_SUCCESS
Exemple #15
0
    def post(self, account, mafuluo, **kwargs):
        """
        接受帮助的时候,如果有一单申请帮助未完成,则不能接受帮助
        :param account: 账号
        :param mafuluo: 提取的马夫罗,整形
        :param kwargs:
        :return:
        """
        mafuluo = int(mafuluo)
        # 提取的马夫罗总数必须大于0
        if mafuluo <= 0 :
            logger.info("accept_help ERROR_LOGIC, mafuluo:%s<=0!!!, id:%s" % (mafuluo, account.id))
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 提取的马夫罗必须小于账号拥有的马夫罗
        if mafuluo > account.attr_mafuluo:
            logger.info("accept_help ERROR_LOGIC, mafuluo:%s>=acount.attr_mafuluo:%s!!!, id:%s" % (mafuluo, account.attr_mafuluo, account.id))
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 申请帮助还在请求处理,
        if ApplyHelpReqMgr().get_unfinish(account.id):
            logger.info("accept_help ERROR_LOGIC, has ApplyHelpReqMgr!!!, id:%s" % account.id)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 申请帮助还在匹配处理
        if ApplyHelpMgr().get_unfinish(account.id):
            logger.info("accept_help ERROR_LOGIC, has ApplyHelpMgr!!!, id:%s" % account.id)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 接受帮助还在请求处理,
        if AcceptHelpReqMgr().get_unfinish(account.id):
            logger.info("apply_help ERROR_LOGIC, has AcceptHelpReqMgr!!!, id:%s" % account.id)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 接受帮助还在匹配处理
        if AcceptHelpMgr().get_unfinish(account.id):
            logger.info("apply_help ERROR_LOGIC, has AcceptHelpMgr!!!, id:%s" % account.id)
            self.set_status(error_code.ERROR_LOGIC, 'Parameter Error')
            return {"result": error_code.ERROR_LOGIC}

        # 资金平衡判断
        if ArgumentParser().args.use_system_balance:
            if ServerInfoMgr().attr_total_accept_money + mafuluo + ServerInfoMgr().attr_system_balance\
                    > ServerInfoMgr().attr_total_apply_money:
                logger.info("accept_help ERROR_LOGIC, has reach the system balance!!!, "
                            "total_accept_money:%s, total_apply_money:%s, system_balance:%s, mafuluo:%s"
                            %(ServerInfoMgr().attr_total_accept_money,
                              ServerInfoMgr().attr_total_apply_money,
                              ServerInfoMgr().attr_system_balance,
                              mafuluo))
                self.set_status(error_code.EEROR_ACCEPT_BALANCE, 'Parameter Error')
                return

        # 扣除mafuluo
        account.attr_mafuluo -= mafuluo

        # 请求接受帮助
        AcceptHelpReqMgr().add_req(account.id, mafuluo)

        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)}
Exemple #16
0
 def post(self, account, **kwargs):
     return {
         "result": error_code.ERROR_SUCCESS,
         "apply_help_list": ApplyHelpMgr().match_ls()
     }