微信后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.3 KiB

package com.ynxbd.common.dao;
import com.ynxbd.common.action.pay.SelfHelpCount;
import com.ynxbd.common.bean.ConfigSelfHelp;
import com.ynxbd.common.bean.SelfHelp;
import com.ynxbd.common.config.db.DataBase;
import java.util.List;
public class SelfHelpDao {
/**
* 查询申请单列表
*/
public List<ConfigSelfHelp> selectConfigList(Integer groupType) {
String sql = "select * from config_self_help where isDisabled = 0 and groupType= ? order by seq, id asc";
return DataBase.select(sql, ConfigSelfHelp.class, ps -> {
ps.setInt(1, groupType);
});
}
/**
* 查询申请单列表
*/
public ConfigSelfHelp selectConfigByCode(String code) {
String sql = "select * from config_self_help where code= ? and isDisabled = 0 and (everyDayNum is not null and everyDayNum != 0)";
return DataBase.selectOne(sql, ConfigSelfHelp.class, ps -> {
ps.setString(1, code);
});
}
/**
* 查询申请单列表
*/
public synchronized int selectTodayCount(String code) {
String sql = "select count(*) from self_help where ((NoticeState = 0 and to_days(updateTime) = to_days(now())) or (NoticeState = -1 and updateTime >= DATE_SUB(now(), INTERVAL 5 MINUTE)) or (NoticeState = -2 and updateTime >= DATE_SUB(now(), INTERVAL 5 MINUTE))) and code = ? ";
return DataBase.selectCount(sql, ps -> {
ps.setString(1, code);
});
}
/**
* 查询申请单列表
*/
public synchronized SelfHelpCount selectTodayCountBean(String code) {
String sql = "SELECT ifNull(SUM(CASE WHEN NoticeState = 0 THEN 1 ELSE 0 END), 0) AS endTotal, " +
" ifNull(SUM(CASE WHEN (NoticeState = -2 and updateTime >= DATE_SUB(now(), INTERVAL 5 MINUTE)) THEN 1 ELSE 0 END), 0) AS payTotal " +
" FROM self_help where to_days(updateTime) = to_days(now()) and code = ?";
return DataBase.selectOne(sql, SelfHelpCount.class, ps -> {
ps.setString(1, code);
});
}
/**
* 查询申请单列表
*
* @param treatNum 门诊号
*/
public SelfHelp selectPrepayByTreatNum(String treatNum) {
String sql = "select * from self_help where treatNum = ? and updateTime >= DATE_SUB(now(), INTERVAL 5 MINUTE) and noticeState = -2 ";
return DataBase.selectOne(sql, SelfHelp.class, ps -> {
ps.setString(1, treatNum);
});
}
/**
* 查询申请单列表
*
* @param treatNum 门诊号
*/
public SelfHelp selectByTreatNum(String treatNum) {
String sql = "select * from self_help where treatNum = ?";
return DataBase.selectOne(sql, SelfHelp.class, ps -> {
ps.setString(1, treatNum);
});
}
/**
* 查询申请单列表
*
* @param treatNum 组
*/
public boolean updateByTreatNum(String treatNum) {
String sql = "update self_help set updateTime= now() where treatNum= ? and noticeState = -1";
return DataBase.update(sql, ps -> {
ps.setString(1, treatNum);
}) > 0;
}
/**
* 修改通知
*
* @param treatNum 组
*/
public boolean updateNotice(String treatNum) {
String sql = "update self_help set noticeState= 0, updateTime= now() where treatNum= ?";
return DataBase.update(sql, ps -> {
ps.setString(1, treatNum);
}) > 0;
}
/**
* 预支付占号
*
* @param treatNum 组
*/
public boolean updatePrepay(String treatNum) {
String sql = "update self_help set noticeState= -2, updateTime= now() where treatNum= ? and noticeState != 0";
return DataBase.update(sql, ps -> {
ps.setString(1, treatNum);
}) > 0;
}
/**
* 新增
*/
public boolean insert(String openid, String treatNum, String code) {
String sql = "insert into self_help(updateTime, noticeState, openid, treatNum, code) values(now(), ?,?,?,?)";
return DataBase.insert(sql, ps -> {
ps.setInt(1, -1);
ps.setString(2, openid);
ps.setString(3, treatNum);
ps.setString(4, code);
}) > 0;
}
}