Example #1
0
def agency_financial_detail():
    form = QueryAgencyFinancialForm()
    #    wtforms_components.read_only(form.submit2) #TODO, 暂时禁用, 待实现db中的指出查询后去掉这一行
    if not current_user.is_staff():
        form.agencyid.data = current_user.agencyid
        wtforms_components.read_only(form.agencyid)

    if form.validate_on_submit():
        agencyid = form.agencyid.data if current_user.is_staff(
        ) else current_user.agencyid  #反外挂
        if form.submit1.data is True:
            info = u"购钻明细, 代理ID: {}".format(agencyid)
            dbRetIsOk, rowData, totalMoney = Mysqlhandler.me(
            ).queryAgencyIncomeDetail(agencyid)
            cols = [u"交易流水号", u"钻石数量", u"上级代理ID", u"时间"]
        else:
            info = u"支钻明细, 代理ID: {}".format(agencyid)
            dbRetIsOk, rowData, totalMoney = Mysqlhandler.me(
            ).queryAgencyOutcomeDetail(agencyid)
            cols = [u"交易流水号", u"钻石数量", u"下级代理ID", u"玩家ID", u"时间"]
        if dbRetIsOk == True:
            ext_info = u"总额:{}".format(totalMoney)
            return render_template(
                'query_ret.html',
                info=info,
                ext_info=ext_info,
                cols=cols,
                records=rowData,
                next_url=url_for('main.agency_financial_detail'))
        flash(u"查询失败{}".format(dbRetData))
    return render_template('form.html', form=form, tittle=u"钻石明细查询")
Example #2
0
def player_recharge():
    form = AddPlayerMoneyForm()
    if form.validate_on_submit():
        playerid = form.playerid.data
        money = form.money.data

        agencyid = current_user.agencyid
        if current_user.is_admin():
            dbRetIsOk, dbRetData = Mysqlhandler.me().playerRechargeByAdmin(
                agencyid, playerid, money)
        else:
            dbRetIsOk, dbRetData = Mysqlhandler.me().playerRechargeByAgency(
                agencyid, playerid, money)

        if dbRetIsOk == True:
            current_user.refreshFromDb()
            form.playerid.data = ""
            form.money.data = ""
            msg = u'充值成功, 玩家id:{}, 充值额:{}, 流水号:{}'.format(
                playerid, money, dbRetData)
            return redirect(
                url_for('main.rander_form_ret',
                        msg=msg,
                        op='main.player_recharge'))
        else:
            flash(u"充值失败, {}".format(dbRetData))
    return render_template('form.html', form=form, tittle=u"给玩家游戏账号充值")
Example #3
0
def agency_recharge():
    form = AddAgencyMoneyForm()
    if form.validate_on_submit():
        agencyid = form.agencyid.data
        money = form.money.data
        superviorid = current_user.agencyid

        if current_user.is_admin():
            dbRetIsOk, dbRetData = Mysqlhandler.me().agencyRechargeByAdmin(
                superviorid, agencyid, money)
        else:
            dbRetIsOk, dbRetData = Mysqlhandler.me().agencyRechargeBySupervior(
                superviorid, agencyid, money)
        if dbRetIsOk == True:
            current_user.refreshFromDb()
            form.agencyid.data = ""
            form.money.data = ""
            msg = u'代理充值成功, ID:{}, 充值额:{}, 流水号:{}'.format(
                agencyid, money, dbRetData)
            return redirect(
                url_for('main.rander_form_ret',
                        msg=msg,
                        op='main.agency_recharge'))

        flash(u"充值失败, {}".format(dbRetData))
    return render_template('form.html', form=form, tittle=u"给代理金库充值")
Example #4
0
def agency_financial_info():
    superviorid = None if current_user.is_staff() else current_user.agencyid
    form = QueryAgencyFinancialInfoForm()
    if form.validate_on_submit():
        if form.submit1.data is True:
            info = u"下属累计购买钻石数量"
            dbRetIsOk, dbRetData = Mysqlhandler.me().queryAgencyIncomeInfo(
                superviorid)
        else:
            info = u"下属累计支出钻石总量"
            dbRetIsOk, dbRetData = Mysqlhandler.me().queryAgencyOutcomeInfo(
                superviorid)
        if dbRetIsOk == True:
            cols = [u"下级代理ID", u"钻石数量"]
            return render_template(
                'query_ret.html',
                info=info,
                cols=cols,
                records=dbRetData,
                next_url=url_for('main.agency_financial_info'))
        flash(u"查询失败, {}".format(dbRetData))
    return render_template('form.html', form=form, tittle=u"下属钻石情况查询")
Example #5
0
def agency_modify_password():
    superviorid = None if current_user.is_staff() else current_user.agencyid
    form = ModifyPasswordForm()
    if form.validate_on_submit():
        agencyid = current_user.agencyid
        password = form.password.data
        newpassword = form.newpassword.data
        dbRetIsOk, dbRetData = Mysqlhandler.me().agencyModifyPassword(
            agencyid, password, newpassword)
        if dbRetIsOk == True:
            msg = "修改密码成功"
            return redirect(
                url_for('main.rander_form_ret', msg=msg, op='main.index'))
        flash(u"修改密码失败, {}".format(dbRetData))
    return render_template('form.html', form=form, tittle=u"修改密码")
Example #6
0
def admin_del_agency():
    form = ModifyAgencyForm()
    if form.validate_on_submit():
        agencyid = form.agencyid.data
        dbRet = Mysqlhandler.me().delAgency(agencyid)
        if dbRet is None:
            form.agencyid.data = ''
            msg = u"操作成功, {} 已经不是代理了".format(agencyid)
            #return render_template('form_ret.html', msg = msg, next_url = url_for('main.admin_modify_agency'))
            return redirect(
                url_for('main.rander_form_ret',
                        msg=msg,
                        op='main.admin_del_agency'))
        flash(u"操作失败, {}".format(dbRet))
    return render_template('form.html', form=form, tittle=u"删除代理")
Example #7
0
def add_player():
    form = AddPlayerForm()
    if not current_user.is_staff():
        form.superviorid.data = current_user.agencyid
        wtforms_components.read_only(form.superviorid)
    if form.validate_on_submit():
        playerid = form.playerid.data
        superviorid = form.superviorid.data if current_user.is_staff(
        ) else current_user.agencyid  #反外挂
        dbRetIsOk, dbRetData = Mysqlhandler.me().addPlayer(
            superviorid, playerid, current_user.is_staff())

        if dbRetIsOk == True:
            form.playerid.data = ""
            form.superviorid.data = ""
            msg = u'玩家代理关系设置成功, 玩家ID:{}, 代理ID:{}'.format(playerid, superviorid)
            #return render_template('form_ret.html', msg = msg, next_url = url_for('main.add_player'))
            return redirect(
                url_for('main.rander_form_ret', msg=msg, op='main.add_player'))
        else:
            flash(u"绑定失败, {}".format(dbRetData))
    return render_template('form.html', form=form, tittle=u"设置玩家的代理")
Example #8
0
def admin_add_agency():
    form = AddAgencyForm()
    if form.validate_on_submit():
        agencyid = form.agencyid.data
        superviorid = form.superviorid.data
        password = form.password.data
        if agencyid == superviorid:
            flash(u"代理的上级不能是自己")
        else:
            dbRet = Mysqlhandler.me().addAgency(
                agencyid, password, superviorid,
                current_user.adminid() == superviorid)
            if dbRet is None:
                form.agencyid.data = None
                form.superviorid.data = current_user.agencyid
                msg = u'代理设置成功, ID:{}, 上级ID:{}'.format(agencyid, superviorid)
                #return render_template('form_ret.html', msg = msg, next_url = url_for('main.admin_add_agency'))
                return redirect(
                    url_for('main.rander_form_ret',
                            msg=msg,
                            op='main.admin_add_agency'))
            flash(u"代理设置失败, {}".format(dbRet))
    return render_template('form.html', form=form, tittle=u"设置代理")