Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
xingxing-dd committed Oct 6, 2023
1 parent 846d852 commit 826f028
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ruoyi.client;

import com.ruoyi.client.domain.ClientUserWallet;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(contextId = "remoteClientWalletService", value = ServiceNameConstants.CLIENT_SERVICE)
public interface RemoteClientWalletService {

@PostMapping("/wallet/detail")
public R<ClientUserWallet> getUserWallet(@RequestBody ClientUserWallet clientUserWallet);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.ruoyi.client.domain;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.math.BigDecimal;

/**
* 用户资产对象 client_user_wallet
*
* @author ruoyi
* @date 2023-08-29
*/
public class ClientUserWallet extends BaseEntity
{
private static final long serialVersionUID = 1L;

/** 主键 */
@Excel(name = "主键")
private Long id;

/** 用户id */
@Excel(name = "用户id")
private Long userId;

/** 总金额 */
@Excel(name = "总金额")
private BigDecimal totalAmount;

/** 币种 */
@Excel(name = "币种")
private String currency;

/** 状态(normal/freeze) */
@Excel(name = "状态(normal/freeze)")
private String status;

/** 删除标识 */
private Long delFlag;

public void setId(Long id)
{
this.id = id;
}

public Long getId()
{
return id;
}
public void setUserId(Long userId)
{
this.userId = userId;
}

public Long getUserId()
{
return userId;
}
public void setTotalAmount(BigDecimal totalAmount)
{
this.totalAmount = totalAmount;
}

public BigDecimal getTotalAmount()
{
return totalAmount;
}
public void setCurrency(String currency)
{
this.currency = currency;
}

public String getCurrency()
{
return currency;
}
public void setStatus(String status)
{
this.status = status;
}

public String getStatus()
{
return status;
}
public void setDelFlag(Long delFlag)
{
this.delFlag = delFlag;
}

public Long getDelFlag()
{
return delFlag;
}

@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userId", getUserId())
.append("totalAmount", getTotalAmount())
.append("currency", getCurrency())
.append("status", getStatus())
.append("remark", getRemark())
.append("delFlag", getDelFlag())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public class MarketConstant {

public static final Long HOT_PRODUCT = 1L;

public static final String SELL = "sell";

public static final String BUY = "buy";

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -102,4 +104,15 @@ public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(clientUserWalletService.deleteClientUserWalletByIds(ids));
}

/**
* 获取用户钱包数据
* @param clientUserWallet
* @return
*/
@PostMapping("/detail")
public R<ClientUserWallet> getUserWallet(@RequestBody ClientUserWallet clientUserWallet) {
return R.ok(clientUserWalletService.getUserWallet(clientUserWallet.getUserId()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,11 @@ public interface IClientUserWalletService
* @param bizOrderId
*/
public void balanceRollback(Long userId, String operator, String currency, Long bizOrderId);

/**
* 获取用户钱包
* @param userId
* @return
*/
public ClientUserWallet getUserWallet(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public void balanceRollback(Long userId, String operator, String currency, Long
clientUserWalletFlowMapper.insertClientUserWalletFlow(clientUserWalletFlow);
}

@Override
public ClientUserWallet getUserWallet(Long userId) {
return getUserWallet(userId, "USD");
}

private ClientUserWallet getUserWallet(Long userId, String currency) {
ClientUserWallet selectParams = new ClientUserWallet();
selectParams.setUserId(userId);
Expand Down
4 changes: 4 additions & 0 deletions ruoyi-modules/ruoyi-market/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<artifactId>selenium-java</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-api-client</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.ruoyi.market.crawler.core.model.ProductPriceCache;
import com.ruoyi.market.domain.ProductCategory;
import com.ruoyi.market.domain.ProductInfo;
import com.ruoyi.market.domain.req.ExchangeOrderCalculateReq;
import com.ruoyi.market.domain.req.KLineQueryReq;
import com.ruoyi.market.domain.req.ProductQueryReq;
import com.ruoyi.market.domain.vo.ProductInfoVo;
Expand Down Expand Up @@ -81,4 +82,9 @@ public AjaxResult productConfig(@RequestBody ProductQueryReq req) {
return AjaxResult.success(marketClientService.selectProductConfig(req.getProductCode()));
}

@PostMapping("/exchange/calculate")
public AjaxResult calculate(@RequestBody ExchangeOrderCalculateReq req) {
return AjaxResult.success(marketClientService.calculate(req));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ProductConfig extends BaseEntity

/** 每张数量 */
@Excel(name = "每张数量")
private Double eachSheetNum;
private BigDecimal eachSheetNum;

/** 最小倍率 */
@Excel(name = "最小倍率")
Expand Down Expand Up @@ -120,12 +120,12 @@ public BigDecimal getSpreadRate()
{
return spreadRate;
}
public void setEachSheetNum(Double eachSheetNum)
public void setEachSheetNum(BigDecimal eachSheetNum)
{
this.eachSheetNum = eachSheetNum;
}

public Double getEachSheetNum()
public BigDecimal getEachSheetNum()
{
return eachSheetNum;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.ruoyi.market.domain.req;

import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@ToString
public class ExchangeOrderCalculateReq implements Serializable {

private String productCode;

private String direct;

private BigDecimal exchangePrice;

private BigDecimal multiplier;

private BigDecimal sheetNum;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ruoyi.market.domain.vo;

import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@ToString
public class ExchangeOrderCalculateVo implements Serializable {

private BigDecimal feeAmount;

private BigDecimal margin;

private BigDecimal totalBalance;

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.ruoyi.market.domain.vo;

import com.ruoyi.common.core.annotation.Excel;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@ToString
public class ProductConfigVo implements Serializable {

/** 每张数量 */
private BigDecimal eachSheetNum;

/** 最小倍率 */
private Double minMultiplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ruoyi.market.service;

import com.ruoyi.market.domain.ProductCategory;
import com.ruoyi.market.domain.req.ExchangeOrderCalculateReq;
import com.ruoyi.market.domain.vo.ExchangeOrderCalculateVo;
import com.ruoyi.market.domain.vo.HotProductInfoVo;
import com.ruoyi.market.domain.vo.ProductConfigVo;
import com.ruoyi.market.domain.vo.ProductInfoVo;
Expand Down Expand Up @@ -40,4 +42,6 @@ public interface IMarketClientService {
* @return
*/
ProductConfigVo selectProductConfig(String productCode);

ExchangeOrderCalculateVo calculate(ExchangeOrderCalculateReq req);
}
Loading

0 comments on commit 826f028

Please sign in to comment.