public ShopMember memberLogin( HttpServletRequest request, HttpServletResponse response, String username) throws UsernameNotFoundException, BadCredentialsException, UserNotInWebsiteException, UserNotAcitveException { // Long webId = web.getId(); // 先退出登录 logout(request, response); User user = userMng.getByUsername(username); ShopMember member = shopMemberMng.getByUsername(username); if (member == null) { throw new UserNotInWebsiteException("user '" + user.getUsername()); } else { if (!member.getMember().getActive()) { throw new UserNotAcitveException("user '" + user.getUsername()); } } userMng.updateLoginInfo(user.getId(), request.getRemoteAddr()); rememberMeService.loginSuccess(request, response, member.getMember()); session.setAttribute(request, response, SESSION_USER_ID_KEY, user.getId()); session.setAttribute(request, response, SESSION_MEMBER_ID_KEY, member.getId()); addUsernameCookie(member.getUsername(), null, null, request, response); shoppingSvc.addCookie(member, request, response); return member; }
private ShopMember getMemberFromSession( HttpServletRequest request, HttpServletResponse response, Website web) { Long memberId = (Long) session.getAttribute(request, SESSION_MEMBER_ID_KEY); System.out.println(session.getSessionId(request, response)); ShopMember member = null; Long webId = web.getId(); if (memberId != null) { member = shopMemberMng.findById(memberId); // 本站会员 /*if (member != null && member.getWebsite().getId().equals(webId)) { return member; }*/ // 全站会员 if (member != null) { return member; } } Long userId = (Long) session.getAttribute(request, SESSION_USER_ID_KEY); if (userId != null) { member = shopMemberMng.getByUserId(webId, userId); if (member == null) { ShopConfig config = shopConfigMng.findById(webId); // 自动注册 if (config.getRegisterAuto()) { member = shopMemberMng.join(userId, webId, config.getRegisterGroup()); } } if (member != null) { session.setAttribute(request, response, SESSION_MEMBER_ID_KEY, member.getId()); } } return member; }
// 选择收货地址、付款方式、配送方式 @RequestMapping(value = "/cart/checkout_shipping.jspx") public String shippingInput( Long[] cart2Checkbox, HttpServletRequest request, HttpServletResponse response, ModelMap model) { Website web = SiteUtils.getWeb(request); ShopMember member = MemberThread.get(); if (member == null) { return "redirect:../login.jspx"; } Cart cart = shoppingSvc.getCart(member.getId()); if (cart == null) { return "redirect:shopping_cart.jspx"; } List<PopularityItem> popularityItems = null; Double popularityPrice = 0.0; if (cart != null) { popularityItems = popularityItemMng.getlist(cart.getId(), null); for (PopularityItem popularityItem : popularityItems) { popularityPrice += popularityItem.getPopularityGroup().getPrivilege() * popularityItem.getCount(); } } Set<CartItem> items = getItems(cart2Checkbox, cart); Double price = getPrice(items); // 配送方式 List<Shipping> splist = shippingMng.getList(web.getId(), true); // 会员地址 List<ShopMemberAddress> smalist = shopMemberAddressMng.getList(member.getId()); // 所处省份 List<Address> plist = addressMng.getListById(null); // 付款方式 List<Payment> paylist = paymentMng.getList((long) 1, true); model.addAttribute( "memberCouponlist", memberCouponMng.getList(member.getId(), new BigDecimal(price))); model.addAttribute("items", getItems(cart2Checkbox, cart)); model.addAttribute("smalist", smalist); model.addAttribute("plist", plist); model.addAttribute("paylist", paylist); model.addAttribute("splist", splist); model.addAttribute("popularityPrice", popularityPrice); ShopFrontHelper.setCommonData(request, model, web, 1); return web.getTplSys(MEMBER_SYS, MessageResolver.getMessage(request, CHECKOUT_SHIPPING)); }
/** 会员中心优惠劵 */ @RequestMapping(value = "/myCoupon.jspx", method = RequestMethod.GET) public String pay1(HttpServletRequest request, ModelMap model) { Website web = SiteUtils.getWeb(request); ShopMember member = MemberThread.get(); List<MemberCoupon> list = memberCouponMng.getList(member.getId()); model.addAttribute("couList", list); model.addAttribute("historyProductIds", getHistoryProductIds(request)); ShopFrontHelper.setCommonData(request, model, web, 1); return web.getTplSys("member", MessageResolver.getMessage(request, "tpl.myCoupon")); }
public ShopMember memberLogin( HttpServletRequest request, HttpServletResponse response, Website web, String username, String password) throws UsernameNotFoundException, BadCredentialsException, UserNotInWebsiteException, UserNotAcitveException { Long webId = web.getId(); // 先退出登录 logout(request, response); User user = login(username, password); ShopMember member = shopMemberMng.getByUserId(webId, user.getId()); if (member == null) { ShopConfig config = shopConfigMng.findById(webId); if (config.getRegisterAuto()) { // 自动注册 member = shopMemberMng.join(user, webId, config.getRegisterGroup()); } else { throw new UserNotInWebsiteException( "user '" + user.getUsername() + "' not in Website '" + webId + "'"); } } else { if (!member.getMember().getActive()) { throw new UserNotAcitveException( "user '" + user.getUsername() + "' not Active '" + webId + "'"); } } userMng.updateLoginInfo(user.getId(), request.getRemoteAddr()); rememberMeService.loginSuccess(request, response, member.getMember()); session.setAttribute(request, response, SESSION_USER_ID_KEY, user.getId()); session.setAttribute(request, response, SESSION_MEMBER_ID_KEY, member.getId()); addUsernameCookie(member.getUsername(), null, null, request, response); shoppingSvc.addCookie(member, request, response); return member; }