| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | public void hasPay(Long id) { |
| | | OtcOrder otcOrder = this.baseMapper.selectById(id); |
| | | |
| | | if (otcOrder == null) { |
| | | throw new GlobalException("订单不存在"); |
| | | } |
| | | |
| | | if (!OtcOrder.STATUS_SUBMIT.equals(otcOrder.getStatus())) { |
| | | throw new GlobalException("状态不正确"); |
| | | } |
| | | |
| | | if (!OtcEntrustOrder.ORDER_TYPE_B.equals(otcOrder.getOrderType())) { |
| | | throw new GlobalException("不是购买单"); |
| | | } |
| | | |
| | | this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_PAY, otcOrder.getOrderNo()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void finishOrder(Long id) { |
| | | MemberEntity member = LoginUserUtils.getAppLoginUser(); |
| | | OtcOrder otcOrder = this.baseMapper.selectById(id); |
| | | |
| | | if (otcOrder == null) { |
| | | throw new GlobalException("订单不存在"); |
| | | } |
| | | |
| | | if (!OtcOrder.STATUS_PAY.equals(otcOrder.getStatus())) { |
| | | throw new GlobalException("状态不正确"); |
| | | } |
| | | |
| | | if (!OtcEntrustOrder.ORDER_TYPE_S.equals(otcOrder.getOrderType())) { |
| | | throw new GlobalException("不是出售单"); |
| | | } |
| | | |
| | | OtcOrder buyOrder = this.baseMapper.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_B); |
| | | OtcOrder saleOrder = this.baseMapper.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_S); |
| | | MemberWalletCoinEntity buyWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(buyOrder.getMemberId(), "USDT"); |
| | | MemberWalletCoinEntity saleWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(saleOrder.getMemberId(), "USDT"); |
| | | |
| | | // 购买者钱包可用新增币 |
| | | memberWalletCoinDao.updateBlockBalance(buyWallet.getId(), buyOrder.getCoinAmount(), BigDecimal.ZERO, 0); |
| | | |
| | | // 出售者钱包冻结减少币 |
| | | memberWalletCoinDao.reduceFrozenBalance(saleWallet.getId(), buyOrder.getCoinAmount()); |
| | | |
| | | this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_PAY, otcOrder.getOrderNo()); |
| | | } |
| | | } |