LgcAssetBasketOperation.jsp
10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %> <%@ include file="/systeminfo/init_wev8.jsp" %>
<%
String operation = Util.null2String(request.getParameter("operation"));
String catalogid = Util.null2String(request.getParameter("catalogid"));
String assetid = Util.null2String(request.getParameter("assetid"));
String webshopreturn = Util.null2String(request.getParameter("webshopreturn"));
String theassortment = Util.null2String(request.getParameter("theassortment"));
String selectedid = Util.null2String(request.getParameter("selectedid"));
String thecountry = Util.null2String(request.getParameter("thecountry"));
String theassetcountry = Util.null2String(request.getParameter("theassetcountry"));
String theattributes = Util.null2String(request.getParameter("theattributes"));
String isthenew = Util.null2String(request.getParameter("isthenew"));
String start = Util.null2String(request.getParameter("start"));
String webshoptype = Util.null2String(request.getParameter("webshoptype"));
String webshopmanageid = Util.null2String(request.getParameter("webshopmanageid"));
String userid = ""+ user.getUID() ;
int cookieage = 3*60*60*24 ;
if(operation.equals("add")) {
int buyitemcount = Util.getIntValue(Util.getCookie(request, "CoItem_"+userid+"_"+assetid+"_"+thecountry),-1) ;
int buycount = Util.getIntValue(Util.getCookie(request, "CoItemAll_"+userid),-1) ;
if(buyitemcount == -1) buyitemcount = 1 ;
else buyitemcount = buyitemcount+1 ;
if(buycount == -1) buycount = 1 ;
else buycount = buycount+1 ;
Util.setCookie(response , "CoItem_"+userid+"_"+assetid+"_"+thecountry , ""+buyitemcount , cookieage) ;
Util.setCookie(response , "CoItemAll_"+userid , ""+buycount , cookieage) ;
if(webshopreturn.equals("1"))
response.sendRedirect("LgcCatalogsView.jsp?id="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start);
else
response.sendRedirect("LgcAssetBasket.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("delete")) {
String cookiename = Util.null2String(request.getParameter("thecookiename"));
int buyitemcount = Util.getIntValue(Util.getCookie(request,cookiename)) ;
Util.setCookie(response , cookiename , "" , 0) ;
int buycount = Util.getIntValue(Util.getCookie(request, "CoItemAll_"+userid)) - buyitemcount ;
Util.setCookie(response , "CoItemAll_"+userid , ""+buycount , cookieage) ;
response.sendRedirect("LgcAssetBasket.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("addasset")) {
int buyitemcount = Util.getIntValue(Util.getCookie(request, "CoItem_"+userid+"_"+assetid+"_"+theassetcountry),-1) ;
int buycount = Util.getIntValue(Util.getCookie(request, "CoItemAll_"+userid),-1) ;
if(buyitemcount == -1) buyitemcount = 1 ;
else buyitemcount = buyitemcount+1 ;
if(buycount == -1) buycount = 1 ;
else buycount = buycount+1 ;
Util.setCookie(response , "CoItem_"+userid+"_"+assetid+"_"+theassetcountry , ""+buyitemcount , cookieage) ;
Util.setCookie(response , "CoItemAll_"+userid , ""+buycount , cookieage) ;
response.sendRedirect("LgcAssetBasket.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("change")) {
Enumeration theparanames = request.getParameterNames() ;
int buycount = 0 ;
while(theparanames.hasMoreElements()) {
String paraname = (String)theparanames.nextElement() ;
if(paraname.indexOf("CoItem_"+userid+"_") <0) continue ;
int paravalue = Util.getIntValue(request.getParameter(paraname),-1) ;
if(paravalue <0) paravalue = Util.getIntValue(Util.getCookie(request, paraname),0) ;
if(paravalue == 0 ) {
Util.setCookie(response , paraname , "" , 0) ;
continue ;
}
buycount += paravalue ;
Util.setCookie(response , paraname , ""+paravalue , cookieage) ;
}
Util.setCookie(response , "CoItemAll_"+userid , ""+buycount , cookieage) ;
response.sendRedirect("LgcAssetBasket.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("userinfo")) {
Enumeration theparanames = request.getParameterNames() ;
int buycount = 0 ;
while(theparanames.hasMoreElements()) {
String paraname = (String)theparanames.nextElement() ;
if(paraname.indexOf("CoItem_"+userid+"_") <0) continue ;
int paravalue = Util.getIntValue(request.getParameter(paraname),-1) ;
if(paravalue <0) paravalue = Util.getIntValue(Util.getCookie(request, paraname),0) ;
if(paravalue == 0 ) {
Util.setCookie(response , paraname , "" , 0) ;
continue ;
}
buycount += paravalue ;
Util.setCookie(response , paraname , ""+paravalue , cookieage) ;
}
Util.setCookie(response , "CoItemAll_"+userid , ""+buycount , cookieage) ;
response.sendRedirect("LgcBasketUserInfo.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("confirm")) {
Enumeration theparanames = request.getParameterNames() ;
int buycount = 0 ;
while(theparanames.hasMoreElements()) {
String paraname = (String)theparanames.nextElement() ;
if(paraname.indexOf("CoItem_"+userid+"_") <0) continue ;
int paravalue = Util.getIntValue(request.getParameter(paraname),-1) ;
if(paravalue <0) paravalue = Util.getIntValue(Util.getCookie(request, paraname),0) ;
if(paravalue == 0 ) {
Util.setCookie(response , paraname , "" , 0) ;
continue ;
}
buycount += paravalue ;
Util.setCookie(response , paraname , ""+paravalue , cookieage) ;
}
Util.setCookie(response , "CoItemAll_"+userid , ""+buycount , cookieage) ;
response.sendRedirect("LgcBasketConfirm.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("adduserinfo")) {
String username = Util.fromScreen(request.getParameter("username"),user.getLanguage());
String useremail = Util.fromScreen(request.getParameter("useremail"),user.getLanguage());
String receiveaddress = Util.fromScreen(request.getParameter("receiveaddress"),user.getLanguage());
String postcode = Util.fromScreen(request.getParameter("postcode"),user.getLanguage());
String telephone1 = Util.fromScreen(request.getParameter("telephone1"),user.getLanguage());
String telephone2 = Util.fromScreen(request.getParameter("telephone2"),user.getLanguage());
String purchaseremark = Util.fromScreen(request.getParameter("purchaseremark"),user.getLanguage());
user.setLastname(username) ;
user.setEmail(useremail) ;
user.setReceiveaddress(receiveaddress) ;
user.setPostcode(postcode) ;
user.setTelephone(telephone1) ;
user.setMobile(telephone2) ;
user.setRemark(purchaseremark) ;
response.sendRedirect("LgcBasketConfirm.jsp?catalogid="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start+"&webshoptype="+webshoptype+"&webshopmanageid="+webshopmanageid);
}
if(operation.equals("endsubmit")) {
RecordSet rs = new RecordSet() ;
char separator = Util.getSeparator() ;
String usertype = "" ;
if(webshoptype.equals("0")) usertype = "0" ;
else {
String theusertype = user.getResourcetype() ;
if(theusertype.equals("F") || theusertype.equals("H") || theusertype.equals("D") || theusertype.equals("T")) usertype = "9" ;
else if(theusertype.equals("O")) usertype = "2" ;
else usertype = "1" ;
}
String currencyid = Util.null2String(request.getParameter("thecurrencyid"));
String purchasecount = Util.null2String(request.getParameter("pricecount"));
String username = user.getUsername() ;
String usercountry = user.getCountryid() ;
String useremail = user.getEmail() ;
String receiveaddress = user.getReceiveaddress() ;
String postcode = user.getPostcode() ;
String telephone1 = user.getTelephone() ;
String telephone2 = user.getMobile() ;
String receivetype = "" ;
String paymentmode = "1" ;
String purchaseremark = user.getRemark() ;
Calendar today = Calendar.getInstance();
String purchasedate = Util.add0(today.get(Calendar.YEAR), 4) +"-"+
Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;
String para = usertype + separator + userid + separator + username + separator + usercountry
+ separator + useremail + separator + receiveaddress + separator + receivetype
+ separator + postcode + separator + telephone1 + separator + telephone2
+ separator + paymentmode + separator + currencyid + separator + purchasecount
+ separator + purchaseremark + separator + purchasedate + separator + webshopmanageid;
rs.executeProc("LgcWebShop_Insert",para);
rs.next() ;
String id = rs.getString(1) ;
Cookie thecookies[] = request.getCookies() ;
if(thecookies != null) {
for(int i=0 ; i<thecookies.length ; i++) {
String cookiename = thecookies[i].getName() ;
if(cookiename.indexOf("CoItem_"+userid+"_") <0) continue ;
String tempstr[] = Util.TokenizerString2(cookiename,"_") ;
String theassetid = tempstr[2] ;
String countryid = tempstr[3] ;
String purchasenum = Util.null2String(Util.getCookie(request,cookiename)) ;
para = theassetid + separator + countryid + separator + purchasenum ;
rs.executeProc("LgcAssetPrice_Select",para);
rs.next() ;
String assetprice = Util.null2String(rs.getString(1)) ;
String taxrate = Util.null2String(rs.getString(2)) ;
String thecurrencyid = Util.null2String(rs.getString(3));
para = id + separator + theassetid + separator + countryid + separator + thecurrencyid
+ separator + assetprice + separator + taxrate + separator + purchasenum ;
rs.executeProc("LgcWebShopDetail_Insert",para);
Util.setCookie(response , cookiename , "" , 0) ;
}
}
Util.setCookie(response , "CoItemAll_"+userid , "" , 0) ;
response.sendRedirect("LgcCatalogsView.jsp?id="+catalogid+"&theassortment="+theassortment+"&selectedid="+selectedid+"&thecountry="+thecountry+"&theattributes="+theattributes+"&isthenew=0&start="+start);
}
%>