|
@@ -159,6 +159,8 @@ public class WsProcessUtils extends DbProcessorAbstract {
|
|
|
PreparedStatement updateRegister = null;
|
|
PreparedStatement updateRegister = null;
|
|
|
PreparedStatement selectChargeId = null;
|
|
PreparedStatement selectChargeId = null;
|
|
|
PreparedStatement insertCharge = null;
|
|
PreparedStatement insertCharge = null;
|
|
|
|
|
+ PreparedStatement updateTurn = null;
|
|
|
|
|
+ PreparedStatement insertTurn = null;
|
|
|
PreparedStatement updateInbox = null;
|
|
PreparedStatement updateInbox = null;
|
|
|
ResultSet registerRs = null;
|
|
ResultSet registerRs = null;
|
|
|
ResultSet chargeIdRs = null;
|
|
ResultSet chargeIdRs = null;
|
|
@@ -284,6 +286,31 @@ public class WsProcessUtils extends DbProcessorAbstract {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Do not call ADD_TURN here because that procedure commits internally.
|
|
|
|
|
+ // Keep the turn credit in the same durable transaction as renew/inbox so
|
|
|
|
|
+ // a rollback or replay can never credit the subscriber twice.
|
|
|
|
|
+ updateTurn = connection.prepareStatement("UPDATE LUCKY_SPIN SET "
|
|
|
|
|
+ + "ADDED=NVL(ADDED, 0)+?, LAST_UPDATE=SYSDATE "
|
|
|
|
|
+ + "WHERE ID=(SELECT ID FROM LUCKY_SPIN WHERE MSISDN=? AND ROWNUM=1)");
|
|
|
|
|
+ setQueryTimeout(updateTurn);
|
|
|
|
|
+ updateTurn.setInt(1, event.getProductNumberSpin());
|
|
|
|
|
+ updateTurn.setString(2, event.getMsisdn());
|
|
|
|
|
+ int updatedTurnRows = updateTurn.executeUpdate();
|
|
|
|
|
+ if (updatedTurnRows == 0) {
|
|
|
|
|
+ insertTurn = connection.prepareStatement("INSERT INTO LUCKY_SPIN "
|
|
|
|
|
+ + "(ID, MSISDN, ADDED, USED, INSERT_TIME, EXPIRE_TIME, LAST_UPDATE, CHANNEL_ADD) "
|
|
|
|
|
+ + "VALUES (LUCKY_SPIN_SEQ.NEXTVAL, ?, ?, 0, SYSDATE, SYSDATE+7, SYSDATE, 1)");
|
|
|
|
|
+ setQueryTimeout(insertTurn);
|
|
|
|
|
+ insertTurn.setString(1, event.getMsisdn());
|
|
|
|
|
+ insertTurn.setInt(2, event.getProductNumberSpin());
|
|
|
|
|
+ if (insertTurn.executeUpdate() != 1) {
|
|
|
|
|
+ throw new SQLException("LUCKY_SPIN insert affected unexpected row count");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (updatedTurnRows != 1) {
|
|
|
|
|
+ throw new SQLException("LUCKY_SPIN update affected unexpected row count: "
|
|
|
|
|
+ + updatedTurnRows);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
updateInbox = connection.prepareStatement("UPDATE RESULT_REQUEST_INBOX SET "
|
|
updateInbox = connection.prepareStatement("UPDATE RESULT_REQUEST_INBOX SET "
|
|
|
+ "STATUS='PROCESSED', CHARGE_LOG_ID=?, PROCESSED_TIME=SYSTIMESTAMP, "
|
|
+ "STATUS='PROCESSED', CHARGE_LOG_ID=?, PROCESSED_TIME=SYSTIMESTAMP, "
|
|
|
+ "UPDATED_TIME=SYSTIMESTAMP WHERE EVENT_ID=?");
|
|
+ "UPDATED_TIME=SYSTIMESTAMP WHERE EVENT_ID=?");
|
|
@@ -297,6 +324,8 @@ public class WsProcessUtils extends DbProcessorAbstract {
|
|
|
throw new SQLException("RESULT_REQUEST_INBOX final update affected unexpected row count");
|
|
throw new SQLException("RESULT_REQUEST_INBOX final update affected unexpected row count");
|
|
|
}
|
|
}
|
|
|
connection.commit();
|
|
connection.commit();
|
|
|
|
|
+ logger.info("add turn success Renew " + event.getMsisdn()
|
|
|
|
|
+ + ", turn " + event.getProductNumberSpin());
|
|
|
return 0;
|
|
return 0;
|
|
|
} catch (SQLException ex) {
|
|
} catch (SQLException ex) {
|
|
|
if (connection != null) {
|
|
if (connection != null) {
|
|
@@ -312,6 +341,8 @@ public class WsProcessUtils extends DbProcessorAbstract {
|
|
|
closeResultSet(registerRs);
|
|
closeResultSet(registerRs);
|
|
|
closeResultSet(duplicateRs);
|
|
closeResultSet(duplicateRs);
|
|
|
closeStatement(updateInbox);
|
|
closeStatement(updateInbox);
|
|
|
|
|
+ closeStatement(insertTurn);
|
|
|
|
|
+ closeStatement(updateTurn);
|
|
|
closeStatement(insertCharge);
|
|
closeStatement(insertCharge);
|
|
|
closeStatement(selectChargeId);
|
|
closeStatement(selectChargeId);
|
|
|
closeStatement(updateRegister);
|
|
closeStatement(updateRegister);
|