Search in sources :

Example 1 with MemberReceipt

use of cn.lili.modules.member.entity.dos.MemberReceipt in project lilishop by lilishop.

the class MemberReceiptServiceImpl method deleteMemberReceipt.

@Override
public Boolean deleteMemberReceipt(String id) {
    // 根据会员id查询发票信息
    MemberReceipt memberReceiptDb = this.baseMapper.selectById(id);
    if (memberReceiptDb != null) {
        // 如果会员发票信息不为空 则逻辑删除此发票信息
        memberReceiptDb.setDeleteFlag(false);
        this.baseMapper.updateById(memberReceiptDb);
    }
    return true;
}
Also used : MemberReceipt(cn.lili.modules.member.entity.dos.MemberReceipt)

Example 2 with MemberReceipt

use of cn.lili.modules.member.entity.dos.MemberReceipt in project lilishop by lilishop.

the class MemberReceiptServiceImpl method addMemberReceipt.

@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addMemberReceipt(MemberReceiptAddVO memberReceiptAddVO, String memberId) {
    // 校验发票抬头是否重复
    List<MemberReceipt> receipts = this.baseMapper.selectList(new QueryWrapper<MemberReceipt>().eq("member_id", memberId).eq("receipt_title", memberReceiptAddVO.getReceiptTitle()));
    if (!receipts.isEmpty()) {
        throw new ServiceException(ResultCode.USER_RECEIPT_REPEAT_ERROR);
    }
    // 参数封装
    MemberReceipt memberReceipt = new MemberReceipt();
    BeanUtil.copyProperties(memberReceiptAddVO, memberReceipt);
    // 根据会员信息查询会员
    Member member = memberService.getById(memberId);
    if (member != null) {
        memberReceipt.setMemberId(memberId);
        memberReceipt.setMemberName(member.getUsername());
        // 设置发票默认
        List<MemberReceipt> list = this.baseMapper.selectList(new QueryWrapper<MemberReceipt>().eq("member_id", memberId));
        // 如果当前会员只有一个发票则默认为默认发票,反之需要校验参数默认值,做一些处理
        if (list.isEmpty()) {
            memberReceipt.setIsDefault(1);
        } else {
            if (memberReceiptAddVO.getIsDefault().equals(1)) {
                // 如果参数传递新添加的发票信息为默认,则需要把其他发票置为非默认
                this.update(new UpdateWrapper<MemberReceipt>().eq("member_id", memberId));
                // 设置当前发票信息为默认
                memberReceipt.setIsDefault(memberReceiptAddVO.getIsDefault());
            } else {
                memberReceiptAddVO.setIsDefault(0);
            }
        }
        return this.baseMapper.insert(memberReceipt) > 0 ? true : false;
    }
    throw new ServiceException(ResultCode.USER_RECEIPT_NOT_EXIST);
}
Also used : MemberReceipt(cn.lili.modules.member.entity.dos.MemberReceipt) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with MemberReceipt

use of cn.lili.modules.member.entity.dos.MemberReceipt in project lilishop by lilishop.

the class MemberReceiptServiceImpl method editMemberReceipt.

@Override
@Transactional(rollbackFor = Exception.class)
public Boolean editMemberReceipt(MemberReceiptAddVO memberReceiptAddVO, String memberId) {
    // 根据会员id查询发票信息
    MemberReceipt memberReceiptDb = this.baseMapper.selectById(memberReceiptAddVO.getId());
    if (memberReceiptDb != null) {
        // 检验是否有权限修改
        if (!memberReceiptDb.getMemberId().equals(memberId)) {
            throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
        }
        // 校验发票抬头是否重复
        List<MemberReceipt> receipts = this.baseMapper.selectList(new QueryWrapper<MemberReceipt>().eq("member_id", memberId).eq("receipt_title", memberReceiptAddVO.getReceiptTitle()).ne("id", memberReceiptAddVO.getId()));
        if (!receipts.isEmpty()) {
            throw new ServiceException(ResultCode.USER_RECEIPT_REPEAT_ERROR);
        }
        BeanUtil.copyProperties(memberReceiptAddVO, memberReceiptDb);
        // 对发票默认进行处理  如果参数传递新添加的发票信息为默认,则需要把其他发票置为非默认
        if (memberReceiptAddVO.getIsDefault().equals(1)) {
            this.update(new UpdateWrapper<MemberReceipt>().eq("member_id", memberId));
        }
        return this.baseMapper.updateById(memberReceiptDb) > 0 ? true : false;
    }
    throw new ServiceException(ResultCode.USER_RECEIPT_NOT_EXIST);
}
Also used : MemberReceipt(cn.lili.modules.member.entity.dos.MemberReceipt) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MemberReceipt (cn.lili.modules.member.entity.dos.MemberReceipt)3 ServiceException (cn.lili.common.exception.ServiceException)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)2 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Member (cn.lili.modules.member.entity.dos.Member)1