Authored by wangshusheng

砍价

... ... @@ -7,6 +7,7 @@ public class CutDownPriceUserRecord {
private Integer userId;
private Integer createTime;
private Integer updateTime;
private Integer cutTime;
private Integer activityId;
private Integer productSkn;
private Integer helpCount;
... ... @@ -75,4 +76,12 @@ public class CutDownPriceUserRecord {
public void setUseCount(Integer useCount) {
this.useCount = useCount;
}
public Integer getCutTime() {
return cutTime;
}
public void setCutTime(Integer cutTime) {
this.cutTime = cutTime;
}
}
... ...
... ... @@ -10,9 +10,10 @@
<result column="use_count" property="useCount" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="cut_time" property="cutTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, user_id, activity_id, product_skn, help_count, use_count, create_time, update_time
id, user_id, activity_id, product_skn, help_count, use_count, create_time, update_time, cut_time
</sql>
<insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord">
... ... @@ -61,7 +62,7 @@
<update id="updateCutDownHelpCount" >
update cutdown_price_user_record
set help_count = help_count+1, update_time= UNIX_TIMESTAMP()
set help_count = help_count+1, update_time= UNIX_TIMESTAMP(), cut_time= UNIX_TIMESTAMP()
where user_id = #{userId,jdbcType=INTEGER}
and activity_id = #{activityId,jdbcType=INTEGER}
and product_skn = #{productSkn,jdbcType=INTEGER}
... ...
... ... @@ -125,16 +125,7 @@ public class CutDownProductPriceRest {
}
logger.info("CutDownProductPriceRest queryCutPriceProductForOrder params is{}", cutPriceHelpUserRequestBO);
CutDownPriceActivityProductBo productInfo = cutDownPriceService.queryCutProductInfoForOrder(cutPriceHelpUserRequestBO);
// 校验是否已经砍价成功
if(productInfo.getHasJoinNum()<productInfo.getJoinNum()){
logger.warn(" you have not cutdown success, params is {}", cutPriceHelpUserRequestBO);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CUTDOWN_SUCCESS_ERROR);
}
// 校验是否已经使用过
if(productInfo.getCanUseCount()==0){
logger.warn(" you have used this cutdown, params is {}", cutPriceHelpUserRequestBO);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_USED_CUTDOWNORDER_ERROR);
}
logger.info("CutDownProductPriceRest queryCutPriceProductForOrder success, params is {}", cutPriceHelpUserRequestBO);
return productInfo;
}
... ...
... ... @@ -167,6 +167,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PRODUCT_NOTEXIST_ERROR);
}
CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
if(record==null){
logger.warn(" you have not create cutprice, activityId is {}, productSkn is {}", activityId, productSkn);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CREATE_CUTDOWN_ERROR);
}
// 组装信息
CutDownPriceActivityProductBo bo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, null, null);
if(record!=null){
... ... @@ -175,6 +180,22 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
// 设置已砍价记录
bo.setHasJoinNum(record.getHelpCount());
}
// 校验是否已经砍价成功
if(bo.getHasJoinNum()<bo.getJoinNum()){
logger.warn(" you have not cutdown success, params is {}", cutPriceHelpUserRequestBO);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CUTDOWN_SUCCESS_ERROR);
}
// 用户发起砍价成功后,24小时未付款,则取消
if(record.getCutTime()+24*3600 < DateUtils.getCurrentTimeSecond()){
logger.warn(" you create cutprice has expired, activityId is {}, productSkn is {}", activityId, productSkn);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_CREATE_HAS_EXPIRED_ERROR);
}
// 校验是否已经使用过
if(bo.getCanUseCount()==0){
logger.warn(" you have used this cutdown, params is {}", cutPriceHelpUserRequestBO);
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_USED_CUTDOWNORDER_ERROR);
}
return bo;
}
... ...