From 73ca3b17a2be81720b08562c0098ebfede61a5a6 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 25 May 2021 18:36:38 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderDao.java | 5 ++ src/main/resources/mapper/otc/OtcSettingDao.xml | 5 ++ src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java | 2 src/main/java/com/xcong/excoin/modules/otc/entity/OtcSetting.java | 13 ++++++ src/main/resources/mapper/otc/OtcOrderDao.xml | 17 ++++++++ src/main/java/com/xcong/excoin/modules/otc/dao/OtcSettingDao.java | 5 ++ src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java | 21 ++++++++++ 7 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderDao.java b/src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderDao.java index 04413c9..e9ad2e1 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderDao.java +++ b/src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderDao.java @@ -6,6 +6,7 @@ import com.xcong.excoin.modules.otc.entity.OtcOrder; import com.xcong.excoin.modules.otc.vo.OrderListVo; import org.apache.ibatis.annotations.Param; +import org.web3j.abi.datatypes.Int; import java.math.BigDecimal; import java.util.List; @@ -29,4 +30,8 @@ BigDecimal selectMemberAvgPayTime(@Param("memberId") Long memberId); BigDecimal selectMemberAvgCoinTime(@Param("memberId") Long memberId); + + List<OtcOrder> selectOrderListForUser(@Param("memberId") Long memberId, @Param("status") Integer status); + + BigDecimal selectOrderTotalAmount(@Param("memberId") Long memberId); } diff --git a/src/main/java/com/xcong/excoin/modules/otc/dao/OtcSettingDao.java b/src/main/java/com/xcong/excoin/modules/otc/dao/OtcSettingDao.java index 5c6c4cf..62b4547 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/dao/OtcSettingDao.java +++ b/src/main/java/com/xcong/excoin/modules/otc/dao/OtcSettingDao.java @@ -1,5 +1,8 @@ package com.xcong.excoin.modules.otc.dao; -public interface OtcSettingDao { +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.xcong.excoin.modules.otc.entity.OtcSetting; + +public interface OtcSettingDao extends BaseMapper<OtcSetting> { } diff --git a/src/main/java/com/xcong/excoin/modules/otc/entity/OtcSetting.java b/src/main/java/com/xcong/excoin/modules/otc/entity/OtcSetting.java index a4bea0d..e428fae 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/entity/OtcSetting.java +++ b/src/main/java/com/xcong/excoin/modules/otc/entity/OtcSetting.java @@ -2,8 +2,21 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import org.web3j.abi.datatypes.Int; + +import java.math.BigDecimal; @Data @TableName("otc_setting") public class OtcSetting { + + private Long id; + + private Integer orderNum; + + private BigDecimal completionRate; + + private BigDecimal totalAmount; + + private Integer cancellNum; } diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java index 6d4d740..693d224 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java @@ -83,7 +83,7 @@ memberWalletCoinDao.updateFrozenBalance(member.getId(), coinWallet.getId(), addDto.getAmount()); } - if (MemberEntity.IS_TRADER_Y.equals(member.getIsTrader())) { + if (!MemberEntity.IS_TRADER_Y.equals(member.getIsTrader())) { throw new GlobalException("不是市商"); } 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 66fbe07..cecad17 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,5 +1,6 @@ package com.xcong.excoin.modules.otc.service.impl; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.exception.GlobalException; @@ -8,9 +9,13 @@ 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.dao.OtcOrderDao; +import com.xcong.excoin.modules.otc.dao.OtcSettingDao; 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.entity.OtcOrder; +import com.xcong.excoin.modules.otc.entity.OtcSetting; import com.xcong.excoin.modules.otc.mapper.OtcEntrustOrderMapper; import com.xcong.excoin.modules.otc.mapper.OtcMarketBussinessMapper; import com.xcong.excoin.modules.otc.service.OtcMarketBussinessService; @@ -28,6 +33,9 @@ private final OtcEntrustOrderDao otcEntrustOrderDao; private final MemberDao memberDao; + private final OtcSettingDao otcSettingDao; + private final OtcOrderDao otcOrderDao; + @Override public void add() { MemberEntity member = LoginUserUtils.getAppLoginUser(); @@ -36,6 +44,19 @@ if (MemberEntity.IS_TRADER_Y.equals(member.getIsTrader())) { throw new GlobalException("已经是市商"); } + OtcSetting setting = otcSettingDao.selectById(1L); + // 所有已完成订单 + List<OtcOrder> finishOrders = otcOrderDao.selectOrderListForUser(member.getId(), 0); + if (CollUtil.isEmpty(finishOrders) || setting.getOrderNum() > finishOrders.size()) { + throw new GlobalException("条件未达标"); + } + + List<OtcOrder> unFinishOrders = otcOrderDao.selectOrderListForUser(member.getId(), 4); + if (CollUtil.isNotEmpty(unFinishOrders)) { + BigDecimal.valueOf(finishOrders.size() - unFinishOrders.size()).divide(BigDecimal.valueOf(finishOrders.size()), 2, BigDecimal.ROUND_DOWN) + } + + BigDecimal totalAmount = otcOrderDao.selectOrderTotalAmount(member.getId()); OtcMarketBussiness mb = this.baseMapper.selectMarketBussinessByMemberId(member.getId()); OtcMarketBussiness otcMb = new OtcMarketBussiness(); diff --git a/src/main/resources/mapper/otc/OtcOrderDao.xml b/src/main/resources/mapper/otc/OtcOrderDao.xml index 8938669..7aafbd5 100644 --- a/src/main/resources/mapper/otc/OtcOrderDao.xml +++ b/src/main/resources/mapper/otc/OtcOrderDao.xml @@ -85,4 +85,21 @@ from otc_order where status=3 and member_id=40 and order_type='S' </select> + + <select id="selectOrderListForUser" resultType="com.xcong.excoin.modules.otc.entity.OtcOrder"> + select * from otc_order + where member_id=#{memberId} + <!-- 查询除完成以外所有订单 --> + <if test="status != null and status == 0"> + and status != 3 + </if> + <if test="status != null and status != 0"> + and status != 3 + </if> + </select> + + <select id="selectOrderTotalAmount" resultType="java.math.BigDecimal"> + select sum(total_amount) from otc_order + where member_id=#{memberId} and status = 3 + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/otc/OtcSettingDao.xml b/src/main/resources/mapper/otc/OtcSettingDao.xml new file mode 100644 index 0000000..85d8c5f --- /dev/null +++ b/src/main/resources/mapper/otc/OtcSettingDao.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.xcong.excoin.modules.otc.dao.OtcSettingDao"> + +</mapper> \ No newline at end of file -- Gitblit v1.9.1