feat:导入金额
This commit is contained in:
1 parent
c717985e1d
commit
4d7b7e3fe5
22 files changed
+412
-35
No files matched your search
@@ -170,7 +170,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 '创建时间',
|
||||
|
||||
+11
@@ -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获取用户
|
||||
*
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+10
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户全部信息
|
||||
*
|
||||
|
||||
+7
-7
@@ -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));
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+2
-5
@@ -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))
|
||||
|
||||
+24
@@ -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();
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -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))
|
||||
|
||||
+2
-5
@@ -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))
|
||||
|
||||
+7
@@ -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;
|
||||
|
||||
}
|
||||
+50
@@ -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;
|
||||
}
|
||||
+7
-2
@@ -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;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
||||
+4
-2
@@ -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")
|
||||
|
||||
+21
-1
@@ -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;
|
||||
|
||||
}
|
||||
+66
-4
@@ -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 ************************************* */
|
||||
|
||||
}
|
||||
+18
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -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);
|
||||
}
|
||||
-2
@@ -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;
|
||||
|
||||
+146
@@ -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 ************************************* */
|
||||
}
|
||||
+1
@@ -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;
|
||||
/**
|
||||
* 充值导入表
|
||||
|
||||
Reference in new issue
Block a user