feat(bpm): 添加一键支付功能并优化相关模块
- 在 BpmOAExpensesController 中添加 oneClickPayment 接口 - 在 BpmOAExpensesMapper 和 XML 中实现 oneClickPayment 方法 - 更新 BpmOAExpensesService接口并实现一键支付逻辑- 优化 BpmOAPayment 相关实体和查询 - 调整 BpmOASalary 相关实体和逻辑
This commit is contained in:
parent
31e12935f8
commit
cb7c1fd484
@ -94,4 +94,13 @@ public class BpmOAExpensesController {
|
||||
expensesService.refused(id, processInstanceId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/oneClickPayment")
|
||||
@Operation(summary = "一键支付")
|
||||
@Parameter(name = "month", description = "月份", required = true, example = "2025-04")
|
||||
public CommonResult<Boolean> oneClickPayment(String month) {
|
||||
|
||||
expensesService.oneClickPayment(month);
|
||||
return success(true);
|
||||
}
|
||||
}
|
@ -42,10 +42,10 @@ public class BpmOASalaryController {
|
||||
@Operation(summary = "创建请求申请")
|
||||
public CommonResult<Long> createSalary(@Valid @RequestBody BpmOASalaryCreateReqVO createReqVO) {
|
||||
|
||||
if (createReqVO.getFactoryId() != null) {
|
||||
DeptRespDTO dto = deptApi.getDeptByFactoryId(createReqVO.getFactoryId()).getCheckedData();
|
||||
createReqVO.setCompanyDeptId(dto.getId());
|
||||
}
|
||||
// if (createReqVO.getFactoryId() != null) {
|
||||
// DeptRespDTO dto = deptApi.getDeptByFactoryId(createReqVO.getFactoryId()).getCheckedData();
|
||||
// createReqVO.setCompanyDeptId(dto.getId());
|
||||
// }
|
||||
return success(salaryService.createSalary(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
|
@ -30,4 +30,7 @@ public class BpmOAExpensesPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "审批通过时间")
|
||||
private String[] endTime;
|
||||
|
||||
@Schema(description = "收款人姓名")
|
||||
private String payeeName;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class BpmOAPaymentCreateReqVO {
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Schema(description = "付款比例 | 针对分期付款情况", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Integer paymentRatio;
|
||||
private BigDecimal paymentRatio;
|
||||
|
||||
@Schema(description = "付款金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "付款金额不能为空")
|
||||
|
@ -68,7 +68,7 @@ public class BpmOAPaymentRespVO extends BpmOABaseRespVO {
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Schema(description = "付款比例 | 针对分期付款情况")
|
||||
private Integer paymentRatio;
|
||||
private BigDecimal paymentRatio;
|
||||
|
||||
@Schema(description = "付款金额")
|
||||
private BigDecimal amount;
|
||||
@ -92,7 +92,10 @@ public class BpmOAPaymentRespVO extends BpmOABaseRespVO {
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "累计付款比列")
|
||||
private Integer ratio;
|
||||
private BigDecimal ratio;
|
||||
|
||||
@Schema(description = "累计付款金额")
|
||||
private BigDecimal paymentAmount;
|
||||
|
||||
@Schema(description = "上传文件")
|
||||
private List<UploadUserFile> fileItems;
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 薪资付款申请 创建 Request VO
|
||||
@ -30,11 +31,15 @@ public class BpmOASalaryCreateReqVO {
|
||||
@DateTimeFormat(pattern = "yyyy-MM")
|
||||
private String salaryDate;
|
||||
|
||||
@Schema(description = "公司类型 | 1公司 2工厂", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "公司类型不能为空")
|
||||
private Integer deptType;
|
||||
|
||||
@Schema(description = "付款公司")
|
||||
private Long companyDeptId;
|
||||
|
||||
@Schema(description = "付款工厂编号")
|
||||
private Long factoryId;
|
||||
@Schema(description = "付款工厂的部门编号集合")
|
||||
private Set<Long> factoryDeptId;
|
||||
|
||||
@Schema(description = "付款总额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "付款总额不能为空")
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author 符溶馨
|
||||
@ -27,12 +28,21 @@ public class BpmOASalaryRespVO extends BpmOABaseRespVO {
|
||||
@DateTimeFormat(pattern = "yyyy-MM")
|
||||
private String salaryDate;
|
||||
|
||||
@Schema(description = "公司类型 | 1公司 2工厂")
|
||||
private Integer deptType;
|
||||
|
||||
@Schema(description = "付款公司")
|
||||
private Long companyDeptId;
|
||||
|
||||
@Schema(description = "付款公司名称")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "付款工厂的部门编号集合")
|
||||
private Set<Long> factoryDeptId;
|
||||
|
||||
@Schema(description = "付款工厂名称")
|
||||
private String factoryName;
|
||||
|
||||
@Schema(description = "付款工厂")
|
||||
private Long FactoryId;
|
||||
|
||||
|
@ -78,9 +78,9 @@ public class BpmOAPaymentDO extends BaseDO {
|
||||
private Long bankId;
|
||||
|
||||
/**
|
||||
* 付款方式 | 1预付款 2分期付款 3全额付款
|
||||
* 付款方式 | 1分批付款 3全额付款 4指定金额付款
|
||||
*/
|
||||
private Integer paymentMethod;
|
||||
private BigDecimal paymentMethod;
|
||||
|
||||
/**
|
||||
* 付款总额 | 针对预付款、分期付款情况
|
||||
|
@ -64,11 +64,11 @@ public class BpmOAReimbursementDO extends BaseDO {
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 报销明细数据JSON
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Reimbursement> reimbursements;
|
||||
// /**
|
||||
// * 报销明细数据JSON
|
||||
// */
|
||||
// @TableField(typeHandler = JacksonTypeHandler.class)
|
||||
// private List<Reimbursement> reimbursements;
|
||||
/**
|
||||
* 总报销金额
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.salary.SalarySubjectItemsVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
@ -12,6 +13,7 @@ import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* OA 薪资付款 DO
|
||||
@ -50,11 +52,22 @@ public class BpmOASalaryDO extends BaseDO {
|
||||
*/
|
||||
private String salaryDate;
|
||||
|
||||
/**
|
||||
* 公司类型 | 1公司 2工厂
|
||||
*/
|
||||
private Integer deptType;
|
||||
|
||||
/**
|
||||
* 付款公司
|
||||
*/
|
||||
private Long companyDeptId;
|
||||
|
||||
/**
|
||||
* 付款工厂的部门编号集合
|
||||
*/
|
||||
@TableField(typeHandler = JsonLongSetTypeHandler.class)
|
||||
private Set<Long> factoryDeptId;
|
||||
|
||||
/**
|
||||
* 付款总额
|
||||
*/
|
||||
|
@ -16,4 +16,6 @@ public interface BpmOAExpensesMapper extends BaseMapperX<BpmOAExpensesDO> {
|
||||
@Param("pageReqVO") BpmOAExpensesPageReqVO pageReqVO);
|
||||
|
||||
BpmOAExpensesTotal selectTotal(@Param("pageReqVO") BpmOAExpensesPageReqVO pageReqVO);
|
||||
|
||||
void oneClickPayment(@Param("month") String month);
|
||||
}
|
||||
|
@ -91,4 +91,10 @@ public interface BpmOAExpensesService {
|
||||
* @param processInstanceId 流程实例编号
|
||||
*/
|
||||
void refused(Long id, String processInstanceId);
|
||||
|
||||
/**
|
||||
* 一键支付
|
||||
* @param month 月份
|
||||
*/
|
||||
void oneClickPayment(String month);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -265,7 +266,10 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(expenses.getUserId());
|
||||
|
||||
// 获取收款人信息
|
||||
BankRespDTO bankRespDTO = bankApi.getBank(expenses.getBankId()).getCheckedData();
|
||||
BankRespDTO bankRespDTO = null;
|
||||
if (expenses.getBankId() != null) {
|
||||
bankRespDTO = bankApi.getBank(expenses.getBankId()).getCheckedData();
|
||||
}
|
||||
|
||||
// 获取付款公司信息
|
||||
FactoryInfoDTO dto = new FactoryInfoDTO();
|
||||
@ -285,7 +289,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setRecipientName(bankRespDTO.getNickname())
|
||||
.setRecipientName(bankRespDTO != null ? bankRespDTO.getNickname() : "")
|
||||
.setCompanyFactoryId(dto.getId())
|
||||
);
|
||||
}
|
||||
@ -311,4 +315,10 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
|
||||
// 同步更新流程实例表
|
||||
processInstanceService.updateProcessInstanceResult(processInstanceId, BpmProcessInstanceResultEnum.BACK.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oneClickPayment(String month) {
|
||||
|
||||
expensesMapper.oneClickPayment(month);
|
||||
}
|
||||
}
|
||||
|
@ -70,12 +70,14 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
salaryMapper.insert(salary) ;
|
||||
|
||||
// 获取申请公司或工厂信息
|
||||
DeptRespDTO dto = deptApi.getDept(salary.getCompanyDeptId()).getCheckedData();
|
||||
|
||||
// 配置申请公司或工厂部门flag
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
processInstanceVariables.put("company_dept_flag", dto.getFlag());
|
||||
if (createReqVO.getDeptType() == 1) {
|
||||
// 获取申请公司信息
|
||||
DeptRespDTO dto = deptApi.getDept(salary.getCompanyDeptId()).getCheckedData();
|
||||
processInstanceVariables.put("company_dept_flag", dto.getFlag());
|
||||
}
|
||||
processInstanceVariables.put("dept_type", createReqVO.getDeptType());
|
||||
// 发起 BPM 流程
|
||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
@ -112,9 +114,6 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
|
||||
// -- 插入到财务支付表中
|
||||
CommonResult<AdminUserRespDTO> user = userApi.getUser(salaryDO.getUserId());
|
||||
|
||||
// 从缓存中部门所属公司信息
|
||||
DeptRespDTO deptRespDTO = deptApi.getDept(salaryDO.getCompanyDeptId()).getCheckedData();
|
||||
|
||||
financialPaymentService.save(new FinancialPaymentDO()
|
||||
.setUserId(salaryDO.getUserId())
|
||||
.setDeptId(user.getData() == null ? null : user.getData().getDeptId())
|
||||
@ -127,7 +126,7 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
|
||||
.setProcessInstanceName(processInstance.getName())
|
||||
.setBeginTime(processInstance.getCreateTime())
|
||||
.setEndTime(processInstance.getEndTime())
|
||||
.setCompanyId(deptRespDTO != null && deptRespDTO.getFactoryId() == null ? deptRespDTO.getId() : null)
|
||||
.setCompanyId(salaryDO.getDeptType() == 1 ? salaryDO.getCompanyDeptId() : null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?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="cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAExpensesMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
@ -50,6 +49,9 @@
|
||||
<if test="pageReqVO.costSection != null">
|
||||
AND a.cost_section = #{pageReqVO.costSection}
|
||||
</if>
|
||||
<if test="pageReqVO.payeeName != null">
|
||||
AND ub.nickname LIKE CONCAT('%', #{pageReqVO.payeeName}, '%')
|
||||
</if>
|
||||
<if test="pageReqVO.endTime != null and pageReqVO.endTime.length > 0">
|
||||
<if test="pageReqVO.endTime[0] != null">
|
||||
and DATE_FORMAT(c.end_time, '%Y-%m-%d') >= #{pageReqVO.endTime[0]}
|
||||
@ -70,6 +72,7 @@
|
||||
bpm_oa_expenses a
|
||||
LEFT JOIN bpm_oa_expenses_item b ON b.expenses_id = a.id
|
||||
LEFT JOIN bpm_process_instance_ext c ON c.process_instance_id = a.process_instance_id
|
||||
LEFT JOIN system_bank ub ON ub.id = a.bank_id
|
||||
WHERE
|
||||
a.deleted = 0
|
||||
AND b.deleted = 0
|
||||
@ -86,6 +89,9 @@
|
||||
<if test="pageReqVO.costSection != null">
|
||||
AND b.cost_section = #{pageReqVO.costSection}
|
||||
</if>
|
||||
<if test="pageReqVO.payeeName != null">
|
||||
AND ub.nickname LIKE CONCAT('%', #{pageReqVO.payeeName}, '%')
|
||||
</if>
|
||||
<if test="pageReqVO.endTime != null and pageReqVO.endTime.length > 0">
|
||||
<if test="pageReqVO.endTime[0] != null">
|
||||
and DATE_FORMAT(c.end_time, '%Y-%m-%d') >= #{pageReqVO.endTime[0]}
|
||||
@ -95,4 +101,14 @@
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="oneClickPayment">
|
||||
UPDATE bpm_oa_expenses e
|
||||
JOIN bpm_process_instance_ext b ON e.process_instance_id = b.process_instance_id
|
||||
SET e.STATUS = 1, e.amount_paid = e.total_money
|
||||
WHERE
|
||||
e.result = 2
|
||||
AND e.STATUS != 2
|
||||
AND DATE_FORMAT( b.end_time, '%Y-%m' ) = #{month}
|
||||
</update>
|
||||
</mapper>
|
||||
|
@ -17,7 +17,8 @@
|
||||
bank.nickname as nickname,
|
||||
bank.bank_no as bankNo,
|
||||
bank.bank_name as bankName,
|
||||
COALESCE(SUM( b.payment_ratio ), 0) + COALESCE(a.payment_ratio,0) AS ratio
|
||||
COALESCE(SUM( b.payment_ratio ), 0) + COALESCE(a.payment_ratio,0) AS ratio,
|
||||
COALESCE(SUM( b.amount ), 0) + COALESCE(a.amount, 0) AS paymentAmount
|
||||
FROM
|
||||
bpm_oa_payment a
|
||||
<if test="method != 1">
|
||||
@ -35,6 +36,6 @@
|
||||
GROUP BY
|
||||
a.id
|
||||
HAVING
|
||||
ratio < 100
|
||||
amount < total_amount
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user