feat:有订单交易记录不能删除

This commit is contained in:
dzc committed 2025-04-07 16:52:49 +08:00
1 parent 406c60f84d
commit dcac429cfa
4 files changed
+29 -7

No files matched your search

@@ -21,8 +21,10 @@ public interface RemoteHardOrderService {
@GetMapping("/hard-order/get-by-ids")
R<List<HardOrderEntity>> getByIds(@RequestParam List<Long> ids);
@PostMapping("/hard-order/page")
R<Page<List<HardOrderEntity>>> getPage(@RequestParam Page page, @RequestBody HardOrderPreferencesDto hardOrderPreferencesDto);
@NoToken
@GetMapping("/hard-order/mch-count-by-id")
R<Long> getMchCountById(@RequestParam Long id);
}
@@ -88,6 +88,16 @@ public class HardOrderController {
dto.setOrderIds(ids);
return R.ok(hardOrderMapper.list(dto));
}
@Inner
@Operation(summary = "app查询订单列表", description = "app查询订单列表")
@GetMapping("/mch-count-by-id")
public R<Long> getMchCountById(@RequestParam Long id) {
LambdaQueryWrapper<HardOrderEntity> query = new LambdaQueryWrapper<HardOrderEntity>().eq(HardOrderEntity::getMerchantId, id);
Long count = hardOrderMapper.selectCount(query);
if (ObjectUtil.isEmpty(count)) count = 0L;
return R.ok(count);
}
/* ************************************* end 远程调用 ************************************* */
/* ************************************* start app start ************************************* */
@@ -301,14 +301,14 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
if (ObjectUtil.isEmpty(walletTypeList)) return walletPage;
// 查询所有钱包类型的流水记录
for (WalletTypeEntity i : walletTypeList) {
dto.setWalletTypeId(i.getId());
if (ObjectUtil.isEmpty(dto.getUserId())) {
dto.setUserIds(userIds);
WalletManageBalanceDto walletBalanceDto = BeanUtils.toBean(dto, WalletManageBalanceDto.class);
walletBalanceDto.setWalletTypeId(i.getId());
if (ObjectUtil.isEmpty(walletBalanceDto.getUserId())) {
walletBalanceDto.setUserIds(userIds);
}
List<WalletManageBalanceVo> itemList = baseMapper.selectBalance(dto);
List<WalletManageBalanceVo> itemList = baseMapper.selectBalance(walletBalanceDto);
if (ObjectUtil.isEmpty(itemList)) continue;
for (WalletManageBalanceVo j : itemList) {
// j.setWalletTypeName(i.getName());
walletPage.getRecords().stream().filter(v -> ObjectUtil.equals(i.getId(), v.getWalletTypeId()) && ObjectUtil.equals(v.getUserId(), j.getUserId())).findFirst().ifPresent(v -> {
if (ObjectUtil.isNotEmpty(j.getBalance())) {
v.setBalance(j.getBalance());
@@ -20,6 +20,7 @@ import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService;
import com.bsd.pjcloud.hard.api.utils.Drawing2D;
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
@@ -67,6 +68,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
private final RemoteUserService remoteUserService;
private final RemoteDeptService remoteDeptService;
private final RemoteFileService remoteFileService;
private final RemoteHardOrderService remoteHardOrderService;
@Lazy
private final WalletThirdZyService walletThirdZyService;
@@ -152,6 +154,14 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
@Override
public void delByIds(ArrayList<Long> list) {
if (ObjectUtil.isEmpty(list)) return;
// 判断下面是否有订单
List<MchManageVo> mchList = baseMapper.list(MchManageDto.builder().ids(list).build());
for (MchManageVo v : mchList) {
Long count = remoteHardOrderService.getMchCountById(v.getId()).getData();
if (ObjectUtil.isNotEmpty(count) && count > 0) {
throw new RuntimeException("该商户<" + v.getName() + ">有订单交易记录,不能删除");
}
}
// 删除缓存
list.forEach(v -> {
redisTemplate.opsForValue().getAndDelete(CacheConstants.WALLET_MCH + v);