fix getProductMap use ProductIndexEsField
Showing
1 changed file
with
70 additions
and
63 deletions
1 | package com.yoho.search.service.service.helper; | 1 | package com.yoho.search.service.service.helper; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONArray; | ||
3 | import com.yoho.search.base.utils.ConvertUtils; | 4 | import com.yoho.search.base.utils.ConvertUtils; |
4 | import com.yoho.search.base.utils.DateUtil; | 5 | import com.yoho.search.base.utils.DateUtil; |
5 | import com.yoho.search.base.utils.ISearchConstants; | 6 | import com.yoho.search.base.utils.ISearchConstants; |
@@ -680,84 +681,90 @@ public class SearchServiceHelper { | @@ -680,84 +681,90 @@ public class SearchServiceHelper { | ||
680 | Map<String, Object> productMap = new HashMap<String, Object>(); | 681 | Map<String, Object> productMap = new HashMap<String, Object>(); |
681 | if (map.containsKey("_highlight") && map.get("_highlight") != null) { | 682 | if (map.containsKey("_highlight") && map.get("_highlight") != null) { |
682 | Map<String, Object> highlightMap = (Map<String, Object>) map.get("_highlight"); | 683 | Map<String, Object> highlightMap = (Map<String, Object>) map.get("_highlight"); |
683 | - if (highlightMap.containsKey("productName.productName_ansj")) { | ||
684 | - productMap.put("product_name_highlight", highlightMap.getOrDefault("productName.productName_ansj", "")); | 684 | + if (highlightMap.containsKey(ProductIndexEsField.productName_productName_ansj)) { |
685 | + productMap.put("product_name_highlight", highlightMap.getOrDefault(ProductIndexEsField.productName_productName_ansj, "")); | ||
685 | } | 686 | } |
686 | } | 687 | } |
687 | - productMap.put("product_name", map.getOrDefault("productName", "")); | ||
688 | - productMap.put("brand_name", map.getOrDefault("brandName", "")); | ||
689 | - productMap.put("brand_domain", map.get("brandDomain")); | ||
690 | - productMap.put("market_price", map.get("marketPrice")); | ||
691 | - productMap.put("brand_id", map.get("brandId")); | ||
692 | - productMap.put("shop_id", map.get("shopId")); | ||
693 | - productMap.put("vip_price", map.get("vipPrice")); | ||
694 | - productMap.put("vip1_price", map.get("vip1Price")); | ||
695 | - productMap.put("vip2_price", map.get("vip2Price")); | ||
696 | - productMap.put("vip3_price", map.get("vip3Price")); | ||
697 | - productMap.put("sales_price", map.get("salesPrice")); | ||
698 | - productMap.put("vip_discount_type", map.get("vipDiscountType")); | ||
699 | - productMap.put("product_id", map.get("productId")); | ||
700 | - productMap.put("product_skn", map.get("productSkn")); | ||
701 | - productMap.put("goods_list", map.get("goodsList")); | ||
702 | - productMap.put("is_new", map.get("isnew")); | ||
703 | - productMap.put("is_advance", map.get("isAdvance")); | ||
704 | - productMap.put("is_deposit_advance", map.get("isDepositAdvance")); | ||
705 | - productMap.put("first_shelve_time", map.get("firstShelveTime")); | ||
706 | - productMap.put("is_seckill", map.get("isSeckill")); | ||
707 | - productMap.put("is_limitbuy", map.get("isLimitbuy")); | ||
708 | - productMap.put("is_limited", map.get("islimited")); | ||
709 | - productMap.put("stock_number", map.get("storageNum")); | ||
710 | - productMap.put("is_outlets", map.get("isOutlets")); | ||
711 | - productMap.put("is_special", map.get("isSpecial")); | ||
712 | - productMap.put("gender", map.get("gender")); | ||
713 | - productMap.put("default_images", map.get("defaultImages")); | ||
714 | - productMap.put("middle_sort_id", map.get("middleSortId")); | ||
715 | - productMap.put("small_sort_id", map.get("smallSortId")); | ||
716 | - productMap.put("max_sort_id", map.get("maxSortId")); | ||
717 | - productMap.put("is_discount", map.get("isDiscount")); | ||
718 | - productMap.put("is_soon_sold_out", map.get("isSoonSoldOut")); | ||
719 | - productMap.put("edit_time", map.get("editTime")); | ||
720 | - productMap.put("shelve_time", map.get("shelveTime")); | ||
721 | - productMap.put("storage_num", map.get("storageNum")); | ||
722 | - productMap.put("sales_num", map.get("salesNum")); | ||
723 | - productMap.put("status", map.get("status")); | ||
724 | - productMap.put("is_promotion", map.get("ispromotion")); | ||
725 | - String yohoodIdFromMap = (String) map.get("yohoodId"); | ||
726 | - if (yohoodIdFromMap != null && yohoodIdFromMap.length() > 0) { | ||
727 | - productMap.put("yohood_id", yohoodIdFromMap); | ||
728 | - } else { | ||
729 | - productMap.put("yohood_id", null); | ||
730 | - } | ||
731 | - productMap.put("sales_phrase", map.get("salesPhrase")); | ||
732 | - | ||
733 | - String isStudentPrice = (String) map.get("isStudentPrice"); | 688 | + productMap.put("product_id", map.get(ProductIndexEsField.productId)); |
689 | + productMap.put("product_name", map.getOrDefault(ProductIndexEsField.productName, "")); | ||
690 | + productMap.put("product_skn", map.get(ProductIndexEsField.productSkn)); | ||
691 | + | ||
692 | + productMap.put("brand_id", map.get(ProductIndexEsField.brandId)); | ||
693 | + productMap.put("brand_name", map.getOrDefault(ProductIndexEsField.brandName, "")); | ||
694 | + productMap.put("brand_domain", map.get(ProductIndexEsField.brandDomain)); | ||
695 | + productMap.put("country_id", map.get(ProductIndexEsField.countryId)); | ||
696 | + | ||
697 | + productMap.put("shop_id", map.get(ProductIndexEsField.shopId)); | ||
698 | + productMap.put("shop_name", map.get(ProductIndexEsField.shopName)); | ||
699 | + productMap.put("shop_domain", map.get(ProductIndexEsField.shopDomain)); | ||
700 | + | ||
701 | + productMap.put("sales_price", map.get(ProductIndexEsField.salesPrice)); | ||
702 | + productMap.put("market_price", map.get(ProductIndexEsField.marketPrice)); | ||
703 | + productMap.put("vip_price", map.get(ProductIndexEsField.vipPrice)); | ||
704 | + productMap.put("vip1_price", map.get(ProductIndexEsField.vip1Price)); | ||
705 | + productMap.put("vip2_price", map.get(ProductIndexEsField.vip2Price)); | ||
706 | + productMap.put("vip3_price", map.get(ProductIndexEsField.vip3Price)); | ||
707 | + productMap.put("vip_discount_type", map.get(ProductIndexEsField.vipDiscountType)); | ||
708 | + | ||
709 | + productMap.put("default_images", map.getOrDefault(ProductIndexEsField.defaultImages, "")); | ||
710 | + productMap.put("skn_default_img", map.getOrDefault(ProductIndexEsField.sknDefaultImg, "")); | ||
711 | + | ||
712 | + productMap.put("edit_time", map.get(ProductIndexEsField.editTime)); | ||
713 | + productMap.put("shelve_time", map.get(ProductIndexEsField.shelveTime)); | ||
714 | + productMap.put("first_shelve_time", map.get(ProductIndexEsField.firstShelveTime)); | ||
715 | + | ||
716 | + productMap.put("max_sort_id", map.get(ProductIndexEsField.maxSortId)); | ||
717 | + productMap.put("middle_sort_id", map.get(ProductIndexEsField.middleSortId)); | ||
718 | + productMap.put("small_sort_id", map.get(ProductIndexEsField.smallSortId)); | ||
719 | + productMap.put("small_sort_name", map.get(ProductIndexEsField.smallSort)); | ||
720 | + | ||
721 | + productMap.put("stock_number", map.getOrDefault(ProductIndexEsField.storageNum, 0)); | ||
722 | + productMap.put("storage_num", map.getOrDefault(ProductIndexEsField.storageNum, 0)); | ||
723 | + productMap.put("sales_num", map.getOrDefault(ProductIndexEsField.salesNum, 0)); | ||
724 | + | ||
725 | + productMap.put("gender", map.get(ProductIndexEsField.gender)); | ||
726 | + productMap.put("age_level", map.getOrDefault(ProductIndexEsField.ageLevel, ""));// 年龄层,逗号隔开的字符串 | ||
727 | + productMap.put("sales_phrase", map.getOrDefault(ProductIndexEsField.salesPhrase, "")); | ||
728 | + productMap.put("status", map.getOrDefault(ProductIndexEsField.status, 0)); | ||
729 | + productMap.put("goods_list", map.getOrDefault(ProductIndexEsField.goodsList, new JSONArray())); | ||
730 | + | ||
731 | + productMap.put("is_new", map.getOrDefault(ProductIndexEsField.isnew, "N")); | ||
732 | + productMap.put("is_advance", map.getOrDefault(ProductIndexEsField.isAdvance, "N")); | ||
733 | + productMap.put("is_deposit_advance", map.getOrDefault(ProductIndexEsField.isDepositAdvance, "N")); | ||
734 | + productMap.put("is_seckill", map.getOrDefault(ProductIndexEsField.isSeckill, "N")); | ||
735 | + productMap.put("is_limitbuy", map.getOrDefault(ProductIndexEsField.isLimitbuy, "N")); | ||
736 | + productMap.put("is_limited", map.getOrDefault(ProductIndexEsField.islimited, "N")); | ||
737 | + productMap.put("is_outlets", map.getOrDefault(ProductIndexEsField.isOutlets, 2)); | ||
738 | + productMap.put("is_special", map.getOrDefault(ProductIndexEsField.isSpecial, "N")); | ||
739 | + productMap.put("is_discount", map.getOrDefault(ProductIndexEsField.isDiscount, "N")); | ||
740 | + productMap.put("is_soon_sold_out", map.getOrDefault(ProductIndexEsField.isSoonSoldOut, "N")); | ||
741 | + productMap.put("is_promotion", map.getOrDefault(ProductIndexEsField.ispromotion, 0)); | ||
742 | + | ||
743 | + // yohoodId | ||
744 | + String yohoodId = (String) map.getOrDefault(ProductIndexEsField.yohoodId, ""); | ||
745 | + productMap.put("yohood_id", StringUtils.isNotBlank(yohoodId) ? yohoodId : null); | ||
746 | + | ||
747 | + // 学生价和学生返币 | ||
748 | + productMap.put("is_student_rebate", map.getOrDefault(ProductIndexEsField.isstudentrebate, "N")); | ||
749 | + String isStudentPrice = (String) map.get(ProductIndexEsField.isStudentPrice); | ||
734 | productMap.put("is_student_price", isStudentPrice); | 750 | productMap.put("is_student_price", isStudentPrice); |
735 | if (isStudentPrice == null || isStudentPrice.equalsIgnoreCase("N")) { | 751 | if (isStudentPrice == null || isStudentPrice.equalsIgnoreCase("N")) { |
736 | productMap.put("student_price", null); | 752 | productMap.put("student_price", null); |
737 | } else { | 753 | } else { |
738 | - productMap.put("student_price", map.get("studentPrice")); | 754 | + productMap.put("student_price", map.get(ProductIndexEsField.studentPrice)); |
739 | } | 755 | } |
740 | - productMap.put("country_id", map.get("countryId")); | ||
741 | - // 是否学生返币 | ||
742 | - productMap.put("is_student_rebate", map.getOrDefault("isstudentrebate", "N")); | ||
743 | - // 年龄层,逗号隔开的字符串 | ||
744 | - productMap.put("age_level", map.getOrDefault("ageLevel", "")); | ||
745 | 756 | ||
746 | - // 是否是全球购商品 | ||
747 | - productMap.put("is_global", map.getOrDefault("isGlobal", "N")); | 757 | + // 全球购相关 |
758 | + productMap.put("is_global", map.getOrDefault(ProductIndexEsField.isGlobal, "N")); | ||
748 | Integer tbl_country_id = 0; | 759 | Integer tbl_country_id = 0; |
749 | try { | 760 | try { |
750 | - tbl_country_id = (Integer) map.get("tblCountryId"); | 761 | + tbl_country_id = (Integer) map.get(ProductIndexEsField.tblCountryId); |
751 | } catch (Exception e) { | 762 | } catch (Exception e) { |
752 | } | 763 | } |
753 | productMap.put("tbl_country_id", tbl_country_id); | 764 | productMap.put("tbl_country_id", tbl_country_id); |
754 | - productMap.put("tbl_country_name", map.get("tblCountryName")); | 765 | + productMap.put("tbl_country_name", map.get(ProductIndexEsField.tblCountryName)); |
755 | String tbl_plane = (tbl_country_id != null && tbl_country_id != 86) ? "Y" : "N"; | 766 | String tbl_plane = (tbl_country_id != null && tbl_country_id != 86) ? "Y" : "N"; |
756 | productMap.put("tbl_plane", tbl_plane); | 767 | productMap.put("tbl_plane", tbl_plane); |
757 | - productMap.put("skn_default_img", map.get("sknDefaultImg")); | ||
758 | - productMap.put("small_sort_name", map.get("smallSort")); | ||
759 | - productMap.put("shop_name", map.get("shopName")); | ||
760 | - productMap.put("shop_domain", map.get("shopDomain")); | ||
761 | 768 | ||
762 | // 一些特殊场景需要额外返回一些参数 | 769 | // 一些特殊场景需要额外返回一些参数 |
763 | if (extendedFields != null) { | 770 | if (extendedFields != null) { |
-
Please register or login to post a comment