Project

General

Profile

Programming Guide for Batch Program » History » Version 2

chin-yeh, 09/29/2011 10:49 AM

1 1 chin-yeh
{{toc}}
2
3
h1. Programming Guide for Batch Program
4 2 chin-yeh
5
> Refer to [[Programming Guide]] if integrating in other environment, e.g. web app
6
7
All of the APIs mentioned below will not invoke the DP web services at all. Instead it will insert record into [[Specification#DP_INTERFACE|interface table]] and then those records will be picked up by a specific batch program and send it to DP on daily basis.
8
9
The Javadoc of *dp-client*:
10
> http://192.168.2.13:50000/dp_client_apidocs/
11
12
The binary or source files of *dp-client*:
13
> [[wiki#SCM|SCM]]
14
15
Demo application of *dp-client*:
16
> There is no demo application for these APIs but these API usage is very similiar with the one that mentioned in [[Programming Guide]]
17
18
h2. Commit Sales
19
20
This method is used to deduct DP balance. And, this method *will only persist* the transaction details into database.
21
22
_Method Signature:_
23
<pre>
24
<code class="JAVA">
25
public static int persistSalesCommit(java.sql.Connection dbConnection,
26
                                     java.lang.String transactionId,
27
                                     java.lang.String countryCode,
28
                                     java.lang.String memberId,
29
                                     java.util.Date trxDate,
30
                                     java.math.BigDecimal dpAmount,
31
                                     java.math.BigDecimal invoiceAmount)
32
                              throws java.sql.SQLException
33
</code>
34
</pre>
35
36
37
h3. Input Parameters
38
39
See "persistSalesCommit":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
40
41
h3. Output Parameters
42
43
The number of affected rows
44
45
h3. Code Snippets
46
47
<pre>
48
<code class="JAVA">
49
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
50
TransactionResponse dpResponse = new TransactionResponse();
51
try {
52
	dpResponse = DPServicesUtils.persistSalesCommit(dbConnection,
53
				trxId, countryCode, shopperId,
54
				trxDate, dpAmount, invoiceAmount);
55
} catch (SQLException ex) {
56
	LOGGER.error("Error in persisting the event", ex);
57
} finally {		
58
	if (dbConnection != null) {
59
	   dbConnection.close();
60
	}
61
}
62
</code>
63
</pre>
64
65
h2. Sales Return / Cancel Sales
66
67
This method is used to adjust the DP balance.
68
69
_Method Signature:_
70
<pre>
71
<code class="JAVA">
72
public static int persistSalesReturn(java.sql.Connection connection,
73
                                     java.lang.String transactionId,
74
                                     java.lang.String countryCode,
75
                                     java.lang.String memberId,
76
                                     java.util.Date trxDate,
77
                                     java.math.BigDecimal dpAmount,
78
                                     java.math.BigDecimal invoiceAmount)
79
                              throws java.sql.SQLException
80
</code>
81
</pre>
82
83
h3. Input Parameters
84
85
See "persistSalesReturn":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
86
87
h3. Output Parameters
88
89
The number of affected rows
90
91
h3. Code Snippets
92
93
<pre>
94
<code class="JAVA">
95
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
96
	
97
TransactionResponse dpResponse = new TransactionResponse();
98
99
try {
100
	dpResponse = DPServicesUtils.persistSalesReturn(dbConnection, trxId, countryCode, 
101
			shopperId,trxDate, dpAmount, invoiceAmount);	
102
103
} catch (SQLException ex) {
104
	LOGGER.error("Error in persisting the event", ex);
105
} finally {
106
	if (dbConnection != null) {
107
		dbConnection.close();
108
	}
109
}
110
</code>
111
</pre>
112
113
114
h2. VIP Upgrade to BO
115
116
This method upgrades the VIP to BO. One must utilize all of the remaining DP balance in the limited period of time. The validity period is determined by DP.
117
118
_Method Signature:_
119
<pre>
120
<code class="JAVA">
121
public static int persistVipUpgrade(java.sql.Connection connection,
122
                                    java.lang.String trxId,
123
                                    java.lang.String countryCode,
124
                                    java.lang.String memberName,
125
                                    java.lang.String memberId,
126
                                    java.lang.String newMemberId,
127
                                    java.util.Date trxDate)
128
                             throws java.sql.SQLException
129
</code>
130
</pre>
131
132
h3. Input Parameters
133
134
See "persistVipUpgrade":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
135
136
h3. Output Parameters
137
138
The number of affected rows
139
140
h3. Code Snippets
141
142
<pre>
143
<code class="JAVA">
144
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
145
	
146
TransactionResponse dpResponse = new TransactionResponse();
147
148
try {
149
	dpResponse = DPServicesUtils.persistVipUpgrade(dbConnection, trxId, countryCode,
150
			memberName, shopperId, newShopperId, trxDate);
151
152
} catch (SQLException ex) {
153
	LOGGER.error("Error in persisting the event", ex);
154
} finally {
155
	if (dbConnection != null) {
156
		dbConnection.close();
157
	}
158
}
159
</code>
160
</pre>