diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java index 46cf62c35..4abb18e5f 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopPayTypeController.java @@ -6,6 +6,7 @@ import com.czg.account.dto.paytype.ShopPayTypeAddDTO; import com.czg.account.entity.ShopPayType; import com.czg.account.service.ShopPayTypeService; import com.czg.annotation.SaAdminCheckPermission; +import com.czg.exception.ApiNotPrintException; import com.czg.resp.CzgResult; import com.czg.sa.StpKit; import com.mybatisflex.core.query.QueryWrapper; @@ -49,6 +50,14 @@ public class ShopPayTypeController { @PutMapping public CzgResult edit(@RequestBody ShopPayTypeDTO shopPayTypeDTO) { ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeDTO, ShopPayType.class); + long count = shopPayTypeService.count(new QueryWrapper().eq(ShopPayType::getShopId, StpKit.USER.getShopId()).and(r -> { + r.eq(ShopPayType::getPayType, shopPayType.getPayType()).or(r1 -> { + r1.eq(ShopPayType::getPayName, shopPayType.getPayName()); + }); + })); + if (count > 0) { + throw new ApiNotPrintException("支付方式或支付名称已存在"); + } return CzgResult.success(shopPayTypeService.update(shopPayType, new QueryWrapper().eq(ShopPayType::getId, shopPayTypeDTO.getId()).eq(ShopPayType::getShopId, StpKit.USER.getShopId()))); }