Subversion Repositories SmartDukaan

Rev

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

Rev 34620 Rev 35205
Line 24... Line 24...
24
import com.spice.profitmandi.service.authentication.RoleManager;
24
import com.spice.profitmandi.service.authentication.RoleManager;
25
import com.spice.profitmandi.service.catalog.BrandsService;
25
import com.spice.profitmandi.service.catalog.BrandsService;
26
import com.spice.profitmandi.service.offers.ItemCriteria;
26
import com.spice.profitmandi.service.offers.ItemCriteria;
27
import com.spice.profitmandi.service.offers.OfferService;
27
import com.spice.profitmandi.service.offers.OfferService;
28
import com.spice.profitmandi.service.user.RetailerService;
28
import com.spice.profitmandi.service.user.RetailerService;
29
import com.spice.profitmandi.service.whatsapp.WhatsappMessageType;
-
 
30
import com.spice.profitmandi.web.model.LoginDetails;
29
import com.spice.profitmandi.web.model.LoginDetails;
31
import com.spice.profitmandi.web.util.CookiesProcessor;
30
import com.spice.profitmandi.web.util.CookiesProcessor;
32
import com.spice.profitmandi.web.util.MVCResponseSender;
31
import com.spice.profitmandi.web.util.MVCResponseSender;
33
import org.apache.commons.io.FileUtils;
32
import org.apache.commons.io.FileUtils;
34
import org.apache.commons.io.output.ByteArrayOutputStream;
33
import org.apache.commons.io.output.ByteArrayOutputStream;
Line 63... Line 62...
63
import java.io.InputStream;
62
import java.io.InputStream;
64
import java.time.Instant;
63
import java.time.Instant;
65
import java.time.LocalDate;
64
import java.time.LocalDate;
66
import java.time.LocalDateTime;
65
import java.time.LocalDateTime;
67
import java.time.YearMonth;
66
import java.time.YearMonth;
68
import java.util.List;
-
 
69
import java.util.*;
67
import java.util.*;
-
 
68
import java.util.List;
70
import java.util.stream.Collectors;
69
import java.util.stream.Collectors;
71
 
70
 
72
@Controller
71
@Controller
73
@Transactional(rollbackOn = Throwable.class)
72
@Transactional(rollbackOn = Throwable.class)
74
public class OfferController {
73
public class OfferController {
Line 271... Line 270...
271
            sendWhatsapp(offer, fofoIds, imageUrl);
270
            sendWhatsapp(offer, fofoIds, imageUrl);
272
        }
271
        }
273
    }
272
    }
274
 
273
 
275
    private void sendWhatsapp(Offer offer, List<Integer> fofoIds, String imageUrl) throws Exception {
274
    private void sendWhatsapp(Offer offer, List<Integer> fofoIds, String imageUrl) throws Exception {
276
        if (fofoIds == null) {
-
 
277
            fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId()).collect(Collectors.toList());
-
 
278
        }
-
 
279
        final List<Integer> finalFofoIds = fofoIds;
275
        offerService.sendWhatsapp(offer, fofoIds, imageUrl);
280
        //List<String> mobileNumbers = retailerService.getAllFofoRetailers().entrySet().stream().filter(x -> finalFofoIds.contains(x.getKey())).map(x -> x.getValue().getMobileNumber()).collect(Collectors.toList());
-
 
281
        List<String> mobileNumbers = new ArrayList<>();
-
 
282
        mobileNumbers.add("9911565032");
-
 
283
        String message = "%s\n" +
-
 
284
                "On %s of select models\n" +
-
 
285
                "From %s to %s\n" +
-
 
286
                "\n" +
-
 
287
                "Happy Selling\n" +
-
 
288
                "Team Smartdukaan";
-
 
289
        //TV's mobile
-
 
290
        for (String mobileNumber : mobileNumbers) {
-
 
291
            notificationService.sendWhatsappMediaMessage(String.format(message, offer.getName(),
-
 
292
                    offer.getSchemeType().toString(), FormattingUtils.formatDate(offer.getStartDate()),
-
 
293
                    FormattingUtils.formatDate(offer.getEndDate())), mobileNumber, imageUrl, "offer-" + offer.getId() + ".png", WhatsappMessageType.IMAGE);
-
 
294
        }
-
 
295
    }
276
    }
296
 
277
 
297
    private InputStream asInputStream(BufferedImage bi) throws Exception {
278
    private InputStream asInputStream(BufferedImage bi) throws Exception {
298
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
279
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
299
        ImageIO.write(bi, "png", baos);
280
        ImageIO.write(bi, "png", baos);