支付方式接口
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.czg.account.dto.ShopPayTypeDTO;
|
||||||
|
import com.czg.account.entity.ShopPayType;
|
||||||
|
import com.czg.account.service.ShopPayTypeService;
|
||||||
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式管理
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/payType")
|
||||||
|
public class ShopPayTypeController {
|
||||||
|
@Resource
|
||||||
|
private ShopPayTypeService shopPayTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式列表
|
||||||
|
*/
|
||||||
|
@SaAdminCheckPermission(value = "shopPayType:list", name = "支付方式列表")
|
||||||
|
@GetMapping
|
||||||
|
public CzgResult<List<ShopPayType>> list() {
|
||||||
|
return CzgResult.success(shopPayTypeService.getList(StpKit.USER.getShopId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式详情获取
|
||||||
|
*/
|
||||||
|
@SaAdminCheckPermission(value = "shopPayType:detail", name = "支付方式详情获取")
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public CzgResult<ShopPayType> detail(@RequestParam Integer id) {
|
||||||
|
return CzgResult.success(shopPayTypeService.getOne(new QueryWrapper().eq(ShopPayType::getId, id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式详情获取
|
||||||
|
*/
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
|
||||||
|
package com.czg.account.dto;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺支付类型 实体类。
|
||||||
|
*
|
||||||
|
* @author zs
|
||||||
|
* @since 2025-02-26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ShopPayTypeDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自增id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 是否快捷展示1是0否
|
||||||
|
*/
|
||||||
|
private Integer isShowShortcut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
private String shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package com.czg.account.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺支付类型 实体类。
|
||||||
|
*
|
||||||
|
* @author zs
|
||||||
|
* @since 2025-02-26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Table("tb_shop_pay_type")
|
||||||
|
public class ShopPayType implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自增id
|
||||||
|
*/
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付类型cash,alipay,weixin,deposit,arrears,virtual,member-account
|
||||||
|
*/
|
||||||
|
private String payType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付类型名称支付类型名称:现金,支付宝,刷卡deposit,挂单arrears,储值member-account自定义virtual
|
||||||
|
*/
|
||||||
|
private String payName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否快捷展示1是0否
|
||||||
|
*/
|
||||||
|
private Integer isShowShortcut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
@Column(onInsertValue = "now()")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图标
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.czg.account.service;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
import com.czg.account.entity.ShopPayType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺支付类型 服务层。
|
||||||
|
*
|
||||||
|
* @author zs
|
||||||
|
* @since 2025-02-26
|
||||||
|
*/
|
||||||
|
public interface ShopPayTypeService extends IService<ShopPayType> {
|
||||||
|
|
||||||
|
List<ShopPayType> getList(Long shopId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
Reference in New Issue
Block a user