feat:钱包规则代码生成

This commit is contained in:
dzc committed 2025-03-26 11:26:59 +08:00
1 parent 656dd8f376
commit 31760af911
13 files changed
+476 -7

No files matched your search

+34 -4
View File
@@ -87,13 +87,43 @@ CREATE TABLE wallet_manage
CREATE INDEX idx_dept_id ON wallet_manage (user_id);
-- ----------------------------
-- Table structure for wallet_rule_dept
-- Table structure for wallet_rule_price_config
-- ----------------------------
DROP TABLE IF EXISTS wallet_rule_price_config;
CREATE TABLE wallet_rule_price_config
(
id bigint NOT NULL COMMENT '主键',
rule_price_type varchar(64) NOT NULL COMMENT '规则类型',
base_price bigint NOT NULL COMMENT '基础金额',
multiple bigint NOT NULL COMMENT '金额的倍数必须大于1',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '商家商品价格配置表';
-- ----------------------------
-- Table structure for wallet_rule_config
-- Table structure for wallet_rule_mch_config
-- ----------------------------
DROP TABLE IF EXISTS wallet_rule_mch_config;
CREATE TABLE wallet_rule_mch_config
(
id bigint NOT NULL COMMENT '主键',
source_mch_id bigint NOT NULL COMMENT '源商户id',
traget_mch_id bigint NOT NULL COMMENT '目标商户id',
rule_price_config_id bigint NOT NULL COMMENT '规则配置id',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID'
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '商户规格配置表';
-- ----------------------------
-- Table structure for wallet_type
-- ----------------------------
@@ -1,6 +1,5 @@
package com.bsd.pjcloud.common.core.constant.enums;
import lombok.Data;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -8,8 +7,8 @@ import lombok.RequiredArgsConstructor;
@Getter
public enum MerchantTypeEnum {
CANTEEN("1", "食堂"),
SUPERMARKET("2", "超市"),
SELF_SUPERMARKET("3", "自营超市"),
SELF_SUPERMARKET("2", "自营超市"),
SUPERMARKET("3", "合作超市"),
;
/**
@@ -0,0 +1,24 @@
package com.bsd.pjcloud.wallet.api.constant;
import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
@Getter
@AllArgsConstructor
public enum WalletRulePriceTypeEnum {
STRIDE_LIMIT("10", "跨单位额外支付"),
EVERY_LIMIT("20", "每餐额度额外支付"),
;
private final String code;
private final String desc;
public static WalletRulePriceTypeEnum valueOfByCode(String code) {
if (ObjectUtil.isEmpty(code)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(code, v.getCode())).findFirst().get();
}
}
@@ -0,0 +1,90 @@
package com.bsd.pjcloud.wallet.api.entity.rule;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
* 商户规格配置表
*
* @author pjcloud
* @date 2025-03-26 11:14:39
*/
@Data
@TenantTable
@TableName("wallet_rule_mch_config")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "商户规格配置表")
public class WalletRuleMchConfigEntity extends Model<WalletRuleMchConfigEntity> {
/**
* 主键
*/
@Schema(description="主键")
private Long id;
/**
* 源商户id
*/
@Schema(description="源商户id")
private Long sourceMchId;
/**
* 目标商户id
*/
@Schema(description="目标商户id")
private Long tragetMchId;
/**
* 规则配置id
*/
@Schema(description="规则配置id")
private Long rulePriceConfigId;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
private Long tenantId;
}
@@ -0,0 +1,86 @@
package com.bsd.pjcloud.wallet.api.entity.rule;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
@Data
@TenantTable
@TableName("wallet_rule_price_config")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "钱包规则")
public class WalletRulePriceConfigEntity extends Model<WalletRulePriceConfigEntity> {
/**
* 主键
*/
@Schema(description = "主键")
private Long id;
/**
* 规则类型
*/
@Schema(description = "规则类型")
private String rulePriceType;
/**
* 基础金额
*/
@Schema(description = "基础金额")
private Long basePrice;
/**
* 金额的倍数必须大于1
*/
@Schema(description = "金额的倍数必须大于1")
private Long multiple;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -0,0 +1,91 @@
package com.bsd.pjcloud.wallet.controller.rule;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleMchConfigEntity;
import com.bsd.pjcloud.wallet.service.WalletRuleMchConfigService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-rule-mch-config")
@Tag(description = "wallet-rule-mch-config", name = "商户规格配置表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletRuleMchConfigController {
private final WalletRuleMchConfigService walletRuleMchConfigService;
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_view')")
public R getWalletRuleMchConfigPage(@ParameterObject Page page, @ParameterObject WalletRuleMchConfigEntity walletRuleMchConfig) {
LambdaQueryWrapper<WalletRuleMchConfigEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(walletRuleMchConfigService.page(page, wrapper));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(walletRuleMchConfigService.getById(id));
}
/**
* 新增商户规格配置表
*
* @param walletRuleMchConfig 商户规格配置表
* @return R
*/
@Operation(summary = "新增商户规格配置表", description = "新增商户规格配置表")
@SysLog("新增商户规格配置表")
@PostMapping
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_add')")
public R save(@RequestBody WalletRuleMchConfigEntity walletRuleMchConfig) {
return R.ok(walletRuleMchConfigService.save(walletRuleMchConfig));
}
/**
* 修改商户规格配置表
*
* @param walletRuleMchConfig 商户规格配置表
* @return R
*/
@Operation(summary = "修改商户规格配置表", description = "修改商户规格配置表")
@SysLog("修改商户规格配置表")
@PutMapping
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_edit')")
public R updateById(@RequestBody WalletRuleMchConfigEntity walletRuleMchConfig) {
return R.ok(walletRuleMchConfigService.updateById(walletRuleMchConfig));
}
@Operation(summary = "通过id删除商户规格配置表", description = "通过id删除商户规格配置表")
@SysLog("通过id删除商户规格配置表")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_del')")
public R removeById(@RequestBody Long ids) {
return R.ok(walletRuleMchConfigService.removeBatchByIds(CollUtil.toList(ids)));
}
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_export')")
public List<WalletRuleMchConfigEntity> export(WalletRuleMchConfigEntity walletRuleMchConfig, Long[] ids) {
return walletRuleMchConfigService.list(Wrappers.lambdaQuery(walletRuleMchConfig).in(ArrayUtil.isNotEmpty(ids), WalletRuleMchConfigEntity::getId, ids));
}
}
@@ -0,0 +1,78 @@
package com.bsd.pjcloud.wallet.controller.rule;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRulePriceConfigEntity;
import com.bsd.pjcloud.wallet.service.WalletRulePriceConfigService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-rule-price-config")
@Tag(description = "wallet-rule-price-config", name = "钱包规则管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletRulePriceConfigController {
private final WalletRulePriceConfigService walletRulePriceConfigService;
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_view')")
public R getWalletRulePriceConfigPage(@ParameterObject Page page, @ParameterObject WalletRulePriceConfigEntity walletRulePriceConfig) {
LambdaQueryWrapper<WalletRulePriceConfigEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(walletRulePriceConfigService.page(page, wrapper));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/id")
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(walletRulePriceConfigService.getById(id));
}
@Operation(summary = "新增钱包规则", description = "新增钱包规则")
@SysLog("新增钱包规则")
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_add')")
public R save(@RequestBody WalletRulePriceConfigEntity walletRulePriceConfig) {
return R.ok(walletRulePriceConfigService.save(walletRulePriceConfig));
}
@Operation(summary = "修改钱包规则", description = "修改钱包规则")
@SysLog("修改钱包规则")
@PutMapping
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_edit')")
public R updateById(@RequestBody WalletRulePriceConfigEntity walletRulePriceConfig) {
return R.ok(walletRulePriceConfigService.updateById(walletRulePriceConfig));
}
@Operation(summary = "通过id删除钱包规则", description = "通过id删除钱包规则")
@SysLog("通过id删除钱包规则")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(walletRulePriceConfigService.removeBatchByIds(CollUtil.toList(ids)));
}
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_export')")
public List<WalletRulePriceConfigEntity> export(WalletRulePriceConfigEntity walletRulePriceConfig, Long[] ids) {
return walletRulePriceConfigService.list(Wrappers.lambdaQuery(walletRulePriceConfig).in(ArrayUtil.isNotEmpty(ids), WalletRulePriceConfigEntity::getId, ids));
}
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.wallet.mapper.rule;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleMchConfigEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WalletRuleMchConfigMapper extends PjcloudBaseMapper<WalletRuleMchConfigEntity> {
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.wallet.mapper.rule;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRulePriceConfigEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WalletRulePriceConfigMapper extends PjcloudBaseMapper<WalletRulePriceConfigEntity> {
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleMchConfigEntity;
public interface WalletRuleMchConfigService extends IService<WalletRuleMchConfigEntity> {
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRulePriceConfigEntity;
public interface WalletRulePriceConfigService extends IService<WalletRulePriceConfigEntity> {
}
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.wallet.service.impl.rule;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleMchConfigEntity;
import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleMchConfigMapper;
import com.bsd.pjcloud.wallet.service.WalletRuleMchConfigService;
import org.springframework.stereotype.Service;
/**
* 商户规格配置表
*
* @author pjcloud
* @date 2025-03-26 11:14:39
*/
@Service
public class WalletRuleMchConfigServiceImpl extends ServiceImpl<WalletRuleMchConfigMapper, WalletRuleMchConfigEntity> implements WalletRuleMchConfigService {
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.wallet.service.impl.rule;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRulePriceConfigEntity;
import com.bsd.pjcloud.wallet.mapper.rule.WalletRulePriceConfigMapper;
import com.bsd.pjcloud.wallet.service.WalletRulePriceConfigService;
import org.springframework.stereotype.Service;
/**
* 钱包规则
*
* @author dzc
* @date 2025-03-26 11:09:52
*/
@Service
public class WalletRulePriceConfigServiceImpl extends ServiceImpl<WalletRulePriceConfigMapper, WalletRulePriceConfigEntity> implements WalletRulePriceConfigService {
}