| | |
| | | package com.mzl.flower.service.impl.wallet; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.constant.Constants; |
| | | import com.mzl.flower.dto.request.wallet.CreateWalletBillRecordDTO; |
| | | import com.mzl.flower.dto.request.wallet.QueryWalletBillDTO; |
| | | import com.mzl.flower.dto.response.wallet.WalletBillRecordVO; |
| | | import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO; |
| | | import com.mzl.flower.entity.payment.Transfer; |
| | | import com.mzl.flower.entity.payment.TransferDetail; |
| | | import com.mzl.flower.entity.wallet.WalletBillRecordDO; |
| | | import com.mzl.flower.entity.wallet.WalletDO; |
| | | import com.mzl.flower.entity.wallet.WalletWithdrawRecordDO; |
| | | import com.mzl.flower.mapper.payment.TransferDetailMapper; |
| | | import com.mzl.flower.mapper.payment.TransferMapper; |
| | | import com.mzl.flower.mapper.wallet.WalletBillRecordMapper; |
| | | import com.mzl.flower.mapper.wallet.WalletMapper; |
| | | import com.mzl.flower.mapper.wallet.WalletWithdrawRecordMapper; |
| | | import com.mzl.flower.service.wallet.WalletBillRecordService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mzl.flower.service.wallet.WalletService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private WalletMapper walletMapper; |
| | | |
| | | @Resource |
| | | private WalletWithdrawRecordMapper walletWithdrawRecordMapper; |
| | | @Override |
| | | public void create(CreateWalletBillRecordDTO dto) { |
| | | |
| | |
| | | walletDO.setWithdrawnAmount(walletDO.getWithdrawnAmount().add(walletBillRecordDO.getChangeAmount())); |
| | | walletMapper.updateById(walletDO); |
| | | } |
| | | //回写提现状态 |
| | | if (StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) { |
| | | WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletBillRecordDO.getWithdrawRecordId()); |
| | | withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.SUCCESS.name()); |
| | | walletWithdrawRecordMapper.updateById(withdrawRecordDO); |
| | | } |
| | | |
| | | } else if ("FAIL".equals(dStatus)) { |
| | | walletBillRecordDO.setTransferState(Constants.SETTLEMENT_STATUS.FAILED.name()); |
| | |
| | | walletDO.setWithdrawableAmount(walletDO.getWithdrawableAmount().add(walletBillRecordDO.getChangeAmount())); |
| | | walletMapper.updateById(walletDO); |
| | | } |
| | | //回写提现状态 |
| | | if (StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) { |
| | | WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletBillRecordDO.getWithdrawRecordId()); |
| | | withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.FAILURE.name()); |
| | | walletWithdrawRecordMapper.updateById(withdrawRecordDO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Page<WalletBillRecordVO> getPage(Page page, QueryWalletBillDTO dto) { |
| | | List<WalletBillRecordVO> list = walletBillRecordMapper.getPage(page,dto); |
| | | page.setRecords(list); |
| | | return page; |
| | | } |
| | | } |