Subversion Repositories SmartDukaan

Rev

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

Rev 32717 Rev 32978
Line 16... Line 16...
16
import com.spice.profitmandi.common.web.client.RestClient;
16
import com.spice.profitmandi.common.web.client.RestClient;
17
import com.spice.profitmandi.common.web.util.ResponseSender;
17
import com.spice.profitmandi.common.web.util.ResponseSender;
18
import com.spice.profitmandi.dao.entity.catalog.*;
18
import com.spice.profitmandi.dao.entity.catalog.*;
19
import com.spice.profitmandi.dao.entity.dtr.WebListing;
19
import com.spice.profitmandi.dao.entity.dtr.WebListing;
20
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
20
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
21
import com.spice.profitmandi.dao.entity.dtr.WebProductListing;
-
 
22
import com.spice.profitmandi.dao.entity.fofo.CatalogFavourite;
21
import com.spice.profitmandi.dao.entity.fofo.CatalogFavourite;
23
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
22
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
24
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
23
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
25
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
24
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
26
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
25
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
Line 29... Line 28...
29
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
28
import com.spice.profitmandi.dao.enumuration.dtr.WebListingType;
30
import com.spice.profitmandi.dao.model.AmountModel;
29
import com.spice.profitmandi.dao.model.AmountModel;
31
import com.spice.profitmandi.dao.model.CreateOfferRequest;
30
import com.spice.profitmandi.dao.model.CreateOfferRequest;
32
import com.spice.profitmandi.dao.model.UserCart;
31
import com.spice.profitmandi.dao.model.UserCart;
33
import com.spice.profitmandi.dao.repository.catalog.*;
32
import com.spice.profitmandi.dao.repository.catalog.*;
34
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
35
import com.spice.profitmandi.dao.repository.dtr.Mongo;
33
import com.spice.profitmandi.dao.repository.dtr.*;
36
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
-
 
37
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
-
 
38
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
-
 
39
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
-
 
40
import com.spice.profitmandi.dao.repository.fofo.CatalogFavouriteRepository;
34
import com.spice.profitmandi.dao.repository.fofo.CatalogFavouriteRepository;
41
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
35
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
42
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
36
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
43
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
37
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
44
import com.spice.profitmandi.service.authentication.RoleManager;
38
import com.spice.profitmandi.service.authentication.RoleManager;
45
import com.spice.profitmandi.service.catalog.BrandsService;
39
import com.spice.profitmandi.service.catalog.BrandsService;
46
import com.spice.profitmandi.service.inventory.*;
40
import com.spice.profitmandi.service.inventory.*;
47
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
-
 
48
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
41
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
49
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
42
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
50
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
43
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
51
import com.spice.profitmandi.service.pricing.PricingService;
44
import com.spice.profitmandi.service.pricing.PricingService;
52
import com.spice.profitmandi.service.scheme.SchemeService;
45
import com.spice.profitmandi.service.scheme.SchemeService;
Line 62... Line 55...
62
import org.apache.logging.log4j.Logger;
55
import org.apache.logging.log4j.Logger;
63
import org.json.JSONArray;
56
import org.json.JSONArray;
64
import org.json.JSONObject;
57
import org.json.JSONObject;
65
import org.springframework.beans.factory.annotation.Autowired;
58
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.beans.factory.annotation.Value;
59
import org.springframework.beans.factory.annotation.Value;
67
import org.springframework.cglib.core.Local;
-
 
68
import org.springframework.http.HttpStatus;
60
import org.springframework.http.HttpStatus;
69
import org.springframework.http.MediaType;
61
import org.springframework.http.MediaType;
70
import org.springframework.http.ResponseEntity;
62
import org.springframework.http.ResponseEntity;
71
import org.springframework.stereotype.Controller;
63
import org.springframework.stereotype.Controller;
72
import org.springframework.transaction.annotation.Transactional;
64
import org.springframework.transaction.annotation.Transactional;
Line 74... Line 66...
74
import org.springframework.web.bind.annotation.RequestMapping;
66
import org.springframework.web.bind.annotation.RequestMapping;
75
import org.springframework.web.bind.annotation.RequestMethod;
67
import org.springframework.web.bind.annotation.RequestMethod;
76
import org.springframework.web.bind.annotation.RequestParam;
68
import org.springframework.web.bind.annotation.RequestParam;
77
 
69
 
78
import javax.servlet.http.HttpServletRequest;
70
import javax.servlet.http.HttpServletRequest;
79
 
-
 
80
import java.time.LocalDate;
71
import java.time.LocalDate;
81
import java.time.LocalDateTime;
72
import java.time.LocalDateTime;
82
import java.util.*;
73
import java.util.*;
83
import java.util.concurrent.atomic.AtomicInteger;
74
import java.util.concurrent.atomic.AtomicInteger;
84
import java.util.stream.Collectors;
75
import java.util.stream.Collectors;
Line 149... Line 140...
149
 
140
 
150
    @Autowired
141
    @Autowired
151
    private RoleManager roleManagerService;
142
    private RoleManager roleManagerService;
152
 
143
 
153
    @Autowired
144
    @Autowired
154
    private SuggestedPoDetailRepository monthlyPoDetailRepository;
145
    private SuggestedPoDetailRepository suggestedPoDetailRepository;
155
 
146
 
156
    @Autowired
147
    @Autowired
157
    private SuggestedPoRepository suggestedPoRepository;
148
    private SuggestedPoRepository suggestedPoRepository;
158
 
149
 
159
    @Autowired
150
    @Autowired
Line 217... Line 208...
217
    }
208
    }
218
 
209
 
219
    @RequestMapping(value = "/fofo/suggestedPo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
210
    @RequestMapping(value = "/fofo/suggestedPo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
220
    public ResponseEntity<?> getSuggestedPo(HttpServletRequest request, @RequestParam int id) throws ProfitMandiBusinessException {
211
    public ResponseEntity<?> getSuggestedPo(HttpServletRequest request, @RequestParam int id) throws ProfitMandiBusinessException {
221
 
212
 
222
        List<SuggestedPoDetail> mpd = monthlyPoDetailRepository.selectByPoId(id);
213
        List<SuggestedPoDetail> mpd = suggestedPoDetailRepository.selectByPoId(id);
223
        Map<Integer, Integer> itemIdsQtyMap = mpd.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getQuantity()));
214
        Map<Integer, Integer> itemIdsQtyMap = mpd.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getQuantity()));
224
 
215
 
225
        Set<Integer> catalogIds = itemRepository.selectByIds(itemIdsQtyMap.keySet()).stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
216
        Set<Integer> catalogIds = itemRepository.selectByIds(itemIdsQtyMap.keySet()).stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
226
        RestClient rc = new RestClient();
217
        RestClient rc = new RestClient();
227
        Map<String, String> params = new HashMap<>();
218
        Map<String, String> params = new HashMap<>();
Line 306... Line 297...
306
            catalogFavourite.setCatalogId(catalogId);
297
            catalogFavourite.setCatalogId(catalogId);
307
            catalogFavourite.setFofoId(fofoId);
298
            catalogFavourite.setFofoId(fofoId);
308
            catalogFavourite.setCreatedTimestamp(LocalDateTime.now());
299
            catalogFavourite.setCreatedTimestamp(LocalDateTime.now());
309
            catalogFavouriteRepository.persist(catalogFavourite);
300
            catalogFavouriteRepository.persist(catalogFavourite);
310
 
301
 
311
        }
-
 
312
 
-
 
313
        else {
302
        } else {
314
            catalogFavouriteRepository.deleteByPartnerAndCatalogId(fofoId, catalogId);
303
            catalogFavouriteRepository.deleteByPartnerAndCatalogId(fofoId, catalogId);
315
        }
304
        }
316
        return responseSender.ok(true);
305
        return responseSender.ok(true);
317
    }
306
    }
318
 
307
 
Line 812... Line 801...
812
                        String poColor = "grey";
801
                        String poColor = "grey";
813
                        boolean active = false;
802
                        boolean active = false;
814
                        if (currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) > 0) {
803
                        if (currentAvailability != null && currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) > 0) {
815
                            poColor = "green";
804
                            poColor = "green";
816
                            modelColorClass = "green";
805
                            modelColorClass = "green";
817
                        } else
-
 
818
                            if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
806
                        } else if (poItemAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) > 0) {
819
                                if (currentAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) + currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) <= 0) {
807
                            if (currentAvailability != null && poItemAvailability.stream().collect(Collectors.summingInt(SaholicPOItem::getUnfulfilledQty)) + currentAvailability.stream().collect(Collectors.summingInt(SaholicCISTable::getNetAvailability)) <= 0) {
820
                                    poColor = "grey";
808
                                poColor = "grey";
821
                                } else {
809
                            } else {
822
                                    poColor = "yellow";
810
                                poColor = "yellow";
823
                                    if (modelColorClass != "green") {
811
                                if (modelColorClass != "green") {
824
                                        modelColorClass = poColor;
812
                                    modelColorClass = poColor;
825
                                    }
-
 
826
                                }
813
                                }
827
                            }
814
                            }
-
 
815
                        }
828
                        fdi.setColorClass(poColor);
816
                        fdi.setColorClass(poColor);
829
                        fdi.setSellingPrice(sellingPrice);
817
                        fdi.setSellingPrice(sellingPrice);
830
                        fdi.setActive(active);
818
                        fdi.setActive(active);
831
                        fdi.setMrp(childItem.getDouble("mrp_f"));
819
                        fdi.setMrp(childItem.getDouble("mrp_f"));
832
                        fdi.setMop((float) childItem.getDouble("mop_f"));
820
                        fdi.setMop((float) childItem.getDouble("mop_f"));
Line 834... Line 822...
834
                        if (fdi.getColor().equalsIgnoreCase("any colour")) {
822
                        if (fdi.getColor().equalsIgnoreCase("any colour")) {
835
                            fdiAnyColour = fdi;
823
                            fdiAnyColour = fdi;
836
                        }
824
                        }
837
                        fdi.setTagId(childItem.getInt("tagId_i"));
825
                        fdi.setTagId(childItem.getInt("tagId_i"));
838
                        fdi.setItem_id(itemId);
826
                        fdi.setItem_id(itemId);
839
                        Float cashBack = schemeService.getCatalogSchemeCashBack().get(fofoCatalogResponse.getCatalogId());
827
                        Float cashBack = schemeService.getCatalogSchemeCashBack(fofoId, Arrays.asList(fofoCatalogResponse.getCatalogId())).get(fofoCatalogResponse.getCatalogId());
840
                        cashBack = cashBack == null ? 0 : cashBack;
828
                        cashBack = cashBack == null ? 0 : cashBack;
841
                        fdi.setCashback(cashBack);
829
                        fdi.setCashback(cashBack);
842
                        fdi.setMinBuyQuantity(1);
830
                        fdi.setMinBuyQuantity(1);
843
                        if (hotDeal) {
831
                        if (hotDeal) {
844
                            if (currentAvailability != null) {
832
                            if (currentAvailability != null) {