Subversion Repositories SmartDukaan

Rev

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

Rev 28355 Rev 28374
Line 54... Line 54...
54
import com.spice.profitmandi.common.web.client.RestClient;
54
import com.spice.profitmandi.common.web.client.RestClient;
55
import com.spice.profitmandi.common.web.util.ResponseSender;
55
import com.spice.profitmandi.common.web.util.ResponseSender;
56
import com.spice.profitmandi.dao.entity.catalog.Item;
56
import com.spice.profitmandi.dao.entity.catalog.Item;
57
import com.spice.profitmandi.dao.entity.catalog.TagListing;
57
import com.spice.profitmandi.dao.entity.catalog.TagListing;
58
import com.spice.profitmandi.dao.entity.dtr.WebListing;
58
import com.spice.profitmandi.dao.entity.dtr.WebListing;
-
 
59
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
59
import com.spice.profitmandi.dao.entity.fofo.Customer;
60
import com.spice.profitmandi.dao.entity.fofo.Customer;
60
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
61
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
61
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
62
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
62
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
63
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
63
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
64
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
Line 73... Line 74...
73
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
74
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
74
import com.spice.profitmandi.dao.repository.cs.CsService;
75
import com.spice.profitmandi.dao.repository.cs.CsService;
75
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
76
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
76
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
77
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
77
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
78
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
-
 
79
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
78
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
80
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
79
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
81
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
80
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
82
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
81
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
83
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
82
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
84
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
Line 115... Line 117...
115
 
117
 
116
	private static final List<Integer> TAG_IDS = Arrays.asList(4);
118
	private static final List<Integer> TAG_IDS = Arrays.asList(4);
117
 
119
 
118
	@Autowired
120
	@Autowired
119
	CustomerAddressRepository customerAddressRepository;
121
	CustomerAddressRepository customerAddressRepository;
-
 
122
	
-
 
123
	@Autowired
-
 
124
	WebOfferRepository webOfferRepository;
120
 
125
 
121
	@Value("${new.solr.url}")
126
	@Value("${new.solr.url}")
122
	private String solrUrl;
127
	private String solrUrl;
123
 
128
 
124
	@Autowired
129
	@Autowired
Line 373... Line 378...
373
			if (authUserEmails != null) {
378
			if (authUserEmails != null) {
374
				authUserEmails = new ArrayList<>();
379
				authUserEmails = new ArrayList<>();
375
			}
380
			}
376
			logger.info("authUserEmails {}", authUserEmails);
381
			logger.info("authUserEmails {}", authUserEmails);
377
			authUserEmails.addAll(bccTo);
382
			authUserEmails.addAll(bccTo);
-
 
383
			StringBuffer itemBuffer = new StringBuffer();
-
 
384
			List<PendingOrderItem> orderItems = pendingOrderItemRepository.selectByOrderId(pendingOrder.getId());
-
 
385
			int totalItems = 0;
-
 
386
			String itemNoColor = null;
-
 
387
			float maxValue = 0;
-
 
388
			for(PendingOrderItem orderItem : orderItems) {
-
 
389
				if(maxValue < orderItem.getSellingPrice()) {
-
 
390
					maxValue = orderItem.getSellingPrice();
-
 
391
					itemNoColor = itemRepository.selectById(orderItem.getItemId()).getItemDescriptionNoColor();
-
 
392
				}
-
 
393
				totalItems += orderItem.getQuantity();
378
 
394
			}
-
 
395
			if(totalItems > 1) {
-
 
396
				itemBuffer.append(StringUtils.abbreviate(itemNoColor, 22));
-
 
397
				itemBuffer.append(" +").append(totalItems-1).append(" items");
-
 
398
			} else {
-
 
399
				itemBuffer.append(StringUtils.abbreviate(itemNoColor, 30));
-
 
400
			}
-
 
401
			String message = String.format(OtpProcessor.TEMPLATE_ORDER_CREATED, pendingOrder.getId(), itemBuffer.toString(), pendingOrder.getTotalAmount());
-
 
402
			otpProcessor.sendSms(OtpProcessor.TEMPLATE_ORDER_CREATED_ID, message, customer.getMobileNumber());
379
			emailService.sendMailWithAttachments("Order Created with SmartDukaan", "order-confirm.vm", emailModel,
403
			emailService.sendMailWithAttachments("Order Created with SmartDukaan", "order-confirm.vm", emailModel,
380
					customerEmail, null, authUserEmails.toArray(new String[0]));
404
					customerEmail, null, authUserEmails.toArray(new String[0]));
381
		}
405
		}
382
		return responseSender.ok(returnMap);
406
		return responseSender.ok(returnMap);
383
 
407
 
Line 682... Line 706...
682
			JSONObject doc = docs.getJSONObject(i);
706
			JSONObject doc = docs.getJSONObject(i);
683
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
707
			FofoCatalogResponse ffdr = new FofoCatalogResponse();
684
			ffdr.setCatalogId(doc.getInt("catalogId_i"));
708
			ffdr.setCatalogId(doc.getInt("catalogId_i"));
685
			ffdr.setImageUrl(doc.getString("imageUrl_s"));
709
			ffdr.setImageUrl(doc.getString("imageUrl_s"));
686
			ffdr.setTitle(doc.getString("title_s"));
710
			ffdr.setTitle(doc.getString("title_s"));
-
 
711
			List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(ffdr.getCatalogId());
-
 
712
			if(webOffers != null && webOffers.size() > 0) {
-
 
713
				ffdr.setOffers(webOffers.stream().map(x->x.getSmallText()).collect(Collectors.toList()));
-
 
714
			}
687
			try {
715
			try {
688
				ffdr.setFeature(doc.getString("feature_s"));
716
				ffdr.setFeature(doc.getString("feature_s"));
689
			} catch (Exception e) {
717
			} catch (Exception e) {
690
				ffdr.setFeature(null);
718
				ffdr.setFeature(null);
691
				logger.info("Could not find Feature_s for {}", ffdr.getCatalogId());
-
 
692
			}
719
			}
693
			ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
720
			ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
694
			if (doc.has("_childDocuments_")) {
721
			if (doc.has("_childDocuments_")) {
695
				for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
722
				for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
696
					JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
723
					JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
Line 709... Line 736...
709
						fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
736
						fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
710
						fdi.setTagId(childItem.getInt("tagId_i"));
737
						fdi.setTagId(childItem.getInt("tagId_i"));
711
						fdi.setItem_id(itemId);
738
						fdi.setItem_id(itemId);
712
						Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
739
						Float cashBack = schemeService.getItemSchemeCashBack().get(itemId);
713
						cashBack = cashBack == null ? 0 : cashBack;
740
						cashBack = cashBack == null ? 0 : cashBack;
-
 
741
						//TODO:Dont commit
714
						fdi.setCashback(cashBack);
742
						fdi.setCashback(Math.min(100, fdi.getMop()));
715
						fdi.setMinBuyQuantity(1);
743
						fdi.setMinBuyQuantity(1);
716
						int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0
744
						int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0
717
								: partnerStockAvailabilityMap.get(itemId);
745
								: partnerStockAvailabilityMap.get(itemId);
718
						int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0
746
						int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0
719
								: Math.max(0, ourItemAvailabilityMap.get(itemId));
747
								: Math.max(0, ourItemAvailabilityMap.get(itemId));