⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rewardmsgaction.java

📁 cwbbs 云网论坛源码
💻 JAVA
字号:
package com.redmoon.forum.plugin.reward;import javax.servlet.http.HttpServletRequest;import cn.js.fan.util.ErrMsgException;import javax.servlet.ServletContext;import com.redmoon.forum.plugin.base.IPluginMsgAction;import org.apache.log4j.Logger;import com.redmoon.forum.MsgDb;import cn.js.fan.util.ParamUtil;import cn.js.fan.util.StrUtil;import cn.js.fan.util.ResKeyException;import com.redmoon.kit.util.FileUpload;import com.redmoon.forum.MsgMgr;import com.redmoon.forum.plugin.ScoreMgr;import com.redmoon.forum.plugin.ScoreUnit;import cn.js.fan.web.SkinUtil;public class RewardMsgAction implements IPluginMsgAction {    Logger logger = Logger.getLogger(this.getClass().getName());    public RewardMsgAction() {    }        public synchronized boolean editTopic(ServletContext application,                                          HttpServletRequest request,                                          MsgDb md, FileUpload fu) throws            ErrMsgException {        boolean re = false;        if (md.getReplyid() == -1) {            RewardDb rd = new RewardDb();            rd = rd.getRewardDb(md.getId());            if (rd.getScoreGiven()>0)                return true;            String moneyCode = fu.getFieldValue("moneyCode");            String strPoint = fu.getFieldValue("sum");            int point = 0;            if (StrUtil.isNumeric(strPoint)) {                point = Integer.parseInt(strPoint);            } else                throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_score"));            if (moneyCode.equals(""))                throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_choose_Currency"));                        ScoreMgr sm = new ScoreMgr();            ScoreUnit su = sm.getScoreUnit(moneyCode);            double syScore = su.getScore().getUserSum(md.getName());            if (syScore < point) {                String str = SkinUtil.LoadString(request,"res.forum.plugin.reward","err_score_OutOfBalance");                str = StrUtil.format(str,new Object[]{""+syScore});                                throw new ErrMsgException(str);            }            rd.setMoneyCode(moneyCode);            rd.setScore(point);            try {                re = rd.save();            }            catch (ResKeyException e) {                throw new ErrMsgException(e.getMessage(request));            }        }        else            return true;        return re;    }    public boolean AddNew(ServletContext application,                          HttpServletRequest request, MsgDb md, FileUpload fu) throws            ErrMsgException {                String moneyCode = StrUtil.getNullString(fu.getFieldValue("moneyCode"));        String strPoint = StrUtil.getNullStr(fu.getFieldValue("sum"));        int point = 0;        if (StrUtil.isNumeric(strPoint)) {            point = Integer.parseInt(strPoint);        }        else                throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_score"));        if (moneyCode.equals(""))                throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_choose_Currency"));                ScoreMgr sm = new ScoreMgr();        ScoreUnit su = sm.getScoreUnit(moneyCode);        try {            su.getScore().pay(md.getName(), su.getScore().SELLER_SYSTEM, point);        }        catch (ResKeyException e) {            throw new ErrMsgException(e.getMessage(request));        }        RewardDb rd = new RewardDb();        rd.setMsgId(md.getId());        rd.setScore(point);        rd.setMoneyCode(moneyCode);        boolean re = false;        try {            re = rd.create();        }        catch (ResKeyException e) {            throw new ErrMsgException(e.getMessage(request));        }        return re;    }    public boolean AddQuickReply(ServletContext application,                                 HttpServletRequest request, long replyMsgId) throws            ErrMsgException {        return true;    }        public boolean delTopic(ServletContext application,                            HttpServletRequest request, MsgDb md) throws            ErrMsgException {        return true;    }        public boolean delSingleMsg(long delId) throws            ResKeyException {        RewardDb rd = new RewardDb();        rd = rd.getRewardDb(delId);        if (rd.isLoaded())            return rd.del();        else            return true;    }    public boolean AddReply(ServletContext application,                            HttpServletRequest request, MsgDb md, FileUpload fu) throws            ErrMsgException {        return true;    }        public int pay(HttpServletRequest request) throws ErrMsgException {        long msgId = ParamUtil.getLong(request, "msgId");        MsgMgr mm = new MsgMgr();        MsgDb md = mm.getMsgDb(msgId);        if (!md.isLoaded()) {            throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_isNotExsist"));        }                RewardPrivilege rp = new RewardPrivilege();        if (!rp.isOwner(request, md.getRootid())) {            throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_isOwner"));        }        int score = ParamUtil.getInt(request, "score");        if (score<=0) {            throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","score_invalid"));        }        RewardDb rootRd = new RewardDb();        rootRd = rootRd.getRewardDb(md.getRootid());                RewardDb rd = rootRd.getRewardDb(msgId);        if (rd.isLoaded()) {            String moneyCode = rootRd.getMoneyCode();            ScoreMgr sm = new ScoreMgr();            ScoreUnit su = sm.getScoreUnit(moneyCode);            String moneyName = "";            if (su!=null)               moneyName = su.getName(request);            String str = SkinUtil.LoadString(request, "res.forum.plugin.reward", "err_isSended");            str = StrUtil.format(str, new Object[] {""+moneyName});            str = StrUtil.format(str, new Object[] {""+rd.getScore()});            throw new ErrMsgException(str);                    }                if (rootRd.isEnd()) {            throw new ErrMsgException(SkinUtil.LoadString(request,"res.forum.plugin.reward","err_isEnd"));        }        int r = 0;        try {            r = rootRd.doPay(md, score);        }        catch (ResKeyException e) {            throw new ErrMsgException(e.getMessage(request));        }        return r;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -