111
This commit is contained in:
1 parent
a8e2a507d9
commit
68a2b4f68c
11 files changed
+140
-14
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.task;
|
||||
|
||||
import com.ruoyi.system.domain.UsdtFundFlow;
|
||||
import com.ruoyi.system.domain.UsdtFundFlowPlus;
|
||||
import com.ruoyi.system.domain.UsdtOrdersPlus;
|
||||
import com.ruoyi.system.domain.UsdtUserSettlementConfigurationPlus;
|
||||
import com.ruoyi.system.service.IUsdtFundFlowService;
|
||||
import com.ruoyi.system.service.IUsdtOrdersService;
|
||||
import com.ruoyi.system.service.IUsdtUserSettlementConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component("splitAccountsTask")
|
||||
public class SplitAccountsTask {
|
||||
@Autowired
|
||||
private IUsdtOrdersService usdtOrdersService;
|
||||
@Autowired
|
||||
private IUsdtUserSettlementConfigurationService usdtUserSettlementConfigurationService;
|
||||
@Autowired
|
||||
private IUsdtFundFlowService usdtFundFlowService;
|
||||
public void execute() {
|
||||
List<UsdtOrdersPlus> list = usdtOrdersService.getWillSettlement(1000);
|
||||
Map<Long, UsdtUserSettlementConfigurationPlus> configMap = new HashMap<Long, UsdtUserSettlementConfigurationPlus>();
|
||||
List<UsdtFundFlowPlus> fundFlows = new ArrayList<UsdtFundFlowPlus>();
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (UsdtOrdersPlus usdtOrdersPlus : list) {
|
||||
UsdtUserSettlementConfigurationPlus config = configMap.getOrDefault(usdtOrdersPlus.getUserId(), usdtUserSettlementConfigurationService.getByUserId(usdtOrdersPlus.getUserId()));
|
||||
BigDecimal yj = usdtOrdersPlus.getActualAmount().multiply(config.getCommissionRate());
|
||||
UsdtFundFlowPlus yjFlow = new UsdtFundFlowPlus();
|
||||
yjFlow.setAppId(usdtOrdersPlus.getAppId());
|
||||
yjFlow.setAmount(yj);
|
||||
yjFlow.setOrderId(usdtOrdersPlus.getId());
|
||||
yjFlow.setOpType(1);
|
||||
yjFlow.setUserId(usdtOrdersPlus.getUserId());
|
||||
yjFlow.setToken(usdtOrdersPlus.getToken());
|
||||
|
||||
UsdtFundFlowPlus shFlow = new UsdtFundFlowPlus();
|
||||
shFlow.setAppId(usdtOrdersPlus.getAppId());
|
||||
shFlow.setAmount(usdtOrdersPlus.getActualAmount().subtract(yj));
|
||||
shFlow.setOrderId(usdtOrdersPlus.getId());
|
||||
shFlow.setOpType(0);
|
||||
shFlow.setUserId(usdtOrdersPlus.getUserId());
|
||||
shFlow.setToken(usdtOrdersPlus.getToken());
|
||||
|
||||
fundFlows.add(yjFlow);
|
||||
fundFlows.add(shFlow);
|
||||
ids.add(usdtOrdersPlus.getId());
|
||||
}
|
||||
if(!fundFlows.isEmpty()){
|
||||
usdtFundFlowService.saveBatch(fundFlows);
|
||||
}
|
||||
if(ids.isEmpty()){
|
||||
this.usdtOrdersService.updateSettlementStatusByIds(ids,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class UsdtFundFlow extends BaseEntity
|
||||
|
||||
/** 操作类型 */
|
||||
@Excel(name = "操作类型")
|
||||
private Long opType;
|
||||
private Integer opType;
|
||||
|
||||
/** Token地址 */
|
||||
@Excel(name = "Token地址")
|
||||
@@ -130,12 +130,12 @@ public class UsdtFundFlow extends BaseEntity
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
public void setOpType(Long opType)
|
||||
public void setOpType(Integer opType)
|
||||
{
|
||||
this.opType = opType;
|
||||
}
|
||||
|
||||
public Long getOpType()
|
||||
public Integer getOpType()
|
||||
{
|
||||
return opType;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class UsdtFundFlowPlus implements Serializable
|
||||
private BigDecimal amount;
|
||||
/** 操作类型 */
|
||||
@Excel(name = "操作类型")
|
||||
private Long opType;
|
||||
private Integer opType;
|
||||
/** Token地址 */
|
||||
@Excel(name = "Token地址")
|
||||
private String token;
|
||||
@@ -126,12 +126,12 @@ public class UsdtFundFlowPlus implements Serializable
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
public void setOpType(Long opType)
|
||||
public void setOpType(Integer opType)
|
||||
{
|
||||
this.opType = opType;
|
||||
}
|
||||
|
||||
public Long getOpType()
|
||||
public Integer getOpType()
|
||||
{
|
||||
return opType;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class UsdtOrders extends BaseEntity
|
||||
|
||||
/** 结算状态 */
|
||||
@Excel(name = "结算状态")
|
||||
private Long settlementStatus;
|
||||
private Integer settlementStatus;
|
||||
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
@@ -234,12 +234,12 @@ public class UsdtOrders extends BaseEntity
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setSettlementStatus(Long settlementStatus)
|
||||
public void setSettlementStatus(Integer settlementStatus)
|
||||
{
|
||||
this.settlementStatus = settlementStatus;
|
||||
}
|
||||
|
||||
public Long getSettlementStatus()
|
||||
public Integer getSettlementStatus()
|
||||
{
|
||||
return settlementStatus;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class UsdtOrdersPlus implements Serializable
|
||||
private Long appId;
|
||||
/** 结算状态 */
|
||||
@Excel(name = "结算状态")
|
||||
private Long settlementStatus;
|
||||
private Integer settlementStatus;
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
private Long userId;
|
||||
@@ -219,12 +219,12 @@ public class UsdtOrdersPlus implements Serializable
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
public void setSettlementStatus(Long settlementStatus)
|
||||
public void setSettlementStatus(Integer settlementStatus)
|
||||
{
|
||||
this.settlementStatus = settlementStatus;
|
||||
}
|
||||
|
||||
public Long getSettlementStatus()
|
||||
public Integer getSettlementStatus()
|
||||
{
|
||||
return settlementStatus;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
@@ -45,7 +46,30 @@ public class WalletAddressPlus implements Serializable
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
private Long userId;
|
||||
public void setId(Long id)
|
||||
|
||||
@Excel(name = "usdt余额")
|
||||
private BigDecimal usdtBalance;
|
||||
|
||||
@Excel(name = "trx余额")
|
||||
private BigDecimal trxBalance;
|
||||
|
||||
public BigDecimal getTrxBalance() {
|
||||
return trxBalance;
|
||||
}
|
||||
|
||||
public void setTrxBalance(BigDecimal trxBalance) {
|
||||
this.trxBalance = trxBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getUsdtBalance() {
|
||||
return usdtBalance;
|
||||
}
|
||||
|
||||
public void setUsdtBalance(BigDecimal usdtBalance) {
|
||||
this.usdtBalance = usdtBalance;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IUsdtOrdersService extends IService<UsdtOrdersPlus>
|
||||
{
|
||||
/**
|
||||
* 获取已支付未结算订单
|
||||
* @return
|
||||
*/
|
||||
List<UsdtOrdersPlus> getWillSettlement(Integer size);
|
||||
|
||||
List<SelectItem> select(String keyword,boolean isUser);
|
||||
/**
|
||||
@@ -26,6 +31,8 @@ public interface IUsdtOrdersService extends IService<UsdtOrdersPlus>
|
||||
*/
|
||||
public UsdtOrders selectUsdtOrdersById(Long id,boolean isUser);
|
||||
|
||||
|
||||
int updateSettlementStatusByIds(List<Long> ids,Integer settlementStatus);
|
||||
/**
|
||||
* 查询订单列表
|
||||
*
|
||||
@@ -88,4 +95,6 @@ public interface IUsdtOrdersService extends IService<UsdtOrdersPlus>
|
||||
Long count(String where);
|
||||
|
||||
<T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass);
|
||||
|
||||
|
||||
}
|
||||
+2
@@ -26,6 +26,8 @@ public interface IUsdtUserSettlementConfigurationService extends IService<UsdtUs
|
||||
*/
|
||||
public UsdtUserSettlementConfiguration selectUsdtUserSettlementConfigurationById(Long id,boolean isUser);
|
||||
|
||||
|
||||
UsdtUserSettlementConfigurationPlus getByUserId(Long userId);
|
||||
/**
|
||||
* 查询商户配置列表
|
||||
*
|
||||
|
||||
@@ -68,6 +68,14 @@ public class UsdtOrdersServiceImpl extends ServiceImpl<UsdtOrdersMapper, UsdtOrd
|
||||
throw new RuntimeException("无权限");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsdtOrdersPlus> getWillSettlement(Integer size) {
|
||||
LambdaQueryWrapper<UsdtOrdersPlus> lambdaQueryWrapper = new LambdaQueryWrapper<UsdtOrdersPlus>()
|
||||
.eq(UsdtOrdersPlus::getSettlementStatus,0).eq(UsdtOrdersPlus::getStatus,2).last("limit "+ size);
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectItem> select(String keyword,boolean isUser) {
|
||||
LambdaQueryWrapper<UsdtOrdersPlus> lambdaQueryWrapper = new LambdaQueryWrapper<UsdtOrdersPlus>()
|
||||
@@ -181,6 +189,12 @@ public class UsdtOrdersServiceImpl extends ServiceImpl<UsdtOrdersMapper, UsdtOrd
|
||||
return vo;
|
||||
}
|
||||
|
||||
public int updateSettlementStatusByIds(List<Long> ids,Integer settlementStatus){
|
||||
UsdtOrdersPlus usdtOrders = new UsdtOrdersPlus();
|
||||
usdtOrders.setSettlementStatus(settlementStatus);
|
||||
return baseMapper.update(usdtOrders, new LambdaQueryWrapper<UsdtOrdersPlus>()
|
||||
.and(i -> i.in(UsdtOrdersPlus::getId, ids)));
|
||||
}
|
||||
/**
|
||||
* 查询订单列表
|
||||
*
|
||||
|
||||
+7
@@ -181,6 +181,13 @@ public class UsdtUserSettlementConfigurationServiceImpl extends ServiceImpl<Usdt
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsdtUserSettlementConfigurationPlus getByUserId(Long userId) {
|
||||
LambdaQueryWrapper<UsdtUserSettlementConfigurationPlus> lambdaQueryWrapper = new LambdaQueryWrapper<UsdtUserSettlementConfigurationPlus>()
|
||||
.eq(UsdtUserSettlementConfigurationPlus::getUserId, userId);
|
||||
return getOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商户配置列表
|
||||
*
|
||||
|
||||
@@ -13,10 +13,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="deletedAt" column="deleted_at" />
|
||||
<result property="appId" column="app_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="usdtBalance" column="usdt_balance" />
|
||||
<result property="trxBalance" column="trx_balance" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectWalletAddressVo">
|
||||
select id, token, status, created_at, updated_at, deleted_at, app_id, user_id from wallet_address
|
||||
select id, token, status, created_at, updated_at, deleted_at, app_id, user_id,usdt_balance,trx_balance from wallet_address
|
||||
</sql>
|
||||
|
||||
<select id="selectWalletAddressList" parameterType="WalletAddress" resultMap="WalletAddressResult">
|
||||
@@ -47,6 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deletedAt != null">deleted_at,</if>
|
||||
<if test="appId != null">app_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="usdtBalance != null">usdt_balance,</if>
|
||||
<if test="trxBalance != null">trx_balance,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="token != null and token != ''">#{token},</if>
|
||||
@@ -56,6 +60,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deletedAt != null">#{deletedAt},</if>
|
||||
<if test="appId != null">#{appId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="usdtBalance != null">#{usdtBalance},</if>
|
||||
<if test="trxBalance != null">#{trxBalance},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -69,6 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
|
||||
<if test="appId != null">app_id = #{appId},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="usdtBalance != null">usdt_balance = #{usdtBalance},</if>
|
||||
<if test="trxBalance != null">trx_balance = #{trxBalance},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in new issue
Block a user