del:删除商户服务

creat:新建钱包商户
This commit is contained in:
dzc committed 2025-01-02 12:00:52 +08:00
1 parent da4a59e0ca
commit c086729afb
34 files changed
+398 -444

No files matched your search

+30
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
-- ----------------------------
@@ -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,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>
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import lombok.Data;
@Data
public class MchManageDto extends MchManageEntity {
}
@@ -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,29 @@
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-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,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
@@ -1,14 +1,20 @@
package merchant.controller;
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 merchant.entity.MchManageEntity;
import merchant.service.MchManageService;
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.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;
@@ -24,8 +30,8 @@ import java.util.List;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
* @author dzc
* @date 2025-01-02 11:09:26
*/
@RestController
@RequiredArgsConstructor
@@ -36,6 +42,34 @@ 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-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 ************************************* */
/**
* 分页查询
*
@@ -45,12 +79,26 @@ public class MchManageController {
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('mch_mchManage_view')")
@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")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
public R getMchManagePage(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
return R.ok(mchManageService.pageJoin(page, dto));
}
/**
* 通过id查询商户管理
@@ -60,8 +108,8 @@ public class MchManageController {
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('mch_mchManage_view')")
public R getById(@PathVariable("id") Long id) {
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
public R getDetail(@PathVariable("id") Long id) {
return R.ok(mchManageService.getById(id));
}
@@ -74,9 +122,9 @@ public class MchManageController {
@Operation(summary = "新增商户管理", description = "新增商户管理")
@SysLog("新增商户管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_add')")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_add')")
public R save(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.save(mchManage));
return R.ok(mchManageService.create(mchManage));
}
/**
@@ -88,9 +136,10 @@ public class MchManageController {
@Operation(summary = "修改商户管理", description = "修改商户管理")
@SysLog("修改商户管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_edit')")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_edit')")
public R updateById(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.updateById(mchManage));
mchManageService.edit(mchManage);
return R.ok(true);
}
/**
@@ -102,9 +151,10 @@ public class MchManageController {
@Operation(summary = "通过id删除商户管理", description = "通过id删除商户管理")
@SysLog("通过id删除商户管理")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_del')")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(mchManageService.removeBatchByIds(CollUtil.toList(ids)));
mchManageService.delByIds(CollUtil.toList(ids));
return R.ok(true);
}
@@ -117,7 +167,7 @@ public class MchManageController {
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('mch_mchManage_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,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,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,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;
}
}
@@ -44,6 +44,7 @@ public class WalletActiveServiceImpl extends ServiceImpl<WalletActiveMapper, Wal
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();
@@ -98,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,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"/>