feat:钱包冻结、开卡
This commit is contained in:
1 parent
e4e05b53da
commit
da4a59e0ca
15 files changed
+257
-67
No files matched your search
@@ -64,6 +64,7 @@ CREATE TABLE wallet_active
|
||||
dept_id bigint NOT NULL COMMENT '部门id',
|
||||
merchant_id bigint NOT NULL COMMENT '商户id',
|
||||
card_number varchar(128) NOT NULL 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 '创建时间',
|
||||
|
||||
+41
-31
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
+17
@@ -1,8 +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;
|
||||
|
||||
}
|
||||
+6
@@ -65,6 +65,12 @@ public class WalletActiveEntity extends Model<WalletActiveEntity> {
|
||||
@Schema(description="用户卡号")
|
||||
private String cardNumber;
|
||||
|
||||
/**
|
||||
* 饭卡顺序
|
||||
*/
|
||||
@Schema(description="饭卡顺序")
|
||||
private Integer cardSort;
|
||||
|
||||
/**
|
||||
* 饭卡是否在硬件上激活
|
||||
*/
|
||||
|
||||
@@ -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>
|
||||
|
||||
+42
-23
@@ -6,7 +6,9 @@ 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;
|
||||
@@ -17,10 +19,12 @@ 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;
|
||||
|
||||
/**
|
||||
* 钱包开卡
|
||||
@@ -30,22 +34,32 @@ import java.util.Objects;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/walletActive" )
|
||||
@Tag(description = "walletActive" , name = "钱包开卡管理" )
|
||||
@RequestMapping("/wallet-active")
|
||||
@Tag(description = "wallet-active", name = "钱包开卡管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
@Validated
|
||||
public class WalletActiveController {
|
||||
|
||||
private final WalletActiveService walletActiveService;
|
||||
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 page 分页对象
|
||||
* @param walletActive 钱包开卡
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletActive_view')" )
|
||||
@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));
|
||||
@@ -54,51 +68,55 @@ public class WalletActiveController {
|
||||
|
||||
/**
|
||||
* 通过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) {
|
||||
@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("新增钱包开卡" )
|
||||
@Operation(summary = "新增钱包开卡", description = "新增钱包开卡")
|
||||
@SysLog("新增钱包开卡")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletActive_add')" )
|
||||
@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("修改钱包开卡" )
|
||||
@Operation(summary = "修改钱包开卡", description = "修改钱包开卡")
|
||||
@SysLog("修改钱包开卡")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletActive_edit')" )
|
||||
@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删除钱包开卡" )
|
||||
@Operation(summary = "通过id删除钱包开卡", description = "通过id删除钱包开卡")
|
||||
@SysLog("通过id删除钱包开卡")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletActive_del')" )
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletActive_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(walletActiveService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
@@ -106,14 +124,15 @@ public class WalletActiveController {
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param walletActive 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletActive_export')" )
|
||||
public List<WalletActiveEntity> export(WalletActiveEntity walletActive,Long[] ids) {
|
||||
@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));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -29,8 +29,8 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/walletFreeze" )
|
||||
@Tag(description = "walletFreeze" , name = "饭卡冻结记录表管理" )
|
||||
@RequestMapping("/wallet-freeze" )
|
||||
@Tag(description = "wallet-freeze" , name = "饭卡冻结记录表管理" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class WalletFreezeController {
|
||||
|
||||
|
||||
+8
-6
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-1
@@ -1,8 +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);
|
||||
}
|
||||
+3
@@ -10,4 +10,7 @@ public interface WalletTypeService extends IService<WalletTypeEntity> {
|
||||
|
||||
WalletTypeEntity getByUniqueCode(WalletTypeCodeEnum walletTypeCodeEnum);
|
||||
|
||||
void create(WalletTypeEntity dto);
|
||||
|
||||
void edit(WalletTypeEntity dto);
|
||||
}
|
||||
+54
@@ -1,16 +1,70 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
+7
@@ -4,13 +4,20 @@ 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 {
|
||||
}
|
||||
+50
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user