usdt_orders 收款订单禁止修改,只允许删除过期的订单
This commit is contained in:
1 parent
cc5fe279e9
commit
f6babe9358
3 files changed
+92
-16
No files matched your search
+21
-14
@@ -15,6 +15,8 @@ import com.ruoyi.system.service.IUsdtOrdersService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
|
||||
import java.util.*;
|
||||
/**
|
||||
@@ -243,11 +245,8 @@ public class UsdtOrdersServiceImpl extends ServiceImpl<UsdtOrdersMapper, UsdtOrd
|
||||
@Override
|
||||
public int updateUsdtOrders(UsdtOrders usdtOrders,boolean isUser)
|
||||
{
|
||||
usdtOrders.setUpdatedAt(DateUtils.getNowDate());
|
||||
if(isUser){
|
||||
checkUser(usdtOrders);
|
||||
}
|
||||
return usdtOrdersMapper.updateUsdtOrders(usdtOrders);
|
||||
// 收款订单由支付工作流维护,不允许通过管理端修改金额、状态或归属。
|
||||
throw new CustomException("收款订单禁止修改");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,13 +256,24 @@ public class UsdtOrdersServiceImpl extends ServiceImpl<UsdtOrdersMapper, UsdtOrd
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteUsdtOrdersByIds(Long[] ids,boolean isUser)
|
||||
{
|
||||
if(isUser){
|
||||
List<UsdtOrdersPlus> list= getByIds(Arrays.asList(ids),false,UsdtOrdersPlus::getUserId,UsdtOrdersPlus::getId);
|
||||
checkUserPlus(list);
|
||||
if (ids == null || ids.length == 0 || Arrays.asList(ids).contains(null)) {
|
||||
throw new CustomException("请选择需要删除的已过期订单");
|
||||
}
|
||||
return usdtOrdersMapper.deleteUsdtOrdersByIds(ids);
|
||||
// 固定加锁顺序;整批校验通过才删除,避免混入待支付/已支付订单导致部分删除。
|
||||
Long[] uniqueIds = new TreeSet<>(Arrays.asList(ids)).toArray(new Long[0]);
|
||||
for (Long id : uniqueIds) {
|
||||
UsdtOrdersPlus order = usdtOrdersMapper.selectByIdForUpdate(id);
|
||||
if (order == null || (isUser && !Objects.equals(order.getUserId(), SecurityUtils.getUserId()))) {
|
||||
throw new CustomException("订单不存在或无权删除");
|
||||
}
|
||||
if (!Long.valueOf(3L).equals(order.getStatus())) {
|
||||
throw new CustomException("仅允许删除已过期的收款订单");
|
||||
}
|
||||
}
|
||||
return usdtOrdersMapper.deleteUsdtOrdersByIds(uniqueIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,12 +283,9 @@ public class UsdtOrdersServiceImpl extends ServiceImpl<UsdtOrdersMapper, UsdtOrd
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteUsdtOrdersById(Long id,boolean isUser)
|
||||
{
|
||||
if(isUser){
|
||||
UsdtOrdersPlus vo = getById(id,UsdtOrdersPlus::getUserId,UsdtOrdersPlus::getId);
|
||||
checkUser(vo);
|
||||
}
|
||||
return usdtOrdersMapper.deleteUsdtOrdersById(id);
|
||||
return deleteUsdtOrdersByIds(new Long[] {id}, isUser);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user