Commit e8022eaf by 郑勇

修改课程券使用不消失

parent 7bb7becf
...@@ -13,6 +13,7 @@ import com.pcloud.book.giftcoupon.dto.GiftReceiveDTO; ...@@ -13,6 +13,7 @@ import com.pcloud.book.giftcoupon.dto.GiftReceiveDTO;
import com.pcloud.book.giftcoupon.dto.MyGiftPackageDTO; import com.pcloud.book.giftcoupon.dto.MyGiftPackageDTO;
import com.pcloud.book.giftcoupon.entity.GiftCouponPackage; import com.pcloud.book.giftcoupon.entity.GiftCouponPackage;
import com.pcloud.book.giftcoupon.entity.GiftReceive; import com.pcloud.book.giftcoupon.entity.GiftReceive;
import com.pcloud.book.giftcoupon.enums.CouponTypeEnum;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
...@@ -147,12 +148,18 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz { ...@@ -147,12 +148,18 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void useGiftCoupon(Long wechatUserId, Long giftPackageId) { public void useGiftCoupon(Long wechatUserId, Long giftPackageId) {
GiftCouponPackage giftCouponPackage = giftCouponPackageDao.getById(giftPackageId);
if(null==giftCouponPackage){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "当前奖券包不存在");
}
GiftReceive giftReceive = giftReceiveDao.getGiftReceive(wechatUserId, giftPackageId); GiftReceive giftReceive = giftReceiveDao.getGiftReceive(wechatUserId, giftPackageId);
if(null==giftReceive){ if(null==giftReceive){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "当前奖券包不存在"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "你还未领取该奖券包");
} }
if(giftReceive.getReceiveNum()-giftReceive.getUsedNum()<=0){ if(!CouponTypeEnum.COURSE_COUPON.value.equals(giftCouponPackage.getCouponType())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "当前奖券包已经使用完了"); if (giftReceive.getReceiveNum() - giftReceive.getUsedNum() <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "当前奖券包已经使用完了");
}
} }
//todo 可能有其他操作,如果点击不跳转页面,需要控制重复点击 //todo 可能有其他操作,如果点击不跳转页面,需要控制重复点击
giftReceiveDao.useGiftCoupon(wechatUserId,giftPackageId); giftReceiveDao.useGiftCoupon(wechatUserId,giftPackageId);
......
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
gift_receive b LEFT JOIN gift_coupon_package a gift_receive b LEFT JOIN gift_coupon_package a
on a.id=b.gift_package_id on a.id=b.gift_package_id
where b.wechat_user_id=#{wechatUserId} where b.wechat_user_id=#{wechatUserId}
and b.used_num <![CDATA[ < ]]> b.receive_num and ( (coupon_type=1) or (coupon_type!=1 and b.used_num <![CDATA[ < ]]> b.receive_num) )
<if test="state!=null and state==1"> <if test="state!=null and state==1">
and now() <![CDATA[ <= ]]> a.valid_date_end and now() <![CDATA[ <= ]]> a.valid_date_end
</if> </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