From 65195546935460c30a12e1219398d9d9e75229ee Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 14 Mar 2012 02:24:50 +0000 Subject: [PATCH] Working on merchant, finished. --- .../com/gempukku/lotro/db/DbMerchantDAO.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbMerchantDAO.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbMerchantDAO.java index 48da9fd4c..088b914fd 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbMerchantDAO.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbMerchantDAO.java @@ -33,7 +33,13 @@ public class DbMerchantDAO implements MerchantDAO { try { Connection connection = _dbAccess.getDataSource().getConnection(); try { - PreparedStatement statement = connection.prepareStatement("update merchant_data set transaction_price=?, transaction_date=?, transaction_type=? where blueprint_id=?"); + String sql; + if (transactionType == TransactionType.BUY) + sql = "update merchant_data set transaction_price=?, transaction_date=?, transaction_type=?, buy_count=buy_count+1 where blueprint_id=?"; + else + sql = "update merchant_data set transaction_price=?, transaction_date=?, transaction_type=?, sell_count=sell_count+1 where blueprint_id=?"; + + PreparedStatement statement = connection.prepareStatement(sql); try { statement.setFloat(1, price); statement.setTimestamp(2, new Timestamp(date.getTime())); @@ -55,7 +61,13 @@ public class DbMerchantDAO implements MerchantDAO { try { Connection connection = _dbAccess.getDataSource().getConnection(); try { - PreparedStatement statement = connection.prepareStatement("insert into merchant_data (transaction_price, transaction_date, transaction_type, blueprint_id) values (?,?,?,?)"); + String sql; + if (transactionType == TransactionType.BUY) + sql = "insert into merchant_data (transaction_price, transaction_date, transaction_type, blueprint_id, sell_count, buy_count) values (?,?,?,?,0,1)"; + else + sql = "insert into merchant_data (transaction_price, transaction_date, transaction_type, blueprint_id, sell_count, buy_count) values (?,?,?,?,1,0)"; + + PreparedStatement statement = connection.prepareStatement(sql); try { statement.setFloat(1, price); statement.setTimestamp(2, new Timestamp(date.getTime()));