📄 lovematch_g.jsp
字号:
<!--
* @ name: lovematch_g.jsp
* @ Author : ranxu
* @ date :2008-06-10
-->
<%@ page
import='java.io.*,java.text.*,java.util.Date,java.util.Vector, java.sql.*,com.entaz.lib.db.*,com.entaz.relay.net.*,java.text.DecimalFormat'
contentType='text/html;charset=euc-kr'%>
<%@ include file="../imgpath.jsp"%>
<%@ include file="../common_func.jsp"%>
<%!/*------------------------------------------------------------------------------------------------------
+ method:getAnswer()
action: star 1(db)--"拱捍磊府"(jsp)
2(db)--"拱绊扁磊府"(jsp)
.
.
12(db)--"堪家磊府"(jsp)
blood 1(db)--"A"(jsp)
2(db)--"B"(jsp)
3(db)--"O"(jsp)
4(db)--"AB"(jsp)
lovePoint 65-70(db)--5(jsp)
70-75(db)--10(jsp)
75-80(db)--20(jsp)
80-85(db)--30(jsp)
85-90(db)--40(jsp)
90-95(db)--100(jsp)
>95(db)--200(jsp)
author:ranxu 2008-06-05
-------------------------------------------------------------------------------------------------------*/
int BLOOD_A = 1;
int BLOOD_B = 2;
int BLOOD_O = 4;
int BLOOD_AB = 3;
int STAR_拱捍 = 1;
int STAR_拱绊扁 = 2;
int STAR_剧 = 3;
int STAR_炔家 = 4;
int STAR_街嫡捞 = 5;
int STAR_霸 = 6;
int STAR_荤磊 = 7;
int STAR_贸赤 = 8;
int STAR_玫莫 = 9;
int STAR_傈哎 = 10;
int STAR_荤荐 = 11;
int STAR_堪家 = 12;
int LOVEPOINT_65 = 65;
int LOVEPOINT_70 = 70;
int LOVEPOINT_75 = 75;
int LOVEPOINT_80 = 80;
int LOVEPOINT_85 = 85;
int LOVEPOINT_90 = 90;
int LOVEPOINT_95 = 95;
public String getBlood(int key) {
String ret = "";
if (key == BLOOD_A) {
ret = "A";
} else if (key == BLOOD_B) {
ret = "B";
} else if (key == BLOOD_O) {
ret = "O";
} else if (key == BLOOD_AB) {
ret = "AB";
}
return ret;
}
public String getStar(int key) {
String ret = "";
if (key == STAR_拱捍) {
ret = "拱捍磊府";
} else if (key == STAR_拱绊扁) {
ret = "拱绊扁磊府";
} else if (key == STAR_剧) {
ret = "剧磊府 ";
} else if (key == STAR_炔家) {
ret = "炔家磊府";
} else if (key == STAR_街嫡捞) {
ret = "街嫡捞磊府";
} else if (key == STAR_霸) {
ret = "霸磊府";
} else if (key == STAR_荤磊) {
ret = "荤磊磊府";
} else if (key == STAR_贸赤) {
ret = "贸赤磊府";
} else if (key == STAR_玫莫) {
ret = "玫莫磊府";
} else if (key == STAR_傈哎) {
ret = "傈哎磊府";
} else if (key == STAR_荤荐) {
ret = "荤荐磊府";
} else if (key == STAR_堪家) {
ret = "堪家磊府";
}
return ret;
}
public int getLovePoint(int key) {
int ret=0;
if (key >= LOVEPOINT_65 && key < LOVEPOINT_70) {
ret = 5;
} else if (key >= LOVEPOINT_70 && key < LOVEPOINT_75) {
ret = 10;
} else if (key >= LOVEPOINT_75 && key < LOVEPOINT_80) {
ret = 20;
} else if (key >= LOVEPOINT_80 && key < LOVEPOINT_85) {
ret = 30;
} else if (key >= LOVEPOINT_85 && key < LOVEPOINT_90) {
ret = 40;
} else if (key >= LOVEPOINT_90 && key < LOVEPOINT_95) {
ret = 100;
} else if (key >= LOVEPOINT_95) {
ret = 200;
}
return ret;
}%>
<%
/*------------------------------------------------------------------------------------------------------
parameter from last page:knowmate_s.jap or knowmate_k.jap
-------------------------------------------------------------------------------------------------------*/
String mphone = request.getParameter("mphone");
String gphone = request.getParameter("gphone");
/*------------------------------------------------------------------------------------------------------
+ parameter of current page
-------------------------------------------------------------------------------------------------------*/
String guestNickname = "";
int guestStar = 0;
int guestBlood = 0;
int guestAge = 0;
int guestYear = 0;
int guestMonth = 0;
int guestDay = 0;
String hostNickname = "";
int hostStar = 0;
int hostBlood = 0;
int hostAge = 0;
int hostYear = 0;
int hostMonth = 0;
int hostDay = 0;
int currentYear = 0;
int currentMonth = 0;
int currentDay = 0;
int loveIdx = 0;
int lovePoint = 0;
String luckNum = "";
String comment = "";
int guestAttentionPoint = 0;
int guestAttentionPointOld = 0;
int hostAttentionPoint = 0;
int hostAttentionPointOld = 0;
/*------------------------------------------------------------------------------------------------------
+ DB
-------------------------------------------------------------------------------------------------------*/
PreparedStatement pstmt = null;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
int ret = -1;
boolean str_Flag = true;
String riqi = null;
int intRiqi = 0;
Date regdater = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
riqi = sf.format(regdater);
intRiqi = Integer.parseInt(riqi.replace("-",""));
boolean ktv = true;
boolean haveDate = true;
boolean haveDateOne = true;
try
{
/*------------------------------------------------------------------------------------------------
* DB 目池记
-------------------------------------------------------------------------------------------------*/
%><%@ include file="../getConnection.jsp"%><%
/*------------------------------------------------------------------------------------------------
* All Quiz answerCount
-------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------
+ guest's info
-------------------------------------------------------------------------------------------------------*/
//con = DBConnector.getConnection(db_name);
//if (con == null) {
// return;
//}
sql = " select nickname,star,blood,(substring(convert(varchar(8),getDate(),112),0,5)-year+1) age,"
+ " year,month,day from Gt_user_info WITH (READUNCOMMITTED) where phonenum =? ";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, mphone);
rs = pstmt.executeQuery();
if (rs.next()) {
guestNickname = rs.getString("nickname");
guestStar = rs.getInt("star");
guestBlood = rs.getInt("blood");
guestAge = rs.getInt("age");
guestYear = rs.getInt("year");
guestMonth = rs.getInt("month");
guestDay = rs.getInt("day");
}
rs.close();
pstmt.close();
/*------------------------------------------------------------------------------------------------------
+ host's info
-------------------------------------------------------------------------------------------------------*/
sql = " select nickname,star,blood,(substring(convert(varchar(8),getDate(),112),0,5)-year+1) age,"
+ " year,month,day from Gt_user_info WITH (READUNCOMMITTED) where phonenum =? ";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1, Long.parseLong(gphone));
rs = pstmt.executeQuery();
if (rs.next()) {
hostNickname = rs.getString("nickname");
hostStar = rs.getInt("star");
hostBlood = rs.getInt("blood");
hostAge = rs.getInt("age");
hostYear = rs.getInt("year");
hostMonth = rs.getInt("month");
hostDay = rs.getInt("day");
}
rs.close();
pstmt.close();
/*------------------------------------------------------------------------------------------------------
+ currentYear,currentMonth,currentDay
-------------------------------------------------------------------------------------------------------*/
sql = " select substring(convert(varchar(12),getdate(),112),3,2) year, "
+ " substring(convert(varchar(12),getdate(),112),5,2) month, "
+ " substring(convert(varchar(12),getdate(),112),7,2) day";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
currentYear = rs.getInt("year");
currentMonth = rs.getInt("month");
currentDay = rs.getInt("day");
}
rs.close();
pstmt.close();
loveIdx = (guestYear % 100 + guestMonth + guestDay + hostYear % 100
+ hostMonth + hostDay + currentYear + currentMonth + currentDay) % 60;
System.out.println("loveIdx:" + loveIdx);
/*------------------------------------------------------------------------------------------------------
+ lovePoint,luckNum,comment
-------------------------------------------------------------------------------------------------------*/
sql = " select * from gt_mugeta_love_manage WITH (READUNCOMMITTED) where idx=?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1, loveIdx);
rs = pstmt.executeQuery();
if (rs.next()) {
lovePoint = rs.getInt("love_point");
luckNum = rs.getString("luck_num");
comment = rs.getString("comment");
}
rs.close();
pstmt.close();
/*------------------------------------------------------------------------------------------------------
+ guest's attention piont
-------------------------------------------------------------------------------------------------------*/
sql = " select * from gt_lucky_attention_point WITH (READUNCOMMITTED) where phonenum=? and guest_phone=?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1, Long.parseLong(mphone));
pstmt.setLong(2, Long.parseLong(gphone));
rs = pstmt.executeQuery();
if (rs.next()) {
guestAttentionPoint = rs.getInt("attention_point");
guestAttentionPointOld = rs.getInt("attention_point_old");
}
rs.close();
pstmt.close();
/*------------------------------------------------------------------------------------------------------
+ host's attention piont
-------------------------------------------------------------------------------------------------------*/
sql = " select * from gt_lucky_attention_point WITH (READUNCOMMITTED) where phonenum=? and guest_phone=?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1, Long.parseLong(gphone));
pstmt.setLong(2, Long.parseLong(mphone));
rs = pstmt.executeQuery();
if (rs.next()) {
hostAttentionPoint = rs.getInt("attention_point");
hostAttentionPointOld = rs.getInt("attention_point_old");
}
rs.close();
pstmt.close();
/*------------------------------------------------------------------------------------------------------
+ add lovepiont between host and guest
-------------------------------------------------------------------------------------------------------*/
long hostPhone_db = 0;
long guestPhone_db = 0;
String hostNickname_db = "";
String guestNickname_db = "";
if(Long.parseLong(mphone)>Long.parseLong(gphone)){
hostPhone_db = Long.parseLong(mphone) ;
guestPhone_db = Long.parseLong(gphone);
hostNickname_db = guestNickname;
guestNickname_db = hostNickname ;
}else{
hostPhone_db = Long.parseLong(gphone) ;
guestPhone_db = Long.parseLong(mphone);
hostNickname_db = hostNickname;
guestNickname_db = guestNickname ;
}
sql = "SELECT * FROM GT_LUCK_POINT_DATE WHERE mphone = ? and gphone = ?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(mphone));
pstmt.setLong(2,Long.parseLong(gphone));
rs=pstmt.executeQuery();
if(rs.next()){
ktv = false;
}else{
haveDateOne = false;
}
rs.close();
pstmt.close();
if(!ktv){
sql = "SELECT * FROM GT_LUCKY_LOVE WHERE Guest_phone = ? and phonenum = ? and left(regdate,10) = left(getdate(),10)";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(mphone));
pstmt.setLong(2,Long.parseLong(gphone));
rs=pstmt.executeQuery();
if(rs.next()){
str_Flag = false;
}
rs.close();
pstmt.close();
}
if(haveDateOne){
sql = "SELECT * FROM GT_LUCK_POINT_DATE WHERE mphone = ? and gphone = ? and left(love_point_date,10) > left(getdate()-2,10)";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(mphone));
pstmt.setLong(2,Long.parseLong(gphone));
rs=pstmt.executeQuery();
if(rs.next()){
haveDate = false;
}
rs.close();
pstmt.close();
if(haveDate){
System.out.print("------------------------------");
sql = "UPDATE GT_LUCK_POINT_DATE SET love_point_date = getdate() WHERE gphone = ? and mphone = ?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(mphone));
ret = pstmt.executeUpdate();
pstmt.close();
}
}else{
sql = "insert into gt_luck_point_date (mphone,gphone,love_point_date) values (?,?,getdate())";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(mphone));
pstmt.setLong(2,Long.parseLong(gphone));
ret = pstmt.executeUpdate();
pstmt.close();
}
if(haveDate){
sql = "select * from gt_lucky_attention_point WITH (READUNCOMMITTED) where phonenum=? and guest_phone=? ";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(mphone));
rs=pstmt.executeQuery();
if(rs.next()){
sql = "update gt_lucky_attention_point set attention_point=attention_point+1 where phonenum=? and guest_phone=?";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(mphone));
ret = pstmt.executeUpdate();
pstmt.close();
}else{
sql = "insert into gt_lucky_attention_point (phonenum,guest_phone,attention_point,attention_point_old,regdate) values (?,?,?,?,?)";
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(gphone));
pstmt.setLong(2,Long.parseLong(mphone));
pstmt.setLong(3,1);
pstmt.setLong(4,0);
pstmt.setString(5,riqi);
ret = pstmt.executeUpdate();
pstmt.close();
}
rs.close();
}
if(str_Flag){
sql="insert into gt_lucky_love (phonenum,guest_phone,nickname,guest_nickname,love_point,title,text,flag,nregdate,regdate)values (?,?,?,?,?,?,?,?,?,?)";
Date nowTime=new Date(System.currentTimeMillis());
SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyyMMdd");
String todayTime=sDateFormat.format(nowTime);
int nngdate = Integer.parseInt(todayTime);
pstmt = con.prepareStatement(sql);
pstmt.setLong(1,hostPhone_db);
pstmt.setLong(2,guestPhone_db);
pstmt.setString(3,hostNickname_db);
pstmt.setString(4,guestNickname_db);
pstmt.setInt(5,lovePoint);
pstmt.setString(6,luckNum);
pstmt.setString(7,comment);
pstmt.setInt(8,0);
pstmt.setInt(9,nngdate);
pstmt.setString(10,riqi);
ret = pstmt.executeUpdate();
if(ret==-1){
return;
}
rs.close();
pstmt.close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -