Subversion Repositories SmartDukaan

Rev

Rev 34637 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34637 Rev 37409
Line 139... Line 139...
139
        LOGGER.info("consolidatedBiddingMessage liquidations: {}",liquidations);
139
        LOGGER.info("consolidatedBiddingMessage liquidations: {}",liquidations);
140
 
140
 
141
        if (liquidations.size() > 0) {
141
        if (liquidations.size() > 0) {
142
            StringBuilder message = new StringBuilder("*Bidding Update!*\n" +
142
            StringBuilder message = new StringBuilder("*Bidding Update!*\n" +
143
                    "Place your best bids and unlock unbeatable price on smartphones!\n");
143
                    "Place your best bids and unlock unbeatable price on smartphones!\n");
-
 
144
            // Same lots, one line, for the WhatsApp template variable — Meta rejects newlines inside a
-
 
145
            // parameter, and the surrounding copy already lives in the approved template.
144
            //StringBuilder templateMessage = new StringBuilder("bidd_live");
146
            List<String> lots = new ArrayList<>();
145
            for (Liquidation liquidation : liquidations) {
147
            for (Liquidation liquidation : liquidations) {
146
                List<Item> items = itemRepository.selectAllByCatalogItemId(liquidation.getCatalogId());
148
                List<Item> items = itemRepository.selectAllByCatalogItemId(liquidation.getCatalogId());
147
                List<Bid> bids = bidRepository.selectBidByLiquidationId(liquidation.getId());
149
                List<Bid> bids = bidRepository.selectBidByLiquidationId(liquidation.getId());
148
                if (items.size() > 0) {
150
                if (items.size() > 0) {
149
                    long remainingQty = 0;
151
                    long remainingQty = 0;
Line 162... Line 164...
162
                            .append("Starting price: *").append(liquidation.getPrice()).append("*\n");
164
                            .append("Starting price: *").append(liquidation.getPrice()).append("*\n");
163
                        if (bids.size() > 0) {
165
                        if (bids.size() > 0) {
164
                            message.append("Top Bid: *").append(bids.get(0).getBiddingAmount()).append("*\n");
166
                            message.append("Top Bid: *").append(bids.get(0).getBiddingAmount()).append("*\n");
165
                        }
167
                        }
166
                        message.append("Ending on: *").append(StringUtils.toLocalDateTime(liquidation.getEndDate().toString())).append("*\n");
168
                        message.append("Ending on: *").append(StringUtils.toLocalDateTime(liquidation.getEndDate().toString())).append("*\n");
-
 
169
 
-
 
170
                        StringBuilder lot = new StringBuilder()
-
 
171
                                .append(items.get(0).getItemDescription())
-
 
172
                                .append(" at ").append(Math.round(discountPercentage)).append("% off, from ")
-
 
173
                                .append(liquidation.getPrice());
-
 
174
                        if (bids.size() > 0) {
-
 
175
                            lot.append(", top bid ").append(bids.get(0).getBiddingAmount());
-
 
176
                        }
167
                        //templateMessage.append("|").append(items.get(0).getItemDescription()).append("|").append(liquidation.getPrice()).append("|").append(StringUtils.toLocalDateTime(liquidation.getEndDate().toString()));
177
                        lot.append(", ends ").append(StringUtils.toLocalDateTime(liquidation.getEndDate().toString()));
-
 
178
                        lots.add(lot.toString());
168
                    }
179
                    }
169
                }
180
                }
170
            }
181
            }
171
 
182
 
172
            message.append("\nDon't miss out. Submit your bid now and grab the deal before it's gone!");
183
            message.append("\nDon't miss out. Submit your bid now and grab the deal before it's gone!");
173
 
184
 
174
            LOGGER.info("templateMessage : {}",message.toString());
185
            LOGGER.info("templateMessage : {}",message.toString());
175
 
186
 
-
 
187
            // Nothing in stock means the notification would announce an empty auction, and an empty
-
 
188
            // template variable is rejected by Meta anyway.
-
 
189
            if (lots.isEmpty()) {
176
            bidService.biddingLiveNotification(message.toString(), "https://images.smartdukaan.com/uploads/whatsapp.jpeg");
190
                LOGGER.info("consolidatedBiddingMessage: no lots with stock, skipping notification");
-
 
191
                return;
-
 
192
            }
177
            //notificationService.sendWhatsappMessage(message, "Bidding Live Now!", "8529003611");
193
            bidService.biddingLiveNotification(message.toString(), lots,
178
            //notificationService.sendWhatsappMediaMessage(message.toString(), "8529003611", "https://images.smartdukaan.com/uploads/whatsapp.jpeg","whatsapp.jpeg", WhatsappMessageType.IMAGE);
194
                    "https://images.smartdukaan.com/uploads/whatsapp.jpeg");
179
        }
195
        }
180
    }
196
    }
181
}
197
}