update 新增数据补全,删除接口
This commit is contained in:
@@ -43,4 +43,12 @@ public interface ManageWalletOutInMapper extends BaseMapper<ManageWalletOutIn> {
|
||||
@DistributionDB
|
||||
List<SummaryOfPendingPaymentsDto> summaryOfPendingPayments();
|
||||
|
||||
|
||||
/**
|
||||
* 获取最大日期
|
||||
* @param coin
|
||||
* @return
|
||||
*/
|
||||
LocalDateTime getMaxDateData();
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.m2pool.manage.entity.ManageWalletOutIn;
|
||||
import com.m2pool.manage.vo.ManageBaseVo;
|
||||
import com.m2pool.manage.vo.ManageBroadcastVo;
|
||||
import com.m2pool.manage.vo.PageVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ public class ManageUserServiceImpl implements ManageUserService {
|
||||
//查询起付额
|
||||
List<SummaryOfPendingPaymentsDto> startPayments = manageBroadcastMapper.getStartPayments(summaryOfPendingPaymentsList);
|
||||
|
||||
// 创建一个 Map 用于存储第二个集合中元素的 user 和 coin 组合对应的 startPayAmount
|
||||
// 创建一个 Map 用于存储第二个集合中元素的 user 和 coin 组合对应的 startPayAmount . 这里可以优化一下,防止多key报错,不过一般不出这个问题
|
||||
Map<String, BigDecimal> startPayAmountMap = startPayments.stream()
|
||||
.collect(Collectors.toMap(
|
||||
dto -> dto.getUser() + "_" + dto.getCoin(),
|
||||
|
||||
@@ -42,20 +42,18 @@ public class ManageTask {
|
||||
/**
|
||||
* 存储交易记录定时任务
|
||||
*/
|
||||
@Scheduled(cron = "22 35 0/1 * * ?")
|
||||
//@Scheduled(cron = "0 0/1 * * * ?")
|
||||
//@Scheduled(cron = "22 58 0/1 * * ?")
|
||||
@Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void insertDataToWalletOutInDb(){
|
||||
ManageWalletOutIn manageWalletOutIn = manageWalletOutInMapper.selectOne(new LambdaQueryWrapper<ManageWalletOutIn>()
|
||||
.orderByDesc(ManageWalletOutIn::getDate
|
||||
).last("limit 1"));
|
||||
LocalDateTime maxDateData = manageWalletOutInMapper.getMaxDateData();
|
||||
|
||||
LocalDateTime startDate = null;
|
||||
List<ManageWalletOutIn> manageWalletOutIns = new ArrayList<>();
|
||||
if (manageWalletOutIn != null){
|
||||
startDate = manageWalletOutIn.getDate();
|
||||
if (maxDateData != null){
|
||||
startDate = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||
//获取startDate 后的数据,用于比对
|
||||
manageWalletOutIns = manageWalletOutInMapper.selectList(new LambdaQueryWrapper<ManageWalletOutIn>()
|
||||
.ge(ManageWalletOutIn::getDate, startDate.toLocalDate().atStartOfDay()));
|
||||
.ge(ManageWalletOutIn::getDate, startDate));
|
||||
}
|
||||
|
||||
List<ManageWalletOutIn> walletIn = manageWalletOutInMapper.getWalletIn(startDate);
|
||||
@@ -99,7 +97,12 @@ public class ManageTask {
|
||||
walletInfo.addAll(updatedInList);
|
||||
|
||||
} else {
|
||||
walletInfo.addAll(outList);
|
||||
List<ManageWalletOutIn> collect = outList.stream().peek(outItem -> {
|
||||
if (outItem.getShouldOutDate() == null) {
|
||||
outItem.setShouldOutDate(outItem.getDate().toLocalDate().atStartOfDay());
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
walletInfo.addAll(collect);
|
||||
}
|
||||
}
|
||||
//外层为in,内层为out -----新增当天只有walletIn,没有walletOut的数据
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
`user`,
|
||||
address,
|
||||
`date`,
|
||||
DATE(`date`) as shouldOutDate,
|
||||
COALESCE(DATE(`should_out_date`),DATE(`date`)) as shouldOutDate,
|
||||
max_height,
|
||||
allocation_amount as allocationAmount,
|
||||
transfer_amount as transferAmount
|
||||
@@ -53,7 +53,7 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
order by `date` desc
|
||||
order by `shouldOutDate` desc
|
||||
</select>
|
||||
<select id="getHistoryBalance" resultType="com.m2pool.manage.dto.HistoryBalanceDto">
|
||||
SELECT
|
||||
@@ -167,9 +167,10 @@
|
||||
user_account_balance uab
|
||||
JOIN user_miner_account uma ON uma.id = uab.ma_id
|
||||
WHERE
|
||||
uab.status = 0 AND (
|
||||
<foreach collection="list" item="item" separator="OR">
|
||||
(`user` = #{item.user} AND coin = #{item.coin})
|
||||
</foreach>
|
||||
(`miner_user` = #{item.user} AND coin = #{item.coin})
|
||||
</foreach>)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
SELECT
|
||||
wi.coin,
|
||||
wi.`user`,
|
||||
wi.should_out_date AS `date`,
|
||||
COALESCE(wi.`should_out_date`, wi.`create_date`) as `date`,
|
||||
wi.amount AS allocationAmount,
|
||||
wi.`create_date` as `shouldOutDate`,
|
||||
wi.should_out_date AS `shouldOutDate`,
|
||||
wi.max_height AS maxHeight
|
||||
FROM
|
||||
wallet_in wi
|
||||
<where>
|
||||
<choose>
|
||||
<when test="startDate != null">
|
||||
wi.`should_out_date` >= DATE(#{startDate})
|
||||
wi.`create_date` >= DATE(#{startDate})
|
||||
</when>
|
||||
<otherwise>
|
||||
wi.`should_out_date` <![CDATA[ <= ]]> NOW()
|
||||
wi.`create_date` <![CDATA[ <= ]]> NOW()
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
@@ -47,4 +47,7 @@
|
||||
<select id="summaryOfPendingPayments" resultType="com.m2pool.manage.dto.SummaryOfPendingPaymentsDto">
|
||||
select coin, max(max_height) as maxHeight, max(should_out_date) AS shouldOutDate, `user`, sum(amount) as needPayAmount from wallet_in where state = 2 group by coin,`user`
|
||||
</select>
|
||||
<select id="getMaxDateData" resultType="java.time.LocalDateTime">
|
||||
select `date` from manage_wallet_out_in order by `date` desc limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user