Authored by wangshusheng

修改bug

... ... @@ -5,7 +5,7 @@ import java.math.BigDecimal;
public class CutDownPriceProduct {
private Integer id;
private Integer activityId;
private String productSkn;
private Integer productSkn;
private Integer createTime;
private Integer updateTime;
private Integer joinNum;
... ... @@ -28,11 +28,11 @@ public class CutDownPriceProduct {
this.activityId = activityId;
}
public String getProductSkn() {
public Integer getProductSkn() {
return productSkn;
}
public void setProductSkn(String productSkn) {
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
... ...
... ... @@ -2,8 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yoho.activity.dal.CutDownPriceActivityMapper">
<resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceActivity">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="activity_id" property="activityId" jdbcType="INTEGER" />
<id column="activity_id" jdbcType="INTEGER" property="activityId" />
<result column="activity_name" property="activityName" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="begin_time" property="beginTime" jdbcType="INTEGER" />
... ... @@ -15,7 +14,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, activity_id, activity_name, status, begin_time, end_time, create_time, update_time, jump_url, banner_url
activity_id, activity_name, status, begin_time, end_time, create_time, update_time, jump_url, banner_url
</sql>
<select id="selectCutDownPriceActivity" resultMap="BaseResultMap">
... ...
... ... @@ -30,7 +30,7 @@
from cutdown_price_product
where
<foreach collection="list" item="item" index="index" separator="OR">
(activity_id=#{item.activityId,jdbcType=INTEGER} and (product_skn=#{item.productSkn,jdbcType=INTEGER}))
(activity_id=#{item.activityId,jdbcType=INTEGER} and product_skn=#{item.productSkn,jdbcType=INTEGER})
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -29,7 +29,7 @@
insert into cutdown_price_help_user (user_id, help_user_id,help_user_name,help_user_img_url,activity_id,product_skn,cut_price,create_time)
values (#{userId,jdbcType=INTEGER}, #{helpUserId,jdbcType=VARCHAR}, #{helpUserName,jdbcType=VARCHAR},
#{helpUserImgUrl,jdbcType=VARCHAR}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER},
#{cutPrice,jdbcType=DECIMAL}, current_timestamp()
#{cutPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}
)
</insert>
... ... @@ -40,4 +40,15 @@
AND activity_id = #{activityId,jdbcType=INTEGER}
AND product_skn = #{productSkn,jdbcType=INTEGER}
</select>
<select id="selectHelpInfoList" resultMap="BaseResultMap" parameterType="java.util.List">
select
<include refid="Base_Column_List" />
from cutdown_price_help_user
where
<foreach collection="list" item="item" index="index" separator="OR">
(user_id = #{item.userId,jdbcType=INTEGER} and activity_id=#{item.activityId,jdbcType=INTEGER} and product_skn=#{item.productSkn,jdbcType=INTEGER})
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -14,7 +14,7 @@
<insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord">
insert into cutdown_price_user_record (user_id, activity_id, product_skn, create_time)
values (#{userId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, current_timestamp()
values (#{userId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}
)
</insert>
... ...
... ... @@ -21,11 +21,5 @@ public interface ICutDownPriceService {
int addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
Boolean judgeHelpUserExist(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
void addShareInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO);
Boolean judgeHelpUserNumMoreLimit(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO);
PageResponseBo<CutDownPriceActivityProductBo> queryMyCutPriceListByPage(CutDownProductQueryRequest request);
}
... ...
... ... @@ -5,6 +5,7 @@ import com.yoho.activity.common.convert.BeanConvert;
import com.yoho.activity.common.redis.CacheKeyEnum;
import com.yoho.activity.common.redis.RedisHashCache;
import com.yoho.activity.common.redis.RedisValueCache;
import com.yoho.activity.common.utils.DateUtils;
import com.yoho.activity.dal.CutDownPriceUserHelpMapper;
import com.yoho.activity.dal.CutDownPriceUserRecordMapper;
import com.yoho.activity.dal.model.CutDownPriceProductHelpUser;
... ... @@ -76,11 +77,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn);
if (CollectionUtils.isEmpty(helpUsers)){
logger.info("CutDownPriceServiceImpl :: queryHelpInfo result is null");
return null;
return Lists.newArrayList();
}
List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class);
//获取用户头像
getUserInfo(userId, helpUsersBoList);
helpUserWrapper = new CutDownPriceProductHelpUserWrapper();
helpUserWrapper.setHelpUserBoList(helpUsersBoList);
redisValueCache.set(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix, helpUserWrapper, 300, TimeUnit.SECONDS);
return helpUserWrapper.getHelpUserBoList();
... ... @@ -196,9 +198,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
helpUser.setCutPrice(cutPrice);
helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
// 插入表
cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
// 清理缓存
// 清理缓存,用户帮砍记录列表、商品详情页
clearCache(activityId, productSkn, userId);
return cutPrice;
}
... ... @@ -226,6 +230,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
record.setActivityId(activityId);
record.setProductSkn(productSkn);
record.setUserId(userId);
record.setCreateTime(DateUtils.getCurrentTimeSecond());
int num = cutDownPriceUserRecordMapper.addCutDownUserRecord(record);
return num;
}
... ... @@ -235,11 +240,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
logger.warn(" the cutdown activity not exist, activityId is {}", activityId);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
}
if(activityBo.getBeginTime() > System.currentTimeMillis()){
if(activityBo.getBeginTime() > System.currentTimeMillis()/1000){
logger.warn(" the cutdown activity not start, activityId is {}", activityId);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
}
if(activityBo.getEndTime() < System.currentTimeMillis()){
if(activityBo.getEndTime() < System.currentTimeMillis()/1000){
logger.warn(" the cutdown activity has end, activityId is {}", activityId);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
}
... ... @@ -249,21 +254,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
}
}
@Override
public Boolean judgeHelpUserExist(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
return null;
}
@Override
public void addShareInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
}
@Override
public Boolean judgeHelpUserNumMoreLimit(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
return null;
}
private CutDownPriceProductHelpUser convertCutDownPriceProductHelpUser(CutPriceHelpUserRequestBO request) {
CutDownPriceProductHelpUser user = new CutDownPriceProductHelpUser();
user.setUserId(request.getUserId());
... ... @@ -284,7 +274,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
BigDecimal shouldCutPrice = new BigDecimal(0);
BigDecimal hasCutPrice = new BigDecimal(0);
for (CutDownPriceProductHelpUser helpUser : helpUsers){
hasCutPrice.add(helpUser.getCutPrice());
hasCutPrice = hasCutPrice.add(helpUser.getCutPrice());
}
int cutNum = helpUsers.size();
BigDecimal rangePrice = highPrice.subtract(hasCutPrice).subtract(lowPrice);//价格区间
... ... @@ -320,8 +310,8 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
activityProductBo.setProductSkn(cutDownPriceProductBo.getProductSkn());
activityProductBo.setBeginTime(activityBo.getBeginTime());
activityProductBo.setEndTime(activityBo.getEndTime());
activityProductBo.setCurrentTime(System.currentTimeMillis());
activityProductBo.setCurrentTime(System.currentTimeMillis()/1000);
activityProductBo.setStatus(activityBo.getStatus());
activityProductBo.setHighPrice(cutDownPriceProductBo.getHighPrice());
activityProductBo.setLowPrice(cutDownPriceProductBo.getLowPrice());
activityProductBo.setJoinNum(cutDownPriceProductBo.getJoinNum());
... ... @@ -335,7 +325,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
BigDecimal hasCutPrice = new BigDecimal(0);
for(CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
hasCutPrice.add(helpUserBo.getCutPrice());
hasCutPrice = hasCutPrice.add(helpUserBo.getCutPrice());
activityProductBo.setUserImgUrl(helpUserBo.getUserImgUrl());// 赋值一次就可以了
}
activityProductBo.setHasCutPrice(hasCutPrice);
... ... @@ -391,4 +381,13 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
public void addToRedis(CacheKeyEnum keyEnum, Integer uid, Object value, String... param) {
redisHashCache.put(keyEnum.getCacheKey(), uid, keyEnum.getHashKey(param), value, 300, TimeUnit.SECONDS);
}
// 清理缓存,用户帮砍记录列表、商品详情页
private void clearCache(Integer activityId, Integer productSkn, Integer userId) {
// 取缓存
String redisKeySuffix = userId + ":" + activityId + ":" + productSkn;
redisValueCache.delete(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix);
}
}
... ...
... ... @@ -26,7 +26,7 @@ redis.proxy.auth=
execute.timetask.host=192.168.90.9
#zkAddress
zkAddress=127.0.0.1:2181
zkAddress=192.168.102.45:2181
# web context
web.context=activity
... ...
... ... @@ -3,5 +3,3 @@ consumer:
username: yoho
password: yoho
consumers:
- class: com.yoho.product.syschronize.mq.consumer.PricePlanDeleteMessageConsumer
topic: price_plan_delete
... ...
... ... @@ -3,6 +3,4 @@ consumer:
username: ${rabbit_common_user}
password: ${rabbit_common_password}
consumers:
- class: com.yoho.product.syschronize.mq.consumer.PricePlanDeleteMessageConsumer
topic: price_plan_delete
... ...