Commit 7e3ab7f9 by 田超

Merge branch 'fixbug/1026084' into 'master'

bug: [1026084]  首页改版-新人礼包模块部分】推荐到首页关闭应该不能显示在小程序首页里

See merge request rays/pcloud-book!1018
parents bcc0aada 7898b767
......@@ -35,6 +35,16 @@ public class BookBizException extends BizException{
* 参数为空
*/
public static final int PARAM_IS_NULL = 20210002;
/**
* 库存为空
*/
public static final int STOCK_IS_EMPTY = 20210111;
/**
* 库存为空
*/
public static final int HAS_RECEIVED = 20210112;
/**
* 时间格式错误
......
......@@ -339,11 +339,11 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
Integer giftReceiveCount = giftReceiveDao.getGiftReceiveCount(giftReceive.getWechatUserId(), giftReceive.getGiftPackageId());
//库存减一
if(giftCouponPackage.getStock()<1){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "库存不够");
throw new BookBizException(BookBizException.STOCK_IS_EMPTY, "今日库存已用完");
}
//超过单个奖券领取上限
if(giftReceiveCount>=giftCouponPackage.getReceiveLimit()){
throw new BookBizException(BookBizException.SUCCESS, "该类型的兑换券您已经领取过,请前往“我的券库”使用吧");
throw new BookBizException(BookBizException.HAS_RECEIVED, "该类型的兑换券您已经领取过,请前往“我的券库”使用吧");
}
//超过券库总领取上限
Integer giftAllReceiveCount =giftReceiveDao.getGiftAllReceiveCount(giftReceive.getWechatUserId());
......@@ -589,8 +589,9 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
List<Long> list=giftCategoryDao.getByParams(map);
Random index = new Random();
List<Long> resultIds = new ArrayList<>();
List<Integer> indexList = new ArrayList<>();
if(list.size()>=COUPON_MAX_SHOW_SIZE){
List<Integer> indexList = new ArrayList<>();
for(int i=0,j;i<COUPON_MAX_SHOW_SIZE;i++){
//获取在 list.size 返回内的随机数
j= index.nextInt(list.size());
......@@ -604,10 +605,18 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
}
}
}else{
List<Integer> indexList = new ArrayList<>();
if (!ListUtils.isEmpty(list)){
resultIds.addAll(list);
}
List<Long> list1=giftCategoryDao.getOtherByParams(map);
if(ListUtils.isEmpty(list1)){
return resultIds;
}
if(list1.size()+resultIds.size()<=COUPON_MAX_SHOW_SIZE){
resultIds.addAll(list1);
return resultIds;
}
for(int i=0,j;i<COUPON_MAX_SHOW_SIZE-list.size();i++){
//获取在 list.size 返回内的随机数
j= index.nextInt(list1.size());
......
......@@ -8,7 +8,10 @@ import lombok.Data;
public class ExceptionDTO {
String errorMsg;
public ExceptionDTO(String errorMsg) {
Integer errorCode;
public ExceptionDTO(String errorMsg,Integer errorCode) {
this.errorMsg = errorMsg;
this.errorCode=errorCode;
}
}
......@@ -132,7 +132,11 @@ public class GiftCouponPackageFacade {
try {
giftCouponPackageBiz.createGiftReceive(GiftReceive);
}catch (BookBizException e){
return new ResponseDto<>(e.getCode(),e.getMsg(),new ExceptionDTO(e.getMsg()));
if(BookBizException.HAS_RECEIVED==e.getCode() || BookBizException.STOCK_IS_EMPTY==e.getCode()) {
return new ResponseDto<>(BookBizException.SUCCESS, e.getMsg(), new ExceptionDTO(e.getMsg(), e.getCode()));
}else{
return new ResponseDto<>(e.getCode(), e.getMsg(), new ExceptionDTO(e.getMsg(), e.getCode()));
}
}
return new ResponseDto<>();
}
......
......@@ -141,7 +141,6 @@
)t on a.id=t.gift_package_id
where a.is_delete=0
and a.stock>0
and a.on_shelves=1
and a.rec_to_page=1
and now() <![CDATA[ < ]]> a.valid_date_end
......@@ -153,8 +152,8 @@
from
gift_coupon_package a
where a.is_delete=0
and a.stock>0
and a.on_shelves=1
and a.rec_to_page=1
and now() <![CDATA[ < ]]> a.valid_date_end
and a.id not in
(
......
......@@ -234,7 +234,6 @@
from
gift_coupon_package a
where a.is_delete=0
and a.stock>0
<if test="title !=null and title !=''">
and (a.title like concat('%',#{title},'%') or a.resource_number like concat('%',#{title},'%'))
</if>
......@@ -378,7 +377,6 @@
from
gift_coupon_package a
where a.is_delete=0
and a.stock>0
<if test="title !=null and title !=''">
and (a.title like concat('%',#{title},'%') or a.url_number like concat('%',#{title},'%'))
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment