Authored by gemingdan

vip价格处理

... ... @@ -15,10 +15,11 @@
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="effect_time" property="effectTime" jdbcType="INTEGER" />
<result column="end_time" property="endTime" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, plan_id, product_skn, current_saleprice, special_price, vip_discount_type, vip_price,
vip1_price, vip2_price, vip3_price, create_time, effect_time, end_time
vip1_price, vip2_price, vip3_price, create_time, effect_time, end_time,status
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -45,12 +46,12 @@
current_saleprice, special_price, vip_discount_type,
vip_price, vip1_price, vip2_price,
vip3_price, create_time, effect_time,
end_time)
end_time,status)
values (#{id,jdbcType=INTEGER}, #{planId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER},
#{currentSaleprice,jdbcType=DECIMAL}, #{specialPrice,jdbcType=DECIMAL}, #{vipDiscountType,jdbcType=INTEGER},
#{vipPrice,jdbcType=DECIMAL}, #{vip1Price,jdbcType=DECIMAL}, #{vip2Price,jdbcType=DECIMAL},
#{vip3Price,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}, #{effectTime,jdbcType=INTEGER},
#{endTime,jdbcType=INTEGER})
#{endTime,jdbcType=INTEGER},#{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.ProductPricePlan" >
insert into product_price_plan
... ... @@ -94,6 +95,9 @@
<if test="endTime != null" >
end_time,
</if>
<if test="status != null" >
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ... @@ -135,6 +139,9 @@
<if test="endTime != null" >
#{endTime,jdbcType=INTEGER},
</if>
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductPricePlan" >
... ... @@ -176,6 +183,9 @@
<if test="endTime != null" >
end_time = #{endTime,jdbcType=INTEGER},
</if>
<if test="status != null" >
status = #{status,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
... ... @@ -192,7 +202,8 @@
vip3_price = #{vip3Price,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=INTEGER},
effect_time = #{effectTime,jdbcType=INTEGER},
end_time = #{endTime,jdbcType=INTEGER}
end_time = #{endTime,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.increment;
import java.math.BigDecimal;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
... ... @@ -16,6 +17,7 @@ import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.PriceUtil;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.service.base.ProductPricePlanService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
... ... @@ -72,6 +74,10 @@ public class ProductPricePlanMqListener extends AbstractMqListener implements Ch
}
productPricePlanService.saveOrUpdate(productPricePlan);
String idValue = String.valueOf(productPricePlan.getId());
double[] vippricearray = PriceUtil.getVipPriceDoubleArray(productPricePlan.getCurrentSaleprice(), productPricePlan.getVipPrice(), productPricePlan.getVip1Price(), productPricePlan.getVip2Price(), productPricePlan.getVip3Price(), productPricePlan.getVipDiscountType());
data.put("vip1Price",vippricearray[0]);
data.put("vip2Price",vippricearray[1]);
data.put("vip3Price",vippricearray[2]);
indexService.updateIndexData(indexName, idValue, data);
logger.info("[func=updateData][step=success][indexName={}][id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
}
... ...
package com.yoho.search.consumer.service.base;
import java.math.BigDecimal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.base.utils.PriceUtil;
import com.yoho.search.dal.ProductPricePlanMapper;
import com.yoho.search.dal.model.ProductPricePlan;
... ... @@ -19,7 +21,14 @@ public class ProductPricePlanService {
}
public List<ProductPricePlan> getPageLists(int offset, int limit) {
return productPricePlanMapper.selectPageLists(offset,limit);
List<ProductPricePlan> list = productPricePlanMapper.selectPageLists(offset,limit);
for(ProductPricePlan p:list){
BigDecimal[] vippricearray = PriceUtil.getVipPriceBigDecimalArray(p.getCurrentSaleprice(), p.getVipPrice(), p.getVip1Price(), p.getVip2Price(), p.getVip3Price(), p.getVipDiscountType());
p.setVip1Price(vippricearray[0]);
p.setVip2Price(vippricearray[1]);
p.setVip3Price(vippricearray[2]);
}
return list;
}
public int updateByPrimaryKeySelective(ProductPricePlan record){
... ...