Subversion Repositories SmartDukaan

Rev

Rev 28854 | Rev 28977 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
28755 amit.gupta 1
package com.spice.profitmandi.dao.model;
2
 
28797 amit.gupta 3
import java.time.LocalDate;
4
import java.time.LocalDateTime;
28900 manish 5
import java.util.Arrays;
6
import java.util.List;
28797 amit.gupta 7
 
8
import org.apache.logging.log4j.LogManager;
9
import org.apache.logging.log4j.Logger;
10
 
28755 amit.gupta 11
import com.spice.profitmandi.dao.enumuration.fofo.ApplicableServiceType;
12
import com.spice.profitmandi.dao.enumuration.fofo.PartnerStatusType;
13
 
14
public class FinanceServicesModel {
15
 
16
	private int fofoId;
17
	private PartnerStatusType partnerStatusType;
18
	private ApplicableServiceType applicableType;
28797 amit.gupta 19
	private boolean active;
28755 amit.gupta 20
	private int brandServiceId;
21
	private int serviceId;
22
	private String brand;
23
	private String name;
28797 amit.gupta 24
	private String code;
28854 manish 25
	private ApplicableServiceType serviceApplicableType;
28797 amit.gupta 26
	private String fofoCode;
27
	private LocalDateTime createTimestamp;
28
	private LocalDateTime deploymentDate;
29
	private LocalDateTime payDate;
28755 amit.gupta 30
 
28797 amit.gupta 31
	private static final Logger LOGGER = LogManager.getLogger(FinanceServicesModel.class);
28755 amit.gupta 32
 
28900 manish 33
	static final List<String> paperFinanceServices = Arrays.asList("SAMSUNG SURE", "BAJAJ FINSERV", "HOME CREDIT",
34
			"HDB", "CAPITAL FIRST");
35
 
28797 amit.gupta 36
	public boolean getServiceStatusByCodeTimeStamp() throws NullPointerException {
28755 amit.gupta 37
 
28797 amit.gupta 38
		LOGGER.info("thisName" + this.getName());
39
		LOGGER.info("fofoThis" + this.getFofoId());
40
 
41
		if (this.getName().equals("PAYTM") && this.getCreateTimestamp() != null) {
42
 
43
			LocalDateTime paytmTime = this.getCreateTimestamp().plusDays(5);
44
			LocalDateTime currDate = LocalDate.now().atStartOfDay();
45
 
46
			if (currDate.isBefore(paytmTime)) {
47
				LOGGER.info("PAYTMTrue");
48
				return true;
49
			}
50
			return false;
51
		}
52
 
53
		else if (this.getName().equals("PINELABS") && this.getCreateTimestamp() != null)
54
 
55
		{
56
 
57
			LOGGER.info("PINELABS");
58
			LocalDateTime pinlabsTime = this.getCreateTimestamp().plusDays(10);
59
 
60
			LocalDateTime currDate = LocalDate.now().atStartOfDay();
61
 
62
			if (currDate.isBefore(pinlabsTime)) {
63
				LOGGER.info("PINELABTrue");
64
				return true;
65
			}
66
 
67
			return false;
68
 
69
		}
70
 
71
		else if (this.getName().equals("ZEST MONEY") && this.getCreateTimestamp() != null)
72
 
73
		{
74
			LocalDateTime zestMoneyTime = this.getCreateTimestamp().plusDays(10);
75
 
76
			LocalDateTime currDate = LocalDate.now().atStartOfDay();
77
 
78
			if (currDate.isBefore(zestMoneyTime)) {
79
				LOGGER.info("MONEYTrue");
80
				return true;
81
			}
82
 
83
			else {
28900 manish 84
 
28797 amit.gupta 85
				return false;
86
			}
87
 
88
		}
89
 
28900 manish 90
		for (String paperFinanceServices : paperFinanceServices) {
91
			if (this.getName().equals(paperFinanceServices)) {
92
				LocalDateTime minDate = null;
93
				LocalDateTime currDate = LocalDate.now().atStartOfDay();
94
				if (this.getDeploymentDate() != null && this.getPayDate() != null) {
95
					minDate = this.getDeploymentDate().isBefore(this.getPayDate()) ? this.getDeploymentDate()
96
							: this.getPayDate();
28797 amit.gupta 97
 
28900 manish 98
					if (currDate.isBefore(minDate)) {
99
						LOGGER.info("MONEYTrue");
100
						return true;
101
					}
28797 amit.gupta 102
 
28900 manish 103
					else {
28797 amit.gupta 104
 
28900 manish 105
						return false;
106
					}
28797 amit.gupta 107
 
108
				}
109
 
28900 manish 110
				else if (this.getPayDate() == null && this.getPayDate() == null) {
28797 amit.gupta 111
 
112
					return false;
113
				}
114
 
28900 manish 115
				else if (this.getPayDate() == null) {
116
					minDate = this.getDeploymentDate();
117
					if (currDate.isBefore(minDate)) {
118
						LOGGER.info("MONEYTrue");
119
						return true;
120
					}
28797 amit.gupta 121
 
28900 manish 122
					else {
28797 amit.gupta 123
 
28900 manish 124
						return false;
125
					}
126
				} else {
127
					minDate = this.getPayDate();
128
					if (currDate.isBefore(minDate)) {
129
						LOGGER.info("MONEYTrue");
130
						return true;
131
					}
28797 amit.gupta 132
 
28900 manish 133
					else {
28797 amit.gupta 134
 
28900 manish 135
						return false;
136
					}
28797 amit.gupta 137
				}
138
			}
139
 
140
		}
141
 
142
		return true;
28755 amit.gupta 143
	}
144
 
145
	public int getFofoId() {
146
		return fofoId;
147
	}
148
 
149
	public void setFofoId(int fofoId) {
150
		this.fofoId = fofoId;
151
	}
152
 
153
	public PartnerStatusType getPartnerStatusType() {
154
		return partnerStatusType;
155
	}
156
 
157
	public void setPartnerStatusType(PartnerStatusType partnerStatusType) {
158
		this.partnerStatusType = partnerStatusType;
159
	}
160
 
28797 amit.gupta 161
	public ApplicableServiceType getApplicableType() {
162
		return applicableType;
163
	}
164
 
165
	public void setApplicableType(ApplicableServiceType applicableType) {
166
		this.applicableType = applicableType;
167
	}
168
 
169
	public boolean isActive() {
170
		return active;
171
	}
172
 
173
	public void setActive(boolean active) {
174
		this.active = active;
175
	}
176
 
28755 amit.gupta 177
	public int getBrandServiceId() {
178
		return brandServiceId;
179
	}
180
 
181
	public void setBrandServiceId(int brandServiceId) {
182
		this.brandServiceId = brandServiceId;
183
	}
184
 
185
	public int getServiceId() {
186
		return serviceId;
187
	}
188
 
189
	public void setServiceId(int serviceId) {
190
		this.serviceId = serviceId;
191
	}
192
 
193
	public String getBrand() {
194
		return brand;
195
	}
196
 
197
	public void setBrand(String brand) {
198
		this.brand = brand;
199
	}
200
 
201
	public String getName() {
202
		return name;
203
	}
204
 
205
	public void setName(String name) {
206
		this.name = name;
207
	}
208
 
28797 amit.gupta 209
	public String getCode() {
210
		return code;
211
	}
212
 
213
	public void setCode(String code) {
214
		this.code = code;
215
	}
216
 
28854 manish 217
	public ApplicableServiceType getServiceApplicableType() {
218
		return serviceApplicableType;
219
	}
220
 
221
	public void setServiceApplicableType(ApplicableServiceType serviceApplicableType) {
222
		this.serviceApplicableType = serviceApplicableType;
223
	}
224
 
28797 amit.gupta 225
	public String getFofoCode() {
226
		return fofoCode;
227
	}
228
 
229
	public void setFofoCode(String fofoCode) {
230
		this.fofoCode = fofoCode;
231
	}
232
 
233
	public LocalDateTime getCreateTimestamp() {
234
		return createTimestamp;
235
	}
236
 
237
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
238
		this.createTimestamp = createTimestamp;
239
	}
240
 
241
	public LocalDateTime getDeploymentDate() {
242
		return deploymentDate;
243
	}
244
 
245
	public void setDeploymentDate(LocalDateTime deploymentDate) {
246
		this.deploymentDate = deploymentDate;
247
	}
248
 
249
	public LocalDateTime getPayDate() {
250
		return payDate;
251
	}
252
 
253
	public void setPayDate(LocalDateTime payDate) {
254
		this.payDate = payDate;
255
	}
256
 
28854 manish 257
	public static Logger getLogger() {
258
		return LOGGER;
28755 amit.gupta 259
	}
260
 
261
	@Override
28854 manish 262
	public String toString() {
263
		return "FinanceServicesModel [fofoId=" + fofoId + ", partnerStatusType=" + partnerStatusType
264
				+ ", applicableType=" + applicableType + ", active=" + active + ", brandServiceId=" + brandServiceId
265
				+ ", serviceId=" + serviceId + ", brand=" + brand + ", name=" + name + ", code=" + code
266
				+ ", serviceApplicableType=" + serviceApplicableType + ", fofoCode=" + fofoCode + ", createTimestamp="
267
				+ createTimestamp + ", deploymentDate=" + deploymentDate + ", payDate=" + payDate + "]";
28755 amit.gupta 268
	}
269
 
270
	public FinanceServicesModel(int fofoId, PartnerStatusType partnerStatusType, ApplicableServiceType applicableType,
28854 manish 271
			boolean active, int brandServiceId, int serviceId, String brand, String name, String code,
272
			ApplicableServiceType serviceApplicableType, String fofoCode, LocalDateTime createTimestamp) {
28755 amit.gupta 273
		super();
274
		this.fofoId = fofoId;
275
		this.partnerStatusType = partnerStatusType;
276
		this.applicableType = applicableType;
277
		this.active = active;
278
		this.brandServiceId = brandServiceId;
279
		this.serviceId = serviceId;
280
		this.brand = brand;
281
		this.name = name;
28797 amit.gupta 282
		this.code = code;
28854 manish 283
		this.serviceApplicableType = serviceApplicableType;
28797 amit.gupta 284
		this.fofoCode = fofoCode;
285
		this.createTimestamp = createTimestamp;
28755 amit.gupta 286
	}
287
 
28900 manish 288
}