Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
1946 chandransh 1
package in.shop2020.payment.persistence;
2
 
3
import java.util.List;
4
import java.util.Map;
5
 
6
import org.apache.ibatis.annotations.Param;
7
 
8
import in.shop2020.payment.domain.Payment;
9
import in.shop2020.payment.domain.PaymentAttribute;
10
 
11
public interface PaymentMapper {
12
	int insertPayment(Payment payment);
13
 
14
	void updatePayment(Payment payment);
15
 
16
	// TODO: All getPayment methods currently employ the simple N+1 strategy to
17
	// load the attributes. This is not desirable. Instead, more labour should
18
	// be spent into writing the long result maps which will use a single query.
19
	Payment getPayment(long id);
20
 
21
	List<Payment> getPaymentsForUser(@Param("userId") long userId,
22
			@Param("fromTime") String fromTime, @Param("toTime") String toTime,
23
			@Param("status") int status, @Param("gatewayId") long gatewayId);
24
 
25
	List<Payment> getPayments(@Param("fromTime") String fromTime, @Param("toTime") String toTime,
26
			@Param("status") int status, @Param("gatewayId") long gatewayId);
2976 chandransh 27
 
28
    /**
29
     * Currently, it returns the last payment for a transaction assuming that
30
     * it is the only one which can be successful.
31
     * 
32
     * @param merchantTxnId
33
     *            The merchant transaction for which payments are required.
34
     * @return A list of payments
35
     */
1946 chandransh 36
	List<Payment> getPaymentForTxn(long merchantTxnId);
2976 chandransh 37
 
38
    /**
39
     * Finds the maximum and minimum amount among the successful payments.
40
     * 
41
     * @return A map containing the maximum and minimum amount keyed using MAX
42
     *         and MIN as keys respectively.
43
     */
1946 chandransh 44
	Map<String, Float> getMinMaxPaymentAmount();
2976 chandransh 45
 
46
    /**
47
     * Get the list of attributes of a payment.
48
     * 
49
     * @param id
50
     *            Id of the payment whose attributes are required.
51
     * @return A list of all the attributes of a payment.
52
     */
1946 chandransh 53
	List<PaymentAttribute> getAttributesForPayment(long id);
2976 chandransh 54
 
55
    /**
56
     * Inserts an attribute for the given payments. If the attribute is already
57
     * present, just updates its value.
58
     * 
59
     * @param paymentId
60
     *            Id of the payment for which the attribute has to be added or
61
     *            updated.
62
     * @param name
63
     *            Name of the attribute
64
     * @param value
65
     *            Value of the attribute
66
     */
1946 chandransh 67
	void insertPaymentAttribute(@Param("paymentId") long paymentId,
68
			@Param("name") String name, @Param("value") String value);
69
}