From 9739e12c89e42a2b445801fea0ad958c5f08281c Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 18 May 2021 18:32:51 +0800 Subject: [PATCH] add entrustOrder and marketBusiness --- src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java | 77 +++++++++++++++++++++++++++++++++++++- 1 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java index 20d147b..ceb5fc2 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java @@ -1,13 +1,86 @@ package com.xcong.excoin.modules.otc.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.xcong.excoin.common.LoginUserUtils; +import com.xcong.excoin.common.exception.GlobalException; +import com.xcong.excoin.common.response.Result; +import com.xcong.excoin.modules.member.entity.MemberEntity; +import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderDao; +import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao; +import com.xcong.excoin.modules.otc.dto.MbAddDto; +import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; -import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessMapper; +import com.xcong.excoin.modules.otc.mapper.OtcEntrustOrderMapper; +import com.xcong.excoin.modules.otc.mapper.OtcMarketBussinessMapper; import com.xcong.excoin.modules.otc.service.OtcMarketBussinessService; +import com.xcong.excoin.modules.otc.vo.EntrustListInfoVo; +import com.xcong.excoin.modules.otc.vo.MarketBussinessInfoVo; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.util.List; + @Service @RequiredArgsConstructor -public class OtcMarketBussinessServiceImpl extends ServiceImpl<OtcMarketBussinessMapper, OtcMarketBussiness> implements OtcMarketBussinessService { +public class OtcMarketBussinessServiceImpl extends ServiceImpl<OtcMarketBussinessDao, OtcMarketBussiness> implements OtcMarketBussinessService { + + private final OtcEntrustOrderDao otcEntrustOrderDao; + + @Override + public void add(MbAddDto mbAddDto) { + MemberEntity member = LoginUserUtils.getAppLoginUser(); + + OtcMarketBussiness mb = this.baseMapper.selectMarketBussinessByMemberId(member.getId()); + if (mb != null) { + throw new GlobalException("该用户已经是市商或正在审核"); + } + + OtcMarketBussiness otcMb = new OtcMarketBussiness(); + otcMb.setNikename(mbAddDto.getNickname()); + otcMb.setMemberId(member.getId()); + otcMb.setAvgCoinTime(0); + otcMb.setAvgPayTime(0); + otcMb.setTotalOrderCnt(0); + otcMb.setBuyCnt(0); + otcMb.setFinishRatio(BigDecimal.ZERO); + otcMb.setStatus(OtcMarketBussiness.CHECK_WAIT); + + this.baseMapper.insert(otcMb); + } + + @Override + public Integer findMbStatus() { + MemberEntity member = LoginUserUtils.getAppLoginUser(); + + OtcMarketBussiness mb = this.baseMapper.selectMarketBussinessByMemberId(member.getId()); + if (mb == null) { + return 0; + } + return mb.getStatus(); + } + + @Override + public Result findMbInfo(Long id) { + OtcMarketBussiness mb = this.baseMapper.selectById(id); + if (mb == null) { + return Result.fail("未找到对应信息"); + } + + MarketBussinessInfoVo mbVo = OtcMarketBussinessMapper.INSTANCE.entityToVo(mb); + + OtcEntrustOrder query = new OtcEntrustOrder(); + query.setMemberId(mb.getMemberId()); + query.setOrderType(OtcEntrustOrder.ORDER_TYPE_B); + query.setStatus(OtcEntrustOrder.LINE_UP); + List<OtcEntrustOrder> buysEntity = otcEntrustOrderDao.selectEntrustOrderByOrderType(query); + List<EntrustListInfoVo> buys = OtcEntrustOrderMapper.INSTANCE.entrustToListInfoVoList(buysEntity); + + query.setOrderType(OtcEntrustOrder.ORDER_TYPE_S); + List<OtcEntrustOrder> salesEntity = otcEntrustOrderDao.selectEntrustOrderByOrderType(query); + List<EntrustListInfoVo> sales = OtcEntrustOrderMapper.INSTANCE.entrustToListInfoVoList(salesEntity); + mbVo.setBuys(buys); + mbVo.setSales(sales); + return Result.ok(mbVo); + } } -- Gitblit v1.9.1