init
This commit is contained in:
@@ -22,4 +22,8 @@ public interface AnchorApplyService extends IService<AnchorApply> {
|
||||
AnchorJoinHomeVo joinHome(Long userId);
|
||||
|
||||
boolean joinAnchor(Long userId);
|
||||
|
||||
void auditAnchorSuccess(Long id);
|
||||
|
||||
void auditAnchorFail(Long id);
|
||||
}
|
||||
|
||||
@@ -3,17 +3,24 @@ package com.ruoyi.cai.service.impl;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.Anchor;
|
||||
import com.ruoyi.cai.domain.AnchorApply;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.dto.admin.vo.AnchorApplyAdminVo;
|
||||
import com.ruoyi.cai.dto.app.vo.AnchorJoinHomeVo;
|
||||
import com.ruoyi.cai.enums.AuditStatusEnum;
|
||||
import com.ruoyi.cai.enums.GenderEnum;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import com.ruoyi.cai.mapper.AnchorApplyMapper;
|
||||
import com.ruoyi.cai.service.AnchorApplyService;
|
||||
import com.ruoyi.cai.service.AnchorService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -28,6 +35,10 @@ public class AnchorApplyServiceImpl extends ServiceImpl<AnchorApplyMapper, Ancho
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AnchorService anchorService;
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
@Override
|
||||
public AnchorApply getByUserId(Long userId){
|
||||
@@ -76,17 +87,62 @@ public class AnchorApplyServiceImpl extends ServiceImpl<AnchorApplyMapper, Ancho
|
||||
throw new ServiceException("您还未同意个人协议");
|
||||
}
|
||||
AnchorApply anchorApply = this.getByUserId(userId);
|
||||
if(anchorApply != null && anchorApply.getStatus() == 1){
|
||||
if(anchorApply != null && AuditStatusEnum.AUDITING.getCode().equals(anchorApply.getAuditStatus())){
|
||||
throw new ServiceException("您的提交的申请正在审核中请耐心等待");
|
||||
}
|
||||
if(anchorApply == null){
|
||||
anchorApply = new AnchorApply();
|
||||
}else{
|
||||
anchorApply.setAuditCount(anchorApply.getAuditCount()+1);
|
||||
}
|
||||
anchorApply.setStatus(1);
|
||||
anchorApply = new AnchorApply();
|
||||
anchorApply.setUserId(userId);
|
||||
anchorApply.setAuditStatus(AuditStatusEnum.AUDITING.getCode());
|
||||
anchorApply.setCreateTime(LocalDateTime.now());
|
||||
this.saveOrUpdate(anchorApply);
|
||||
this.save(anchorApply);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditAnchorSuccess(Long id) {
|
||||
AnchorApply anchorApply = this.getById(id);
|
||||
if(anchorApply == null){
|
||||
throw new ServiceException("审核失败,数据不存在");
|
||||
}
|
||||
Long userId = anchorApply.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
Anchor anchor = anchorService.getByUserId(userId);
|
||||
if(user == null){
|
||||
throw new ServiceException("用户不存在");
|
||||
}
|
||||
if(user.getIsAnchor() == 1 || anchor != null){
|
||||
throw new ServiceException("改用户已经是主播");
|
||||
}
|
||||
if(!GenderEnum.WOMEN.getCode().equals(user.getGender())){
|
||||
throw new ServiceException("只有女用户可以加入主播");
|
||||
}
|
||||
boolean boo = userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId, user.getId()).eq(User::getIsAnchor, 0)
|
||||
.set(User::getIsAnchor, 1));
|
||||
if(!boo){
|
||||
throw new ServiceException("加入主播失败");
|
||||
}
|
||||
this.update(Wrappers.lambdaUpdate(AnchorApply.class)
|
||||
.eq(AnchorApply::getId,id)
|
||||
.set(AnchorApply::getAuditTime,LocalDateTime.now())
|
||||
.set(AnchorApply::getAuditStatus,AuditStatusEnum.SUCCESS.getCode()));
|
||||
Long price = systemConfigManager.getSystemConfigOfLong(SystemConfigEnum.DEFAULT_ANCHOR_PRICE);
|
||||
Anchor save = new Anchor();
|
||||
save.setUserId(user.getId());
|
||||
save.setPrice(price);
|
||||
save.setVideoRate(systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.DEFAULT_ANCHOR_VIDEO_PRICE));
|
||||
save.setGuardRate(systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.DEFAULT_ANCHOR_GUARD_PRICE));
|
||||
save.setGiftRate(systemConfigManager.getSystemConfigOfBigDecimal(SystemConfigEnum.DEFAULT_ANCHOR_GIFT_PRICE));
|
||||
anchorService.save(save);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditAnchorFail(Long id) {
|
||||
this.update(Wrappers.lambdaUpdate(AnchorApply.class)
|
||||
.eq(AnchorApply::getId,id)
|
||||
.set(AnchorApply::getAuditTime,LocalDateTime.now())
|
||||
.set(AnchorApply::getAuditStatus,AuditStatusEnum.FAIL.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.ruoyi.common.exception.ServiceException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 女神列表Service业务层处理
|
||||
@@ -36,6 +37,7 @@ public class AnchorServiceImpl extends ServiceImpl<AnchorMapper, Anchor> impleme
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void joinAnchor(Long userId){
|
||||
User user = userService.getById(userId);
|
||||
Anchor anchor = this.getByUserId(userId);
|
||||
@@ -72,6 +74,7 @@ public class AnchorServiceImpl extends ServiceImpl<AnchorMapper, Anchor> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void closeAnchor(Long userId){
|
||||
User user = userService.getById(userId);
|
||||
Anchor anchor = this.getByUserId(userId);
|
||||
|
||||
Reference in New Issue
Block a user