归集任务删除,只允许删除被拒绝状态的归集任务,删除归集任务,要同时删除归集任务下的明细数据
This commit is contained in:
1 parent
f6babe9358
commit
33481ab6eb
5 files changed
+23
-24
No files matched your search
+7
@@ -24,6 +24,13 @@ public class UsdtOrdersRestrictionTest {
|
|||||||
ReflectionTestUtils.setField(service, "usdtOrdersMapper", mapper);
|
ReflectionTestUtils.setField(service, "usdtOrdersMapper", mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rejectsManualCreationForBothScopes() {
|
||||||
|
rejects(() -> service.insertUsdtOrders(new UsdtOrders(), false));
|
||||||
|
rejects(() -> service.insertUsdtOrders(new UsdtOrders(), true));
|
||||||
|
verify(mapper, never()).insertUsdtOrders(any());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rejectsManualUpdatesForBothScopes() {
|
public void rejectsManualUpdatesForBothScopes() {
|
||||||
rejects(() -> service.updateUsdtOrders(new UsdtOrders(), false));
|
rejects(() -> service.updateUsdtOrders(new UsdtOrders(), false));
|
||||||
|
|||||||
+6
-5
@@ -131,7 +131,7 @@ public class UsdtAggregationWorkflowService {
|
|||||||
taskService.updateById(task);
|
taskService.updateById(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 仅允许删除尚未执行且处于待审核或审核拒绝状态的任务。 */
|
/** 仅允许删除审核拒绝且尚未执行的任务;主任务与明细同事务软删除,保留审计记录。 */
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteTask(Long taskId, boolean userMode) {
|
public void deleteTask(Long taskId, boolean userMode) {
|
||||||
UsdtAggregationTask task = taskMapper.selectUsdtAggregationTaskByIdForUpdate(taskId);
|
UsdtAggregationTask task = taskMapper.selectUsdtAggregationTaskByIdForUpdate(taskId);
|
||||||
@@ -140,15 +140,16 @@ public class UsdtAggregationWorkflowService {
|
|||||||
throw new CustomException("无权删除该归集任务");
|
throw new CustomException("无权删除该归集任务");
|
||||||
}
|
}
|
||||||
if (!Integer.valueOf(0).equals(task.getStatus())
|
if (!Integer.valueOf(0).equals(task.getStatus())
|
||||||
|| !(Integer.valueOf(0).equals(task.getVerifyStatus())
|
|| !Integer.valueOf(2).equals(task.getVerifyStatus())) {
|
||||||
|| Integer.valueOf(2).equals(task.getVerifyStatus()))) {
|
throw new CustomException("仅允许删除审核拒绝且尚未执行的归集任务");
|
||||||
throw new CustomException("只有待审核或审核拒绝且尚未执行的任务可以删除");
|
|
||||||
}
|
}
|
||||||
Date now = DateUtils.getNowDate();
|
Date now = DateUtils.getNowDate();
|
||||||
task.setDeletedAt(now);
|
task.setDeletedAt(now);
|
||||||
task.setUpdatedAt(now);
|
task.setUpdatedAt(now);
|
||||||
task.setRemark("任务已删除");
|
task.setRemark("任务已删除");
|
||||||
taskMapper.updateUsdtAggregationTask(task);
|
if (taskMapper.updateUsdtAggregationTask(task) != 1) {
|
||||||
|
throw new CustomException("归集任务删除失败,请刷新后重试");
|
||||||
|
}
|
||||||
itemService.update(new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<UsdtAggregationTaskItemPlus>()
|
itemService.update(new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<UsdtAggregationTaskItemPlus>()
|
||||||
.eq(UsdtAggregationTaskItemPlus::getParentId, taskId)
|
.eq(UsdtAggregationTaskItemPlus::getParentId, taskId)
|
||||||
.isNull(UsdtAggregationTaskItemPlus::getDeletedAt)
|
.isNull(UsdtAggregationTaskItemPlus::getDeletedAt)
|
||||||
|
|||||||
+6
-10
@@ -1,5 +1,7 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.exception.CustomException;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
@@ -258,11 +260,8 @@ public class UsdtAggregationTaskServiceImpl extends ServiceImpl<UsdtAggregationT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteUsdtAggregationTaskByIds(Long[] ids, boolean isUser) {
|
public int deleteUsdtAggregationTaskByIds(Long[] ids, boolean isUser) {
|
||||||
if (isUser) {
|
// 禁止生成式 CRUD 绕过审核状态校验及明细级联删除,统一由工作流处理。
|
||||||
List<UsdtAggregationTaskPlus> list = getByIds(Arrays.asList(ids), false, UsdtAggregationTaskPlus::getUserId, UsdtAggregationTaskPlus::getId);
|
throw new CustomException("请通过归集任务工作流删除审核拒绝的任务");
|
||||||
checkUserPlus(list);
|
|
||||||
}
|
|
||||||
return usdtAggregationTaskMapper.deleteUsdtAggregationTaskByIds(ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,10 +272,7 @@ public class UsdtAggregationTaskServiceImpl extends ServiceImpl<UsdtAggregationT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteUsdtAggregationTaskById(Long id, boolean isUser) {
|
public int deleteUsdtAggregationTaskById(Long id, boolean isUser) {
|
||||||
if (isUser) {
|
// 工作流会锁定主任务,并在同一事务中软删除主任务与全部明细。
|
||||||
UsdtAggregationTaskPlus vo = getById(id, UsdtAggregationTaskPlus::getUserId, UsdtAggregationTaskPlus::getId);
|
throw new CustomException("请通过归集任务工作流删除审核拒绝的任务");
|
||||||
checkUser(vo);
|
|
||||||
}
|
|
||||||
return usdtAggregationTaskMapper.deleteUsdtAggregationTaskById(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.common.select.SelectItem;
|
import com.ruoyi.common.select.SelectItem;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.UsdtOrders;
|
import com.ruoyi.system.domain.UsdtOrders;
|
||||||
@@ -228,12 +227,8 @@ public class UsdtOrdersServiceImpl extends ServiceImpl<UsdtOrdersMapper, UsdtOrd
|
|||||||
@Override
|
@Override
|
||||||
public int insertUsdtOrders(UsdtOrders usdtOrders,boolean isUser)
|
public int insertUsdtOrders(UsdtOrders usdtOrders,boolean isUser)
|
||||||
{
|
{
|
||||||
usdtOrders.setCreatedAt(DateUtils.getNowDate());
|
// 管理页面及用户管理页面均禁止手工造单;正常订单由支付创建流程生成。
|
||||||
usdtOrders.setUpdatedAt(DateUtils.getNowDate());
|
throw new CustomException("收款订单禁止管理端新增,请通过支付接口创建订单");
|
||||||
if(isUser){
|
|
||||||
usdtOrders.setUserId(SecurityUtils.getUserId());
|
|
||||||
}
|
|
||||||
return usdtOrdersMapper.insertUsdtOrders(usdtOrders);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectUsdtAggregationTaskItemList" parameterType="UsdtAggregationTaskItem" resultMap="UsdtAggregationTaskItemResult">
|
<select id="selectUsdtAggregationTaskItemList" parameterType="UsdtAggregationTaskItem" resultMap="UsdtAggregationTaskItemResult">
|
||||||
<include refid="selectUsdtAggregationTaskItemVo"/>
|
<include refid="selectUsdtAggregationTaskItemVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
deleted_at is null
|
||||||
<if test="tokenAddress != null and tokenAddress != ''"> and token_address = #{tokenAddress}</if>
|
<if test="tokenAddress != null and tokenAddress != ''"> and token_address = #{tokenAddress}</if>
|
||||||
<if test="status != null "> and status = #{status}</if>
|
<if test="status != null "> and status = #{status}</if>
|
||||||
<if test="opeAmount != null "> and ope_amount = #{opeAmount}</if>
|
<if test="opeAmount != null "> and ope_amount = #{opeAmount}</if>
|
||||||
<if test="createdAt != null "> and created_at = #{createdAt}</if>
|
<if test="createdAt != null "> and created_at = #{createdAt}</if>
|
||||||
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
|
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
|
||||||
<if test="deletedAt != null "> and deleted_at = #{deletedAt}</if>
|
|
||||||
<if test="needEnergyNum != null "> and need_energy_num = #{needEnergyNum}</if>
|
<if test="needEnergyNum != null "> and need_energy_num = #{needEnergyNum}</if>
|
||||||
<if test="needBandwidthNum != null "> and need_bandwidth_num = #{needBandwidthNum}</if>
|
<if test="needBandwidthNum != null "> and need_bandwidth_num = #{needBandwidthNum}</if>
|
||||||
<if test="gapBandwidthNum != null "> and gap_bandwidth_num = #{gapBandwidthNum}</if>
|
<if test="gapBandwidthNum != null "> and gap_bandwidth_num = #{gapBandwidthNum}</if>
|
||||||
@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectUsdtAggregationTaskItemById" parameterType="Long" resultMap="UsdtAggregationTaskItemResult">
|
<select id="selectUsdtAggregationTaskItemById" parameterType="Long" resultMap="UsdtAggregationTaskItemResult">
|
||||||
<include refid="selectUsdtAggregationTaskItemVo"/>
|
<include refid="selectUsdtAggregationTaskItemVo"/>
|
||||||
where id = #{id}
|
where id = #{id} and deleted_at is null
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUsdtAggregationTaskItem" parameterType="UsdtAggregationTaskItem" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertUsdtAggregationTaskItem" parameterType="UsdtAggregationTaskItem" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|||||||
Reference in new issue
Block a user