1:可返回对象。
String selSql=" select trade_id, subject, descption, medical_his, check_result, hope_help, accept_time, doctor_id,doctor_name, pay_fee, order_status, pay_start_time, pay_finish_time, pay_id, status, remark from td_trade_advise_fee where trade_id= "+ tradeId;
TradeAdviseFee tradeAdviseFee=(TradeAdviseFee)this.jdbcTemplate.
queryForObject(selSql,new
dviseFeeRowMapper());
return tradeAdviseFee ;
2:查询:
public long getPayQuestionCount(String userId, int status) {
String tempSql = "select count(1) from td_trade_advise_fee adviseFee where 1=1";
if(userId!=null && !userId.equals("")){
tempSql += " and adviseFee.doctor_id='"+userId+"'";
}
tempSql+="and
adviseFee.status='"+6+"'";
long count = this.jdbcTemplate.
queryForLong(tempSql);
return count;
}
3:更新
@Override
public int updateWZTradeAdviseFee(TradeAdviseFee tradeAdviseFee) {
// TODO Auto-generated method stub
String updateSql = "update td_trade_advise_fee set subject=?,descption=?,medical_his=?,check_result=?,hope_help=?,doctor_id=?,doctor_name=?," +
"pay_fee=?,status=?,patientName=? where trade_id=?";
int result = this.jdbcTemplate.update(updateSql, new Object[]{tradeAdviseFee.getSubject(),tradeAdviseFee.getDescption(),tradeAdviseFee.getMedicalHis(),
tradeAdviseFee.getCheckResult(),tradeAdviseFee.getHopeHelp(),tradeAdviseFee.getDoctorId(),tradeAdviseFee.getDoctorName(),tradeAdviseFee.getPayFee(),
tradeAdviseFee.getStatus(),tradeAdviseFee.getPatientName(),tradeAdviseFee.getTradeId()});
return result;
}
4:查询list集合
public List<Long> getTradeAdviseDoctorPager(String userId, Pager pager) {
String tempSql = "select distinct(adviseFee.doctor_id) from td_trade_advise_fee adviseFee,td_trade trade where adviseFee.trade_id=trade.trade_id and trade.user_id=?";
String selectSql = "select * from (select * from " + tempSql + ") as a limit ?,?";
List<Long> doctIdList = this.jdbcTemplate.
queryForList(selectSql, Long.class, new Object[]{userId});
return doctIdList;
}
5:删除
public int deleteTradeAdviseFee(long tradeId) {
String deleteSql = "delete from td_trade_advise_fee where trade_id=?";
int result = this.jdbcTemplate.
update(deleteSql, new Object[]{tradeId});
return result;
}
6:插入
public boolean insertTradeAdviseFee(String cookieId, long tradeType, String tradeName,
String userId, String userName, TradeAdviseFee tradeAdviseFee) {
try {
String getSeqSql = "select max(trade_id)+1 from td_trade_advise_fee";
long newSeq = this.jdbcTemplate.queryForLong(getSeqSql);
Date da=new Date();
String insertTradeSql = "insert into td_trade(trade_id,cookieId,trade_type,trade_name,user_id,user_name,start_time,state)" +
"values(?,?,?,?,?,?,"+da+",1)";
int result =
this.jdbcTemplate.update(insertTradeSql, new Object[]{newSeq,cookieId,tradeType,tradeName,userId,userName});
String insertAdviseSql = "insert into td_trade_advise_fee(trade_id,subject,descption,medical_his,check_result,hope_help,accept_time," +
"doctor_id,doctor_name,pay_fee,order_status,status)values(?,?,?,?,?,?,"+da+",?,?,?,?,?)";
result = this.jdbcTemplate.update(insertAdviseSql, new Object[]{newSeq,tradeAdviseFee.getSubject(),tradeAdviseFee.getDescption(),tradeAdviseFee.getMedicalHis(),
tradeAdviseFee.getCheckResult(),tradeAdviseFee.getHopeHelp(),tradeAdviseFee.getDoctorId(),tradeAdviseFee.getDoctorName(),tradeAdviseFee.getPayFee(),});
return true;
}
catch (DataAccessException e) {
logger.error("添加收费咨询信息错误!", e);
}
return false;
}