@Override protected void display(Map<String, String> params) { String pager = params.get("pager"); // on开启,off关闭 pager = StringUtil.isEmpty(pager) ? "on" : pager; Integer modelid = Integer.valueOf(params.get("modelid")); String pageSizeParam = params.get("pagesize"); int pageSize = StringUtil.isEmpty(pageSizeParam) ? 20 : Integer.valueOf(pageSizeParam); HttpServletRequest request = ThreadContextHolder.getHttpRequest(); String pageParam = request.getParameter("page"); int pageNo = StringUtil.isEmpty(pageParam) ? 1 : Integer.valueOf(pageParam); String showchilds = params.get("showchild"); // 是否显示子站数据 yes/no boolean showchild = showchilds == null ? false : (showchilds.trim().toUpperCase().equals("YES")); if ("on".equals(pager)) { Page dataPage = dataManager.search(pageNo, pageSize, modelid); List dataList = (List) dataPage.getResult(); this.putData("dataList", dataList); SearchPagerHtmlBuilder pagerHtmlBuilder = new SearchPagerHtmlBuilder(pageNo, dataPage.getTotalCount(), pageSize); String pagerHtml = pagerHtmlBuilder.buildPageHtml(); this.putData("pager", pagerHtml); } else { List dataList = dataManager.search(modelid); this.putData("dataList", dataList); this.putData("pager", "<!--不分页-->"); } }
public void filter(StringBuffer sql, Cat cat, String urlFragment) { String keyword = urlFragment == null ? "" : urlFragment; if (!StringUtil.isEmpty(keyword)) { String encoding = EopSetting.ENCODING; if (!StringUtil.isEmpty(encoding)) { keyword = StringUtil.to(keyword, encoding); } sql.append(" and g.name like '%"); sql.append(keyword); sql.append("%'"); } }
@Override protected void display(Map<String, String> params) { Integer catid = Integer.valueOf(params.get("catid")); String countStr = params.get("count"); String term = params.get("term"); String showchilds = params.get("showchild"); // 是否显示子站数据 yes/no boolean showchild = showchilds == null ? false : (showchilds.trim().toUpperCase().equals("YES")); // 排序,规则是:已有" order by ",应直接写后面的内容,如<orders>name desc,sort desc</orders> /** 网友洪(2134535)提供 */ String orders = params.get("orders"); Integer count = StringUtil.isEmpty(countStr) ? 10 : Integer.valueOf(countStr); Page page = dataManager.listAll(catid, term, orders, showchild, 1, count); List articleList = (List) page.getResult(); this.putData("dataList", articleList); // // DataCat cat =this.dataCatManager.get(Integer.valueOf(catid)); // // Nav nav = new Nav(); // nav.setTitle("首页"); // nav.setLink("index.html"); // nav.setTips("首页"); // this.putNav(nav); // // Nav nav1 = new Nav(); // nav1.setTitle(cat.getName() ); // nav1.setTips(cat.getName()); // this.putNav(nav1); }
/** 检测当前产品是否有新版本 */ public VersionState checkNewVersion() { if (logger.isDebugEnabled()) { logger.debug("检测当前产品是否有新版本..."); } VersionState versionState = new VersionState(); String newVersion = this.getNewVersion(); String currentVersion = EopSetting.VERSION; if (logger.isDebugEnabled()) { logger.debug("产品当前版本为:[" + currentVersion + "]最新版本为:[" + newVersion + "]"); } if (!StringUtil.isEmpty(newVersion)) { // 如果新版本号大有新版本 if (this.versionLargerThen(newVersion, currentVersion)) { versionState.setHaveNewVersion(true); versionState.setNewVersion(newVersion); List<UpdateLog> updateLogList = getUpdateLog(); versionState.setUpdateLogList(updateLogList); } } if (logger.isDebugEnabled()) { logger.debug("检测新版本完成."); } return versionState; }
@Override public Page search(Long acid, String cname, int pageNo, int pageSize, String order) { StringBuffer term = new StringBuffer(); StringBuffer sql = new StringBuffer( "select v.*, c.cname cname from " + this.getTableName("adv") + " v left join " + this.getTableName("adcolumn") + " c on c.acid = v.acid"); if (acid != null) { term.append(" where c.acid=" + acid); } if (!StringUtil.isEmpty(cname)) { if (term.length() > 0) { term.append(" and "); } else { term.append(" where "); } term.append(" aname like'%" + cname + "%'"); } sql.append(term); order = order == null ? " aid desc" : order; sql.append(" order by " + order); Page page = this.daoSupport.queryForPage(sql.toString(), pageNo, pageSize); return page; }
/** * 判断ver1是否比ver2大 * * @param ver1 * @param ver2 * @return */ private boolean versionLargerThen(String ver1, String ver2) { if (StringUtil.isEmpty(ver1)) throw new IllegalArgumentException("ver1版本不能为空"); if (StringUtil.isEmpty(ver2)) throw new IllegalArgumentException("ver2版本不能为空"); if (ver1.length() != ver2.length()) throw new IllegalArgumentException("ver2与ver2版本号格式不相同"); if (ver1.length() != 5) throw new IllegalArgumentException("版本号格式不正确,应为如:2.1.0"); String[] ver1a = ver1.split("\\."); Integer ver1i = Integer.valueOf(ver1a[0]) * 1000000 + Integer.valueOf(ver1a[1]) * 1000 + Integer.valueOf(ver1a[2]); String[] ver2a = ver2.split("\\."); Integer ver2i = Integer.valueOf(ver2a[0]) * 1000000 + Integer.valueOf(ver2a[1]) * 1000 + Integer.valueOf(ver2a[2]); return ver1i > ver2i; }
/* */ public void filter(List<CartItem> itemlist, String sessionid) /* */ { /* 43 */ for (CartItem cartItem : itemlist) { /* 44 */ String addon = cartItem.getAddon(); /* 45 */ if (!StringUtil.isEmpty(addon)) { /* 46 */ JSONArray specArray = JSONArray.fromObject(addon); /* 47 */ List list = (List) JSONArray.toCollection(specArray, Map.class); /* 48 */ cartItem.getOthers().put("specList", list); /* */ } /* */ } /* */ }
public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String pic = params.get("pic").toString(); if (StringUtil.isEmpty(pic)) pic = "http://" + EopSetting.IMG_SERVER_DOMAIN + "/images/no_picture.jpg"; if (pic.startsWith("fs:")) { pic = UploadUtil.replacePath(pic); } String postfix = params.get("postfix").toString(); env.getOut().write(UploadUtil.getThumbPath(pic, postfix)); }
/* */ private void fillChildMenu(List<Menu> menuList, Element parentEl) /* */ { /* 179 */ for (Menu menu : menuList) /* 180 */ if (menu.getMenutype().intValue() != 1) { /* 181 */ Element menuEl = new Element("menu"); /* 182 */ menuEl.setAttribute("text", menu.getTitle()); /* 183 */ String url = menu.getUrl(); /* 184 */ if (!StringUtil.isEmpty(url)) { /* 185 */ menuEl.setAttribute("url", url); /* */ } /* */ /* 188 */ String target = menu.getTarget(); /* 189 */ if (!StringUtil.isEmpty(target)) { /* 190 */ menuEl.setAttribute("target", target); /* */ } /* */ /* 193 */ List children = menu.getChildren(); /* 194 */ if ((children != null) && (!children.isEmpty())) { /* 195 */ fillChildMenu(children, menuEl); /* */ } /* 197 */ parentEl.addContent(menuEl); /* */ } /* */ }
/* */ public Page list(String keyword, int pageNo, int pageSize) /* */ { /* 388 */ String sql = "select s.id,s.sitename,s.point,s.createtime,s.sitestate,s.logincount,s.lastlogin,u.username from eop_site s,eop_user u where s.userid=u.id"; /* */ /* 392 */ if (!StringUtil.isEmpty(keyword)) { /* 393 */ sql = sql + " and (s.sitename like '%" + keyword + "%' "; /* 394 */ sql = sql + " or u.username like '%" + keyword + "%'"; /* 395 */ sql = sql + " or s.id in(select siteid from eop_sitedomain where domain like '%" + keyword + "%') )"; /* */ } /* */ /* 398 */ sql = sql + " order by s.createtime desc"; /* */ /* 400 */ return this.daoSupport.queryForPage(sql, pageNo, pageSize, new Object[0]); /* */ }
/* (non-Javadoc) * @see com.enation.app.setting.service.ISettingService#getSetting() */ @Override public Map<String, Map<String, String>> getSetting() { String sql = "select * from settings"; List<Map<String, String>> list = this.baseDaoSupport.queryForList(sql); Map<String, Map<String, String>> cfg = new HashMap(); for (Map<String, String> map : list) { String setting_value = map.get("cfg_value"); if (StringUtil.isEmpty(setting_value)) { cfg.put(map.get("cfg_group"), new HashMap<String, String>()); } else { JSONObject jsonObject = JSONObject.fromObject(setting_value); Map itemMap = (Map) JSONObject.toBean(jsonObject, Map.class); cfg.put(map.get("cfg_group"), itemMap); } } return cfg; }
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { CartItem cartItem = new CartItem(); cartItem.setId(rs.getInt("cart_id")); cartItem.setProduct_id(rs.getInt("product_id")); cartItem.setGoods_id(rs.getInt("goods_id")); cartItem.setName(rs.getString("name")); cartItem.setMktprice(rs.getDouble("mktprice")); cartItem.setPrice(rs.getDouble("price")); cartItem.setCoupPrice(rs.getDouble("price")); // 优惠价格默认为销售价,则优惠规则去改变 // cartItem.setCatid(rs.getInt("catid")); String image_default = rs.getString("image_default"); if (image_default != null) { image_default = UploadUtil.replacePath(image_default); } cartItem.setImage_default(image_default); cartItem.setNum(rs.getInt("num")); cartItem.setPoint(rs.getInt("point")); cartItem.setItemtype(rs.getInt("itemtype")); if (cartItem.getItemtype().intValue() == 0) { cartItem.setAddon(rs.getString("addon")); } // 赠品设置其限购数量 if (cartItem.getItemtype().intValue() == 2) { cartItem.setLimitnum(rs.getInt("limitnum")); } if (cartItem.getItemtype().intValue() == 1) { cartItem.setSn(rs.getString("sn")); } if (cartItem.getItemtype().intValue() == 0) { String specs = rs.getString("specs"); cartItem.setSpecs(specs); if (StringUtil.isEmpty(specs)) cartItem.setName(cartItem.getName()); else cartItem.setName(cartItem.getName() + "(" + specs + ")"); } return cartItem; }
/* */ private DataLog createDataLog(Map goods) /* */ { /* 52 */ DataLog datalog = new DataLog(); /* 53 */ datalog.setContent("商品名:" + goods.get("name") + "<br>" + "描述:" + goods.get("intro")); /* 54 */ String image_file = (String) goods.get("image_file"); /* */ /* 56 */ StringBuffer pics = new StringBuffer(); /* 57 */ if (!StringUtil.isEmpty(image_file)) { /* 58 */ String[] files = StringUtils.split(image_file, ","); /* 59 */ for (String file : files) { /* 60 */ if (pics.length() > 0) /* 61 */ pics.append(","); /* 62 */ pics.append(UploadUtil.getThumbPath(file, "_thumbnail")); /* 63 */ pics.append("|"); /* 64 */ pics.append(file); /* */ } /* */ } /* */ /* 68 */ datalog.setPics(pics.toString()); /* 69 */ datalog.setLogtype("商品"); /* 70 */ datalog.setOptype("添加"); /* 71 */ datalog.setUrl("/goods-" + goods.get("goods_id") + ".html"); /* */ /* 73 */ return datalog; /* */ }
/* */ public String getEditHtml(Map goods, HttpServletRequest request) /* */ { /* 48 */ String contextPath = request.getContextPath(); /* */ /* 50 */ FreeMarkerPaser freeMarkerPaser = FreeMarkerPaser.getInstance(); /* */ /* 53 */ String image_default = null; /* 54 */ if ((goods.get("image_file") != null) && (goods.get("image_file") != "")) { /* 55 */ String image_file = goods.get("image_file").toString(); /* 56 */ String[] thumbnail_images = StringUtils.split(image_file, ","); /* */ /* 58 */ image_default = (String) goods.get("image_default"); /* 59 */ if (!StringUtil.isEmpty(image_default)) { /* 60 */ image_default = UploadUtil.replacePath(image_default); /* */ } /* */ /* 64 */ freeMarkerPaser.putData("ctx", contextPath); /* 65 */ freeMarkerPaser.putData("image_default", image_default); /* 66 */ freeMarkerPaser.putData("thumbnail_images", thumbnail_images); /* */ } /* */ /* 69 */ freeMarkerPaser.setPageName("album"); /* 70 */ String html = freeMarkerPaser.proessPageContent(); /* 71 */ return html; /* */ }
@Override public String onCallBack() { HttpServletRequest request = ThreadContextHolder.getHttpRequest(); Map<String, String> configparams = this.getConfigParams(); String partner = configparams.get("partner"); // partner合作伙伴id(必须填写) String key = configparams.get("key"); // partner 的对应交易安全校验码(必须填写) String encoding = configparams.get("callback_encoding"); // 获取支付宝POST过来反馈信息 Map<String, String> params = new HashMap<String, String>(); Map requestParams = request.getParameterMap(); for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { String name = (String) iter.next(); String[] values = (String[]) requestParams.get(name); String valueStr = ""; for (int i = 0; i < values.length; i++) { valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; } if (!StringUtil.isEmpty(encoding)) { valueStr = StringUtil.to(valueStr, encoding); } params.put(name, valueStr); } // 获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// String trade_no = request.getParameter("trade_no"); // 支付宝交易号 String order_no = request.getParameter("out_trade_no"); // 获取订单号 String total_fee = request.getParameter("price"); // 获取总金额 String subject = request.getParameter("subject"); // 商品名称、订单名称 if (!StringUtil.isEmpty(encoding)) { subject = StringUtil.to(subject, encoding); } String body = ""; if (request.getParameter("body") != null) { body = request.getParameter("body"); // 商品描述、订单备注、描述 if (!StringUtil.isEmpty(encoding)) { body = StringUtil.to(body, encoding); } } String buyer_email = request.getParameter("buyer_email"); // 买家支付宝账号 String receive_name = ""; // 收货人姓名 if (request.getParameter("receive_name") != null) { receive_name = request.getParameter("receive_name"); if (!StringUtil.isEmpty(encoding)) { receive_name = StringUtil.to(receive_name, encoding); } } String receive_address = ""; // 收货人地址 if (request.getParameter("receive_address") != null) { receive_address = request.getParameter("receive_address"); if (!StringUtil.isEmpty(encoding)) { receive_address = StringUtil.to(receive_address, encoding); } } String receive_zip = ""; // 收货人邮编 if (request.getParameter("receive_zip") != null) { receive_zip = request.getParameter("receive_zip"); if (!StringUtil.isEmpty(encoding)) { receive_zip = StringUtil.to(receive_zip, encoding); } } String receive_phone = ""; // 收货人电话 if (request.getParameter("receive_phone") != null) { receive_phone = request.getParameter("receive_phone"); if (!StringUtil.isEmpty(encoding)) { receive_phone = StringUtil.to(receive_phone, encoding); } } String receive_mobile = ""; // 收货人手机 if (request.getParameter("receive_mobile") != null) { receive_mobile = request.getParameter("receive_mobile"); if (!StringUtil.isEmpty(encoding)) { receive_mobile = StringUtil.to(receive_mobile, encoding); } } String trade_status = request.getParameter("trade_status"); // 交易状态 // 获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// if (AlipayNotify.callbackverify(params, key, partner)) { // 验证成功 ////////////////////////////////////////////////////////////////////////////////////////// // 请在这里加上商户的业务逻辑程序代码 this.paySuccess(order_no); // ——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— this.logger.info("异步校验订单[" + order_no + "]成功"); if (trade_status.equals("WAIT_BUYER_PAY")) { // 该判断表示买家已在支付宝交易管理中产生了交易记录,但没有付款 // 判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) // 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 // 如果有做过处理,不执行商户的业务程序 return ("success"); // 请不要修改或删除 } else if (trade_status.equals("WAIT_SELLER_SEND_GOODS")) { // 该判断表示买家已在支付宝交易管理中产生了交易记录且付款成功,但卖家没有发货 // 判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) // 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 // 如果有做过处理,不执行商户的业务程序 return ("success"); // 请不要修改或删除 } else if (trade_status.equals("WAIT_BUYER_CONFIRM_GOODS")) { // 该判断表示卖家已经发了货,但买家还没有做确认收货的操作 // 判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) // 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 // 如果有做过处理,不执行商户的业务程序 return ("success"); // 请不要修改或删除 } else if (trade_status.equals("TRADE_FINISHED")) { // 该判断表示买家已经确认收货,这笔交易完成 // 判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) // 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 // 如果有做过处理,不执行商户的业务程序 return ("success"); // 请不要修改或删除 } else { return ("success"); // 请不要修改或删除 } // ——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ////////////////////////////////////////////////////////////////////////////////////////// } else { // 验证失败 return ("fail"); } }
@Override public String onReturn() { Map<String, String> cfgparams = paymentManager.getConfigParams(this.getId()); HttpServletRequest request = ThreadContextHolder.getHttpRequest(); this.logger.info("返回来的body" + request.getParameter("body")); String key = cfgparams.get("key"); String partner = cfgparams.get("partner"); String encoding = cfgparams.get("return_encoding"); // 获取支付宝GET过来反馈信息 Map<String, String> params = new HashMap<String, String>(); Map requestParams = request.getParameterMap(); for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { String name = (String) iter.next(); String[] values = (String[]) requestParams.get(name); String valueStr = ""; for (int i = 0; i < values.length; i++) { valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; } // 乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 if (!StringUtil.isEmpty(encoding)) { valueStr = StringUtil.to(valueStr, encoding); } params.put(name, valueStr); } // 获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)// String trade_no = request.getParameter("trade_no"); // 支付宝交易号 String order_no = request.getParameter("out_trade_no"); // 获取订单号 String total_fee = request.getParameter("total_fee"); // 获取总金额 String subject = request.getParameter("subject"); // 商品名称、订单名称 if (!StringUtil.isEmpty(encoding)) { subject = StringUtil.to(subject, encoding); } String body = ""; if (request.getParameter("body") != null) { body = request.getParameter("body"); // 商品描述、订单备注、描述 if (!StringUtil.isEmpty(encoding)) { body = StringUtil.to(body, encoding); } } String buyer_email = request.getParameter("buyer_email"); // 买家支付宝账号 String receive_name = ""; // 收货人姓名 if (request.getParameter("receive_name") != null) { receive_name = request.getParameter("receive_name"); if (!StringUtil.isEmpty(encoding)) { receive_name = StringUtil.to(receive_name, encoding); } } String receive_address = ""; // 收货人地址 if (request.getParameter("receive_address") != null) { receive_address = request.getParameter("receive_address"); if (!StringUtil.isEmpty(encoding)) { receive_address = StringUtil.to(receive_address, encoding); } } String receive_zip = ""; // 收货人邮编 if (request.getParameter("receive_zip") != null) { receive_zip = request.getParameter("receive_zip"); if (!StringUtil.isEmpty(encoding)) { receive_zip = StringUtil.to(receive_zip, encoding); } } String receive_phone = ""; // 收货人电话 if (request.getParameter("receive_phone") != null) { receive_phone = request.getParameter("receive_phone"); if (!StringUtil.isEmpty(encoding)) { receive_phone = StringUtil.to(receive_phone, encoding); } } String receive_mobile = ""; // 收货人手机 if (request.getParameter("receive_mobile") != null) { receive_mobile = request.getParameter("receive_mobile"); if (!StringUtil.isEmpty(encoding)) { receive_mobile = StringUtil.to(receive_mobile, encoding); } } String trade_status = request.getParameter("trade_status"); // 交易状态 // 获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)// // 计算得出通知验证结果 boolean verify_result = AlipayNotify.returnverify(params, key, partner); if (verify_result) { // 验证成功 ////////////////////////////////////////////////////////////////////////////////////////// // 请在这里加上商户的业务逻辑程序代码 // ——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— if (trade_status.equals("WAIT_SELLER_SEND_GOODS")) { // 判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) // 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 // 如果有做过处理,不执行商户的业务程序 } if (trade_status.equals("TRADE_FINISHED")) { // 判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) // 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 // 如果有做过处理,不执行商户的业务程序 } this.paySuccess(order_no); return order_no; // ——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ////////////////////////////////////////////////////////////////////////////////////////// } else { throw new RuntimeException("验证失败"); } }
protected void showSuccessJson(String message) { if (StringUtil.isEmpty(message)) this.json = "{result:1}"; else this.json = "{result:1,message:'" + message + "'}"; }
protected void showErrorJson(String message) { if (StringUtil.isEmpty(message)) this.json = "{result:0}"; else this.json = "{result:0,message:'" + message + "'}"; }