📄 eccreditaction.java
字号:
explanation= explanation==null?"":explanation;
explanation = Common.cutstr(Common.htmlspecialchars(explanation), 200, "");
dataBaseService.runQuery("update jrun_tradecomments set explanation='"+explanation+"' where id="+id);
String message = "<script type=\"text/javascript\">$('ecce_"+id+"').innerHTML = '<font class=\"lighttxt\">解释: "+explanation+"</font>';hideMenu();</script>";
writeMessage(response,message,false);
}
return null;
}
@SuppressWarnings("unchecked")
public ActionForward rate(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
Map<String,String> settings = (Map<String,String>)request.getAttribute("settings");
int timestamp = (Integer)(request.getAttribute("timestamp"));
int jsprun_uid = (Integer)request.getSession().getAttribute("jsprun_uid");
String jsprun_usess = (String)request.getSession().getAttribute("jsprun_userss");
String boardurl = (String)request.getSession().getAttribute("boardurl");
String type = request.getParameter("type");
String orderid = request.getParameter("orderid");
if(Common.isEmpty(type)||Common.isEmpty(orderid)){
request.setAttribute("errorInfo", "未定义操作,请返回。");
return mapping.findForward("showMessage");
}
String raterid = "";
String ratee = "";
String rateeid = "";
if(type.equals("0")){
raterid = "buyerid";
ratee = "seller";
rateeid = "sellerid";
}else{
raterid = "sellerid";
ratee = "buyer";
rateeid = "buyerid";
}
List<Map<String,String>> orders = dataBaseService.executeQuery("SELECT * FROM jrun_tradelog WHERE orderid='"+orderid+"' AND "+raterid+"='"+jsprun_uid+"'");
Map<String,String> order = orders.size()>0?orders.get(0):null;
if(order==null){
request.setAttribute("resultInfo", "指定的订单不存在或已被删除。");
return mapping.findForward("showMessage");
}else if(order.get("ratestatus").equals("3")||(type.equals("0")&&order.get("ratestatus").equals("1"))||(type.equals("1")&&order.get("ratestatus").equals("2"))){
request.setAttribute("resultInfo", "不能重复评价。");
return mapping.findForward("showMessage");
}else if(!Tenpayapi.trade_typestatus("successtrades").equals(order.get("status"))&&!Tenpayapi.trade_typestatus("refundsuccess").equals(order.get("status"))){
request.setAttribute("resultInfo", "指定的评价不存在或已被删除。");
return mapping.findForward("showMessage");
}
String ratesubmit = request.getParameter("ratesubmit");
String uid = jsprun_uid ==Common.toDigit(order.get("buyerid"))?order.get("sellerid"): order.get("buyerid");
if(ratesubmit==null){
request.setAttribute("order", order);
return mapping.findForward("ec_rate");
}else{
String ec_credit = settings.get("ec_credit");
Map buycreditMap = dataParse.characterParse(ec_credit, true);
String maxcreditspermonth = buycreditMap.get("maxcreditspermonth").toString();
String score = request.getParameter("score");
String message = request.getParameter("message");
message = message==null?"":message;
message = Common.cutstr(Common.dhtmlspecialchars(message), 200);
String level = score.equals("1")?"good":(score.equals("0")?"soso":"bad");
String pid = order.get("pid");
dataBaseService.runQuery("INSERT INTO jrun_tradecomments (pid, orderid, type, raterid, rater, ratee, rateeid, score, message, dateline,explanation) VALUES ('"+pid+"', '"+orderid+"', '"+type+"', '"+jsprun_uid+"', '"+jsprun_usess+"', '"+order.get(ratee)+"', '"+order.get(rateeid)+"', '"+score+"', '"+message+"', '"+timestamp+"','')");
if(order.get("offline").equals("0")){
List<Map<String,String>> db = dataBaseService.executeQuery("SELECT COUNT(score) as count FROM jrun_tradecomments WHERE raterid='"+jsprun_uid+"' AND type='"+type+"'");
if(db.size()>0 && Common.toDigit(db.get(0).get("count"))<Common.toDigit(maxcreditspermonth)){
updateusercredit(Common.toDigit(uid),(type.equals("1")?"sellercredit":"buyercredit"),level,timestamp);
}
}
String ratestatus ="";
if(type.equals("0")){
ratestatus = order.get("ratestatus").equals("2")?"3":"1";
}else{
ratestatus = order.get("ratestatus").equals("1")?"3":"2";
}
dataBaseService.runQuery("UPDATE jrun_tradelog SET ratestatus='"+ratestatus+"' WHERE orderid='"+order.get("orderid")+"'");
if(!ratestatus.equals("3")){
Common.sendpm(order.get(rateeid), "[系统消息] 商品交易的对方已经评价,请回评", "这是由论坛系统自动发送的通知短消息。\n\n[url="+boardurl+"trade.jsp?orderid="+orderid+"]查看交易单[/url]\n\n与您交易的 "+jsprun_usess+" 已经给您作了评价,请尽快评价对方。", "0", "System Message", timestamp);
}
request.setAttribute("resultInfo", "您的评价已经成功。");
return mapping.findForward("showMessage");
}
}
@SuppressWarnings("unchecked")
private Map updatecreditcache(int uid,int timestamp, String type){
Map<String,Integer> all = countcredit(uid,type,timestamp,0);
Map<String,Integer> halfyear = countcredit(uid,type,timestamp,180);
Map<String,Integer> thismonth = countcredit(uid,type,timestamp,30);
Map<String,Integer> thisweek = countcredit(uid,type,timestamp,7);
Map<String,Integer> before = new HashMap<String,Integer>();
before.put("good", all.get("good")-halfyear.get("good"));
before.put("soso", all.get("soso")-halfyear.get("soso"));
before.put("bad", all.get("bad")-halfyear.get("bad"));
before.put("total", all.get("total")-halfyear.get("total"));
Map data = new HashMap();
data.put("all", all);
data.put("before", before);
data.put("halfyear", halfyear);
data.put("thismonth", thismonth);
data.put("thisweek", thisweek);
String datastring = dataParse.combinationChar(data);
dataBaseService.runQuery("REPLACE INTO jrun_spacecaches (uid, variable, value, expiration) VALUES ('"+uid+"', '"+type+"', '"+datastring+"', '"+(timestamp+86400)+"')");
return data;
}
private Map<String,Integer> countcredit(int uid, String type,int timestamp,int days){
Map<String,Integer> result = new HashMap<String,Integer>();
type = type.equals("buyercredit")?"1":"0";
String timeadd = days>0?" and dateline>="+(timestamp-days*86400):"";
List<Map<String,String>> credits = dataBaseService.executeQuery("select score from jrun_tradecomments where rateeid="+uid+" and type="+type+timeadd);
int good = 0;int soso=0;int bad=0;
for(Map<String,String>credit:credits){
if(credit.get("score").equals("1")){
good++;
}else if(credit.get("score").equals("0")){
soso++;
}else{
bad++;
}
}
result.put("good", good);
result.put("soso", soso);
result.put("bad", bad);
result.put("total", good+soso+bad);
return result;
}
@SuppressWarnings("unchecked")
private void updateusercredit(int uid,String type,String level,int timestamp){
if(uid<=0|| !Common.isinarray(type, new String[]{"buyercredit","sellercredit"})||!Common.isinarray(level, new String[]{"good","soso","bad"})){
return;
}
List<Map<String,String>> caches = dataBaseService.executeQuery("SELECT value, expiration FROM jrun_spacecaches WHERE uid='"+uid+"' AND variable='"+type+"'");
int expiration = 0;
Map<String,Map<String,Integer>> cache = new HashMap<String,Map<String,Integer>>();
if(caches.size()>0){
cache = dataParse.characterParse(caches.get(0).get("value"), false);
expiration = Integer.valueOf(caches.get(0).get("expiration"));
}else{
Map<String,Integer> init = new HashMap<String,Integer>();
init.put("good", 0);
init.put("soso", 0);
init.put("bad", 0);
init.put("total", 0);
cache.put("all", init);
cache.put("before", init);
cache.put("halfyear", init);
cache.put("thismonth", init);
cache.put("thisweek", init);
expiration =timestamp+86400;
}
String [] array = new String[]{"all","before","halfyear","thismonth","thisweek"};
for(String key:array){
Map chchekey = cache.get(key);
chchekey.put(level, Common.toDigit(chchekey.get(level).toString())+1);
chchekey.put("total", Common.toDigit(chchekey.get("total").toString())+1);
}
String cachedata = dataParse.combinationChar(cache);
dataBaseService.runQuery("REPLACE INTO jrun_spacecaches (uid, variable, value, expiration) VALUES ('"+uid+"', '"+type+"', '"+cachedata+"', '"+expiration+"')");
String score = level.equals("good")?"1":(level.equals("soso")?"0":"-1");
dataBaseService.runQuery("update jrun_memberfields set "+type+"="+type+"+"+score+" where uid="+uid);
}
private void writeMessage(HttpServletResponse response,String message,boolean iserror){
response.setContentType("application/xml");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Program", "no-cache");
response.setDateHeader("Expirse", 0);
String content = "<?xml version=\"1.0\" encoding=\""+JspRunConfig.charset+"\"?><root><![CDATA[";
if(iserror){
message = message+" <script type=\"text/javascript\" reload=\"1\">function ajaxerror() { alert('"+message+"');}ajaxerror();</script>";
}
message = message.replaceAll("([\\x01-\\x09\\x0b-\\x0c\\x0e-\\x1f])+", "");
message = message.replaceAll("]]>", "]]>");
content = content+message+"]]></root>";
try {
response.getWriter().write(content);
} catch (IOException e) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -