public Long addCheckRecord( Connection conn, Integer creditrating, Long adminId, Long userId, Integer mterType) throws SQLException { Long result = -1L; Dao.Tables.t_user_check check = new Dao().new Tables().new t_user_check(); // 审核员的审核记录更新 DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String date = format.format(new Date()); // check.checkdate.setValue(date); // 设置审核时间 // 查询t_materialsauth表中信用积分 Map<String, String> map = null; int precreditrating = -1; Dao.Tables.t_materialsauth materialsauth = new Dao().new Tables().new t_materialsauth(); try { DataSet ds = materialsauth.open( conn, "criditing", " userId =" + userId + " AND materAuthTypeId = " + mterType, "", -1, -1); map = BeanMapUtils.dataSetToMap(ds); } catch (DataException e) { e.printStackTrace(); } if (map.size() > 0 && map != null) { precreditrating = Convert.strToInt(map.get("criditing"), -1); } if (precreditrating != -1) { check.perrecode.setValue(precreditrating); // 设置原来的信用分数 check.afterrecode.setValue(precreditrating + creditrating); check.adminId.setValue(adminId); // 设置审核者的id check.userId.setValue(userId); check.materialType.setValue(mterType); // 插入用户审核的类型 return check.insert(conn); // 插入审核员的id } return result; }
/** * 添加信用总分 * * @param conn * @param userId * @param alloption * @param creditrating * @param adminId * @param mterType * @return * @throws SQLException * @throws Exception */ public Long Updatecreditrating( Connection conn, Long userId, String alloption, Integer creditrating, Integer mterType, int status) throws SQLException, Exception { Long resut1 = -1L; Long resut2 = -1L; Dao.Tables.t_user user = new Dao().new Tables().new t_user(); Dao.Tables.t_materialsauth materialsauth = new Dao().new Tables().new t_materialsauth(); DataSet ds = user.open(conn, "creditrating", " id = " + userId, "", -1, -1); DataSet mads = materialsauth.open( conn, "auditStatus", " userId = " + userId + " AND materAuthTypeId = " + mterType, "", 0, -1); Integer precreditrating = -1; // 原来的信用积分 Integer auditStatus = -1; boolean flag = false; Map<String, String> map = new HashMap<String, String>(); Map<String, String> nmap = new HashMap<String, String>(); map = BeanMapUtils.dataSetToMap(ds); nmap = BeanMapUtils.dataSetToMap(mads); if (map != null && map.size() > 0 && nmap.size() > 0 && nmap != null) { precreditrating = Convert.strToInt(map.get("creditrating"), -1); auditStatus = Convert.strToInt(nmap.get("auditStatus"), -1); } else { return -1L; } if (StringUtils.isNotBlank(alloption) && mterType != null && alloption != null) { // 向证件类型主表更新数据 // 设置失效时间 DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String authTime = format.format(new Date()); Calendar cal = Calendar.getInstance(); cal.setTime(format.parse(authTime)); cal.add(Calendar.DATE, 30); String passDate = null; passDate = format.format(cal.getTime()); if (passDate != null && auditStatus == 2 && auditStatus != -1) { materialsauth.pastTime.setValue(passDate); } // ===== materialsauth.criditing.setValue(creditrating); materialsauth.option.setValue(alloption); materialsauth.auditStatus.setValue(status); resut1 = materialsauth.update(conn, " userId = " + userId + " AND materAuthTypeId = " + mterType); if (resut1 > 0) { flag = true; } else { flag = false; } } if (creditrating != null && creditrating != -1 && precreditrating != -1) { user.creditrating.setValue(creditrating + precreditrating); // 当前的信用积分加上后台添加的信用分数 resut2 = user.update(conn, " id = " + userId); // 更新信用分 if (resut2 > 0) { flag = true; } else { flag = false; } } map = null; nmap = null; ds = null; mads = null; if (flag) { return 1L; } else { return -1L; } }