src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
@@ -21,7 +21,16 @@ WALLETCOINCODE("USDT", "USDT"), SUBMITSALESWALLETCOINORDER_SERVICERATE("ServiceRate","0.002"), SUBMITSALESWALLETCOINORDER_TYPE("type","1"), //SUBMITSALESWALLETCOINORDER_TYPE_S("买入","1"), //SUBMITSALESWALLETCOINORDER_TYPE_B("卖出","2"), //SUBMITSALESWALLETCOINORDER_TRADETYPE_S("市价","1"), //SUBMITSALESWALLETCOINORDER_TRADETYPE_X("限价","2"), //SUBMITSALESWALLETCOINORDER_ORDERSTATUS_ONE("委托中","1"), //SUBMITSALESWALLETCOINORDER_ORDERSTATUS_TWO("撤单","2"), //SUBMITSALESWALLETCOINORDER_ORDERSTATUS_THREE("已成交","3"), ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_NO("isCollect","0"), src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
@@ -23,9 +23,6 @@ import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceFromAgentDto; import com.xcong.excoin.modules.coin.service.CoinService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -54,8 +51,11 @@ */ @ApiOperation(value="获取币币账户某个币种信息", notes="获取币币账户某个币种信息") @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletCoinInfoVo.class)}) @ApiImplicitParams({ @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query") }) @GetMapping(value = "/getWalletCoinBySymbol") public Result getWalletCoinBySymbol(@ApiParam(name="symbol",value="币种",required=true)String symbol) { public Result getWalletCoinBySymbol(String symbol) { return coinService.getWalletCoinBySymbol(symbol); } @@ -86,8 +86,11 @@ * @return */ @ApiOperation(value="查询币币账户里面的可用资产余额", notes="查询币币账户里面的可用资产余额") @ApiImplicitParams({ @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query") }) @GetMapping(value="/findWalletCoinBySymbol") public Result findWalletCoinBysymbol(@ApiParam(name="symbol",value="币种",required=true)String symbol) { public Result findWalletCoinBysymbol(String symbol) { return coinService.findWalletCoinBySymbol(symbol); } src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java
@@ -12,13 +12,23 @@ import org.springframework.web.bind.annotation.RestController; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.coin.parameter.dto.CancelEntrustWalletCoinOrderDto; import com.xcong.excoin.modules.coin.parameter.dto.FindCollectDto; import com.xcong.excoin.modules.coin.parameter.dto.SubmitSalesWalletCoinOrderDto; import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceDto; import com.xcong.excoin.modules.coin.parameter.vo.MemberSelectSymbolsVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealListVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinVo; import com.xcong.excoin.modules.coin.parameter.vo.TransactionPageOfWalletCoinVo; import com.xcong.excoin.modules.coin.service.OrderCoinService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -35,16 +45,18 @@ * @return */ @ApiOperation(value = "进入交易页面", notes = "进入交易页面") @ApiResponses({@ApiResponse( code = 200, message = "success", response = TransactionPageOfWalletCoinVo.class)}) @ApiImplicitParams({ @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query"), @ApiImplicitParam(name = "type", value = "买入卖出类型1:买入,2:卖出", required = true, dataType = "String", paramType="query") }) @GetMapping(value = "/enterTransactionPageOfWalletCoin") public Result enterTransactionPageOfWalletCoin( @ApiParam(name="symbol",value="币种",required=true)String symbol, @ApiParam(name="type",value="买入卖出类型",required=true)String type) { public Result enterTransactionPageOfWalletCoin(String symbol,String type) { return orderCoinService.enterTransactionPageOfWalletCoin(symbol,type); } /** * 提交买卖订单 * @param buySymbolTradeVo * @param token * @return */ @ApiOperation(value = "提交买卖订单", notes = "提交买卖订单") @@ -57,5 +69,79 @@ BigDecimal amount = submitSalesWalletCoinOrderDto.getAmount(); return orderCoinService.submitSalesWalletCoinOrder(symbol,type,tradeType,price,amount); } /** * 获取委托单数据 * @return */ @ApiOperation(value = "获取委托单数据", notes = "获取委托单数据") @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinVo.class)}) @ApiImplicitParams({ @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query"), @ApiImplicitParam(name = "status", value = "状态 1:委托中2:撤单3:已成交", required = true, dataType = "Integer", paramType="query") }) @GetMapping(value = "/getEntrustWalletCoinOrder") public Result getEntrustWalletCoinOrder(String symbol,Integer status) { return orderCoinService.getEntrustWalletCoinOrder(symbol,status); } /** * 撤销委托订单 * @return */ @ApiOperation(value = "撤销委托订单", notes = "撤销委托订单") @PostMapping(value="/cancelEntrustWalletCoinOrder") public Result cancelEntrustWalletCoinOrder(@RequestBody @Valid CancelEntrustWalletCoinOrderDto cancelEntrustWalletCoinOrderDto) { String orderNo = cancelEntrustWalletCoinOrderDto.getOrderNo(); return orderCoinService.cancelEntrustWalletCoinOrder(orderNo); } /** * 获取币币交易历史订单信息 * @return */ @ApiOperation(value = "获取币币交易历史订单信息", notes = "获取币币交易历史订单信息") @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinDealListVo.class)}) @GetMapping(value = "/findAllWalletCoinOrder") public Result findAllWalletCoinOrder() { return orderCoinService.findAllWalletCoinOrder(); } /** * 获取一条币币交易历史订单信息 * @return */ @ApiOperation(value = "获取一条币币交易历史订单信息", notes = "获取一条币币交易历史订单信息") @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinDealVo.class)}) @ApiImplicitParams({ @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType="query") }) @GetMapping(value = "/findWalletCoinOrder") public Result findWalletCoinOrder(Long orderId) { return orderCoinService.findWalletCoinOrder(orderId); } /** * 币币自选|取消自选 * @return */ @ApiOperation(value = "币币自选|取消自选", notes = "币币自选|取消自选") @PostMapping(value="/findCollect") public Result findCollect(@RequestBody @Valid FindCollectDto findCollectDto) { String symbol = findCollectDto.getSymbol(); Integer type = findCollectDto.getType(); return orderCoinService.findCollect(symbol,type); } /** * 币币是否自选 * @return */ @ApiOperation(value = "币币是否自选", notes = "币币是否自选") @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberSelectSymbolsVo.class)}) @PostMapping(value="/checkIsCollect") public Result checkIsCollect(@ApiParam(name="symbol",value="币种",required=true)String symbol) { return orderCoinService.checkIsCollect(symbol); } } src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountFlowEntityDao.java
New file @@ -0,0 +1,8 @@ package com.xcong.excoin.modules.coin.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity; public interface MemberAccountFlowEntityDao extends BaseMapper<MemberAccountFlowEntity>{ } src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java
@@ -1,8 +1,16 @@ package com.xcong.excoin.modules.coin.dao; import java.util.List; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity; public interface OrderCoinDealDao extends BaseMapper<OrderCoinsDealEntity>{ List<OrderCoinsDealEntity> selectAllWalletCoinOrder(@Param("memberId")Long memberId); OrderCoinsDealEntity selectWalletCoinOrder(@Param("memberId")Long memberId,@Param("orderId")Long orderId); } src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinsDao.java
New file @@ -0,0 +1,15 @@ package com.xcong.excoin.modules.coin.dao; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; public interface OrderCoinsDao extends BaseMapper<OrderCoinsEntity>{ long getOrderCountByToday(@Param("now")String now,@Param("tomorrow") String tomorrow); OrderCoinsEntity findCoinOrderListByMemberIdAndSysmbol(@Param("memberId")Long memberId,@Param("symbol")String symbol,@Param("status")int status); OrderCoinsEntity findWalletCoinOrderByOrderNo(@Param("orderNo")String orderNo); } src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountFlowEntity.java
New file @@ -0,0 +1,60 @@ package com.xcong.excoin.modules.coin.entity; import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.TableName; import com.xcong.excoin.common.system.base.BaseEntity; import lombok.Data; /** * 会员账户流水情况 */ @Data @TableName("member_account_flow") public class MemberAccountFlowEntity extends BaseEntity { /** * */ private static final long serialVersionUID = 1L; /** * 会员ID */ private Long memberId; /** * 价格 */ private BigDecimal price; /** * 用户余额 */ private BigDecimal balance; /** * 来源 */ private String source; public static final String SOURCE_BUY = "币币买入"; public static final String SOURCE_SALE = "币币卖出"; public static final String SOURCE_CANCEL = "撤销币币委托单"; /** * 币种 */ private String symbol; /** * 备注 */ private String remark; public static final String REMARK_BUY = "买入"; public static final String REMARK_SALE = "卖出"; public static final String REMARK_CANCEL = "撤销"; public static final String REMARK_RETURNBALANCE = "返回金额:"; } src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsDealEntity.java
@@ -1,5 +1,7 @@ package com.xcong.excoin.modules.coin.entity; import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.TableName; import com.xcong.excoin.common.system.base.BaseEntity; @@ -15,5 +17,53 @@ * */ private static final long serialVersionUID = 1L; /** * 会员ID */ private Long memberId; /** * 订单主表ID */ private Long orderId; /** * 订单编号 */ private String orderNo; /** * 订单类型 1、买入2、卖出 */ private Integer orderType; public static final Integer ORDERTYPE_BUY = 1; public static final Integer ORDERTYPE_SELL = 2; /** * 交易类型 1:市价2:限价 */ private Integer tradeType; public static final Integer TRADETYPE_MARKETPRICE = 1; public static final Integer TRADETYPE_FIXEDPRICE = 2; /** * 币种 */ private String symbol; /** * 数量 */ private BigDecimal symbolCnt; /** * 委托价 */ private BigDecimal entrustPrice; /** * 成交价 */ private BigDecimal dealPrice; /** * 成交金额 */ private BigDecimal dealAmount; /** * 手续费 */ private BigDecimal feeAmount; } src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsEntity.java
@@ -1,7 +1,6 @@ package com.xcong.excoin.modules.coin.entity; import java.math.BigDecimal; import java.util.Date; import com.baomidou.mybatisplus.annotation.TableName; import com.xcong.excoin.common.system.base.BaseEntity; @@ -30,7 +29,10 @@ /** * 订单类型 1、买入2、卖出 */ private int orderType; private Integer orderType; public static final Integer ORDERTYPE_BUY = 1; public static final Integer ORDERTYPE_SELL = 2; /** * 币种 */ @@ -54,7 +56,7 @@ /** * 成交价 */ private Double dealPrice; private BigDecimal dealPrice; /** * 成交金额 */ @@ -63,13 +65,20 @@ * 状态 1:委托中2:撤单3:已成交 */ private Integer orderStatus; public static final Integer ORDERSTATUS_DODING = 1; public static final Integer ORDERSTATUS_CANCEL = 2; public static final Integer ORDERSTATUS_DONE = 3; /** * 交易类型 1:市价2:限价 */ private Integer tradeType; public static final Integer TRADETYPE_MARKETPRICE = 1; public static final Integer TRADETYPE_FIXEDPRICE = 2; /** * 手续费 */ private String feeAmount; private BigDecimal feeAmount; } src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinDealMapper.java
New file @@ -0,0 +1,14 @@ package com.xcong.excoin.modules.coin.mapper; import org.mapstruct.factory.Mappers; import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo; public abstract class OrderWalletCoinDealMapper { public static final OrderWalletCoinDealMapper INSTANCE = Mappers.getMapper(OrderWalletCoinDealMapper.class); public abstract OrderWalletCoinDealVo entityToVo(OrderCoinsDealEntity orderCoinsDealEntity); } src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinMapper.java
New file @@ -0,0 +1,14 @@ package com.xcong.excoin.modules.coin.mapper; import org.mapstruct.factory.Mappers; import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinVo; public abstract class OrderWalletCoinMapper { public static final OrderWalletCoinMapper INSTANCE = Mappers.getMapper(OrderWalletCoinMapper.class); public abstract OrderWalletCoinVo entityToVo(OrderCoinsEntity orderCoinsEntity); } src/main/java/com/xcong/excoin/modules/coin/parameter/dto/CancelEntrustWalletCoinOrderDto.java
New file @@ -0,0 +1,19 @@ package com.xcong.excoin.modules.coin.parameter.dto; import java.math.BigDecimal; import javax.validation.constraints.NotNull; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "CancelEntrustWalletCoinOrderDto", description = "撤销委托订单") public class CancelEntrustWalletCoinOrderDto { @NotNull(message = "订单编号不能为空") @ApiModelProperty(value = "订单编号", example = "100") private String orderNo; } src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindCollectDto.java
New file @@ -0,0 +1,20 @@ package com.xcong.excoin.modules.coin.parameter.dto; import javax.validation.constraints.NotNull; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "FindCollectDto", description = "币币自选|取消自选参数接收类") public class FindCollectDto { @NotNull(message = "币种") @ApiModelProperty(value = "币种", example = "BTC") private String symbol; @NotNull(message = "币币自选") @ApiModelProperty(value = "自选标识1:选中0:未选中", example = "1") private Integer type; } src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
@@ -7,18 +7,20 @@ import lombok.Data; @Data @ApiModel(value = "SubmitSalesWalletCoinOrderDto", description = "提交买卖订单接收类") @ApiModel(value = "SubmitSalesWalletCoinOrderDto", description = "提交买卖订单参数接收类") public class SubmitSalesWalletCoinOrderDto { @NotNull(message = "币种不能为空") @ApiModelProperty(value = "币种", example = "BTC") private String symbol; @NotNull(message = "币种不能为空") @ApiModelProperty(value = "币种", example = "USDT") @NotNull(message = "交易类型不能为空") @ApiModelProperty(value = "买入卖出类型买入:1,卖出:2", example = "USDT") private Integer type; @NotNull(message = "账户类型不能为空") @ApiModelProperty(value = "账户类型", example = "1") @NotNull(message = "交易方式不能为空") @ApiModelProperty(value = "市价:1,限价:2", example = "1") private Integer tradeType; @NotNull(message = "数量不能为空") src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberSelectSymbolsVo.java
New file @@ -0,0 +1,23 @@ package com.xcong.excoin.modules.coin.parameter.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "MemberSelectSymbolsVo", description = "币币是否自选返回") public class MemberSelectSymbolsVo { /** * 会员ID */ @ApiModelProperty(value = "是否自选1:选中0:未选中") private Integer isCollect; public static final Integer ISCOLLECT_YES = 1; public static final Integer ISCOLLECT_NO = 0; /** * 币种 */ @ApiModelProperty(value = "币种") private String symbol; } src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java
@@ -7,7 +7,7 @@ import lombok.Data; @Data @ApiModel(value = "代理账户信息返回", description = "代理账户信息返回") @ApiModel(value = "MemberWalletAgentInfoVo", description = "代理账户信息返回") public class MemberWalletAgentInfoVo { /** src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealListVo.java
New file @@ -0,0 +1,16 @@ package com.xcong.excoin.modules.coin.parameter.vo; import java.util.List; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "OrderWalletCoinDealListVo", description = "币币交易历史订单信息返回") public class OrderWalletCoinDealListVo { @ApiModelProperty(value = "历史订单详情") private List<OrderWalletCoinDealVo> orderWalletCoinDealVo; } src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealVo.java
New file @@ -0,0 +1,76 @@ package com.xcong.excoin.modules.coin.parameter.vo; import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "OrderWalletCoinDealVo", description = "历史订单详情") public class OrderWalletCoinDealVo { /** * 会员ID */ @ApiModelProperty(value = "会员ID") private Long memberId; /** * 订单主表ID */ @ApiModelProperty(value = "订单主表ID") private Long orderId; /** * 订单编号 */ @ApiModelProperty(value = "订单编号") private String orderNo; /** * 订单类型 1、买入2、卖出 */ @ApiModelProperty(value = "订单类型 1、买入2、卖出") private Integer orderType; /** * 交易类型 1:市价2:限价 */ @ApiModelProperty(value = "交易类型 1:市价2:限价") private Integer tradeType; /** * 币种 */ @ApiModelProperty(value = "币种") private String symbol; /** * 数量 */ @ApiModelProperty(value = "数量") private BigDecimal symbolCnt; /** * 委托价 */ @ApiModelProperty(value = "委托价") private BigDecimal entrustPrice; /** * 成交价 */ @ApiModelProperty(value = "成交价") private BigDecimal dealPrice; /** * 成交金额 */ @ApiModelProperty(value = "成交金额") private BigDecimal dealAmount; /** * 手续费 */ @ApiModelProperty(value = "手续费") private BigDecimal feeAmount; @ApiModelProperty(value = "时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime; } src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinVo.java
New file @@ -0,0 +1,65 @@ package com.xcong.excoin.modules.coin.parameter.vo; import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "OrderWalletCoinVo", description = "订单详情") public class OrderWalletCoinVo { /** * 订单编号 */ @ApiModelProperty(value = "订单编号") private String orderNo; /** * 币种 */ @ApiModelProperty(value = "币种") private String symbol; /** * 市场价 */ @ApiModelProperty(value = "市场价") private BigDecimal markPrice; /** * 委托量 */ @ApiModelProperty(value = "委托量") private BigDecimal entrustCnt; /** * 委托价 */ @ApiModelProperty(value = "委托价") private BigDecimal entrustPrice; /** * 成交量 */ @ApiModelProperty(value = "成交量") private BigDecimal dealCnt; /** * 成交价 */ @ApiModelProperty(value = "成交价") private BigDecimal dealPrice; /** * 成交金额 */ @ApiModelProperty(value = "成交金额") private BigDecimal dealAmount; /** * 手续费 */ @ApiModelProperty(value = "手续费") private BigDecimal feeAmount; @ApiModelProperty(value = "时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime; } src/main/java/com/xcong/excoin/modules/coin/parameter/vo/TransactionPageOfWalletCoinVo.java
New file @@ -0,0 +1,50 @@ package com.xcong.excoin.modules.coin.parameter.vo; import java.math.BigDecimal; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "OrderWalletCoinDealVo", description = "进入交易页面返回") public class TransactionPageOfWalletCoinVo { /** * 是否自选 */ @ApiModelProperty(value = "是否自选") private Integer isCollect; public static final Integer ISCOLLECT_YES = 1; public static final Integer ISCOLLECT_NO = 0; /** * 点差 */ @ApiModelProperty(value = "点差") private BigDecimal spread; /** * 手续费 */ @ApiModelProperty(value = "手续费") private BigDecimal feeRatio; /** * 用户可用金额 */ @ApiModelProperty(value = "用户可用金额") private BigDecimal availableBalance; /** * 当前价 */ @ApiModelProperty(value = "当前价") private BigDecimal currentPrice; /** * 比例 */ @ApiModelProperty(value = "比例") private BigDecimal cnyUsdt; /** * 换算成人民币之后的价格 */ @ApiModelProperty(value = "换算成人民币之后的价格") private BigDecimal currentPriceCny; } src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java
@@ -7,10 +7,24 @@ import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; public interface OrderCoinService extends IService<OrderCoinsEntity>{ public String generateSimpleSerialno(String userId); Result enterTransactionPageOfWalletCoin(String symbol, String type); Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price, BigDecimal amount); public Result getEntrustWalletCoinOrder(String symbol, Integer status); public Result cancelEntrustWalletCoinOrder(String orderNo); public Result findAllWalletCoinOrder(); public Result findWalletCoinOrder(Long orderId); public Result findCollect(String symbol, Integer type); public Result checkIsCollect(String symbol); } src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -1,7 +1,11 @@ package com.xcong.excoin.modules.coin.service.impl; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -15,13 +19,24 @@ import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao; import com.xcong.excoin.modules.coin.dao.MemberSelectSymbolsDao; import com.xcong.excoin.modules.coin.dao.OrderCoinDao; import com.xcong.excoin.modules.coin.dao.OrderCoinDealDao; import com.xcong.excoin.modules.coin.dao.OrderCoinsDao; import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao; import com.xcong.excoin.modules.coin.dao.platform.TradeSettingDao; import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange; import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity; import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity; import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; import com.xcong.excoin.modules.coin.entity.PlatformTradeSettingEntity; import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinDealMapper; import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinMapper; import com.xcong.excoin.modules.coin.parameter.vo.MemberSelectSymbolsVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealListVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinVo; import com.xcong.excoin.modules.coin.parameter.vo.TransactionPageOfWalletCoinVo; import com.xcong.excoin.modules.coin.service.OrderCoinService; import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao; import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity; @@ -30,10 +45,11 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; @Service public class OrderCoinServiceImpl extends ServiceImpl<OrderCoinDao, OrderCoinsEntity> implements OrderCoinService{ public class OrderCoinServiceImpl extends ServiceImpl<OrderCoinsDao, OrderCoinsEntity> implements OrderCoinService{ @Resource TradeSettingDao platformTradeSettingDao; @@ -43,6 +59,37 @@ MemberSelectSymbolsDao memberSelectSymbolsDao; @Resource CnyUsdtExchangeDao cnyUsdtExchangeDao; @Resource OrderCoinsDao orderCoinsDao; @Resource OrderCoinDealDao orderCoinDealDao; @Resource MemberAccountFlowEntityDao memberAccountFlowEntityDao; @Override public String generateSimpleSerialno(String userId) { StringBuilder sb = new StringBuilder(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd"); Date now = new Date(); sb.append(sd.format(now)); Calendar calendar = new GregorianCalendar(); calendar.setTime(now); calendar.add(calendar.DATE, 1); Date nextDate = calendar.getTime(); if (StrUtil.isNotEmpty(userId)) { sb.append(userId); } sb.append(RandomUtil.randomInt(2)); long count = orderCoinsDao.getOrderCountByToday(sdf.format(now), sdf.format(nextDate)); count++; int size = 4; for (int i = 0; i < size - String.valueOf(count).length(); i++) { sb.append("0"); } sb.append(count); return sb.toString(); } @Override public Result enterTransactionPageOfWalletCoin(String symbol, String type) { @@ -72,38 +119,334 @@ CnyUsdtExchange cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne(); BigDecimal cnyUsdt = cnyUsdtExchange.getValue(); Map<String, Object> map = new HashMap<String, Object>(); TransactionPageOfWalletCoinVo transactionPageOfWalletCoinVo = new TransactionPageOfWalletCoinVo(); //是否自选 if(CollUtil.isEmpty(memSymbols)) { map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_NO.getName(), MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_NO.getValue());//是否已经自选该币种 transactionPageOfWalletCoinVo.setIsCollect(TransactionPageOfWalletCoinVo.ISCOLLECT_NO); }else { map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_YES.getName(), MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_YES.getValue());//是否已经自选该币种 transactionPageOfWalletCoinVo.setIsCollect(TransactionPageOfWalletCoinVo.ISCOLLECT_YES); } if (ObjectUtil.isEmpty(walletCoin)) return Result.fail(MessageSourceUtils.getString("order_service_0003")); map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_SPREAD.getValue(), tradeSetting.getSpread());// 点差 map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CLOSINGRATIO.getValue(), tradeSetting.getFeeRatio());// 手续费用率 // 点差 transactionPageOfWalletCoinVo.setSpread(tradeSetting.getSpread().setScale(4, BigDecimal.ROUND_DOWN)); // 手续费用率 transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getFeeRatio().setScale(4, BigDecimal.ROUND_DOWN)); // 用户可用金额 if(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_BUY.getValue().equals(type)) {//买入 map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_MEMBERMONEY.getValue(), walletCoinUsdt.getAvailableBalance());// 用户可用金额 transactionPageOfWalletCoinVo.setAvailableBalance(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN)); }else { map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_MEMBERMONEY.getValue(), walletCoin.getAvailableBalance());// 用户可用金额 transactionPageOfWalletCoinVo.setAvailableBalance(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN)); } map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CURRENTPRICE.getValue(), closePrice);//当前价 map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CNYUSDT.getValue(), cnyUsdt);//比例 map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CURRENTPRICECNY.getValue(), cnyUsdt.multiply(closePrice));//换算成人民币的币种价格 return Result.ok(map); } //当前价 transactionPageOfWalletCoinVo.setCurrentPrice(closePrice.setScale(4, BigDecimal.ROUND_DOWN)); //比例 transactionPageOfWalletCoinVo.setCnyUsdt(cnyUsdt.setScale(4, BigDecimal.ROUND_DOWN)); //换算成人民币的币种价格 transactionPageOfWalletCoinVo.setCurrentPriceCny(cnyUsdt.multiply(closePrice).setScale(4, BigDecimal.ROUND_DOWN)); return Result.ok(transactionPageOfWalletCoinVo); } @Override @Transactional public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price, BigDecimal amount) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); /** * todo */ //查询当前价 //BigDecimal nowPrice = new BigDecimal(redisUtil.getString(CoinTypeConConvert.convertToKey(symbol+"/USDT"))); BigDecimal nowPrice = new BigDecimal("10.0000"); // 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置 symbol = symbol.toUpperCase(); MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol); if (ObjectUtil.isEmpty(walletCoin)) { return Result.fail(MessageSourceUtils.getString("order_service_0003")); } // 查询交易设置 PlatformTradeSettingEntity tradeSetting = platformTradeSettingDao.findTradeSetting(); if(ObjectUtil.isEmpty(tradeSetting)) { return Result.fail(MessageSourceUtils.getString("order_service_0009")); } // 手续费用(手续费=建仓价X数量X手续费率) BigDecimal closingPrice = price.multiply(amount).multiply(new BigDecimal(MemberWalletCoinEnum.SUBMITSALESWALLETCOINORDER_SERVICERATE.getValue())); //总费用 = 成交价*数量+手续费 BigDecimal totalPayPrice = price.multiply(amount).add(closingPrice); String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId,walletCode); if(OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) { //买入,所需总费用跟用户USDT金额进行比较 BigDecimal availableBalance = walletCoinUsdt.getAvailableBalance(); if (totalPayPrice.compareTo(availableBalance) > 0) { return Result.fail(MessageSourceUtils.getString("order_service_0010")); } }else { //卖出,所需总费用跟用户所对应的币种金额进行比较 BigDecimal availableBalance = walletCoin.getAvailableBalance(); if (amount.compareTo(availableBalance) > 0) { return Result.fail(MessageSourceUtils.getString("order_service_0010")); } } // 创建订单 OrderCoinsEntity order = new OrderCoinsEntity(); if (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType)) { // 如果是限价交易直接插入主表数据 order.setMemberId(memberId); order.setOrderNo(generateSimpleSerialno(memberId.toString())); order.setOrderType(type); order.setSymbol(symbol); order.setMarkPrice(nowPrice.setScale(4, BigDecimal.ROUND_DOWN)); order.setEntrustCnt(amount.setScale(4, BigDecimal.ROUND_DOWN)); order.setEntrustPrice(price.setScale(4, BigDecimal.ROUND_DOWN)); order.setDealCnt(amount.setScale(4, BigDecimal.ROUND_DOWN)); order.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN)); order.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN)); order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DODING); order.setTradeType(tradeType); order.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN)); orderCoinsDao.insert(order); //更新用户钱包信息 //冻结相应的资产 if(OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) { //如果是买入,所对应的币种增加,USDT账户减少金额 BigDecimal availableBalance = walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice); BigDecimal frozenBalance = walletCoinUsdt.getFrozenBalance().add(totalPayPrice); walletCoinUsdt.setAvailableBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN)); walletCoinUsdt.setFrozenBalance(frozenBalance.setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoinUsdt); }else { //如果是卖出,币种减少,USDT增加 BigDecimal availableBalance = walletCoin.getAvailableBalance().subtract(amount); BigDecimal frozenBalance = walletCoin.getFrozenBalance().add(amount); walletCoin.setAvailableBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN)); walletCoin.setFrozenBalance(frozenBalance.setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoin); } } else { //如果是市价交易,主表和附表都需要插入数据 order.setMemberId(memberId); order.setOrderNo(generateSimpleSerialno(memberId.toString())); order.setOrderType(type); order.setSymbol(symbol); order.setMarkPrice(nowPrice.setScale(4, BigDecimal.ROUND_DOWN)); order.setEntrustCnt(amount.setScale(4, BigDecimal.ROUND_DOWN)); order.setEntrustPrice(price.setScale(4, BigDecimal.ROUND_DOWN)); order.setDealCnt(amount.setScale(4, BigDecimal.ROUND_DOWN)); order.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN)); order.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN)); order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DONE); order.setTradeType(tradeType); order.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN)); orderCoinsDao.insert(order); OrderCoinsDealEntity detail = new OrderCoinsDealEntity(); detail.setMemberId(memberId); detail.setOrderId(order.getId()); detail.setOrderNo(order.getOrderNo()); detail.setOrderType(type); detail.setTradeType(tradeType); detail.setSymbol(symbol); detail.setSymbolCnt(amount.setScale(4, BigDecimal.ROUND_DOWN)); detail.setEntrustPrice(price.setScale(4, BigDecimal.ROUND_DOWN)); detail.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN)); detail.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN)); detail.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN)); orderCoinDealDao.insert(detail); if(OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) { //如果是买入,所对应的币种增加,USDT账户减少金额 // 更新用户的可用金额 walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(amount).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoin); walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoinUsdt); }else { //如果是卖出,币种减少,USDT增加 walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().subtract(amount).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoin); walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().add(totalPayPrice).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoinUsdt); } } // 流水记录 MemberAccountFlowEntity record = new MemberAccountFlowEntity(); record.setMemberId(memberId); if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) { record.setPrice(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN)); record.setSource(MemberAccountFlowEntity.SOURCE_BUY+symbol); record.setRemark(MemberAccountFlowEntity.REMARK_BUY+symbol+":"+amount.setScale(4, BigDecimal.ROUND_DOWN)); } else { record.setPrice(totalPayPrice.negate().setScale(4, BigDecimal.ROUND_DOWN)); record.setSource(MemberAccountFlowEntity.SOURCE_SALE+symbol); record.setRemark(MemberAccountFlowEntity.REMARK_SALE+symbol+":"+amount.setScale(4, BigDecimal.ROUND_DOWN)); } record.setSymbol(symbol); record.setBalance(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN)); memberAccountFlowEntityDao.insert(record); return Result.ok(MessageSourceUtils.getString("order_service_0011")); } @Override public Result getEntrustWalletCoinOrder(String symbol, Integer status) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); OrderCoinsEntity orderCoin = orderCoinsDao.findCoinOrderListByMemberIdAndSysmbol(memberId, symbol, status); OrderWalletCoinVo entityToVo = OrderWalletCoinMapper.INSTANCE.entityToVo(orderCoin); return Result.ok(entityToVo); } @Override @Transactional public Result cancelEntrustWalletCoinOrder(String orderNo) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); OrderCoinsEntity orderCoinsEntity = orderCoinsDao.findWalletCoinOrderByOrderNo(orderNo); if(ObjectUtil.isNotEmpty(orderCoinsEntity) && orderCoinsEntity.getMemberId() == memberId) { if(orderCoinsEntity.getOrderStatus() == OrderCoinsEntity.ORDERSTATUS_CANCEL){ return Result.fail(MessageSourceUtils.getString("order_service_0012")); } orderCoinsEntity.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_CANCEL); orderCoinsDao.updateById(orderCoinsEntity); String symbol = orderCoinsEntity.getSymbol(); if(orderCoinsEntity.getOrderType() == OrderCoinsEntity.TRADETYPE_FIXEDPRICE) { //如果是限价买入,撤单将USDT账户冻结金额返回 String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode); if (ObjectUtil.isNotEmpty(walletCoin)) { //手续费 = 开仓价*数量*手续费率 //返还金额=开仓价*未成交数量+手续费 BigDecimal returnBalance = orderCoinsEntity.getEntrustPrice().add(orderCoinsEntity.getFeeAmount()); walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoin); // 流水记录 MemberAccountFlowEntity record = new MemberAccountFlowEntity(); record.setSource(MemberAccountFlowEntity.SOURCE_CANCEL); record.setRemark(MemberAccountFlowEntity.REMARK_CANCEL+symbol+MemberAccountFlowEntity.REMARK_RETURNBALANCE+returnBalance); record.setBalance(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN)); record.setMemberId(memberId); record.setSymbol(symbol); record.setPrice(returnBalance); memberAccountFlowEntityDao.insert(record); return Result.ok(MessageSourceUtils.getString("order_service_0013")); } }else { //如果是限价卖出,撤单将对应的钱包冻结金额返回 String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode); if (ObjectUtil.isNotEmpty(walletCoin)) { //返还金额=开仓价*未成交数量 BigDecimal returnBalance = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance()); walletCoin.setAvailableBalance(returnBalance.setScale(4, BigDecimal.ROUND_DOWN)); walletCoin.setFrozenBalance(BigDecimal.ZERO); memberWalletCoinDao.updateById(walletCoin); // 流水记录 MemberAccountFlowEntity record = new MemberAccountFlowEntity(); record.setSource(MemberAccountFlowEntity.SOURCE_CANCEL); record.setRemark(MemberAccountFlowEntity.REMARK_CANCEL+symbol+MemberAccountFlowEntity.REMARK_RETURNBALANCE+returnBalance); record.setBalance(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN)); record.setMemberId(memberId); record.setSymbol(symbol); record.setPrice(walletCoin.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN)); memberAccountFlowEntityDao.insert(record); return Result.ok(MessageSourceUtils.getString("order_service_0013")); } } OrderCoinsDealEntity detail = new OrderCoinsDealEntity(); detail.setMemberId(memberId); detail.setOrderId(orderCoinsEntity.getId()); detail.setOrderNo(generateSimpleSerialno(memberId.toString())); detail.setOrderType(orderCoinsEntity.getOrderType()); detail.setTradeType(orderCoinsEntity.getTradeType()); detail.setSymbol(symbol); detail.setSymbolCnt(orderCoinsEntity.getEntrustCnt()); detail.setEntrustPrice(orderCoinsEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); detail.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); detail.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); detail.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); orderCoinDealDao.insert(detail); } return Result.fail(MessageSourceUtils.getString("order_service_0043")); } @Override public Result findAllWalletCoinOrder() { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); OrderWalletCoinDealListVo orderWalletCoinDealListVo = new OrderWalletCoinDealListVo(); List<OrderWalletCoinDealVo> arrayList = new ArrayList<OrderWalletCoinDealVo>(); List<OrderCoinsDealEntity> selectAllWalletCoinOrder = orderCoinDealDao.selectAllWalletCoinOrder(memberId); if(CollUtil.isNotEmpty(selectAllWalletCoinOrder)) { for(OrderCoinsDealEntity orderCoinsDealEntity: selectAllWalletCoinOrder) { OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVo(orderCoinsDealEntity); arrayList.add(entityToVo); } } orderWalletCoinDealListVo.setOrderWalletCoinDealVo(arrayList); return Result.ok(orderWalletCoinDealListVo); } @Override public Result findWalletCoinOrder(Long orderId) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); OrderCoinsDealEntity selectWalletCoinOrder = orderCoinDealDao.selectWalletCoinOrder(orderId,memberId); OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVo(selectWalletCoinOrder); return Result.ok(entityToVo); } @Override public Result findCollect(String symbol, Integer type) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); if(type==1) { //添加自选 MemberSelectSymbolsEntity symbols = new MemberSelectSymbolsEntity(); symbols.setMemberId(memberId); symbols.setSymbol(symbol); memberSelectSymbolsDao.insert(symbols); return Result.ok(MessageSourceUtils.getString("order_service_0015")); }else { Map<String, Object> columnMap = new HashMap<>(); columnMap.put("symbol", symbol); memberSelectSymbolsDao.deleteByMap(columnMap);; return Result.ok(MessageSourceUtils.getString("order_service_0016")); } } @Override public Result checkIsCollect(String symbol) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo(); List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol = memberSelectSymbolsDao.selectSymbolByMemIdAndSymbol(memberId, symbol); if(CollUtil.isNotEmpty(selectSymbolByMemIdAndSymbol)) { memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_YES); }else { memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO); } memberSelectSymbolsVo.setSymbol(symbol); return Result.ok(memberSelectSymbolsVo); } } src/main/java/com/xcong/excoin/modules/member/entity/MemberSelectSymbolsEntity.java
@@ -1,7 +1,5 @@ package com.xcong.excoin.modules.member.entity; import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.TableName; import com.xcong.excoin.common.system.base.BaseEntity; @@ -11,7 +9,7 @@ * 会员自选币种 */ @Data @TableName @TableName("member_select_symbols") public class MemberSelectSymbolsEntity extends BaseEntity{ /** * @@ -20,10 +18,10 @@ /** * 会员ID */ private BigDecimal memberId; private long memberId; /** * 币种 */ private BigDecimal symbol; private String symbol; } src/main/resources/mapper/member/MemberAccountFlowEntityDao.xml
New file @@ -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.coin.dao.MemberAccountFlowEntityDao"> </mapper> src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml
New file @@ -0,0 +1,19 @@ <?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.coin.dao.OrderCoinDealDao"> <select id="selectAllWalletCoinOrder" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity"> select * from coins_order_deal <where> <if test="memberId != null and memberId != ''"> and memberid = #{memberId} </if> </where> order by id desc </select> <select id="selectWalletCoinOrder" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity"> select * from coins_order_deal where order_id= #{orderId} and memberid = #{memberId} </select> </mapper> src/main/resources/mapper/walletCoinOrder/OrderCoinsDao.xml
New file @@ -0,0 +1,22 @@ <?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.coin.dao.OrderCoinsDao"> <select id="getOrderCountByToday" resultType="long"> <![CDATA[ SELECT COUNT(*) from coins_order WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= DATE_FORMAT(#{now}, '%Y-%m-%d') and DATE_FORMAT(create_time, '%Y-%m-%d') < DATE_FORMAT(#{tomorrow}, '%Y-%m-%d') ]]> </select> <select id="findCoinOrderListByMemberIdAndSysmbol" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsEntity"> SELECT * FROM coins_order a where a.member_id= #{memberId} and a.order_status = #{status} <if test="symbol != null and symbol !=''"> and a.symbol = #{symbol} </if> </select> <select id="findWalletCoinOrderByOrderNo" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsEntity"> SELECT * FROM coins_order a where a.order_no= #{orderNo} </select> </mapper>