treasure_buy.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:6k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=utf-8" %>
  2. <%@ page import="java.util.*"%>
  3. <%@ page import="cn.js.fan.db.Conn"%>
  4. <%@ page import="cn.js.fan.util.*"%>
  5. <%@ page import="cn.js.fan.web.*"%>
  6. <%@ page import="com.redmoon.forum.person.*"%>
  7. <%@ page import="com.redmoon.forum.plugin.*"%>
  8. <%@ page import="com.redmoon.forum.plugin.entrance.*"%>
  9. <%@ page import="com.redmoon.forum.*"%>
  10. <%@ page import="com.redmoon.forum.treasure.*"%>
  11. <%@ page import="com.redmoon.forum.plugin.base.*"%>
  12. <%@ taglib uri="/WEB-INF/tlds/LabelTag.tld" prefix="lt" %>
  13. <jsp:useBean id="StrUtil" scope="page" class="cn.js.fan.util.StrUtil"/>
  14. <%
  15. String skincode = UserSet.getSkin(request);
  16. if (skincode.equals(""))
  17. skincode = UserSet.defaultSkin;
  18. SkinMgr skm = new SkinMgr();
  19. Skin skin = skm.getSkin(skincode);
  20. if (skin==null)
  21. skin = skm.getSkin(UserSet.defaultSkin);
  22. String skinPath = skin.getPath();
  23. %>
  24. <html><head>
  25. <meta http-equiv="pragma" content="no-cache">
  26. <link href="<%=skinPath%>/skin.css" rel="stylesheet" type="text/css">
  27. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  28. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  29. <title><lt:Label res="res.label.forum.treasure" key="buy_treasure"/> - <%=Global.AppName%></title>
  30. <style type="text/css">
  31. <!--
  32. .style1 {
  33. font-size: 14px;
  34. font-weight: bold;
  35. }
  36. -->
  37. </style>
  38. <body bgcolor="#FFFFFF" topmargin='0' leftmargin='0'>
  39. <%@ include file="inc/header.jsp"%>
  40. <jsp:useBean id="privilege" scope="page" class="com.redmoon.forum.Privilege"/>
  41. <%
  42. if (!privilege.isUserLogin(request)) {
  43. out.println(SkinUtil.makeErrMsg(request, SkinUtil.LoadString(request, SkinUtil.ERR_NOT_LOGIN)));
  44. return;
  45. }
  46. String code = ParamUtil.get(request, "code");
  47. if (code.equals("")) {
  48. out.print(SkinUtil.makeErrMsg(request, SkinUtil.LoadString(request, "res.label.forum.treasure", "need_code")));
  49. return;
  50. }
  51. TreasureMgr tmr = new TreasureMgr();
  52. TreasureUnit tu = tmr.getTreasureUnit(code);
  53. String userName = privilege.getUser(request);
  54. String op = ParamUtil.get(request, "op");
  55. if (op.equals("buy")) {
  56.   if (tu.getCount()<=0) {
  57.    out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "res.label.forum.treasure", "store_inadequate")));
  58. return;
  59.   }
  60.   String moneyCode = ParamUtil.get(request, "moneyCode");
  61.   Vector pricev = tu.getPrice();
  62.   Iterator pir = pricev.iterator();
  63.   ScoreMgr sm = new ScoreMgr();
  64.   while (pir.hasNext()) {
  65.    TreasurePrice tp = (TreasurePrice)pir.next();
  66.    double value = tp.getValue();
  67. TreasureUserDb tud = new TreasureUserDb();
  68. tud = tud.getTreasureUserDb(userName, code);
  69.    ScoreUnit su = sm.getScoreUnit(tp.getScoreCode());
  70. // 检查用户的积分够不够
  71. // 原先已买过
  72. if (tud.isLoaded()) {
  73. IPluginScore ips = su.getScore();
  74. if (ips.pay(userName, ips.SELLER_SYSTEM, value)) {
  75. tud.setAmount(tud.getAmount() + 1);
  76. if (tud.save()) {
  77. tmr.setTreasureCount(code, tu.getCount() - 1);
  78. out.print(StrUtil.Alert_Redirect(SkinUtil.LoadString(request, "res.label.forum.treasure", "buy_success"), "../usercenter.jsp"));
  79. return;
  80. }
  81. }
  82. }
  83. else {// 原先没买过
  84. tud.setUserName(userName);
  85. tud.setTreasureCode(code);
  86. tud.setAmount(1);
  87. if (tud.create()) {
  88. tmr.setTreasureCount(code, tu.getCount() - 1);
  89. out.print(StrUtil.Alert_Redirect(SkinUtil.LoadString(request, "res.label.forum.treasure", "buy_success"), "../usercenter.jsp"));
  90. return;
  91. }
  92. }
  93.   }
  94. }
  95. %>
  96. <br>
  97. <table width="98%" height="227" border='0' align="center" cellpadding='0' cellspacing='0' class="frame_gray">
  98.   <tr> 
  99.     <td height=20 align="center" class="thead"><span class="style1"><lt:Label res="res.label.forum.treasure" key="buy_treasure"/></span></td>
  100.   </tr>
  101.   <tr> 
  102.     <td valign="top"><br>
  103.       <br>
  104.       <table width="43%"  border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#EFEFEF">
  105.         <tr>
  106.           <td height="24" colspan="2" align="center" class="td_title"><font color=white><%=tu.getName()%></font></td>
  107.         </tr>
  108.         <tr align="center">
  109.           <td height="22" colspan="2" bgcolor="#FFFFFF"><%=tu.getDesc()%></td>
  110.         </tr>
  111.         <tr>
  112.           <td width="48%" height="130" rowspan="2" align="center" bgcolor="#FFFFFF"><img src="<%=tu.getImage()%>"> </td>
  113.           <td width="52%" height="55" valign="top" bgcolor="#FFFFFF"><lt:Label res="res.label.forum.treasure" key="buy_point"/>
  114.             <br>
  115.               <%
  116.   Vector pricev = tu.getPrice();
  117.   Iterator pir = pricev.iterator();
  118.   ScoreMgr sm = new ScoreMgr();
  119.   while (pir.hasNext()) {
  120.    TreasurePrice tp = (TreasurePrice)pir.next();
  121.    ScoreUnit su = sm.getScoreUnit(tp.getScoreCode());
  122.   %>
  123.               <lt:Label res="res.label.forum.treasure" key="use"/><%=su.getName()%>&nbsp;<%=tp.getValue()%>&nbsp;<a href="treasure_buy.jsp?op=buy&code=<%=StrUtil.UrlEncode(tu.getCode())%>&moneyCode=<%=StrUtil.UrlEncode(tp.getScoreCode())%>"><lt:Label res="res.label.forum.treasure" key="confirm_buy"/></a>
  124.   <%}%>   
  125.               <br>
  126.           <lt:Label res="res.label.forum.treasure" key="day_count"/><%=tu.getDay()%> </td>
  127.         </tr>
  128.         <tr>
  129.           <td height="22" bgcolor="#FFFFFF"><lt:Label res="res.label.forum.treasure" key="store_count"/><%=tu.getCount()%></td>
  130.         </tr>
  131.       </table></td>
  132.   </tr>
  133. </table>
  134. </td> </tr>             
  135.       </table>                                        
  136.        </td>                                        
  137.      </tr>                                        
  138.  </table> 
  139.  <%@ include file="inc/footer.jsp"%>                                       
  140. </body>                                        
  141. </html>                            
  142.