Project

General

Profile

Programming Guide for Batch Program » History » Version 3

chin-yeh, 09/29/2011 10:51 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 3 chin-yeh
This method is used to deduct DP balance. 
21 1 chin-yeh
22 3 chin-yeh
_This method *will only persist* the transaction details into database._
23
24 2 chin-yeh
_Method Signature:_
25
<pre>
26
<code class="JAVA">
27
public static int persistSalesCommit(java.sql.Connection dbConnection,
28
                                     java.lang.String transactionId,
29
                                     java.lang.String countryCode,
30
                                     java.lang.String memberId,
31
                                     java.util.Date trxDate,
32
                                     java.math.BigDecimal dpAmount,
33
                                     java.math.BigDecimal invoiceAmount)
34
                              throws java.sql.SQLException
35
</code>
36
</pre>
37
38
39
h3. Input Parameters
40
41
See "persistSalesCommit":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
42
43
h3. Output Parameters
44
45
The number of affected rows
46
47
h3. Code Snippets
48
49
<pre>
50
<code class="JAVA">
51
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
52
TransactionResponse dpResponse = new TransactionResponse();
53
try {
54
	dpResponse = DPServicesUtils.persistSalesCommit(dbConnection,
55
				trxId, countryCode, shopperId,
56
				trxDate, dpAmount, invoiceAmount);
57
} catch (SQLException ex) {
58
	LOGGER.error("Error in persisting the event", ex);
59
} finally {		
60
	if (dbConnection != null) {
61
	   dbConnection.close();
62
	}
63
}
64
</code>
65
</pre>
66
67
h2. Sales Return / Cancel Sales
68
69
This method is used to adjust the DP balance.
70 1 chin-yeh
71 3 chin-yeh
_This method *will only persist* the transaction details into database._
72
73 2 chin-yeh
_Method Signature:_
74
<pre>
75
<code class="JAVA">
76
public static int persistSalesReturn(java.sql.Connection connection,
77
                                     java.lang.String transactionId,
78
                                     java.lang.String countryCode,
79
                                     java.lang.String memberId,
80
                                     java.util.Date trxDate,
81
                                     java.math.BigDecimal dpAmount,
82
                                     java.math.BigDecimal invoiceAmount)
83
                              throws java.sql.SQLException
84
</code>
85
</pre>
86
87
h3. Input Parameters
88
89
See "persistSalesReturn":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
90
91
h3. Output Parameters
92
93
The number of affected rows
94
95
h3. Code Snippets
96
97
<pre>
98
<code class="JAVA">
99
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
100
	
101
TransactionResponse dpResponse = new TransactionResponse();
102
103
try {
104
	dpResponse = DPServicesUtils.persistSalesReturn(dbConnection, trxId, countryCode, 
105
			shopperId,trxDate, dpAmount, invoiceAmount);	
106
107
} catch (SQLException ex) {
108
	LOGGER.error("Error in persisting the event", ex);
109
} finally {
110
	if (dbConnection != null) {
111
		dbConnection.close();
112
	}
113
}
114
</code>
115
</pre>
116
117
118
h2. VIP Upgrade to BO
119
120 1 chin-yeh
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.
121 3 chin-yeh
122
_This method *will only persist* the transaction details into database._
123 2 chin-yeh
124
_Method Signature:_
125
<pre>
126
<code class="JAVA">
127
public static int persistVipUpgrade(java.sql.Connection connection,
128
                                    java.lang.String trxId,
129
                                    java.lang.String countryCode,
130
                                    java.lang.String memberName,
131
                                    java.lang.String memberId,
132
                                    java.lang.String newMemberId,
133
                                    java.util.Date trxDate)
134
                             throws java.sql.SQLException
135
</code>
136
</pre>
137
138
h3. Input Parameters
139
140
See "persistVipUpgrade":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
141
142
h3. Output Parameters
143
144
The number of affected rows
145
146
h3. Code Snippets
147
148
<pre>
149
<code class="JAVA">
150
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
151
	
152
TransactionResponse dpResponse = new TransactionResponse();
153
154
try {
155
	dpResponse = DPServicesUtils.persistVipUpgrade(dbConnection, trxId, countryCode,
156
			memberName, shopperId, newShopperId, trxDate);
157
158
} catch (SQLException ex) {
159
	LOGGER.error("Error in persisting the event", ex);
160
} finally {
161
	if (dbConnection != null) {
162
		dbConnection.close();
163
	}
164
}
165
</code>
166
</pre>