| 7226 |
anupam.sin |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 7293 |
anupam.sin |
3 |
import java.text.SimpleDateFormat;
|
| 7263 |
anupam.sin |
4 |
import java.util.ArrayList;
|
| 7386 |
anupam.sin |
5 |
import java.util.Arrays;
|
| 7263 |
anupam.sin |
6 |
import java.util.Calendar;
|
| 7293 |
anupam.sin |
7 |
import java.util.Date;
|
| 7263 |
anupam.sin |
8 |
import java.util.List;
|
|
|
9 |
import java.util.Random;
|
|
|
10 |
|
| 7343 |
anupam.sin |
11 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
12 |
import org.apache.struts2.convention.annotation.Results;
|
| 7263 |
anupam.sin |
13 |
import org.apache.thrift.TException;
|
|
|
14 |
import org.apache.thrift.transport.TTransportException;
|
|
|
15 |
|
| 7427 |
anupam.sin |
16 |
import in.shop2020.logistics.DeliveryType;
|
|
|
17 |
import in.shop2020.logistics.LogisticsInfo;
|
| 7293 |
anupam.sin |
18 |
import in.shop2020.logistics.PickUpType;
|
| 7427 |
anupam.sin |
19 |
import in.shop2020.logistics.LogisticsService.Client;
|
| 7263 |
anupam.sin |
20 |
import in.shop2020.model.v1.catalog.Item;
|
| 7427 |
anupam.sin |
21 |
import in.shop2020.model.v1.catalog.ItemShippingInfo;
|
| 7323 |
anupam.sin |
22 |
import in.shop2020.model.v1.catalog.StorePricing;
|
| 7386 |
anupam.sin |
23 |
import in.shop2020.model.v1.order.HotspotStore;
|
| 7263 |
anupam.sin |
24 |
import in.shop2020.model.v1.order.LineItem;
|
|
|
25 |
import in.shop2020.model.v1.order.Order;
|
| 7293 |
anupam.sin |
26 |
import in.shop2020.model.v1.order.OrderSource;
|
| 7263 |
anupam.sin |
27 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 7293 |
anupam.sin |
28 |
import in.shop2020.model.v1.order.OrderType;
|
| 7263 |
anupam.sin |
29 |
import in.shop2020.model.v1.order.SourceDetail;
|
| 7386 |
anupam.sin |
30 |
import in.shop2020.model.v1.order.StoreOrderDetail;
|
|
|
31 |
import in.shop2020.model.v1.order.StorePaymentStatus;
|
| 7263 |
anupam.sin |
32 |
import in.shop2020.model.v1.order.Transaction;
|
|
|
33 |
import in.shop2020.model.v1.order.TransactionStatus;
|
|
|
34 |
import in.shop2020.model.v1.user.User;
|
|
|
35 |
import in.shop2020.model.v1.user.UserContextException;
|
| 7268 |
anupam.sin |
36 |
import in.shop2020.payments.PaymentStatus;
|
| 7263 |
anupam.sin |
37 |
import in.shop2020.thrift.clients.CatalogClient;
|
|
|
38 |
import in.shop2020.thrift.clients.HelperClient;
|
| 7427 |
anupam.sin |
39 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 7268 |
anupam.sin |
40 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 7263 |
anupam.sin |
41 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
42 |
import in.shop2020.thrift.clients.UserClient;
|
|
|
43 |
import in.shop2020.utils.Mail;
|
|
|
44 |
|
|
|
45 |
import in.shop2020.serving.controllers.BaseController;
|
| 7293 |
anupam.sin |
46 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 7263 |
anupam.sin |
47 |
|
| 7343 |
anupam.sin |
48 |
@Results({
|
|
|
49 |
@Result(name="order-success-redirect", type="redirectAction", params = {"actionName", "order-success", "paymentId", "${paymentId}", "userId", "${userId}"})
|
|
|
50 |
})
|
|
|
51 |
|
| 7226 |
anupam.sin |
52 |
public class PaymentDetailsController extends BaseController {
|
|
|
53 |
|
| 7248 |
anupam.sin |
54 |
/**
|
|
|
55 |
*
|
|
|
56 |
*/
|
|
|
57 |
private static final long serialVersionUID = 1L;
|
|
|
58 |
private String name;
|
|
|
59 |
private String phone;
|
| 7226 |
anupam.sin |
60 |
private String line1;
|
|
|
61 |
private String line2;
|
|
|
62 |
private String city;
|
|
|
63 |
private String state;
|
|
|
64 |
private String pincode;
|
| 7263 |
anupam.sin |
65 |
private Long product_id;
|
|
|
66 |
private String email;
|
|
|
67 |
private static int LENGTH = 10;
|
|
|
68 |
private static final String chars = "abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
69 |
private static final Random random = new Random();
|
|
|
70 |
private String errorMsg = "";
|
|
|
71 |
private double price;
|
| 7293 |
anupam.sin |
72 |
private List<Order> orders = new ArrayList<Order>();
|
|
|
73 |
private Double advanceAmount;
|
|
|
74 |
private String deliveryDate = "";
|
| 7323 |
anupam.sin |
75 |
private String productName = "";
|
|
|
76 |
private String bestDealText = "";
|
|
|
77 |
private String CatalogItemId = "";
|
| 7611 |
anupam.sin |
78 |
private String cardType = "";
|
| 7343 |
anupam.sin |
79 |
private long paymentId;
|
|
|
80 |
private long userId;
|
| 7226 |
anupam.sin |
81 |
|
| 7343 |
anupam.sin |
82 |
|
| 7323 |
anupam.sin |
83 |
private StorePricing sp;
|
| 7386 |
anupam.sin |
84 |
private double cardAmount;
|
|
|
85 |
private double cashAmount;
|
| 7399 |
anupam.sin |
86 |
private String edc;
|
| 7423 |
anupam.sin |
87 |
private String approvalCode;
|
| 7293 |
anupam.sin |
88 |
|
| 7248 |
anupam.sin |
89 |
public String index() {
|
| 7386 |
anupam.sin |
90 |
String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
|
|
|
91 |
if(loginStatus == null || !loginStatus.equals("TRUE")){
|
|
|
92 |
return "authfail";
|
|
|
93 |
}
|
|
|
94 |
storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
|
|
|
95 |
if(!hotspotStores.containsKey(storeId)){
|
|
|
96 |
try{
|
|
|
97 |
HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
|
|
|
98 |
hotspotStores.put(storeId, hotSpotStore);
|
|
|
99 |
} catch (Exception e) {
|
|
|
100 |
log.error("Unable to get store", e);
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
|
| 7248 |
anupam.sin |
104 |
return INDEX;
|
|
|
105 |
}
|
|
|
106 |
|
| 7226 |
anupam.sin |
107 |
public String create(){
|
|
|
108 |
return index();
|
|
|
109 |
}
|
| 7263 |
anupam.sin |
110 |
|
|
|
111 |
public String persistTransaction() {
|
| 7427 |
anupam.sin |
112 |
if(advanceAmount > price) {
|
|
|
113 |
setErrorMsg("Advance amount was greater than Total Price.");
|
|
|
114 |
return "error-result";
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
if(cashAmount + cardAmount != advanceAmount) {
|
|
|
118 |
setErrorMsg("Sum of cash and card amounts was not equal to total Price.");
|
|
|
119 |
return "error-result";
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
if(cardAmount > 0 && approvalCode.equals("")) {
|
|
|
123 |
setErrorMsg("Approval code cannot be empty.");
|
|
|
124 |
return "error-result";
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
validateAddress();
|
|
|
128 |
|
| 7263 |
anupam.sin |
129 |
Transaction txnObj = new Transaction();
|
| 7386 |
anupam.sin |
130 |
StoreOrderDetail storeOrderDetail = new StoreOrderDetail();
|
| 7263 |
anupam.sin |
131 |
|
|
|
132 |
if(email != null && !email.isEmpty()) {
|
| 7343 |
anupam.sin |
133 |
userId = createUserAndSendMail(email);
|
| 7263 |
anupam.sin |
134 |
} else {
|
| 7427 |
anupam.sin |
135 |
log.error("Email is null, terminating the transaction");
|
|
|
136 |
setErrorMsg("Invalid email Id. Please try again.");
|
|
|
137 |
return "error-result";
|
| 7263 |
anupam.sin |
138 |
}
|
|
|
139 |
|
| 7427 |
anupam.sin |
140 |
if(userId == -1 || userId == 0) {
|
| 7263 |
anupam.sin |
141 |
log.error("Unable to get a user, terminating the transaction");
|
|
|
142 |
setErrorMsg("Unable to create a user for this order. Please try again.");
|
|
|
143 |
return "error-result";
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
txnObj.setShoppingCartid(0);
|
| 7343 |
anupam.sin |
147 |
txnObj.setCustomer_id(userId);
|
| 7263 |
anupam.sin |
148 |
txnObj.setCreatedOn(Calendar.getInstance().getTimeInMillis());
|
|
|
149 |
txnObj.setTransactionStatus(TransactionStatus.INIT);
|
|
|
150 |
txnObj.setStatusDescription("New Store Order");
|
|
|
151 |
txnObj.setCoupon_code("");
|
| 19443 |
amit.gupta |
152 |
//txnObj.setPayment_option(payment_option)(0);
|
|
|
153 |
log.info("UserId : " + userId);
|
| 7343 |
anupam.sin |
154 |
Order order = createOrder(userId);
|
| 7323 |
anupam.sin |
155 |
|
|
|
156 |
if(order == null) {
|
| 7263 |
anupam.sin |
157 |
log.error("Unable to create transaction");
|
|
|
158 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
159 |
return "error-result";
|
|
|
160 |
}
|
|
|
161 |
|
| 7323 |
anupam.sin |
162 |
orders.add(order);
|
| 7263 |
anupam.sin |
163 |
txnObj.setOrders(orders);
|
| 7386 |
anupam.sin |
164 |
|
| 7263 |
anupam.sin |
165 |
TransactionClient tcl;
|
| 7268 |
anupam.sin |
166 |
long txnId = 0;
|
| 7263 |
anupam.sin |
167 |
try {
|
|
|
168 |
tcl = new TransactionClient();
|
| 7268 |
anupam.sin |
169 |
txnId = tcl.getClient().createTransaction(txnObj);
|
| 7386 |
anupam.sin |
170 |
|
|
|
171 |
storeOrderDetail.setAdvanceAmount(advanceAmount);
|
|
|
172 |
storeOrderDetail.setCardAmount(cardAmount);
|
|
|
173 |
storeOrderDetail.setCashAmount(cashAmount);
|
|
|
174 |
storeOrderDetail.setOrderId(txnId);
|
| 7399 |
anupam.sin |
175 |
storeOrderDetail.setStoreId(Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
|
| 7386 |
anupam.sin |
176 |
if(advanceAmount == price) {
|
|
|
177 |
storeOrderDetail.setPayStatus(StorePaymentStatus.FULL_PAY_RECEIVED);
|
|
|
178 |
} else {
|
|
|
179 |
storeOrderDetail.setPayStatus(StorePaymentStatus.ADV_RECEIVED);
|
|
|
180 |
}
|
| 7399 |
anupam.sin |
181 |
if(cardAmount > 0) {
|
| 7611 |
anupam.sin |
182 |
if(edc == null || edc.equals("")) {
|
|
|
183 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
184 |
log.error("Error : EDC is null");
|
|
|
185 |
return "error-result";
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
if(cardType == null || cardType.equals("")) {
|
|
|
189 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
190 |
log.error("Error : CardType is null");
|
|
|
191 |
return "error-result";
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
if(cardType == null || cardType.equals("")) {
|
|
|
195 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
196 |
log.error("Error : CardType is null");
|
|
|
197 |
return "error-result";
|
|
|
198 |
}
|
|
|
199 |
|
| 7399 |
anupam.sin |
200 |
storeOrderDetail.setEdcBank(edc);
|
| 7611 |
anupam.sin |
201 |
storeOrderDetail.setCardType(cardType);
|
|
|
202 |
storeOrderDetail.setApprovalCode(approvalCode);
|
| 7399 |
anupam.sin |
203 |
}
|
|
|
204 |
storeOrderDetail.setCardRefundAmount(0);
|
|
|
205 |
storeOrderDetail.setCashRefundAmount(0);
|
| 7386 |
anupam.sin |
206 |
|
|
|
207 |
boolean saveSuccess = tcl.getClient().saveStoreOrderDetail(storeOrderDetail);
|
|
|
208 |
if(!saveSuccess) {
|
|
|
209 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
210 |
return "error-result";
|
|
|
211 |
}
|
|
|
212 |
|
| 7263 |
anupam.sin |
213 |
} catch (Exception e) {
|
|
|
214 |
log.error("Unable to create transaction", e);
|
|
|
215 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
216 |
return "error-result";
|
|
|
217 |
}
|
| 7268 |
anupam.sin |
218 |
|
| 7293 |
anupam.sin |
219 |
PaymentClient pcl;
|
| 7268 |
anupam.sin |
220 |
try {
|
| 7293 |
anupam.sin |
221 |
pcl = new PaymentClient();
|
| 7343 |
anupam.sin |
222 |
paymentId = pcl.getClient().createPayment(userId, price, 10, txnId, true);
|
| 7293 |
anupam.sin |
223 |
//Update payment status as authorized
|
| 7343 |
anupam.sin |
224 |
pcl.getClient().updatePaymentDetails(paymentId, "", "", "0", "", "", "", "", "", PaymentStatus.SUCCESS, "", null);
|
|
|
225 |
txnId = pcl.getClient().getPayment(paymentId).getMerchantTxnId();
|
| 7268 |
anupam.sin |
226 |
} catch(Exception e) {
|
|
|
227 |
log.error("Unable to create payment for this order");
|
|
|
228 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
229 |
return "error-result";
|
|
|
230 |
}
|
| 7293 |
anupam.sin |
231 |
|
|
|
232 |
try {
|
| 7323 |
anupam.sin |
233 |
TransactionStatus txnStatus = TransactionStatus.COD_IN_PROCESS;
|
|
|
234 |
if(advanceAmount >= price) {
|
|
|
235 |
txnStatus = TransactionStatus.AUTHORIZED;
|
|
|
236 |
}
|
|
|
237 |
|
| 7293 |
anupam.sin |
238 |
tcl = new TransactionClient();
|
| 7323 |
anupam.sin |
239 |
boolean status = tcl.getClient().changeTransactionStatus(txnId, txnStatus, "Payment authorized", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.STORE);
|
| 7293 |
anupam.sin |
240 |
if(!status) {
|
|
|
241 |
log.error("Unable to update transaction");
|
|
|
242 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
243 |
return "error-result";
|
|
|
244 |
}
|
|
|
245 |
} catch (Exception e) {
|
|
|
246 |
log.error("Unable to create transaction", e);
|
|
|
247 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
248 |
return "error-result";
|
|
|
249 |
}
|
|
|
250 |
|
| 19443 |
amit.gupta |
251 |
//No mail is required to sent.
|
|
|
252 |
/*try {
|
| 7426 |
anupam.sin |
253 |
|
|
|
254 |
tcl = new TransactionClient();
|
|
|
255 |
tcl.getClient().enqueueTransactionInfoEmail(txnId);
|
|
|
256 |
} catch (Exception e) {
|
|
|
257 |
log.error("Unable to send email", e);
|
| 19443 |
amit.gupta |
258 |
}*/
|
| 7426 |
anupam.sin |
259 |
|
| 7343 |
anupam.sin |
260 |
return "order-success-redirect";
|
| 7263 |
anupam.sin |
261 |
}
|
|
|
262 |
|
| 7427 |
anupam.sin |
263 |
String validateAddress() {
|
|
|
264 |
if(name.equals("") || line1.equals("") || city.equals("") || state.equals("") || pincode.equals("") || phone.equals("")) {
|
|
|
265 |
setErrorMsg("Address was invalid");
|
|
|
266 |
return "error-result";
|
|
|
267 |
}
|
|
|
268 |
return "";
|
|
|
269 |
}
|
|
|
270 |
|
| 7263 |
anupam.sin |
271 |
public Order createOrder(long userId) {
|
|
|
272 |
LineItem lineObj = createLineItem();
|
|
|
273 |
if (lineObj == null) {
|
|
|
274 |
return null;
|
|
|
275 |
}
|
|
|
276 |
Order order = new Order();
|
|
|
277 |
User user = new User();
|
|
|
278 |
try {
|
|
|
279 |
UserClient ucl = new UserClient();
|
|
|
280 |
user = ucl.getClient().getUserById(userId);
|
|
|
281 |
} catch (Exception e) {
|
|
|
282 |
log.error("Unable to get user for id " + userId, e);
|
|
|
283 |
return null;
|
|
|
284 |
}
|
|
|
285 |
order.setCustomer_id(user.getUserId());
|
|
|
286 |
order.setCustomer_email(user.getEmail());
|
|
|
287 |
order.setCustomer_name(name);
|
|
|
288 |
order.setCustomer_address1(line1);
|
|
|
289 |
order.setCustomer_address2(line2);
|
|
|
290 |
order.setCustomer_city(city);
|
|
|
291 |
order.setCustomer_state(state);
|
|
|
292 |
order.setCustomer_pincode(pincode);
|
|
|
293 |
order.setCustomer_mobilenumber(phone);
|
|
|
294 |
|
|
|
295 |
order.setTotal_amount(price);
|
| 7427 |
anupam.sin |
296 |
order.setStatus(OrderStatus.PAYMENT_PENDING);
|
|
|
297 |
order.setStatusDescription("Order Incomplete");
|
| 7263 |
anupam.sin |
298 |
order.setCreated_timestamp(Calendar.getInstance().getTimeInMillis());
|
| 7268 |
anupam.sin |
299 |
order.setTotal_weight(lineObj.getTotal_weight());
|
| 7263 |
anupam.sin |
300 |
|
| 19706 |
amit.gupta |
301 |
order.setSource(OrderSource.STORE.getValue());
|
| 7423 |
anupam.sin |
302 |
order.setStoreId(Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
|
| 7323 |
anupam.sin |
303 |
|
| 7293 |
anupam.sin |
304 |
order.setAdvanceAmount(advanceAmount);
|
| 7323 |
anupam.sin |
305 |
order.setFreebieItemId(sp.getFreebieItemId());
|
| 7293 |
anupam.sin |
306 |
|
| 7435 |
anupam.sin |
307 |
order.setOrderType(OrderType.B2C);
|
|
|
308 |
|
| 7268 |
anupam.sin |
309 |
List<LineItem> lines = new ArrayList<LineItem>();
|
|
|
310 |
lines.add(lineObj);
|
|
|
311 |
order.setLineitems(lines);
|
| 7263 |
anupam.sin |
312 |
return order;
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
public LineItem createLineItem() {
|
|
|
316 |
LineItem lineitem = new LineItem();
|
|
|
317 |
Item item = null;
|
|
|
318 |
try {
|
|
|
319 |
CatalogClient ccl = new CatalogClient();
|
|
|
320 |
item = ccl.getClient().getItem(product_id);
|
| 7323 |
anupam.sin |
321 |
sp = ccl.getClient().getStorePricing(product_id);
|
|
|
322 |
lineitem.setDealText(sp.getBestDealText());
|
| 7427 |
anupam.sin |
323 |
|
|
|
324 |
ItemShippingInfo info = ccl.getClient().isActive(product_id);
|
|
|
325 |
boolean isActive = info.isIsActive();
|
|
|
326 |
boolean activeOnStore = ccl.getClient().getItem(product_id).isActiveOnStore();
|
|
|
327 |
|
|
|
328 |
if(!isActive || !activeOnStore) {
|
|
|
329 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
330 |
return null;
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
if(price < sp.getAbsoluteMinPrice()) {
|
|
|
334 |
setErrorMsg("You cannot sell below Rs." + sp.getAbsoluteMinPrice());
|
|
|
335 |
return null;
|
|
|
336 |
}
|
| 7263 |
anupam.sin |
337 |
} catch (Exception e) {
|
|
|
338 |
log.error("Unable to get the item from catalog service, ItemId : " + product_id, e);
|
|
|
339 |
setErrorMsg("Unable to create order. Please try again.");
|
|
|
340 |
return null;
|
|
|
341 |
}
|
|
|
342 |
lineitem.setProductGroup(item.getProductGroup());
|
|
|
343 |
lineitem.setBrand(item.getBrand());
|
|
|
344 |
lineitem.setModel_number(item.getModelNumber());
|
|
|
345 |
lineitem.setModel_name(item.getModelName());
|
|
|
346 |
if(item.getColor() == null || item.getColor().isEmpty()) {
|
|
|
347 |
lineitem.setColor("");
|
|
|
348 |
} else {
|
|
|
349 |
lineitem.setColor(item.getColor());
|
|
|
350 |
}
|
|
|
351 |
lineitem.setExtra_info(item.getFeatureDescription());
|
|
|
352 |
lineitem.setItem_id(item.getId());
|
|
|
353 |
lineitem.setQuantity(1.0);
|
|
|
354 |
lineitem.setUnit_price(price);
|
|
|
355 |
lineitem.setTotal_price(price);
|
|
|
356 |
lineitem.setUnit_weight(item.getWeight());
|
|
|
357 |
lineitem.setTotal_weight(item.getWeight());
|
| 7360 |
anupam.sin |
358 |
lineitem.setDealText(bestDealText);
|
| 7263 |
anupam.sin |
359 |
|
|
|
360 |
if(item.getWarrantyPeriod() > 0) {
|
|
|
361 |
//Computing Manufacturer Warranty expiry date
|
|
|
362 |
Calendar cal = Calendar.getInstance();
|
|
|
363 |
cal.add(Calendar.MONTH, item.getWarrantyPeriod());
|
| 7268 |
anupam.sin |
364 |
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
|
| 7263 |
anupam.sin |
365 |
lineitem.setWarrantry_expiry_timestamp(cal.getTimeInMillis());
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
return lineitem;
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
private static String generateNewPassword() {
|
|
|
372 |
char[] buf = new char[LENGTH];
|
|
|
373 |
for (int i = 0; i < buf.length; i++) {
|
|
|
374 |
buf[i] = chars.charAt(random.nextInt(chars.length()));
|
|
|
375 |
}
|
|
|
376 |
return new String(buf);
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
private long createUserAndSendMail(String email) {
|
|
|
380 |
User user = null;
|
|
|
381 |
String password = null;
|
|
|
382 |
try{
|
|
|
383 |
UserClient ucl = new UserClient();
|
|
|
384 |
user = ucl.getClient().getUserByEmail(email);
|
|
|
385 |
if(user.getUserId() == -1) {
|
|
|
386 |
user.setEmail(email);
|
|
|
387 |
password = generateNewPassword();
|
|
|
388 |
String encryptedPassword = password;
|
|
|
389 |
user.setPassword(encryptedPassword);
|
|
|
390 |
user.setCommunicationEmail(email);
|
|
|
391 |
UserClient userContextServiceClient = new UserClient();
|
|
|
392 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
|
|
|
393 |
user = userClient.createUser(user);
|
|
|
394 |
|
|
|
395 |
List<String> toList = new ArrayList<String>();
|
|
|
396 |
toList.add(email);
|
|
|
397 |
HelperClient helperServiceClient = null;
|
|
|
398 |
helperServiceClient = new HelperClient();
|
|
|
399 |
in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
|
|
|
400 |
Mail mail = new Mail();
|
|
|
401 |
mail.setSubject("Saholic Registration successful");
|
|
|
402 |
mail.setTo(toList);
|
|
|
403 |
mail.setData("Your have successfully registered with Saholic.com. Your user name is: " + email + " and your password is: " + password);
|
|
|
404 |
client.sendMail(mail);
|
|
|
405 |
}
|
|
|
406 |
}catch (UserContextException ux){
|
|
|
407 |
return -1;
|
|
|
408 |
} catch (TTransportException e) {
|
|
|
409 |
return -1;
|
|
|
410 |
} catch (TException e) {
|
|
|
411 |
return -1;
|
|
|
412 |
} catch (Exception e) {
|
|
|
413 |
log.error("Unexpected error while mailing the new password");
|
|
|
414 |
return -1;
|
|
|
415 |
}
|
|
|
416 |
return user.getUserId();
|
|
|
417 |
}
|
| 7386 |
anupam.sin |
418 |
|
|
|
419 |
public List<String> getAllEdcBanks() {
|
|
|
420 |
List<String> banks = new ArrayList<String>();
|
|
|
421 |
try {
|
|
|
422 |
TransactionClient tcl = new TransactionClient();
|
|
|
423 |
banks = tcl.getClient().getAllEdcBanks();
|
|
|
424 |
} catch (Exception e) {
|
|
|
425 |
log.error("Unable to get banks for EDC", e);
|
|
|
426 |
}
|
|
|
427 |
return banks;
|
|
|
428 |
}
|
| 7263 |
anupam.sin |
429 |
|
| 7226 |
anupam.sin |
430 |
public String getLine1() {
|
|
|
431 |
return line1;
|
|
|
432 |
}
|
|
|
433 |
|
|
|
434 |
public void setLine1(String line1) {
|
|
|
435 |
this.line1 = line1;
|
|
|
436 |
}
|
|
|
437 |
|
|
|
438 |
public String getLine2() {
|
|
|
439 |
return line2;
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
public void setLine2(String line2) {
|
|
|
443 |
this.line2 = line2;
|
|
|
444 |
}
|
|
|
445 |
|
|
|
446 |
public String getCity() {
|
|
|
447 |
return city;
|
|
|
448 |
}
|
|
|
449 |
|
|
|
450 |
public void setCity(String city) {
|
|
|
451 |
this.city = city;
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
public String getState() {
|
|
|
455 |
return state;
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
public void setState(String state) {
|
|
|
459 |
this.state = state;
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
public String getPincode() {
|
|
|
463 |
return pincode;
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
public void setPincode(String pincode) {
|
|
|
467 |
this.pincode = pincode;
|
|
|
468 |
}
|
|
|
469 |
|
| 7248 |
anupam.sin |
470 |
public String getName() {
|
|
|
471 |
return name;
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
public void setName(String name) {
|
|
|
475 |
this.name = name;
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
public String getPhone() {
|
|
|
479 |
return phone;
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
public void setPhone(String phone) {
|
|
|
483 |
this.phone = phone;
|
|
|
484 |
}
|
|
|
485 |
|
| 7263 |
anupam.sin |
486 |
public void setProduct_id(Long product_id) {
|
|
|
487 |
this.product_id = product_id;
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
public Long getProduct_id() {
|
|
|
491 |
return product_id;
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
public String getEmail() {
|
|
|
495 |
return email;
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
public void setEmail(String email) {
|
|
|
499 |
this.email = email;
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
public void setErrorMsg(String errorMsg) {
|
|
|
503 |
this.errorMsg = errorMsg;
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
public String getErrorMsg() {
|
|
|
507 |
return errorMsg;
|
|
|
508 |
}
|
|
|
509 |
|
|
|
510 |
public double getPrice() {
|
|
|
511 |
return price;
|
|
|
512 |
}
|
|
|
513 |
|
|
|
514 |
public void setPrice(double price) {
|
|
|
515 |
this.price = price;
|
|
|
516 |
}
|
| 7293 |
anupam.sin |
517 |
|
|
|
518 |
public List<Order> getOrders() {
|
|
|
519 |
return orders;
|
|
|
520 |
}
|
|
|
521 |
|
|
|
522 |
public void setOrders(List<Order> orders) {
|
|
|
523 |
this.orders = orders;
|
|
|
524 |
}
|
|
|
525 |
|
|
|
526 |
public Double getAdvanceAmount() {
|
|
|
527 |
return advanceAmount;
|
|
|
528 |
}
|
|
|
529 |
|
|
|
530 |
public void setAdvanceAmount(Double advanceAmount) {
|
|
|
531 |
this.advanceAmount = advanceAmount;
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
public void setDeliveryDate(String deliveryDate) {
|
|
|
535 |
this.deliveryDate = deliveryDate;
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
public String getDeliveryDate() {
|
|
|
539 |
return deliveryDate;
|
|
|
540 |
}
|
|
|
541 |
|
| 7323 |
anupam.sin |
542 |
public String getProductName() {
|
|
|
543 |
return productName;
|
|
|
544 |
}
|
|
|
545 |
|
|
|
546 |
public void setProductName(String productName) {
|
|
|
547 |
this.productName = productName;
|
|
|
548 |
}
|
|
|
549 |
|
|
|
550 |
public String getBestDealText() {
|
|
|
551 |
return bestDealText;
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
public void setBestDealText(String bestDealText) {
|
|
|
555 |
this.bestDealText = bestDealText;
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
|
|
|
559 |
public String getImageSource() {
|
|
|
560 |
return "/storewebsite/images/website/" + getCatalogItemId() + "/default.jpg";
|
|
|
561 |
}
|
|
|
562 |
|
|
|
563 |
public String getCatalogItemId() {
|
|
|
564 |
return CatalogItemId;
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
public void setCatalogItemId(String catalogItemId) {
|
|
|
568 |
CatalogItemId = catalogItemId;
|
|
|
569 |
}
|
| 7343 |
anupam.sin |
570 |
|
|
|
571 |
public long getPaymentId() {
|
|
|
572 |
return paymentId;
|
|
|
573 |
}
|
|
|
574 |
|
|
|
575 |
public void setPaymentId(long paymentId) {
|
|
|
576 |
this.paymentId = paymentId;
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
public long getUserId() {
|
|
|
580 |
return userId;
|
|
|
581 |
}
|
|
|
582 |
|
|
|
583 |
public void setUserId(long userId) {
|
|
|
584 |
this.userId = userId;
|
|
|
585 |
}
|
| 7386 |
anupam.sin |
586 |
|
|
|
587 |
public double getCashAmount() {
|
|
|
588 |
return cashAmount;
|
|
|
589 |
}
|
|
|
590 |
|
|
|
591 |
public void setCashAmount(double cashAmount) {
|
|
|
592 |
this.cashAmount = cashAmount;
|
|
|
593 |
}
|
|
|
594 |
|
|
|
595 |
public double getCardAmount() {
|
|
|
596 |
return cardAmount;
|
|
|
597 |
}
|
|
|
598 |
|
|
|
599 |
public void setCardAmount(double cardAmount) {
|
|
|
600 |
this.cardAmount = cardAmount;
|
|
|
601 |
}
|
| 7399 |
anupam.sin |
602 |
|
|
|
603 |
public String getEdc() {
|
|
|
604 |
return edc;
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
public void setEdc(String edc) {
|
|
|
608 |
this.edc = edc;
|
|
|
609 |
}
|
| 7423 |
anupam.sin |
610 |
|
|
|
611 |
public String getApprovalCode() {
|
|
|
612 |
return approvalCode;
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
public void setApprovalCode(String approvalCode) {
|
|
|
616 |
this.approvalCode = approvalCode;
|
|
|
617 |
}
|
| 7611 |
anupam.sin |
618 |
|
|
|
619 |
public void setCardType(String cardType) {
|
|
|
620 |
this.cardType = cardType;
|
|
|
621 |
}
|
|
|
622 |
|
|
|
623 |
public String getCardType() {
|
|
|
624 |
return cardType;
|
|
|
625 |
}
|
| 7226 |
anupam.sin |
626 |
}
|