diff --git a/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSCallback.java b/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSCallback.java index b77f4ef..08a1b88 100644 --- a/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSCallback.java +++ b/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSCallback.java @@ -48,6 +48,7 @@ @BsonDiscriminator @MongoEntity(collection = "rewards_leak") public class DVSCallback extends AbsMongoItem { + @BsonProperty(value = "transactionId") private Long dtOneId; @@ -92,4 +93,5 @@ public class DVSCallback extends AbsMongoItem { private List benefits; private String loadProvider; + } diff --git a/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSResp.java b/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSResp.java index 08b54b7..973cf30 100644 --- a/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSResp.java +++ b/core/src/main/java/com/abavilla/fpi/load/entity/dtone/DVSResp.java @@ -30,6 +30,7 @@ import com.dtone.dvs.dto.Product; import com.dtone.dvs.dto.Promotion; import com.dtone.dvs.dto.Rates; +import com.dtone.dvs.dto.StatementIdentifier; import com.dtone.dvs.dto.Status; import com.dtone.dvs.dto.Values; import io.quarkus.runtime.annotations.RegisterForReflection; @@ -44,24 +45,49 @@ @NoArgsConstructor @BsonDiscriminator public class DVSResp extends AbsMongoField { + private Long dtOneId; + private String externalId; + private LocalDateTime creationDate; + private LocalDateTime confirmationExpirationDate; + private LocalDateTime confirmationDate; + private Status status; + private String operatorReference; + private Pin pin; + private Product product; + private Prices prices; + private Rates rates; - private List benefits; + private List promotions; + private Values requestedValues; + private Values adjustedValues; + private Party sender; + private Party beneficiary; + private PartyIdentifier debitPartyIdentifier; + private PartyIdentifier creditPartyIdentifier; + + private StatementIdentifier statementIdentifier; + + private String callbackUrl; + + private List benefits; + private String loadProvider; + } diff --git a/core/src/main/java/com/abavilla/fpi/load/mapper/load/dtone/DTOneMapper.java b/core/src/main/java/com/abavilla/fpi/load/mapper/load/dtone/DTOneMapper.java index 859e128..3cd6af4 100644 --- a/core/src/main/java/com/abavilla/fpi/load/mapper/load/dtone/DTOneMapper.java +++ b/core/src/main/java/com/abavilla/fpi/load/mapper/load/dtone/DTOneMapper.java @@ -23,6 +23,7 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import com.abavilla.fpi.fw.mapper.IMapper; import com.abavilla.fpi.load.dto.load.dtone.DVSCallbackDto; @@ -31,11 +32,16 @@ import com.abavilla.fpi.load.entity.dtone.DVSResp; import com.abavilla.fpi.load.util.LoadConst; import com.dtone.dvs.dto.Transaction; +import com.dtone.dvs.dto.TransactionFixed; +import com.dtone.dvs.dto.TransactionRanged; import com.dtone.dvs.dto.TransactionRequest; +import org.apache.commons.lang3.ObjectUtils; +import org.mapstruct.AfterMapping; import org.mapstruct.InjectionStrategy; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingConstants; +import org.mapstruct.MappingTarget; @Mapper(componentModel = MappingConstants.ComponentModel.CDI, injectionStrategy = InjectionStrategy.CONSTRUCTOR) @@ -46,12 +52,34 @@ public interface DTOneMapper extends IMapper { @Mapping(target = "dtOneId", source = "id") DVSResp copyTransactionRespToDVSResp(Transaction dto); + @AfterMapping + default void postCopyTransactionRespToDVSResp(Transaction dvsCallbackTransaction, @MappingTarget DVSResp dvsResp) { + if (dvsCallbackTransaction instanceof TransactionFixed fixed && ObjectUtils.isNotEmpty(fixed.getBenefits())) { + dvsResp.setBenefits(new ArrayList<>(fixed.getBenefits().size())); + dvsResp.getBenefits().addAll(fixed.getBenefits()); + } else if (dvsCallbackTransaction instanceof TransactionRanged ranged && ObjectUtils.isNotEmpty(ranged.getBenefits())) { + dvsResp.setBenefits(new ArrayList<>(ranged.getBenefits().size())); + dvsResp.getBenefits().addAll(ranged.getBenefits()); + } + } + @Mapping(target = "loadProvider", constant = LoadConst.PROV_DTONE) DVSCallback mapDTOneRespToEntity(DVSCallbackDto dto); @Mapping(target = "dtOneId", source = "id") DVSCallbackDto mapDTOneTransactionToCallbackDto(Transaction dto); + @AfterMapping + default void postMapDTOneTransactionToCallbackDto(Transaction dvsCallbackTransaction, @MappingTarget DVSCallbackDto dvsCallbackDto) { + if (dvsCallbackTransaction instanceof TransactionFixed fixed && ObjectUtils.isNotEmpty(fixed.getBenefits())) { + dvsCallbackDto.setBenefits(new ArrayList<>(fixed.getBenefits().size())); + dvsCallbackDto.getBenefits().addAll(fixed.getBenefits()); + } else if (dvsCallbackTransaction instanceof TransactionRanged ranged && ObjectUtils.isNotEmpty(ranged.getBenefits())) { + dvsCallbackDto.setBenefits(new ArrayList<>(ranged.getBenefits().size())); + dvsCallbackDto.getBenefits().addAll(ranged.getBenefits()); + } + } + default String dtLdtToStr(LocalDateTime ldtTimestamp) { if (ldtTimestamp != null) { var formatter = DateTimeFormatter.ISO_DATE_TIME; diff --git a/core/src/main/java/com/abavilla/fpi/load/service/load/RewardsCallbackSvc.java b/core/src/main/java/com/abavilla/fpi/load/service/load/RewardsCallbackSvc.java index 5886e04..d91e752 100644 --- a/core/src/main/java/com/abavilla/fpi/load/service/load/RewardsCallbackSvc.java +++ b/core/src/main/java/com/abavilla/fpi/load/service/load/RewardsCallbackSvc.java @@ -21,7 +21,6 @@ import java.time.Duration; import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.util.ArrayList; import java.util.function.Function; import com.abavilla.fpi.fw.entity.mongo.AbsMongoItem; @@ -47,15 +46,12 @@ import com.abavilla.fpi.sms.ext.rest.SmsApi; import com.abavilla.fpi.telco.ext.enums.ApiStatus; import com.dtone.dvs.dto.Transaction; -import com.dtone.dvs.dto.TransactionFixed; -import com.dtone.dvs.dto.TransactionRanged; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import io.quarkus.logging.Log; import io.smallrye.mutiny.Uni; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.microprofile.rest.client.inject.RestClient; @@ -104,13 +100,6 @@ public Uni storeCallback(GLRewardsCallbackDto callbackDto) { public Uni storeCallback(Transaction dvsCallbackTransaction) { var dvsCallbackDto = dtOneMapper.mapDTOneTransactionToCallbackDto(dvsCallbackTransaction); - if (dvsCallbackTransaction instanceof TransactionFixed fixed && ObjectUtils.isNotEmpty(fixed.getBenefits())) { - dvsCallbackDto.setBenefits(new ArrayList<>(fixed.getBenefits().size())); - dvsCallbackDto.getBenefits().addAll(fixed.getBenefits()); - } else if (dvsCallbackTransaction instanceof TransactionRanged ranged && ObjectUtils.isNotEmpty(ranged.getBenefits())) { - dvsCallbackDto.setBenefits(new ArrayList<>(ranged.getBenefits().size())); - dvsCallbackDto.getBenefits().addAll(ranged.getBenefits()); - } return storeCallback( dtOneMapper.mapDTOneRespToEntity(dvsCallbackDto), ApiStatus.fromDtOne(dvsCallbackDto.getStatus().getId()), @@ -244,7 +233,7 @@ private Uni sendFPIAckMsg(RewardsTransStatus rewardsTransStatus, AbsMongoItem } private String retrievePinFromCallBack(RewardsTransStatus rewardsTransStatus, AbsMongoItem callbackResponse) { - String pin = StringUtils.EMPTY; + var pin = StringUtils.EMPTY; if (StringUtils.equals(rewardsTransStatus.getLoadProvider(), LoadConst.PROV_DTONE)) { var dvsCallback = (DVSCallback) callbackResponse; if (dvsCallback.getPin() != null && StringUtils.isNotBlank(dvsCallback.getPin().getCode())) {