|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.core.constants.Constants; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberRevenueMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.WithdrawalOrdersMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.business.model.MemberRevenue; | 
|---|
|  |  |  | import com.doumee.dao.business.model.WithdrawalOrders; | 
|---|
|  |  |  | import com.doumee.dao.dto.WithdrawalDTO; | 
|---|
|  |  |  | import com.doumee.service.business.WithdrawalOrdersService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 提现申请记录Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WithdrawalOrdersMapper withdrawalOrdersMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberRevenueMapper memberRevenueMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(WithdrawalOrders withdrawalOrders) { | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryWrapper<WithdrawalOrders> wrapper = new QueryWrapper<>(withdrawalOrders); | 
|---|
|  |  |  | return withdrawalOrdersMapper.selectCount(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /************************************移动端接口*******************************************/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 提现申请 | 
|---|
|  |  |  | * @param withdrawalDTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void  applyWithdrawal(WithdrawalDTO withdrawalDTO){ | 
|---|
|  |  |  | if(Objects.isNull(withdrawalDTO) | 
|---|
|  |  |  | || Objects.isNull(withdrawalDTO.getAmount())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Member member = memberMapper.selectById(withdrawalDTO.getMember().getId()); | 
|---|
|  |  |  | if(Objects.isNull(member)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户信息异常,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(member.getAmount() < withdrawalDTO.getAmount()){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,可提现余额不足。"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WithdrawalOrders withdrawalOrders = new WithdrawalOrders(); | 
|---|
|  |  |  | withdrawalOrders.setCreateTime(new Date()); | 
|---|
|  |  |  | withdrawalOrders.setMemberId(member.getId()); | 
|---|
|  |  |  | withdrawalOrders.setAmount(withdrawalDTO.getAmount()); | 
|---|
|  |  |  | withdrawalOrders.setStatus(Constants.ZERO); | 
|---|
|  |  |  | withdrawalOrders.setType(Constants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 发起提现申请 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新用户余额 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储流水记录 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|