取消会员

This commit is contained in:
Flow 2025-06-24 10:44:00 +08:00
parent fa416ada57
commit 9b7159f8c1
3 changed files with 27 additions and 0 deletions

View File

@ -148,4 +148,12 @@ public class PersonController {
personService.becomeVip(reqVO);
return success(true);
}
@PutMapping("/cancel-vip")
@Operation(summary = "取消会员")
@Parameter(name = "userid", description = "用户编号", required = true)
public CommonResult<Boolean> cancelVip(@RequestParam("userid") Integer userid) {
personService.cancelVip(userid);
return success(true);
}
}

View File

@ -110,4 +110,11 @@ public interface PersonService {
* @param reqVO 开通会员请求参数
*/
void becomeVip(@Valid PersonBecomeVipReqVO reqVO);
/**
* 取消会员
*
* @param userid 用户编号
*/
void cancelVip(Integer userid);
}

View File

@ -151,4 +151,16 @@ public class PersonServiceImpl implements PersonService {
.set(PersonDO::getVipstarttime, reqVO.getVipstarttime()) // 设置会员开始时间
.set(PersonDO::getVipendtime, reqVO.getVipendtime())); // 设置会员结束时间
}
@Override
public void cancelVip(Integer userid) {
// 校验用户存在
validatePersonExists(userid);
// 取消会员将vipstarttimevipendtime设置为nullisvip设置为0
personMapper.update(null, new LambdaUpdateWrapper<PersonDO>()
.eq(PersonDO::getId, userid)
.set(PersonDO::getIsvip, 0) // 设置为非会员状态
.set(PersonDO::getVipstarttime, null) // 清空会员开始时间
.set(PersonDO::getVipendtime, null)); // 清空会员结束时间
}
}