This commit is contained in:
zjf committed 2025-01-02 12:55:58 +08:00
commit 2529a05743
78 files changed
+1775 -642

No files matched your search

+41 -13
View File
@@ -1,5 +1,35 @@
create database `pjcloudx_wallet` default character set utf8mb4 collate utf8mb4_general_ci;
-- ----------------------------
-- Table structure for mch_manage
-- ----------------------------
DROP TABLE IF EXISTS `mch_manage`;
CREATE TABLE mch_manage
(
id bigint NOT NULL COMMENT '主键',
dept_id bigint NOT NULL COMMENT '绑定的部门id',
name varchar(64) NOT NULL COMMENT '商户名',
types varchar(64) NOT NULL COMMENT '店铺类型,逗号分隔',
logo_pic varchar(256) NOT NULL COMMENT '商户logo图片',
collection_code varchar(256) DEFAULT '' COMMENT '商户收款码,自动生成',
swiper_pic text DEFAULT NULL COMMENT '商户轮播图,逗号分隔',
phone varchar(128) DEFAULT '' COMMENT '商户手机号',
job_start_time timestamp DEFAULT NULL COMMENT '商户开始营业时间',
job_end_time timestamp DEFAULT NULL COMMENT '商户结束营业时间',
address_des varchar(256) DEFAULT NULL COMMENT '商户地址',
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',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT ='商户管理';
CREATE INDEX idx_dept_id ON mch_manage (dept_id);
-- ----------------------------
-- Table structure for wallet_manage
-- ----------------------------
@@ -9,7 +39,7 @@ CREATE TABLE wallet_manage
id bigint NOT NULL COMMENT '主键',
user_id bigint NOT NULL COMMENT '饭卡绑定的用户id',
wallet_type_id bigint NOT NULL COMMENT '饭卡类型id',
dept_id BIGINT NOT NULL COMMENT '部门id',
dept_id bigint NOT NULL COMMENT '部门id',
card_number varchar(64) COMMENT '饭卡卡号',
balance int DEFAULT 0 NOT NULL COMMENT '余额,单位分',
total_expense int DEFAULT 0 NOT NULL COMMENT '累计支出,单位分',
@@ -61,10 +91,11 @@ CREATE TABLE wallet_active
user_id bigint NOT NULL COMMENT '用户id',
wallet_id bigint NOT NULL COMMENT '钱包id',
wallet_type_id bigint NOT NULL COMMENT '饭卡类型id',
dept_id BIGINT NOT NULL COMMENT '部门id',
merchant_id BIGINT NOT NULL COMMENT '商户id',
dept_id bigint NOT NULL COMMENT '部门id',
merchant_id bigint NOT NULL COMMENT '商户id',
card_number varchar(128) NOT NULL COMMENT '用户卡号',
is_active_hardware BIT DEFAULT 0 COMMENT '饭卡是否在硬件上激活',
card_sort int NOT NULL COMMENT '饭卡顺序',
is_active_hardware char(1) DEFAULT '0' COMMENT '饭卡是否在硬件上激活',
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 '修改人',
@@ -75,8 +106,7 @@ CREATE TABLE wallet_active
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='钱包开卡';
CREATE INDEX idx_dept_id ON wallet_active (user_id);
CREATE INDEX idx_dept_id ON wallet_active (wallet_id);
CREATE INDEX idx_dept_id ON wallet_active (wallet_type_id);
CREATE INDEX idx_dept_id ON wallet_active (dept_id);
-- ----------------------------
-- Table structure for wallet_freeze
@@ -84,10 +114,10 @@ CREATE INDEX idx_dept_id ON wallet_active (wallet_type_id);
DROP TABLE IF EXISTS wallet_freeze;
CREATE TABLE wallet_freeze
(
id bigint NOT NULL COMMENT '编号',
wallet_id bigint NOT NULL COMMENT '钱包id',
user_id bigint NOT NULL COMMENT '用户id',
free_status TINYINT NOT NULL COMMENT '冻结状态',
id bigint NOT NULL COMMENT '编号',
wallet_id bigint NOT NULL COMMENT '钱包id',
user_id bigint NOT NULL COMMENT '用户id',
free_status tinytext NOT NULL COMMENT '冻结状态',
remark varchar(1024) COMMENT '备注',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
@@ -98,8 +128,6 @@ CREATE TABLE wallet_freeze
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='饭卡冻结记录表';
CREATE INDEX idx_dept_id ON wallet_freeze (wallet_id);
CREATE INDEX idx_dept_id ON wallet_freeze (user_id);
-- ----------------------------
-- Table structure for wallet_transaction
@@ -170,7 +198,7 @@ CREATE TABLE wallet_recharge_import
id bigint NOT NULL COMMENT '编号',
user_id bigint NOT NULL COMMENT '用户id',
apply_id bigint NOT NULL COMMENT '申请id',
before_price int NOT NULL COMMENT '导入前的金额',
before_price int DEFAULT NULL COMMENT '导入前的金额',
price int NOT NULL COMMENT '交易金额, 单位分',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
@@ -49,58 +49,64 @@ import java.util.stream.Collectors;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/merchantInfo" )
@Tag(description = "merchantInfo" , name = "商户管理管理" )
@RequestMapping("/merchantInfo")
@Tag(description = "merchantInfo", name = "商户管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MerchantInfoController {
private final MerchantInfoService merchantInfoService;
private final MerchantInfoService merchantInfoService;
private final RemoteDeptService remoteDeptService;
private final RemoteFileService remoteFileService;
/**
* 分页查询
* @param page 分页对象
*
* @param page 分页对象
* @param merchantInfo 商户管理
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_view')" )
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_view')")
public R getMerchantInfoPage(@ParameterObject Page page, @ParameterObject MerchantInfoEntity merchantInfo) {
LambdaQueryWrapper<MerchantInfoEntity> wrapper = Wrappers.lambdaQuery();
Page pageData = merchantInfoService.page(page, wrapper);
List<MerchantInfoEntity> records = pageData.getRecords();
List<Long> deptIds =
records.stream().map(MerchantInfoEntity::getDeptId).distinct().collect(Collectors.toList());
Map<Long, SysDept> sysDeptMap=remoteDeptService.getDeptByDeptIds(deptIds).getData();
records.forEach(record->{record.setDeptName(sysDeptMap.get(record.getDeptId())==null?"":sysDeptMap.get(record.getDeptId()).getName());});
Map<Long, SysDept> sysDeptMap = remoteDeptService.getDeptByDeptIds(deptIds).getData();
records.forEach(record -> {
record.setDeptName(sysDeptMap.get(record.getDeptId()) == null ? "" : sysDeptMap.get(record.getDeptId()).getName());
});
return R.ok(pageData);
}
/**
* 通过id查询商户管理
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_view')" )
public R getById(@PathVariable("id" ) Long id) {
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(merchantInfoService.getById(id));
}
/**
* 新增商户管理
*
* @param merchantInfo 商户管理
* @return R
*/
@Operation(summary = "新增商户管理" , description = "新增商户管理" )
@SysLog("新增商户管理" )
@Operation(summary = "新增商户管理", description = "新增商户管理")
@SysLog("新增商户管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_add')" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_add')")
public R save(@RequestBody MerchantInfoEntity merchantInfo) throws Exception {
LambdaQueryWrapper<MerchantInfoEntity> wrapper = Wrappers.lambdaQuery();
@@ -112,10 +118,10 @@ public class MerchantInfoController {
boolean isDepartmentAlreadyBound = merchantInfoService.exists(wrapper);
if (isMerchantNameExists) {
return R.failed("商户名称已存在");
return R.failed("商户名称已存在");
}
if (isDepartmentAlreadyBound) {
return R.failed("部门已被绑定");
return R.failed("部门已被绑定");
}
merchantInfoService.save(merchantInfo);
// 生成二维码
@@ -124,9 +130,9 @@ public class MerchantInfoController {
String fileName = "merchant_collect_money_code" + merchantCollectMoneyCodeDto.getId();
byte[] bytes = QRCodeImageGenerator.generateQrCodeImage(JSON.toJSONString(merchantCollectMoneyCodeDto), 1024);
// 使用字节流创建 MockMultipartFile
MultipartFile multipartFile = new MockMultipartFile("file", fileName+".png", "image/png", new ByteArrayInputStream(bytes));
MultipartFile multipartFile = new MockMultipartFile("file", fileName + ".png", "image/png", new ByteArrayInputStream(bytes));
R upload = remoteFileService.upload(multipartFile,null,null,null);
R upload = remoteFileService.upload(multipartFile, null, null, null);
Map data = (Map) upload.getData();
String url = (String) data.get("url");
MerchantInfoEntity merchantInfoEntity = new MerchantInfoEntity();
@@ -139,13 +145,14 @@ public class MerchantInfoController {
/**
* 修改商户管理
*
* @param merchantInfo 商户管理
* @return R
*/
@Operation(summary = "修改商户管理" , description = "修改商户管理" )
@SysLog("修改商户管理" )
@Operation(summary = "修改商户管理", description = "修改商户管理")
@SysLog("修改商户管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_edit')" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_edit')")
public R updateById(@RequestBody MerchantInfoEntity merchantInfo) throws Exception {
// String bucketName = properties.getBucketName();
// // 生成二维码
@@ -165,13 +172,14 @@ public class MerchantInfoController {
/**
* 通过id删除商户管理
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商户管理" , description = "通过id删除商户管理" )
@SysLog("通过id删除商户管理" )
@Operation(summary = "通过id删除商户管理", description = "通过id删除商户管理")
@SysLog("通过id删除商户管理")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_del')" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(merchantInfoService.removeBatchByIds(CollUtil.toList(ids)));
}
@@ -179,26 +187,28 @@ public class MerchantInfoController {
/**
* 导出excel 表格
*
* @param merchantInfo 查询条件
* @param ids 导出指定ID
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_export')" )
public List<MerchantInfoEntity> export(MerchantInfoEntity merchantInfo,Long[] ids) {
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_export')")
public List<MerchantInfoEntity> export(MerchantInfoEntity merchantInfo, Long[] ids) {
return merchantInfoService.list(Wrappers.lambdaQuery(merchantInfo).in(ArrayUtil.isNotEmpty(ids), MerchantInfoEntity::getId, ids));
}
/**
* 获得商户下拉框
*
* @return
*/
@GetMapping("/selectMerchantList")
@Operation(summary = "获得商户下拉框")
public R<List<MerchantInfoVO>> selectMerchantList(@RequestParam(value = "type",required = false)String type) {
List<MerchantInfoVO> list=merchantInfoService.selectMerchantList(type);
public R<List<MerchantInfoVO>> selectMerchantList(@RequestParam(value = "type", required = false) String type) {
List<MerchantInfoVO> list = merchantInfoService.selectMerchantList(type);
return R.ok(list);
}
@@ -9,7 +9,7 @@ spring:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: pjcloud-register:8848
server-addr: ${NACOS_HOST:pjcloud-register}:${NACOS_PORT:8848}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
config:
@@ -122,6 +122,8 @@ public interface CacheConstants {
/* ************************************* start 钱包相关 start ************************************* */
String WALLET_MCH = "wallet:detail:mch";
String WALLET_DETAIL = "wallet:detail:manage";
String WALLET_TYPE_DETAIL = "wallet:detail:type";
-18
View File
@@ -1,18 +0,0 @@
# 开发组IDE 编辑器标准 V2.1.0
root = true
[*.{adoc, bat, groovy, html, java, js, jsp, kt, kts, md, properties, py, rb, sh, sql, svg, txt, xml, xsd}]
charset = utf-8
[*.{groovy, java, kt, kts, xml, xsd}]
indent_style = tab
indent_size = 4
continuation_indent_size = 8
end_of_line = lf
[*.{js, html}]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
-22
View File
@@ -1,22 +0,0 @@
项目描述 ....
| 姓名 | 角色 | 时间 |
| ---- | ---- |---------|
| xxx | 开发 | 2023-01 |
| | | |
| | | |
```
项目根目录
├── xxx-api -- 业务接口(实体,DTO,utils,feign接口)
├── xxx-biz -- 业务实现[默认服务端口 : 6060]
```
@@ -1,42 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-merchant</artifactId>
<version>5.7.0</version>
</parent>
<artifactId>pjcloud-merchant-api</artifactId>
<dependencies>
<!-- 连表查询注解 -->
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-annotation</artifactId>
</dependency>
<!--core 工具类-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-core</artifactId>
</dependency>
<!--mybatis plus spring,包含了mybatis plus core-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring</artifactId>
</dependency>
<!--feign 工具类-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-feign</artifactId>
</dependency>
<!-- excel 导入导出 -->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-excel</artifactId>
</dependency>
</dependencies>
</project>
@@ -1,6 +0,0 @@
/*
@author pigx archetype
* <p>
* feign client 存放目录,注意 @EnablePigxFeignClients 的扫描范围
*/
package merchant.api.feign;
@@ -1,6 +0,0 @@
/*
* @author pigx archetype
* <p>
* 常量和枚举定义
*/
package merchant.constant;
@@ -1,6 +0,0 @@
/*
* @author pigx archetype
* <p>
* DTO 存放目录
*/
package merchant.dto;
@@ -1,6 +0,0 @@
/*
* @author pigx archetype
* <p>
* 实体 存放目录
*/
package merchant.entity;
@@ -1,134 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-merchant</artifactId>
<version>5.7.0</version>
</parent>
<artifactId>pjcloud-merchant-biz</artifactId>
<dependencies>
<!--必备: 注册中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--必备: 配置中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--必备: 操作数据源相关-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-data</artifactId>
</dependency>
<!--必备:pigx安全模块-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-security</artifactId>
</dependency>
<!--必备:xss 过滤模块-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-xss</artifactId>
</dependency>
<!--必备: sentinel 依赖-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-sentinel</artifactId>
</dependency>
<!--必备: feign 依赖-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-feign</artifactId>
</dependency>
<!--必备: 依赖api模块-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-merchant-api</artifactId>
<version>5.7.0</version>
</dependency>
<!--必备: log 依赖-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-log</artifactId>
</dependency>
<!--选配: mybatis 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<!--选配: druid 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-3-starter</artifactId>
</dependency>
<!--选配: mysql 数据库驱动 -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!--选配: swagger文档-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-swagger</artifactId>
</dependency>
<!--必备: undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<!--必备: spring boot web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--测试: spring boot test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
<id>cloud</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<loaderImplementation>CLASSIC</loaderImplementation>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>boot</id>
</profile>
</profiles>
</project>
@@ -1,24 +0,0 @@
package merchant;
import com.bsd.pjcloud.common.feign.annotation.EnablePjcloudFeignClients;
import com.bsd.pjcloud.common.security.annotation.EnablePjcloudResourceServer;
import com.bsd.pjcloud.common.swagger.annotation.EnableOpenApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author archetype auto
* <p>
* 项目启动类
*/
@EnableOpenApi("merchant")
@EnablePjcloudFeignClients
@EnableDiscoveryClient
@EnablePjcloudResourceServer
@SpringBootApplication
public class MerchantApp {
public static void main(String[] args) {
SpringApplication.run(MerchantApp.class, args);
}
}
@@ -1,124 +0,0 @@
package merchant.controller;
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 merchant.entity.MchManageEntity;
import merchant.service.MchManageService;
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;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/mchManage")
@Tag(description = "mchManage", name = "商户管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MchManageController {
private final MchManageService mchManageService;
/**
* 分页查询
*
* @param page 分页对象
* @param mchManage 商户管理
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('mch_mchManage_view')")
public R getMchManagePage(@ParameterObject Page page, @ParameterObject MchManageEntity mchManage) {
LambdaQueryWrapper<MchManageEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(mchManageService.page(page, wrapper));
}
/**
* 通过id查询商户管理
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('mch_mchManage_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(mchManageService.getById(id));
}
/**
* 新增商户管理
*
* @param mchManage 商户管理
* @return R
*/
@Operation(summary = "新增商户管理", description = "新增商户管理")
@SysLog("新增商户管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_add')")
public R save(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.save(mchManage));
}
/**
* 修改商户管理
*
* @param mchManage 商户管理
* @return R
*/
@Operation(summary = "修改商户管理", description = "修改商户管理")
@SysLog("修改商户管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_edit')")
public R updateById(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.updateById(mchManage));
}
/**
* 通过id删除商户管理
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商户管理", description = "通过id删除商户管理")
@SysLog("通过id删除商户管理")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(mchManageService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
* @param mchManage 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('mch_mchManage_export')")
public List<MchManageEntity> export(MchManageEntity mchManage, Long[] ids) {
return mchManageService.list(Wrappers.lambdaQuery(mchManage).in(ArrayUtil.isNotEmpty(ids), MchManageEntity::getId, ids));
}
}
@@ -1,4 +0,0 @@
/*
* @author pigx archetype
*/
package merchant.controller;
@@ -1,10 +0,0 @@
package merchant.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import merchant.entity.MchManageEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
}
@@ -1,6 +0,0 @@
/*
* @author pigx archetype
* <p>
* Mybatis Mapper 存放目录
*/
package merchant.mapper;
@@ -1,8 +0,0 @@
package merchant.service;
import com.baomidou.mybatisplus.extension.service.IService;
import merchant.entity.MchManageEntity;
public interface MchManageService extends IService<MchManageEntity> {
}
@@ -1,16 +0,0 @@
package merchant.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import merchant.entity.MchManageEntity;
import merchant.mapper.MchManageMapper;
import merchant.service.MchManageService;
import org.springframework.stereotype.Service;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
*/
@Service
public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManageEntity> implements MchManageService {
}
@@ -1,4 +0,0 @@
/*
* @author pigx archetype
*/
package merchant.service;
@@ -1,18 +0,0 @@
server:
port: 6060
spring:
application:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pjcloud-register}:${NACOS_PORT:8848}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
config:
import:
- optional:nacos:application-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml
@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
小技巧: 在根pom里面设置统一存放路径,统一管理方便维护
<properties>
<log-path>/Users/lengleng</log-path>
</properties>
1. 其他模块加日志输出,直接copy本文件放在resources 目录即可
2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
-->
<configuration debug="false" scan="false">
<property name="log.path" value="logs/${project.artifactId}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<logger name="org.activiti.engine.impl.db" level="DEBUG">
<appender-ref ref="debug"/>
</logger>
<!--nacos 心跳 INFO 屏蔽-->
<logger name="com.alibaba.nacos" level="OFF">
<appender-ref ref="error"/>
</logger>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
</root>
</configuration>
-21
View File
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bsd</groupId>
<artifactId>pjcloud</artifactId>
<version>5.7.0</version>
</parent>
<artifactId>pjcloud-merchant</artifactId>
<packaging>pom</packaging>
<!--项目子模块-->
<modules>
<module>pjcloud-merchant-api</module>
<module>pjcloud-merchant-biz</module>
</modules>
</project>
@@ -4,12 +4,23 @@ server:
basedir: logs
error:
include-message: always
#db:
# num: 1
# user: ${MYSQL_USER:root}
# password: ${MYSQL_PWD:root}
# url:
# 0: jdbc:mysql://${MYSQL_HOST:pjcloud-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pjcloudx_config}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
# pool:
# config:
# connectionTimeout: 30000
# validationTimeout: 10000
db:
num: 1
user: ${MYSQL_USER:root}
password: ${MYSQL_PWD:root}
user: root
password: root
url:
0: jdbc:mysql://${MYSQL_HOST:pjcloud-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pjcloudx_config}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
0: jdbc:mysql://127.0.0.1:3306/pjcloudx_config?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
pool:
config:
connectionTimeout: 30000
@@ -57,6 +57,17 @@ public interface RemoteUserService {
@GetMapping("/user/get-by-user-id")
R<UserInfo> getByUserId(@RequestParam("userId") Long userId);
/**
* 通过姓名和手机号查询用户、角色信息
*
* @param name
* @param mobile
* @return
*/
@NoToken
@GetMapping("/user/get-name-and-mobile")
R<UserInfo> getUserByNameAndMobile(@RequestParam("name") String name, @RequestParam("mobile") String mobile);
/**
* 根据用户ID获取用户
*
@@ -98,7 +98,7 @@ public class DataUtil {
public <T extends BaseUserInterface> T convertUser(T v, SysUser user) {
if (ObjectUtil.isEmpty(user)) return v;
v.setUsername(user.getUsername());
v.setUsername(user.getName());
v.setUserMobile(user.getPhone());
v.setUserAvatar(user.getAvatar());
return v;
@@ -78,6 +78,16 @@ public class SysUserController {
return R.ok(userService.findUserInfo(user));
}
@Inner
@GetMapping("/get-name-and-mobile")
public R<UserInfo> getUserByNameAndMobile(@RequestParam("name") String name, @RequestParam("mobile") String mobile) {
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getName, name).eq(SysUser::getPhone, mobile));
if (user == null) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, name, mobile));
}
return R.ok(userService.findUserInfo(user));
}
/**
* 获取指定用户全部信息
*
@@ -47,7 +47,7 @@ public class SysUserFaceController {
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
public R getSysUserFacePage(@ParameterObject Page page, @ParameterObject SysUserFaceEntity sysUserFace) {
LambdaQueryWrapper<SysUserFaceEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(sysUserFaceService.page(page, wrapper));
@@ -55,7 +55,7 @@ public class SysUserFaceController {
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
public R getSysUserFacePageJoin(@ParameterObject Page page, @ParameterObject SysUserFaceDto dto) {
return R.ok(sysUserFaceService.pageJoin(page, dto));
}
@@ -69,7 +69,7 @@ public class SysUserFaceController {
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysUserFaceService.getById(id));
}
@@ -83,7 +83,7 @@ public class SysUserFaceController {
@Operation(summary = "新增人脸样本表", description = "新增人脸样本表")
@SysLog("新增人脸样本表")
@PostMapping
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_add')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_add')")
public R save(@RequestBody SysUserFaceEntity sysUserFace) {
return R.ok(sysUserFaceService.create(sysUserFace));
}
@@ -97,7 +97,7 @@ public class SysUserFaceController {
@Operation(summary = "修改人脸样本表", description = "修改人脸样本表")
@SysLog("修改人脸样本表")
@PutMapping
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_edit')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_edit')")
public R updateById(@RequestBody SysUserFaceEntity sysUserFace) {
sysUserFaceService.edit(sysUserFace);
return R.ok(true);
@@ -112,7 +112,7 @@ public class SysUserFaceController {
@Operation(summary = "通过id删除人脸样本表", description = "通过id删除人脸样本表")
@SysLog("通过id删除人脸样本表")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_del')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_del')")
public R removeById(@RequestBody Long[] ids) {
sysUserFaceService.delByIds(CollUtil.toList(ids));
return R.ok(true);
@@ -128,7 +128,7 @@ public class SysUserFaceController {
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('userFace_sysUserFace_export')")
// @PreAuthorize("@pms.hasPermission('userFace_sysUserFace_export')")
public List<SysUserFaceEntity> export(SysUserFaceEntity sysUserFace, Long[] ids) {
return sysUserFaceService.list(Wrappers.lambdaQuery(sysUserFace).in(ArrayUtil.isNotEmpty(ids), SysUserFaceEntity::getId, ids));
}
@@ -1,11 +1,13 @@
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 WalletBizEnum {
UPDATE("1", "更新余额"),
BATCH("2", "批量更新余额"),
@@ -15,11 +17,6 @@ public enum WalletBizEnum {
private final String desc;
WalletBizEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public static WalletBizEnum descOf(String description) {
return Arrays.stream(WalletBizEnum.values())
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
@@ -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 WalletBizRechargeEnum {
ADD("1", "添加"),
REDUCTION("2", "减少"),
;
private final String code;
private final String desc;
public static WalletBizRechargeEnum descOf(String description) {
return Arrays.stream(WalletBizRechargeEnum.values())
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
.findFirst().get();
}
}
@@ -1,11 +1,13 @@
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 WalletTypeCodeEnum {
SUPERMARKET("1", "超市"),
CANTEEN("2", "食堂"),
@@ -14,11 +16,6 @@ public enum WalletTypeCodeEnum {
private final String desc;
WalletTypeCodeEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public static WalletTypeCodeEnum descOf(String description) {
return Arrays.stream(WalletTypeCodeEnum.values())
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
@@ -1,11 +1,13 @@
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 WalletTypeEnum {
EAT("1", "饭卡钱包"),
@@ -16,11 +18,6 @@ public enum WalletTypeEnum {
private final String desc;
WalletTypeEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public static WalletTypeEnum descOf(String description) {
return Arrays.stream(WalletTypeEnum.values())
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
@@ -0,0 +1,19 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class MchManageDto extends MchManageEntity {
private List<Long> deptIds;
}
@@ -0,0 +1,25 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class WalletActiveDto extends WalletActiveEntity {
@Schema(description = "数量")
@Max(200)
@Min(1)
@NotNull(message = "数量不能为空")
private Long count;
@NotNull(message = "商户id不能为空")
private Long merchantId;
@NotNull(message = "钱包类型id不能为空")
private Long walletTypeId;
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import lombok.Data;
@Data
public class WalletFreezeEntityDto extends WalletFreezeEntity {
}
@@ -1,9 +1,16 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeApplyEntity;
import lombok.Data;
import java.util.List;
@Data
public class WalletRechargeApplyDto extends WalletRechargeApplyEntity {
private List<Long> userIds;
private List<Long> walletTypeIds;
}
@@ -0,0 +1,50 @@
package com.bsd.pjcloud.wallet.api.dto.excel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.bsd.pjcloud.common.excel.annotation.ExcelLine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false)
@HeadRowHeight(20)
@ContentRowHeight(10)
@ExcelIgnoreUnannotated
public class WalletRechargeExcelDto {
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
private Long lineNum;
@ColumnWidth(100)
@ExcelProperty("用户名")
private String username;
@ColumnWidth(100)
@ExcelProperty("用户手机号")
private String userMobile;
@ColumnWidth(100)
@ExcelProperty("操作金额")
private String price;
// 操作余额
private Integer priceNumber;
// 用户id
private Long userId;
}
@@ -1,4 +1,4 @@
package merchant.entity;
package com.bsd.pjcloud.wallet.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -11,8 +11,8 @@ import java.time.LocalDateTime;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
* @author dzc
* @date 2025-01-02 11:09:26
*/
@Data
@TenantTable
@@ -0,0 +1,121 @@
package com.bsd.pjcloud.wallet.api.entity;
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 dzc
* @date 2024-12-31 18:53:31
*/
@Data
@TenantTable
@TableName("wallet_active")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "钱包开卡")
public class WalletActiveEntity extends Model<WalletActiveEntity> {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="主键")
private Long id;
/**
* 用户id
*/
@Schema(description="用户id")
private Long userId;
/**
* 钱包id
*/
@Schema(description="钱包id")
private Long walletId;
/**
* 饭卡类型id
*/
@Schema(description="饭卡类型id")
private Long walletTypeId;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 商户id
*/
@Schema(description="商户id")
private Long merchantId;
/**
* 用户卡号
*/
@Schema(description="用户卡号")
private String cardNumber;
/**
* 饭卡顺序
*/
@Schema(description="饭卡顺序")
private Integer cardSort;
/**
* 饭卡是否在硬件上激活
*/
@Schema(description="饭卡是否在硬件上激活")
private String isActiveHardware;
/**
* 创建人
*/
@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,97 @@
package com.bsd.pjcloud.wallet.api.entity;
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 dzc
* @date 2024-12-31 18:54:43
*/
@Data
@TenantTable
@TableName("wallet_freeze")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "饭卡冻结记录表")
public class WalletFreezeEntity extends Model<WalletFreezeEntity> {
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
private Long id;
/**
* 钱包id
*/
@Schema(description="钱包id")
private Long walletId;
/**
* 用户id
*/
@Schema(description="用户id")
private Long userId;
/**
* 冻结状态
*/
@Schema(description="冻结状态")
private String freeStatus;
/**
* 备注
*/
@Schema(description="备注")
private String remark;
/**
* 创建人
*/
@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;
}
@@ -1,12 +1,16 @@
package com.bsd.pjcloud.wallet.api.entity;
import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
@@ -21,7 +25,7 @@ import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Schema(description = "充值/扣款申请")
public class WalletRechargeApplyEntity extends Model<WalletRechargeApplyEntity> {
/**
* 主键ID
*/
@@ -57,7 +61,8 @@ public class WalletRechargeApplyEntity extends Model<WalletRechargeApplyEntity>
* 导入时间(手动选择)
*/
@Schema(description = "导入时间(手动选择)")
private LocalDateTime importTime;
@JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
private LocalDate importTime;
/**
* 备注
@@ -3,8 +3,7 @@ package com.bsd.pjcloud.wallet.api.entity;
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 lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
@@ -15,6 +14,9 @@ import java.time.LocalDateTime;
* @author dzc
* @date 2024-12-31 14:24:39
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@TenantTable
@TableName("wallet_recharge_import")
@@ -0,0 +1,33 @@
package com.bsd.pjcloud.wallet.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(contextId = "remoteMchService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteMchService {
@NoToken
@GetMapping("/get-by-id")
R<MchManageDto> getById(@RequestParam Long id);
@NoToken
@GetMapping("/get-by-ids")
R<List<MchManageDto>> getByIds(@RequestParam List<Long> ids);
@NoToken
@GetMapping("/get-by-dept-id")
R<MchManageDto> getByDeptId(@RequestParam Long deptId);
@NoToken
@GetMapping("/get-first-mch")
R<MchManageDto> getFirstMch(@RequestParam List<Long> deptIds);
}
@@ -7,7 +7,6 @@ import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -0,0 +1,12 @@
package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import lombok.Data;
@Data
public class MchManageVo extends MchManageEntity implements BaseDeptInterface {
private String deptName;
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import lombok.Data;
@Data
public class WalletActiveVo extends WalletActiveEntity {
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import lombok.Data;
@Data
public class WalletFreezeVo extends WalletFreezeEntity {
}
@@ -1,9 +1,29 @@
package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeApplyEntity;
import lombok.Data;
@Data
public class WalletRechargeApplyVo extends WalletRechargeApplyEntity {
public class WalletRechargeApplyVo extends WalletRechargeApplyEntity implements BaseUserInterface, BaseDeptInterface {
private String walletTypeName;
private String uniqueCode;
/**
* 用户相关
*/
private String username;
private String userMobile;
private String userAvatar;
/**
* 部门相关
*/
private String deptName;
}
@@ -0,0 +1,23 @@
package com.bsd.pjcloud.wallet.api.vo.code;
import lombok.Data;
@Data
public class MchCollectionCodeVo {
/**
* 商户Id
*/
private Long id;
/**
* 商户名
*/
private String name;
/**
* 商户类型
*/
private String type;
public String getFileName() {
return "merchant_collect_money_code_" + id;
}
}
@@ -1 +1,2 @@
com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
com.bsd.pjcloud.wallet.api.feign.RemoteMchService
@@ -94,6 +94,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-idempotent</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
@@ -0,0 +1,183 @@
package com.bsd.pjcloud.wallet.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
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.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.service.MchManageService;
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;
/**
* 商户管理
*
* @author dzc
* @date 2025-01-02 11:09:26
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/mch-manage")
@Tag(description = "mch-manage", name = "商户管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MchManageController {
private final MchManageService mchManageService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-by-id")
public R<MchManageDto> getById(@RequestParam Long id) {
MchManageEntity mchManage = mchManageService.getById(id);
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(BeanUtils.toBean(mchManage, MchManageDto.class));
}
@Inner
@GetMapping("/get-by-ids")
public R<List<MchManageDto>> getByIds(@RequestParam List<Long> ids) {
Page<MchManageVo> page = mchManageService.pageJoin(new Page<>(), MchManageDto.builder().deptIds(ids).build());
if (ObjectUtil.isAllNotEmpty(page, page.getRecords())) return R.failed("商户不存在");
return R.ok(BeanUtils.toBean(page.getRecords(), MchManageDto.class));
}
@Inner
@GetMapping("/get-by-dept-id")
public R<MchManageDto> getByDeptId(@RequestParam Long deptId) {
MchManageDto mchManage = mchManageService.getByDeptId(deptId);
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(mchManage);
}
@Inner
@GetMapping("/get-first-mch")
public R<MchManageDto> getFirstMch(@RequestParam List<Long> deptIds) {
MchManageDto mchManage = mchManageService.getFirstMch(deptIds);
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(mchManage);
}
/* ************************************* end 远程调用 end ************************************* */
/**
* 分页查询
*
* @param page 分页对象
* @param mchManage 商户管理
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
public R getMchManagePage(@ParameterObject Page page, @ParameterObject MchManageEntity mchManage) {
LambdaQueryWrapper<MchManageEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(mchManageService.page(page, wrapper));
}
/**
* 分页复杂查询
*
* @param page 分页对象
* @param dto 商户管理
* @return
*/
@Operation(summary = "分页复杂查询", description = "分页查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
public R getMchManagePageJoin(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
return R.ok(mchManageService.pageJoin(page, dto));
}
/**
* 通过id查询商户管理
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
public R getDetail(@PathVariable("id") Long id) {
return R.ok(mchManageService.getById(id));
}
/**
* 新增商户管理
*
* @param mchManage 商户管理
* @return R
*/
@Operation(summary = "新增商户管理", description = "新增商户管理")
@SysLog("新增商户管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_mchManage_add')")
public R save(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.create(mchManage));
}
/**
* 修改商户管理
*
* @param mchManage 商户管理
* @return R
*/
@Operation(summary = "修改商户管理", description = "修改商户管理")
@SysLog("修改商户管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('wallet_mchManage_edit')")
public R updateById(@RequestBody MchManageEntity mchManage) {
mchManageService.edit(mchManage);
return R.ok(true);
}
/**
* 通过id删除商户管理
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商户管理", description = "通过id删除商户管理")
@SysLog("通过id删除商户管理")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('wallet_mchManage_del')")
public R removeById(@RequestBody Long[] ids) {
mchManageService.delByIds(CollUtil.toList(ids));
return R.ok(true);
}
/**
* 导出excel 表格
*
* @param mchManage 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_export')")
public List<MchManageEntity> export(MchManageEntity mchManage, Long[] ids) {
return mchManageService.list(Wrappers.lambdaQuery(mchManage).in(ArrayUtil.isNotEmpty(ids), MchManageEntity::getId, ids));
}
}
@@ -0,0 +1,138 @@
package com.bsd.pjcloud.wallet.controller;
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.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import com.bsd.pjcloud.wallet.service.WalletActiveService;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 钱包开卡
*
* @author dzc
* @date 2024-12-31 18:53:31
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-active")
@Tag(description = "wallet-active", name = "钱包开卡管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
@Validated
public class WalletActiveController {
private final WalletActiveService walletActiveService;
@PostMapping("/fast-create-card")
@Operation(summary = "一键开卡")
@Idempotent(info = "正在开卡中,请勿重复提交")
public R<Boolean> fastCreateCard(WalletActiveDto dto) {
walletActiveService.fastCreateCard(dto);
return R.ok(true);
}
/**
* 分页查询
*
* @param page 分页对象
* @param walletActive 钱包开卡
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletActive_view')")
public R getWalletActivePage(@ParameterObject Page page, @ParameterObject WalletActiveEntity walletActive) {
LambdaQueryWrapper<WalletActiveEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(walletActiveService.page(page, wrapper));
}
/**
* 通过id查询钱包开卡
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_walletActive_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(walletActiveService.getById(id));
}
/**
* 新增钱包开卡
*
* @param walletActive 钱包开卡
* @return R
*/
@Operation(summary = "新增钱包开卡", description = "新增钱包开卡")
@SysLog("新增钱包开卡")
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_walletActive_add')")
public R save(@RequestBody WalletActiveEntity walletActive) {
return R.ok(walletActiveService.save(walletActive));
}
/**
* 修改钱包开卡
*
* @param walletActive 钱包开卡
* @return R
*/
@Operation(summary = "修改钱包开卡", description = "修改钱包开卡")
@SysLog("修改钱包开卡")
@PutMapping
@PreAuthorize("@pms.hasPermission('wallet_walletActive_edit')")
public R updateById(@RequestBody WalletActiveEntity walletActive) {
return R.ok(walletActiveService.updateById(walletActive));
}
/**
* 通过id删除钱包开卡
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除钱包开卡", description = "通过id删除钱包开卡")
@SysLog("通过id删除钱包开卡")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('wallet_walletActive_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(walletActiveService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
* @param walletActive 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletActive_export')")
public List<WalletActiveEntity> export(WalletActiveEntity walletActive, Long[] ids) {
return walletActiveService.list(Wrappers.lambdaQuery(walletActive).in(ArrayUtil.isNotEmpty(ids), WalletActiveEntity::getId, ids));
}
}
@@ -0,0 +1,118 @@
package com.bsd.pjcloud.wallet.controller;
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.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.service.WalletFreezeService;
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;
/**
* 饭卡冻结记录表
*
* @author dzc
* @date 2024-12-31 18:54:43
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-freeze" )
@Tag(description = "wallet-freeze" , name = "饭卡冻结记录表管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletFreezeController {
private final WalletFreezeService walletFreezeService;
/**
* 分页查询
* @param page 分页对象
* @param walletFreeze 饭卡冻结记录表
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')" )
public R getWalletFreezePage(@ParameterObject Page page, @ParameterObject WalletFreezeEntity walletFreeze) {
LambdaQueryWrapper<WalletFreezeEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(walletFreezeService.page(page, wrapper));
}
/**
* 通过id查询饭卡冻结记录表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(walletFreezeService.getById(id));
}
/**
* 新增饭卡冻结记录表
* @param walletFreeze 饭卡冻结记录表
* @return R
*/
@Operation(summary = "新增饭卡冻结记录表" , description = "新增饭卡冻结记录表" )
@SysLog("新增饭卡冻结记录表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_add')" )
public R save(@RequestBody WalletFreezeEntity walletFreeze) {
return R.ok(walletFreezeService.save(walletFreeze));
}
/**
* 修改饭卡冻结记录表
* @param walletFreeze 饭卡冻结记录表
* @return R
*/
@Operation(summary = "修改饭卡冻结记录表" , description = "修改饭卡冻结记录表" )
@SysLog("修改饭卡冻结记录表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_edit')" )
public R updateById(@RequestBody WalletFreezeEntity walletFreeze) {
return R.ok(walletFreezeService.updateById(walletFreeze));
}
/**
* 通过id删除饭卡冻结记录表
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除饭卡冻结记录表" , description = "通过id删除饭卡冻结记录表" )
@SysLog("通过id删除饭卡冻结记录表" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(walletFreezeService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param walletFreeze 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_export')" )
public List<WalletFreezeEntity> export(WalletFreezeEntity walletFreeze,Long[] ids) {
return walletFreezeService.list(Wrappers.lambdaQuery(walletFreeze).in(ArrayUtil.isNotEmpty(ids), WalletFreezeEntity::getId, ids));
}
}
@@ -6,7 +6,10 @@ 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.excel.annotation.RequestExcel;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.dto.WalletRechargeApplyDto;
import com.bsd.pjcloud.wallet.api.dto.excel.WalletRechargeExcelDto;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeApplyEntity;
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -17,8 +20,8 @@ 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.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
@@ -36,6 +39,35 @@ public class WalletRechargeApplyController {
private final WalletRechargeApplyService walletRechargeApplyService;
/**
* 提交申请
*
* @return
*/
@Operation(summary = "提交申请", description = "提交申请")
@SysLog("提交申请")
@PostMapping("/apply")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_apply')")
public R apply(@RequestBody WalletRechargeApplyDto dto) {
walletRechargeApplyService.apply(dto);
return R.ok(true);
}
/**
* 取消申请
*
* @return
*/
@Operation(summary = "取消申请", description = "取消申请")
@SysLog("取消申请")
@PostMapping("/cancel-apply")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_cancel_apply')")
public R cancelApply(@RequestBody WalletRechargeApplyDto dto) {
walletRechargeApplyService.cancelApply(dto);
return R.ok(true);
}
/**
* 分页查询
*
@@ -51,6 +83,20 @@ public class WalletRechargeApplyController {
return R.ok(walletRechargeApplyService.page(page, wrapper));
}
/**
* 分页查询
*
* @param page 分页对象
* @param dto 充值/扣款申请
* @return
*/
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_view')")
public R getWalletRechargeApplyPage(@ParameterObject Page page, @ParameterObject WalletRechargeApplyDto dto) {
return R.ok(walletRechargeApplyService.pageJoin(page, dto));
}
/**
* 通过id查询充值/扣款申请
@@ -68,15 +114,16 @@ public class WalletRechargeApplyController {
/**
* 新增充值/扣款申请
*
* @param walletRechargeApply 充值/扣款申请
* @param dto 充值/扣款申请
* @return R
*/
@Operation(summary = "新增充值/扣款申请", description = "新增充值/扣款申请")
@SysLog("新增充值/扣款申请")
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_add')")
public R save(@RequestBody WalletRechargeApplyEntity walletRechargeApply) {
return R.ok(walletRechargeApplyService.save(walletRechargeApply));
public R save(@RequestBody WalletRechargeApplyDto dto) {
walletRechargeApplyService.create(dto);
return R.ok();
}
/**
@@ -108,6 +155,8 @@ public class WalletRechargeApplyController {
}
/* ************************************* start excel start ************************************* */
/**
* 导出excel 表格
*
@@ -121,4 +170,17 @@ public class WalletRechargeApplyController {
public List<WalletRechargeApplyEntity> export(WalletRechargeApplyEntity walletRechargeApply, Long[] ids) {
return walletRechargeApplyService.list(Wrappers.lambdaQuery(walletRechargeApply).in(ArrayUtil.isNotEmpty(ids), WalletRechargeApplyEntity::getId, ids));
}
/**
* 读取excel内容
* @param excelVOList
* @param bindingResult
* @return
*/
@PostMapping("/read-excel")
public R readExcel(@RequestExcel List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult) {
return walletRechargeApplyService.readExcel(excelVOList, bindingResult);
}
/* ************************************* start excel start ************************************* */
}
@@ -66,28 +66,30 @@ public class WalletTypeController {
/**
* 新增钱包类型
* @param walletType 钱包类型
* @param dto 钱包类型
* @return R
*/
@Operation(summary = "新增钱包类型" , description = "新增钱包类型" )
@SysLog("新增钱包类型" )
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_walletType_add')" )
public R save(@RequestBody WalletTypeEntity walletType) {
return R.ok(walletTypeService.save(walletType));
public R save(@RequestBody WalletTypeEntity dto) {
walletTypeService.create(dto);
return R.ok(true);
}
/**
* 修改钱包类型
* @param walletType 钱包类型
* @param dto 钱包类型
* @return R
*/
@Operation(summary = "修改钱包类型" , description = "修改钱包类型" )
@SysLog("修改钱包类型" )
@PutMapping
@PreAuthorize("@pms.hasPermission('wallet_walletType_edit')" )
public R updateById(@RequestBody WalletTypeEntity walletType) {
return R.ok(walletTypeService.updateById(walletType));
public R updateById(@RequestBody WalletTypeEntity dto) {
walletTypeService.edit(dto);
return R.ok(true);
}
/**
@@ -0,0 +1,21 @@
package com.bsd.pjcloud.wallet.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
default Page<MchManageVo> pageJoin(Page page, MchManageDto dto) {
MPJLambdaQueryWrapper<MchManageEntity> wrapper = new MPJLambdaQueryWrapper<MchManageEntity>()
.selectAll(MchManageEntity.class)
.likeIfExists(MchManageEntity::getName, dto.getName());
return selectJoinPage(page, MchManageVo.class, wrapper);
}
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.wallet.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WalletActiveMapper extends PjcloudBaseMapper<WalletActiveEntity> {
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.wallet.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WalletFreezeMapper extends PjcloudBaseMapper<WalletFreezeEntity> {
}
@@ -1,11 +1,29 @@
package com.bsd.pjcloud.wallet.mapper;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.WalletRechargeApplyDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeApplyEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletRechargeApplyVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WalletRechargeApplyMapper extends PjcloudBaseMapper<WalletRechargeApplyEntity> {
default Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto) {
MPJLambdaWrapper<WalletRechargeApplyEntity> wrapper = new MPJLambdaWrapper<WalletRechargeApplyEntity>()
.selectAll(WalletRechargeApplyEntity.class)
.selectAs(WalletTypeEntity::getName, WalletRechargeApplyVo::getWalletTypeName)
.selectAs(WalletTypeEntity::getUniqueCode, WalletRechargeApplyVo::getUniqueCode)
.leftJoin(WalletTypeEntity.class, WalletTypeEntity::getId, WalletRechargeApplyEntity::getWalletTypeId)
.eqIfExists(WalletRechargeApplyEntity::getWalletTypeId, dto.getWalletTypeId())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getWalletTypeIds()), WalletManageEntity::getWalletTypeId, dto.getWalletTypeIds());
return selectJoinPage(page, WalletRechargeApplyVo.class, wrapper);
}
}
@@ -0,0 +1,25 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import java.util.ArrayList;
import java.util.List;
public interface MchManageService extends IService<MchManageEntity> {
Long create(MchManageEntity dto);
void edit(MchManageEntity dto);
void delByIds(ArrayList<Long> list);
Page<MchManageVo> pageJoin(Page page, MchManageDto dto);
MchManageDto getByDeptId(Long deptId);
MchManageDto getFirstMch(List<Long> deptIds);
}
@@ -0,0 +1,14 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
public interface WalletActiveService extends IService<WalletActiveEntity> {
/**
* 一键开卡
*
* @param dto
*/
void fastCreateCard(WalletActiveDto dto);
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
public interface WalletFreezeService extends IService<WalletFreezeEntity> {
}
@@ -1,8 +1,40 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.wallet.api.dto.WalletRechargeApplyDto;
import com.bsd.pjcloud.wallet.api.dto.excel.WalletRechargeExcelDto;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeApplyEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletRechargeApplyVo;
import org.springframework.validation.BindingResult;
import java.util.List;
public interface WalletRechargeApplyService extends IService<WalletRechargeApplyEntity> {
void create(WalletRechargeApplyEntity dto);
Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto);
/**
* 提交申请
*
* @param dto
*/
void apply(WalletRechargeApplyDto dto);
/**
* 取消申请
*
* @param dto
*/
void cancelApply(WalletRechargeApplyDto dto);
/**
* 读取excel内容
* @param excelVOList
* @param bindingResult
*/
R readExcel(List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult);
}
@@ -10,4 +10,7 @@ public interface WalletTypeService extends IService<WalletTypeEntity> {
WalletTypeEntity getByUniqueCode(WalletTypeCodeEnum walletTypeCodeEnum);
void create(WalletTypeEntity dto);
void edit(WalletTypeEntity dto);
}
@@ -0,0 +1,175 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteFileService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.exception.CheckedException;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.code.MchCollectionCodeVo;
import com.bsd.pjcloud.wallet.mapper.MchManageMapper;
import com.bsd.pjcloud.wallet.service.MchManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 商户管理
*
* @author dzc
* @date 2025-01-02 11:09:26
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManageEntity> implements MchManageService {
private final String TAG = "商户管理";
private final RemoteDeptService remoteDeptService;
private final RemoteFileService remoteFileService;
private final StringRedisTemplate redisTemplate;
@Override
@Cacheable(value = CacheConstants.WALLET_DETAIL, key = "#id", condition = "#id != null", unless = "#result == null")
public MchManageEntity getById(Serializable id) {
return super.getById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long create(MchManageEntity dto) {
if (existName(dto.getName(), null)) {
throw new CheckedException("商户名不能重复");
}
if (existDeptId(dto.getDeptId(), null)) {
throw new CheckedException("改部门已经绑定过商户");
}
baseMapper.insert(dto);
try {
MchCollectionCodeVo mchCollectionCode = new MchCollectionCodeVo();
BeanUtils.toBean(dto, MchCollectionCodeVo.class);
byte[] bytes = QRCodeImageGenerator.generateQrCodeImage(JSON.toJSONString(mchCollectionCode), 1024);
MultipartFile multipartFile = new MockMultipartFile("file", mchCollectionCode.getFileName() + ".png", "image/png", new ByteArrayInputStream(bytes));
R upload = remoteFileService.upload(multipartFile, null, null, null);
Map data = (Map) upload.getData();
String url = (String) data.get("url");
MchManageEntity merchantInfoEntity = new MchManageEntity();
merchantInfoEntity.setCollectionCode(url);
merchantInfoEntity.setId(dto.getId());
updateById(merchantInfoEntity);
} catch (Exception e) {
e.printStackTrace();
log.error("|{}|新增商户,生成收款码错误dto:|{}|error:|{}|", TAG, JSON.toJSONString(dto), e.getMessage());
}
return dto.getId();
}
@Override
@CachePut(value = CacheConstants.WALLET_MCH, key = "dto.getId()", condition = "dto.getId() != null", unless = "#result == null ")
public void edit(MchManageEntity dto) {
if (existName(dto.getName(), null)) {
throw new CheckedException("商户名不能重复");
}
if (existDeptId(dto.getDeptId(), null)) {
throw new CheckedException("改部门已经绑定过商户");
}
MchManageEntity mchManage = getById(dto.getId());
if (ObjectUtil.isEmpty(mchManage)) {
throw new CheckedException("商户不存在");
}
baseMapper.updateById(dto);
}
@Override
public void delByIds(ArrayList<Long> list) {
if (ObjectUtil.isEmpty(list)) return;
delByIds(list);
// 删除缓存
list.forEach(v -> redisTemplate.opsForValue().getAndDelete(CacheConstants.WALLET_MCH + v));
}
@Override
public Page<MchManageVo> pageJoin(Page page, MchManageDto dto) {
Page<MchManageVo> list = baseMapper.pageJoin(page, dto);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 部门
List<Long> deptIds = list.getRecords().stream().map(MchManageVo::getDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = remoteDeptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(page.getRecords(), deptList.getData());
}
}
return list;
}
@Override
public MchManageDto getByDeptId(Long deptId) {
MchManageEntity mchManage = baseMapper.selectOne(new LambdaQueryWrapper<MchManageEntity>()
.eq(MchManageEntity::getDeptId, deptId)
);
return BeanUtils.toBean(mchManage, MchManageDto.class);
}
@Override
public MchManageDto getFirstMch(List<Long> deptIds) {
List<MchManageEntity> merchantList = baseMapper.selectList(new LambdaQueryWrapper<MchManageEntity>());
if (ObjectUtil.isEmpty(merchantList)) return null;
for (Long id : deptIds) {
for (MchManageEntity merchant : merchantList) {
if (ObjectUtil.equals(merchant.getDeptId(), id)) {
return BeanUtils.toBean(merchant, MchManageDto.class);
}
}
}
return null;
}
private boolean existName(String name, Long id) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchManageEntity>()
.eq(ObjectUtil.isNotEmpty(name), MchManageEntity::getName, name)
.ne(ObjectUtil.isNotEmpty(id), MchManageEntity::getId, id)
);
if (ObjectUtil.isNotEmpty(id)) {
return count >= 1;
}
return count > 0;
}
private boolean existDeptId(Long deptId, Long id) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchManageEntity>()
.eq(ObjectUtil.isNotEmpty(deptId), MchManageEntity::getDeptId, deptId)
.ne(ObjectUtil.isNotEmpty(id), MchManageEntity::getId, id)
);
if (ObjectUtil.isNotEmpty(id)) {
return count >= 1;
}
return count > 0;
}
}
@@ -0,0 +1,71 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.exception.CheckedException;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.mapper.WalletActiveMapper;
import com.bsd.pjcloud.wallet.service.WalletActiveService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
import java.util.List;
/**
* 钱包开卡
*
* @author dzc
* @date 2024-12-31 18:53:31
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class WalletActiveServiceImpl extends ServiceImpl<WalletActiveMapper, WalletActiveEntity> implements WalletActiveService {
private final WalletTypeService walletTypeService;
@Override
@Transactional(rollbackFor = Exception.class)
public void fastCreateCard(WalletActiveDto dto) {
Long count = dto.getCount();
// 查询饭卡钱包类型
WalletTypeEntity walletType = walletTypeService.getById(dto.getWalletTypeId());
if (ObjectUtil.isEmpty(walletType)) throw new CheckedException("钱包类型不存在");
// 查询商户
int startNum = 1;
WalletActiveEntity last = getLast();
if (ObjectUtil.isNotEmpty(last)) startNum = last.getCardSort();
List<WalletActiveEntity> batchSaveList = new ArrayList<>();
for (int i = 0; i < count; i++) {
startNum += 1;
WalletActiveEntity item = new WalletActiveEntity();
String cardNumber = "hq" + String.format("%06d", startNum) + RandomUtil.randomString(RandomUtil.BASE_CHAR, 4);
item.setCardNumber(cardNumber);
item.setWalletTypeId(walletType.getId());
item.setDeptId(null);
item.setMerchantId(null);
item.setIsActiveHardware(YesNoEnum.NO.getCode());
batchSaveList.add(item);
}
baseMapper.insert(batchSaveList);
}
private WalletActiveEntity getLast() {
LambdaQueryWrapper<WalletActiveEntity> query = new LambdaQueryWrapper<WalletActiveEntity>();
query.orderByDesc(WalletActiveEntity::getId).last("LIMIT 1");
return baseMapper.selectOne(query);
}
}
@@ -0,0 +1,23 @@
package com.bsd.pjcloud.wallet.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.mapper.WalletFreezeMapper;
import com.bsd.pjcloud.wallet.service.WalletFreezeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* 饭卡冻结记录表
*
* @author dzc
* @date 2024-12-31 18:54:43
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class WalletFreezeServiceImpl extends ServiceImpl<WalletFreezeMapper, WalletFreezeEntity> implements WalletFreezeService {
}
@@ -24,11 +24,9 @@ import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.ehcache.xml.model.CacheTemplate;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -100,7 +98,6 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
}
@Override
@CachePut(value = CacheConstants.WALLET_DETAIL, key = "#userId-#walletTypeCode.name()", unless = "#result == null ")
public WalletManageEntity getOrCreateWallet(Long userId, WalletTypeCodeEnum walletTypeCode) {
WalletTypeEntity walletType = walletTypeService.getByUniqueCode(walletTypeCode);
if (ObjectUtil.isEmpty(walletType)) return null;
@@ -1,16 +1,162 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.exception.CheckedException;
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.MsgUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.excel.vo.ErrorMessage;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.dto.WalletRechargeApplyDto;
import com.bsd.pjcloud.wallet.api.dto.excel.WalletRechargeExcelDto;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeApplyEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeImportEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletRechargeApplyVo;
import com.bsd.pjcloud.wallet.mapper.WalletRechargeApplyMapper;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 充值/扣款申请
*
* @author pjcloud
* @date 2024-12-31 14:23:57
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeApplyMapper, WalletRechargeApplyEntity> implements WalletRechargeApplyService {
private final WalletRechargeImportServiceImpl rechargeImportService;
private final WalletManageService walletManageService;
private final RemoteUserService userService;
private final RemoteDeptService deptService;
@Override
public void create(WalletRechargeApplyEntity dto) {
PjcloudUser loginUser = SecurityUtils.getUser();
dto.setDeptId(loginUser.getDeptId());
dto.setUserId(loginUser.getId());
baseMapper.insert(dto);
}
@Override
public Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto) {
Page<WalletRechargeApplyVo> list = baseMapper.pageJoin(page, dto);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 用户
List<Long> userIds = list.getRecords().stream().map(WalletRechargeApplyVo::getUserId).distinct().toList();
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
if (ObjectUtil.isNotEmpty(userList.getData())) {
DataUtil.convertUserList(page.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
}
// 部门
List<Long> deptIds = list.getRecords().stream().map(WalletRechargeApplyVo::getDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(page.getRecords(), deptList.getData());
}
}
return list;
}
@Override
public void apply(WalletRechargeApplyDto dto) {
WalletRechargeApplyEntity rechargeApply = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(rechargeApply)) {
throw new CheckedException("充值申请不存在");
}
baseMapper.updateById(dto);
}
@Override
public void cancelApply(WalletRechargeApplyDto dto) {
WalletRechargeApplyEntity rechargeApply = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(rechargeApply)) {
throw new CheckedException("充值申请不存在");
}
}
/* ************************************* start excel start ************************************* */
@Override
@Transactional(rollbackFor = Exception.class)
public R readExcel(List<WalletRechargeExcelDto> list, BindingResult bindingResult) {
if (ObjectUtil.isEmpty(list)) return R.failed();
list = list.stream().filter(v -> !ObjectUtil.isAllEmpty(v.getUsername(), v.getUserMobile(), v.getPrice())).toList();
if (ObjectUtil.isEmpty(list)) return R.failed();
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
for (WalletRechargeExcelDto v : list) {
Set<String> errors = new LinkedHashSet<>();
if (ObjectUtil.isEmpty(v.getPrice())) {
errors.add("请输入操作金额");
} else {
try {
int i = new BigDecimal(v.getPrice()).multiply(new BigDecimal(100)).intValue();
v.setPriceNumber(i);
} catch (Exception e) {
errors.add("请输入正确的操作金额");
}
}
if (ObjectUtil.isEmpty(v.getUsername())) {
errors.add("请输入用户名");
} else if (ObjectUtil.isEmpty(v.getUserMobile())) {
errors.add("请输入用户手机号");
} else if (!Validator.isMobile(v.getUserMobile())) {
errors.add("用户手机号格式不正确");
} else {
R<UserInfo> user = userService.getUserByNameAndMobile(v.getUsername(), v.getUserMobile());
Optional<Long> userId = Optional.of(user).map(R::getData).map(UserInfo::getSysUser).map(SysUser::getUserId);
if (userId.isEmpty()) {
errors.add("用户不存在");
} else {
v.setUserId(userId.get());
}
}
if (ObjectUtil.isNotEmpty(errors)) {
errorMessageList.add(new ErrorMessage(v.getLineNum(), errors));
}
}
if (ObjectUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
PjcloudUser loginUser = SecurityUtils.getUser();
WalletRechargeApplyEntity insertObj = new WalletRechargeApplyEntity();
insertObj.setDeptId(loginUser.getDeptId());
insertObj.setUserId(loginUser.getId());
int i = baseMapper.insert(insertObj);
if (i <= 0) {
throw new CheckedException("导入失败");
}
List<WalletRechargeImportEntity> batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).build()).toList();
batchSaveList.forEach(v -> v.setApplyId(insertObj.getId()));
rechargeImportService.saveBatch(batchSaveList);
return R.ok(null, MsgUtils.getMessage(ErrorCodes.SYS_USER_IMPORT_SUCCEED));
}
/* ************************************* end excel end ************************************* */
}
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.wallet.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.wallet.api.entity.WalletRechargeImportEntity;
import com.bsd.pjcloud.wallet.mapper.WalletRechargeImportMapper;
import com.bsd.pjcloud.wallet.service.WalletRechargeImportService;
import org.springframework.stereotype.Service;
/**
* 充值导入表
@@ -1,12 +1,15 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.exception.CheckedException;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@@ -34,4 +37,51 @@ public class WalletTypeServiceImpl extends ServiceImpl<WalletTypeMapper, WalletT
);
}
@Override
public void create(WalletTypeEntity dto) {
if (existName(dto.getId(), dto.getName())) {
throw new CheckedException("钱包名存在");
}
if (existCode(dto.getId(), dto.getUniqueCode())) {
throw new CheckedException("钱包类型存在");
}
baseMapper.insert(dto);
}
@Override
public void edit(WalletTypeEntity dto) {
if (existName(dto.getId(), dto.getName())) {
throw new CheckedException("钱包名存在");
}
if (existCode(dto.getId(), dto.getUniqueCode())) {
throw new CheckedException("钱包类型存在");
}
WalletTypeEntity walletType = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(walletType)) {
throw new CheckedException("钱包类型不存在");
}
baseMapper.updateById(dto);
}
public boolean existName(Long id, String name) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<WalletTypeEntity>()
.ne(ObjectUtil.isNotEmpty(id), WalletTypeEntity::getId, id)
.eq(ObjectUtil.isNotEmpty(name), WalletTypeEntity::getName, name)
);
if (ObjectUtil.isNotEmpty(id)) {
return count >= 1;
}
return count > 0;
}
public boolean existCode(Long id, String code) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<WalletTypeEntity>()
.ne(ObjectUtil.isNotEmpty(id), WalletTypeEntity::getId, id)
.eq(ObjectUtil.isNotEmpty(code), WalletTypeEntity::getUniqueCode, code)
);
if (ObjectUtil.isNotEmpty(id)) {
return count >= 1;
}
return count > 0;
}
}
@@ -1,9 +1,9 @@
<?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="merchant.mapper.MchManageMapper">
<mapper namespace="com.bsd.pjcloud.wallet.mapper.MchManageMapper">
<resultMap id="mchManageMap" type="merchant.entity.MchManageEntity">
<resultMap id="mchManageMap" type="com.bsd.pjcloud.wallet.api.entity.MchManageEntity">
<id property="id" column="id"/>
<result property="deptId" column="dept_id"/>
<result property="name" column="name"/>
@@ -0,0 +1,22 @@
<?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.bsd.pjcloud.wallet.mapper.WalletActiveMapper">
<resultMap id="walletActiveMap" type="com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity">
<id property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="walletId" column="wallet_id"/>
<result property="walletTypeId" column="wallet_type_id"/>
<result property="deptId" column="dept_id"/>
<result property="merchantId" column="merchant_id"/>
<result property="cardNumber" column="card_number"/>
<result property="isActiveHardware" column="is_active_hardware"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -0,0 +1,19 @@
<?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.bsd.pjcloud.wallet.mapper.WalletFreezeMapper">
<resultMap id="walletFreezeMap" type="com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity">
<id property="id" column="id"/>
<result property="walletId" column="wallet_id"/>
<result property="userId" column="user_id"/>
<result property="freeStatus" column="free_status"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
-1
View File
@@ -125,7 +125,6 @@
<module>pjcloud-wallet</module>
<module>pjcloud-supermarket</module>
<module>pjcloud-hardware</module>
<module>pjcloud-merchant</module>
</modules>
<dependencyManagement>