| Line 4... |
Line 4... |
| 4 |
import com.google.gson.Gson;
|
4 |
import com.google.gson.Gson;
|
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
6 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 7 |
import com.spice.profitmandi.common.model.PartnerTargetModel;
|
7 |
import com.spice.profitmandi.common.model.PartnerTargetModel;
|
| 8 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
8 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
9 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 9 |
import com.spice.profitmandi.common.util.Utils;
|
10 |
import com.spice.profitmandi.common.util.Utils;
|
| 10 |
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
|
11 |
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
|
| 11 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
12 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
| 12 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
13 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 13 |
import com.spice.profitmandi.dao.entity.catalog.TargetSlabEntity;
|
14 |
import com.spice.profitmandi.dao.entity.catalog.TargetSlabEntity;
|
| Line 39... |
Line 40... |
| 39 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
40 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| 40 |
import com.spice.profitmandi.service.scheme.InventoryPayoutModel;
|
41 |
import com.spice.profitmandi.service.scheme.InventoryPayoutModel;
|
| 41 |
import com.spice.profitmandi.service.user.RetailerService;
|
42 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 42 |
import com.spice.profitmandi.service.wallet.WalletService;
|
43 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 43 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
44 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| - |
|
45 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 44 |
import org.apache.logging.log4j.LogManager;
|
46 |
import org.apache.logging.log4j.LogManager;
|
| 45 |
import org.apache.logging.log4j.Logger;
|
47 |
import org.apache.logging.log4j.Logger;
|
| 46 |
import org.apache.poi.ss.usermodel.Cell;
|
48 |
import org.apache.poi.ss.usermodel.Cell;
|
| 47 |
import org.apache.poi.ss.usermodel.CellType;
|
49 |
import org.apache.poi.ss.usermodel.CellType;
|
| 48 |
import org.apache.poi.ss.usermodel.Row;
|
50 |
import org.apache.poi.ss.usermodel.Row;
|
| Line 1075... |
Line 1077... |
| 1075 |
}
|
1077 |
}
|
| 1076 |
}
|
1078 |
}
|
| 1077 |
return sb.toString();
|
1079 |
return sb.toString();
|
| 1078 |
}
|
1080 |
}
|
| 1079 |
|
1081 |
|
| - |
|
1082 |
@Override
|
| - |
|
1083 |
public ByteArrayOutputStream createCSVOfferReport(CreateOfferRequest createOfferRequest) throws Exception {
|
| - |
|
1084 |
List<List<?>> listOfRows = new ArrayList<>();
|
| - |
|
1085 |
ByteArrayOutputStream baos = null;
|
| - |
|
1086 |
Collection<OfferRowModel> offerRowModels = offerRepository.getOfferRows(createOfferRequest);
|
| - |
|
1087 |
ItemCriteriaPayout itemCriteriaPayout = createOfferRequest.getTargetSlabs().get(0).getItemCriteriaPayouts().get(0);
|
| - |
|
1088 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.SELLIN)) {
|
| - |
|
1089 |
for (OfferRowModel offerRowModel : offerRowModels) {
|
| - |
|
1090 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(offerRowModel.getFofoId());
|
| - |
|
1091 |
listOfRows.add(Arrays.asList(
|
| - |
|
1092 |
createOfferRequest.getId()
|
| - |
|
1093 |
, createOfferRequest.getName()
|
| - |
|
1094 |
, createOfferRequest.getTargetType()
|
| - |
|
1095 |
, createOfferRequest.getSchemeType()
|
| - |
|
1096 |
, itemCriteriaPayout.getStartDate()
|
| - |
|
1097 |
, itemCriteriaPayout.getEndDate()
|
| - |
|
1098 |
// , createOfferRequest.getBrandShareTerms()
|
| - |
|
1099 |
, createOfferRequest.getSellinPercentage()
|
| - |
|
1100 |
, "--"
|
| - |
|
1101 |
, createOfferRequest.getItemCriteriaString()
|
| - |
|
1102 |
, createOfferRequest.getStartDate()
|
| - |
|
1103 |
, createOfferRequest.getEndDate()
|
| - |
|
1104 |
, createOfferRequest.getCreatedOn()
|
| - |
|
1105 |
, customRetailer.getPartnerId()
|
| - |
|
1106 |
, customRetailer.getBusinessName()
|
| - |
|
1107 |
, customRetailer.getCode()
|
| - |
|
1108 |
, offerRowModel.getTotalBasePurchaseValue()
|
| - |
|
1109 |
, offerRowModel.getAchievedTarget()
|
| - |
|
1110 |
, offerRowModel.getPayoutPurchaseValue()
|
| - |
|
1111 |
, offerRowModel.getPayout()
|
| - |
|
1112 |
, offerRowModel.getPayoutType()
|
| - |
|
1113 |
, offerRowModel.getFinalPayout()
|
| - |
|
1114 |
, String.join(", ", offerRowModel.getEligibleImeis())));
|
| - |
|
1115 |
}
|
| - |
|
1116 |
baos = FileUtil.getCSVByteStream(
|
| - |
|
1117 |
Arrays.asList(
|
| - |
|
1118 |
"Id"
|
| - |
|
1119 |
, "Name"
|
| - |
|
1120 |
, "Target Type"
|
| - |
|
1121 |
, "Scheme Type"
|
| - |
|
1122 |
, "Payout Start"
|
| - |
|
1123 |
, "Payout End"
|
| - |
|
1124 |
// , "Brand %"
|
| - |
|
1125 |
, "Sellin %"
|
| - |
|
1126 |
, "Partner Criteria"
|
| - |
|
1127 |
, "Item Criteria"
|
| - |
|
1128 |
, "Start"
|
| - |
|
1129 |
, "End"
|
| - |
|
1130 |
, "Created"
|
| - |
|
1131 |
, "Partner Id"
|
| - |
|
1132 |
, "Partner Name"
|
| - |
|
1133 |
, "Partner Code"
|
| - |
|
1134 |
, "Base Purchase"
|
| - |
|
1135 |
, "Achieved Target"
|
| - |
|
1136 |
, "Eligible Purchase"
|
| - |
|
1137 |
, "Slab Amount"
|
| - |
|
1138 |
, "Slab Amount Type"
|
| - |
|
1139 |
, "Payout Value(Rs.)"
|
| - |
|
1140 |
, "Eligible IMEIs"
|
| - |
|
1141 |
, "Billing Pending Imeis"
|
| - |
|
1142 |
), listOfRows);
|
| - |
|
1143 |
} else {
|
| - |
|
1144 |
for (OfferRowModel offerRowModel : offerRowModels) {
|
| - |
|
1145 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(offerRowModel.getFofoId());
|
| - |
|
1146 |
listOfRows.add(Arrays.asList(
|
| - |
|
1147 |
createOfferRequest.getId()
|
| - |
|
1148 |
, createOfferRequest.getName()
|
| - |
|
1149 |
, createOfferRequest.getTargetType()
|
| - |
|
1150 |
, createOfferRequest.getSchemeType()
|
| - |
|
1151 |
, itemCriteriaPayout.getStartDate()
|
| - |
|
1152 |
, itemCriteriaPayout.getEndDate()
|
| - |
|
1153 |
// , createOfferRequest.getBrandShareTerms()
|
| - |
|
1154 |
, createOfferRequest.getSellinPercentage()
|
| - |
|
1155 |
, createOfferRequest.getPartnerCriteriaString()
|
| - |
|
1156 |
, createOfferRequest.getItemCriteriaString()
|
| - |
|
1157 |
, createOfferRequest.getStartDate()
|
| - |
|
1158 |
, createOfferRequest.getEndDate()
|
| - |
|
1159 |
, createOfferRequest.getCreatedOn()
|
| - |
|
1160 |
, customRetailer.getPartnerId()
|
| - |
|
1161 |
, customRetailer.getBusinessName()
|
| - |
|
1162 |
, customRetailer.getCode()
|
| - |
|
1163 |
, offerRowModel.getTotalSale()
|
| - |
|
1164 |
, offerRowModel.getEligibleSale()
|
| - |
|
1165 |
, offerRowModel.getPayoutTargetAchieved()
|
| - |
|
1166 |
, offerRowModel.getPayoutValue()
|
| - |
|
1167 |
, offerRowModel.getPayoutType()
|
| - |
|
1168 |
, offerRowModel.getPayoutValueDp()
|
| - |
|
1169 |
, offerRowModel.getFinalPayout()
|
| - |
|
1170 |
, String.join(", ", offerRowModel.getEligibleImeis())
|
| - |
|
1171 |
// ,String.join(", ", offerRowModel.getBaseCriteria())
|
| - |
|
1172 |
)
|
| - |
|
1173 |
);
|
| - |
|
1174 |
}
|
| - |
|
1175 |
baos = FileUtil.getCSVByteStream(
|
| - |
|
1176 |
Arrays.asList(
|
| - |
|
1177 |
"Id"
|
| - |
|
1178 |
, "Name"
|
| - |
|
1179 |
, "Target Type"
|
| - |
|
1180 |
, "Scheme Type"
|
| - |
|
1181 |
, "Payout Start"
|
| - |
|
1182 |
, "Payout End"
|
| - |
|
1183 |
// , "Brand %"
|
| - |
|
1184 |
, "Sellin %"
|
| - |
|
1185 |
, "Partner Criteria"
|
| - |
|
1186 |
, "Item Criteria"
|
| - |
|
1187 |
, "Start"
|
| - |
|
1188 |
, "End"
|
| - |
|
1189 |
, "Created"
|
| - |
|
1190 |
, "Partner Id"
|
| - |
|
1191 |
, "Partner Name"
|
| - |
|
1192 |
, "Partner Code"
|
| - |
|
1193 |
, "Total Sale"
|
| - |
|
1194 |
, "Eligible Sale"
|
| - |
|
1195 |
, "Payout Target Achieved"
|
| - |
|
1196 |
, "Payout Amount"
|
| - |
|
1197 |
, "Payout Amount Type"
|
| - |
|
1198 |
, "Payout Value DP"
|
| - |
|
1199 |
, "Amount to be credited"
|
| - |
|
1200 |
, "Eligible Activated Imeis"
|
| - |
|
1201 |
), listOfRows);
|
| - |
|
1202 |
}
|
| - |
|
1203 |
return baos;
|
| - |
|
1204 |
}
|
| - |
|
1205 |
|
| 1080 |
private void appendPartnerCodes(List<Integer> fofoIds, StringBuilder sb) throws ProfitMandiBusinessException {
|
1206 |
private void appendPartnerCodes(List<Integer> fofoIds, StringBuilder sb) throws ProfitMandiBusinessException {
|
| 1081 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getAllFofoRetailers();
|
1207 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getAllFofoRetailers();
|
| 1082 |
List<String> businessNames = fofoIds.stream().map(x -> customRetailersMap.get(x)).filter(x -> x != null).map(x -> x.getBusinessName()).collect(Collectors.toList());
|
1208 |
List<String> businessNames = fofoIds.stream().map(x -> customRetailersMap.get(x)).filter(x -> x != null).map(x -> x.getBusinessName()).collect(Collectors.toList());
|
| 1083 |
sb.append(String.join(", ", businessNames));
|
1209 |
sb.append(String.join(", ", businessNames));
|
| 1084 |
}
|
1210 |
}
|