- 浏览: 73862 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
m.g:
mac vmmap pid | grep .jar
让MyEclipse7.1更精简 -
marlgl:
heyjava 写道T60 刚换完散热装置的路过...9月就过 ...
Thinkpad 死于 Lenovo ? -
yexin218:
呵呵,楼主估计买的不是行货吧。我自己买了两台thinkpad
...
Thinkpad 死于 Lenovo ? -
heyjava:
T60 刚换完散热装置的路过...9月就过保修期了...以后要 ...
Thinkpad 死于 Lenovo ? -
grandboy:
不买Thinkpad, 买什么啊? 我就没有发现在哪一个牌子更 ...
Thinkpad 死于 Lenovo ?
200行一个方法,到处充斥着全局变量
真是个神仙啊!
first:
干掉全局变量,164行
second:
100行
真是个神仙啊!
public String payCart() { identity = getPubStrB();//证件号码 SessionUtil sessionUtil = new SessionUtil(); CookieUtil cookieUtil = new CookieUtil(); int k=0,coinTotal=0,gameMoneyTotal=0,payStatus=0; //读取商品 String [] tmpShopArr; String [] tmpArr; strComm = getPubStrA(); if(strComm==null || strComm.length()<3) return ERROR; tmpShopArr = strComm.split(";"); shopAmountArr = new int[tmpShopArr.length]; shopArr = new Shop[tmpShopArr.length]; for(int p=0; p<tmpShopArr.length; p++){ tmpArr = tmpShopArr[p].split("-"); shopAmountArr[k] = Integer.parseInt(tmpArr[1]); detachedCriteria = DetachedCriteria.forClass(Shop.class); detachedCriteria.add(Restrictions.eq("id", Integer.parseInt(tmpArr[0]))); shopArr[k] = (Shop)userDao.findAllByCriteria(detachedCriteria).get(0); k++; } detachedCriteria = DetachedCriteria.forClass(UserInfo.class); detachedCriteria.add(Restrictions.eq("userId", userCenter.getCUID())); userInfo = (UserInfo)userDao.findAllByCriteria(detachedCriteria).get(0); for(int i=0; i<shopArr.length; i++){ shop = shopArr[i]; if(shop.getAmount()<1){ payStatus = 1; this.setActionMessage(shop.getGoodsName()+"已销完"); return SUCCESS; } if(shop.getGoodsType()==2){ if(gameDao.getGameNum(userCenter.getCUID(),shop.getVarField1())>=0){ this.setActionMessage("您的游戏积分大于零"); payStatus = 1; return SUCCESS; } } if(shop.getPrice()>0 && shop.getPrice1()>0 ){//选择最优惠价支付 if(shop.getBeneficiary()==0){ if(userInfo.getVipOverTime().getTime()>new Date().getTime()){//以会员价price1 if(shop.getPrice1Type()==0){ coinTotal = coinTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); }else{ gameMoneyTotal = gameMoneyTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); } }else{//以普通价price if(shop.getPriceType()==0){ coinTotal = coinTotal + shop.getPrice()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice()*shopAmountArr[i]); }else{ gameMoneyTotal = gameMoneyTotal + shop.getPrice()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice()*shopAmountArr[i]); } } }else{//以普通价price1 if(shop.getPrice1Type()==0){ coinTotal = coinTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); }else{ gameMoneyTotal = gameMoneyTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); } } }else if(shop.getPrice()>0 && shop.getPrice1()==0){//一种价支付 price if(shop.getPriceType()==0){ coinTotal = coinTotal + shop.getPrice()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice()*shopAmountArr[i]); }else{ gameMoneyTotal = gameMoneyTotal + shop.getPrice()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice()*shopAmountArr[i]); } }else if(shop.getPrice()==0 && shop.getPrice1()>0){//以一种价支付 if(shop.getBeneficiary()==0){ if(userInfo.getVipOverTime().getTime()>new Date().getTime()){//以会员价price1 if(shop.getPrice1Type()==0){ coinTotal = coinTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); }else{ gameMoneyTotal = gameMoneyTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); } }else{ payStatus = 1; this.setActionMessage("您不能购买"+shop.getGoodsName()); return SUCCESS; } }else{//以普通价price1 if(shop.getPrice1Type()==0){ coinTotal = coinTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); }else{ gameMoneyTotal = gameMoneyTotal + shop.getPrice1()*shopAmountArr[i]; shop.setPayAmount(shop.getPrice1()*shopAmountArr[i]); } } } } //支付有错误 if(payStatus==1)return SUCCESS; if(userInfo.getMoney()-coinTotal<0){ this.setActionMessage("您的账户金币余额不足,请充值"); return SUCCESS; } if(userInfo.getBankGameMoney()-gameMoneyTotal<0){ this.setActionMessage("您的保险箱游戏币余额不足"); return SUCCESS; } //在有效期内才能购买其它配饰 int nday=0; for(int j=0; j<shopArr.length; j++){ if(shopArr[j].getGoodsType()==4 && shopArr[j].getVarField1().length()>1 ){ nday = Integer.parseInt(shopArr[j].getVarField1()); if(nday>showDay)showDay = nday; showType = 1; }else if(shopArr[j].getGoodsType()==4){ showType = 1; } } if(showType==1 && showDay==0){ Date tday = new Date(); if(userInfo.getShowOverTime()==null || userInfo.getShowOverTime().getTime()<tday.getTime()){ this.setActionMessage("请查看形象秀的使用说明,再进行购买"); return SUCCESS; } } buyShow = ""; for(int j = 0; j < shopArr.length; j++){ shop = shopArr[j]; if(shop.getGoodsType()==0){//游戏道具 buyGameProp(j); }else if(shop.getGoodsType()==1){//实物兑换 buyProduct(j); }else if(shop.getGoodsType()==2){//负分清零 doGameZero(j); }else if(shop.getGoodsType()==3){//会员资格 payVip(j); } else if (shop.getGoodsType() == 4) {//show int showIndex = this.getShowIndex(shop); buyShow += "," + showIndex + "," + shop.getPic(); payShow(j); } shop.setAmount(shop.getAmount()-shopAmountArr[j]); gameDao.updateObject(shop); } if (buyShow.length() > 5) { Map<String, String> showMap = this.getShowMap(buyShow, userCenter.getCIndexOf(12), cookieUtil.getCookie("show")); strComm=""; myShow=""; if (showMap.size() > 0) { Object[] o = this.g(showMap); for(int i = 0; i < o.length; i++) { String key = o[i].toString(); strComm += "#" + key + "#" + showMap.get(key); myShow += "," + showMap.get(key); } } myShow = myShow.substring(1); strComm = strComm.substring(1); String rootPath = ServletActionContext.getServletContext().getRealPath("/"); ImageUtil image = new ImageUtil(); BufferedImage bufimg = image.showImage(myShow, rootPath + "show/"); if (this.createShowImage(bufimg, myShow)) { cookieUtil.setCookie("show",strComm,-1); userInfo.setShowCustom(strComm); if (showDay > 0) { Date tday = new Date(); GregorianCalendar gDay = new GregorianCalendar(); if(userInfo.getShowOverTime()==null || userInfo.getShowOverTime().getTime()<tday.getTime()){ userInfo.setShowOverTime(tday); } gDay.setTimeInMillis(userInfo.getShowOverTime().getTime()); gDay.add(Calendar.DATE,showDay); userInfo.setShowOverTime(gDay.getTime()); } userInfo.setSelfImageShow(userInfo.getIfSelfImage()); userCenter.reSaveCID(12,strComm); strComm = "show"; } else { logger.debug(userCenter.getCUID() + " no pic"); this.setActionMessage("SHOW生成错误"); return SUCCESS; } } userInfo.setMoney(userInfo.getMoney()-coinTotal); userInfo.setBankGameMoney(userInfo.getBankGameMoney()-gameMoneyTotal); userDao.updateObject(userInfo); sessionUtil.setSession("cart",null,0); sessionUtil.setSession("preShow",null,0); cookieUtil.clearKey("GoodsSort"); this.setActionMessage(strComm+"完成支付。共消费游戏币:"+gameMoneyTotal + ",需重新登录才生效"); return SUCCESS; }
first:
干掉全局变量,164行
public String payCart() { /* * 购买的“物品-数量”字符串 * e.g: * 物品-数量;物品-数量 */ String shopAndCountString = getPubStrA(); if (shopAndCountString == null || shopAndCountString.length() < 3) return ERROR; DetachedCriteria detachedCriteria = DetachedCriteria.forClass( UserInfo.class ); detachedCriteria.add( Restrictions.eq("userId", userCenter.getUserID()) ); UserInfo userInfo = (UserInfo) userDao.findAllByCriteria(detachedCriteria).get(0); /* * 是否游戏中 */ if (userInfo.getPlayServerId() > 0) { this.setActionMessage("账号在游戏中,请先退出游戏再操作"); return SUCCESS; } /* * 读取商品 */ String[] idAndAmountArray = shopAndCountString.split(";"); List<Integer> shopAmountList = this.getShopAmountList(idAndAmountArray);//商品数量List List<Shop> shopList = this.getShopList(idAndAmountArray);//商品List long gameMoneyTotal = 0; int showDay = 0; boolean hasShow = false;//是否有“形象秀”物品 for (int i = 0; i < shopList.size(); i++) { Shop shop = shopList.get(i); if (shop.getAmount() < 1) { this.setActionMessage(shop.getGoodsName() + "已销完"); return SUCCESS; } if (shop.getGoodsType() == 2) { if ( gamePointOverZero( userCenter.getUserID(), parseOldGameId(shop.getVarField1()) ) ) { this.setActionMessage("您的游戏积分大于零"); return SUCCESS; } } long vipOverTime = userInfo.getVipOverTime().getTime(), nowTime = new Date().getTime(); if (shop.getPrice() == 0 && shop.getPrice1() > 0) {// 以一种价支付 if (shop.getBeneficiary() == 0) { if (vipOverTime <= nowTime) {// 以会员价price1 this.setActionMessage("您不能购买" + shop.getGoodsName()); return SUCCESS; } } } gameMoneyTotal = getPayGameMoneyTotal(shop, shopAmountList.get(i), vipOverTime > nowTime, gameMoneyTotal); if ( shop.getGoodsType() == 4 ) { hasShow = true;//形象秀 if ( shop.getVarField1().length() > 1 ) { int days = Integer.parseInt( shop.getVarField1() );//形象秀有效期 showDay = (days > showDay) ? days : showDay; } } }// end for if (userInfo.getGameMoney() - gameMoneyTotal < 0) { this.setActionMessage("您的游戏币余额不足"); return SUCCESS; } // 在有效期内才能购买其它配饰 if ( hasShow && showDay == 0 ) { if (userInfo.getShowOverTime() == null || userInfo.getShowOverTime().getTime() < new Date().getTime()) { this.setActionMessage("请查看形象秀的使用说明,再进行购买"); return SUCCESS; } } StringBuilder payShowImages = new StringBuilder(); for (int j = 0; j < shopList.size(); j++) { Shop shop = shopList.get(j); if (shop.getGoodsType() == 0) {// 游戏道具 buyGameProp( userInfo, shop ); } else if (shop.getGoodsType() == 1) {// 实物兑换 buyProduct( userInfo, shop ); } else if (shop.getGoodsType() == 2) {// 负分清零 setupGamePointsToZero( userInfo, shop ); } else if (shop.getGoodsType() == 3) {// 会员资格 payVip( userInfo, shop, shopAmountList.get(j) ); } else if (shop.getGoodsType() == 4) {// show payShowImages.append( "," + this.getShowIndex(shop) + "," + shop.getPic() ); payShow( userInfo, shop ); } shop.setAmount(shop.getAmount() - shopAmountList.get(j)); gameDao.updateObject(shop); } CookieUtil cookieUtil = new CookieUtil(); if (payShowImages.length() > 5) { Map<String, String> showMap = this.getShowMap( payShowImages.toString(), userCenter.getShow(), cookieUtil.getCookie("show") ); StringBuilder strComm = new StringBuilder(); StringBuilder myShow = new StringBuilder(); if (showMap.size() > 0) { Object[] o = this.g(showMap); for (int i = 0; i < o.length; i++) { String key = o[i].toString(); strComm.append( "#" + key + "#" + showMap.get(key) ); myShow.append( "," + showMap.get(key) ); } } String showImages = myShow.substring(1); String showCustomString = strComm.substring(1); ImageUtil image = new ImageUtil(); BufferedImage bufimg = image.showImage( showImages, ServletActionContext.getServletContext().getRealPath("/") + "show/"); if ( this.createShowImage(bufimg, showImages) ) { cookieUtil.setCookie("show", showCustomString, -1); userInfo.setShowCustom( showCustomString ); if (showDay > 0) { Date tday = new Date(); GregorianCalendar gDay = new GregorianCalendar(); if (userInfo.getShowOverTime() == null || userInfo.getShowOverTime().getTime() < tday.getTime()) { userInfo.setShowOverTime(tday); } gDay.setTimeInMillis(userInfo.getShowOverTime().getTime()); gDay.add(Calendar.DATE, showDay); userInfo.setShowOverTime(gDay.getTime()); } userInfo.setSelfImageShow(userInfo.getIfSelfImage()); userCenter.reSaveCID(12, showCustomString); } else { logger.debug(userCenter.getUserName() + " no pic"); this.setActionMessage("SHOW生成错误"); return SUCCESS; } } userInfo.setGameMoney( ( int )(userInfo.getGameMoney() - gameMoneyTotal) ); userDao.updateObject(userInfo); SessionUtil sessionUtil = new SessionUtil(); sessionUtil.setSession(SessionKey.cart.getValue(), null, 0); sessionUtil.setSession(SessionKey.show.getValue(), null, 0); cookieUtil.clearKey("GoodsSort"); this.setActionMessage("完成支付。共消费游戏币:" + gameMoneyTotal + ",需重新登录才生效"); return SUCCESS; }
second:
100行
public String payCart() { /* * 购买的“物品-数量”字符串 * e.g: * 物品-数量;物品-数量 */ String shopAndCountString = getPubStrA(); if (shopAndCountString == null || shopAndCountString.length() < 3) return ERROR; DetachedCriteria detachedCriteria = DetachedCriteria.forClass( UserInfo.class ); detachedCriteria.add( Restrictions.eq("userId", userCenter.getUserID()) ); UserInfo userInfo = (UserInfo) userDao.findAllByCriteria(detachedCriteria).get(0); /* * 是否游戏中 */ if (userInfo.getPlayServerId() > 0) { this.setActionMessage("账号在游戏中,请先退出游戏再操作"); return SUCCESS; } /* * 读取商品 */ String[] idAndAmountArray = shopAndCountString.split(";"); List<Integer> shopAmountList = this.getShopAmountList(idAndAmountArray);//商品数量List List<Shop> shopList = this.getShopList(idAndAmountArray);//商品List long gameMoneyTotal = 0; int showDay = 0; boolean hasShow = false;//是否有“形象秀”物品 for (int i = 0; i < shopList.size(); i++) { Shop shop = shopList.get(i); if (shop.getAmount() < 1) { this.setActionMessage(shop.getGoodsName() + "已销完"); return SUCCESS; } if (shop.getGoodsType() == 2) { if ( gamePointOverZero( userCenter.getUserID(), parseOldGameId(shop.getVarField1()) ) ) { this.setActionMessage("您的游戏积分大于零"); return SUCCESS; } } long vipOverTime = userInfo.getVipOverTime().getTime(), nowTime = new Date().getTime(); if (shop.getPrice() == 0 && shop.getPrice1() > 0) {// 以一种价支付 if (shop.getBeneficiary() == 0) { if (vipOverTime <= nowTime) {// 以会员价price1 this.setActionMessage("您不能购买" + shop.getGoodsName()); return SUCCESS; } } } gameMoneyTotal = getPayGameMoneyTotal(shop, shopAmountList.get(i), vipOverTime > nowTime, gameMoneyTotal); if ( shop.getGoodsType() == 4 ) { hasShow = true;//形象秀 if ( shop.getVarField1().length() > 1 ) { int days = Integer.parseInt( shop.getVarField1() );//形象秀有效期 showDay = (days > showDay) ? days : showDay; } } }// end for if (userInfo.getGameMoney() - gameMoneyTotal < 0) { this.setActionMessage("您的游戏币余额不足"); return SUCCESS; } // 在有效期内才能购买其它配饰 if ( hasShow && showDay == 0 ) { if (userInfo.getShowOverTime() == null || userInfo.getShowOverTime().getTime() < new Date().getTime()) { this.setActionMessage("请查看形象秀的使用说明,再进行购买"); return SUCCESS; } } CookieUtil cookieUtil = new CookieUtil(); if ( ! createShowImage(shopList, shopAmountList, cookieUtil, userInfo, showDay) ) { logger.debug(userCenter.getUserName() + " no pic"); this.setActionMessage("SHOW生成错误"); return SUCCESS; } userInfo.setGameMoney( ( int )(userInfo.getGameMoney() - gameMoneyTotal) ); userDao.updateObject(userInfo); SessionUtil sessionUtil = new SessionUtil(); sessionUtil.setSession(SessionKey.cart.getValue(), null, 0); sessionUtil.setSession(SessionKey.show.getValue(), null, 0); cookieUtil.clearKey("GoodsSort"); this.setActionMessage("完成支付。共消费游戏币:" + gameMoneyTotal + ",需重新登录才生效"); return SUCCESS; }
发表评论
-
shiro session listener
2016-08-17 17:54 974package com.xyz.service.shiro; ... -
What do the arrow icons in Subclipse mean?
2013-02-07 09:43 646http://stackoverflow.com/questi ... -
Java call R - windows
2012-12-10 10:29 689引用install.packages("rJava& ... -
flash camera
2012-06-19 10:24 687flash拍照改进版 - 参照的原版地址不详。 camera ... -
让MyEclipse7.1更精简
2010-04-30 14:47 1640去除MyEclipse 的一些相关的jsf的支持jar包 查 ... -
在Linux平台下使用JNI
2010-04-07 14:49 923参考:http://www.ibm.com/developer ... -
Disable “WARNING: Parameters: Invalid chunk ignored.” messages in Tomcat log
2009-07-23 16:11 1442http://www.itonguard.com/200806 ... -
面试中,BubbleSort/BinarySearch 问到的几率真高
2008-10-16 18:18 1019最近在找工作,经常被 ... -
DateFormat
2008-01-25 17:05 1044import java.text.DateFormat; ... -
Java Language Specification
2007-04-25 16:13 1316Preface THE Java programmi ...
相关推荐
《神仙道游戏分析》 神仙道,一款深受玩家喜爱的网络游戏,以其独特的世界观、丰富的角色设定和策略性十足的游戏玩法,吸引了无数玩家投身其中。本文将深入探讨神仙道游戏的设计理念、核心机制以及其在游戏设计领域...
《神仙道数据分析详解》 神仙道,作为一款深受玩家喜爱的网络游戏,其背后的数据分析是游戏设计和优化的重要环节。本文将围绕“神仙道”的功能系统、代码组成、架构以及仿真建模进行深入探讨,旨在揭示游戏运行的...
在道教的神仙体系中,最高层次的神祇通常被称为“三清”,即元始天尊、灵宝天尊和道德天尊,他们代表着道教的至高无上的神力与智慧。元始天尊象征着宇宙的初始与创造,灵宝天尊则代表着宇宙的法则与秩序,而道德天尊...
《神仙道》是一款深受玩家喜爱的在线角色扮演游戏,其丰富的游戏素材是构成游戏世界不可或缺的部分。在这个主题下,我们将深入探讨“《神仙道》游戏素材”中的“人物待机图”这一重要元素,以及它在游戏开发和设计中...
神仙道架设视频教程
【Magisk模块与神仙自动救砖】 Magisk是一款由XDA开发者开发的系统级修改工具,主要用于Android设备。它提供了一种安全的方式来隐藏root权限,安装自定义模块,并对系统进行深度定制,同时还能保持设备的系统更新...
《神仙道浮云自动摘桃源代码》是一个针对网络游戏《神仙道》的辅助工具,旨在自动化游戏中的"摘桃"这一活动,减轻玩家的游戏负担。该源码包含了两个主要的API(应用程序接口):登录API和摘桃API,分别用于处理游戏...
上古封印单机版 仿新仙剑OL神仙道横版回合页游单机一键端 GM元宝 [2020新版]上古封印单机版 仿新仙剑OL神仙道横版回合页游单机一键端 GM元宝 上古封印单机版 仿新仙剑OL神仙道横版回合页游单机一键端 GM元宝
在这里,它可能被用来执行一些设备初始化操作或者在系统启动后执行必要的修复步骤。 5. **META-INF**:这是一个重要的目录,包含了Magisk模块的元数据和安装信息。`META-INF/com/google/android`目录下的文件(如`...
作用:由某些面具模块导致你手机无法开机的情况,刷入该模块后,你无需手动任何设置自动帮你禁用所有面具模块,让你成功开机。 系统更新后第一次开机时停用,再第二次重启时再继续触发。当刷入一些模块后导致无法...
很抱歉,根据您提供的文件信息,标题"不是神仙胜似神仙.doc"以及描述内容似乎并不涉及具体的IT知识点。标签为空,部分内容则是一段富含哲理的生活心态描述,并非技术性的内容。因此,我无法为您生成相关的IT知识文章...
在给定的“通达信指标公式源码神仙脚.doc”文档中,我们可以看到一个用于判断市场底部和发出买入信号的自定义公式。接下来,我们将深入解析这个公式的主要组成部分。 首先,我们来看两个关键变量VAR2和VAR3。这两个...
3dmax插件神器-013-神仙小辅助.mse
本案例通过分析热门游戏“神仙道”的数值系统,将深入探讨这一领域的核心概念和设计策略。 首先,我们要理解游戏数值系统的核心作用。它是游戏规则的数学模型,包括角色属性、技能效果、经济系统、战斗计算等。在...
这个指标被称为“神仙脚”,可能是为了形象地表示在股票图表上找到的某种特定的市场底部形态,帮助投资者识别潜在的买入机会。 源码中的关键变量和函数解释如下: 1. `VAR2:=TROUGHBARS(3,15,1);` 这一行定义了...
标题中的“Flash神仙动画,氏量神仙素材.rar”暗示了这个压缩包包含的是与Flash相关的动画素材,特别是关于神仙或类似奇幻角色的设计。Flash是一种曾经广泛使用的动画制作软件,允许用户创建互动式的2D动画、游戏和...
《神仙道》是一款深受玩家喜爱的在线角色扮演游戏,其丰富的游戏性和独特的数值系统是吸引玩家的重要因素之一。本文将深入探讨《神仙道》中的游戏数值资料,尤其是从提供的压缩包文件"《神仙道》角色属性相关及部分...
Hutool 介绍和应用 Hutool 是一个 Java 工具包,旨在简化开发者的生活,提供了各种 Util 工具类,帮助开发者快速高效地完成各种任务。下面是 Hutool 的一些重要特性和应用场景: 1. 文件和流操作:Hutool 提供了...
【明朝历史】整死三位皇后的明朝皇帝朱厚:朕乃神仙下凡.pdf