| | |
| | | package com.ruoyi.member.service.impl.member; |
| | | |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.member.domain.pojo.member.MemberCoupon; |
| | | import com.ruoyi.member.mapper.member.MemberCouponMapper; |
| | | import com.ruoyi.member.service.member.MemberCouponService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.vo.AppMemberCouponVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | List<AppMemberCouponVo> appMemberCouponVoList = memberCouponMapper.listVoMemberCouponByUserId(userId); |
| | | return appMemberCouponVoList; |
| | | } |
| | | |
| | | /** |
| | | * @description 核销优惠券 |
| | | * @author jqs |
| | | * @date 2023/6/26 17:02 |
| | | * @param verifyCoupon |
| | | * @return void |
| | | */ |
| | | @Override |
| | | public void verifyCoupon(String verifyCoupon){ |
| | | MemberCoupon memberCoupon = this.getById(verifyCoupon); |
| | | if(memberCoupon==null){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_NO_FIND); |
| | | } |
| | | if(memberCoupon.getCouponStatus()==0){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_EXPIRED); |
| | | }else if(memberCoupon.getCouponStatus()==2){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_USED); |
| | | }else if(memberCoupon.getCouponStatus()!=0){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_NO_FIND); |
| | | } |
| | | if(memberCoupon.getCouponType()!=4){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_TYPE_ERROR); |
| | | } |
| | | //更新优惠券为已使用 |
| | | memberCoupon.setCouponStatus(2); |
| | | memberCoupon.setUseTime(new Date()); |
| | | this.saveOrUpdate(memberCoupon); |
| | | } |
| | | } |