Showing
1 changed file
with
169 additions
and
171 deletions
@@ -20,183 +20,181 @@ import java.util.Map; | @@ -20,183 +20,181 @@ import java.util.Map; | ||
20 | @Component | 20 | @Component |
21 | public class ProductILogicService { | 21 | public class ProductILogicService { |
22 | 22 | ||
23 | - private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class); | 23 | + private final Logger logger = LoggerFactory.getLogger(ProductILogicService.class); |
24 | 24 | ||
25 | - @Autowired | ||
26 | - private SpecialDealLogicService specialDealLogicService; | 25 | + @Autowired |
26 | + private SpecialDealLogicService specialDealLogicService; | ||
27 | 27 | ||
28 | - /** | ||
29 | - * 拼装ProductIBO数据(包含了product,brand,sort,shop几部分信息),全量增量都有调用 | ||
30 | - */ | ||
31 | - public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> productSortMap, Map<Integer, Brand> brandMap, | ||
32 | - Map<Integer, Shops> shopMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap) { | 28 | + /** |
29 | + * 拼装ProductIBO数据(包含了product,brand,sort,shop几部分信息),全量增量都有调用 | ||
30 | + */ | ||
31 | + public List<ProductIBO> buildProductIBO(List<Product> products, Map<Integer, ProductSort> productSortMap, Map<Integer, Brand> brandMap, | ||
32 | + Map<Integer, Shops> shopMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap) { | ||
33 | 33 | ||
34 | - long begin = System.currentTimeMillis(); | ||
35 | - List<ProductIBO> productIBOList = new ArrayList<>(); | 34 | + List<ProductIBO> productIBOList = new ArrayList<>(); |
36 | 35 | ||
37 | - for (Product p : products) { | ||
38 | - ProductIBO productIBO = new ProductIBO(); | ||
39 | - try { | ||
40 | - productIBO.setId(p.getId().toString()); | ||
41 | - productIBO.setProductId(p.getId()); | ||
42 | - productIBO.setProductSkn(p.getErpProductId()); | ||
43 | - productIBO.setShopId(p.getShopId()); | ||
44 | - productIBO.setSupplierId(p.getSupplierId()); | ||
45 | - productIBO.setProductName(p.getProductName()); | ||
46 | - productIBO.setSalesPhrase(p.getSalesPhrase()); | ||
47 | - productIBO.setMarketPhrase(p.getMarketPhrase()); | ||
48 | - productIBO.setBrandId(p.getBrandId()); | ||
49 | - productIBO.setMaxSortId(p.getMaxSortId()); | ||
50 | - productIBO.setMiddleSortId(p.getMiddleSortId()); | ||
51 | - productIBO.setSmallSortId(p.getSmallSortId()); | ||
52 | - productIBO.setSeriesId(p.getSeriesId()); | ||
53 | - productIBO.setIsSeckill("N"); | ||
54 | - productIBO.setBundleType(p.getBundleType()); | ||
55 | - if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) { | ||
56 | - productIBO.setIsSeckill("Y"); | ||
57 | - } | ||
58 | - productIBO.setStyle(p.getStyle()); | ||
59 | - productIBO.setPattern(p.getPattern()); | ||
60 | - productIBO.setPhrase(p.getPhrase()); | ||
61 | - productIBO.setIsPhraseExist("Y"); | ||
62 | - if (StringUtils.isBlank(p.getPhrase())) { | ||
63 | - productIBO.setIsPhraseExist("N"); | ||
64 | - } | ||
65 | - productIBO.setGender(p.getGender()); | ||
66 | - productIBO.setGenderS("男,女"); | ||
67 | - if (p.getGender() != null) { | ||
68 | - if (p.getGender().equals("1")) { | ||
69 | - productIBO.setGenderS("男"); | ||
70 | - } | ||
71 | - if (p.getGender().equals("2")) { | ||
72 | - productIBO.setGenderS("女"); | ||
73 | - } | ||
74 | - } | ||
75 | - productIBO.setIslimited("N"); | ||
76 | - if ("Y".equals(p.getIsLimited())) { | ||
77 | - productIBO.setIslimited("Y"); | ||
78 | - } | ||
79 | - productIBO.setIsSpecial("N"); | ||
80 | - if ("Y".equals(p.getIsSpecial())) { | ||
81 | - productIBO.setIsSpecial("Y"); | ||
82 | - } | ||
83 | - productIBO.setIsSales("Y"); | ||
84 | - if ("N".equals(p.getIsSales())) { | ||
85 | - productIBO.setIsSales("N"); | ||
86 | - } | ||
87 | - productIBO.setIsAdvance("N"); | ||
88 | - if ("Y".equals(p.getIsAdvance())) { | ||
89 | - productIBO.setIsAdvance("Y"); | ||
90 | - } | ||
91 | - productIBO.setIsOutlets(2); | ||
92 | - if ("Y".equals(p.getIsOutlets())) { | ||
93 | - productIBO.setIsOutlets(1); | ||
94 | - } | ||
95 | - productIBO.setIsLimitbuy("N"); | ||
96 | - if ("Y".equals(p.getIsLimitbuy())) { | ||
97 | - productIBO.setIsLimitbuy("Y"); | ||
98 | - } | ||
99 | - productIBO.setIsInstalment("0"); | ||
100 | - if ("1".equals(p.getIsInstalment())) { | ||
101 | - productIBO.setIsInstalment("1"); | ||
102 | - } | ||
103 | - productIBO.setIsSeckill("N"); | ||
104 | - if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) { | ||
105 | - productIBO.setIsSeckill("Y"); | ||
106 | - } | ||
107 | - productIBO.setIsDepositAdvance("N"); | ||
108 | - if ("Y".equals(p.getIsDepositAdvance())) { | ||
109 | - productIBO.setIsDepositAdvance("Y"); | ||
110 | - } | ||
111 | - productIBO.setIspromotion(p.getIsPromotion()); | ||
112 | - productIBO.setAttribute(p.getAttribute()); | ||
113 | - productIBO.setSeasons(p.getSeasons()); | ||
114 | - productIBO.setFirstShelveTime(p.getFirstShelveTime()); | ||
115 | - productIBO.setShelveTime(p.getShelveTime()); | ||
116 | - String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd"); | ||
117 | - productIBO.setShelveDay(shelveDay); | ||
118 | - if (p.getShelveTime() == 0) { | ||
119 | - productIBO.setShelveDay("0"); | ||
120 | - } | ||
121 | - productIBO.setEditTime(p.getEditTime()); | ||
122 | - productIBO.setStatus(p.getStatus()); | ||
123 | - productIBO.setFolderId(p.getFolderId()); | ||
124 | - productIBO.setSellChannels(p.getSellChannels()); | ||
125 | - productIBO.setAgeLevel(p.getAgeLevel()); | ||
126 | - productIBO.setAppType(p.getAppType()); | ||
127 | - productIBO.setCouponLimitStatus(p.getCouponLimitStatus()); | ||
128 | - productIBO.setIsFobbiden(p.getIsFobbiden()); | ||
129 | - productIBO.setStoreShowStatus(p.getStoreShowStatus()); | ||
130 | - productIBO.setIsLimitTimeAdvance(p.getIsLimitTimeAdvance()); | ||
131 | - productIBO.setSellType(p.getSellType()); | ||
132 | - // 品牌 | ||
133 | - this.buildBrand(brandMap, csBrandKeywordMap, p, productIBO); | ||
134 | - // 品类 | ||
135 | - this.buildSort(productSortMap, p, productIBO); | ||
136 | - // 店铺 | ||
137 | - this.buildShop(shopMap, p, productIBO); | ||
138 | - // 增加一些特殊处理的逻辑 | ||
139 | - specialDealLogicService.specialDealForProductIBO(productIBO); | ||
140 | - productIBOList.add(productIBO); | ||
141 | - } catch (Exception e) { | ||
142 | - logger.error("[fun=buildProductIBO][" + p.getId() + "]" + e.getMessage(), e); | ||
143 | - } | ||
144 | - } | ||
145 | - logger.info("[fun=buildProductIBO],[cost: {}]", System.currentTimeMillis() - begin); | ||
146 | - return productIBOList; | ||
147 | - } | 36 | + for (Product p : products) { |
37 | + ProductIBO productIBO = new ProductIBO(); | ||
38 | + try { | ||
39 | + productIBO.setId(p.getId().toString()); | ||
40 | + productIBO.setProductId(p.getId()); | ||
41 | + productIBO.setProductSkn(p.getErpProductId()); | ||
42 | + productIBO.setShopId(p.getShopId()); | ||
43 | + productIBO.setSupplierId(p.getSupplierId()); | ||
44 | + productIBO.setProductName(p.getProductName()); | ||
45 | + productIBO.setSalesPhrase(p.getSalesPhrase()); | ||
46 | + productIBO.setMarketPhrase(p.getMarketPhrase()); | ||
47 | + productIBO.setBrandId(p.getBrandId()); | ||
48 | + productIBO.setMaxSortId(p.getMaxSortId()); | ||
49 | + productIBO.setMiddleSortId(p.getMiddleSortId()); | ||
50 | + productIBO.setSmallSortId(p.getSmallSortId()); | ||
51 | + productIBO.setSeriesId(p.getSeriesId()); | ||
52 | + productIBO.setIsSeckill("N"); | ||
53 | + productIBO.setBundleType(p.getBundleType()); | ||
54 | + if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) { | ||
55 | + productIBO.setIsSeckill("Y"); | ||
56 | + } | ||
57 | + productIBO.setStyle(p.getStyle()); | ||
58 | + productIBO.setPattern(p.getPattern()); | ||
59 | + productIBO.setPhrase(p.getPhrase()); | ||
60 | + productIBO.setIsPhraseExist("Y"); | ||
61 | + if (StringUtils.isBlank(p.getPhrase())) { | ||
62 | + productIBO.setIsPhraseExist("N"); | ||
63 | + } | ||
64 | + productIBO.setGender(p.getGender()); | ||
65 | + productIBO.setGenderS("男,女"); | ||
66 | + if (p.getGender() != null) { | ||
67 | + if (p.getGender().equals("1")) { | ||
68 | + productIBO.setGenderS("男"); | ||
69 | + } | ||
70 | + if (p.getGender().equals("2")) { | ||
71 | + productIBO.setGenderS("女"); | ||
72 | + } | ||
73 | + } | ||
74 | + productIBO.setIslimited("N"); | ||
75 | + if ("Y".equals(p.getIsLimited())) { | ||
76 | + productIBO.setIslimited("Y"); | ||
77 | + } | ||
78 | + productIBO.setIsSpecial("N"); | ||
79 | + if ("Y".equals(p.getIsSpecial())) { | ||
80 | + productIBO.setIsSpecial("Y"); | ||
81 | + } | ||
82 | + productIBO.setIsSales("Y"); | ||
83 | + if ("N".equals(p.getIsSales())) { | ||
84 | + productIBO.setIsSales("N"); | ||
85 | + } | ||
86 | + productIBO.setIsAdvance("N"); | ||
87 | + if ("Y".equals(p.getIsAdvance())) { | ||
88 | + productIBO.setIsAdvance("Y"); | ||
89 | + } | ||
90 | + productIBO.setIsOutlets(2); | ||
91 | + if ("Y".equals(p.getIsOutlets())) { | ||
92 | + productIBO.setIsOutlets(1); | ||
93 | + } | ||
94 | + productIBO.setIsLimitbuy("N"); | ||
95 | + if ("Y".equals(p.getIsLimitbuy())) { | ||
96 | + productIBO.setIsLimitbuy("Y"); | ||
97 | + } | ||
98 | + productIBO.setIsInstalment("0"); | ||
99 | + if ("1".equals(p.getIsInstalment())) { | ||
100 | + productIBO.setIsInstalment("1"); | ||
101 | + } | ||
102 | + productIBO.setIsSeckill("N"); | ||
103 | + if ("Y".equals(p.getIsSeckill()) || "1".equals(p.getIsSeckill())) { | ||
104 | + productIBO.setIsSeckill("Y"); | ||
105 | + } | ||
106 | + productIBO.setIsDepositAdvance("N"); | ||
107 | + if ("Y".equals(p.getIsDepositAdvance())) { | ||
108 | + productIBO.setIsDepositAdvance("Y"); | ||
109 | + } | ||
110 | + productIBO.setIspromotion(p.getIsPromotion()); | ||
111 | + productIBO.setAttribute(p.getAttribute()); | ||
112 | + productIBO.setSeasons(p.getSeasons()); | ||
113 | + productIBO.setFirstShelveTime(p.getFirstShelveTime()); | ||
114 | + productIBO.setShelveTime(p.getShelveTime()); | ||
115 | + String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd"); | ||
116 | + productIBO.setShelveDay(shelveDay); | ||
117 | + if (p.getShelveTime() == 0) { | ||
118 | + productIBO.setShelveDay("0"); | ||
119 | + } | ||
120 | + productIBO.setEditTime(p.getEditTime()); | ||
121 | + productIBO.setStatus(p.getStatus()); | ||
122 | + productIBO.setFolderId(p.getFolderId()); | ||
123 | + productIBO.setSellChannels(p.getSellChannels()); | ||
124 | + productIBO.setAgeLevel(p.getAgeLevel()); | ||
125 | + productIBO.setAppType(p.getAppType()); | ||
126 | + productIBO.setCouponLimitStatus(p.getCouponLimitStatus()); | ||
127 | + productIBO.setIsFobbiden(p.getIsFobbiden()); | ||
128 | + productIBO.setStoreShowStatus(p.getStoreShowStatus()); | ||
129 | + productIBO.setIsLimitTimeAdvance(p.getIsLimitTimeAdvance()); | ||
130 | + productIBO.setSellType(p.getSellType()); | ||
131 | + // 品牌 | ||
132 | + this.buildBrand(brandMap, csBrandKeywordMap, p, productIBO); | ||
133 | + // 品类 | ||
134 | + this.buildSort(productSortMap, p, productIBO); | ||
135 | + // 店铺 | ||
136 | + this.buildShop(shopMap, p, productIBO); | ||
137 | + // 增加一些特殊处理的逻辑 | ||
138 | + specialDealLogicService.specialDealForProductIBO(productIBO); | ||
139 | + productIBOList.add(productIBO); | ||
140 | + } catch (Exception e) { | ||
141 | + logger.error("[fun=buildProductIBO][" + p.getId() + "]" + e.getMessage(), e); | ||
142 | + } | ||
143 | + } | ||
144 | + return productIBOList; | ||
145 | + } | ||
148 | 146 | ||
149 | - private void buildBrand(Map<Integer, Brand> brandMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap, Product p, ProductIBO productIBO) { | ||
150 | - Brand brand = brandMap.get(p.getBrandId()); | ||
151 | - CsBrandKeyword csBrandKeyword = csBrandKeywordMap.get(p.getBrandId()); | ||
152 | - if (brand != null) { | ||
153 | - productIBO.setBrandNameCn(brand.getBrandNameCn()); | ||
154 | - productIBO.setBrandNameEn(brand.getBrandNameEn()); | ||
155 | - productIBO.setBrandKeyword(brand.getBrandKeyword()); | ||
156 | - productIBO.setBrandName(brand.getBrandName()); | ||
157 | - productIBO.setBrandDomain(brand.getBrandDomain()); | ||
158 | - productIBO.setBrandAlif(BrandNameUtils.genBrandAlif(brand.getBrandName(),brand.getBrandNameCn())); | ||
159 | - productIBO.setCountryId(brand.getCountryId()); | ||
160 | - } | ||
161 | - if (csBrandKeyword != null) { | ||
162 | - productIBO.setCsBrandKeyword(csBrandKeyword.getKeyword()); | ||
163 | - } | ||
164 | - } | 147 | + private void buildBrand(Map<Integer, Brand> brandMap, Map<Integer, CsBrandKeyword> csBrandKeywordMap, Product p, ProductIBO productIBO) { |
148 | + Brand brand = brandMap.get(p.getBrandId()); | ||
149 | + CsBrandKeyword csBrandKeyword = csBrandKeywordMap.get(p.getBrandId()); | ||
150 | + if (brand != null) { | ||
151 | + productIBO.setBrandNameCn(brand.getBrandNameCn()); | ||
152 | + productIBO.setBrandNameEn(brand.getBrandNameEn()); | ||
153 | + productIBO.setBrandKeyword(brand.getBrandKeyword()); | ||
154 | + productIBO.setBrandName(brand.getBrandName()); | ||
155 | + productIBO.setBrandDomain(brand.getBrandDomain()); | ||
156 | + productIBO.setBrandAlif(BrandNameUtils.genBrandAlif(brand.getBrandName(), brand.getBrandNameCn())); | ||
157 | + productIBO.setCountryId(brand.getCountryId()); | ||
158 | + } | ||
159 | + if (csBrandKeyword != null) { | ||
160 | + productIBO.setCsBrandKeyword(csBrandKeyword.getKeyword()); | ||
161 | + } | ||
162 | + } | ||
165 | 163 | ||
166 | - private void buildSort(Map<Integer, ProductSort> ProductSortMap, Product p, ProductIBO productIBO) { | ||
167 | - ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId()); | ||
168 | - if (productSortMax != null) { | ||
169 | - productIBO.setMaxSort(productSortMax.getSortName()); | ||
170 | - productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy()); | ||
171 | - } else { | ||
172 | - productIBO.setMaxSort(""); | ||
173 | - productIBO.setMaxSortName(""); | ||
174 | - } | ||
175 | - ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId()); | ||
176 | - if (productSortMiddle != null) { | ||
177 | - productIBO.setMiddleSort(productSortMiddle.getSortName()); | ||
178 | - productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy()); | ||
179 | - } else { | ||
180 | - productIBO.setMiddleSort(""); | ||
181 | - productIBO.setMiddleSortName(""); | ||
182 | - } | ||
183 | - ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId()); | ||
184 | - if (productSortSmall != null) { | ||
185 | - productIBO.setSmallSort(productSortSmall.getSortName()); | ||
186 | - productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy()); | ||
187 | - } else { | ||
188 | - productIBO.setSmallSort(""); | ||
189 | - productIBO.setSmallSortName(""); | ||
190 | - } | ||
191 | - } | 164 | + private void buildSort(Map<Integer, ProductSort> ProductSortMap, Product p, ProductIBO productIBO) { |
165 | + ProductSort productSortMax = ProductSortMap.get(p.getMaxSortId()); | ||
166 | + if (productSortMax != null) { | ||
167 | + productIBO.setMaxSort(productSortMax.getSortName()); | ||
168 | + productIBO.setMaxSortName(p.getMaxSortId() + ":" + productSortMax.getSortName() + ":" + productSortMax.getOrderBy()); | ||
169 | + } else { | ||
170 | + productIBO.setMaxSort(""); | ||
171 | + productIBO.setMaxSortName(""); | ||
172 | + } | ||
173 | + ProductSort productSortMiddle = ProductSortMap.get(p.getMiddleSortId()); | ||
174 | + if (productSortMiddle != null) { | ||
175 | + productIBO.setMiddleSort(productSortMiddle.getSortName()); | ||
176 | + productIBO.setMiddleSortName(p.getMiddleSortId() + ":" + productSortMiddle.getSortName() + ":" + productSortMiddle.getOrderBy()); | ||
177 | + } else { | ||
178 | + productIBO.setMiddleSort(""); | ||
179 | + productIBO.setMiddleSortName(""); | ||
180 | + } | ||
181 | + ProductSort productSortSmall = ProductSortMap.get(p.getSmallSortId()); | ||
182 | + if (productSortSmall != null) { | ||
183 | + productIBO.setSmallSort(productSortSmall.getSortName()); | ||
184 | + productIBO.setSmallSortName(p.getSmallSortId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy()); | ||
185 | + } else { | ||
186 | + productIBO.setSmallSort(""); | ||
187 | + productIBO.setSmallSortName(""); | ||
188 | + } | ||
189 | + } | ||
192 | 190 | ||
193 | - private void buildShop(Map<Integer, Shops> shopMap, Product p, ProductIBO productIBO) { | ||
194 | - Shops shops = shopMap.get(p.getShopId()); | ||
195 | - if (shops != null) { | ||
196 | - productIBO.setShopName(shops.getShopName()); | ||
197 | - productIBO.setShopDomain(shops.getShopDomain()); | ||
198 | - productIBO.setShopCreateTime(shops.getCreateTime()); | ||
199 | - } | ||
200 | - } | 191 | + private void buildShop(Map<Integer, Shops> shopMap, Product p, ProductIBO productIBO) { |
192 | + Shops shops = shopMap.get(p.getShopId()); | ||
193 | + if (shops != null) { | ||
194 | + productIBO.setShopName(shops.getShopName()); | ||
195 | + productIBO.setShopDomain(shops.getShopDomain()); | ||
196 | + productIBO.setShopCreateTime(shops.getCreateTime()); | ||
197 | + } | ||
198 | + } | ||
201 | 199 | ||
202 | } | 200 | } |
-
Please register or login to post a comment