| Line 931... |
Line 931... |
| 931 |
fofoStore.setFofoType(updateRetailerRequest.getFofoType());
|
931 |
fofoStore.setFofoType(updateRetailerRequest.getFofoType());
|
| 932 |
fofoStore.setActivationType(ActivationType.ACTIVE);
|
932 |
fofoStore.setActivationType(ActivationType.ACTIVE);
|
| 933 |
fofoStore.setGstNumber(updateRetailerRequest.getGstNumber());
|
933 |
fofoStore.setGstNumber(updateRetailerRequest.getGstNumber());
|
| 934 |
fofoStoreRepository.persist(fofoStore);
|
934 |
fofoStoreRepository.persist(fofoStore);
|
| 935 |
|
935 |
|
| 936 |
PincodePartner pincodePartner = pincodePartnerRepository.selectPartnerByPincode(retailerAddress.getPinCode(), fofoStore.getId());
|
- |
|
| 937 |
if (pincodePartner == null) {
|
- |
|
| 938 |
PincodePartner pinPartner = new PincodePartner();
|
- |
|
| 939 |
pinPartner.setFofoId(fofoStore.getId());
|
- |
|
| 940 |
pinPartner.setPincode(retailerAddress.getPinCode());
|
- |
|
| 941 |
pincodePartnerRepository.perist(pinPartner);
|
- |
|
| 942 |
}
|
- |
|
| 943 |
}
|
- |
|
| 944 |
|
- |
|
| 945 |
// Link store code to onboarding panel and create STORE_CODE_CREATED timeline
|
936 |
// Link store code to onboarding panel (only for NEW store creation)
|
| 946 |
// Runs for BOTH new and existing fofoStore to handle retry scenarios
|
- |
|
| 947 |
if (fofoStore != null && fofoStore.getCode() != null && !fofoStore.getCode().isEmpty()) {
|
- |
|
| 948 |
try {
|
937 |
try {
|
| 949 |
int addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailerId);
|
938 |
PartnerOnBoardingPanel pobp = partnerOnBoardingPanelRepository.selectByPhoneNumber(
|
| 950 |
Address addr = addressRepository.selectById(addressId);
|
939 |
Long.parseLong(retailerAddress.getPhoneNumber()));
|
| 951 |
PartnerOnBoardingPanel pobp = partnerOnBoardingPanelRepository.selectByPhoneNumber(Long.parseLong(addr.getPhoneNumber()));
|
- |
|
| 952 |
if (pobp != null) {
|
940 |
if (pobp != null) {
|
| 953 |
PartnerVerificationpanel partnerVerificationpanel = partnerOnboardingVerificationRepository.selectByOnboardingId(pobp.getId());
|
941 |
PartnerVerificationpanel pvp = partnerOnboardingVerificationRepository
|
| 954 |
if (partnerVerificationpanel != null
|
942 |
.selectByOnboardingId(pobp.getId());
|
| 955 |
&& PartnerVerificationApprovalStatus.YES.equals(partnerVerificationpanel.getApproval())) {
|
943 |
if (pvp != null && PartnerVerificationApprovalStatus.YES.equals(pvp.getApproval())) {
|
| 956 |
pobp.setCode(fofoStore.getCode());
|
944 |
pobp.setCode(fofoStore.getCode());
|
| 957 |
storeTimelineTatService.onCodeCreated(pobp.getId());
|
945 |
storeTimelineTatService.onCodeCreated(pobp.getId());
|
| 958 |
PartnerVerificationCheckboxes cb = partnerOnboardingVerificationRepository
|
946 |
PartnerVerificationCheckboxes cb = partnerOnboardingVerificationRepository
|
| 959 |
.selectVerifiCheckboxByOnboardingId(pobp.getId());
|
947 |
.selectVerifiCheckboxByOnboardingId(pobp.getId());
|
| 960 |
if (cb == null) {
|
948 |
if (cb == null) {
|
| 961 |
cb = new PartnerVerificationCheckboxes();
|
949 |
cb = new PartnerVerificationCheckboxes();
|
| 962 |
cb.setOnboardingId(pobp.getId());
|
950 |
cb.setOnboardingId(pobp.getId());
|
| 963 |
partnerOnboardingVerificationRepository.persist(cb);
|
951 |
partnerOnboardingVerificationRepository.persist(cb);
|
| 964 |
}
|
952 |
}
|
| 965 |
}
|
953 |
}
|
| 966 |
} else {
|
- |
|
| 967 |
LOGGER.warn("No onboarding panel entry found for phone {}. Store code {} created for retailer {} " +
|
- |
|
| 968 |
"but not linked to onboarding panel.",
|
- |
|
| 969 |
addr.getPhoneNumber(), fofoStore.getCode(), retailerId);
|
- |
|
| 970 |
}
|
954 |
}
|
| 971 |
} catch (Exception e) {
|
955 |
} catch (Exception e) {
|
| 972 |
LOGGER.error("Failed to link store code to onboarding panel for retailerId: {}. " +
|
956 |
LOGGER.error("Error linking store code to onboarding for retailerId: {}", retailerId, e);
|
| 973 |
"Store code was created successfully but timeline/email may be incomplete.", retailerId, e);
|
- |
|
| 974 |
}
|
957 |
}
|
| 975 |
}
|
- |
|
| 976 |
|
958 |
|
| - |
|
959 |
PincodePartner pincodePartner = pincodePartnerRepository.selectPartnerByPincode(retailerAddress.getPinCode(), fofoStore.getId());
|
| 977 |
if (fofoStore.isTrial()) {
|
960 |
if (pincodePartner == null) {
|
| 978 |
|
- |
|
| - |
|
961 |
PincodePartner pinPartner = new PincodePartner();
|
| 979 |
storeTimelineTatService.sendTrialStoreCreationMail(fofoStore, updateRetailerRequest);
|
962 |
pinPartner.setFofoId(fofoStore.getId());
|
| 980 |
storeTimelineTatService.sendTrialActivationMail(fofoStore, updateRetailerRequest);
|
963 |
pinPartner.setPincode(retailerAddress.getPinCode());
|
| - |
|
964 |
pincodePartnerRepository.perist(pinPartner);
|
| - |
|
965 |
}
|
| 981 |
|
966 |
|
| - |
|
967 |
if (fofoStore.isTrial()) {
|
| - |
|
968 |
storeTimelineTatService.sendTrialStoreCreationMail(fofoStore, updateRetailerRequest);
|
| - |
|
969 |
storeTimelineTatService.sendTrialActivationMail(fofoStore, updateRetailerRequest);
|
| - |
|
970 |
}
|
| 982 |
}
|
971 |
}
|
| 983 |
|
972 |
|
| 984 |
return fofoStore;
|
973 |
return fofoStore;
|
| 985 |
}
|
974 |
}
|
| 986 |
|
975 |
|