This commit is contained in:
k.struzhkin 2020-04-17 13:28:50 +03:00
parent 1c1268ca7d
commit ae427dcce6
6 changed files with 13 additions and 8 deletions

View File

@ -94,7 +94,7 @@ public class ContractCreatedHandler extends AbstractClaimChangedHandler {
contract.setContractorId(contractorId);
contractDao.save(contract).ifPresentOrElse(
cntrctId -> updateContractReference(event, changeId, sequenceId, contractCreated, contractId, partyId, contractorId, cntrctId),
cntrctId -> updateContractReference(event, changeId, sequenceId, contractCreated, contractId, partyId, contractorId, cntrctId, claimEffectId),
() -> log.info("contract create duplicated, sequenceId={}, partyId={}, changeId={}", sequenceId, partyId, changeId)
);
}
@ -110,9 +110,10 @@ public class ContractCreatedHandler extends AbstractClaimChangedHandler {
}
private void updateContractReference(MachineEvent event, Integer changeId, long sequenceId, com.rbkmoney.damsel.domain.Contract contractCreated,
String contractId, String partyId, String contractorId, Long cntrctId) {
String contractId, String partyId, String contractorId, Long cntrctId, Integer claimEffectId) {
if (contractCreated.isSetContractor()) {
Contractor contractor = ContractorUtil.convertContractor(sequenceId, event.getCreatedAt(), partyId, contractCreated.getContractor(), contractorId, changeId);
Contractor contractor = ContractorUtil.convertContractor(sequenceId, event.getCreatedAt(),
partyId, contractCreated.getContractor(), contractorId, changeId, claimEffectId);
contractorDao.save(contractor);
}

View File

@ -53,9 +53,9 @@ public class ContractorCreatedHandler extends AbstractClaimChangedHandler {
log.info("Start contractor created handling, eventId={}, partyId={}, contractorId={}", eventId, partyId, contractorId);
partyDao.get(partyId); //check party is exist
Contractor contractor = ContractorUtil.convertContractor(eventId, event.getCreatedAt(), partyId, contractorCreated, contractorId, changeId);
Contractor contractor = ContractorUtil.convertContractor(eventId, event.getCreatedAt(), partyId, contractorCreated,
contractorId, changeId, claimEffectId);
contractor.setIdentificationalLevel(partyContractor.getStatus().name());
contractor.setClaimEffectId(claimEffectId);
contractorDao.save(contractor).ifPresentOrElse(
cntrctId -> log.info("Contract contractor has been saved, eventId={}, partyId={}, contractorId={}", eventId, partyId, contractorId),
() -> log.info("contract contractor duplicated, sequenceId={}, partyId={}, changeId={}", sequenceId, partyId, changeId)

View File

@ -131,7 +131,7 @@ public class PartyRevisionChangedHandler extends AbstractPartyManagementHandler
contractIds.add(contractSourceId);
Long contractId = ids.get(i);
long sequenceId = event.getEventId();
ContractUtil.resetBaseFields(event, changeId, sequenceId, contractSource, contractSource.getClaimEffectId());
ContractUtil.resetBaseFields(event, changeId, sequenceId, contractSource, -1);
contractSource.setId(contractId);
contractSource.setRevision(revision);

View File

@ -13,11 +13,13 @@ import com.rbkmoney.newway.domain.tables.pojos.Contractor;
public class ContractorUtil {
public static Contractor convertContractor(long sequenceId, String eventCreatedAt, String partyId,
com.rbkmoney.damsel.domain.Contractor contractorSource, String contractorId, Integer changeId) {
com.rbkmoney.damsel.domain.Contractor contractorSource,
String contractorId, Integer changeId, Integer claimEffectId) {
Contractor contractor = new Contractor();
contractor.setRevision(-1L);
contractor.setSequenceId((int) sequenceId);
contractor.setChangeId(changeId);
contractor.setClaimEffectId(claimEffectId);
contractor.setEventCreatedAt(TypeUtil.stringToLocalDateTime(eventCreatedAt));
contractor.setPartyId(partyId);
contractor.setContractorId(contractorId);

View File

@ -16,7 +16,7 @@ public class ShopUtil {
public static void resetBaseFields(MachineEvent event, Integer changeId, long sequenceId, Shop shopSource, Integer claimEffectId) {
shopSource.setId(null);
shopSource.setRevision(null);
shopSource.setRevision(-1L);
shopSource.setWtime(null);
shopSource.setSequenceId((int) sequenceId);
shopSource.setChangeId(changeId);

View File

@ -0,0 +1,2 @@
alter table nw.contract_adjustment drop constraint if exists fk_adjustment_to_contract;
alter table nw.payout_tool drop constraint if exists fk_payout_tool_to_contract;