/** * 购买商品-生成订单 * * @author zhliu * @date 2015年6月19日 * @parm * @param request * @param response * @param packageId : 套餐ID * @param count * @return */ @RequestMapping("/buyProdOrder") public String buyProdOrder(HttpServletRequest request, RequestBookingOrder bookingOrder) { Order order = new Order(); try { User user = (User) request.getSession().getAttribute(SecurityConstants.SESSION_USER); bookingOrder.setUserId(user.getObjectId()); bookingOrder.setOrderType(IBSConstants.ORDER_TYPE_POINT_BUY); // 年度福利 bookingOrder.setOrderSource(IBSConstants.ORDER_SOURCE_HR); // 企业HR端 bookingOrder.setOrderProductType( IBSConstants.ORDER_PRODUCT_TYPE_WELFARE); // 订单商品类型 1福利套餐,2体检套餐,3SKU商品,4生活服务 bookingOrder.setUserId(user.getObjectId()); logger.info("HR端购买福利 --购买商品---开始"); order = orderManager.createImmediateOrder(bookingOrder); logger.info("HR端购买福利 --购买商品---结束"); } catch (Exception e) { e.printStackTrace(); logger.error("HR端购买福利 --购买商品---失败"); logger.error(e.getMessage()); } return "redirect:" + "buyWelfareOrderSuc/" + order.getObjectId(); }
/** * 购买福利-生成订单 -- 根据子订单 ID 进行支付 * * @author zhliu * @date 2015年7月3日 * @parm * @param request * @param response * @param objectId : 子订单ID * @return */ @RequestMapping("/buyWelfareSubOrderSuc/{objectId}") public String buyWelfareSubOrderSuc(HttpServletRequest request, @PathVariable Long objectId) { User user = (User) request.getSession().getAttribute(SecurityConstants.SESSION_USER); SubOrder subOrder = new SubOrder(); double totalAmount = 0.0; // 应付总额 Double sumPoint = 0.0; // 员工 积分 Order order = new Order(); // 总订单 try { // 查询剩余积分 sumPoint = userManager.getUserBalance(user.getObjectId()); subOrder = subOrderManager.getByObjectId(objectId); order = orderManager.getByObjectId(subOrder.getGeneralOrderId()); totalAmount = subOrder.getPayableAmount(); request.setAttribute("sumPoint", sumPoint); request.setAttribute("subOrder", subOrder); request.setAttribute("totalAmount", totalAmount); if (order.getPaymentWay() != null && order.getPaymentWay() == 2) { return HOME_DIR + "/buyWelfareOrder"; } else { return HOME_DIR + "/buyWelfareOrderPayOffline"; } } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); } return HOME_DIR + "/buyWelfareOrder"; }
/** * 购买福利-生成订单 * * @author zhliu * @date 2015年6月19日 * @parm * @param request * @param response * @param packageId : 套餐ID * @param count * @return */ @RequestMapping("/buyWelfareOrder") public String buyWelfareOrder(HttpServletRequest request, RequestBookingOrder bookingOrder) { Order order = new Order(); try { User user = (User) request.getSession().getAttribute(SecurityConstants.SESSION_USER); bookingOrder.setUserId(user.getObjectId()); bookingOrder.setOrderType(IBSConstants.ORDER_TYPE_POINT_BUY); // 积分购买 bookingOrder.setOrderSource(IBSConstants.ORDER_SOURCE_HR); // 企业HR端 // bookingOrder.setOrderProductType(IBSConstants.ORDER_PRODUCT_TYPE_WELFARE);//订单商品类型 // 1福利套餐,2体检套餐,3SKU商品,4生活服务 bookingOrder.setUserId(user.getObjectId()); logger.info("HR端购买福利 --购买福利---开始"); order = orderManager.createImmediateOrder(bookingOrder); logger.info("HR端购买福利 --购买福利---结束"); } catch (Exception e) { logger.error("HR端购买福利 出错了,抛异常信息...", e); if (e.getMessage().equals("商品库存不足")) { request.setAttribute("msg", e.getMessage()); } else { request.setAttribute("msg", "预定失败"); } return HOME_DIR + "/bookOrderFail"; } return "redirect:" + "buyWelfareOrderSuc/" + order.getObjectId(); }
/** * 积分支付 * * @author zhliu * @date 2015年6月30日 * @param request * @param response * @param subOrderNo:子订单号 * @param payWay :线上支付渠道(1:积分支付;2支付宝支付;3:混合支付) * @param password :支付密码 * @return */ @RequestMapping("integralPaySetPayment") public String integralPaySetPayment( HttpServletRequest request, String subOrderId, String subOrderNo, String payWay, String password, Long orderId) { try { User user = (User) request.getSession().getAttribute(SecurityConstants.SESSION_USER); // 更新 订单 实付金额 SubOrder subOrder = new SubOrder(); subOrder.setSubOrderNo(subOrderNo); subOrder = subOrderManager.getBySample(subOrder).get(0); if (payWay != null && payWay.equals(String.valueOf(IBSConstants.PAY_WAY_ON_LINE_INTEGRAL))) { // 积分支付 subOrder.setActuallyAmount(0.0); subOrder.setActuallyIntegral(subOrder.getPayableAmount()); } else if (payWay != null && payWay.equals(String.valueOf(IBSConstants.PAY_WAY_ON_LINE_ALIPAY))) { // 支付宝支付 subOrder.setActuallyAmount(subOrder.getPayableAmount()); subOrder.setActuallyIntegral(0.0); } else { return null; } subOrderManager.save(subOrder); // 积分支付 Map resultMap = orderManager.integralPay(subOrderId, user.getObjectId(), password); request.setAttribute("message", resultMap.get("message")); // 支付信息 /*if(orderId == null){//子订单ID return "redirect:"+"buyWelfareSubOrderSuc/"+subOrderId; }else{//总订单ID return "redirect:"+"buyWelfareOrderSuc/"+orderId; }*/ return "redirect:" + "buyWelfareSubOrderSuc/" + subOrderId; } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); } return null; }