1.
package com.biotool.web.controller.helper; import org.apache.commons.lang3.StringUtils; import javax.servlet.http.HttpSession; import java.util.Objects; public class OrderSessionHelper{ public static final String BIOTOOL_PAID = "biotool_paid"; //将成功付款的订单保存到session public static void setPaidOrderInSession(HttpSession session, String orderNo) { if (StringUtils.isNotBlank(orderNo)) { orderNo = orderNo.trim().toUpperCase(); session.setAttribute(BIOTOOL_PAID + orderNo, orderNo); } } //检查session中是否有订单付款信息 public static boolean hasPaidOrderInSession(HttpSession session, String orderNo) { boolean result = false; if (StringUtils.isNotBlank(orderNo)) { orderNo = orderNo.trim().toUpperCase(); result = orderNo.equals(Objects.toString(session.getAttribute(BIOTOOL_PAID + orderNo))); } return result; } // public static boolean noPaidOrderInSession(HttpSession session, String orderNo) { return !hasPaidOrderInSession(session, orderNo); } }