📄 member.java
字号:
SQL.append(" order by MakeDate desc");
String result = "";
DBAccess d = new DBAccess();
result = d.executeQuery(SQL.toString(),cm.propList,pageSize,pageIndex);
setCOUNT(d.COUNT);
setEOF(d.EOF);
return result;
}
/**
* 验证数据库中是否存在号码为IDNumber的证件,若存在,返回true,否则返回false
* @param IDNumber 证件号码
* @return boolean
*/
public boolean verifyIDNumber(String IDNumber){
if(!Data.hasValue(IDNumber))return true; //IDNumber为空,停止注册
List l = new ArrayList();
l.add(IDNumber);
l.add(Member.get15IDNo(IDNumber)); //如果IDNumber为身份证,则15位和18位都代表同一个证件
l.add(Member.get18IDNo(IDNumber,""));
String sql = "SELECT count(IDNumber) as count FROM members WHERE idnumber=? Or (idnumber=? And idtype='0') Or (idnumber=? And idtype='0')";
DBAccess d = new DBAccess();
l = d.parseSQL(sql,l);
if(l==null)return true; //查询数据库出现异常,停止注册
else if(l.size()==0)return true; //l大小出现异常,停止注册
else if("0".equals((String)l.get(0)))return false; //IDNumber不存在,可以注册
else return true; //IDNumber已存在,停止注册
}
/**
* 验证数据库中是否存在号码为MemberID的用户ID,若存在,返回true,否则返回false
* @param MemberID 用户ID
* @return boolean
*/
public boolean verifyMemberID(String MemberID){
this.set("MemberID", MemberID);
String sql = "SELECT count(IDNumber) as count FROM members WHERE MemberID =?";
DBAccess d = new DBAccess();
String str = d.executeQuery(sql, this.propList, 1, 1);
if("0".equals(str))return false;
return true;
}
/**
* 验证用户登录
* @param AccountType 帐号类型
* @param AccountID 帐号ID
* @param Password 密码
* @return boolean
*/
public boolean verify(String AccountType,String AccountID,String Password){
String sql = "";
List l = new ArrayList();
if("0".equals(AccountType)){
sql = "select Password,CustomerNo from members where memberid=?";
l.add(AccountID);
}else if("1".equals(AccountType)){
sql = "select Password,CustomerNo from members where idnumber=? Or (idnumber=? And idtype='0') Or (idnumber=? And idtype='0')";
l.add(AccountID);
l.add(Member.get15IDNo(AccountID)); //无论用户输入的身份证号码是15位还是18位都可以通过验证
l.add(Member.get18IDNo(AccountID,""));
}
DBAccess d = new DBAccess();
l = d.parseSQL(sql,l);
if(l==null){
this.setErrorStr("loginFail");
return false;
}
if(l.size()==0){
this.setErrorStr("nouser");
return false;
}
String pwd = l.get(0).toString();
String CustomerNo = l.get(1).toString();
Md5 m = new Md5();
if(m.getMD5ofStr(Password).equals(pwd)){
this.set("CustomerNo", CustomerNo);
return true;
}else{
this.setErrorStr("passworderror");
return false;
}
}
/**
* 根据保单号从核心库中取5要素同用户输入值进行对比,若全部匹配,则返回true,否则返回false
* @param tmp 五要素
* @return boolean
*/
public boolean validateUser(String tmp){
if(!Data.hasValue(tmp))return false;
//System.out.println(tmp);
String strSplit[] = tmp.split(",");
if(strSplit.length!=7)return false;
String strTmp[] = {"AppName","AppSex","AppBirthday","IdType","IdNo"};
Customer cus = new Customer();
Element ele = null;
/*modify by qixin 2007-12-14 start*/
String info1 = "输入的注册信息:\n类型:"+strSplit[0]+"\n";
info1 += "号码:"+strSplit[1]+"\n";
info1 += "客户姓名:"+strSplit[2]+"\n";
info1 += "性别:"+strSplit[3]+"\n";
info1 += "出生日期:"+strSplit[4]+"\n";
info1 += "证件类型:"+strSplit[5]+"\n";
info1 += "证件号码:"+strSplit[6]+"\n";
//System.out.println("info1==>"+info1);
/*modify by qixin 2007-12-14 end*/
try{
ele = cus.CustomerRegist(strSplit[0], strSplit[1]);
}catch(Exception e){
System.out.println("Validate.validateUser()"+e.getMessage());
}
/*modify by qixin 2007-12-14 start*/
String st = "注册查询信息inputXML:\n";
st += cus.inputXML + "\n\n";
st += "注册查询信息outputXML:\n";
st += cus.outputXML + "\n\n";
String info2 = "";
if(ele!=null){
info2 += "报文信息:\n姓名:"+cus.getElementText(ele,"AppName")+"\n";
info2 += "性别:"+cus.getElementText(ele,"AppSex")+"\n";
info2 += "出生日期:"+cus.getElementText(ele,"AppBirthday")+"\n";
info2 += "证件类型:"+cus.getElementText(ele,"IdType")+"\n";
info2 += "证件号码:"+cus.getElementText(ele,"IdNo")+"\n";
}
String note = info1+"\n#######################\n"+info2;
if(ele==null){
String info3 = "没有查到任何相应信息";
note = info1+"\n#######################\n"+info3;
UserLog ul = new UserLog();
try{
ul.create(strSplit[1],"注册",strSplit[1],"注册查询失败");
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
int TableID = ul.getCOUNT();
if(TableID!=0){
BlobInfo bb = new BlobInfo();
try{
bb.create(""+TableID,"UserLog",note,st);
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
}
/*modify by qixin 2007-12-14 end*/
setErrorStr("你输入的保单号码不存在。");
return false;
}
//检查客户姓名、性别、出生日期、证件类型
for(int i=0;i<4;i++){
String tmpCore = cus.getElementText(ele,strTmp[i]);
if("不详".equals(tmpCore))continue;
if(!strSplit[i+2].equals(tmpCore)){
/*modify by qixin 2007-12-14 start*/
UserLog ul = new UserLog();
try{
ul.create(strSplit[1],"注册",strSplit[1],"注册查询失败");
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
int TableID = ul.getCOUNT();
if(TableID!=0){
BlobInfo bb = new BlobInfo();
try{
bb.create(""+TableID,"UserLog",note,st);
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
}
/*modify by qixin 2007-12-14 end*/
setErrorStr("你填写的资料与系统资料不符,请重新填写。");
return false;
}
}
//检查证件号码
String strID = cus.getElementText(ele,strTmp[4]);
if("身份证".equals(strSplit[5]))strID = Member.get18IDNo(strID, strTmp[2]); //如果是身份证,则转换成18位的身份证
if(strID==null){
setErrorStr("coredataerror");
return false;
}
if(strID.equals(strSplit[6])){ //证件号码匹配
//取其他信息
String tmpName[] = {"Province","Occupation","TelePhone","MobilePhone","Email","ZipCode","PostalAddress","CustomerNo"};
String tmpValue[] = {"Province","OccupationName","HomePhone","Mobile","EMail","ZipCode","PostalAddress","AppNo"};
for(int i=0;i<tmpName.length;i++){
set(tmpName[i],cus.getElementText(ele,tmpValue[i]));
}
/*modify by qixin 2007-12-14 start*/
UserLog ul = new UserLog();
try{
ul.create(strSplit[1],"注册",strSplit[1],"注册查询成功");
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
int TableID = ul.getCOUNT();
if(TableID!=0){
BlobInfo bb = new BlobInfo();
try{
bb.create(""+TableID,"UserLog",note,st);
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
}
/*modify by qixin 2007-12-14 end*/
return true;
}
else {
/*modify by qixin 2007-12-14 start*/
UserLog ul = new UserLog();
try{
ul.create(strSplit[1],"注册",strSplit[1],"注册查询失败");
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
int TableID = ul.getCOUNT();
if(TableID!=0){
BlobInfo bb = new BlobInfo();
try{
bb.create(""+TableID,"UserLog",note,st);
}catch(Exception e){
System.out.println("Member.validateUser()"+e.getMessage());
}
}
/*modify by qixin 2007-12-14 end*/
setErrorStr("你填写的资料与系统资料不符,请重新填写。");
return false;
}
}
/**
* 字典转换
* @param tmp
* @return String
*/
public String convertToNumber(String tmp){
if(!Data.hasValue(tmp))return "";
String str = "";
if(tmp.equals("男"))str="0";
else if(tmp.equals("女"))str="1";
else if(tmp.equals("身份证"))str="0";
else if(tmp.equals("护照"))str="1";
else if(tmp.equals("军官证"))str="2";
else if(tmp.equals("驾照"))str="3";
else if(tmp.equals("出生证明"))str="4";
else if(tmp.equals("户口簿"))str="5";
else if(tmp.equals("其他"))str="6";
else if(tmp.equals("数据转换证件"))str="7";
else if(tmp.equals("保单号"))str="0";
else if(tmp.equals("暂收费号"))str="1";
else if(tmp.equals("未婚"))str="0";
else if(tmp.equals("已婚"))str="1";
return str;
}
/**
* 获取18位身份证
* @param IDNo 身份证号
* @param Birthday 出生日期
* @return String
*/
public static String get18IDNo(String IDNo,String Birthday){
if(!Data.hasValue(IDNo) || (IDNo.length()!=18 && IDNo.length()!=15))return IDNo;
if(IDNo.length()==18){
if(IDNo.endsWith("x"))IDNo = IDNo.substring(0,17) + "X";
return IDNo;
}
String str = "";
str += IDNo.substring(0,6);
if(Data.hasValue(Birthday) && Birthday.length()==10){
str += Birthday.substring(0,2);
}else str += "19";
str += IDNo.substring(6,15);
int n = 0;
int[] weight = new int[] {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
for(int i=0;i<17;i++){
n += Integer.parseInt(str.substring(i,i+1))*weight[i];
}
n %= 11;
if(n==0)str += "1";
else if(n==1)str += "0";
else if(n==2)str += "X";
else if(n==3)str += "9";
else if(n==4)str += "8";
else if(n==5)str += "7";
else if(n==6)str += "6";
else if(n==7)str += "5";
else if(n==8)str += "4";
else if(n==9)str += "3";
else if(n==10)str += "2";
return str;
}
/**
* 获取15位身份证
* @param IDNo 身份证号
* @return String
*/
public static String get15IDNo(String IDNo){
if(!Data.hasValue(IDNo) || (IDNo.length()!=18 && IDNo.length()!=15))return "";
if(IDNo.length()==15)return IDNo;
String str = "";
str += IDNo.substring(0,6);
str += IDNo.substring(8,17);
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -