@RequestProcessing(value="/admin/charge-point",method=HTTPRequestMethod.POST) @Before(adviceClass={StopwatchStartAdvice.class,MallAdminCheck.class}) @After(adviceClass=StopwatchEndAdvice.class) public void chargePoint(final HTTPRequestContext context,final HttpServletRequest request,final HttpServletResponse response) throws Exception {
  final String userName=request.getParameter(User.USER_NAME);
  final String pointStr=request.getParameter(Common.POINT);
  final String memo=request.getParameter(Common.MEMO);
  if (StringUtils.isBlank(pointStr) || !StringUtils.isNumeric(memo)) {
    final AbstractFreeMarkerRenderer renderer=new SkinRenderer();
    context.setRenderer(renderer);
    renderer.setTemplateName("admin/error.ftl");
    final Map<String,Object> dataModel=renderer.getDataModel();
    dataModel.put(Keys.MSG,"Charge point memo format error");
    filler.fillHeaderAndFooter(request,response,dataModel);
    return;
  }
  final JSONObject user=userQueryService.getUserByName(userName);
  if (null == user) {
    final AbstractFreeMarkerRenderer renderer=new SkinRenderer();
    context.setRenderer(renderer);
    renderer.setTemplateName("admin/error.ftl");
    final Map<String,Object> dataModel=renderer.getDataModel();
    dataModel.put(Keys.MSG,"User [name=" + userName + "] not found");
    filler.fillHeaderAndFooter(request,response,dataModel);
    return;
  }
  final JSONObject currentUser=(JSONObject)request.getAttribute(User.USER);
  try {
    final int point=Integer.valueOf(pointStr);
    final String transferId=pointtransferMgmtService.transfer(Pointtransfer.ID_C_SYS,user.optString(Keys.OBJECT_ID),Pointtransfer.TRANSFER_TYPE_C_CHARGE,point,memo + "-" + currentUser.optString(Keys.OBJECT_ID));
    final JSONObject notification=new JSONObject();
    notification.put(Notification.NOTIFICATION_USER_ID,user.optString(Keys.OBJECT_ID));
    notification.put(Notification.NOTIFICATION_DATA_ID,transferId);
    notificationMgmtService.addPointChargeNotification(notification);
  }
 catch (  final Exception e) {
    final AbstractFreeMarkerRenderer renderer=new SkinRenderer();
    context.setRenderer(renderer);
    renderer.setTemplateName("admin/error.ftl");
    final Map<String,Object> dataModel=renderer.getDataModel();
    dataModel.put(Keys.MSG,e.getMessage());
    filler.fillHeaderAndFooter(request,response,dataModel);
    return;
  }
  response.sendRedirect(Latkes.getServePath() + "/admin/charge-records");
}

@ RequestProcessing ( value = "/admin/charge-point" , method = HTTPRequestMethod . POST ) @ Before ( adviceClass = { StopwatchStartAdvice . class , MallAdminCheck . class } ) @ After ( adviceClass = StopwatchEndAdvice . class ) public void chargePoint ( final HTTPRequestContext context , final HttpServletRequest request , final HttpServletResponse response ) throws Exception { final String userName = request . getParameter ( User . USER_NAME ) ; final String pointStr = request . getParameter ( Common . POINT ) ; final String memo = request . getParameter ( Common . MEMO ) ; if ( StringUtils . isBlank ( pointStr ) || ! StringUtils . isNumeric ( memo ) ) { final AbstractFreeMarkerRenderer renderer = new SkinRenderer ( ) ; context . setRenderer ( renderer ) ; renderer . setTemplateName ( "admin/error.ftl" ) ; final Map < String , Object > dataModel = renderer . getDataModel ( ) ; dataModel . put ( Keys . MSG , "Charge point memo format error" ) ; filler . fillHeaderAndFooter ( request , response , dataModel ) ; return ; } final JSONObject user = userQueryService . getUserByName ( userName ) ; if ( null == user ) { final AbstractFreeMarkerRenderer renderer = new SkinRenderer ( ) ; context . setRenderer ( renderer ) ; renderer . setTemplateName ( "admin/error.ftl" ) ; final Map < String , Object > dataModel = renderer . getDataModel ( ) ; dataModel . put ( Keys . MSG , "User [name=" + userName + "] not found" ) ; filler . fillHeaderAndFooter ( request , response , dataModel ) ; return ; } final JSONObject currentUser = ( JSONObject ) request . getAttribute ( User . USER ) ; try { final int point = Integer . valueOf ( pointStr ) ; final String transferId = pointtransferMgmtService . transfer ( Pointtransfer . ID_C_SYS , user . optString ( Keys . OBJECT_ID ) , Pointtransfer . TRANSFER_TYPE_C_CHARGE , point , memo + "-" + currentUser . optString ( Keys . OBJECT_ID ) ) ; final JSONObject notification = new JSONObject ( ) ; notification . put ( Notification . NOTIFICATION_USER_ID , user . optString ( Keys . OBJECT_ID ) ) ; notification . put ( Notification . NOTIFICATION_DATA_ID , transferId ) ; notificationMgmtService . addPointChargeNotification ( notification ) ; } catch ( final Exception e ) { final AbstractFreeMarkerRenderer renderer = new SkinRenderer ( ) ; context . setRenderer ( renderer ) ; renderer . setTemplateName ( "admin/error.ftl" ) ; final Map < String , Object > dataModel = renderer . getDataModel ( ) ; dataModel . put ( Keys . MSG , e . getMessage ( ) ) ; filler . fillHeaderAndFooter ( request , response , dataModel ) ; return ; } response . sendRedirect ( Latkes . getServePath ( ) + "/admin/charge-records" ) ; }
charges a user ' s point .
