Click the button to allow only one month (remittance)

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

Implementation allows one button click only once a month, if that has been clicked, the prompt has been clicked, do not click again.
Background controller level code

/**
* 跳转支付页面
*/
@RequestMapping("pay")
public String pay(@RequestParam Map map, HttpSession session){
    Object dw_account = session.getAttribute("account");
    System.out.println(dw_account);
    map.put("dw_account", dw_account);
    List<Map> list = comService.getTime(map);
//拿到汇缴记录时间
    String oldTi = list.get(0).get("ANCE_DATE") + "";
//将汇缴时间的“-”变为“”,并且截取前六位
    String oldTime = oldTi.replace("-", "").substring(0, 6);
//取当前时间
    Date date = new Date();
//把时间格式设置为yyyyMM格式
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
    String now = dateFormat.format(date);
//把时间转换为字符串
    String nowTime = now.toString();
//拿到汇缴记录的时间与当前时间的年月作比较,看是否相等
    if (nowTime.equals(oldTime)) {
        session.setAttribute("Msg","本月已汇缴!");
        return "qiantai/danjiaona";
    }else{
        Object payables = map.get("payables");
        Object userID=map.get("userID");
        session.setAttribute("payables",payables);
        session.setAttribute("userID",userID);
        return "qiantai/pay";
    }
}
/**
* 提示错误信息
* @return
*/
@ResponseBody
@RequestMapping("showMsg")
public Object showMsg(HttpSession httpSession){
    Object msg = "";
    try {
        msg = httpSession.getAttribute("Msg");
    } catch (Exception e) {
        return msg;
    }
    return msg;
}

js code
using data taken from the background ajax

$.ajax({
   url:"/qian/showMsg",
   success:function (data) {
       $("#info").html(data);
   }
});

Guess you like

Origin blog.csdn.net/weixin_44001965/article/details/92575686