Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
xingxing-dd committed Oct 22, 2023
1 parent c997bb5 commit 030c2e5
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void register(String username, String password, String phonenumber, Long
clientUser.setPhonenumber(phonenumber);
clientUser.setInviteCode(inviteCode);
clientUser.setPassword(SecurityUtils.encryptPassword(password));
logger.info("注册用户信息:{}", clientUser);
R<Boolean> registerResult = remoteClientUserService.registerUserInfo(clientUser, SecurityConstants.INNER);
if (R.FAIL == registerResult.getCode())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public class ClientConstant {

public static final Long ENTRUST_SUCCESS = 1L;

public static final Long ENTRUST_CANCLE = 2L;
public static final Long ENTRUST_CANCEL = 2L;

public static final Long POSITION_PENDING = 0L;

public static final Long POSITION_CLOSED = 1L;

public static final Long LIQUIDATION = 2L;

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class TradeTransactionServiceImpl implements TradeTransactionService {

@Override
public void tradeOrderPriceChange(String productCode) {
log.info("产品{}价格发生波动,开始检查订单", productCode);
String productPriceCacheKey = String.format(PRODUCT_PRICE_INFO_KEY, productCode, DateUtils.dateTime());
JSONObject price = redisService.getCacheObject(productPriceCacheKey);
TradeOrder tradeOrder = new TradeOrder();
Expand Down Expand Up @@ -114,7 +113,6 @@ private void tradeOrderDelivery(TradeOrder tradeOrder) {

@Override
public void entrustOrderPriceChange(String productCode) {
log.info("产品{}价格发生波动,开始检查订单", productCode);
String productPriceCacheKey = String.format(PRODUCT_PRICE_INFO_KEY, productCode, DateUtils.dateTime());
JSONObject price = redisService.getCacheObject(productPriceCacheKey);
EntrustOrder entrustOrder = new EntrustOrder();
Expand All @@ -140,7 +138,6 @@ protected void processIfBuy(EntrustOrder entrustOrder, BigDecimal currentPrice)
if (entrustOrder.getTradePrice().compareTo(currentPrice) < 0) {
return;
}
log.info("委托买入订单{}即将交割", entrustOrder.getOrderId());
EntrustOrder updateOrder = new EntrustOrder();
updateOrder.setId(entrustOrder.getId());
updateOrder.setStatus(1L);
Expand All @@ -154,7 +151,6 @@ protected void processIfSell(EntrustOrder entrustOrder, BigDecimal currentPrice)
if (entrustOrder.getTradePrice().compareTo(currentPrice) > 0) {
return;
}
log.info("委托卖出订单{}即将交割", entrustOrder.getOrderId());
EntrustOrder updateOrder = new EntrustOrder();
updateOrder.setId(entrustOrder.getId());
updateOrder.setStatus(1L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.client.domain.ClientUser;
import com.ruoyi.client.service.IClientUserService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -37,6 +39,9 @@ public class ClientUserWalletController extends BaseController
@Autowired
private IClientUserWalletService clientUserWalletService;

@Autowired
private IClientUserService clientUserService;

/**
* 查询用户资产列表
*/
Expand All @@ -46,6 +51,13 @@ public TableDataInfo list(ClientUserWallet clientUserWallet)
{
startPage();
List<ClientUserWallet> list = clientUserWalletService.selectClientUserWalletList(clientUserWallet);
for (ClientUserWallet wallet: list) {
ClientUser clientUser = clientUserService.selectClientUserByUserId(wallet.getUserId());
if (clientUser == null) {
continue;
}
wallet.setUserName(clientUser.getUserName());
}
return getDataTable(list);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,9 @@ public AjaxResult orderPriceChange(@RequestParam("productCode") String productCo
return AjaxResult.success();
}

@PostMapping("/sellOut")
public AjaxResult sellOut(@RequestBody TradeOrder tradeOrder) {
return AjaxResult.success(tradeOrderService.sellOut(tradeOrder));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class ClientUserWallet extends BaseEntity
@Excel(name = "用户id")
private Long userId;

@Excel(name = "用户名")
private String userName;

/** 总金额 */
@Excel(name = "总金额")
private BigDecimal totalAmount;
Expand Down Expand Up @@ -94,6 +97,14 @@ public Long getDelFlag()
return delFlag;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ public interface ITradeOrderService
* @param tradeOrder
*/
public boolean submit(TradeOrder tradeOrder);

/**
* 平仓
* @param tradeOrder
* @return
*/
public boolean sellOut(TradeOrder tradeOrder);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ruoyi.client.service.impl;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;

Expand All @@ -10,6 +12,7 @@
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.uuid.UUID;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.market.api.RemoteProductInfoService;
Expand All @@ -25,7 +28,7 @@

import javax.annotation.Resource;

import static com.ruoyi.common.core.constant.MarketConstant.PRODUCT_PRICE_INFO_KEY;
import static com.ruoyi.common.core.constant.MarketConstant.*;

/**
* 交易订单Service业务层处理
Expand Down Expand Up @@ -151,6 +154,40 @@ public boolean submit(TradeOrder tradeOrder) {
return true;
}

@Override
public boolean sellOut(TradeOrder tradeOrder) {
TradeOrder existOrder = tradeOrderMapper.selectTradeOrderById(tradeOrder.getId());
if (existOrder == null) {
throw new IllegalArgumentException("Order is not exist");
}
if (!ClientConstant.POSITION_PENDING.equals(existOrder.getStatus())) {
throw new IllegalArgumentException("Order status is not correct");
}
String productPriceCacheKey = String.format(PRODUCT_PRICE_INFO_KEY, existOrder.getProductCode(), DateUtils.dateTime());
JSONObject price = redisService.getCacheObject(productPriceCacheKey);
BigDecimal currentPrice = price.getBigDecimal("currentPrice");
TradeOrder updateOrder = new TradeOrder();
if (StringUtils.equals(BUY, tradeOrder.getTradeDirect())) {
updateOrder.setIncome(currentPrice.subtract(existOrder.getTradePrice()).multiply(existOrder.getSheetNum()).setScale(6, RoundingMode.HALF_UP));
} else {
updateOrder.setIncome(existOrder.getTradePrice().subtract(currentPrice).multiply(existOrder.getSheetNum()).setScale(6, RoundingMode.HALF_UP));
}
updateOrder.setStatus(1L);
updateOrder.setDeliveryAmount(currentPrice.multiply(existOrder.getSheetNum()).setScale(6, RoundingMode.HALF_UP));
updateOrder.setDeliveryPrice(currentPrice);
updateOrder.setRemark("止盈平仓");
updateTradeOrder(updateOrder);
clientUserWalletService.balanceChange(
existOrder.getUserId(),
"system",
updateOrder.getId(),
"USD",
updateOrder.getIncome(),
ClientConstant.INCREASE
);
return true;
}

@Transactional(rollbackFor = Exception.class)
public void generateOrder(TradeOrder tradeOrder) {
tradeOrder.setStatus(0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

<select id="selectClientUserAuthList" parameterType="com.ruoyi.client.domain.ClientUserAuth" resultMap="ClientUserAuthResult">
<include refid="selectClientUserAuthVo"/>
<where>
<where>
<if test="userId != null"> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="realName != null and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
Expand Down
26 changes: 17 additions & 9 deletions ruoyi-ui/src/views/client/auth/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
<el-option
v-for="dict in dict.type.client_data_status"
v-for="dict in dict.type.client_auth_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
Expand Down Expand Up @@ -83,13 +83,21 @@
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="用户id" align="center" prop="userId" />
<el-table-column label="用户名" align="center" prop="userName" />
<el-table-column label="证件正面" align="center" prop="credentialFront" />
<el-table-column label="证件反面" align="center" prop="credentialBackground" />
<el-table-column label="证件正面" align="center" prop="credentialFront" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.credentialFront" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="证件反面" align="center" prop="credentialBackground" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.credentialBackground" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="真实姓名" align="center" prop="realName" />
<el-table-column label="证件号" align="center" prop="credentialNo" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.client_data_status" :value="scope.row.status"/>
<dict-tag :options="dict.type.client_auth_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
Expand All @@ -114,7 +122,7 @@
</template>
</el-table-column>
</el-table>

<pagination
v-show="total>0"
:total="total"
Expand All @@ -133,10 +141,10 @@
<el-input v-model="form.userName" placeholder="请输入用户名" />
</el-form-item>
<el-form-item label="证件正面" prop="credentialFront">
<el-input v-model="form.credentialFront" placeholder="请输入证件正面" />
<image-upload v-model="form.credentialFront"/>
</el-form-item>
<el-form-item label="证件反面" prop="credentialBackground">
<el-input v-model="form.credentialBackground" placeholder="请输入证件反面" />
<image-upload v-model="form.credentialBackground"/>
</el-form-item>
<el-form-item label="真实姓名" prop="realName">
<el-input v-model="form.realName" placeholder="请输入真实姓名" />
Expand All @@ -147,7 +155,7 @@
<el-form-item label="状态" prop="status">
<el-select v-model="form.status" placeholder="请选择状态">
<el-option
v-for="dict in dict.type.client_data_status"
v-for="dict in dict.type.client_auth_status"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
Expand All @@ -171,7 +179,7 @@ import { listAuth, getAuth, delAuth, addAuth, updateAuth } from "@/api/client/au
export default {
name: "Auth",
dicts: ['client_data_status'],
dicts: ['client_auth_status'],
data() {
return {
// 遮罩层
Expand Down
2 changes: 1 addition & 1 deletion ruoyi-ui/src/views/client/wallet-flow/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

<el-table v-loading="loading" :data="walletFlowList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键id" align="center" prop="id" />
<!-- <el-table-column label="主键id" align="center" prop="id" />-->
<el-table-column label="钱包id" align="center" prop="walletId" />
<el-table-column label="用户号" align="center" prop="userId" />
<el-table-column label="订单号" align="center" prop="bizOrderId" />
Expand Down
3 changes: 2 additions & 1 deletion ruoyi-ui/src/views/client/wallet/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@

<el-table v-loading="loading" :data="walletList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" />
<!-- <el-table-column label="主键" align="center" prop="id" />-->
<el-table-column label="用户id" align="center" prop="userId" />
<el-table-column label="用户名" align="center" prop="userName" />
<el-table-column label="总金额" align="center" prop="totalAmount" />
<el-table-column label="币种" align="center" prop="currency" />
<el-table-column label="状态" align="center" prop="status">
Expand Down
3 changes: 2 additions & 1 deletion ruoyi-ui/src/views/fund/account/recharge/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

<el-table v-loading="loading" :data="accountList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<!-- <el-table-column label="编号" align="center" prop="id" />-->
<el-table-column label="所属用户" align="center" prop="userId" />
<el-table-column label="所属用户名" align="center" prop="userName" />
<el-table-column label="账户名" align="center" prop="accountName" />
Expand Down Expand Up @@ -292,6 +292,7 @@ export default {
/** 查询账号管理列表 */
getList() {
this.loading = true;
this.queryParams.accountUsage = "recharge";
listAccount(this.queryParams).then(response => {
this.accountList = response.rows;
this.total = response.total;
Expand Down
3 changes: 2 additions & 1 deletion ruoyi-ui/src/views/fund/account/withdraw/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<el-table v-loading="loading" :data="accountList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<!-- <el-table-column label="编号" align="center" prop="id" />-->
<el-table-column label="账户名" align="center" prop="accountName" />
<el-table-column label="账号" align="center" prop="accountNo" />
<el-table-column label="币种" align="center" prop="accountCurrency" />
Expand Down Expand Up @@ -271,6 +271,7 @@ export default {
/** 查询充值帐号列表 */
getList() {
this.loading = true;
this.queryParams.accountUsage = "withdraw";
listAccount(this.queryParams).then(response => {
this.accountList = response.rows;
this.total = response.total;
Expand Down
4 changes: 2 additions & 2 deletions ruoyi-ui/src/views/fund/config/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

<el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" />
<!-- <el-table-column label="主键" align="center" prop="id" />-->
<el-table-column label="用户id" align="center" prop="userId" />
<el-table-column label="用户名" align="center" prop="userName" />
<el-table-column label="交易类型" align="center" prop="tradeType">
Expand Down Expand Up @@ -139,7 +139,7 @@
</template>
</el-table-column>
</el-table>

<pagination
v-show="total>0"
:total="total"
Expand Down
2 changes: 1 addition & 1 deletion ruoyi-ui/src/views/fund/entrust/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<el-table v-loading="loading" :data="entrustList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="订单编号" align="center" prop="id" />
<!-- <el-table-column label="订单编号" align="center" prop="id" />-->
<el-table-column label="订单号" align="center" prop="orderId" />
<el-table-column label="用户id" align="center" prop="userId" />
<el-table-column label="用户名" align="center" prop="userName" />
Expand Down
2 changes: 1 addition & 1 deletion ruoyi-ui/src/views/fund/trade/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<el-table v-loading="loading" :data="tradeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="订单编号" align="center" prop="id" />
<!-- <el-table-column label="订单编号" align="center" prop="id" />-->
<el-table-column label="订单号" align="center" prop="orderId" />
<el-table-column label="用户id" align="center" prop="userId" />
<el-table-column label="用户名" align="center" prop="userName" />
Expand Down
4 changes: 2 additions & 2 deletions ruoyi-ui/src/views/fund/withdraw/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<el-table v-loading="loading" :data="withdrawList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<!-- <el-table-column label="编号" align="center" prop="id" />-->
<el-table-column label="用户名" align="center" prop="userName" />
<el-table-column label="订单号" align="center" prop="orderId" />
<el-table-column label="提现金额" align="center" prop="amount" />
Expand Down Expand Up @@ -129,7 +129,7 @@
</template>
</el-table-column>
</el-table>

<pagination
v-show="total>0"
:total="total"
Expand Down
Loading

0 comments on commit 030c2e5

Please sign in to comment.