Project

General

Profile

Programming Guide for Batch Program » History » Revision 2

Revision 1 (chin-yeh, 09/29/2011 09:41 AM) → Revision 2/5 (chin-yeh, 09/29/2011 10:49 AM)

{{toc}} 

 h1. Programming Guide for Batch Program 

 > Refer to [[Programming Guide]] if integrating in other environment, e.g. web app 

 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. 

 The Javadoc of *dp-client*: 
 > http://192.168.2.13:50000/dp_client_apidocs/ 

 The binary or source files of *dp-client*: 
 > [[wiki#SCM|SCM]] 

 Demo application of *dp-client*: 
 > There is no demo application for these APIs but these API usage is very similiar with the one that mentioned in [[Programming Guide]] 

 h2. Commit Sales 

 This method is used to deduct DP balance. And, this method *will only persist* the transaction details into database. 

 _Method Signature:_ 
 <pre> 
 <code class="JAVA"> 
 public static int persistSalesCommit(java.sql.Connection dbConnection, 
                                      java.lang.String transactionId, 
                                      java.lang.String countryCode, 
                                      java.lang.String memberId, 
                                      java.util.Date trxDate, 
                                      java.math.BigDecimal dpAmount, 
                                      java.math.BigDecimal invoiceAmount) 
                               throws java.sql.SQLException 
 </code> 
 </pre> 


 h3. Input Parameters 

 See "persistSalesCommit":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html 

 h3. Output Parameters 

 The number of affected rows 

 h3. Code Snippets 

 <pre> 
 <code class="JAVA"> 
 Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2"); 
 TransactionResponse dpResponse = new TransactionResponse(); 
 try { 
	 dpResponse = DPServicesUtils.persistSalesCommit(dbConnection, 
				 trxId, countryCode, shopperId, 
				 trxDate, dpAmount, invoiceAmount); 
 } catch (SQLException ex) { 
	 LOGGER.error("Error in persisting the event", ex); 
 } finally { 		
	 if (dbConnection != null) { 
	    dbConnection.close(); 
	 } 
 } 
 </code> 
 </pre> 

 h2. Sales Return / Cancel Sales 

 This method is used to adjust the DP balance. 

 _Method Signature:_ 
 <pre> 
 <code class="JAVA"> 
 public static int persistSalesReturn(java.sql.Connection connection, 
                                      java.lang.String transactionId, 
                                      java.lang.String countryCode, 
                                      java.lang.String memberId, 
                                      java.util.Date trxDate, 
                                      java.math.BigDecimal dpAmount, 
                                      java.math.BigDecimal invoiceAmount) 
                               throws java.sql.SQLException 
 </code> 
 </pre> 

 h3. Input Parameters 

 See "persistSalesReturn":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html 

 h3. Output Parameters 

 The number of affected rows 

 h3. Code Snippets 

 <pre> 
 <code class="JAVA"> 
 Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2"); 
	
 TransactionResponse dpResponse = new TransactionResponse(); 

 try { 
	 dpResponse = DPServicesUtils.persistSalesReturn(dbConnection, trxId, countryCode,  
			 shopperId,trxDate, dpAmount, invoiceAmount); 	

 } catch (SQLException ex) { 
	 LOGGER.error("Error in persisting the event", ex); 
 } finally { 
	 if (dbConnection != null) { 
		 dbConnection.close(); 
	 } 
 } 
 </code> 
 </pre> 


 h2. VIP Upgrade to BO 

 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. 

 _Method Signature:_ 
 <pre> 
 <code class="JAVA"> 
 public static int persistVipUpgrade(java.sql.Connection connection, 
                                     java.lang.String trxId, 
                                     java.lang.String countryCode, 
                                     java.lang.String memberName, 
                                     java.lang.String memberId, 
                                     java.lang.String newMemberId, 
                                     java.util.Date trxDate) 
                              throws java.sql.SQLException 
 </code> 
 </pre> 

 h3. Input Parameters 

 See "persistVipUpgrade":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html 

 h3. Output Parameters 

 The number of affected rows 

 h3. Code Snippets 

 <pre> 
 <code class="JAVA"> 
 Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2"); 
	
 TransactionResponse dpResponse = new TransactionResponse(); 

 try { 
	 dpResponse = DPServicesUtils.persistVipUpgrade(dbConnection, trxId, countryCode, 
			 memberName, shopperId, newShopperId, trxDate); 

 } catch (SQLException ex) { 
	 LOGGER.error("Error in persisting the event", ex); 
 } finally { 
	 if (dbConnection != null) { 
		 dbConnection.close(); 
	 } 
 } 
 </code> 
 </pre>