Subversion Repositories SmartDukaan

Rev

Rev 34624 | Rev 35394 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34624 Rev 35205
Line 5... Line 5...
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.FileUtil;
-
 
10
import com.spice.profitmandi.common.util.FormattingUtils;
10
import com.spice.profitmandi.common.util.Utils;
11
import com.spice.profitmandi.common.util.Utils;
11
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
12
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
12
import com.spice.profitmandi.dao.entity.catalog.Offer;
13
import com.spice.profitmandi.dao.entity.catalog.Offer;
13
import com.spice.profitmandi.dao.entity.catalog.TagListing;
14
import com.spice.profitmandi.dao.entity.catalog.TagListing;
14
import com.spice.profitmandi.dao.entity.catalog.TargetSlabEntity;
15
import com.spice.profitmandi.dao.entity.catalog.TargetSlabEntity;
Line 28... Line 29...
28
import com.spice.profitmandi.dao.model.AmountModel;
29
import com.spice.profitmandi.dao.model.AmountModel;
29
import com.spice.profitmandi.dao.model.CreateOfferRequest;
30
import com.spice.profitmandi.dao.model.CreateOfferRequest;
30
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
31
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
31
import com.spice.profitmandi.dao.model.OfferRowModel;
32
import com.spice.profitmandi.dao.model.OfferRowModel;
32
import com.spice.profitmandi.dao.repository.catalog.*;
33
import com.spice.profitmandi.dao.repository.catalog.*;
-
 
34
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
33
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
35
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
34
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
36
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
35
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
37
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
36
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
38
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
37
import com.spice.profitmandi.dao.repository.warehouse.AgeingSummaryModel;
39
import com.spice.profitmandi.dao.repository.warehouse.AgeingSummaryModel;
38
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
40
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
39
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
41
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
-
 
42
import com.spice.profitmandi.service.NotificationService;
40
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
43
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
41
import com.spice.profitmandi.service.scheme.InventoryPayoutModel;
44
import com.spice.profitmandi.service.scheme.InventoryPayoutModel;
42
import com.spice.profitmandi.service.user.RetailerService;
45
import com.spice.profitmandi.service.user.RetailerService;
43
import com.spice.profitmandi.service.wallet.WalletService;
46
import com.spice.profitmandi.service.wallet.WalletService;
-
 
47
import com.spice.profitmandi.service.whatsapp.WhatsappMessageType;
44
import in.shop2020.model.v1.order.WalletReferenceType;
48
import in.shop2020.model.v1.order.WalletReferenceType;
45
import org.apache.commons.io.output.ByteArrayOutputStream;
49
import org.apache.commons.io.output.ByteArrayOutputStream;
46
import org.apache.logging.log4j.LogManager;
50
import org.apache.logging.log4j.LogManager;
47
import org.apache.logging.log4j.Logger;
51
import org.apache.logging.log4j.Logger;
48
import org.apache.poi.ss.usermodel.Cell;
52
import org.apache.poi.ss.usermodel.Cell;
Line 73... Line 77...
73
 
77
 
74
    @Autowired
78
    @Autowired
75
    private Gson gson;
79
    private Gson gson;
76
 
80
 
77
    @Autowired
81
    @Autowired
-
 
82
    NotificationService notificationService;
-
 
83
 
-
 
84
    @Autowired
78
    private OfferRepository offerRepository;
85
    private OfferRepository offerRepository;
79
 
86
 
80
    @Autowired
87
    @Autowired
81
    private RetailerService retailerService;
88
    private RetailerService retailerService;
82
    @Autowired
89
    @Autowired
Line 94... Line 101...
94
    @Autowired
101
    @Autowired
95
    private TagListingRepository tagListingRepository;
102
    private TagListingRepository tagListingRepository;
96
 
103
 
97
    @Autowired
104
    @Autowired
98
    private OfferTargetSlabRepository offerTargetSlabRepository;
105
    private OfferTargetSlabRepository offerTargetSlabRepository;
-
 
106
    @Autowired
-
 
107
    private FofoStoreRepository fofoStoreRepository;
99
 
108
 
100
    @Autowired
109
    @Autowired
101
    CacheManager oneDayCacheManager;
110
    CacheManager oneDayCacheManager;
102
 
111
 
103
 
112
 
Line 1218... Line 1227...
1218
                    ), listOfRows);
1227
                    ), listOfRows);
1219
        }
1228
        }
1220
        return baos;
1229
        return baos;
1221
    }
1230
    }
1222
 
1231
 
-
 
1232
    @Override
-
 
1233
    public void sendWhatsapp(Offer offer, List<Integer> fofoIds, String imageUrl) throws Exception {
-
 
1234
        if (fofoIds == null) {
-
 
1235
            fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toList());
-
 
1236
        }
-
 
1237
        final List<Integer> finalFofoIds = fofoIds;
-
 
1238
        //List<String> mobileNumbers = retailerService.getAllFofoRetailers().entrySet().stream().filter(x -> finalFofoIds.contains(x.getKey())).map(x -> x.getValue().getMobileNumber()).collect(Collectors.toList());
-
 
1239
        List<String> mobileNumbers = new ArrayList<>();
-
 
1240
        mobileNumbers.add("9911565032");
-
 
1241
        //mobileNumbers.add("9990381569");
-
 
1242
        //mobileNumbers.add("8383849914");
-
 
1243
        String message = "%s\n" +
-
 
1244
                "On %s of select models\n" +
-
 
1245
                "From %s to %s\n" +
-
 
1246
                "\n" +
-
 
1247
                "Happy Selling\n" +
-
 
1248
                "Team Smartdukaan";
-
 
1249
        //TV's mobile
-
 
1250
        for (String mobileNumber : mobileNumbers) {
-
 
1251
            notificationService.sendWhatsappMediaMessage(String.format(message, offer.getName(),
-
 
1252
                    offer.getSchemeType().toString(), FormattingUtils.formatDate(offer.getStartDate()),
-
 
1253
                    FormattingUtils.formatDate(offer.getEndDate())), mobileNumber, imageUrl, "offer-" + offer.getId() + ".png", WhatsappMessageType.IMAGE);
-
 
1254
        }
-
 
1255
    }
-
 
1256
 
1223
    private void appendPartnerCodes(List<Integer> fofoIds, StringBuilder sb) throws ProfitMandiBusinessException {
1257
    private void appendPartnerCodes(List<Integer> fofoIds, StringBuilder sb) throws ProfitMandiBusinessException {
1224
        Map<Integer, CustomRetailer> customRetailersMap = retailerService.getAllFofoRetailers();
1258
        Map<Integer, CustomRetailer> customRetailersMap = retailerService.getAllFofoRetailers();
1225
        List<String> businessNames = fofoIds.stream().map(x -> customRetailersMap.get(x)).filter(x -> x != null).map(x -> x.getBusinessName()).collect(Collectors.toList());
1259
        List<String> businessNames = fofoIds.stream().map(x -> customRetailersMap.get(x)).filter(x -> x != null).map(x -> x.getBusinessName()).collect(Collectors.toList());
1226
        sb.append(String.join(", ", businessNames));
1260
        sb.append(String.join(", ", businessNames));
1227
    }
1261
    }