支付方式修改接口完善

This commit is contained in:
张松
2025-03-04 17:29:31 +08:00
parent fcd9196558
commit 7499cee35e
2 changed files with 9 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
package com.czg.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.ShopPayTypeDTO;
import com.czg.account.dto.paytype.ShopPayTypeAddDTO;
import com.czg.account.entity.ShopPayType;
@@ -50,13 +51,13 @@ public class ShopPayTypeController {
@PutMapping
public CzgResult<Boolean> 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());
});
}).ne(ShopPayType::getId, shopPayTypeDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("支付方式或支付名称已存在");
if (StrUtil.isNotBlank(shopPayTypeDTO.getPayName())) {
long count = shopPayTypeService.count(new QueryWrapper().eq(ShopPayType::getShopId, StpKit.USER.getShopId())
.eq(ShopPayType::getPayName, shopPayTypeDTO.getPayName())
.ne(ShopPayType::getId, shopPayTypeDTO.getId()));
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())));
}

View File

@@ -33,6 +33,7 @@ public class ShopPayTypeDTO implements Serializable {
* 是否快捷展示1是0否
*/
private Integer isShowShortcut;
private String payName;
/**
* 0允许退款 1-不允许退款