| 1946 |
chandransh |
1 |
package in.shop2020.payment.handler;
|
|
|
2 |
|
|
|
3 |
import java.text.SimpleDateFormat;
|
|
|
4 |
import java.util.Date;
|
|
|
5 |
import java.util.List;
|
|
|
6 |
import java.util.Map;
|
|
|
7 |
|
|
|
8 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
9 |
import org.springframework.stereotype.Service;
|
|
|
10 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
11 |
|
|
|
12 |
import in.shop2020.payment.domain.Payment;
|
|
|
13 |
import in.shop2020.payment.persistence.PaymentMapper;
|
|
|
14 |
|
|
|
15 |
@Service
|
|
|
16 |
public class PaymentHandler{
|
|
|
17 |
|
|
|
18 |
@Autowired
|
|
|
19 |
private PaymentMapper paymentMapper;
|
|
|
20 |
|
|
|
21 |
@Transactional
|
|
|
22 |
public long insertPayment(Payment payment){
|
|
|
23 |
paymentMapper.insertPayment(payment);
|
|
|
24 |
return payment.getId();
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public Payment getPayment(long id){
|
|
|
28 |
return paymentMapper.getPayment(id);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
@Transactional
|
|
|
32 |
public void updatePayment(Payment payment, Map<String, String> attributes){
|
|
|
33 |
paymentMapper.updatePayment(payment);
|
|
|
34 |
for(String key: attributes.keySet()){
|
|
|
35 |
paymentMapper.insertPaymentAttribute(payment.getId(), key, attributes.get(key));
|
|
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
public List<Payment> getPayments(long tFromTime, long tToTime, int status, long gatewayId){
|
|
|
40 |
SimpleDateFormat mysqlDateFormatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
41 |
String fromTime = mysqlDateFormatter.format(new Date(tFromTime));
|
|
|
42 |
String toTime = mysqlDateFormatter.format(new Date(tToTime));
|
| 2279 |
chandransh |
43 |
return paymentMapper.getPayments(fromTime, toTime, status, gatewayId);
|
| 1946 |
chandransh |
44 |
}
|
|
|
45 |
|
|
|
46 |
public List<Payment> getPaymentsForUser(long userId, long tFromTime, long tToTime, int status, long gatewayId){
|
|
|
47 |
SimpleDateFormat mysqlDateFormatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
48 |
String fromTime = mysqlDateFormatter.format(new Date(tFromTime));
|
|
|
49 |
String toTime = mysqlDateFormatter.format(new Date(tToTime));
|
|
|
50 |
return paymentMapper.getPaymentsForUser(userId, fromTime, toTime, status, gatewayId);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
public List<Payment> getPaymentForTxn(long merchantTxnId){
|
|
|
54 |
return paymentMapper.getPaymentForTxn(merchantTxnId);
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
public Map<String, Float> getMinMaxPaymentAmount(){
|
|
|
58 |
return paymentMapper.getMinMaxPaymentAmount();
|
|
|
59 |
}
|
|
|
60 |
}
|