支付方式接口

This commit is contained in:
张松 2025-02-26 10:59:07 +08:00
parent 533a5a4e7e
commit 6488a55355
6 changed files with 97 additions and 7 deletions

View File

@ -42,13 +42,23 @@ public class ShopPayTypeController {
}
/**
* 支付方式详情获取
* 支付方式编辑
*/
@SaAdminCheckPermission(value = "shopPayType:edit", name = "支付方式编辑")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody ShopPayTypeDTO shopPayTypeDTO) {
ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeDTO, ShopPayType.class);
return CzgResult.success(shopPayTypeService.updateById(shopPayType));
return CzgResult.success(shopPayTypeService.update(shopPayType, new QueryWrapper().eq(ShopPayType::getId, shopPayTypeDTO.getId()).eq(ShopPayType::getShopId, StpKit.USER.getShopId())));
}
/**
* 支付方式添加
*/
@SaAdminCheckPermission(value = "shopPayType:save", name = "支付方式添加")
@PostMapping
public CzgResult<Boolean> add(@RequestBody ShopPayTypeDTO shopPayTypeDTO) {
ShopPayType shopPayType = BeanUtil.copyProperties(shopPayTypeDTO, ShopPayType.class);
return CzgResult.success(shopPayTypeService.add(StpKit.USER.getShopId(),shopPayType));
}
}

View File

@ -34,11 +34,6 @@ public class ShopPayTypeDTO implements Serializable {
*/
private Integer isShowShortcut;
/**
* 店铺id
*/
private String shopId;
/**
* 0允许退款 1-不允许退款
*/

View File

@ -0,0 +1,66 @@
package com.czg.account.dto.paytype;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
/**
* 店铺支付类型 实体类
*
* @author zs
* @since 2025-02-26
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ShopPayTypeAddDTO {
/**
* 是否快捷展示1是0否
*/
private Integer isShowShortcut;
/**
* 0允许退款 1-不允许退款
*/
private Integer isRefundable;
/**
* 是否打开钱箱
*/
private Integer isOpenCashDrawer;
/**
* 0不是 1是 [系统级支付]
*/
private Integer isSystem;
/**
* 0-非虚拟 1虚拟 virtual
*/
private Integer isIdeal;
/**
* 0-不显示1显示
*/
private Integer isDisplay;
/**
* 排序
*/
private Integer sorts;
/**
* 图标
*/
private String icon;
}

View File

@ -15,4 +15,6 @@ public interface ShopPayTypeService extends IService<ShopPayType> {
List<ShopPayType> getList(Long shopId);
Boolean add(Long shopId, ShopPayType shopPayType);
}

View File

@ -1,5 +1,7 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.exception.ApiNotPrintException;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
@ -40,4 +42,18 @@ public class ShopPayTypeServiceImpl extends ServiceImpl<ShopPayTypeMapper, ShopP
}
return list;
}
@Override
public Boolean add(Long shopId, ShopPayType shopPayType) {
long count = count(new QueryWrapper().eq(ShopPayType::getPayType, shopPayType.getPayType()).or(r -> {
r.eq(ShopPayType::getPayName, shopPayType.getPayName());
}));
if (count > 0) {
throw new ApiNotPrintException("支付方式或支付名称已存在");
}
ShopPayType payType = BeanUtil.copyProperties(shopPayType, ShopPayType.class);
payType.setShopId(shopId);
return save(payType);
}
}

View File

@ -71,6 +71,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
if (isVip != null) {
queryWrapper.eq(ShopUser::getIsVip, isVip);
}
queryWrapper.orderBy(ShopUser::getId, false);
return mapper.xmlPaginate("selectPageByKeyAndIsVip", PageUtil.buildPage(), queryWrapper);
}