koushanshan 1 年之前
父节点
当前提交
4f70702a12

+ 48 - 2
src/main/java/com/dk/oauth/controller/integral/CouponReceiveController.java

@@ -1,14 +1,24 @@
 package com.dk.oauth.controller.integral;
 
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.model.VO.integral.CouponReceiveVO;
+import com.dk.oauth.model.VO.integral.CouponSendVO;
 import com.dk.oauth.model.pojo.integral.CouponReceive;
 import com.dk.common.controller.BaseController;
 import com.dk.common.service.BaseService;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.dk.oauth.model.query.integral.CouponReceiveQuery;
+import com.dk.oauth.model.query.integral.CouponSendQuery;
+import com.dk.oauth.model.response.integral.CouponReceiveResponse;
+import com.dk.oauth.model.response.integral.CouponSendResponse;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import com.dk.oauth.service.integral.CouponReceiveService;
 
+import javax.validation.Valid;
+
 @Api(tags = "优惠券获取API接口")
 @RestController
 @RequestMapping("/oauth/couponReceive")
@@ -21,4 +31,40 @@ public class CouponReceiveController{
     @Autowired
     private CouponReceiveService couponReceiveService;
 
+    /**
+     * @desc   : 条件查询
+     * @date   : 2024/7/26 11:06
+     * @author : 寇珊珊
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<CouponReceiveResponse>> selectByCond(@RequestBody CouponReceiveQuery couponReceiveQuery ) {
+        return couponReceiveService.selectByCond(couponReceiveQuery);
+    }
+
+    /**
+     * @desc   : 通过ID查询
+     * @date   : 2024/7/26 11:06
+     * @author : 寇珊珊
+     */
+    @PostMapping({"{id}"})
+    public ResponseResultVO<?> selectById(@PathVariable String id) {
+        return couponReceiveService.selectById(id);
+    }
+
+    /**
+     * @desc   : 新建
+     * @date   : 2024/7/26 11:06
+     * @author : 寇珊珊
+     */
+    @ApiOperation(
+            value = "新建",
+            notes = "新建"
+    )
+    @PostMapping({"insert"})
+    public ResponseResultVO<?> otherOutboundInsert(@Valid @RequestBody CouponReceiveVO couponReceiveVO) {
+        return couponReceiveService.insert(couponReceiveVO);
+    }
+
+
 }

+ 49 - 2
src/main/java/com/dk/oauth/controller/integral/CouponUseController.java

@@ -1,14 +1,24 @@
 package com.dk.oauth.controller.integral;
 
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.model.VO.integral.CouponReceiveVO;
+import com.dk.oauth.model.VO.integral.CouponUseVO;
 import com.dk.oauth.model.pojo.integral.CouponUse;
 import com.dk.common.controller.BaseController;
 import com.dk.common.service.BaseService;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.dk.oauth.model.query.integral.CouponReceiveQuery;
+import com.dk.oauth.model.query.integral.CouponUseQuery;
+import com.dk.oauth.model.response.integral.CouponReceiveResponse;
+import com.dk.oauth.model.response.integral.CouponUseResponse;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import com.dk.oauth.service.integral.CouponUseService;
 
+import javax.validation.Valid;
+
 @Api(tags = "优惠券使用API接口")
 @RestController
 @RequestMapping("/oauth/couponUse")
@@ -21,4 +31,41 @@ public class CouponUseController{
     @Autowired
     private CouponUseService couponUseService;
 
+
+    /**
+     * @desc   : 条件查询
+     * @date   : 2024/7/26 11:06
+     * @author : 寇珊珊
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<CouponUseResponse>> selectByCond(@RequestBody CouponUseQuery couponReceiveQuery) {
+        return couponUseService.selectByCond(couponReceiveQuery);
+    }
+
+    /**
+     * @desc   : 通过ID查询
+     * @date   : 2024/7/26 11:06
+     * @author : 寇珊珊
+     */
+    @PostMapping({"{id}"})
+    public ResponseResultVO<?> selectById(@PathVariable String id) {
+        return couponUseService.selectById(id);
+    }
+
+    /**
+     * @desc   : 更新
+     * @date   : 2024/7/26 16:08
+     * @author : 寇珊珊
+     */
+    @ApiOperation(
+            value = "更新",
+            notes = "更新"
+    )
+    @PostMapping({"update"})
+    public ResponseResultVO<?> update(@Valid @RequestBody CouponUseVO couponUseVO) {
+        return couponUseService.update(couponUseVO);
+    }
+
+
 }

+ 23 - 0
src/main/java/com/dk/oauth/infrastructure/convert/integral/CouponReceiveConvert.java

@@ -0,0 +1,23 @@
+package com.dk.oauth.infrastructure.convert.integral;
+
+import com.dk.oauth.model.VO.integral.CouponReceiveVO;
+import com.dk.oauth.model.pojo.integral.CouponReceive;
+import org.mapstruct.Mapper;
+
+/**
+ * @desc   : 优惠券获取实体类型转换
+ * @date   : 2024/7/26 9:36
+ * @author : 寇珊珊
+ */
+@Mapper(componentModel = "spring")
+public interface CouponReceiveConvert {
+
+    /**
+     * @desc   : VO转pojo
+     * @date   : 2024/7/26 9:37
+     * @author : 寇珊珊
+     */
+    CouponReceive convertToPo(CouponReceiveVO couponReceiveVO);
+
+
+}

+ 1 - 1
src/main/java/com/dk/oauth/infrastructure/convert/integral/CouponSendConvert.java

@@ -5,7 +5,7 @@ import com.dk.oauth.model.pojo.integral.CouponSend;
 import org.mapstruct.Mapper;
 
 /**
- * @desc   : 优惠券发出实体类型转换
+ * @desc   : 优惠券获取实体类型转换
  * @date   : 2024/7/26 9:36
  * @author : 寇珊珊
  */

+ 23 - 0
src/main/java/com/dk/oauth/infrastructure/convert/integral/CouponUseConvert.java

@@ -0,0 +1,23 @@
+package com.dk.oauth.infrastructure.convert.integral;
+
+import com.dk.oauth.model.VO.integral.CouponUseVO;
+import com.dk.oauth.model.pojo.integral.CouponUse;
+import org.mapstruct.Mapper;
+
+/**
+ * @desc   : 优惠券使用实体类型转换
+ * @date   : 2024/7/26 9:36
+ * @author : 寇珊珊
+ */
+@Mapper(componentModel = "spring")
+public interface CouponUseConvert {
+
+    /**
+     * @desc   : VO转pojo
+     * @date   : 2024/7/26 9:37
+     * @author : 寇珊珊
+     */
+    CouponUse convertToPo(CouponUseVO couponUseVO);
+
+
+}

+ 3 - 0
src/main/java/com/dk/oauth/mapper/integral/CouponReceiveMapper.xml

@@ -64,6 +64,9 @@
             <if test="couponName != null and couponName != ''">
                 AND tmc.coupon_name LIKE concat('%',my_ex.likequery(#{couponName}),'%')
             </if>
+            <if test="assistFlag != null and assistFlag ">
+                AND tmcr.assist_date >= NOW() - INTERVAL '7 DAY'
+            </if>
         </where>
     </sql>
 

+ 4 - 0
src/main/java/com/dk/oauth/model/VO/integral/CouponReceiveVO.java

@@ -97,6 +97,10 @@ public class CouponReceiveVO  {
      * @TableField(exist = false)
      */
 
+    @ApiModelProperty(value = "获取用户")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String receiveUser;
+
 
     private static final long serialVersionUID = 1L;
 

+ 3 - 0
src/main/java/com/dk/oauth/model/query/integral/CouponReceiveQuery.java

@@ -99,6 +99,9 @@ public class CouponReceiveQuery extends PageInfo<CouponReceiveQuery> {
     @ApiModelProperty(value = "优惠券名称")
     private String couponName;
 
+    @ApiModelProperty(value = "查询7天内是否助力过")
+    private Boolean assistFlag;
+
 
     private static final long serialVersionUID = 1L;
 

+ 137 - 6
src/main/java/com/dk/oauth/service/integral/CouponReceiveService.java

@@ -1,23 +1,154 @@
 package com.dk.oauth.service.integral;
 
+import com.dk.common.exception.BaseBusinessException;
+import com.dk.common.infrastructure.annotaiton.Pagination;
+import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.infrastructure.convert.integral.CouponReceiveConvert;
+import com.dk.oauth.mapper.integral.CouponMapper;
+import com.dk.oauth.mapper.integral.CouponSendMapper;
+import com.dk.oauth.mapper.integral.CouponUseMapper;
+import com.dk.oauth.model.VO.integral.CouponReceiveVO;
+import com.dk.oauth.model.VO.integral.CouponSendVO;
 import com.dk.oauth.model.pojo.integral.CouponReceive;
 import com.dk.oauth.mapper.integral.CouponReceiveMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.oauth.model.pojo.integral.CouponUse;
+import com.dk.oauth.model.query.integral.CouponReceiveQuery;
+import com.dk.oauth.model.query.integral.CouponSendQuery;
+import com.dk.oauth.model.response.integral.CouponReceiveResponse;
+import com.dk.oauth.model.response.integral.CouponResponse;
+import com.dk.oauth.model.response.integral.CouponSendResponse;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.List;
+
 @Service
 @Transactional
 public class CouponReceiveService extends BaseService<CouponReceive> {
 
-	@Override
-	public BaseMapper<CouponReceive> getRepository() {
-		return couponReceiveMapper;
-	}
+    @Override
+    public BaseMapper<CouponReceive> getRepository() {
+        return couponReceiveMapper;
+    }
+
+    @Autowired
+    private CouponReceiveMapper couponReceiveMapper;
+
+    @Autowired
+    //优惠券获取转换类
+    private CouponReceiveConvert couponReceiveConvert;
+
+    @Autowired
+    //优惠券发出
+    private CouponSendMapper couponSendMapper;
+
+    @Autowired
+    //优惠券使用
+    private CouponUseMapper couponUseMapper;
+
+    @Autowired
+    //优惠券
+    private CouponMapper couponMapper;
+
+
+    /**
+     * @desc : 条件查询
+     * @date : 2024/7/26 11:07
+     * @author : 寇珊珊
+     */
+    @Pagination
+    public ResponseResultVO<PageList<CouponReceiveResponse>> selectByCond(CouponReceiveQuery couponReceiveQuery) {
+        return super.mergeListWithCount(couponReceiveQuery, couponReceiveMapper.selectByCond(couponReceiveQuery),
+                couponReceiveMapper.countByCond(couponReceiveQuery));
+    }
+
+    /**
+     * @desc : 新建
+     * @date : 2024/7/26 11:08
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> insert(CouponReceiveVO couponReceiveVO) {
+        //region 查询7日内已进行过优惠券助力
+        List<CouponReceiveResponse> couponReceiveResponses = couponReceiveMapper.selectByCond(new CouponReceiveQuery().setUserWxid(couponReceiveVO.getUserWxid()).setAssistFlag(true));
+        if (couponReceiveResponses != null && couponReceiveResponses.size() > 0) {
+            //近期己助力过
+            throw new BaseBusinessException(ErrorCodeEnum.I_HAVE_RECENTLY_PROVIDED_ASSISTANCE.getCode(), ErrorCodeEnum.I_HAVE_RECENTLY_PROVIDED_ASSISTANCE.getMessage());
+        }
+        //endregion
+
+        //region 7日内没有进行过助力
+        else {
+
+            //region 查询发出优惠券所需助力人数
+            CouponSendResponse couponSendResponse = couponSendMapper.selectById(couponReceiveVO.getSendId());
+            Integer userNum = couponSendResponse.getUserNum();
+            //endregion
+
+            //region 查询优惠券获取对应的优惠券发出已有多少人助力
+            Long count = couponReceiveMapper.countByCond(new CouponReceiveQuery().setSendId(couponReceiveVO.getSendId()));
+            //endregion
+
+            //region 当前优惠券获取个数 小于 优惠券发出所需助力人数
+            if (count < Long.valueOf(userNum)) {
+                //region 新建
+                couponReceiveVO.setAssistDate(LocalDateTime.now());
+                CouponReceive couponReceive = couponReceiveConvert.convertToPo(couponReceiveVO);
+                couponReceiveMapper.insert(couponReceive);
+                //endregion
+
+                //region 是否新建优惠券使用
+                //新建之后再查一遍 查询优惠券获取对应的优惠券发出已有多少人助力
+                Long addAfterCount = couponReceiveMapper.countByCond(new CouponReceiveQuery().setSendId(couponReceiveVO.getSendId()));
+                //当前优惠券获取个数等于优惠券发出所需助力人数
+                if (addAfterCount == Long.valueOf(userNum)) {
+
+                    //region 新建优惠券使用  状态未使用
+                    CouponUse couponUse = new CouponUse();
+                    //公司id
+                    couponUse.setCpId(couponReceiveVO.getCpId());
+                    //优惠券发出id
+                    couponUse.setSendId(couponSendResponse.getSendId());
+                    //优惠券id
+                    couponUse.setCouponId(couponSendResponse.getCouponId());
+                    //使用有效期
+                    CouponResponse couponResponse = couponMapper.selectById(couponSendResponse.getCouponId());
+                    couponUse.setUseValidDays(couponResponse.getUseValidDays());
+                    //获取日期
+                    couponUse.setReceiveDate(LocalDateTime.now());
+                    //优惠券状态
+                    couponUse.setCouponStatus(Constant.couponStatus.WEI_SHI_YONG.getName());
+                    //获取用户
+                    couponUse.setReceiveUser(couponReceiveVO.getReceiveUser());
+                    couponUseMapper.insert(couponUse);
+                    //endregion
+
+                }
+                //endregion
+            }
+            //endregion
+
+            //region 当前优惠券获取个数 大于等于 优惠券发出所需助力人数
+            else if (count >= Long.valueOf(userNum)) {
+                //所需助力人数已满
+                throw new BaseBusinessException(ErrorCodeEnum.THE_REQUIRED_NUMBER_OF_HELPERS_IS_FULL.getCode(), ErrorCodeEnum.THE_REQUIRED_NUMBER_OF_HELPERS_IS_FULL.getMessage());
+            }
+            //endregion
+
+        }
+        //endregion
+
+        return ResponseResultUtil.success();
+    }
 
-	@Autowired
-	private CouponReceiveMapper couponReceiveMapper;
 
 }

+ 33 - 15
src/main/java/com/dk/oauth/service/integral/CouponSendService.java

@@ -12,9 +12,11 @@ import com.dk.oauth.mapper.integral.CouponReceiveMapper;
 import com.dk.oauth.mapper.integral.CouponSendMapper;
 import com.dk.oauth.model.VO.integral.CouponSendVO;
 import com.dk.oauth.model.pojo.integral.CouponSend;
+import com.dk.oauth.model.query.integral.CouponQuery;
 import com.dk.oauth.model.query.integral.CouponReceiveQuery;
 import com.dk.oauth.model.query.integral.CouponSendQuery;
 import com.dk.oauth.model.response.integral.CouponReceiveResponse;
+import com.dk.oauth.model.response.integral.CouponResponse;
 import com.dk.oauth.model.response.integral.CouponSendResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -67,12 +69,12 @@ public class CouponSendService extends BaseService<CouponSend> {
 	 */
 	@Transactional(rollbackFor = {Exception.class})
 	public ResponseResultVO<?> insert(CouponSendVO couponSendVO) {
-		//region 根据id查询数据, 如果存在: 1:判断已助力人数是否已满 2:判断发送时间是否已过期
+		//region 根据id查询数据
 		CouponSendResponse couponSendResponse = couponSendMapper.selectById(couponSendVO.getCouponId());
 		if(couponSendResponse!=null){
-
 			//region 查询已助力人数
 			List<CouponReceiveResponse> couponReceiveResponses = couponReceiveMapper.selectByCond(new CouponReceiveQuery().setCouponId(couponSendResponse.getCouponId()));
+			int userNum = couponReceiveResponses.size();
 //			if(couponReceiveResponses.size()>couponSendResponse.getUserNum()){
 //				//所需助力人数已满
 //				throw new BaseBusinessException(ErrorCodeEnum.THE_REQUIRED_NUMBER_OF_HELPERS_IS_FULL.getCode(),ErrorCodeEnum.THE_REQUIRED_NUMBER_OF_HELPERS_IS_FULL.getMessage());
@@ -89,40 +91,56 @@ public class CouponSendService extends BaseService<CouponSend> {
 			long thisTime = couponSendVO.getEndDate().toInstant(ZoneOffset.of("+8")).toEpochMilli();
 			//本次发出时间大于截止日期
 			if ( (thisTime / 1000) > (primaryTime / 1000)) {
-				//新建
-				CouponSend couponSend = couponSendConvert.convertToPo(couponSendVO);
-				couponSendMapper.insert(couponSend);
-				return ResponseResultUtil.success();
 
-//				//链接已无效
-//				throw new BaseBusinessException(ErrorCodeEnum.THE_LINK_IS_NO_LONGER_VALID.getCode(),ErrorCodeEnum.THE_LINK_IS_NO_LONGER_VALID.getMessage());
+				//region 新建
+				this.insertCouponSend(couponSendVO);
+				//endregion
+
 			}
 			//本次发出时间小于等于截止日期  并且助力人数未够 直接返回
-			if ( (thisTime / 1000) <= (primaryTime / 1000) && couponReceiveResponses.size() < couponSendResponse.getUserNum() ) {
+			if ( (thisTime / 1000) <= (primaryTime / 1000) && userNum < couponSendResponse.getUserNum() ) {
 				return ResponseResultUtil.success();
 			}
 			//本次发出时间小于等于截止日期  并且助力已满足 新建
-			if ( (thisTime / 1000) <= (primaryTime / 1000) && couponReceiveResponses.size() == couponSendResponse.getUserNum() ) {
-				//新建
+			if ( (thisTime / 1000) <= (primaryTime / 1000) && userNum == couponSendResponse.getUserNum() ) {
 
+				//region 新建
+				this.insertCouponSend(couponSendVO);
+				//endregion
 
 				return ResponseResultUtil.success();
 			}
 			//endregion
-
 		}
 		//endregion
 
 		//region 不存在 新建
 		else {
-
+			//region 新建
+			this.insertCouponSend(couponSendVO);
+			//endregion
 		}
-
 		//endregion
 
 		return ResponseResultUtil.success();
+	}
 
-
+	/**
+	 * @desc : 新建优惠券获取
+	 * @date : 2024/7/26 10:58
+	 * @author : 寇珊珊
+	 */
+	@Transactional(rollbackFor = {Exception.class})
+	public void insertCouponSend(CouponSendVO couponSendVO) {
+		//查询优惠券
+		List<CouponResponse> couponResponses = couponMapper.selectByCond(new CouponQuery());
+		//发出时间
+		couponSendVO.setSendDate(LocalDateTime.now());
+		//截止时间
+		Integer linkValidTimes = couponResponses.get(0).getLinkValidTimes();
+		couponSendVO.setEndDate(couponSendVO.getSendDate().plusHours(linkValidTimes));
+		CouponSend couponSend = couponSendConvert.convertToPo(couponSendVO);
+		couponSendMapper.insert(couponSend);
 	}
 
 

+ 125 - 6
src/main/java/com/dk/oauth/service/integral/CouponUseService.java

@@ -1,23 +1,142 @@
 package com.dk.oauth.service.integral;
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.dk.common.exception.BaseBusinessException;
+import com.dk.common.infrastructure.annotaiton.Pagination;
+import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.infrastructure.convert.integral.CouponUseConvert;
+import com.dk.oauth.model.VO.integral.CouponReceiveVO;
+import com.dk.oauth.model.VO.integral.CouponUseVO;
+import com.dk.oauth.model.pojo.integral.CouponReceive;
 import com.dk.oauth.model.pojo.integral.CouponUse;
 import com.dk.oauth.mapper.integral.CouponUseMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.oauth.model.query.integral.CouponReceiveQuery;
+import com.dk.oauth.model.query.integral.CouponUseQuery;
+import com.dk.oauth.model.response.integral.CouponReceiveResponse;
+import com.dk.oauth.model.response.integral.CouponUseResponse;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.List;
+import java.util.UUID;
+
 @Service
 @Transactional
 public class CouponUseService extends BaseService<CouponUse> {
 
-	@Override
-	public BaseMapper<CouponUse> getRepository() {
-		return couponUseMapper;
-	}
+    @Override
+    public BaseMapper<CouponUse> getRepository() {
+        return couponUseMapper;
+    }
+
+    @Autowired
+    private CouponUseMapper couponUseMapper;
+
+    @Autowired
+    //优惠券使用实体类型转换
+    private CouponUseConvert couponUseConvert;
+
+
+    /**
+     * @desc : 条件查询
+     * @date : 2024/7/26 11:07
+     * @author : 寇珊珊
+     */
+    @Pagination
+    public ResponseResultVO<PageList<CouponUseResponse>> selectByCond(CouponUseQuery couponReceiveQuery) {
+        return super.mergeListWithCount(couponReceiveQuery, couponUseMapper.selectByCond(couponReceiveQuery),
+                couponUseMapper.countByCond(couponReceiveQuery));
+    }
+
+    /**
+     * @desc : 更新
+     * @date : 2024/7/26 16:50
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> update(CouponUseVO couponUseVO) {
+        //根据id查询
+        CouponUseResponse couponUseResponse = couponUseMapper.selectById(couponUseVO.getUseId());
+        if (couponUseResponse != null) {
+            //已使用
+            if (Constant.couponStatus.YI_SHI_YONG.getName().equals(couponUseResponse.getCouponStatus())) {
+                //优惠券已使用
+                throw new BaseBusinessException(ErrorCodeEnum.COUPON_USED_ALREADY.getCode(), ErrorCodeEnum.COUPON_USED_ALREADY.getMessage());
+            }
+            //已无效
+            if (Constant.couponStatus.YI_SHI_XIAO.getName().equals(couponUseResponse.getCouponStatus())) {
+                //优惠券已使用
+                throw new BaseBusinessException(ErrorCodeEnum.COUPON_INVALID.getCode(), ErrorCodeEnum.COUPON_INVALID.getMessage());
+            }
+            //未使用
+            if (Constant.couponStatus.WEI_SHI_YONG.getName().equals(couponUseResponse.getCouponStatus())) {
+                //类型转换
+                CouponUse couponUse = couponUseConvert.convertToPo(couponUseVO);
+                //优惠券使用id
+                couponUse.setUseId(couponUseResponse.getUseId());
+                //优惠券状态
+                couponUse.setCouponStatus(Constant.couponStatus.YI_SHI_YONG.getName());
+                //核销日期
+                couponUse.setUseDate(LocalDateTime.now());
+                //更新
+                couponUseMapper.update(couponUse,
+                        new UpdateWrapper<CouponUse>().lambda()
+                                .eq(CouponUse::getUseId, UUID.fromString(couponUse.getUseId()))
+                );
+            }
+        } else {
+            //优惠券不存在
+            throw new BaseBusinessException(ErrorCodeEnum.COUPON_IS_NOT_EXIST.getCode(), ErrorCodeEnum.COUPON_IS_NOT_EXIST.getMessage());
+        }
+        return ResponseResultUtil.success();
+    }
+
+    /**
+     * @desc : 检索优惠券状态
+     * @date : 2024/7/26 17:06
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> retrievalCouponStatus() {
+        //查询全部优惠券使用
+        List<CouponUseResponse> couponUseResponseList = couponUseMapper.selectByCond(new CouponUseQuery()
+                .setCouponStatus(Constant.couponStatus.WEI_SHI_YONG.getName()));
+        //数据存在
+        if (couponUseResponseList != null && couponUseResponseList.size() > 0) {
+            for (CouponUseResponse couponUseResponse : couponUseResponseList) {
+                //过期时间
+                long beOverdueTime = couponUseResponse.getReceiveDate().plusDays(couponUseResponse.getUseValidDays()).toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                //当前时间
+                long nowTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                //当前时间大于过期时间   优惠券已过期
+                if ((nowTime / 1000) > (beOverdueTime / 1000)) {
+                    //类型转换
+                    CouponUse couponUse = new CouponUse();
+                    //优惠券使用id
+                    couponUse.setUseId(couponUseResponse.getUseId());
+                    //优惠券状态
+                    couponUse.setCouponStatus(Constant.couponStatus.YI_SHI_XIAO.getName());
+                    //核销日期
+                    couponUse.setUseDate(LocalDateTime.now());
+                    //更新
+                    couponUseMapper.update(couponUse,
+                            new UpdateWrapper<CouponUse>().lambda()
+                                    .eq(CouponUse::getUseId, UUID.fromString(couponUse.getUseId()))
+                    );
+                }
+            }
 
-	@Autowired
-	private CouponUseMapper couponUseMapper;
+        }
+        return ResponseResultUtil.success();
+    }
 
 }