Browse Source

10.13 修改实体类与mapper

lihuilin1015备份
huangqizhen 1 month ago
parent
commit
09953628f0
  1. 310
      src/main/java/com/example/demo/controller/cash/CashRefundController.java
  2. 8
      src/main/java/com/example/demo/domain/vo/cash/CashRecordDone.java
  3. 4
      src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java
  4. 221
      src/main/java/com/example/demo/service/cash/ProcessService.java
  5. 2
      src/main/resources/application-prod.yml
  6. 89
      src/main/resources/cashMapper/CashRefundMapper.xml

310
src/main/java/com/example/demo/controller/cash/CashRefundController.java

@ -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: 202509-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: 202509-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;
// }
//}

8
src/main/java/com/example/demo/domain/vo/cash/CashRecordDone.java

@ -49,8 +49,10 @@ public class CashRecordDone {
private String payType;
/** 到账地区 */
private String receivedMarket;
private Date payTime; // 付款时间
private Date receivedTime; // 到账时间
/** 商品数量 */
private Integer goodsNum;
private Integer goodNum;
/** 审核人id */
private Integer auditId;
private Integer status;
@ -91,4 +93,8 @@ public class CashRecordDone {
private String submitterName;
private String auditName;
private String executorName;
private String processInstanceId; // 流程实例ID
private String currentTaskId; // 当前任务ID
}

4
src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java

@ -18,6 +18,6 @@ import java.util.List;
@Mapper
public interface CashRefundMapper {
List<CashCollection> select(CashRecordDone cashRecordDone);
int update(CashRecordDone cashCollection);
int insert(CashRecordDone cashCollection);
int update(CashRecordDone cashRecordDone);
int insert(CashRecordDone cashRecordDone);
}

221
src/main/java/com/example/demo/service/cash/ProcessService.java

@ -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;
// }
//
// // 其他方法保持不变...
//}

2
src/main/resources/application-prod.yml

@ -45,7 +45,7 @@ spring:
pool-name: mysql5HikariCP
maximum-pool-size: 10
sqlserver1:
jdbc-url: jdbc:sqlserver://52.76.43.43:1433;encrypt=true;sslProtocol=TLSv1;trustServerCertificate=true;
jdbc-url: jdbc:sqlserver://10.19.183.6:1433;encrypt=true;sslProtocol=TLSv1;trustServerCertificate=true;
username: gjb_test
password: qweuio!@#$2
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

89
src/main/resources/cashMapper/CashRefundMapper.xml

@ -16,7 +16,6 @@
payment_amount,
received_currency,
received_amount,
handling_charge,
received_market,
pay_type,
pay_time,
@ -104,68 +103,82 @@ status = #{status},
<select id="select" resultType="com.example.demo.domain.vo.cash.CashRecordDone">
select
id,
order_type,
jwcode,
name,
market,
activity,
order_code,
bank_code,
goods_name,
good_num,
payment_currency,
payment_amount,
audit_id,
status,
submitter_id,
voucher,
refund_reason,
refund_model,
executor,
refund_channels,
refund_time,
refund_remark,
refund_voucher,
remark,
reject_reason,
create_time,
update_time,
audit_time,
cr.id,
cr.order_type,
cr.jwcode,
cr.name,
cr.market,
cr.activity,
cr.order_code,
cr.bank_code,
cr.goods_name,
cr.good_num,
cr.payment_currency,
cr.payment_amount,
cr.received_currency,
cr.received_amount,
cr.handling_charge,
cr.pay_type,
cr.received_market,
cr.pay_time,
cr.received_time,
cr.audit_id,
cr.status,
cr.submitter_id,
cr.voucher,
cr.refund_reason,
cr.refund_model,
cr.executor,
cr.refund_channels,
cr.refund_time,
cr.refund_remark,
cr.refund_voucher,
cr.remark,
cr.reject_reason,
cr.create_time,
cr.update_time,
cr.audit_time,
a1.admin_name as submitterName,
a2.admin_name as auditName,
a3.admin_name as executorName
from cash_record
from cash_record cr
left join admin a1 on submitter_id = a1.id
left join admin a2 on audit_id = a2.id
left join admin a3 on executor = a3.account
<where>
<if test="status != null">
status = #{status}
cr.status = #{status}
</if>
<if test="orderCode != null">
and order_code = #{orderCode}
and cr.order_code = #{orderCode}
</if>
<if test="name != null and name.size > 0">
and name = #{name}
and cr.name = #{name}
</if>
<if test="jwcode != null">
and jwcode = #{jwcode}
and cr.jwcode = #{jwcode}
</if>
<if test="markets!= null and markets.size > 0">
AND market IN
AND cr.market IN
<foreach collection="markets" item="markets" open="(" separator="," close=")">
#{markets}
</foreach>
</if>
<if test="paymentCurrency!= null and paymentCurrency.size > 0">
AND cr.payment_currency = #{paymentCurrency}
</if>
<if test="goodsName != null and goodName.size>0">
and goods_name = #{goodsName}
and cr.goods_name = #{goodsName}
</if>
<if test="payTyoe != null and payTyoe.size>0">
and cr.pay_type = #{payTyoe}
</if>
<if test="refundModel != null and refundModel.size>0">
and refundModel = #{refundModel}
and cr.refundModel = #{refundModel}
</if>
<if test="startTime != null and endTime != null">
and `refund_time` BETWEEN #{startTime} AND #{endTime}
and cr.`pay_time` BETWEEN #{startTime} AND #{endTime}
</if>
</where>
</select>
Loading…
Cancel
Save