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

📄 auctionordermgr.java~1~

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA~1~
字号:
package com.redmoon.forum.plugin.auction;

import javax.servlet.http.HttpServletRequest;
import com.redmoon.forum.Privilege;
import cn.js.fan.util.ParamUtil;
import cn.js.fan.util.ErrMsgException;
import com.redmoon.forum.person.UserDb;
import cn.js.fan.util.StrUtil;
import com.redmoon.forum.message.MessageDb;
import cn.js.fan.web.Global;
import cn.js.fan.mail.SendMail;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class AuctionOrderMgr {
    public AuctionOrderMgr() {
    }

    public boolean judgeSellerScore(HttpServletRequest request,
                                    AuctionOrderDb ao) throws ErrMsgException {
        Privilege privilege = new Privilege();
        String userName = privilege.getUser(request);
        int sScore = ao.getSellerScore();
        boolean canDo = false;
        // 当为买家时,分数未评时才可评分
        if (ao.getBuyer().equals(userName)) {
            if (sScore == ao.SCORE_NONE) {
                canDo = true;
            }
        }
        // 当为管理员时可评分
        cn.js.fan.module.pvg.Privilege pvg = new cn.js.fan.module.pvg.Privilege();
        if (pvg.isUserPrivValid(request, "auction"))
            canDo = true;
        if (canDo) {
            int sellerScore = ParamUtil.getInt(request, "score");
            int oldSellerScore = ao.getSellerScore();
            ao.setSellerScore(sellerScore);
            if (ao.save()) {
                // 给用户加分
                UserDb user = new UserDb();
                user = user.getUser(ao.getSeller());
                user.setCredit(user.getCredit() + (sellerScore-oldSellerScore));
                user.save();

                // 发送消息
                AuctionConfig ac = new AuctionConfig();
                // 发短消息
                String subject = ac.getProperty("judgeNotice.subject");
                String body = ac.getProperty("judgeNotice.body");
                body = body.replaceFirst("\\$user", userName);
                body = body.replaceAll("\\$orderId", "" + ao.getId());
                String rootPath = Global.getRootPath();
                rootPath = rootPath.replaceFirst("http", "hhttttpp");
                body = body.replaceAll("\\$rootPath", rootPath);
                body = body.replaceFirst("\\$judgeDesc", ao.getJudgeDesc(request, sellerScore));
                body = body.replaceFirst("\\$credit", ""+sellerScore);

                String ubbBody = ac.getProperty("judgeNotice.ubbBody");
                ubbBody = ubbBody.replaceFirst("\\$user", userName);
                ubbBody = ubbBody.replaceAll("\\$orderId", "" + ao.getId());
                ubbBody = ubbBody.replaceAll("\\$rootPath", rootPath);
                ubbBody = ubbBody.replaceFirst("\\$judgeDesc", ao.getJudgeDesc(request, sellerScore));
                ubbBody = ubbBody.replaceFirst("\\$credit", ""+sellerScore);

                MessageDb msd = new MessageDb();
                msd.title = subject;
                msd.content = ubbBody;
                msd.sender = msd.USER_SYSTEM;
                msd.type = msd.TYPE_SYSTEM;
                msd.ip = "0.0.0.0";
                // 至卖家
                msd.receiver = ao.getSeller();
                msd.create();
                // 至买家
                msd.receiver = ao.getBuyer();
                msd.create();

                // 发邮件
                String from = StrUtil.GBToUnicode(ac.getEmailAlias());
                from += "<" + ac.getEmail() + ">";

                // 至卖家
                SendMail sm = new SendMail();
                sm.send(Global.smtpServer, Global.smtpPort, Global.smtpUser, Global.smtpPwd, user.getEmail(), from, subject, body);
                // 至买家
                user = user.getUser(ao.getBuyer());
                sm.send(Global.smtpServer, Global.smtpPort, Global.smtpUser, Global.smtpPwd, user.getEmail(), from, subject, body);

                return true;
            } else
                return false;
        } else {
            if (userName.equals(ao.getSeller()))
                throw new ErrMsgException("对不起,您不能给自己评分!");
            else
                throw new ErrMsgException("对不起,您不能给卖家评分,如有问题请投诉!");
        }
    }

    public boolean judgeBuyerScore(HttpServletRequest request,
                                   AuctionOrderDb ao) throws ErrMsgException {
        Privilege privilege = new Privilege();
        String userName = privilege.getUser(request);
        int bScore = ao.getBuyerScore();
        boolean canDo = false;
        // 当为卖家评分时,只有分数未平时才可评分
        if (ao.getSeller().equals(userName)) {
            if (bScore == ao.SCORE_NONE) {
                canDo = true;
            }
        }
        // 管理员可评分
        cn.js.fan.module.pvg.Privilege pvg = new cn.js.fan.module.pvg.Privilege();
        if (pvg.isUserPrivValid(request, "auction"))
            canDo = true;

        if (canDo) {
            int buyerScore = ParamUtil.getInt(request, "score1");
            int oldBuyerScore = ao.getBuyerScore();
            ao.setBuyerScore(buyerScore);
            if (ao.save()) {
                // 给用户加分
                UserDb user = new UserDb();
                user = user.getUser(ao.getBuyer());
                user.setCredit(user.getCredit() + (buyerScore - oldBuyerScore));
                user.save();

                // 发送消息
                AuctionConfig ac = new AuctionConfig();
                // 发短消息
                String subject = ac.getProperty("judgeNotice.subject");
                String body = ac.getProperty("judgeNotice.body");
                body = body.replaceFirst("\\$user", userName);
                body = body.replaceAll("\\$orderId", "" + ao.getId());
                String rootPath = Global.getRootPath();
                rootPath = rootPath.replaceFirst("http", "hhttttpp");
                body = body.replaceAll("\\$rootPath", rootPath);
                body = body.replaceFirst("\\$judgeDesc",
                                         ao.getJudgeDesc(request, buyerScore));
                body = body.replaceFirst("\\$credit", "" + buyerScore);

                String ubbBody = ac.getProperty("judgeNotice.ubbBody");
                ubbBody = ubbBody.replaceFirst("\\$user", userName);
                ubbBody = ubbBody.replaceAll("\\$orderId", "" + ao.getId());
                ubbBody = ubbBody.replaceAll("\\$rootPath", rootPath);
                ubbBody = ubbBody.replaceFirst("\\$judgeDesc",
                                               ao.getJudgeDesc(request, buyerScore));
                ubbBody = ubbBody.replaceFirst("\\$credit", "" + buyerScore);

                MessageDb msd = new MessageDb();
                msd.title = subject;
                msd.content = ubbBody;
                msd.sender = msd.USER_SYSTEM;
                msd.type = msd.TYPE_SYSTEM;
                msd.ip = "0.0.0.0";
                // 至卖家
                msd.receiver = ao.getBuyer();
                msd.create();
                // 至买家
                msd.receiver = ao.getBuyer();
                msd.create();

                // 发邮件
                String from = StrUtil.GBToUnicode(ac.getEmailAlias());
                from += "<" + ac.getEmail() + ">";

                // 至卖家
                SendMail sm = new SendMail();
                sm.send(Global.smtpServer, Global.smtpPort, Global.smtpUser,
                        Global.smtpPwd, user.getEmail(), from, subject, body);
                // 至买家
                user = user.getUser(ao.getBuyer());
                sm.send(Global.smtpServer, Global.smtpPort, Global.smtpUser,
                        Global.smtpPwd, user.getEmail(), from, subject, body);

                return true;
            } else
                return false;
        } else {
            throw new ErrMsgException("对不起,您不能再给买家评分,如有问题请投诉!");
        }
    }


}

⌨️ 快捷键说明

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