mirror of
https://github.com/valitydev/dominator.git
synced 2024-11-06 01:45:16 +00:00
IMP-261: bump damsel (remove payout blocks) (#23)
This commit is contained in:
parent
c19a0d14d7
commit
ec5a5e08dd
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -7,4 +7,4 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v2
|
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v3
|
||||||
|
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@ -9,7 +9,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
uses: valitydev/java-workflow/.github/workflows/maven-service-deploy.yml@v2
|
uses: valitydev/java-workflow/.github/workflows/maven-service-deploy.yml@v3
|
||||||
secrets:
|
secrets:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
|
mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
|
||||||
|
22
pom.xml
22
pom.xml
@ -6,7 +6,8 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>service-parent-pom</artifactId>
|
<artifactId>service-parent-pom</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.2</version>
|
||||||
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>dominator</artifactId>
|
<artifactId>dominator</artifactId>
|
||||||
@ -92,6 +93,10 @@
|
|||||||
<groupId>org.flywaydb</groupId>
|
<groupId>org.flywaydb</groupId>
|
||||||
<artifactId>flyway-core</artifactId>
|
<artifactId>flyway-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-database-postgresql</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jooq</groupId>
|
<groupId>org.jooq</groupId>
|
||||||
<artifactId>jooq</artifactId>
|
<artifactId>jooq</artifactId>
|
||||||
@ -157,11 +162,6 @@
|
|||||||
<artifactId>dominator-proto</artifactId>
|
<artifactId>dominator-proto</artifactId>
|
||||||
<version>1.7-41bee97</version>
|
<version>1.7-41bee97</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>dev.vality</groupId>
|
|
||||||
<artifactId>payout-manager-proto</artifactId>
|
|
||||||
<version>1.36-063163d</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>kafka-common-lib</artifactId>
|
<artifactId>kafka-common-lib</artifactId>
|
||||||
@ -184,7 +184,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>damsel</artifactId>
|
<artifactId>damsel</artifactId>
|
||||||
<version>1.636-b869c09</version>
|
<version>1.641-6051aa9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
@ -214,10 +214,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality.geck</groupId>
|
<groupId>dev.vality.geck</groupId>
|
||||||
<artifactId>serializer</artifactId>
|
<artifactId>serializer</artifactId>
|
||||||
|
<version>1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality.geck</groupId>
|
<groupId>dev.vality.geck</groupId>
|
||||||
<artifactId>filter</artifactId>
|
<artifactId>filter</artifactId>
|
||||||
|
<version>1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
@ -270,7 +272,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>dev.vality.maven.plugins</groupId>
|
<groupId>dev.vality.maven.plugins</groupId>
|
||||||
<artifactId>pg-embedded-plugin</artifactId>
|
<artifactId>pg-embedded-plugin</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>2.0.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<port>${local.pg.port}</port>
|
<port>${local.pg.port}</port>
|
||||||
<dbName>${db.name}</dbName>
|
<dbName>${db.name}</dbName>
|
||||||
@ -319,7 +321,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>42.3.9</version>
|
<version>42.7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -344,7 +346,7 @@
|
|||||||
<name>org.jooq.meta.postgres.PostgresDatabase</name>
|
<name>org.jooq.meta.postgres.PostgresDatabase</name>
|
||||||
<includes>.*</includes>
|
<includes>.*</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
schema_version|.*func|get_adjustment.*|get_cashflow.*|get_payment.*|get_payout.*|get_refund.*
|
schema_version|.*func|get_adjustment.*|get_cashflow.*|get_payment.*|get_refund.*
|
||||||
</excludes>
|
</excludes>
|
||||||
<inputSchema>${db.schema}</inputSchema>
|
<inputSchema>${db.schema}</inputSchema>
|
||||||
</database>
|
</database>
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
package com.empayre.dominator.handler.event.stock.impl.partymngmnt.contract;
|
|
||||||
|
|
||||||
import com.empayre.dominator.service.ContractReferenceService;
|
|
||||||
import dev.vality.damsel.domain.PayoutTool;
|
|
||||||
import dev.vality.damsel.payment_processing.ClaimEffect;
|
|
||||||
import dev.vality.damsel.payment_processing.ContractEffectUnit;
|
|
||||||
import dev.vality.damsel.payment_processing.PartyChange;
|
|
||||||
import com.empayre.dominator.dao.party.iface.ContractDao;
|
|
||||||
import com.empayre.dominator.dao.party.iface.PayoutToolDao;
|
|
||||||
import com.empayre.dominator.domain.tables.pojos.Contract;
|
|
||||||
import com.empayre.dominator.factory.claim.effect.ClaimEffectCopyFactory;
|
|
||||||
import com.empayre.dominator.handler.event.stock.impl.partymngmnt.AbstractClaimChangedHandler;
|
|
||||||
import com.empayre.dominator.util.ContractUtil;
|
|
||||||
import dev.vality.machinegun.eventsink.MachineEvent;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ContractPayoutToolCreatedHandler extends AbstractClaimChangedHandler {
|
|
||||||
|
|
||||||
private final ContractDao contractDao;
|
|
||||||
private final PayoutToolDao payoutToolDao;
|
|
||||||
private final ContractReferenceService contractReferenceService;
|
|
||||||
private final ClaimEffectCopyFactory<Contract, Integer> claimEffectCopyFactory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
|
||||||
public void handle(PartyChange change, MachineEvent event, Integer changeId) {
|
|
||||||
long sequenceId = event.getEventId();
|
|
||||||
List<ClaimEffect> claimEffects = getClaimStatus(change).getAccepted().getEffects();
|
|
||||||
for (int i = 0; i < claimEffects.size(); i++) {
|
|
||||||
ClaimEffect claimEffect = claimEffects.get(i);
|
|
||||||
if (claimEffect.isSetContractEffect()
|
|
||||||
&& claimEffect.getContractEffect().getEffect().isSetPayoutToolCreated()) {
|
|
||||||
handleEvent(event, changeId, sequenceId, claimEffects.get(i), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleEvent(MachineEvent event, Integer changeId, long sequenceId, ClaimEffect claimEffect,
|
|
||||||
Integer claimEffectId) {
|
|
||||||
ContractEffectUnit contractEffectUnit = claimEffect.getContractEffect();
|
|
||||||
PayoutTool payoutToolCreated = contractEffectUnit.getEffect().getPayoutToolCreated();
|
|
||||||
String contractId = contractEffectUnit.getContractId();
|
|
||||||
String partyId = event.getSourceId();
|
|
||||||
log.info("Start contract payout tool created handling, sequenceId={}, partyId={}, contractId={}, changeId={}",
|
|
||||||
sequenceId, partyId, contractId, changeId);
|
|
||||||
Contract contractSourceOld = contractDao.get(partyId, contractId);
|
|
||||||
Contract contractNew =
|
|
||||||
claimEffectCopyFactory.create(event, sequenceId, claimEffectId, changeId, contractSourceOld);
|
|
||||||
|
|
||||||
contractDao.save(contractNew).ifPresentOrElse(
|
|
||||||
dbContractId -> {
|
|
||||||
Long oldId = contractSourceOld.getId();
|
|
||||||
contractDao.updateNotCurrent(oldId);
|
|
||||||
contractReferenceService.updateContractReference(oldId, dbContractId);
|
|
||||||
payoutToolDao.save(List.of(ContractUtil.convertPayoutTool(payoutToolCreated, dbContractId)));
|
|
||||||
log.info("Contract contract payout tool created has been saved, " +
|
|
||||||
"sequenceId={}, partyId={}, contractId={}, changeId={}",
|
|
||||||
sequenceId, partyId, contractId, changeId);
|
|
||||||
},
|
|
||||||
() -> log.info("Contract contract payout tool created duplicated, " +
|
|
||||||
"sequenceId={}, partyId={}, contractId={}, changeId={}",
|
|
||||||
sequenceId, partyId, contractId, changeId)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
package com.empayre.dominator.handler.event.stock.impl.partymngmnt.contract;
|
|
||||||
|
|
||||||
import com.empayre.dominator.service.ContractReferenceService;
|
|
||||||
import dev.vality.damsel.payment_processing.ClaimEffect;
|
|
||||||
import dev.vality.damsel.payment_processing.ContractEffectUnit;
|
|
||||||
import dev.vality.damsel.payment_processing.PartyChange;
|
|
||||||
import dev.vality.damsel.payment_processing.PayoutToolInfoChanged;
|
|
||||||
import com.empayre.dominator.dao.party.iface.ContractDao;
|
|
||||||
import com.empayre.dominator.dao.party.iface.PayoutToolDao;
|
|
||||||
import com.empayre.dominator.domain.tables.pojos.Contract;
|
|
||||||
import com.empayre.dominator.domain.tables.pojos.PayoutTool;
|
|
||||||
import com.empayre.dominator.factory.claim.effect.ClaimEffectCopyFactory;
|
|
||||||
import com.empayre.dominator.handler.event.stock.impl.partymngmnt.AbstractClaimChangedHandler;
|
|
||||||
import com.empayre.dominator.util.ContractUtil;
|
|
||||||
import dev.vality.machinegun.eventsink.MachineEvent;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ContractPayoutToolInfoChangedHandler extends AbstractClaimChangedHandler {
|
|
||||||
|
|
||||||
private final ContractDao contractDao;
|
|
||||||
private final PayoutToolDao payoutToolDao;
|
|
||||||
private final ContractReferenceService contractReferenceService;
|
|
||||||
private final ClaimEffectCopyFactory<Contract, Integer> claimEffectCopyFactory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
|
||||||
public void handle(PartyChange change, MachineEvent event, Integer changeId) {
|
|
||||||
long sequenceId = event.getEventId();
|
|
||||||
List<ClaimEffect> claimEffects = getClaimStatus(change).getAccepted().getEffects();
|
|
||||||
for (int i = 0; i < claimEffects.size(); i++) {
|
|
||||||
ClaimEffect claimEffect = claimEffects.get(i);
|
|
||||||
if (claimEffect.isSetContractEffect()
|
|
||||||
&& claimEffect.getContractEffect().getEffect().isSetPayoutToolInfoChanged()) {
|
|
||||||
handleEvent(event, changeId, sequenceId, claimEffects.get(i), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleEvent(MachineEvent event, Integer changeId, long sequenceId, ClaimEffect claimEffect,
|
|
||||||
Integer claimEffectId) {
|
|
||||||
ContractEffectUnit contractEffectUnit = claimEffect.getContractEffect();
|
|
||||||
String contractId = contractEffectUnit.getContractId();
|
|
||||||
String partyId = event.getSourceId();
|
|
||||||
log.info("Start contract payout tool info changed handling, " +
|
|
||||||
"sequenceId={}, partyId={}, contractId={}, changeId={}",
|
|
||||||
sequenceId, partyId, contractId, changeId);
|
|
||||||
Contract contractSourceOld = contractDao.get(partyId, contractId);
|
|
||||||
Contract contractNew =
|
|
||||||
claimEffectCopyFactory.create(event, sequenceId, claimEffectId, changeId, contractSourceOld);
|
|
||||||
|
|
||||||
contractDao.save(contractNew).ifPresentOrElse(
|
|
||||||
dbContractId -> {
|
|
||||||
Long oldId = contractSourceOld.getId();
|
|
||||||
contractDao.updateNotCurrent(oldId);
|
|
||||||
contractReferenceService.updateAdjustments(oldId, dbContractId);
|
|
||||||
updatePayoutTools(contractEffectUnit, oldId, dbContractId);
|
|
||||||
log.info("Contract payout tool info changed has been saved, " +
|
|
||||||
"sequenceId={}, partyId={}, contractId={}, changeId={}",
|
|
||||||
sequenceId, partyId, contractId, changeId);
|
|
||||||
},
|
|
||||||
() -> log.info("Contract payout tool info changed duplicated, " +
|
|
||||||
"sequenceId={}, partyId={}, contractId={}, changeId={}",
|
|
||||||
sequenceId, partyId, contractId, changeId)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePayoutTools(ContractEffectUnit contractEffectUnit, Long oldId, Long dbContractId) {
|
|
||||||
List<PayoutTool> currentPayoutTools = payoutToolDao.getByContractId(oldId);
|
|
||||||
currentPayoutTools.forEach(payoutTool -> {
|
|
||||||
payoutTool.setId(null);
|
|
||||||
payoutTool.setContractId(dbContractId);
|
|
||||||
});
|
|
||||||
PayoutToolInfoChanged payoutToolInfoChanged =
|
|
||||||
contractEffectUnit.getEffect().getPayoutToolInfoChanged();
|
|
||||||
Optional<PayoutTool> payoutToolForChangeOptional = currentPayoutTools.stream()
|
|
||||||
.filter(payoutTool -> payoutTool.getPayoutToolId().equals(payoutToolInfoChanged.getPayoutToolId()))
|
|
||||||
.findAny();
|
|
||||||
List<PayoutTool> modifiedPayoutTools;
|
|
||||||
if (payoutToolForChangeOptional.isPresent()) {
|
|
||||||
PayoutTool payoutToolForChange = payoutToolForChangeOptional.get();
|
|
||||||
PayoutTool newPayoutTool = ContractUtil.buildPayoutTool(dbContractId,
|
|
||||||
payoutToolInfoChanged.getPayoutToolId(),
|
|
||||||
payoutToolForChange.getCreatedAt(),
|
|
||||||
payoutToolForChange.getCurrencyCode(),
|
|
||||||
payoutToolInfoChanged.getInfo()
|
|
||||||
);
|
|
||||||
modifiedPayoutTools = Stream.concat(
|
|
||||||
Stream.of(newPayoutTool),
|
|
||||||
currentPayoutTools.stream()
|
|
||||||
.filter(p -> !p.getPayoutToolId().equals(payoutToolInfoChanged.getPayoutToolId()))
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
} else {
|
|
||||||
modifiedPayoutTools = currentPayoutTools;
|
|
||||||
}
|
|
||||||
payoutToolDao.save(modifiedPayoutTools);
|
|
||||||
}
|
|
||||||
}
|
|
@ -52,7 +52,6 @@ public class ShopContractChangedHandler extends AbstractClaimChangedHandler {
|
|||||||
Shop shopNew = claimEffectCopyFactory.create(event, sequenceId, claimEffectId, changeId, shopOld);
|
Shop shopNew = claimEffectCopyFactory.create(event, sequenceId, claimEffectId, changeId, shopOld);
|
||||||
|
|
||||||
shopNew.setContractId(contractChanged.getContractId());
|
shopNew.setContractId(contractChanged.getContractId());
|
||||||
shopNew.setPayoutToolId(contractChanged.getPayoutToolId());
|
|
||||||
|
|
||||||
shopDao.saveWithUpdateCurrent(shopNew, shopOld.getId(), "contractChanged");
|
shopDao.saveWithUpdateCurrent(shopNew, shopOld.getId(), "contractChanged");
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,6 @@ public class ShopCreatedHandler extends AbstractClaimChangedHandler {
|
|||||||
ShopUtil.fillShopAccount(shop, shopCreated.getAccount());
|
ShopUtil.fillShopAccount(shop, shopCreated.getAccount());
|
||||||
}
|
}
|
||||||
shop.setContractId(shopCreated.getContractId());
|
shop.setContractId(shopCreated.getContractId());
|
||||||
shop.setPayoutToolId(shopCreated.getPayoutToolId());
|
|
||||||
if (shopCreated.isSetPayoutSchedule()) {
|
|
||||||
shop.setPayoutScheduleId(shopCreated.getPayoutSchedule().getId());
|
|
||||||
}
|
|
||||||
return shop;
|
return shop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
package com.empayre.dominator.handler.event.stock.impl.partymngmnt.shop;
|
|
||||||
|
|
||||||
import dev.vality.damsel.payment_processing.ClaimEffect;
|
|
||||||
import dev.vality.damsel.payment_processing.PartyChange;
|
|
||||||
import dev.vality.damsel.payment_processing.ScheduleChanged;
|
|
||||||
import dev.vality.damsel.payment_processing.ShopEffectUnit;
|
|
||||||
import com.empayre.dominator.dao.party.iface.ShopDao;
|
|
||||||
import com.empayre.dominator.domain.tables.pojos.Shop;
|
|
||||||
import com.empayre.dominator.factory.claim.effect.ClaimEffectCopyFactory;
|
|
||||||
import com.empayre.dominator.handler.event.stock.impl.partymngmnt.AbstractClaimChangedHandler;
|
|
||||||
import dev.vality.machinegun.eventsink.MachineEvent;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ShopPayoutScheduleChangedHandler extends AbstractClaimChangedHandler {
|
|
||||||
|
|
||||||
private final ShopDao shopDao;
|
|
||||||
private final ClaimEffectCopyFactory<Shop, Integer> claimEffectCopyFactory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
|
||||||
public void handle(PartyChange change, MachineEvent event, Integer changeId) {
|
|
||||||
long sequenceId = event.getEventId();
|
|
||||||
List<ClaimEffect> claimEffects = getClaimStatus(change).getAccepted().getEffects();
|
|
||||||
for (int i = 0; i < claimEffects.size(); i++) {
|
|
||||||
ClaimEffect claimEffect = claimEffects.get(i);
|
|
||||||
if (claimEffect.isSetShopEffect() && claimEffect.getShopEffect().getEffect().isSetPayoutScheduleChanged()) {
|
|
||||||
handleEvent(event, changeId, sequenceId, claimEffects.get(i), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleEvent(MachineEvent event, Integer changeId, long sequenceId, ClaimEffect e,
|
|
||||||
Integer claimEffectId) {
|
|
||||||
ShopEffectUnit shopEffect = e.getShopEffect();
|
|
||||||
ScheduleChanged payoutScheduleChanged = shopEffect.getEffect().getPayoutScheduleChanged();
|
|
||||||
String shopId = shopEffect.getShopId();
|
|
||||||
String partyId = event.getSourceId();
|
|
||||||
log.info("Start shop payoutScheduleChanged handling, sequenceId={}, partyId={}, shopId={}, changeId={}",
|
|
||||||
sequenceId, partyId, shopId, changeId);
|
|
||||||
|
|
||||||
final Shop shopOld = shopDao.get(partyId, shopId);
|
|
||||||
Shop shopNew = claimEffectCopyFactory.create(event, sequenceId, claimEffectId, changeId, shopOld);
|
|
||||||
|
|
||||||
if (payoutScheduleChanged.isSetSchedule()) {
|
|
||||||
shopNew.setPayoutScheduleId(payoutScheduleChanged.getSchedule().getId());
|
|
||||||
} else {
|
|
||||||
shopNew.setPayoutScheduleId(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
shopDao.saveWithUpdateCurrent(shopNew, shopOld.getId(), "payoutScheduleChanged");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package com.empayre.dominator.handler.event.stock.impl.partymngmnt.shop;
|
|
||||||
|
|
||||||
import com.empayre.dominator.handler.event.stock.impl.partymngmnt.AbstractClaimChangedHandler;
|
|
||||||
import dev.vality.damsel.payment_processing.ClaimEffect;
|
|
||||||
import dev.vality.damsel.payment_processing.PartyChange;
|
|
||||||
import dev.vality.damsel.payment_processing.ShopEffectUnit;
|
|
||||||
import com.empayre.dominator.dao.party.iface.ShopDao;
|
|
||||||
import com.empayre.dominator.domain.tables.pojos.Shop;
|
|
||||||
import com.empayre.dominator.factory.claim.effect.ClaimEffectCopyFactory;
|
|
||||||
import dev.vality.machinegun.eventsink.MachineEvent;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ShopPayoutToolChangedHandler extends AbstractClaimChangedHandler {
|
|
||||||
|
|
||||||
private final ShopDao shopDao;
|
|
||||||
private final ClaimEffectCopyFactory<Shop, Integer> claimEffectCopyFactory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED)
|
|
||||||
public void handle(PartyChange change, MachineEvent event, Integer changeId) {
|
|
||||||
long sequenceId = event.getEventId();
|
|
||||||
List<ClaimEffect> claimEffects = getClaimStatus(change).getAccepted().getEffects();
|
|
||||||
for (int i = 0; i < claimEffects.size(); i++) {
|
|
||||||
ClaimEffect claimEffect = claimEffects.get(i);
|
|
||||||
if (claimEffect.isSetShopEffect() && claimEffect.getShopEffect().getEffect().isSetPayoutToolChanged()) {
|
|
||||||
handleEvent(event, changeId, sequenceId, claimEffects.get(i), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleEvent(MachineEvent event, Integer changeId, long sequenceId, ClaimEffect e,
|
|
||||||
Integer claimEffectId) {
|
|
||||||
ShopEffectUnit shopEffect = e.getShopEffect();
|
|
||||||
String payoutToolChanged = shopEffect.getEffect().getPayoutToolChanged();
|
|
||||||
String shopId = shopEffect.getShopId();
|
|
||||||
String partyId = event.getSourceId();
|
|
||||||
log.info("Start shop payoutToolChanged handling, sequenceId={}, partyId={}, shopId={}, changeId={}",
|
|
||||||
sequenceId, partyId, shopId, changeId);
|
|
||||||
|
|
||||||
final Shop shopOld = shopDao.get(partyId, shopId);
|
|
||||||
Shop shopNew = claimEffectCopyFactory.create(event, sequenceId, claimEffectId, changeId, shopOld);
|
|
||||||
|
|
||||||
shopNew.setPayoutToolId(payoutToolChanged);
|
|
||||||
|
|
||||||
shopDao.saveWithUpdateCurrent(shopNew, shopOld.getId(), "payoutToolChanged");
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,9 +14,12 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class JsonUtil {
|
public class JsonUtil {
|
||||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
public static String thriftBaseToJsonString(TBase thriftBase) {
|
public static String thriftBaseToJsonString(TBase thriftBase) {
|
||||||
|
if (thriftBase == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return new TBaseProcessor().process(thriftBase, new JsonHandler()).toString();
|
return new TBaseProcessor().process(thriftBase, new JsonHandler()).toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -25,6 +28,9 @@ public class JsonUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JsonNode thriftBaseToJsonNode(TBase thriftBase) {
|
public static JsonNode thriftBaseToJsonNode(TBase thriftBase) {
|
||||||
|
if (thriftBase == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return new TBaseProcessor().process(thriftBase, new JsonHandler());
|
return new TBaseProcessor().process(thriftBase, new JsonHandler());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -33,16 +39,22 @@ public class JsonUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String objectToJsonString(Object o) {
|
public static String objectToJsonString(Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return objectMapper.writeValueAsString(o);
|
return OBJECT_MAPPER.writeValueAsString(o);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new RuntimeException("Couldn't convert object to json string: " + o, e);
|
throw new RuntimeException("Couldn't convert object to json string: " + o, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T stringToObject(byte[] stringObject, Class<T> type) {
|
public static <T> T stringToObject(byte[] stringObject, Class<T> type) {
|
||||||
|
if (stringObject == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return objectMapper.readValue(stringObject, type);
|
return OBJECT_MAPPER.readValue(stringObject, type);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Couldn't convert json string to object: ", e);
|
throw new IllegalStateException("Couldn't convert json string to object: ", e);
|
||||||
}
|
}
|
||||||
@ -59,7 +71,7 @@ public class JsonUtil {
|
|||||||
if (Objects.isNull(object)) {
|
if (Objects.isNull(object)) {
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
return objectMapper.writeValueAsBytes(object);
|
return OBJECT_MAPPER.writeValueAsBytes(object);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Couldn't convert object to byte array: ", e);
|
throw new IllegalStateException("Couldn't convert object to byte array: ", e);
|
||||||
}
|
}
|
||||||
|
@ -188,10 +188,6 @@ public class TestDataGenerator {
|
|||||||
.setWithdrawals(
|
.setWithdrawals(
|
||||||
new WithdrawalProvisionTerms()
|
new WithdrawalProvisionTerms()
|
||||||
.setCurrencies(CurrencySelector.value(Set.of(new CurrencyRef().setSymbolicCode("RUB"))))
|
.setCurrencies(CurrencySelector.value(Set.of(new CurrencyRef().setSymbolicCode("RUB"))))
|
||||||
.setPayoutMethods(PayoutMethodSelector.value(Set.of(
|
|
||||||
new PayoutMethodRef()
|
|
||||||
.setId(PayoutMethod.wallet_info)
|
|
||||||
)))
|
|
||||||
.setCashFlow(CashFlowSelector.value(createCashFlowPostings()))
|
.setCashFlow(CashFlowSelector.value(createCashFlowPostings()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user