From 1e2e5bc6044278852114c812d87f271a3f1c9b5d Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 07 Jul 2020 17:25:49 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java | 42 ++++++++++++++++++++++++++---------------- 1 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java b/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java index 7dbddec..3e6014a 100644 --- a/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java @@ -15,19 +15,19 @@ import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.enumerates.CoinTypeEnum; import com.xcong.excoin.common.response.Result; -import com.xcong.excoin.modules.home.dao.MemberPaymentMethodDao; import com.xcong.excoin.modules.home.dao.MemberQuickBuySaleDao; import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto; import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto; -import com.xcong.excoin.modules.home.entity.MemberPaymentMethodEntity; import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity; import com.xcong.excoin.modules.home.mapper.MemberQuickBuySaleEntityMapper; import com.xcong.excoin.modules.home.service.MemberQuickBuySaleService; import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleDetailVo; import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleVo; import com.xcong.excoin.modules.member.dao.MemberDao; +import com.xcong.excoin.modules.member.dao.MemberPaymentMethodDao; import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao; import com.xcong.excoin.modules.member.entity.MemberEntity; +import com.xcong.excoin.modules.member.entity.MemberPaymentMethodEntity; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; import com.xcong.excoin.modules.platform.dao.PlatformPaymentMethodDao; import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity; @@ -70,7 +70,7 @@ MemberQuickBuySaleVo memberQuickBuySaleVo = new MemberQuickBuySaleVo(); memberQuickBuySaleVo.setId(memberQuickBuySaleEntity.getId()); // 返回前台付款方式 - return Result.ok(memberQuickBuySaleVo); + return Result.ok("提交成功",memberQuickBuySaleVo); } @Override @@ -183,19 +183,29 @@ MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectByIdAndMemberId(member.getId(),id); memberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_CANCEL_USER); memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity); - - // 判断是否存在足够余额 - MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(),CoinTypeEnum.USDT.toString()); - boolean flag = true; - while(flag) { - walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(memberQuickBuySaleEntity.getAmountUsdt())); - walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(memberQuickBuySaleEntity.getAmountUsdt())); - int i = memberWalletCoinDao.updateById(walletCoin); - if(i>0) { - flag = false; - } - walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(),CoinTypeEnum.USDT.toString()); - } return Result.ok("成功"); } + + @Override + public Result cancelSell(Long id) { + // 获取当前登录用户 + MemberEntity member = LoginUserUtils.getAppLoginUser(); + MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectByIdAndMemberId(member.getId(),id); + if(memberQuickBuySaleEntity!=null) { + memberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_CANCEL_USER); + memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity); + + MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(),CoinTypeEnum.USDT.toString()); + // 冻结资金返回可用 + int i = memberWalletCoinDao.subFrozenBalance(member.getId(), + walletCoin.getId(), memberQuickBuySaleEntity.getAmountUsdt()); + if(i<0) { + return Result.fail("撤单失败"); + } + return Result.ok("成功"); + }else { + return Result.fail("订单不存在"); + } + + } } -- Gitblit v1.9.1