feat:发票管理
This commit is contained in:
1 parent
bb9f0dd5cd
commit
6ac12d8d44
15 files changed
+320
-90
No files matched your search
+20
-18
@@ -391,24 +391,26 @@ CREATE INDEX idx_dept_id ON wallet_recharge_apply (user_id);
|
||||
DROP TABLE IF EXISTS wallet_recharge_invoice;
|
||||
CREATE TABLE wallet_recharge_invoice
|
||||
(
|
||||
id bigint NOT NULL COMMENT '主键ID',
|
||||
apply_id bigint NOT NULL COMMENT '申请id',
|
||||
code varchar(32) NOT NULL COMMENT '发票代码(七位数)',
|
||||
time datetime DEFAULT NULL COMMENT '发票日期',
|
||||
dept_or_user varchar(64) DEFAULT NULL COMMENT '交款单位或个人',
|
||||
total_price int DEFAULT NULL COMMENT '合计人民币',
|
||||
payee_dept varchar(64) DEFAULT NULL COMMENT '收款单位',
|
||||
payee_user varchar(64) DEFAULT NULL COMMENT '收款人',
|
||||
item_json varchar(2048) DEFAULT NULL COMMENT '备注',
|
||||
remark varchar(1024) DEFAULT NULL COMMENT '备注',
|
||||
status varchar(32) DEFAULT NULL COMMENT '状态',
|
||||
pic_url varchar(1024) 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',
|
||||
id bigint NOT NULL COMMENT '主键ID',
|
||||
apply_user_id bigint DEFAULT NULL COMMENT '申请用户id',
|
||||
apply_dept_id bigint DEFAULT NULL COMMENT '申请用户部门id',
|
||||
apply_id bigint DEFAULT NULL COMMENT '申请id',
|
||||
code varchar(32) NOT NULL COMMENT '发票代码(七位数)',
|
||||
time datetime DEFAULT NULL COMMENT '发票日期',
|
||||
dept_or_user varchar(64) DEFAULT NULL COMMENT '交款单位或个人',
|
||||
total_price int DEFAULT NULL COMMENT '合计人民币',
|
||||
payee_dept varchar(64) DEFAULT NULL COMMENT '收款单位',
|
||||
payee_user varchar(64) DEFAULT NULL COMMENT '收款人',
|
||||
item_json varchar(2048) DEFAULT NULL COMMENT '备注',
|
||||
remark varchar(1024) DEFAULT NULL COMMENT '备注',
|
||||
status varchar(32) DEFAULT NULL COMMENT '状态',
|
||||
pic_url varchar(1024) 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
|
||||
|
||||
+6
-3
@@ -6,13 +6,16 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// cancellation
|
||||
/**
|
||||
* 充值/申请发票状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WalletRechargeInvoiceStatusEnum {
|
||||
|
||||
DEFAULT("1", "默认"),
|
||||
CANCELLATION("2", "作废"),
|
||||
UNCHECKED("1", "未审核"),
|
||||
CHECKED("2", "审核通过"),
|
||||
CANCELLATION("3", "作废"),
|
||||
;
|
||||
private final String code;
|
||||
|
||||
|
||||
+16
-2
@@ -1,17 +1,31 @@
|
||||
package com.bsd.pjcloud.wallet.api.dto.recharge;
|
||||
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.math3.optim.nonlinear.scalar.LineSearch;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充值记录绑定发票
|
||||
*/
|
||||
@Data
|
||||
public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceEntityVo {
|
||||
public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceVo {
|
||||
|
||||
/**
|
||||
* 充值/扣款申请id
|
||||
*/
|
||||
private Long applyId;
|
||||
|
||||
/**
|
||||
* 申请人
|
||||
*/
|
||||
private List<String> userIds;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
}
|
||||
+6
@@ -49,6 +49,12 @@ public class WalletRechargeImportEntity extends Model<WalletRechargeImportEntity
|
||||
@Schema(description = "申请id")
|
||||
private Long applyId;
|
||||
|
||||
/**
|
||||
* 发票id
|
||||
*/
|
||||
@Schema(description = "发票id")
|
||||
private Long invoiceId;
|
||||
|
||||
/**
|
||||
* 导入前的金额
|
||||
*/
|
||||
|
||||
+14
-2
@@ -27,6 +27,18 @@ public class WalletRechargeInvoiceEntity extends Model<WalletRechargeInvoiceEnti
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 申请id
|
||||
*/
|
||||
@Schema(description = "申请id")
|
||||
private Long applyUserId;
|
||||
|
||||
/**
|
||||
* 申请id
|
||||
*/
|
||||
@Schema(description = "申请id")
|
||||
private Long applyDeptId;
|
||||
|
||||
/**
|
||||
* 申请id
|
||||
*/
|
||||
@@ -52,9 +64,9 @@ public class WalletRechargeInvoiceEntity extends Model<WalletRechargeInvoiceEnti
|
||||
private String deptOrUser;
|
||||
|
||||
/**
|
||||
* 合计人民币
|
||||
* 合计人民币(分)
|
||||
*/
|
||||
@Schema(description = "合计人民币")
|
||||
@Schema(description = "合计人民币(分)")
|
||||
private Integer totalPrice;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
* 充值/扣款申请发票记录款项
|
||||
*/
|
||||
@Data
|
||||
public class WalletRechargeInvoiceEntityItemVo {
|
||||
public class WalletRechargeInvoiceItemVo {
|
||||
|
||||
/**
|
||||
* 款项内容
|
||||
+1
-1
@@ -4,7 +4,7 @@ import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletRechargeInvoiceEntityVo extends WalletRechargeInvoiceEntity {
|
||||
public class WalletRechargeInvoiceVo extends WalletRechargeInvoiceEntity {
|
||||
|
||||
private String totalPriceCnStr;
|
||||
|
||||
+5
@@ -144,5 +144,10 @@ public class WalletRechargeApplyController {
|
||||
return walletRechargeApplyService.readExcel(excelVOList, bindingResult);
|
||||
}
|
||||
|
||||
@PostMapping("/read-topup-excel")
|
||||
public R readTopupExcel(@RequestExcel List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult) {
|
||||
return walletRechargeApplyService.readTopupExcel(excelVOList, bindingResult);
|
||||
}
|
||||
|
||||
/* ************************************* start excel start ************************************* */
|
||||
}
|
||||
+13
-8
@@ -2,14 +2,13 @@ package com.bsd.pjcloud.wallet.controller.recharge;
|
||||
|
||||
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.dto.recharge.WalletRechargeBindInvoiceDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -38,7 +37,7 @@ public class WalletRechargeInvoiceController {
|
||||
|
||||
@GetMapping("/get-invoice")
|
||||
@Operation(summary = "批量充值/扣款发票信息")
|
||||
public R<WalletRechargeInvoiceEntityVo> getInvoice(@RequestParam Long id) {
|
||||
public R<WalletRechargeInvoiceVo> getInvoice(@RequestParam Long id) {
|
||||
return R.ok(walletRechargeInvoiceService.getInvoice(id));
|
||||
}
|
||||
|
||||
@@ -49,19 +48,24 @@ public class WalletRechargeInvoiceController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "下拉", description = "下拉")
|
||||
@GetMapping("/select")
|
||||
public R select(@ParameterObject Page page, @ParameterObject WalletRechargeBindInvoiceDto dto) {
|
||||
return R.ok(walletRechargeInvoiceService.scopePageList(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_view')")
|
||||
public R getWalletRechargeInvoicePage(@ParameterObject Page page, @ParameterObject WalletRechargeInvoiceEntity walletRechargeInvoice) {
|
||||
LambdaQueryWrapper<WalletRechargeInvoiceEntity> wrapper = Wrappers.lambdaQuery();
|
||||
return R.ok(walletRechargeInvoiceService.page(page, wrapper));
|
||||
public R getWalletRechargeInvoicePage(@ParameterObject Page page, @ParameterObject WalletRechargeBindInvoiceDto dto) {
|
||||
return R.ok(walletRechargeInvoiceService.scopePageList(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(walletRechargeInvoiceService.getById(id));
|
||||
return R.ok(walletRechargeInvoiceService.joinById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增充值/扣款申请发票记录", description = "新增充值/扣款申请发票记录")
|
||||
@@ -85,7 +89,8 @@ public class WalletRechargeInvoiceController {
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(walletRechargeInvoiceService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
walletRechargeInvoiceService.delByIds(CollUtil.toList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
|
||||
+14
@@ -1,8 +1,12 @@
|
||||
package com.bsd.pjcloud.wallet.mapper.recharge;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface WalletRechargeInvoiceMapper extends PjcloudBaseMapper<WalletRechargeInvoiceEntity> {
|
||||
@@ -11,4 +15,14 @@ public interface WalletRechargeInvoiceMapper extends PjcloudBaseMapper<WalletRec
|
||||
* 查询所有数量包括删除
|
||||
*/
|
||||
Long selectAllCount();
|
||||
|
||||
/**
|
||||
* 分页权限查询
|
||||
*/
|
||||
Page<WalletRechargeInvoiceVo> scopePageList(Page page, @Param("dto") WalletRechargeBindInvoiceDto dto);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
WalletRechargeInvoiceVo joinById(@Param("id") Long id);
|
||||
}
|
||||
+6
-1
@@ -41,10 +41,15 @@ public interface WalletRechargeApplyService extends IService<WalletRechargeApply
|
||||
void cancelApply(WalletRechargeApplyDto dto);
|
||||
|
||||
/**
|
||||
* 读取excel内容
|
||||
* 读取记账扣款、退回各自食堂excel内容
|
||||
*/
|
||||
R readExcel(List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult);
|
||||
|
||||
/**
|
||||
* 读取充值excel内容
|
||||
*/
|
||||
R readTopupExcel(List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult);
|
||||
|
||||
/**
|
||||
* 审批回调
|
||||
*/
|
||||
|
||||
+26
-2
@@ -1,17 +1,31 @@
|
||||
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.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface WalletRechargeInvoiceService extends IService<WalletRechargeInvoiceEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
Page<WalletRechargeInvoiceVo> scopePageList(Page page, WalletRechargeBindInvoiceDto dto);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
WalletRechargeInvoiceVo joinById(Long id);
|
||||
|
||||
/**
|
||||
* 批量充值/扣款发票信息
|
||||
*/
|
||||
WalletRechargeInvoiceEntityVo getInvoice(Long id);
|
||||
WalletRechargeInvoiceVo getInvoice(Long id);
|
||||
|
||||
/**
|
||||
* 获取发票代码
|
||||
@@ -22,4 +36,14 @@ public interface WalletRechargeInvoiceService extends IService<WalletRechargeInv
|
||||
* 绑定发票
|
||||
*/
|
||||
void bindInvoice(@Valid WalletRechargeBindInvoiceDto dto);
|
||||
|
||||
/**
|
||||
* 创建基础发票
|
||||
*/
|
||||
WalletRechargeInvoiceEntity createBaseInvoice(PjcloudUser loginUser, Integer totalPrice);
|
||||
|
||||
/**
|
||||
* 批量删除发票
|
||||
*/
|
||||
void delByIds(ArrayList<Long> list);
|
||||
}
|
||||
+52
-16
@@ -43,6 +43,7 @@ import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
|
||||
@@ -52,6 +53,7 @@ import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeApplyMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper;
|
||||
import com.bsd.pjcloud.wallet.service.*;
|
||||
import com.bsd.pjcloud.wallet.utils.flow.FlowUtil;
|
||||
import com.bsd.pjcloud.wallet.utils.flow.dto.WalletRechargeApplyFlowDto;
|
||||
@@ -59,6 +61,7 @@ import com.bsd.pjcloud.wallet.utils.flow.dto.WalletRechargeApplyFlowDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.BindingResult;
|
||||
@@ -92,6 +95,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
private final WalletTransactionMapper walletTransactionMapper;
|
||||
private final WalletManageMapper walletManageMapper;
|
||||
private final WalletTypeMapper walletTypeMapper;
|
||||
private final WalletRechargeInvoiceService walletRechargeInvoiceService;
|
||||
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteDeptService deptService;
|
||||
@@ -250,13 +254,56 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R readExcel(List<WalletRechargeExcelDto> list, BindingResult bindingResult) {
|
||||
public R readExcel(List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult) {
|
||||
ImmutablePair<List<ErrorMessage>, List<WalletRechargeExcelDto>> pair = validateExcelData(excelVOList, bindingResult);
|
||||
List<ErrorMessage> errorMessages = pair.getLeft();
|
||||
List<WalletRechargeExcelDto> list = pair.getRight();
|
||||
if (ObjectUtil.isNotEmpty(errorMessages)) return R.failed(errorMessages);
|
||||
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 RuntimeException("导入失败");
|
||||
}
|
||||
List<WalletRechargeImportEntity> batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).build()).toList();
|
||||
batchSaveList.forEach(v -> v.setApplyId(insertObj.getId()));
|
||||
rechargeImportService.saveBatch(batchSaveList);
|
||||
return R.ok(null, "导入成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取充值excel内容
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R readTopupExcel(List<WalletRechargeExcelDto> excelVOList, BindingResult bindingResult) {
|
||||
ImmutablePair<List<ErrorMessage>, List<WalletRechargeExcelDto>> pair = validateExcelData(excelVOList, bindingResult);
|
||||
List<ErrorMessage> errorMessages = pair.getLeft();
|
||||
List<WalletRechargeExcelDto> list = pair.getRight();
|
||||
if (ObjectUtil.isNotEmpty(errorMessages)) return R.failed(errorMessages);
|
||||
PjcloudUser loginUser = SecurityUtils.getUser();
|
||||
// 先创建发票
|
||||
Integer totalPrice = list.stream().map(WalletRechargeExcelDto::getPriceNumber).reduce(Integer::sum).orElse(0);
|
||||
WalletRechargeInvoiceEntity invoice = walletRechargeInvoiceService.createBaseInvoice(loginUser, totalPrice);
|
||||
if (ObjectUtil.isEmpty(invoice)) throw new RuntimeException("导入失败");
|
||||
// 导入数据
|
||||
List<WalletRechargeImportEntity> batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).invoiceId(invoice.getId()).build()).toList();
|
||||
rechargeImportService.saveBatch(batchSaveList);
|
||||
return R.ok(null, "导入成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验充值/扣款excel的数据
|
||||
*/
|
||||
public ImmutablePair<List<ErrorMessage>, List<WalletRechargeExcelDto>> validateExcelData(List<WalletRechargeExcelDto> list, BindingResult bindingResult) {
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return R.failed();
|
||||
throw new RuntimeException("读取excel数据错误");
|
||||
}
|
||||
list = list.stream().filter(v -> !ObjectUtil.isAllEmpty(v.getUsername(), v.getUserMobile(), v.getPrice())).toList();
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return R.failed();
|
||||
throw new RuntimeException("读取excel数据错误");
|
||||
}
|
||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||
List<String> usernameList = list.stream().map(WalletRechargeExcelDto::getUsername).toList();
|
||||
@@ -306,20 +353,9 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(errorMessageList)) {
|
||||
return R.failed(errorMessageList);
|
||||
return ImmutablePair.of(errorMessageList, null);
|
||||
}
|
||||
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 RuntimeException("导入失败");
|
||||
}
|
||||
List<WalletRechargeImportEntity> batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).build()).toList();
|
||||
batchSaveList.forEach(v -> v.setApplyId(insertObj.getId()));
|
||||
rechargeImportService.saveBatch(batchSaveList);
|
||||
return R.ok(null, "导入成功");
|
||||
return ImmutablePair.of(null, list);
|
||||
}
|
||||
|
||||
/* ************************************* end excel end ************************************* */
|
||||
|
||||
+87
-17
@@ -1,15 +1,15 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.recharge;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum;
|
||||
@@ -19,12 +19,11 @@ import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityItemVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceItemVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeApplyMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService;
|
||||
import com.bsd.pjcloud.wallet.utils.ConvertCnPriceUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -33,6 +32,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -45,18 +46,37 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
private final WalletRechargeImportMapper importMapper;
|
||||
private final WalletRechargeApplyMapper applyMapper;
|
||||
|
||||
private final WalletRechargeApplyService applyService;
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
private final RemoteWalletSettingService remoteWalletSettingService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Override
|
||||
public Page<WalletRechargeInvoiceVo> scopePageList(Page page, WalletRechargeBindInvoiceDto dto) {
|
||||
return baseMapper.scopePageList(page, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
@Override
|
||||
public WalletRechargeInvoiceVo joinById(Long id) {
|
||||
WalletRechargeInvoiceVo detail = baseMapper.joinById(id);
|
||||
if (ObjectUtil.isEmpty(detail)) return detail;
|
||||
// 转换为元
|
||||
Double price = BigDecimal.valueOf(detail.getTotalPrice()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue();
|
||||
detail.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price)));
|
||||
return detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量充值/扣款发票信息
|
||||
*/
|
||||
@Override
|
||||
public WalletRechargeInvoiceEntityVo getInvoice(Long id) {
|
||||
public WalletRechargeInvoiceVo getInvoice(Long id) {
|
||||
// 查询申请记录
|
||||
WalletRechargeApplyEntity applyDetail = applyService.getById(id);
|
||||
WalletRechargeApplyEntity applyDetail = applyMapper.selectById(id);
|
||||
WalletBizRechargeEnum bizEnum = WalletBizRechargeEnum.valueOfByType(applyDetail.getBizType());
|
||||
if (ObjectUtil.isEmpty(applyDetail)) {
|
||||
throw new RuntimeException("批量充值/扣款申请不存在");
|
||||
@@ -71,13 +91,13 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
}
|
||||
|
||||
// 先去查询有没有已经生产的发票
|
||||
WalletRechargeInvoiceEntityVo result = new WalletRechargeInvoiceEntityVo();
|
||||
WalletRechargeInvoiceVo result = new WalletRechargeInvoiceVo();
|
||||
WalletRechargeInvoiceEntity InvoiceEntity = baseMapper.selectOne(new LambdaQueryWrapper<WalletRechargeInvoiceEntity>()
|
||||
.eq(WalletRechargeInvoiceEntity::getApplyId, id)
|
||||
.eq(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.DEFAULT.getCode())
|
||||
.eq(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.UNCHECKED.getCode())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(InvoiceEntity)) {
|
||||
result = BeanUtil.copyProperties(InvoiceEntity, WalletRechargeInvoiceEntityVo.class);
|
||||
result = BeanUtil.copyProperties(InvoiceEntity, WalletRechargeInvoiceVo.class);
|
||||
Double price = BigDecimal.valueOf(result.getTotalPrice()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue();
|
||||
result.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price)));
|
||||
return result;
|
||||
@@ -104,9 +124,8 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
// 转换为元
|
||||
Double price = BigDecimal.valueOf(totalPrice).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue();
|
||||
// 生成款项
|
||||
WalletRechargeInvoiceEntityItemVo item = new WalletRechargeInvoiceEntityItemVo();
|
||||
String itemName = LocalDateTimeUtil.format(applyDetail.getImportTime(), DatePattern.NORM_DATE_PATTERN) + "," + bizEnum.getDesc() + price + "元";
|
||||
item.setName(itemName);
|
||||
WalletRechargeInvoiceItemVo item = new WalletRechargeInvoiceItemVo();
|
||||
item.setName("伙食费充值");
|
||||
item.setPrice(price);
|
||||
|
||||
result.setApplyId(applyDetail.getId());
|
||||
@@ -117,12 +136,63 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
result.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price)));
|
||||
result.setPayeeDept(walletSetting.getTopupDeptStr());
|
||||
result.setPayeeUser(payeeUser);
|
||||
result.setStatus(WalletRechargeInvoiceStatusEnum.DEFAULT.getCode());
|
||||
result.setStatus(WalletRechargeInvoiceStatusEnum.UNCHECKED.getCode());
|
||||
result.setItemJson(JSONUtil.toJsonStr(List.of(item)));
|
||||
result.setRemark("");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建基础发票
|
||||
*/
|
||||
@Override
|
||||
public WalletRechargeInvoiceEntity createBaseInvoice(PjcloudUser loginUser, Integer totalPrice) {
|
||||
// 查询当前用户
|
||||
UserInfo userInfo = remoteUserService.getByUserId(loginUser.getId()).getData();
|
||||
if (ObjectUtil.isEmpty(userInfo)) throw new RuntimeException("获取当前用户失败");
|
||||
// 获取配置
|
||||
WalletSettingVo walletSetting = remoteWalletSettingService.get().getData();
|
||||
WalletRechargeInvoiceEntity saveObj = new WalletRechargeInvoiceEntity();
|
||||
saveObj.setApplyUserId(userInfo.getSysUser().getUserId());
|
||||
saveObj.setApplyDeptId(userInfo.getSysUser().getDeptId());
|
||||
saveObj.setApplyId(null);
|
||||
saveObj.setCode(getInvoiceCode());
|
||||
saveObj.setTime(LocalDateTime.now());
|
||||
saveObj.setDeptOrUser(userInfo.getSysUser().getName());
|
||||
saveObj.setTotalPrice(totalPrice);
|
||||
if (ObjectUtil.isNotEmpty(walletSetting)) {
|
||||
if (ObjectUtil.isNotEmpty(walletSetting.getTopupUserId())) {
|
||||
// 查询收款人
|
||||
UserInfo payeeUser = remoteUserService.getByUserId(walletSetting.getTopupUserId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(payeeUser)) {
|
||||
saveObj.setPayeeUser(payeeUser.getSysUser().getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(walletSetting.getTopupDeptStr())) {
|
||||
saveObj.setPayeeDept(walletSetting.getTopupDeptStr());
|
||||
}
|
||||
}
|
||||
saveObj.setStatus(WalletRechargeInvoiceStatusEnum.UNCHECKED.getCode());
|
||||
baseMapper.insert(saveObj);
|
||||
return saveObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除发票
|
||||
*/
|
||||
@Override
|
||||
public void delByIds(ArrayList<Long> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
for (Long v : list) {
|
||||
WalletRechargeInvoiceEntity detail = baseMapper.selectById(v);
|
||||
if (ObjectUtil.isEmpty(detail)) continue;
|
||||
if (ObjectUtil.isNotEmpty(detail.getStatus()) && ObjectUtil.notEqual(detail.getStatus(), WalletRechargeInvoiceStatusEnum.UNCHECKED.getCode())) {
|
||||
UserInfo userInfo = remoteUserService.getByUserId(detail.getApplyId()).getData();
|
||||
throw new RuntimeException("用户<" + userInfo.getSysUser().getName() + ">发起的审批不能删除");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发票代码
|
||||
*/
|
||||
@@ -139,7 +209,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bindInvoice(WalletRechargeBindInvoiceDto dto) {
|
||||
WalletRechargeInvoiceEntity entity = BeanUtil.toBean(dto, WalletRechargeInvoiceEntityVo.class);
|
||||
WalletRechargeInvoiceEntity entity = BeanUtil.toBean(dto, WalletRechargeInvoiceVo.class);
|
||||
baseMapper.insertOrUpdate(entity);
|
||||
LambdaUpdateWrapper<WalletRechargeApplyEntity> updateWrapper = new LambdaUpdateWrapper<WalletRechargeApplyEntity>()
|
||||
.set(WalletRechargeApplyEntity::getInvoiceId, entity.getId())
|
||||
|
||||
+53
-19
@@ -2,29 +2,63 @@
|
||||
<!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.recharge.WalletRechargeInvoiceMapper">
|
||||
<resultMap id="walletRechargeInvoiceMap"
|
||||
type="com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="applyId" column="apply_id"/>
|
||||
<result property="code" column="code"/>
|
||||
<result property="time" column="time"/>
|
||||
<result property="deptOrUser" column="dept_or_user"/>
|
||||
<result property="totalPrice" column="total_price"/>
|
||||
<result property="payeeDept" column="payee_dept"/>
|
||||
<result property="payeeUser" column="payee_user"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="status" column="status"/>
|
||||
<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>
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.apply_user_id,
|
||||
a.apply_dept_id,
|
||||
a.apply_id,
|
||||
a.code,
|
||||
a.time,
|
||||
a.dept_or_user,
|
||||
a.total_price,
|
||||
a.payee_dept,
|
||||
a.payee_user,
|
||||
a.item_json,
|
||||
a.remark,
|
||||
a.status,
|
||||
a.pic_url,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.del_flag,
|
||||
a.tenant_id,
|
||||
</sql>
|
||||
|
||||
<sql id="whereA">
|
||||
<if test="dto.status != null">
|
||||
and a.status = #{dto.status}
|
||||
</if>
|
||||
<if test="dto.userIds != null and dto.userIds.size() != 0">
|
||||
and a.apply_user_id in
|
||||
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
|
||||
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectAllCount" resultType="java.lang.Long">
|
||||
SELECT COUNT(0)
|
||||
FROM wallet_recharge_invoice
|
||||
</select>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo">
|
||||
<include refid="selectA"/>
|
||||
1
|
||||
FROM wallet_recharge_invoice a
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
order by a.create_time desc , a.id desc
|
||||
</select>
|
||||
|
||||
<select id="joinById" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo">
|
||||
<include refid="selectA"/>
|
||||
1
|
||||
FROM wallet_recharge_invoice a
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user