src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java
@@ -60,6 +60,10 @@ throw ex; } if (profiles.equals("dev")) { throw ex; } SysExceptionDetailEntity exceptionData = new SysExceptionDetailEntity(); String exStr = printStackTraceToString(ex); ThreadPoolUtils.EXECUTOR.execute(new Runnable(){ src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
@@ -127,12 +127,12 @@ authInfo.put("user", memberInfoVo); } BigDecimal total = coinService.getAllWalletAmount(memberEntity.getId()); if (total.compareTo(AppContants.BASE_MIN_AMOUNT) > 0) { authInfo.put("baseUrl", AppContants.BASE_URL_L2); } else { // BigDecimal total = coinService.getAllWalletAmount(memberEntity.getId()); // if (total.compareTo(AppContants.BASE_MIN_AMOUNT) > 0) { // authInfo.put("baseUrl", AppContants.BASE_URL_L2); // } else { authInfo.put("baseUrl", AppContants.BASE_URL_L1); } // } return Result.ok("success", authInfo); } src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java
@@ -12,6 +12,7 @@ import com.xcong.excoin.common.system.bean.LoginUserBean; import com.xcong.excoin.configurations.properties.ApplicationProperties; import com.xcong.excoin.configurations.properties.SecurityProperties; import com.xcong.excoin.modules.member.dao.MemberDao; import com.xcong.excoin.modules.member.entity.MemberEntity; import com.xcong.excoin.utils.RedisUtils; import com.xcong.excoin.utils.SpringContextHolder; @@ -28,6 +29,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.swing.*; import java.io.IOException; import java.util.ArrayList; src/main/java/com/xcong/excoin/modules/otc/controller/OtcEntrustOrderController.java
New file @@ -0,0 +1,109 @@ package com.xcong.excoin.modules.otc.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.member.entity.MemberEntity; import com.xcong.excoin.modules.otc.dto.EntrustOrderAddDto; import com.xcong.excoin.modules.otc.dto.EntrustOrderListDto; import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.service.OtcEntrustOrderService; import com.xcong.excoin.modules.otc.vo.EntrustListInfoVo; import com.xcong.excoin.modules.otc.vo.EntrustListVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.web3j.abi.datatypes.Int; import javax.validation.Valid; @Slf4j @RestController @RequiredArgsConstructor @RequestMapping(value = "/api/otcOrder") @Validated @Api(value = "OtcEntrustOrderController", tags = "otc委托订单接口类") public class OtcEntrustOrderController { private final OtcEntrustOrderService otcEntrustOrderService; @ApiOperation(value = "添加otc委托单", notes = "添加otc委托单") @PostMapping(value = "/addEntrustOrder") public Result addEntrustOrder(@RequestBody EntrustOrderAddDto addDto) { otcEntrustOrderService.add(addDto); return Result.ok("添加成功"); } @ApiOperation(value = "编辑otc委托单", notes = "编辑otc委托单") @PostMapping(value = "/modifyEntrustOrder") public Result modifyEntrustOrder(@RequestBody EntrustOrderAddDto modifyDto) { otcEntrustOrderService.modify(modifyDto); return Result.ok("编辑成功"); } @ApiOperation(value = "获取otc委托单列表", notes = "获取otc委托单列表") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = EntrustListVo.class) }) @PostMapping(value = "/findEntrustOrderList") public Result findEntrustOrderList(@RequestBody EntrustOrderListDto orderListDto) { IPage<EntrustListVo> result = this.otcEntrustOrderService.findEntrustListInPage(orderListDto); return Result.ok(result.getRecords()); } @ApiOperation(value = "获取我的委托单列表", notes = "获取我的委托单列表") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = EntrustListInfoVo.class) }) @GetMapping(value = "/findOwnEntrustOrderList") public Result findOwnEntrustOrderList() { return Result.ok(otcEntrustOrderService.findOwnEntrustOrder()); } @ApiOperation(value = "获取我的委托单详情") @GetMapping(value = "/findOwnOrderDetail/{id}") public Result findOwnOrderDetail(@PathVariable("id") Long id) { return otcEntrustOrderService.findEntrustOrderDetail(id); } @ApiOperation(value = "上/下线接口") @PostMapping(value = "/upOrDownList/{id}") public Result upOrDownList(@PathVariable("id") Long id) { MemberEntity member = LoginUserUtils.getAppLoginUser(); OtcEntrustOrder otcEntrustOrder = this.otcEntrustOrderService.getById(id); if (otcEntrustOrder == null) { return Result.fail("数据不存在"); } if (!member.getId().equals(otcEntrustOrder.getMemberId())) { return Result.fail("数据错误"); } Integer status = otcEntrustOrder.getStatus(); otcEntrustOrder = new OtcEntrustOrder(); otcEntrustOrder.setId(id); if (status.equals(OtcEntrustOrder.LINE_DOWN)) { otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_UP); } else { otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_DOWN); } this.otcEntrustOrderService.updateById(otcEntrustOrder); return Result.ok("修改成功"); } @ApiOperation(value = "撤销委托单") @PostMapping(value = "/cancelOrder/{id}") public Result cancelOrder(@PathVariable("id") Long id) { this.otcEntrustOrderService.cancelEntrustOrder(id); return Result.ok("撤销成功"); } } src/main/java/com/xcong/excoin/modules/otc/controller/OtcMarketBussinessController.java
New file @@ -0,0 +1,80 @@ package com.xcong.excoin.modules.otc.controller; import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.member.entity.MemberEntity; import com.xcong.excoin.modules.otc.dto.MbAddDto; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; import com.xcong.excoin.modules.otc.mapper.OtcMarketBussinessMapper; import com.xcong.excoin.modules.otc.service.OtcEntrustOrderService; import com.xcong.excoin.modules.otc.service.OtcMarketBussinessService; import com.xcong.excoin.modules.otc.vo.MarketBussinessInfoVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; @Slf4j @Validated @RestController @RequiredArgsConstructor @RequestMapping(value = "/api/marketBussiness") @Api(value = "OtcMarketBussinessController", tags = "otc市商接口类") public class OtcMarketBussinessController { private final OtcMarketBussinessService otcMarketBussinessService; private final OtcEntrustOrderService otcEntrustOrderService; @ApiOperation(value = "applyMarketBussiness", notes = "申请市商接口") @PostMapping(value = "/applyMaketBussiness") public Result applyMarketBussiness(@RequestBody MbAddDto mbAddDto) { otcMarketBussinessService.add(mbAddDto); return Result.ok("申请成功, 等待审核"); } @ApiOperation(value = "modifyMarketBussiness", notes = "修改个人信息") @PostMapping(value = "/modifyMarketBussiness") public Result modifyMarketBussiness(@RequestBody MbAddDto mbAddDto) { if (mbAddDto.getId() == null) { return Result.fail("id不能为空"); } OtcMarketBussiness mb = otcMarketBussinessService.getById(mbAddDto.getId()); if (mb == null) { return Result.fail("市商不存在"); } if (!mb.getStatus().equals(OtcMarketBussiness.CHECK_PASS)) { return Result.fail("暂不能修改信息"); } OtcMarketBussiness otcMb = new OtcMarketBussiness(); otcMb.setId(mbAddDto.getId()); otcMb.setNikename(mbAddDto.getNickname()); otcMarketBussinessService.updateById(otcMb); return Result.ok("修改成功"); } @ApiOperation(value = "findMarketBussinessStatus", notes = "获取市商申请状态接口") @GetMapping(value = "/findMarketBussinessStatus") public Result findMarketBussinessStatus() { return Result.ok("获取成功", otcMarketBussinessService.findMbStatus()); } @ApiOperation(value = "findMbInfo", notes = "获取市商信息") @ApiResponses({ @ApiResponse(code = 200, message = "获取成功", response = MarketBussinessInfoVo.class) }) @GetMapping(value = "/findMbInfo/{id}") public Result findMbInfo(@PathVariable("id") Long id) { return this.otcMarketBussinessService.findMbInfo(id); } } src/main/java/com/xcong/excoin/modules/otc/dao/OtcEntrustOrderDao.java
New file @@ -0,0 +1,19 @@ package com.xcong.excoin.modules.otc.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xcong.excoin.modules.otc.dto.EntrustOrderListDto; import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.vo.EntrustListVo; import org.apache.ibatis.annotations.Param; import java.util.List; public interface OtcEntrustOrderDao extends BaseMapper<OtcEntrustOrder> { IPage<EntrustListVo> selectEntrustListInPage(@Param("record") EntrustOrderListDto dto, Page<EntrustListVo> page); List<OtcEntrustOrder> selectEntrustOrderByOrderType(@Param("record") OtcEntrustOrder otcEntrustOrder); } src/main/java/com/xcong/excoin/modules/otc/dao/OtcEntrustOrderMapper.java
File was deleted src/main/java/com/xcong/excoin/modules/otc/dao/OtcMarketBussinessDao.java
New file @@ -0,0 +1,10 @@ package com.xcong.excoin.modules.otc.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; import org.apache.ibatis.annotations.Param; public interface OtcMarketBussinessDao extends BaseMapper<OtcMarketBussiness> { OtcMarketBussiness selectMarketBussinessByMemberId(@Param("memberId") Long memberId); } src/main/java/com/xcong/excoin/modules/otc/dao/OtcMarketBussinessMapper.java
File was deleted src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderAppealDao.java
File was renamed from src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderAppealMapper.java @@ -3,5 +3,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.otc.entity.OtcOrderAppeal; public interface OtcOrderAppealMapper extends BaseMapper<OtcOrderAppeal> { public interface OtcOrderAppealDao extends BaseMapper<OtcOrderAppeal> { } src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderDao.java
New file @@ -0,0 +1,12 @@ package com.xcong.excoin.modules.otc.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.otc.entity.OtcOrder; import org.apache.ibatis.annotations.Param; import java.util.List; public interface OtcOrderDao extends BaseMapper<OtcOrder> { List<OtcOrder> selectOrderListUnFinish(@Param("memberId") Long memberId, @Param("entrustOrderId") Long entrustOrderId); } src/main/java/com/xcong/excoin/modules/otc/dao/OtcOrderMapper.java
File was deleted src/main/java/com/xcong/excoin/modules/otc/dto/EntrustOrderAddDto.java
New file @@ -0,0 +1,38 @@ package com.xcong.excoin.modules.otc.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import java.math.BigDecimal; @Data @ApiModel(value = "EntrustOrderAddDto", description = "添加委托单接口参数接收类") public class EntrustOrderAddDto { @ApiModelProperty(value = "id-编辑时传") private Long id; @NotBlank(message = "单价不能为空") @ApiModelProperty(value = "单价", example = "1") private BigDecimal unitPrice; @NotBlank(message = "数量不能为空") @ApiModelProperty(value = "数量", example = "1") private BigDecimal amount; @ApiModelProperty(value = "总额", example = "1") private BigDecimal totalAmount; @ApiModelProperty(value = "限额 - 最大值", example = "2") private BigDecimal max; @ApiModelProperty(value = "限额 - 最小值", example = "1") private BigDecimal min; @NotBlank(message = "委托单类型不能为空") @ApiModelProperty(value = "类型", example = "B/买-S/卖 编辑不传") private String type; } src/main/java/com/xcong/excoin/modules/otc/dto/EntrustOrderListDto.java
New file @@ -0,0 +1,27 @@ package com.xcong.excoin.modules.otc.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "EntrustOrderListDto", description = "委托单列表接口参数接收类") public class EntrustOrderListDto { @NotNull @Min(1) @ApiModelProperty(value = "第几页", example = "1") private Integer pageNum; @NotNull @ApiModelProperty(value = "每页数量", example = "10") private Integer pageSize; @NotBlank @ApiModelProperty(value = "类型", example = "B-买 S-卖") private String type; } src/main/java/com/xcong/excoin/modules/otc/dto/MbAddDto.java
New file @@ -0,0 +1,21 @@ package com.xcong.excoin.modules.otc.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "MbAddDto", description = "申请市商接口参数接收类") public class MbAddDto { @ApiModelProperty(value = "id - 编辑时传") private Long id; @NotBlank(message = "昵称不能为空") @ApiModelProperty(value = "昵称", example = "123") private String nickname; } src/main/java/com/xcong/excoin/modules/otc/entity/OtcEntrustOrder.java
@@ -15,6 +15,11 @@ private Long mbId; /** * 委托单号 */ private String entrustOrderNo; /** * 单价 */ private BigDecimal unitPrice; @@ -40,12 +45,29 @@ private BigDecimal limitMaxAmount; /** * 委托单类型 B-买S-卖 * 委托总金额 */ private String orderType; private BigDecimal totalAmount; /** * 1-上线 2-下线 * 委托单类型 B-买 S-卖 */ private String orderType; public static final String ORDER_TYPE_B = "B"; public static final String ORDER_TYPE_S = "S"; /** * 1-上线 2-下线 3-撤销 */ private Integer status; public static final Integer LINE_UP = 1; public static final Integer LINE_DOWN = 2; public static final Integer LINE_CANCEL = 3; /** * 是否市商 1-是 2-否 */ private Integer isMb; public static final Integer IS_MB_Y = 1; public static final Integer IS_MB_N = 2; } src/main/java/com/xcong/excoin/modules/otc/entity/OtcMarketBussiness.java
@@ -20,6 +20,9 @@ * 1-待审核2-审核通过3-审核拒绝 */ private Integer status; public static final Integer CHECK_WAIT = 1; public static final Integer CHECK_PASS = 2; public static final Integer CHECK_REFUSE = 3; private Integer buyCnt; src/main/java/com/xcong/excoin/modules/otc/mapper/OtcEntrustOrderMapper.java
New file @@ -0,0 +1,39 @@ package com.xcong.excoin.modules.otc.mapper; import com.xcong.excoin.modules.otc.dto.EntrustOrderAddDto; import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.vo.EntrustListInfoVo; import com.xcong.excoin.modules.otc.vo.EntrustOrderDetailVo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; @Mapper public abstract class OtcEntrustOrderMapper { public static OtcEntrustOrderMapper INSTANCE = Mappers.getMapper(OtcEntrustOrderMapper.class); @Mapping(target = "coinAmount", source = "amount") @Mapping(target = "limitMinAmount", source = "min") @Mapping(target = "limitMaxAmount", source = "max") @Mapping(target = "orderType", source = "type") public abstract OtcEntrustOrder entrustOrderDtoToEntity(EntrustOrderAddDto entrustOrderAddDto); @Mapping(target = "min", source = "limitMinAmount") @Mapping(target = "max", source = "limitMaxAmount") @Mapping(target = "amount", source = "coinAmount") @Mapping(target = "remainAmount", source = "remainCoinAmount") public abstract EntrustListInfoVo entityToListInfoVo(OtcEntrustOrder otcEntrustOrder); public abstract List<EntrustListInfoVo> entrustToListInfoVoList(List<OtcEntrustOrder> list); @Mapping(target = "min", source = "limitMinAmount") @Mapping(target = "max", source = "limitMaxAmount") @Mapping(target = "amount", source = "coinAmount") @Mapping(target = "remainAmount", source = "remainCoinAmount") @Mapping(target = "orderNo", source = "entrustOrderNo") public abstract EntrustOrderDetailVo entityToOrderDetail(OtcEntrustOrder order); } src/main/java/com/xcong/excoin/modules/otc/mapper/OtcMarketBussinessMapper.java
New file @@ -0,0 +1,14 @@ package com.xcong.excoin.modules.otc.mapper; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; import com.xcong.excoin.modules.otc.vo.MarketBussinessInfoVo; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @Mapper public abstract class OtcMarketBussinessMapper { public static OtcMarketBussinessMapper INSTANCE = Mappers.getMapper(OtcMarketBussinessMapper.class); public abstract MarketBussinessInfoVo entityToVo(OtcMarketBussiness otcMarketBussiness); } src/main/java/com/xcong/excoin/modules/otc/service/OtcEntrustOrderService.java
@@ -1,7 +1,27 @@ package com.xcong.excoin.modules.otc.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.otc.dto.EntrustOrderAddDto; import com.xcong.excoin.modules.otc.dto.EntrustOrderListDto; import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.vo.EntrustListInfoVo; import com.xcong.excoin.modules.otc.vo.EntrustListVo; import java.util.List; public interface OtcEntrustOrderService extends IService<OtcEntrustOrder> { void add(EntrustOrderAddDto addDto); void modify(EntrustOrderAddDto modifyDto); IPage<EntrustListVo> findEntrustListInPage(EntrustOrderListDto dto); List<EntrustListInfoVo> findOwnEntrustOrder(); void cancelEntrustOrder(Long id); Result findEntrustOrderDetail(Long id); } src/main/java/com/xcong/excoin/modules/otc/service/OtcMarketBussinessService.java
@@ -1,7 +1,15 @@ package com.xcong.excoin.modules.otc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.otc.dto.MbAddDto; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; public interface OtcMarketBussinessService extends IService<OtcMarketBussiness> { void add(MbAddDto mbAddDto); Integer findMbStatus(); Result findMbInfo(Long id); } src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java
@@ -1,14 +1,204 @@ package com.xcong.excoin.modules.otc.service.impl; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.common.system.service.CommonService; import com.xcong.excoin.modules.member.dao.MemberAuthenticationDao; 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.otc.dao.OtcMarketBussinessDao; import com.xcong.excoin.modules.otc.dao.OtcOrderDao; import com.xcong.excoin.modules.otc.dto.EntrustOrderAddDto; import com.xcong.excoin.modules.otc.dto.EntrustOrderListDto; import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderMapper; import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderDao; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; import com.xcong.excoin.modules.otc.entity.OtcOrder; import com.xcong.excoin.modules.otc.mapper.OtcEntrustOrderMapper; import com.xcong.excoin.modules.otc.service.OtcEntrustOrderService; import com.xcong.excoin.modules.otc.vo.EntrustListInfoVo; import com.xcong.excoin.modules.otc.vo.EntrustListVo; import com.xcong.excoin.modules.otc.vo.EntrustOrderDetailVo; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.List; @Service @RequiredArgsConstructor public class OtcEntrustOrderServiceImpl extends ServiceImpl<OtcEntrustOrderMapper, OtcEntrustOrder> implements OtcEntrustOrderService { public class OtcEntrustOrderServiceImpl extends ServiceImpl<OtcEntrustOrderDao, OtcEntrustOrder> implements OtcEntrustOrderService { private final OtcMarketBussinessDao otcMarketBussinessDao; private final MemberDao memberDao; private final MemberPaymentMethodDao memberPaymentMethodDao; private final MemberWalletCoinDao memberWalletCoinDao; private final OtcOrderDao otcOrderDao; private final CommonService commonService; @Override @Transactional(rollbackFor = Exception.class) public void add(EntrustOrderAddDto addDto) { MemberEntity member = LoginUserUtils.getAppLoginUser(); OtcEntrustOrder otcEntrustOrder = OtcEntrustOrderMapper.INSTANCE.entrustOrderDtoToEntity(addDto); otcEntrustOrder.setMemberId(member.getId()); member = memberDao.selectById(member.getId()); if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) { throw new GlobalException("未实名认证"); } List<MemberPaymentMethodEntity> payments = memberPaymentMethodDao.selectByMemberId(member.getId()); if (CollUtil.isEmpty(payments)) { throw new GlobalException("未绑定收款方式"); } BigDecimal totalAmount = addDto.getUnitPrice().multiply(addDto.getAmount()); otcEntrustOrder.setTotalAmount(totalAmount); if (OtcEntrustOrder.ORDER_TYPE_S.equals(addDto.getType())) { MemberWalletCoinEntity coinWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT"); if(coinWallet.getAvailableBalance().compareTo(totalAmount) < 0) { throw new GlobalException("可用金额不足"); } memberWalletCoinDao.updateFrozenBalance(member.getId(), coinWallet.getId(), totalAmount); } OtcMarketBussiness mb = otcMarketBussinessDao.selectMarketBussinessByMemberId(member.getId()); if (mb == null) { otcEntrustOrder.setIsMb(OtcEntrustOrder.IS_MB_N); } else { otcEntrustOrder.setMbId(mb.getId()); otcEntrustOrder.setIsMb(OtcEntrustOrder.IS_MB_Y); } otcEntrustOrder.setRemainCoinAmount(addDto.getAmount()); otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_UP); otcEntrustOrder.setEntrustOrderNo(commonService.generateOrderNo(member.getId())); otcEntrustOrder.setId(null); this.baseMapper.insert(otcEntrustOrder); } @Override @Transactional(rollbackFor = Exception.class) public void modify(EntrustOrderAddDto modifyDto) { MemberEntity member = LoginUserUtils.getAppLoginUser(); OtcEntrustOrder otcEntrustOrder = OtcEntrustOrderMapper.INSTANCE.entrustOrderDtoToEntity(modifyDto); otcEntrustOrder.setMemberId(member.getId()); otcEntrustOrder.setRemainCoinAmount(modifyDto.getAmount()); otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_UP); List<OtcOrder> orders = otcOrderDao.selectOrderListUnFinish(member.getId(), otcEntrustOrder.getId()); if (CollUtil.isNotEmpty(orders)) { throw new GlobalException("存在未完成的订单, 无法编辑"); } OtcEntrustOrder prevEntity = this.baseMapper.selectById(modifyDto.getId()); if (prevEntity == null) { throw new GlobalException("参数错误"); } if (!prevEntity.getOrderType().equals(modifyDto.getType())) { throw new GlobalException("类型错误"); } OtcMarketBussiness mb = otcMarketBussinessDao.selectMarketBussinessByMemberId(member.getId()); if (mb == null) { otcEntrustOrder.setIsMb(OtcEntrustOrder.IS_MB_N); } else { otcEntrustOrder.setMbId(mb.getId()); otcEntrustOrder.setIsMb(OtcEntrustOrder.IS_MB_Y); } BigDecimal totalAmount = modifyDto.getUnitPrice().multiply(modifyDto.getAmount()); otcEntrustOrder.setTotalAmount(totalAmount); if (OtcEntrustOrder.ORDER_TYPE_S.equals(modifyDto.getType())) { MemberWalletCoinEntity coinWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT"); coinWallet.setAvailableBalance(coinWallet.getAvailableBalance().add(coinWallet.getFrozenBalance())); if(coinWallet.getAvailableBalance().compareTo(totalAmount) < 0) { throw new GlobalException("可用金额不足"); } coinWallet.setAvailableBalance(coinWallet.getAvailableBalance().subtract(totalAmount)); coinWallet.setFrozenBalance(totalAmount); memberWalletCoinDao.updateById(coinWallet); } this.baseMapper.updateById(otcEntrustOrder); } @Override public IPage<EntrustListVo> findEntrustListInPage(EntrustOrderListDto dto) { Page<EntrustListVo> page = new Page<>(dto.getPageNum(), dto.getPageSize()); return this.baseMapper.selectEntrustListInPage(dto, page); } @Override public List<EntrustListInfoVo> findOwnEntrustOrder() { MemberEntity member = LoginUserUtils.getAppLoginUser(); OtcEntrustOrder query = new OtcEntrustOrder(); query.setStatus(3); query.setMemberId(member.getId()); List<OtcEntrustOrder> otcEntrustOrders = this.baseMapper.selectEntrustOrderByOrderType(query); return OtcEntrustOrderMapper.INSTANCE.entrustToListInfoVoList(otcEntrustOrders); } @Override @Transactional(rollbackFor = Exception.class) public void cancelEntrustOrder(Long id) { MemberEntity member = LoginUserUtils.getAppLoginUser(); OtcEntrustOrder otcEntrustOrder = this.baseMapper.selectById(id); if (otcEntrustOrder == null) { throw new GlobalException("参数错误"); } if (OtcEntrustOrder.LINE_CANCEL.equals(otcEntrustOrder.getStatus())) { throw new GlobalException("请勿重复撤销"); } List<OtcOrder> orders = otcOrderDao.selectOrderListUnFinish(member.getId(), otcEntrustOrder.getId()); if (CollUtil.isNotEmpty(orders)) { throw new GlobalException("存在未完成的订单, 无法撤销"); } if (OtcEntrustOrder.ORDER_TYPE_S.equals(otcEntrustOrder.getOrderType())) { MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT"); memberWalletCoinDao.subFrozenBalance(member.getId(), wallet.getId(), wallet.getFrozenBalance()); } otcEntrustOrder = new OtcEntrustOrder(); otcEntrustOrder.setId(id); otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_CANCEL); this.baseMapper.updateById(otcEntrustOrder); } @Override public Result findEntrustOrderDetail(Long id) { MemberEntity member = LoginUserUtils.getAppLoginUser(); OtcEntrustOrder otcEntrustOrder = this.baseMapper.selectById(id); if (otcEntrustOrder == null) { return Result.fail("参数错误"); } if (!member.getId().equals(otcEntrustOrder.getMemberId())) { return Result.fail("请求有误"); } EntrustOrderDetailVo detail = OtcEntrustOrderMapper.INSTANCE.entityToOrderDetail(otcEntrustOrder); return Result.ok(detail); } } 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); } } src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderAppealServiceImpl.java
@@ -2,12 +2,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.excoin.modules.otc.entity.OtcOrderAppeal; import com.xcong.excoin.modules.otc.dao.OtcOrderAppealMapper; import com.xcong.excoin.modules.otc.dao.OtcOrderAppealDao; import com.xcong.excoin.modules.otc.service.OtcOrderAppealService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class OtcOrderAppealServiceImpl extends ServiceImpl<OtcOrderAppealMapper, OtcOrderAppeal> implements OtcOrderAppealService { public class OtcOrderAppealServiceImpl extends ServiceImpl<OtcOrderAppealDao, OtcOrderAppeal> implements OtcOrderAppealService { } src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java
@@ -2,12 +2,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.excoin.modules.otc.entity.OtcOrder; import com.xcong.excoin.modules.otc.dao.OtcOrderMapper; import com.xcong.excoin.modules.otc.dao.OtcOrderDao; import com.xcong.excoin.modules.otc.service.OtcOrderService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class OtcOrderServiceImpl extends ServiceImpl<OtcOrderMapper, OtcOrder> implements OtcOrderService { public class OtcOrderServiceImpl extends ServiceImpl<OtcOrderDao, OtcOrder> implements OtcOrderService { } src/main/java/com/xcong/excoin/modules/otc/vo/EntrustListInfoVo.java
New file @@ -0,0 +1,60 @@ package com.xcong.excoin.modules.otc.vo; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.Date; @Data @ApiModel(value = "EntrustListInfoVo", description = "委托单列表返回参数类") public class EntrustListInfoVo { @ApiModelProperty(value= "委托单ID") private Long id; @ApiModelProperty(value = "单价") private BigDecimal unitPrice; @ApiModelProperty(value = "限额 最小值") private BigDecimal min; @ApiModelProperty(value = "限额 最大值") private BigDecimal max; @ApiModelProperty(value = "数量") private BigDecimal amount; @ApiModelProperty(value = "剩余数量") private BigDecimal remainAmount; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @ApiModelProperty(value = "创建时间") private Date createTime; @ApiModelProperty(value = "上/下线 1-上线 2-下线") private Integer status; public BigDecimal getUnitPrice() { return unitPrice.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getMin() { return min.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getMax() { return max.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getAmount() { return amount.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getRemainAmount() { return remainAmount.setScale(2, BigDecimal.ROUND_DOWN); } } src/main/java/com/xcong/excoin/modules/otc/vo/EntrustListVo.java
New file @@ -0,0 +1,60 @@ package com.xcong.excoin.modules.otc.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "EntrustListVo", description = "委托单列表接口返回参数类") public class EntrustListVo { @ApiModelProperty(value = "订单ID") private Long id; @ApiModelProperty(value = "市商ID") private Long mbId; @ApiModelProperty(value = "单价") private BigDecimal unitPrice; @ApiModelProperty(value = "市商昵称") private String nickname; @ApiModelProperty(value = "数量") private BigDecimal amount; @ApiModelProperty(value = "限额 最小值") private BigDecimal min; @ApiModelProperty(value = "限额 最大值") private BigDecimal max; @ApiModelProperty(value = "订单数量") private Integer orderCnt; @ApiModelProperty(value = "完成率") private BigDecimal finishRatio; public BigDecimal getUnitPrice() { return unitPrice.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getAmount() { return amount.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getMin() { return min.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getMax() { return max.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getFinishRatio() { return finishRatio.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_DOWN); } } src/main/java/com/xcong/excoin/modules/otc/vo/EntrustOrderDetailVo.java
New file @@ -0,0 +1,70 @@ package com.xcong.excoin.modules.otc.vo; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.Date; @Data @ApiModel(value = "EntrustOrderDetailVo", description = "获取委托单详情接口返回参数类") public class EntrustOrderDetailVo { @ApiModelProperty(value = "委托单号") private String orderNo; @ApiModelProperty(value = "单价") private BigDecimal unitPrice; @ApiModelProperty(value = "委托数量") private BigDecimal amount; @ApiModelProperty(value = "剩余数量") private BigDecimal remainAmount; @ApiModelProperty(value = "委托金额") private BigDecimal totalAmount; @ApiModelProperty(value = "限额 下限") private BigDecimal min; @ApiModelProperty(value = "限额 上限") private BigDecimal max; @ApiModelProperty(value = "类型 B-购买 S-出售") private String orderType; @ApiModelProperty(value = "上/下线 1-上线 2-下线") private Integer status; @ApiModelProperty(value = "创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; public BigDecimal getUnitPrice() { return unitPrice.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getAmount() { return amount.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getRemainAmount() { return remainAmount.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getTotalAmount() { return totalAmount.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getMin() { return min.setScale(2, BigDecimal.ROUND_DOWN); } public BigDecimal getMax() { return max.setScale(2, BigDecimal.ROUND_DOWN); } } src/main/java/com/xcong/excoin/modules/otc/vo/MarketBussinessInfoVo.java
New file @@ -0,0 +1,51 @@ package com.xcong.excoin.modules.otc.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; @Data @ApiModel(value = "MarketBussinessInfoVo", description = "获取市商信息接口返回参数类") public class MarketBussinessInfoVo { @ApiModelProperty(value = "id") private Long id; @ApiModelProperty(value = "会员ID") private Long memberId; @ApiModelProperty(value = "昵称") private String nikename; @ApiModelProperty(value = "审核状态", example = "1-待审核2-审核通过3-审核拒绝") private Integer status; @ApiModelProperty(value = "服务人数") private Integer buyCnt; @ApiModelProperty(value = "总单数") private Integer totalOrderCnt; @ApiModelProperty(value = "完成率") private BigDecimal finishRatio; @ApiModelProperty(value = "平均付款时间") private Integer avgPayTime; @ApiModelProperty(value = "平均放币时间") private Integer avgCoinTime; @ApiModelProperty(value = "卖单") private List<EntrustListInfoVo> sales; @ApiModelProperty(value = "买单") private List<EntrustListInfoVo> buys; public BigDecimal getFinishRatio() { return finishRatio.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_DOWN); } } src/main/java/com/xcong/excoin/quartz/job/BlockCoinUpdateJob.java
@@ -22,7 +22,7 @@ **/ @Slf4j @Component //@ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true") @ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true") public class BlockCoinUpdateJob { @Resource src/main/resources/mapper/otc/OtcEntrustOrderDao.xml
New file @@ -0,0 +1,45 @@ <?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.OtcEntrustOrderDao"> <select id="selectEntrustListInPage" resultType="com.xcong.excoin.modules.otc.vo.EntrustListVo"> select a.id, b.id mbId ,b.nikename nickname ,a.unit_price unitPrice ,a.remain_coin_amount amount ,a.limit_min_amount min ,a.limit_max_amount max ,b.total_order_cnt orderCnt ,b.finish_ratio finishRatio from otc_entrust_order a left join otc_market_bussiness b on a.mb_id=b.id <where> a.status=1 <if test="record != null"> <if test="record.type != null and record.type!=''"> and order_type = #{record.type} </if> </if> </where> </select> <select id="selectEntrustOrderByOrderType" resultType="com.xcong.excoin.modules.otc.entity.OtcEntrustOrder"> select * from otc_entrust_order <where> <if test="record.orderType != null and record.orderType != ''" > and order_type = #{record.orderType} </if> <if test="record.memberId != null"> and member_id = #{record.memberId} </if> <if test="record.status != null and record.status == 3"> and status != #{record.status} </if> <if test="record.status != null and record.status != 3"> and status == #{record.status} </if> </where> </select> </mapper> src/main/resources/mapper/otc/OtcEntrustOrderMapper.xml
File was deleted src/main/resources/mapper/otc/OtcMarketBussinessMapper.xml
@@ -1,5 +1,9 @@ <?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.OtcMarketBussinessMapper"> <mapper namespace="com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao"> <select id="selectMarketBussinessByMemberId" resultType="com.xcong.excoin.modules.otc.entity.OtcMarketBussiness"> select * from otc_market_bussiness where member_id=#{memberId} </select> </mapper> src/main/resources/mapper/otc/OtcOrderAppealDao.xml
File was renamed from src/main/resources/mapper/otc/OtcOrderAppealMapper.xml @@ -1,5 +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.OtcOrderAppealMapper"> <mapper namespace="com.xcong.excoin.modules.otc.dao.OtcOrderAppealDao"> </mapper> src/main/resources/mapper/otc/OtcOrderDao.xml
New file @@ -0,0 +1,9 @@ <?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.OtcOrderDao"> <select id="selectOrderListUnFinish" resultType="com.xcong.excoin.modules.otc.entity.OtcOrder"> select * from otc_order where status not in (2,4) and member_id=#{memberId} and entrust_order_id=#{entrustOrderId} </select> </mapper> src/main/resources/mapper/otc/OtcOrderMapper.xml
File was deleted