Subversion Repositories SmartDukaan

Rev

Rev 21963 | Rev 22363 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21963 Rev 22350
Line 25... Line 25...
25
    private static Logger log = Logger.getLogger(Class.class);
25
    private static Logger log = Logger.getLogger(Class.class);
26
    private String id;
26
    private String id;
27
    private long userId;
27
    private long userId;
28
    private User user;
28
    private User user;
29
    private List<Address> userAddresses;
29
    private List<Address> userAddresses;
30
    private Address primaryAdddress;
30
    private Address primaryAddress;
31
    private String trustLevelDelta;
31
    private String trustLevelDelta;
32
    private PrivateDealUser privateDealUser;
32
    private PrivateDealUser privateDealUser;
33
    private boolean documentVerified=false;
33
    private boolean documentVerified=false;
34
    private String gstin = "Unregistered";
34
    private String gstin = "Unregistered";
35
    private Counter counter= null;
35
    private Counter counter= null;
36
    
36
    
-
 
37
    private String line1;
-
 
38
    private String line2;
-
 
39
    private String city;
-
 
40
    private String pinCode;
-
 
41
    private String state;
37
 
42
 
38
	private String isPrivateDealUserActive;
43
	private String isPrivateDealUserActive;
39
    private static final String chars = "abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
44
    private static final String chars = "abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
40
    private static final Random random = new Random();
45
    private static final Random random = new Random();
41
    private static final int LENGTH = 10;
46
    private static final int LENGTH = 10;
42
 
47
 
43
 
48
 
44
    private in.shop2020.util.DesEncrypter desEncrypter = new in.shop2020.util.DesEncrypter("saholic");
49
    private in.shop2020.util.DesEncrypter desEncrypter = new in.shop2020.util.DesEncrypter("saholic");
45
 
50
 
46
    public String index() throws Exception {
51
    public String index() throws Exception {
-
 
52
    	log.info("GET INDEX CALLED");
47
        UserClient userServiceClient = new UserClient();
53
        UserClient userServiceClient = new UserClient();
48
        in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
54
        in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
49
        user = userClient.getUserById(userId);
55
        user = userClient.getUserById(userId);
50
        userAddresses = user.getAddresses();
56
        userAddresses = user.getAddresses();
51
 
57
        
52
        //
58
        //
53
        // For cases where Default Address is NULL in db, we get 0 as long here
59
        // For cases where Default Address is NULL in db, we get 0 as long here
54
        // Skipping such cases to avoid exception. Ideally UserContextService should simply
60
        // Skipping such cases to avoid exception. Ideally UserContextService should simply
55
        // return null in such cases.
61
        // return null in such cases.
56
        //
62
        //
57
        if (user.getDefaultAddressId() != 0) {
63
        if (user.getDefaultAddressId() != 0) {
58
            primaryAdddress = userClient.getAddressById(user.getDefaultAddressId());
64
            primaryAddress = userClient.getAddressById(user.getDefaultAddressId());
-
 
65
            log.info("primaryAddressState "+primaryAddress.getState());
59
        }
66
        }
60
 
67
 
61
        setPrivateDealUser(userClient.getPrivateDealUser(userId));
68
        setPrivateDealUser(userClient.getPrivateDealUser(userId));
62
        Counter c = userClient.getCounterByUserId(userId);
69
        Counter c = userClient.getCounterByUserId(userId);
63
        if(c.getId()!=0) {
70
        if(c.getId()!=0) {
64
        	this.counter = c;
71
        	this.counter = c;
65
        	if(StringUtils.isNotEmpty(c.getGstin())) {
72
        	if(StringUtils.isNotEmpty(c.getGstin())) {
66
        		this.gstin = c.getGstin();
73
        		this.gstin = c.getGstin();
67
        	}
74
        	}
68
        	this.documentVerified = c.isDocumentVerified();
75
        	this.documentVerified = c.isDocumentVerified();
69
        	
-
 
70
        }
76
        }
71
 
77
 
72
        return INDEX;
78
        return INDEX;
73
    }
79
    }
74
 
80
 
Line 84... Line 90...
84
            userContextServiceClient = new UserClient().getClient();
90
            userContextServiceClient = new UserClient().getClient();
85
            userContextServiceClient.addPrivateDealUser(userId);
91
            userContextServiceClient.addPrivateDealUser(userId);
86
        }
92
        }
87
        return index();
93
        return index();
88
    }
94
    }
-
 
95
    
-
 
96
    public String updateAddress() throws Exception{
-
 
97
    	userId = Long.parseLong(id);
-
 
98
    	userContextServiceClient = new UserClient().getClient();
-
 
99
        user = userContextServiceClient.getUserById(userId);
-
 
100
        primaryAddress = userContextServiceClient.getAddressById(user.getDefaultAddressId());
-
 
101
        primaryAddress.setLine1(line1);
-
 
102
        primaryAddress.setLine2(line2);
-
 
103
        primaryAddress.setCity(city);
-
 
104
        primaryAddress.setPin(pinCode);
-
 
105
        primaryAddress.setState(state);
-
 
106
        userContextServiceClient.updateAddress(primaryAddress);
-
 
107
    	return index();
-
 
108
    }
89
 
109
 
90
    public String changeStatusOfPrivateDealUser() throws Exception{
110
    public String changeStatusOfPrivateDealUser() throws Exception{
91
        if (canViewBulkOrderEnquiry()){
111
        if (canViewBulkOrderEnquiry()){
92
            userContextServiceClient = new UserClient().getClient();
112
            userContextServiceClient = new UserClient().getClient();
93
            userContextServiceClient.changePrivateDealUserStatus(userId, Boolean.valueOf(isPrivateDealUserActive));
113
            userContextServiceClient.changePrivateDealUserStatus(userId, Boolean.valueOf(isPrivateDealUserActive));
Line 160... Line 180...
160
 
180
 
161
    public List<Address> getUserAddresses() {
181
    public List<Address> getUserAddresses() {
162
        return userAddresses;
182
        return userAddresses;
163
    }
183
    }
164
 
184
 
165
    public Address getPrimaryAdddress() {
185
    public Address getPrimaryAddress() {
166
        return primaryAdddress;
186
        return primaryAddress;
167
    }
187
    }
168
 
188
 
169
    public String getTrustLevelDelta() {
189
    public String getTrustLevelDelta() {
170
        return trustLevelDelta;
190
        return trustLevelDelta;
171
    }
191
    }
Line 220... Line 240...
220
 
240
 
221
	public void setGstin(String gstin) {
241
	public void setGstin(String gstin) {
222
		this.gstin = gstin;
242
		this.gstin = gstin;
223
	}
243
	}
224
    
244
    
-
 
245
	public String getLine1() {
-
 
246
		log.info("GET LINE1 CALLED");
-
 
247
		return line1;
-
 
248
	}
-
 
249
	public void setLine1(String line1) {
-
 
250
		this.line1 = line1;
-
 
251
	}
-
 
252
	public String getLine2() {
-
 
253
		return line2;
-
 
254
	}
-
 
255
	public void setLine2(String line2) {
-
 
256
		this.line2 = line2;
-
 
257
	}
-
 
258
	public String getCity() {
-
 
259
		return city;
-
 
260
	}
-
 
261
	public void setCity(String city) {
-
 
262
		this.city = city;
-
 
263
	}
-
 
264
	public String getPinCode() {
-
 
265
		return pinCode;
-
 
266
	}
-
 
267
	public void setPinCode(String pinCode) {
-
 
268
		this.pinCode = pinCode;
-
 
269
	}
-
 
270
	public String getState() {
-
 
271
		return state;
-
 
272
	}
-
 
273
	public void setState(String state) {
-
 
274
		this.state = state;
-
 
275
	}
225
    
276
    
226
}
277
}
227
278