支付方式接口

This commit is contained in:
张松
2025-02-26 10:46:19 +08:00
parent e0fa223a7c
commit 533a5a4e7e
7 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.ShopPayType;
/**
* 店铺支付类型 映射层。
*
* @author zs
* @since 2025-02-26
*/
public interface ShopPayTypeMapper extends BaseMapper<ShopPayType> {
}

View File

@@ -0,0 +1,43 @@
package com.czg.service.account.service.impl;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopPayType;
import com.czg.account.service.ShopPayTypeService;
import com.czg.service.account.mapper.ShopPayTypeMapper;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 店铺支付类型 服务层实现。
*
* @author zs
* @since 2025-02-26
*/
@Service
public class ShopPayTypeServiceImpl extends ServiceImpl<ShopPayTypeMapper, ShopPayType> implements ShopPayTypeService{
private final Map<String, String> payTypeMap = Map.of(
"cash", "现金",
"bank", "银行卡",
"scanCode", "扫码支付",
"deposit", "储值卡"
);
private void addInfo(Long shopId) {
payTypeMap.forEach((k, v) -> save(new ShopPayType().setPayType(k).setPayName(v).setShopId(shopId)));
}
@Override
public List<ShopPayType> getList(Long shopId) {
List<ShopPayType> list = list(new QueryWrapper().eq(ShopPayType::getShopId, StpKit.USER.getShopId()));
if (list.isEmpty()) {
addInfo(shopId);
list = list(new QueryWrapper().eq(ShopPayType::getShopId, StpKit.USER.getShopId()));
}
return list;
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.account.mapper.ShopPayTypeMapper">
</mapper>