Merge branch 'gray' into wn_lastReducePriceTime
# Conflicts: # index/src/main/resources/esmapping/productindex.json # service/src/main/java/com/yoho/search/consumer/service/base/ProductIndexService.java
Showing
12 changed files
with
156 additions
and
123 deletions
@@ -14,18 +14,12 @@ public interface ProductMapper { | @@ -14,18 +14,12 @@ public interface ProductMapper { | ||
14 | 14 | ||
15 | int updateByPrimaryKeySelective(Product record); | 15 | int updateByPrimaryKeySelective(Product record); |
16 | 16 | ||
17 | - int updateByPrimaryKey(Product record); | ||
18 | - | ||
19 | List<Product> selectPageLists(@Param(value = "offset") Integer offset, @Param(value = "pageSize") Integer pageSize); | 17 | List<Product> selectPageLists(@Param(value = "offset") Integer offset, @Param(value = "pageSize") Integer pageSize); |
20 | 18 | ||
21 | Integer selectProductIdBySkn(Integer productSkn); | 19 | Integer selectProductIdBySkn(Integer productSkn); |
22 | 20 | ||
23 | Integer selectSknByProductId(Integer productId); | 21 | Integer selectSknByProductId(Integer productId); |
24 | 22 | ||
25 | - List<Product> selectSknsByProductIds(List<Integer> productIds); | ||
26 | - | ||
27 | - List<Product> selectAll(); | ||
28 | - | ||
29 | int selectCount(); | 23 | int selectCount(); |
30 | 24 | ||
31 | Product selectBySkn(Integer skn); | 25 | Product selectBySkn(Integer skn); |
1 | <?xml version="1.0" encoding="UTF-8" ?> | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
3 | <mapper namespace="com.yoho.search.dal.ProductMapper"> | 3 | <mapper namespace="com.yoho.search.dal.ProductMapper"> |
4 | + | ||
4 | <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.Product"> | 5 | <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.Product"> |
5 | <id column="id" property="id" jdbcType="INTEGER"/> | 6 | <id column="id" property="id" jdbcType="INTEGER"/> |
6 | <result column="shop_id" property="shopId" jdbcType="INTEGER"/> | 7 | <result column="shop_id" property="shopId" jdbcType="INTEGER"/> |
@@ -56,7 +57,9 @@ | @@ -56,7 +57,9 @@ | ||
56 | <result column="is_seckill" property="isSeckill" jdbcType="CHAR"/> | 57 | <result column="is_seckill" property="isSeckill" jdbcType="CHAR"/> |
57 | <result column="market_phrase" property="marketPhrase" jdbcType="VARCHAR"/> | 58 | <result column="market_phrase" property="marketPhrase" jdbcType="VARCHAR"/> |
58 | <result column="bundle_type" property="bundleType" jdbcType="INTEGER"/> | 59 | <result column="bundle_type" property="bundleType" jdbcType="INTEGER"/> |
60 | + <result column="coupon_limit_status" property="couponLimitStatus" jdbcType="INTEGER"/> | ||
59 | </resultMap> | 61 | </resultMap> |
62 | + | ||
60 | <sql id="Base_Column_List"> | 63 | <sql id="Base_Column_List"> |
61 | id, erp_product_id,shop_id, product_name, cn_alphabet, | 64 | id, erp_product_id,shop_id, product_name, cn_alphabet, |
62 | phrase, sales_phrase, brand_id, max_sort_id, middle_sort_id, | 65 | phrase, sales_phrase, brand_id, max_sort_id, middle_sort_id, |
@@ -67,8 +70,9 @@ | @@ -67,8 +70,9 @@ | ||
67 | first_shelve_time,shelve_time,expect_arrival_time, create_time, arrival_time, | 70 | first_shelve_time,shelve_time,expect_arrival_time, create_time, arrival_time, |
68 | edit_time, auditing_time, is_down, status, is_edit, | 71 | edit_time, auditing_time, is_down, status, is_edit, |
69 | vip_discount_type, storage,is_outlets,folder_id,sell_channels, | 72 | vip_discount_type, storage,is_outlets,folder_id,sell_channels, |
70 | - elements, age_level,app_type,is_instalment,is_seckill,is_limitbuy,is_deposit_advance,market_phrase,bundle_type | 73 | + elements, age_level,app_type,is_instalment,is_seckill,is_limitbuy,is_deposit_advance,market_phrase,bundle_type,coupon_limit_status |
71 | </sql> | 74 | </sql> |
75 | + | ||
72 | <select id="selectByPrimaryKey" resultMap="BaseResultMap" | 76 | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
73 | parameterType="java.lang.Integer" timeout="20000"> | 77 | parameterType="java.lang.Integer" timeout="20000"> |
74 | select | 78 | select |
@@ -76,6 +80,7 @@ | @@ -76,6 +80,7 @@ | ||
76 | from product | 80 | from product |
77 | where id = #{id,jdbcType=INTEGER} | 81 | where id = #{id,jdbcType=INTEGER} |
78 | </select> | 82 | </select> |
83 | + | ||
79 | <select id="selectBySkn" resultMap="BaseResultMap" | 84 | <select id="selectBySkn" resultMap="BaseResultMap" |
80 | parameterType="java.lang.Integer" timeout="20000"> | 85 | parameterType="java.lang.Integer" timeout="20000"> |
81 | select | 86 | select |
@@ -84,11 +89,13 @@ | @@ -84,11 +89,13 @@ | ||
84 | where erp_product_id = #{skn,jdbcType=INTEGER} | 89 | where erp_product_id = #{skn,jdbcType=INTEGER} |
85 | limit 1 | 90 | limit 1 |
86 | </select> | 91 | </select> |
92 | + | ||
87 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" | 93 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" |
88 | timeout="20000"> | 94 | timeout="20000"> |
89 | delete from product | 95 | delete from product |
90 | where id = #{id,jdbcType=INTEGER} | 96 | where id = #{id,jdbcType=INTEGER} |
91 | </delete> | 97 | </delete> |
98 | + | ||
92 | <insert id="insert" parameterType="com.yoho.search.dal.model.Product" | 99 | <insert id="insert" parameterType="com.yoho.search.dal.model.Product" |
93 | timeout="20000"> | 100 | timeout="20000"> |
94 | insert ignore into product (id, erp_product_id,shop_id, | 101 | insert ignore into product (id, erp_product_id,shop_id, |
@@ -112,7 +119,7 @@ | @@ -112,7 +119,7 @@ | ||
112 | status, is_edit, vip_discount_type, | 119 | status, is_edit, vip_discount_type, |
113 | storage, | 120 | storage, |
114 | is_outlets, folder_id, | 121 | is_outlets, folder_id, |
115 | - sell_channels, elements,age_level,app_type,is_instalment,is_seckill,is_deposit_advance,is_limitbuy,market_phrase,bundle_type) | 122 | + sell_channels, elements,age_level,app_type,is_instalment,is_seckill,is_deposit_advance,is_limitbuy,market_phrase,bundle_type,coupon_limit_status) |
116 | values | 123 | values |
117 | (#{id,jdbcType=INTEGER}, | 124 | (#{id,jdbcType=INTEGER}, |
118 | #{erpProductId,jdbcType=INTEGER}, | 125 | #{erpProductId,jdbcType=INTEGER}, |
@@ -154,9 +161,11 @@ | @@ -154,9 +161,11 @@ | ||
154 | #{isDepositAdvance,jdbcType=CHAR}, | 161 | #{isDepositAdvance,jdbcType=CHAR}, |
155 | #{isLimitbuy,jdbcType=CHAR}, | 162 | #{isLimitbuy,jdbcType=CHAR}, |
156 | #{marketPhrase,jdbcType=VARCHAR}, | 163 | #{marketPhrase,jdbcType=VARCHAR}, |
157 | - #{bundleType,jdbcType=INTEGER} | 164 | + #{bundleType,jdbcType=INTEGER}, |
165 | + #{couponLimitStatus,jdbcType=INTEGER} | ||
158 | ) | 166 | ) |
159 | </insert> | 167 | </insert> |
168 | + | ||
160 | <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.Product" | 169 | <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.Product" |
161 | timeout="20000"> | 170 | timeout="20000"> |
162 | update product | 171 | update product |
@@ -321,34 +330,37 @@ | @@ -321,34 +330,37 @@ | ||
321 | <if test="bundleType != null"> | 330 | <if test="bundleType != null"> |
322 | bundle_type = #{bundleType,jdbcType=INTEGER}, | 331 | bundle_type = #{bundleType,jdbcType=INTEGER}, |
323 | </if> | 332 | </if> |
333 | + <if test="couponLimitStatus != null"> | ||
334 | + coupon_limit_status = #{couponLimitStatus,jdbcType=INTEGER}, | ||
335 | + </if> | ||
324 | </set> | 336 | </set> |
325 | where id = #{id,jdbcType=INTEGER} | 337 | where id = #{id,jdbcType=INTEGER} |
326 | </update> | 338 | </update> |
339 | + | ||
327 | <select id="selectCount" resultType="java.lang.Integer" timeout="20000"> | 340 | <select id="selectCount" resultType="java.lang.Integer" timeout="20000"> |
328 | SELECT count(*) FROM product | 341 | SELECT count(*) FROM product |
329 | </select> | 342 | </select> |
343 | + | ||
330 | <select id="selectProductIdBySkn" resultType="java.lang.Integer" | 344 | <select id="selectProductIdBySkn" resultType="java.lang.Integer" |
331 | parameterType="java.lang.Integer" timeout="20000"> | 345 | parameterType="java.lang.Integer" timeout="20000"> |
332 | SELECT id FROM product where | 346 | SELECT id FROM product where |
333 | erp_product_id = | 347 | erp_product_id = |
334 | #{productSkn,jdbcType=INTEGER} | 348 | #{productSkn,jdbcType=INTEGER} |
335 | </select> | 349 | </select> |
350 | + | ||
336 | <select id="selectSknByProductId" resultType="java.lang.Integer" | 351 | <select id="selectSknByProductId" resultType="java.lang.Integer" |
337 | parameterType="java.lang.Integer" timeout="20000"> | 352 | parameterType="java.lang.Integer" timeout="20000"> |
338 | SELECT erp_product_id FROM product where | 353 | SELECT erp_product_id FROM product where |
339 | id = | 354 | id = |
340 | #{id,jdbcType=INTEGER} | 355 | #{id,jdbcType=INTEGER} |
341 | </select> | 356 | </select> |
357 | + | ||
342 | <select id="selectPageLists" resultMap="BaseResultMap" timeout="20000"> | 358 | <select id="selectPageLists" resultMap="BaseResultMap" timeout="20000"> |
343 | select | 359 | select |
344 | <include refid="Base_Column_List"/> | 360 | <include refid="Base_Column_List"/> |
345 | from product limit #{offset},#{pageSize} | 361 | from product limit #{offset},#{pageSize} |
346 | </select> | 362 | </select> |
347 | - <select id="selectAll" resultMap="BaseResultMap" timeout="20000"> | ||
348 | - select | ||
349 | - <include refid="Base_Column_List"/> | ||
350 | - from product | ||
351 | - </select> | 363 | + |
352 | <select id="selectBySkns" resultMap="BaseResultMap"> | 364 | <select id="selectBySkns" resultMap="BaseResultMap"> |
353 | Select | 365 | Select |
354 | <include refid="Base_Column_List"/> | 366 | <include refid="Base_Column_List"/> |
@@ -358,6 +370,7 @@ | @@ -358,6 +370,7 @@ | ||
358 | #{item} | 370 | #{item} |
359 | </foreach> | 371 | </foreach> |
360 | </select> | 372 | </select> |
373 | + | ||
361 | <select id="selectListByIds" resultMap="BaseResultMap"> | 374 | <select id="selectListByIds" resultMap="BaseResultMap"> |
362 | select | 375 | select |
363 | <include refid="Base_Column_List"/> | 376 | <include refid="Base_Column_List"/> |
@@ -367,4 +380,5 @@ | @@ -367,4 +380,5 @@ | ||
367 | #{item} | 380 | #{item} |
368 | </foreach> | 381 | </foreach> |
369 | </select> | 382 | </select> |
383 | + | ||
370 | </mapper> | 384 | </mapper> |
@@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
29 | <![CDATA[ start_time <= #{currentTime,jdbcType=INTEGER} ]]> | 29 | <![CDATA[ start_time <= #{currentTime,jdbcType=INTEGER} ]]> |
30 | <![CDATA[ and end_time >= #{currentTime,jdbcType=INTEGER} ]]> | 30 | <![CDATA[ and end_time >= #{currentTime,jdbcType=INTEGER} ]]> |
31 | and status = 1 | 31 | and status = 1 |
32 | - and is_del = 'N' | 32 | + and is_del != 'Y' |
33 | </select> | 33 | </select> |
34 | 34 | ||
35 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | 35 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> |
@@ -25,7 +25,6 @@ | @@ -25,7 +25,6 @@ | ||
25 | open="(" separator="," close=")"> | 25 | open="(" separator="," close=")"> |
26 | #{item} | 26 | #{item} |
27 | </foreach> | 27 | </foreach> |
28 | - and is_del = 'N' | ||
29 | </select> | 28 | </select> |
30 | 29 | ||
31 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | 30 | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> |
1 | package com.yoho.search.consumer.index.increment; | 1 | package com.yoho.search.consumer.index.increment; |
2 | 2 | ||
3 | -import java.util.HashMap; | ||
4 | -import java.util.List; | ||
5 | -import java.util.Map; | ||
6 | -import java.util.UUID; | ||
7 | - | ||
8 | -import org.apache.commons.lang3.StringUtils; | ||
9 | -import org.slf4j.Logger; | ||
10 | -import org.slf4j.LoggerFactory; | ||
11 | -import org.springframework.amqp.core.Message; | ||
12 | -import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; | ||
13 | -import org.springframework.beans.factory.annotation.Autowired; | ||
14 | -import org.springframework.stereotype.Component; | ||
15 | - | ||
16 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
17 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
18 | import com.rabbitmq.client.Channel; | 5 | import com.rabbitmq.client.Channel; |
@@ -24,6 +11,18 @@ import com.yoho.search.consumer.service.base.ActivityProductService; | @@ -24,6 +11,18 @@ import com.yoho.search.consumer.service.base.ActivityProductService; | ||
24 | import com.yoho.search.consumer.service.base.ProductService; | 11 | import com.yoho.search.consumer.service.base.ProductService; |
25 | import com.yoho.search.core.es.utils.IgnoreSomeException; | 12 | import com.yoho.search.core.es.utils.IgnoreSomeException; |
26 | import com.yoho.search.dal.model.ActivityProduct; | 13 | import com.yoho.search.dal.model.ActivityProduct; |
14 | +import org.apache.commons.lang3.StringUtils; | ||
15 | +import org.slf4j.Logger; | ||
16 | +import org.slf4j.LoggerFactory; | ||
17 | +import org.springframework.amqp.core.Message; | ||
18 | +import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; | ||
19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
20 | +import org.springframework.stereotype.Component; | ||
21 | + | ||
22 | +import java.util.HashMap; | ||
23 | +import java.util.List; | ||
24 | +import java.util.Map; | ||
25 | +import java.util.UUID; | ||
27 | 26 | ||
28 | /** | 27 | /** |
29 | * Created by YOHO on 15-9-2. | 28 | * Created by YOHO on 15-9-2. |
@@ -1056,8 +1056,13 @@ | @@ -1056,8 +1056,13 @@ | ||
1056 | "productProfitValue": { | 1056 | "productProfitValue": { |
1057 | "type":"long" | 1057 | "type":"long" |
1058 | }, | 1058 | }, |
1059 | +<<<<<<< HEAD | ||
1059 | "lastReducePriceTime": { | 1060 | "lastReducePriceTime": { |
1060 | "type": "long" | 1061 | "type": "long" |
1062 | +======= | ||
1063 | + "couponLimitStatus": { | ||
1064 | + "type":"long" | ||
1065 | +>>>>>>> gray | ||
1061 | } | 1066 | } |
1062 | } | 1067 | } |
1063 | } | 1068 | } |
@@ -211,6 +211,7 @@ public class ProductIndexService { | @@ -211,6 +211,7 @@ public class ProductIndexService { | ||
211 | map.put(ProductIndexEsField.profitValue, productIndexBO.getProfitValue()); | 211 | map.put(ProductIndexEsField.profitValue, productIndexBO.getProfitValue()); |
212 | map.put(ProductIndexEsField.promotionTitle, productIndexBO.getPromotionTitles()); | 212 | map.put(ProductIndexEsField.promotionTitle, productIndexBO.getPromotionTitles()); |
213 | map.put(ProductIndexEsField.lastReducePriceTime, productIndexBO.getLastReducePriceTime()); | 213 | map.put(ProductIndexEsField.lastReducePriceTime, productIndexBO.getLastReducePriceTime()); |
214 | + map.put(ProductIndexEsField.couponLimitStatus, productIndexBO.getCouponLimitStatus()); | ||
214 | return map; | 215 | return map; |
215 | } | 216 | } |
216 | 217 |
@@ -62,6 +62,8 @@ public class ProductIBO implements Serializable { | @@ -62,6 +62,8 @@ public class ProductIBO implements Serializable { | ||
62 | private String isInstalment; | 62 | private String isInstalment; |
63 | private String isSeckill; | 63 | private String isSeckill; |
64 | private String marketPhrase; | 64 | private String marketPhrase; |
65 | + private Integer couponLimitStatus; | ||
66 | + | ||
65 | 67 | ||
66 | // inner join brand | 68 | // inner join brand |
67 | private String brandNameCn; | 69 | private String brandNameCn; |
@@ -689,4 +691,11 @@ public class ProductIBO implements Serializable { | @@ -689,4 +691,11 @@ public class ProductIBO implements Serializable { | ||
689 | this.isPhraseExist = isPhraseExist; | 691 | this.isPhraseExist = isPhraseExist; |
690 | } | 692 | } |
691 | 693 | ||
694 | + public Integer getCouponLimitStatus() { | ||
695 | + return couponLimitStatus; | ||
696 | + } | ||
697 | + | ||
698 | + public void setCouponLimitStatus(Integer couponLimitStatus) { | ||
699 | + this.couponLimitStatus = couponLimitStatus; | ||
700 | + } | ||
692 | } | 701 | } |
@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONArray; | @@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONArray; | ||
4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
5 | import com.yoho.search.dal.model.PromotionInfo; | 5 | import com.yoho.search.dal.model.PromotionInfo; |
6 | import com.yoho.search.dal.model.PromotionParams; | 6 | import com.yoho.search.dal.model.PromotionParams; |
7 | +import org.apache.commons.collections.CollectionUtils; | ||
7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
9 | import org.springframework.util.Assert; | 10 | import org.springframework.util.Assert; |
10 | 11 | ||
12 | +import java.util.ArrayList; | ||
11 | import java.util.Arrays; | 13 | import java.util.Arrays; |
12 | import java.util.List; | 14 | import java.util.List; |
13 | import java.util.stream.Collectors; | 15 | import java.util.stream.Collectors; |
@@ -17,7 +19,7 @@ import java.util.stream.Collectors; | @@ -17,7 +19,7 @@ import java.util.stream.Collectors; | ||
17 | */ | 19 | */ |
18 | public class PromotionCond { | 20 | public class PromotionCond { |
19 | 21 | ||
20 | - private final Logger INDEX_REBUILD_LOG = LoggerFactory.getLogger("INDEX_REBULDER"); | 22 | + private static final Logger INDEX_REBUILD_LOG = LoggerFactory.getLogger("INDEX_REBULDER"); |
21 | 23 | ||
22 | enum Aggregator { | 24 | enum Aggregator { |
23 | ALL, ANY; | 25 | ALL, ANY; |
@@ -118,19 +120,20 @@ public class PromotionCond { | @@ -118,19 +120,20 @@ public class PromotionCond { | ||
118 | Object condtionsObj = condDetailJSONObj.get("conditions"); | 120 | Object condtionsObj = condDetailJSONObj.get("conditions"); |
119 | if (condtionsObj instanceof JSONArray) { | 121 | if (condtionsObj instanceof JSONArray) { |
120 | JSONArray condItemsJSONArray = (JSONArray) condtionsObj; | 122 | JSONArray condItemsJSONArray = (JSONArray) condtionsObj; |
121 | - Assert.notEmpty(condItemsJSONArray, "condItemsJSONArray is empty."); | ||
122 | - this.condItemList = condItemsJSONArray.stream().map(obj -> (JSONObject) obj).map(CondItem::new).collect(Collectors.toList()); | 123 | + this.condItemList = condItemsJSONArray.isEmpty() ? new ArrayList<>() : |
124 | + condItemsJSONArray.stream().map(obj -> (JSONObject) obj).map(CondItem::new).collect(Collectors.toList()); | ||
123 | } else { | 125 | } else { |
124 | JSONObject condItemsJSONObj = (JSONObject) condtionsObj; | 126 | JSONObject condItemsJSONObj = (JSONObject) condtionsObj; |
125 | - Assert.notEmpty(condItemsJSONObj, "condItemsJSONObj is empty."); | ||
126 | - this.condItemList = condItemsJSONObj.keySet().stream().map(key -> condItemsJSONObj.getJSONObject(key)).map(CondItem::new).collect(Collectors.toList()); | 127 | + this.condItemList = condItemsJSONObj.isEmpty() ? new ArrayList<>() : |
128 | + condItemsJSONObj.keySet().stream().map(key -> condItemsJSONObj.getJSONObject(key)).map(CondItem::new).collect(Collectors.toList()); | ||
127 | } | 129 | } |
128 | - | ||
129 | - Assert.notEmpty(this.condItemList, "condItemList cannot be empty"); | ||
130 | } | 130 | } |
131 | 131 | ||
132 | public boolean matchProduct(final ProductIndexBO productIndexBO) { | 132 | public boolean matchProduct(final ProductIndexBO productIndexBO) { |
133 | - if (this.aggregator == Aggregator.ALL) { | 133 | + if (CollectionUtils.isEmpty(condItemList)) { |
134 | + // 当没有具体条件,比如【全场满99元加5元换购YOHO!当期热销新刊】这种时所有productindex都匹配 | ||
135 | + return true; | ||
136 | + } else if (this.aggregator == Aggregator.ALL) { | ||
134 | return this.condItemList.stream().allMatch(condItem -> condItem.matchProduct(productIndexBO)); | 137 | return this.condItemList.stream().allMatch(condItem -> condItem.matchProduct(productIndexBO)); |
135 | } else { | 138 | } else { |
136 | return this.condItemList.stream().anyMatch(condItem -> condItem.matchProduct(productIndexBO)); | 139 | return this.condItemList.stream().anyMatch(condItem -> condItem.matchProduct(productIndexBO)); |
@@ -166,7 +169,7 @@ public class PromotionCond { | @@ -166,7 +169,7 @@ public class PromotionCond { | ||
166 | 169 | ||
167 | private final List<CondDetail> condDetailList; | 170 | private final List<CondDetail> condDetailList; |
168 | 171 | ||
169 | - public PromotionCond(PromotionInfo promotionInfo, PromotionParams promotionParams) { | 172 | + private PromotionCond(PromotionInfo promotionInfo, PromotionParams promotionParams) { |
170 | this.promotionId = promotionInfo.getId(); | 173 | this.promotionId = promotionInfo.getId(); |
171 | this.promotionTitle = promotionInfo.getTitle(); | 174 | this.promotionTitle = promotionInfo.getTitle(); |
172 | 175 | ||
@@ -212,6 +215,19 @@ public class PromotionCond { | @@ -212,6 +215,19 @@ public class PromotionCond { | ||
212 | Assert.notEmpty(this.condDetailList, "condDetailList cannot be empty"); | 215 | Assert.notEmpty(this.condDetailList, "condDetailList cannot be empty"); |
213 | } | 216 | } |
214 | 217 | ||
218 | + public static PromotionCond build(PromotionInfo promotionInfo, PromotionParams promotionParams) { | ||
219 | + if (promotionInfo == null) { | ||
220 | + return null; | ||
221 | + } | ||
222 | + | ||
223 | + try { | ||
224 | + return new PromotionCond(promotionInfo, promotionParams); | ||
225 | + } catch (Exception e) { | ||
226 | + INDEX_REBUILD_LOG.warn("[func=PromotionCond.build][promotionId={}][errorMsg={}]", promotionInfo.getId(), e.getMessage()); | ||
227 | + return null; | ||
228 | + } | ||
229 | + } | ||
230 | + | ||
215 | public boolean matchProduct(final ProductIndexBO productIndexBO) { | 231 | public boolean matchProduct(final ProductIndexBO productIndexBO) { |
216 | boolean matchResult; | 232 | boolean matchResult; |
217 | if (this.aggregator == Aggregator.ALL) { | 233 | if (this.aggregator == Aggregator.ALL) { |
@@ -247,7 +263,7 @@ public class PromotionCond { | @@ -247,7 +263,7 @@ public class PromotionCond { | ||
247 | promotionParams.setPromotionId(1); | 263 | promotionParams.setPromotionId(1); |
248 | promotionParams.setConditionParam(conditionParam); | 264 | promotionParams.setConditionParam(conditionParam); |
249 | 265 | ||
250 | - PromotionCond promotionCond = new PromotionCond(promotionInfo, promotionParams); | 266 | + PromotionCond promotionCond = PromotionCond.build(promotionInfo, promotionParams); |
251 | 267 | ||
252 | ProductIndexBO productIndexBO = new ProductIndexBO(); | 268 | ProductIndexBO productIndexBO = new ProductIndexBO(); |
253 | productIndexBO.setProductSkn(51049121); | 269 | productIndexBO.setProductSkn(51049121); |
@@ -45,7 +45,7 @@ public class PromotionConditionLogicService { | @@ -45,7 +45,7 @@ public class PromotionConditionLogicService { | ||
45 | // 1. 查询促销列表 | 45 | // 1. 查询促销列表 |
46 | List<PromotionInfo> promotionInfoList = promotionInfoService.selectValidPromotionList(); | 46 | List<PromotionInfo> promotionInfoList = promotionInfoService.selectValidPromotionList(); |
47 | if (CollectionUtils.isEmpty(promotionInfoList)) { | 47 | if (CollectionUtils.isEmpty(promotionInfoList)) { |
48 | - INDEX_REBUILD_LOG.debug("[func=PromotionConditionLogicService.end][msg=no valid promotion]"); | 48 | + INDEX_REBUILD_LOG.info("[func=PromotionConditionLogicService.end][msg=no valid promotion]"); |
49 | return; | 49 | return; |
50 | } | 50 | } |
51 | 51 | ||
@@ -56,7 +56,7 @@ public class PromotionConditionLogicService { | @@ -56,7 +56,7 @@ public class PromotionConditionLogicService { | ||
56 | .collect(Collectors.toList()); | 56 | .collect(Collectors.toList()); |
57 | List<PromotionParams> promotionParamsList = promotionParamsService.selectByPromotionIdList(promotionIdList); | 57 | List<PromotionParams> promotionParamsList = promotionParamsService.selectByPromotionIdList(promotionIdList); |
58 | if (CollectionUtils.isEmpty(promotionParamsList)) { | 58 | if (CollectionUtils.isEmpty(promotionParamsList)) { |
59 | - INDEX_REBUILD_LOG.debug("[func=PromotionConditionLogicService.end][msg=no valid promotion params]"); | 59 | + INDEX_REBUILD_LOG.info("[func=PromotionConditionLogicService.end][msg=no valid promotion params]"); |
60 | return; | 60 | return; |
61 | } | 61 | } |
62 | 62 | ||
@@ -65,7 +65,7 @@ public class PromotionConditionLogicService { | @@ -65,7 +65,7 @@ public class PromotionConditionLogicService { | ||
65 | this.promotionCondList = promotionParamsList.parallelStream() | 65 | this.promotionCondList = promotionParamsList.parallelStream() |
66 | .filter(Objects::nonNull) | 66 | .filter(Objects::nonNull) |
67 | .filter(promotionParams -> StringUtils.isNotEmpty(promotionParams.getConditionParam())) | 67 | .filter(promotionParams -> StringUtils.isNotEmpty(promotionParams.getConditionParam())) |
68 | - .map(promotionParams -> new PromotionCond(promotionInfoMap.get(promotionParams.getPromotionId()), promotionParams)) | 68 | + .map(promotionParams -> PromotionCond.build(promotionInfoMap.get(promotionParams.getPromotionId()), promotionParams)) |
69 | .filter(Objects::nonNull) | 69 | .filter(Objects::nonNull) |
70 | .collect(Collectors.toList()); | 70 | .collect(Collectors.toList()); |
71 | List<Integer> validPromotionIdList = this.promotionCondList.stream().map(PromotionCond::getPromotionId).collect(Collectors.toList()); | 71 | List<Integer> validPromotionIdList = this.promotionCondList.stream().map(PromotionCond::getPromotionId).collect(Collectors.toList()); |
1 | package com.yoho.search.consumer.service.logic; | 1 | package com.yoho.search.consumer.service.logic; |
2 | 2 | ||
3 | -import com.yoho.core.config.ConfigReader; | ||
4 | -import com.yoho.search.dal.ScoreRuleMapper; | ||
5 | -import com.yoho.search.dal.model.ScoreRule; | 3 | +import javax.annotation.Resource; |
4 | + | ||
6 | import org.apache.curator.framework.CuratorFramework; | 5 | import org.apache.curator.framework.CuratorFramework; |
7 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
@@ -10,9 +9,10 @@ import org.springframework.beans.factory.InitializingBean; | @@ -10,9 +9,10 @@ import org.springframework.beans.factory.InitializingBean; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
12 | 11 | ||
13 | -import javax.annotation.Resource; | ||
14 | -import java.util.Arrays; | ||
15 | -import java.util.List; | 12 | +import com.yoho.core.config.ConfigReader; |
13 | +import com.yoho.search.base.constants.ScoreRuleConstants; | ||
14 | +import com.yoho.search.dal.ScoreRuleMapper; | ||
15 | +import com.yoho.search.dal.model.ScoreRule; | ||
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Created by ginozhang on 2017/4/12. | 18 | * Created by ginozhang on 2017/4/12. |
@@ -20,79 +20,74 @@ import java.util.List; | @@ -20,79 +20,74 @@ import java.util.List; | ||
20 | @Component | 20 | @Component |
21 | public class ScoreRuleLogicService implements InitializingBean { | 21 | public class ScoreRuleLogicService implements InitializingBean { |
22 | 22 | ||
23 | - private static final Logger logger = LoggerFactory.getLogger(ScoreRuleLogicService.class); | ||
24 | - | ||
25 | - private static final List<String> SUPPORT_RULE_TYPES = Arrays.asList("BRAND_INCREASE_RULE","NEW_ARRIVAL_PAGE_DECAY_RULE","OTHER_PAGE_DECAY_RULE"); | ||
26 | - | ||
27 | - private static final String CONFIG_ROOT_PATH = "/yh/config"; | ||
28 | - | ||
29 | - private static final String FUNCTION_SCORE_RULE_KEY_TEMPLATE = "search.function.score.%s"; | ||
30 | - | ||
31 | - private static final String DEFAULT_RULE_VALUES = "-1"; | ||
32 | - | ||
33 | - @Autowired | ||
34 | - private ScoreRuleMapper scoreRuleMapper; | ||
35 | - | ||
36 | - @Autowired | ||
37 | - private ConfigReader configReader; | ||
38 | - | ||
39 | - @Resource(name = "curatorFramework") | ||
40 | - private CuratorFramework client; | ||
41 | - | ||
42 | - @Override | ||
43 | - public void afterPropertiesSet() throws Exception { | ||
44 | - for (String ruleType : SUPPORT_RULE_TYPES) { | ||
45 | - ScoreRule scoreRule = scoreRuleMapper.selectByRuleType(ruleType); | ||
46 | - if (scoreRule != null) { | ||
47 | - tryUpdateFunctionScoreRule(scoreRule); | ||
48 | - } else { | ||
49 | - tryRemoveFunctionScoreRule(ruleType); | ||
50 | - } | ||
51 | - } | ||
52 | - } | ||
53 | - | ||
54 | - public void tryUpdateFunctionScoreRule(ScoreRule scoreRule) { | ||
55 | - if (!SUPPORT_RULE_TYPES.contains(scoreRule.getRuleType())) { | ||
56 | - logger.warn("[func=ScoreRuleLogicService.tryUpdateFunctionScoreRule][ruleType={}][message=invalid rule type.]", scoreRule.getRuleType()); | ||
57 | - return; | ||
58 | - } | ||
59 | - | ||
60 | - String key = String.format(FUNCTION_SCORE_RULE_KEY_TEMPLATE, scoreRule.getRuleType().toLowerCase()); | ||
61 | - String srcValue = configReader.getString(key, DEFAULT_RULE_VALUES); | ||
62 | - if (!scoreRule.getRuleValues().equals(srcValue)) { | ||
63 | - logger.info("[func=ScoreRuleLogicService.tryUpdateFunctionScoreRule][ruleType={}][srcValue={}][newValue={}]", scoreRule.getRuleType(), srcValue, scoreRule.getRuleValues()); | ||
64 | - publishToZk(key, scoreRule.getRuleValues()); | ||
65 | - } | ||
66 | - } | ||
67 | - | ||
68 | - public void tryRemoveFunctionScoreRule(String ruleType) { | ||
69 | - if (!SUPPORT_RULE_TYPES.contains(ruleType)) { | ||
70 | - logger.warn("[func=ScoreRuleLogicService.tryRemoveFunctionScoreRule][ruleType={}][message=invalid rule type.]", ruleType); | ||
71 | - return; | ||
72 | - } | ||
73 | - | ||
74 | - String key = String.format(FUNCTION_SCORE_RULE_KEY_TEMPLATE, ruleType.toLowerCase()); | ||
75 | - String srcValue = configReader.getString(key, DEFAULT_RULE_VALUES); | ||
76 | - if (!DEFAULT_RULE_VALUES.equals(srcValue)) { | ||
77 | - logger.info("[func=ScoreRuleLogicService.tryRemoveFunctionScoreRule][ruleType={}][srcValue={}]", ruleType, srcValue); | ||
78 | - publishToZk(key, DEFAULT_RULE_VALUES); | ||
79 | - } | ||
80 | - } | ||
81 | - | ||
82 | - private synchronized void publishToZk(String key, String value) { | ||
83 | - try { | ||
84 | - if (client.checkExists().forPath(CONFIG_ROOT_PATH) == null) { | ||
85 | - client.create().creatingParentContainersIfNeeded().forPath(CONFIG_ROOT_PATH); | ||
86 | - } | ||
87 | - | ||
88 | - String path = CONFIG_ROOT_PATH + "/" + key; | ||
89 | - if (this.client.checkExists().forPath(path) == null) { | ||
90 | - this.client.create().forPath(path, value.getBytes("UTF-8")); | ||
91 | - } else { | ||
92 | - this.client.setData().forPath(path, value.getBytes("UTF-8")); | ||
93 | - } | ||
94 | - } catch (Exception e) { | ||
95 | - logger.error("publish function score rule " + key + " to zk failed!", e); | ||
96 | - } | ||
97 | - } | 23 | + private static final Logger logger = LoggerFactory.getLogger(ScoreRuleLogicService.class); |
24 | + | ||
25 | + private static final String CONFIG_ROOT_PATH = "/yh/config"; | ||
26 | + | ||
27 | + private static final String DEFAULT_RULE_VALUES = "-1"; | ||
28 | + | ||
29 | + @Autowired | ||
30 | + private ScoreRuleMapper scoreRuleMapper; | ||
31 | + | ||
32 | + @Autowired | ||
33 | + private ConfigReader configReader; | ||
34 | + | ||
35 | + @Resource(name = "curatorFramework") | ||
36 | + private CuratorFramework client; | ||
37 | + | ||
38 | + @Override | ||
39 | + public void afterPropertiesSet() throws Exception { | ||
40 | + for (String ruleType : ScoreRuleConstants.getSupportScoreRule()) { | ||
41 | + ScoreRule scoreRule = scoreRuleMapper.selectByRuleType(ruleType); | ||
42 | + if (scoreRule != null) { | ||
43 | + tryUpdateFunctionScoreRule(scoreRule); | ||
44 | + } else { | ||
45 | + tryRemoveFunctionScoreRule(ruleType); | ||
46 | + } | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + public void tryUpdateFunctionScoreRule(ScoreRule scoreRule) { | ||
51 | + if (!ScoreRuleConstants.isScoreRuleSupport(scoreRule.getRuleType())) { | ||
52 | + logger.warn("[func=ScoreRuleLogicService.tryUpdateFunctionScoreRule][ruleType={}][message=invalid rule type.]", scoreRule.getRuleType()); | ||
53 | + return; | ||
54 | + } | ||
55 | + String key = ScoreRuleConstants.getZkDynamicConfigKey(scoreRule.getRuleType()); | ||
56 | + String srcValue = configReader.getString(key, DEFAULT_RULE_VALUES); | ||
57 | + if (!scoreRule.getRuleValues().equals(srcValue)) { | ||
58 | + logger.info("[func=ScoreRuleLogicService.tryUpdateFunctionScoreRule][ruleType={}][srcValue={}][newValue={}]", scoreRule.getRuleType(), srcValue, | ||
59 | + scoreRule.getRuleValues()); | ||
60 | + publishToZk(key, scoreRule.getRuleValues()); | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + public void tryRemoveFunctionScoreRule(String ruleType) { | ||
65 | + if (!ScoreRuleConstants.isScoreRuleSupport(ruleType)) { | ||
66 | + logger.warn("[func=ScoreRuleLogicService.tryRemoveFunctionScoreRule][ruleType={}][message=invalid rule type.]", ruleType); | ||
67 | + return; | ||
68 | + } | ||
69 | + String key = ScoreRuleConstants.getZkDynamicConfigKey(ruleType); | ||
70 | + String srcValue = configReader.getString(key, DEFAULT_RULE_VALUES); | ||
71 | + if (!DEFAULT_RULE_VALUES.equals(srcValue)) { | ||
72 | + logger.info("[func=ScoreRuleLogicService.tryRemoveFunctionScoreRule][ruleType={}][srcValue={}]", ruleType, srcValue); | ||
73 | + publishToZk(key, DEFAULT_RULE_VALUES); | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + private synchronized void publishToZk(String key, String value) { | ||
78 | + try { | ||
79 | + if (client.checkExists().forPath(CONFIG_ROOT_PATH) == null) { | ||
80 | + client.create().creatingParentContainersIfNeeded().forPath(CONFIG_ROOT_PATH); | ||
81 | + } | ||
82 | + | ||
83 | + String path = CONFIG_ROOT_PATH + "/" + key; | ||
84 | + if (this.client.checkExists().forPath(path) == null) { | ||
85 | + this.client.create().forPath(path, value.getBytes("UTF-8")); | ||
86 | + } else { | ||
87 | + this.client.setData().forPath(path, value.getBytes("UTF-8")); | ||
88 | + } | ||
89 | + } catch (Exception e) { | ||
90 | + logger.error("publish function score rule " + key + " to zk failed!", e); | ||
91 | + } | ||
92 | + } | ||
98 | } | 93 | } |
@@ -164,6 +164,7 @@ public class ProductILogicService { | @@ -164,6 +164,7 @@ public class ProductILogicService { | ||
164 | productIBO.setSellChannels(p.getSellChannels()); | 164 | productIBO.setSellChannels(p.getSellChannels()); |
165 | productIBO.setAgeLevel(p.getAgeLevel()); | 165 | productIBO.setAgeLevel(p.getAgeLevel()); |
166 | productIBO.setAppType(p.getAppType()); | 166 | productIBO.setAppType(p.getAppType()); |
167 | + productIBO.setCouponLimitStatus(p.getCouponLimitStatus()); | ||
167 | //品牌 | 168 | //品牌 |
168 | this.buildBrand(brandMap,p,productIBO); | 169 | this.buildBrand(brandMap,p,productIBO); |
169 | //品类 | 170 | //品类 |
-
Please register or login to post a comment