6 changed files with 496 additions and 138 deletions
-
312src/main/java/com/example/demo/controller/cash/CashRefundController.java
-
8src/main/java/com/example/demo/domain/vo/cash/CashRecordDone.java
-
4src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java
-
221src/main/java/com/example/demo/service/cash/ProcessService.java
-
2src/main/resources/application-prod.yml
-
89src/main/resources/cashMapper/CashRefundMapper.xml
@ -1,97 +1,215 @@ |
|||
package com.example.demo.controller.cash; |
|||
|
|||
import com.example.demo.Util.JWTUtil; |
|||
import com.example.demo.domain.entity.Admin; |
|||
import com.example.demo.domain.vo.cash.CashCollection; |
|||
import com.example.demo.domain.vo.cash.CashRecordDone; |
|||
import com.example.demo.domain.vo.coin.Page; |
|||
import com.example.demo.domain.vo.coin.Result; |
|||
import com.example.demo.service.coin.MarketService; |
|||
import com.example.demo.serviceImpl.cash.CashRefundServiceImpl; |
|||
import com.github.pagehelper.PageInfo; |
|||
import jakarta.servlet.http.HttpServletRequest; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.ObjectUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.context.request.RequestContextHolder; |
|||
import org.springframework.web.context.request.ServletRequestAttributes; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @program: GOLD |
|||
* @ClassName RefundController |
|||
* @description: |
|||
* @author: huangqizhen |
|||
* @create: 2025−09-26 14:15 |
|||
* @Version 1.0 |
|||
**/ |
|||
@RestController |
|||
@RequestMapping("/Money") |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
@CrossOrigin |
|||
public class CashRefundController { |
|||
@Autowired |
|||
private CashRefundServiceImpl cashRefundServiceImpl; |
|||
@Autowired |
|||
MarketService marketService; |
|||
@PostMapping("/select") |
|||
public Result select(@RequestBody Page page) throws Exception { |
|||
// 获取当前请求对象 |
|||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|||
String token = request.getHeader("token"); |
|||
|
|||
// 解析 token 获取用户信息 |
|||
Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|||
List<String> userMarkets = Arrays.asList(StringUtils.split(admin.getMarkets(), ",")); |
|||
List<String> markets = marketService.getMarketIds(userMarkets); |
|||
|
|||
// 校验分页参数 |
|||
if (ObjectUtils.isEmpty(page.getPageNum())) { |
|||
return Result.error("页码数为空!"); |
|||
} |
|||
if (ObjectUtils.isEmpty(page.getPageSize())) { |
|||
return Result.error("页大小为空!"); |
|||
} |
|||
|
|||
// 获取传入的市场列表 |
|||
List<String> requestedMarkets = page.getCashRecordDone() != null ? page.getCashRecordDone().getMarkets() : null; |
|||
|
|||
// 权限校验逻辑 |
|||
if (markets.contains("9") || markets.contains("9999")) { |
|||
// 特权市场:9 或 9999,跳过权限校验,直接放行传入的 markets |
|||
// 如果业务需要,也可以在这里做空值处理 |
|||
if (page.getCashRecordDone() != null) { |
|||
// 保持 requestedMarkets 不变,原样接受 |
|||
// 可选:如果 requestedMarkets 为 null,可设为默认值或保持 null |
|||
} |
|||
} else { |
|||
// 普通用户:必须校验权限 |
|||
if (requestedMarkets == null || requestedMarkets.isEmpty()) { |
|||
page.getCashRecordDone().setMarkets(requestedMarkets); |
|||
} |
|||
if (!markets.containsAll(requestedMarkets)) { |
|||
return Result.error("无权限!请求的市场不在授权范围内。"); |
|||
} |
|||
// 校验通过,保持 requestedMarkets 不变 |
|||
} |
|||
return Result.success(cashRefundServiceImpl.select(page.getPageNum(),page.getPageSize(),page.getCashRecordDone())); |
|||
} |
|||
@PostMapping("/add") |
|||
public Result add(@RequestBody CashRecordDone cashCollection){ |
|||
return Result.success(cashRefundServiceImpl.add(cashCollection)); |
|||
} |
|||
@PostMapping("/update") |
|||
public Result update(@RequestBody CashRecordDone cashRecordDone){ |
|||
return Result.success(cashRefundServiceImpl.update(cashRecordDone)); |
|||
} |
|||
// @PostMapping("/local") |
|||
// public Result local(@RequestBody CashCollection cashCollection){ |
|||
// return Result.success(cashRefundServiceImpl.local(cashCollection)); |
|||
// } |
|||
} |
|||
//package com.example.demo.controller.cash; |
|||
// |
|||
// |
|||
//import com.example.demo.Util.JWTUtil; |
|||
//import com.example.demo.domain.entity.Admin; |
|||
//import com.example.demo.domain.vo.cash.CashCollection; |
|||
//import com.example.demo.domain.vo.cash.CashRecordDone; |
|||
//import com.example.demo.domain.vo.coin.Page; |
|||
//import com.example.demo.domain.vo.coin.Result; |
|||
//import com.example.demo.service.cash.ProcessService; |
|||
//import com.example.demo.service.coin.MarketService; |
|||
//import com.example.demo.serviceImpl.cash.CashRefundServiceImpl; |
|||
//import com.github.pagehelper.PageInfo; |
|||
//import jakarta.annotation.Resource; |
|||
//import jakarta.servlet.http.HttpServletRequest; |
|||
//import lombok.RequiredArgsConstructor; |
|||
//import lombok.extern.slf4j.Slf4j; |
|||
//import org.apache.commons.lang3.StringUtils; |
|||
//import org.flowable.engine.ProcessEngine; |
|||
//import org.flowable.engine.RepositoryService; |
|||
//import org.flowable.engine.RuntimeService; |
|||
//import org.flowable.engine.TaskService; |
|||
//import org.flowable.task.api.Task; |
|||
//import org.springframework.beans.factory.annotation.Autowired; |
|||
//import org.springframework.util.ObjectUtils; |
|||
//import org.springframework.web.bind.annotation.*; |
|||
//import org.springframework.web.context.request.RequestContextHolder; |
|||
//import org.springframework.web.context.request.ServletRequestAttributes; |
|||
// |
|||
//import java.util.Arrays; |
|||
//import java.util.HashMap; |
|||
//import java.util.List; |
|||
//import java.util.Map; |
|||
// |
|||
///** |
|||
// * @program: GOLD |
|||
// * @ClassName RefundController |
|||
// * @description: |
|||
// * @author: huangqizhen |
|||
// * @create: 2025−09-26 14:15 |
|||
// * @Version 1.0 |
|||
// **/ |
|||
//@RestController |
|||
//@RequestMapping("/Money") |
|||
//@RequiredArgsConstructor |
|||
//@Slf4j |
|||
//@CrossOrigin |
|||
//public class CashRefundController { |
|||
// @Autowired |
|||
// private CashRefundServiceImpl cashRefundServiceImpl; |
|||
// @Autowired |
|||
// MarketService marketService; |
|||
// @Resource |
|||
// private RepositoryService repositoryService; |
|||
// @Resource |
|||
// private RuntimeService runtimeService; |
|||
// @Resource |
|||
// private TaskService taskService; |
|||
// @Resource |
|||
// private ProcessEngine processEngine; |
|||
// @Autowired |
|||
// private ProcessService processService; |
|||
// @PostMapping("/select") |
|||
// public Result select(@RequestBody Page page) throws Exception { |
|||
// // 获取当前请求对象 |
|||
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|||
// String token = request.getHeader("token"); |
|||
// |
|||
//// 解析 token 获取用户信息 |
|||
// Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|||
// List<String> userMarkets = Arrays.asList(StringUtils.split(admin.getMarkets(), ",")); |
|||
// List<String> markets = marketService.getMarketIds(userMarkets); |
|||
// |
|||
//// 校验分页参数 |
|||
// if (ObjectUtils.isEmpty(page.getPageNum())) { |
|||
// return Result.error("页码数为空!"); |
|||
// } |
|||
// if (ObjectUtils.isEmpty(page.getPageSize())) { |
|||
// return Result.error("页大小为空!"); |
|||
// } |
|||
// |
|||
//// 获取传入的市场列表 |
|||
// List<String> requestedMarkets = page.getCashRecordDone() != null ? page.getCashRecordDone().getMarkets() : null; |
|||
// |
|||
//// 权限校验逻辑 |
|||
// if (markets.contains("9") || markets.contains("9999")) { |
|||
// // 特权市场:9 或 9999,跳过权限校验,直接放行传入的 markets |
|||
// // 如果业务需要,也可以在这里做空值处理 |
|||
// if (page.getCashRecordDone() != null) { |
|||
// // 保持 requestedMarkets 不变,原样接受 |
|||
// // 可选:如果 requestedMarkets 为 null,可设为默认值或保持 null |
|||
// } |
|||
// } else { |
|||
// // 普通用户:必须校验权限 |
|||
// if (requestedMarkets == null || requestedMarkets.isEmpty()) { |
|||
// page.getCashRecordDone().setMarkets(requestedMarkets); |
|||
// } |
|||
// if (!markets.containsAll(requestedMarkets)) { |
|||
// return Result.error("无权限!请求的市场不在授权范围内。"); |
|||
// } |
|||
// // 校验通过,保持 requestedMarkets 不变 |
|||
// } |
|||
// return Result.success(cashRefundServiceImpl.select(page.getPageNum(),page.getPageSize(),page.getCashRecordDone())); |
|||
// } |
|||
// @PostMapping("/add") |
|||
// public Result add(@RequestBody CashRecordDone cashCollection){ |
|||
// return Result.success(cashRefundServiceImpl.add(cashCollection)); |
|||
// } |
|||
// @PostMapping("/update") |
|||
// public Result update(@RequestBody CashRecordDone cashRecordDone){ |
|||
// return Result.success(cashRefundServiceImpl.update(cashRecordDone)); |
|||
// } |
|||
// |
|||
// |
|||
// |
|||
// |
|||
// |
|||
// |
|||
// |
|||
// /** |
|||
// * 当地财务审核 |
|||
// */ |
|||
// @PostMapping("/local-finance/approve") |
|||
// public Map<String, Object> localFinanceApprove( |
|||
// @RequestParam String taskId, |
|||
// @RequestParam boolean approved, |
|||
// @RequestParam(required = false) String comment) { |
|||
// |
|||
// processService.localFinanceApprove(taskId, approved, comment); |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// result.put("success", true); |
|||
// result.put("message", approved ? "当地财务审核通过" : "当地财务已驳回"); |
|||
// |
|||
// return result; |
|||
// } |
|||
// |
|||
// /** |
|||
// * 地区负责人审核 |
|||
// */ |
|||
// @PostMapping("/regional-manager/approve") |
|||
// public Map<String, Object> regionalManagerApprove( |
|||
// @RequestParam String taskId, |
|||
// @RequestParam boolean approved, |
|||
// @RequestParam(required = false) String comment) { |
|||
// |
|||
// processService.regionalManagerApprove(taskId, approved, comment); |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// result.put("success", true); |
|||
// result.put("message", approved ? "地区负责人审核通过" : "地区负责人已驳回"); |
|||
// |
|||
// return result; |
|||
// } |
|||
// |
|||
// /** |
|||
// * 总部财务审批 |
|||
// */ |
|||
// @PostMapping("/head-finance/approve") |
|||
// public Map<String, Object> headFinanceApprove( |
|||
// @RequestParam String taskId, |
|||
// @RequestParam boolean approved, |
|||
// @RequestParam(required = false) String comment) { |
|||
// |
|||
// processService.headFinanceApprove(taskId, approved, comment); |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// result.put("success", true); |
|||
// result.put("message", approved ? "总部财务审批通过" : "总部财务已驳回"); |
|||
// |
|||
// return result; |
|||
// } |
|||
// |
|||
// /** |
|||
// * 提交审批申请 |
|||
// */ |
|||
// @PostMapping("/submit") |
|||
// public Map<String, Object> submitApproval(@RequestBody CashRecordDone order) { |
|||
// return processService.submitApproval(order); |
|||
// } |
|||
// |
|||
// /** |
|||
// * 获取待办审批列表 |
|||
// */ |
|||
// @GetMapping("/pending/{assignee}") |
|||
// public Map<String, Object> getPendingApprovals(@PathVariable String assignee) { |
|||
// List<CashRecordDone> approvals = processService.getPendingApprovals(assignee); |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// result.put("success", true); |
|||
// result.put("data", approvals); |
|||
// result.put("count", approvals.size()); |
|||
// |
|||
// return result; |
|||
// } |
|||
// |
|||
// /** |
|||
// * 获取审批详情 |
|||
// */ |
|||
// @GetMapping("/detail/{orderId}") |
|||
// public Map<String, Object> getApprovalDetail(@PathVariable Long orderId) { |
|||
// Map<String, Object> detail = processService.getApprovalDetail(orderId); |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// if (detail != null) { |
|||
// result.put("success", true); |
|||
// result.put("data", detail); |
|||
// } else { |
|||
// result.put("success", false); |
|||
// result.put("message", "审批单不存在"); |
|||
// } |
|||
// |
|||
// return result; |
|||
// } |
|||
//} |
|||
@ -0,0 +1,221 @@ |
|||
//package com.example.demo.service.cash; |
|||
// |
|||
// |
|||
//import com.example.demo.domain.vo.cash.CashRecordDone; |
|||
//import com.example.demo.mapper.cash.CashRefundMapper; |
|||
//import org.flowable.engine.*; |
|||
//import org.flowable.engine.runtime.ProcessInstance; |
|||
//import org.flowable.task.api.Task; |
|||
//import org.springframework.beans.factory.annotation.Autowired; |
|||
//import org.springframework.stereotype.Service; |
|||
//import org.springframework.transaction.annotation.Transactional; |
|||
// |
|||
//import java.util.HashMap; |
|||
//import java.util.List; |
|||
//import java.util.Map; |
|||
//import java.util.UUID; |
|||
// |
|||
//@Service |
|||
//@Transactional |
|||
//public class ProcessService { |
|||
// |
|||
// @Autowired |
|||
// private RuntimeService runtimeService; |
|||
// |
|||
// @Autowired |
|||
// private TaskService taskService; |
|||
// |
|||
// @Autowired |
|||
// private RepositoryService repositoryService; |
|||
// |
|||
// @Autowired |
|||
// private HistoryService historyService; |
|||
// |
|||
// @Autowired |
|||
// private CashRefundMapper cashRefundMapper; // 新增 |
|||
// |
|||
// /** |
|||
// * 提交审批申请 |
|||
// */ |
|||
// public Map<String, Object> submitApproval(CashRecordDone order) { |
|||
// // 生成订单号 |
|||
// String orderNumber = UUID.randomUUID().toString().replaceAll("-", ""); |
|||
// order.setOrderCode("XJTK" + orderNumber); |
|||
// order.setStatus(10); // 待提交 |
|||
// order.setOrderType(2); |
|||
// |
|||
// // 保存业务数据 |
|||
// cashRefundMapper.insert(order); |
|||
// |
|||
// // 准备流程变量 |
|||
// Map<String, Object> variables = new HashMap<>(); |
|||
// variables.put("name", order.getName()); |
|||
// variables.put("payment_currency", order.getPaymentCurrency()); |
|||
// variables.put("payment_amount", order.getPaymentAmount()); |
|||
// variables.put("goods_name", order.getGoodsName()); |
|||
// variables.put("market", order.getMarket()); |
|||
// variables.put("activity", order.getActivity()); |
|||
// variables.put("goods_num", order.getGoodsNum()); |
|||
// variables.put("pay_type", order.getPayType()); |
|||
//// variables.put("received_market", order.getReceivedMarket()); |
|||
// variables.put("market_list", order.getMarkets()); |
|||
// variables.put("jwcode", order.getJwcode()); |
|||
// variables.put("voucher", order.getVoucher()); |
|||
//// variables.put("bank_code", order.getBankCode()); |
|||
// variables.put("refund_channels", order.getRefundChannels()); |
|||
// variables.put("refund_model", order.getRefundModel()); |
|||
// variables.put("refund_reason", order.getRefundReason()); |
|||
// variables.put("remark", order.getRemark()); |
|||
// variables.put("executor", order.getExecutor()); |
|||
// variables.put("id", order.getId()); |
|||
// |
|||
// // 启动流程 |
|||
// ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("work", variables); |
|||
// |
|||
// // 更新业务数据的流程信息 |
|||
// order.setProcessInstanceId(processInstance.getId()); |
|||
// |
|||
// // 获取第一个任务并更新当前处理人 |
|||
// Task currentTask = taskService.createTaskQuery() |
|||
// .processInstanceId(processInstance.getId()) |
|||
// .singleResult(); |
|||
// if (currentTask != null) { |
|||
// order.setCurrentTaskId(currentTask.getId()); |
|||
// order.setAuditId(currentTask.getAssignee()); |
|||
// order.setStatus(20); // 当地财务审核中 |
|||
// } |
|||
// |
|||
// cashRefundMapper.update(order); |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// result.put("success", true); |
|||
// result.put("orderId", order.getId()); |
|||
// result.put("processInstanceId", processInstance.getId()); |
|||
// result.put("taskId", currentTask != null ? currentTask.getId() : null); |
|||
// |
|||
// return result; |
|||
// } |
|||
// |
|||
// /** |
|||
// * 当地财务审核 |
|||
// */ |
|||
// public void localFinanceApprove(String taskId, boolean approved, String comment) { |
|||
// Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|||
// String processInstanceId = task.getProcessInstanceId(); |
|||
// |
|||
// // 更新业务数据 |
|||
// CashRecordDone order = cashRefundMapper.select(processInstanceId); |
|||
// if (order != null) { |
|||
// cashRefundMapper.update(order.getId(), comment); |
|||
// } |
|||
// |
|||
// String status = approved ? "20" : "12"; // 20=通过, 12=驳回 |
|||
// completeTask(taskId, status, comment, order); |
|||
// } |
|||
// |
|||
// /** |
|||
// * 地区负责人审核 |
|||
// */ |
|||
// public void regionalManagerApprove(String taskId, boolean approved, String comment) { |
|||
// Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|||
// String processInstanceId = task.getProcessInstanceId(); |
|||
// |
|||
// // 更新业务数据 |
|||
// CashRecordDone order = cashRefundMapper.select(processInstanceId); |
|||
// if (order != null) { |
|||
// cashRefundMapper.update(order.getId(), comment); |
|||
// } |
|||
// |
|||
// String status = approved ? "30" : "22"; // 30=通过, 22=驳回 |
|||
// completeTask(taskId, status, comment, order); |
|||
// } |
|||
// |
|||
// /** |
|||
// * 总部财务审批 |
|||
// */ |
|||
// public void headFinanceApprove(String taskId, boolean approved, String comment) { |
|||
// Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|||
// String processInstanceId = task.getProcessInstanceId(); |
|||
// |
|||
// // 更新业务数据 |
|||
// CashRecordDone order = cashRefundMapper.select(processInstanceId); |
|||
// if (order != null) { |
|||
// cashRefundMapper.update(order.getId(), comment); |
|||
// } |
|||
// |
|||
// String status = approved ? "40" : "32"; // 40=通过, 32=驳回 |
|||
// completeTask(taskId, status, comment, order); |
|||
// } |
|||
// |
|||
// /** |
|||
// * 完成任务并更新业务数据 |
|||
// */ |
|||
// private void completeTask(String taskId, String status, String comment, CashRecordDone order) { |
|||
// Map<String, Object> variables = new HashMap<>(); |
|||
// variables.put("status", status); |
|||
// |
|||
// // 添加审批意见 |
|||
// if (comment != null && !comment.trim().isEmpty()) { |
|||
// taskService.addComment(taskId, null, comment); |
|||
// } |
|||
// |
|||
// taskService.complete(taskId, variables); |
|||
// |
|||
// // 更新业务数据状态 |
|||
// if (order != null) { |
|||
// cashRefundMapper.update(order.getId(), status); |
|||
// |
|||
// // 如果不是结束状态,更新当前任务信息 |
|||
// if (!status.equals("12") && !status.equals("22") && !status.equals("32") && !status.equals("40")) { |
|||
// Task nextTask = taskService.createTaskQuery() |
|||
// .processInstanceId(order.getProcessInstanceId()) |
|||
// .singleResult(); |
|||
// if (nextTask != null) { |
|||
// order.setCurrentTaskId(nextTask.getId()); |
|||
// order.setCurrentAssignee(nextTask.getAssignee()); |
|||
// cashRefundMapper.update(order); |
|||
// } |
|||
// } |
|||
// } |
|||
// } |
|||
// |
|||
// /** |
|||
// * 根据用户获取待办审批 |
|||
// */ |
|||
// public List<CashRecordDone> getPendingApprovals(String assignee) { |
|||
// return cashRefundMapper.select(assignee); |
|||
// } |
|||
// |
|||
// /** |
|||
// * 根据申请人获取历史审批 |
|||
// */ |
|||
// public List<CashRecordDone> getApprovalHistory(String applicant) { |
|||
// return cashRefundMapper.select(applicant); |
|||
// } |
|||
// |
|||
// /** |
|||
// * 获取审批详情 |
|||
// */ |
|||
// public Map<String, Object> getApprovalDetail(Long orderId) { |
|||
// CashRecordDone order = cashRefundMapper.select(orderId); |
|||
// if (order == null) { |
|||
// return null; |
|||
// } |
|||
// |
|||
// Map<String, Object> result = new HashMap<>(); |
|||
// result.put("order", order); |
|||
// |
|||
// // 获取流程历史 |
|||
// if (order.getProcessInstanceId() != null) { |
|||
// Object history = historyService.createHistoricActivityInstanceQuery() |
|||
// .processInstanceId(order.getProcessInstanceId()) |
|||
// .orderByHistoricActivityInstanceStartTime().asc() |
|||
// .list(); |
|||
// result.put("processHistory", history); |
|||
// } |
|||
// |
|||
// return result; |
|||
// } |
|||
// |
|||
// // 其他方法保持不变... |
|||
//} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue