Skip to content

Instantly share code, notes, and snippets.

@SinTeZWh1te
Created May 2, 2024 19:03
Show Gist options
  • Save SinTeZWh1te/1770058de71fc0cdb3314f7b88f51077 to your computer and use it in GitHub Desktop.
Save SinTeZWh1te/1770058de71fc0cdb3314f7b88f51077 to your computer and use it in GitHub Desktop.
package ru.test.bgbilling.kernel.scripts.global.test;
import ru.bitel.bgbilling.kernel.container.managed.ServerContext;
import ru.bitel.bgbilling.kernel.contract.balance.common.PaymentService;
import ru.bitel.bgbilling.kernel.contract.balance.common.bean.Payment;
import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase;
import ru.bitel.bgbilling.server.util.Setup;
import ru.bitel.common.sql.ConnectionSet;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/**
* @author sintezwh1te
*/
public class FixBalance
extends GlobalScriptBase {
@Override
public void execute(Setup setup, ConnectionSet connectionSet)
throws Exception {
Connection con = connectionSet.getConnection();
ServerContext serverContext = ServerContext.get();
PaymentService paymentService = serverContext.getService(PaymentService.class, 0);
Date date = new GregorianCalendar(2024, Calendar.APRIL, 30).getTime();
String query = "SELECT id FROM contract";
try (PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
Payment payment = new Payment();
payment.setContractId(rs.getInt("id"));
payment.setSum(BigDecimal.ZERO);
payment.setDate(date);
payment.setTypeId(1); //Тип платежа
payment.setComment("#fix");
paymentService.paymentUpdate(payment, "");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment