www.pudn.com > Community_open20061104.rar > AuctionOrderMgr.java~3~


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; 
import cn.js.fan.web.SkinUtil; 
 
/** 
 * 

Title:

* *

Description:

* *

Copyright: Copyright (c) 2005

* *

Company:

* * @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(SkinUtil.LoadString(request,"res.plugin.auction","err_score_self"));//对不起,您不能给自己评分! else throw new ErrMsgException(SkinUtil.LoadString(request,"res.plugin.auction","err_score_sellers"));//对不起,您不能给卖家评分,如有问题请投诉! } } 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(SkinUtil.LoadString(request,"res.plugin.auction","err_score_buyers"));//对不起,您不能再给买家评分,如有问题请投诉! } } }