| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.training.entity.TrainingRegistration; |
| | | import org.springblade.modules.vip.entity.UserVip; |
| | | import org.springblade.modules.vip.mapper.UserVipMapper; |
| | | import org.springblade.modules.vip.service.UserVipService; |
| | | import org.springblade.modules.vip.vo.UserVipVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户会员服务实现类 |
| | |
| | | @Service |
| | | public class UserVipServiceImpl extends ServiceImpl<UserVipMapper, UserVip> implements UserVipService { |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | /** |
| | | * 自定义分页查询用户会员数据 |
| | |
| | | */ |
| | | @Override |
| | | public boolean insertUserVipInfo(TrainingRegistration trainingRegistration) { |
| | | //1.创建用户会员对象 |
| | | UserVip userVip = new UserVip(); |
| | | //2.数据封装 |
| | | userVip.setApplyId(trainingRegistration.getId()); |
| | | userVip.setCreateTime(new Date()); |
| | | userVip.setUpdateTime(new Date()); |
| | | userVip.setUserId(Long.parseLong(trainingRegistration.getUserId())); |
| | | //先查询之前是否有缴费,比如缴费了取消报名这种情况 |
| | | UserVip userVip1 = new UserVip(); |
| | | userVip1.setUserId(Long.parseLong(trainingRegistration.getUserId())); |
| | | List<UserVip> list = this.list(Condition.getQueryWrapper(userVip1)); |
| | | boolean status = false; |
| | | if (list.size()>0){ |
| | | //更新数据 |
| | | UserVip userVip = list.get(0); |
| | | userVip.setApplyId(trainingRegistration.getId()); |
| | | userVip.setUpdateTime(new Date()); |
| | | //更新 |
| | | status = this.updateById(userVip); |
| | | }else { |
| | | //1.创建用户会员对象 |
| | | UserVip userVip = new UserVip(); |
| | | //2.数据封装 |
| | | userVip.setApplyId(trainingRegistration.getId()); |
| | | userVip.setCreateTime(new Date()); |
| | | userVip.setUpdateTime(new Date()); |
| | | userVip.setUserId(Long.parseLong(trainingRegistration.getUserId())); |
| | | status = this.save(userVip); |
| | | } |
| | | //3.返回 |
| | | return this.save(userVip); |
| | | return status; |
| | | } |
| | | |
| | | /** |
| | | * 查询用户信息(包含用户基本信息及是否缴费/会员) |
| | | * @param userVip |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getUserVipInfo(UserVip userVip) { |
| | | // 根据身份证号查询用户信息 |
| | | User user = new User(); |
| | | user.setCardid(userVip.getIdCardNo()); |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | User user1 = userService.getOne(Condition.getQueryWrapper(user)); |
| | | if (null!=user1){ |
| | | UserVip userVip1 = new UserVip(); |
| | | userVip1.setUserId(user1.getId()); |
| | | UserVip vip = this.getOne(Condition.getQueryWrapper(userVip1)); |
| | | if (null!=vip){ |
| | | UserVipVO vipVO = new UserVipVO(); |
| | | vipVO.setIdCardNo(user1.getCardid()); |
| | | vipVO.setSex(user1.getSex()); |
| | | vipVO.setRealName(user1.getRealName()); |
| | | return vipVO; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |