Phricker » 25 фев 2019, 17:41
$this->bbcode_second_pass_quote('Dog', '')ак добавить в ЛК вывод необходимой суммы для открытия договора:
$this->bbcode_second_pass_code('', 'Модуль 2. Модуль абонентских плат => Запрос доп. расхода для открытия договора')
ОтсюдаваСо стороны биллинга рисуем интерфейс
$this->bbcode_second_pass_code('', '
import ru.bitel.bgbilling.common.BGMessageException;
import javax.jws.WebService;
import java.math.BigDecimal;
@WebService
public interface MyBGBillingService {
BigDecimal getNpayDebetUnlockSumm(int contractId) throws BGMessageException;
}
')
и сервис
$this->bbcode_second_pass_code('', 'import bitel.billing.server.admin.errorlog.AlarmSender;
import bitel.billing.server.admin.errorlog.bean.AlarmErrorMessage;
import bitel.billing.server.contract.bean.ContractManager;
import org.apache.log4j.Logger;
import ru.bitel.bgbilling.common.BGException;
import ru.bitel.bgbilling.common.BGMessageException;
import ru.bitel.bgbilling.kernel.container.service.server.AbstractService;
import ru.bitel.bgbilling.modules.npay.server.bean.DebetStatusManageConfig;
import ru.bitel.bgbilling.server.util.ModuleSetup;
import ru.bitel.bgbilling.server.util.ServerUtils;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.jws.WebService;
import java.math.BigDecimal;
import java.sql.Connection;
@WebService(
endpointInterface = "ru.xxx.MyBGBillingService"
)
public class MyBGBillingServiceImpl
extends AbstractService implements MyBGBillingService {
private final static Logger logger = Logger.getLogger(MyBGBillingServiceImpl.class);
private final static int NPAY_MID = 3;
private Connection con;
public MyBGBillingServiceImpl() {
}
@PostConstruct
protected void init() {
this.con = this.getConnection();
}
@PreDestroy
private void destroy() {
if (con != null) {
ServerUtils.commitConnection(this.con);
ServerUtils.closeConnection(this.con);
}
}
@Override
public BigDecimal getNpayDebetUnlockSumm(int contractId) throws BGMessageException {
BigDecimal result = null;
try (ContractManager contractManager = new ContractManager(this.con)) {
ModuleSetup moduleSetup = new ModuleSetup(this.con, NPAY_MID);
DebetStatusManageConfig debetStatusManageConfig = new DebetStatusManageConfig(moduleSetup);
result = debetStatusManageConfig.getSummaForUnlock(this.con, NPAY_MID, contractManager.getContractById(contractId));
} catch (BGException e) {
AlarmSender.sendAlarm(new AlarmErrorMessage("mybgbilling.getNpayDebetUnlockSumm", "Ошибка при получении суммы разблокировки в скрипте " + MyBGBillingServiceImpl.class, "Что-то случилось в наших лесах. Ошибка на договоре с id=" + contractId + " при получении суммы разблокировки\n" + e), System.currentTimeMillis());
}
return result;
}
}
')
В последних версиях нового ЛК добавили возможность делать свои бины без компиляции.
Рисуем бин в директории
/standalone/deployments/MyBGBilling.war/WEB-INF/dyn$this->bbcode_second_pass_code('', 'import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.bitel.bgbilling.common.BGException;
import ru.bitel.mybgbilling.kernel.common.AbstractBean;
import ru.bitel.mybgbilling.kernel.common.inject.BGInject;
import ru.bitel.mybgbilling.kernel.common.inject.BGInjection;
import ru.ellco.bgbilling.kernel.scripts.mybgbilling.MyBGBillingService;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;
import java.io.Serializable;
import java.math.BigDecimal;
@Named
@ViewScoped
@BGInjection
public class MyNPayBean extends AbstractBean implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(MyNPayBean.class);
@BGInject
private MyBGBillingService myBGBillingService;
@Override
protected void init() throws BGException {
populate();
}
public void populate() throws BGException {
}
public BigDecimal getNpayDebetUnlockSumm() throws BGException {
return this.myBGBillingService.getNpayDebetUnlockSumm(this.getContractId());
}
}')
Копируем интерфейс в эту же папку (естественно соблюдая иерархию т.е. соответственно package делаем сабдиректории).
Т.е. будет как то так
$this->bbcode_second_pass_code('', '/standalone/deployments/MyBGBilling.war/WEB-INF/dyn/ru/xxx/MyBGBillingService.java
')
Описываем сервис в конфигурации сервера биллинга
$this->bbcode_second_pass_code('', '#Сервисы для ЛК
dynservice:ru.xxx.MyBGBillingService=ru.xxx.MyBGBillingServiceImpl')
В нужном месте страницы в ЛК вызываем
$this->bbcode_second_pass_code('', '<ui:fragment rendered="#{myNPayBean.getNpayDebetUnlockSumm() != null}">
<tr>
<td class="col-md-2">Сумма к пополнению:</td>
<td><h:outputText value="#{myNPayBean.getNpayDebetUnlockSumm()}">
<f:converter binding="#{currencyConverter}"/>
</h:outputText>
</td>
</tr>
</ui:fragment>')
Выглядит как-то так
P.S. Вроде ничего не забыл О_о