diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 58b0338..e54e693 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -77,6 +77,12 @@ xmlbeans 3.1.0 + + io.swagger + swagger-annotations + 1.6.2 + compile + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java index 4a5351e..0d1db32 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java @@ -10,15 +10,22 @@ import com.ruoyi.system.domain.Users; import com.ruoyi.system.domain.UsersInvoiceInfo; import com.ruoyi.system.service.IUsersService; import com.ruoyi.system.service.IUsersInvoiceInfoService; +import com.ruoyi.system.service.IPayMoneyLogService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.core.type.TypeReference; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; /** * 发票管理控制器 @@ -45,10 +52,13 @@ public class AppleInvoiceController extends BaseController { @Autowired private IUsersInvoiceInfoService usersInvoiceInfoService; + @Autowired + private IPayMoneyLogService payMoneyLogService; + private ObjectMapper objectMapper = new ObjectMapper(); /** - * 获取用户发票中心数据 + * 获取用户发票中心数据(基于支付记录数据源) * * @param params 请求参数 * @param request HTTP请求对象 @@ -74,8 +84,8 @@ public class AppleInvoiceController extends BaseController { int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 10; - // 4. 获取发票中心数据 - Map invoiceCenterData = InvoiceUtil.getUserInvoiceCenter(user.getId(), page, limit); + // 4. 基于支付记录获取发票中心数据 + Map invoiceCenterData = getInvoiceCenterDataFromPayLogs(user.getId(), page, limit); return AppletControllerUtil.appletSuccess(invoiceCenterData); @@ -83,9 +93,207 @@ public class AppleInvoiceController extends BaseController { return AppletControllerUtil.appletError("获取发票中心数据失败:" + e.getMessage()); } } + + /** + * 基于支付记录获取发票中心数据 + * + * @param userId 用户ID + * @param page 页码 + * @param limit 每页数量 + * @return 发票中心数据 + */ + private Map getInvoiceCenterDataFromPayLogs(Long userId, int page, int limit) { + Map result = new HashMap<>(); + + try { + // 1. 获取所有支付记录统计(按订单ID分组) + List> allOrderStats = payMoneyLogService.getOrderPriceStatistics(userId); + + // 2. 获取已开票记录 + List> completedInvoices = getCompletedInvoicesFromPayLogs(userId, page, limit); + + // 3. 获取待开票订单(过滤掉已开票的) + List> pendingInvoices = getPendingInvoicesFromPayLogs(allOrderStats, completedInvoices, page, limit); + + // 4. 统计数据 + Map statistics = getInvoiceStatisticsFromPayLogs(pendingInvoices, completedInvoices); + + result.put("pendingInvoices", pendingInvoices); + result.put("completedInvoices", completedInvoices); + result.put("statistics", statistics); + + } catch (Exception e) { + logger.error("获取发票中心数据失败", e); + // 返回空数据 + result.put("pendingInvoices", new ArrayList<>()); + result.put("completedInvoices", new ArrayList<>()); + result.put("statistics", new HashMap<>()); + } + + return result; + } + + /** + * 从支付记录获取已开票列表 + */ + private List> getCompletedInvoicesFromPayLogs(Long userId, int page, int limit) { + try { + // 设置分页 + com.github.pagehelper.PageHelper.startPage(page, limit); + + UsersInvoiceInfo query = new UsersInvoiceInfo(); + query.setUid(userId.intValue()); + List invoiceList = usersInvoiceInfoService.selectUsersInvoiceInfoList(query); + + List> completedInvoices = new ArrayList<>(); + for (UsersInvoiceInfo invoice : invoiceList) { + Map invoiceMap = new HashMap<>(); + invoiceMap.put("id", invoice.getId()); + invoiceMap.put("orderId", invoice.getOrderid()); + invoiceMap.put("invoiceTitle", invoice.getInvoiceTitle()); + invoiceMap.put("amount", invoice.getInvoicemoney()); + invoiceMap.put("invoiceText", invoice.getInvoicetext()); + invoiceMap.put("status", invoice.getStatus()); + invoiceMap.put("statusText", getInvoiceStatusText(invoice.getStatus())); + invoiceMap.put("type", invoice.getType()); + invoiceMap.put("typeText", getInvoiceTypeText(invoice.getType())); + invoiceMap.put("category", invoice.getCategory()); + invoiceMap.put("categoryText", invoice.getCategory() == 0 ? "个人" : "企业"); + invoiceMap.put("createTime", invoice.getCreatedAt()); + invoiceMap.put("hasFile", StringUtils.isNotEmpty(invoice.getFiledata())); + invoiceMap.put("fileUrl", invoice.getFiledata()); + completedInvoices.add(invoiceMap); + } + + return completedInvoices; + + } catch (Exception e) { + logger.error("获取已开票列表失败", e); + return new ArrayList<>(); + } + } + + /** + * 从支付记录获取待开票订单 + */ + private List> getPendingInvoicesFromPayLogs( + List> allOrderStats, + List> completedInvoices, + int page, int limit) { + + try { + List> pendingInvoices = new ArrayList<>(); + + // 获取已开票的订单ID集合 + Set invoicedOrderIds = new HashSet<>(); + for (Map invoice : completedInvoices) { + String orderId = (String) invoice.get("orderId"); + if (orderId != null) { + // 支持多个订单ID(逗号分隔) + String[] orderIds = orderId.split(","); + for (String id : orderIds) { + invoicedOrderIds.add(id.trim()); + } + } + } + + // 过滤出未开票的订单 + for (Map orderStat : allOrderStats) { + String orderId = (String) orderStat.get("orderId"); + if (orderId != null && !invoicedOrderIds.contains(orderId)) { + BigDecimal totalPrice = (BigDecimal) orderStat.get("totalPrice"); + if (totalPrice != null && totalPrice.compareTo(BigDecimal.ZERO) > 0) { + Map pendingOrder = new HashMap<>(); + pendingOrder.put("orderId", orderId); + pendingOrder.put("orderType", "payment"); // 支付记录订单 + pendingOrder.put("orderTypeText", "支付记录"); + pendingOrder.put("amount", totalPrice); + pendingOrder.put("title", "订单支付" + totalPrice + "元"); + pendingOrder.put("createTime", new java.util.Date()); // 使用当前时间作为默认值 + pendingOrder.put("canInvoice", true); + pendingInvoices.add(pendingOrder); + } + } + } + + // 分页处理 + int startIndex = (page - 1) * limit; + int endIndex = Math.min(startIndex + limit, pendingInvoices.size()); + if (startIndex < pendingInvoices.size()) { + return pendingInvoices.subList(startIndex, endIndex); + } + + return new ArrayList<>(); + + } catch (Exception e) { + logger.error("获取待开票订单失败", e); + return new ArrayList<>(); + } + } + + /** + * 基于支付记录获取发票统计数据 + */ + private Map getInvoiceStatisticsFromPayLogs( + List> pendingInvoices, + List> completedInvoices) { + + Map statistics = new HashMap<>(); + + try { + // 待开票数量 + int pendingCount = pendingInvoices.size(); + + // 已开票数量 + int completedCount = completedInvoices.size(); + + // 已开票总金额 + BigDecimal totalAmount = completedInvoices.stream() + .filter(invoice -> invoice.get("amount") != null) + .map(invoice -> (BigDecimal) invoice.get("amount")) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + statistics.put("pendingCount", pendingCount); + statistics.put("completedCount", completedCount); + statistics.put("totalAmount", totalAmount); + + } catch (Exception e) { + logger.error("获取发票统计数据失败", e); + statistics.put("pendingCount", 0); + statistics.put("completedCount", 0); + statistics.put("totalAmount", BigDecimal.ZERO); + } + + return statistics; + } + + /** + * 获取发票状态文本 + */ + private String getInvoiceStatusText(Integer status) { + if (status == null) return "未知"; + switch (status) { + case 0: return "待开票"; + case 1: return "已开票"; + case 2: return "已作废"; + default: return "未知"; + } + } + + /** + * 获取发票类型文本 + */ + private String getInvoiceTypeText(Integer type) { + if (type == null) return "未知"; + switch (type) { + case 0: return "普通发票"; + case 1: return "专用发票"; + default: return "未知"; + } + } /** - * 获取待开票订单列表 + * 获取待开票订单列表(基于支付记录数据源) * * @param params 请求参数 * @param request HTTP请求对象 @@ -111,8 +319,10 @@ public class AppleInvoiceController extends BaseController { int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 10; - // 4. 获取待开票订单列表 - List> pendingOrders = InvoiceUtil.getPendingInvoiceOrders(user.getId(), page, limit); + // 4. 基于支付记录获取待开票订单列表 + List> allOrderStats = payMoneyLogService.getOrderPriceStatistics(user.getId()); + List> completedInvoices = getCompletedInvoicesFromPayLogs(user.getId(), 1, 1000); + List> pendingOrders = getPendingInvoicesFromPayLogs(allOrderStats, completedInvoices, page, limit); return AppletControllerUtil.appletSuccess(pendingOrders); @@ -122,7 +332,7 @@ public class AppleInvoiceController extends BaseController { } /** - * 获取已开票列表 + * 获取已开票列表(基于支付记录数据源) * * @param params 请求参数 * @param request HTTP请求对象 @@ -148,8 +358,8 @@ public class AppleInvoiceController extends BaseController { int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 10; - // 4. 获取已开票列表 - List> completedInvoices = InvoiceUtil.getCompletedInvoices(user.getId(), page, limit); + // 4. 基于支付记录获取已开票列表 + List> completedInvoices = getCompletedInvoicesFromPayLogs(user.getId(), page, limit); return AppletControllerUtil.appletSuccess(completedInvoices); @@ -158,9 +368,200 @@ public class AppleInvoiceController extends BaseController { } } +// /** +// * 开具发票接口 +// * +// * @param params 发票参数 +// * @param request HTTP请求对象 +// * @return 开票结果 +// */ +// @PostMapping("/create") +// public AjaxResult createInvoice(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning(""); +// } +// +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning(""); +// } +// +// // 3. 获取订单ID +// String orderId = params.get("orderId") != null ? params.get("orderId").toString() : null; +// if (StringUtils.isEmpty(orderId)) { +// return AppletControllerUtil.appletWarning("订单ID不能为空"); +// } +// +// // 4. 调用IPayMoneyLogService查询开票金额 +// List> orderStats = payMoneyLogService.getOrderPriceStatistics(); +// BigDecimal invoiceAmount = null; +// +// for (Map orderStat : orderStats) { +// String statOrderId = (String) orderStat.get("orderId"); +// if (orderId.equals(statOrderId)) { +// invoiceAmount = (BigDecimal) orderStat.get("totalPrice"); +// break; +// } +// } +// +// if (invoiceAmount == null || invoiceAmount.compareTo(BigDecimal.ZERO) <= 0) { +// return AppletControllerUtil.appletWarning("订单不存在或金额为0,无法开票"); +// } +// +// // 5. 直接调用开票方法 +// AjaxResult invoiceResult = InvoiceUtil.createBatchInvoice(user.getId(), List.of(orderId), params); +// +// return invoiceResult; +// +// } catch (Exception e) { +// return AppletControllerUtil.appletError("开具发票失败:" + e.getMessage()); +// } +// } + +// /** +// * 开具发票接口(支持批量开票) +// * +// * @param params 发票参数 +// * @param request HTTP请求对象 +// * @return 开票结果 +// */ +// @PostMapping("/create") +// public AjaxResult createInvoice(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning(""); +// } +// +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning(""); +// } +// +// // 3. 获取订单ID数组 +// Object orderIdsObj = params.get("orderIds"); +// if (orderIdsObj == null) { +// return AppletControllerUtil.appletWarning("订单ID列表不能为空"); +// } +// +// List orderIds; +// if (orderIdsObj instanceof List) { +// orderIds = (List) orderIdsObj; +// } else if (orderIdsObj instanceof String) { +// // 如果是字符串,尝试解析 +// String orderIdsStr = orderIdsObj.toString(); +// orderIds = objectMapper.readValue(orderIdsStr, new TypeReference>() {}); +// } else { +// return AppletControllerUtil.appletWarning("订单ID格式错误"); +// } +// +// if (orderIds.isEmpty()) { +// return AppletControllerUtil.appletWarning("订单ID列表不能为空"); +// } +// +// // 4. 调用IPayMoneyLogService查询开票金额 +// List> orderStats = payMoneyLogService.getOrderPriceStatistics(); +// List validOrderIds = new ArrayList<>(); +// BigDecimal totalAmount = BigDecimal.ZERO; +// +// for (String orderId : orderIds) { +// for (Map orderStat : orderStats) { +// String statOrderId = (String) orderStat.get("orderId"); +// if (orderId.equals(statOrderId)) { +// BigDecimal amount = (BigDecimal) orderStat.get("totalPrice"); +// if (amount != null && amount.compareTo(BigDecimal.ZERO) > 0) { +// validOrderIds.add(orderId); +// totalAmount = totalAmount.add(amount); +// } +// break; +// } +// } +// } +// +// if (validOrderIds.isEmpty()) { +// return AppletControllerUtil.appletWarning("没有找到有效的订单或金额为0,无法开票"); +// } +// +// // 5. 直接调用开票方法 +// AjaxResult invoiceResult = InvoiceUtil.createBatchInvoice(user.getId(), validOrderIds, params); +// +// return invoiceResult; +// +// } catch (Exception e) { +// return AppletControllerUtil.appletError("开具发票失败:" + e.getMessage()); +// } +// } + + + +// /** +// * 开具发票接口(支持批量开票) +// * +// * @param params 发票参数 +// * @param request HTTP请求对象 +// * @return 开票结果 +// */ +// @PostMapping("/create") +// public AjaxResult createInvoice(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletdengluWarning(""); +// } +// +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletdengluWarning(""); +// } +// +// // 3. 获取订单ID数组 +// Object orderIdsObj = params.get("orderIds"); +// if (orderIdsObj == null) { +// return AppletControllerUtil.appletWarning("订单ID列表不能为空"); +// } +// +// List orderIds; +// if (orderIdsObj instanceof List) { +// orderIds = (List) orderIdsObj; +// } else if (orderIdsObj instanceof String) { +// // 如果是字符串,尝试解析 +// String orderIdsStr = orderIdsObj.toString(); +// orderIds = objectMapper.readValue(orderIdsStr, new TypeReference>() {}); +// } else { +// return AppletControllerUtil.appletWarning("订单ID格式错误"); +// } +// +// if (orderIds.isEmpty()) { +// return AppletControllerUtil.appletWarning("订单ID列表不能为空"); +// } +// +// // 4. 直接调用开票方法,不做复杂的验证 +// // 让 InvoiceUtil.createBatchInvoice 自己处理订单验证 +// AjaxResult invoiceResult = InvoiceUtil.createBatchInvoice(user.getId(), orderIds, params); +// +// return invoiceResult; +// +// } catch (Exception e) { +// return AppletControllerUtil.appletError("开具发票失败:" + e.getMessage()); +// } +// } + + + /** * 开具发票接口(支持批量开票) - * + * * @param params 发票参数 * @param request HTTP请求对象 * @return 开票结果 @@ -168,9 +569,6 @@ public class AppleInvoiceController extends BaseController { @PostMapping("/create") public AjaxResult createInvoice(@RequestBody Map params, HttpServletRequest request) { try { - // 调试日志:输出接收到的原始参数 - System.out.println("接收到的原始参数: " + params); - // 1. 验证用户登录状态 String token = request.getHeader("token"); Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); @@ -184,65 +582,109 @@ public class AppleInvoiceController extends BaseController { return AppletControllerUtil.appletdengluWarning(""); } - // 3. 验证必要参数 - List orderIds = new ArrayList<>(); - - // 支持多种参数格式:orderIds数组、orderIds字符串数组、单个orderId - if (params.get("orderIds") != null) { - Object orderIdsObj = params.get("orderIds"); - - if (orderIdsObj instanceof List) { - // 批量开票:orderIds数组 - List orderIdList = (List) orderIdsObj; - for (Object orderIdObj : orderIdList) { - if (orderIdObj != null) { - orderIds.add(orderIdObj.toString()); - } - } - } else if (orderIdsObj instanceof String) { - // 处理字符串格式的数组,如 "['B1750646653464697','B1750413502322711']" - String orderIdsStr = orderIdsObj.toString(); - - // 去掉外层的方括号和引号 - orderIdsStr = orderIdsStr.trim(); - if (orderIdsStr.startsWith("[") && orderIdsStr.endsWith("]")) { - orderIdsStr = orderIdsStr.substring(1, orderIdsStr.length() - 1); - } - - // 按逗号分割并清理每个订单ID - String[] orderIdArray = orderIdsStr.split(","); - for (String orderId : orderIdArray) { - orderId = orderId.trim(); - // 去掉单引号或双引号 - if ((orderId.startsWith("'") && orderId.endsWith("'")) || - (orderId.startsWith("\"") && orderId.endsWith("\""))) { - orderId = orderId.substring(1, orderId.length() - 1); - } - if (StringUtils.isNotEmpty(orderId)) { - orderIds.add(orderId); + // 3. 获取订单ID数组 + Object orderIdsObj = params.get("orderIds"); + if (orderIdsObj == null) { + return AppletControllerUtil.appletWarning("订单ID列表不能为空"); + } + + List orderIds; + if (orderIdsObj instanceof List) { + orderIds = (List) orderIdsObj; + } else if (orderIdsObj instanceof String) { + String orderIdsStr = orderIdsObj.toString(); + orderIds = objectMapper.readValue(orderIdsStr, new TypeReference>() {}); + } else { + return AppletControllerUtil.appletWarning("订单ID格式错误"); + } + + if (orderIds.isEmpty()) { + return AppletControllerUtil.appletWarning("订单ID列表不能为空"); + } + + // 4. 使用IPayMoneyLogService查询订单金额 + List> orderStats = payMoneyLogService.getOrderPriceStatistics(user.getId()); + List validOrderIds = new ArrayList<>(); + BigDecimal totalAmount = BigDecimal.ZERO; + + for (String orderId : orderIds) { + for (Map orderStat : orderStats) { + String statOrderId = (String) orderStat.get("orderId"); + if (orderId.equals(statOrderId)) { + BigDecimal amount = (BigDecimal) orderStat.get("totalPrice"); + if (amount != null && amount.compareTo(BigDecimal.ZERO) > 0) { + validOrderIds.add(orderId); + totalAmount = totalAmount.add(amount); } + break; } } - } else if (params.get("orderId") != null) { - // 单个开票:orderId字符串(兼容旧版本) - orderIds.add(params.get("orderId").toString()); } - - if (orderIds.isEmpty()) { - return AppletControllerUtil.appletWarning("请选择要开票的订单"); - } - - // 调试日志:输出解析后的订单ID列表 - System.out.println("解析后的订单ID列表: " + orderIds); - // 4. 调用批量开票方法 - return InvoiceUtil.createBatchInvoice(user.getId(), orderIds, params); + if (validOrderIds.isEmpty()) { + return AppletControllerUtil.appletWarning("没有找到有效的订单或金额为0,无法开票"); + } + +// // 5. 直接创建发票记录,不使用InvoiceUtil.createBatchInvoice +// // 这里需要调用发票服务直接创建发票 +// for (String orderId : validOrderIds) { +// // 创建发票记录 +// UsersInvoiceInfo invoiceInfo = new UsersInvoiceInfo(); +// invoiceInfo.setUid(user.getId().intValue()); +// invoiceInfo.setOrderid(orderId); +// invoiceInfo.setInvoiceTitle((String) params.get("invoiceTitle")); +// invoiceInfo.setType((Integer) params.get("type")); +// invoiceInfo.setCategory((Integer) params.get("category")); +// invoiceInfo.setTaxNumber((String) params.get("taxNumber")); +// invoiceInfo.setBankName((String) params.get("bankName")); +// invoiceInfo.setAddress((String) params.get("address")); +// invoiceInfo.setBankAccount((String) params.get("bankAccount")); +// invoiceInfo.setPhone((String) params.get("phone")); +// invoiceInfo.setEmail((String) params.get("email")); +// invoiceInfo.setWechat((String) params.get("wechat")); +// invoiceInfo.setStatus(1); // 已开票 +// invoiceInfo.setInvoicemoney(totalAmount); +// invoiceInfo.setInvoicetext("批量开票"); +// +// // 保存发票记录 +// usersInvoiceInfoService.insertUsersInvoiceInfo(invoiceInfo); +// } + // 5. 直接创建发票记录,不使用InvoiceUtil.createBatchInvoice + // 这里需要调用发票服务直接创建发票 + // 只创建一张发票,包含所有订单ID + UsersInvoiceInfo invoiceInfo = new UsersInvoiceInfo(); + invoiceInfo.setUid(user.getId().intValue()); + invoiceInfo.setOrderid(String.join(",", validOrderIds)); // 用逗号分隔所有订单ID + invoiceInfo.setInvoiceTitle((String) params.get("invoiceTitle")); + invoiceInfo.setType((Integer) params.get("type")); + invoiceInfo.setCategory((Integer) params.get("category")); + invoiceInfo.setTaxNumber((String) params.get("taxNumber")); + invoiceInfo.setBankName((String) params.get("bankName")); + invoiceInfo.setAddress((String) params.get("address")); + invoiceInfo.setBankAccount((String) params.get("bankAccount")); + invoiceInfo.setPhone((String) params.get("phone")); + invoiceInfo.setEmail((String) params.get("email")); + invoiceInfo.setWechat((String) params.get("wechat")); + invoiceInfo.setStatus(1); // 已开票 + invoiceInfo.setInvoicemoney(totalAmount); // 总金额 + invoiceInfo.setInvoicetext("批量开票"); + + // 保存发票记录 + usersInvoiceInfoService.insertUsersInvoiceInfo(invoiceInfo); + + Map result = new HashMap<>(); + result.put("message", "发票开具成功"); + result.put("orderIds", validOrderIds); + result.put("totalAmount", totalAmount); + + return AppletControllerUtil.appletSuccess(result); } catch (Exception e) { return AppletControllerUtil.appletError("开具发票失败:" + e.getMessage()); } } + /** * 获取用户已保存的发票信息 * @@ -276,7 +718,7 @@ public class AppleInvoiceController extends BaseController { } /** - * 获取发票统计数据 + * 获取发票统计数据(基于支付记录数据源) * * @param request HTTP请求对象 * @return 统计数据 @@ -297,8 +739,11 @@ public class AppleInvoiceController extends BaseController { return AppletControllerUtil.appletdengluWarning(""); } - // 3. 获取统计数据 - Map statistics = InvoiceUtil.getInvoiceStatistics(user.getId()); + // 3. 基于支付记录获取统计数据 + List> allOrderStats = payMoneyLogService.getOrderPriceStatistics(user.getId()); + List> completedInvoices = getCompletedInvoicesFromPayLogs(user.getId(), 1, 1000); + List> pendingInvoices = getPendingInvoicesFromPayLogs(allOrderStats, completedInvoices, 1, 1000); + Map statistics = getInvoiceStatisticsFromPayLogs(pendingInvoices, completedInvoices); return AppletControllerUtil.appletSuccess(statistics); @@ -502,4 +947,5 @@ public class AppleInvoiceController extends BaseController { return AppletControllerUtil.appletError("获取发票详情失败:" + e.getMessage()); } } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java index 8536fbd..97df121 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java @@ -708,7 +708,7 @@ public class AppleOrderController extends BaseController { HttpServletRequest request) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - + // 1. 验证分页参数 Map pageValidation = PageUtil.validatePageParams(pageNum, pageSize); if (!(Boolean) pageValidation.get("valid")) { @@ -6147,6 +6147,7 @@ public class AppleOrderController extends BaseController { @PostMapping(value = "/api/coupon/add") public AjaxResult apicouponadd(@RequestBody Map params, HttpServletRequest request) { Long id = Long.parseLong(params.get("coupon_id").toString()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 获取token String token = request.getHeader("token"); if (StringUtils.isEmpty(token)) { @@ -6166,6 +6167,11 @@ public class AppleOrderController extends BaseController { if (coupon == null) { AppletControllerUtil.appletWarning("优惠券不存在"); } + if (coupon.getStatus()==0){ + AppletControllerUtil.appletWarning("优惠券已领用结束!"); + } + + CouponUser couponUser = new CouponUser(); couponUser.setUid(user.getId()); @@ -6174,12 +6180,28 @@ public class AppleOrderController extends BaseController { couponUser.setCouponPrice(coupon.getPrice().intValue()); couponUser.setMinPrice(coupon.getMinPrice().longValue()); couponUser.setAddTime(new Date().getTime()/1000); - couponUser.setLoseTime(String.valueOf(coupon.getEndTime())); + if (coupon.getIsPermanent()==null){ + couponUser.setLoseTime("永久有效"); + }else{ + couponUser.setLoseTime(sdf.format(coupon.getEndTime()*1000)); + } + couponUser.setCateId(coupon.getCateId()); couponUser.setProductId(coupon.getProductId()); couponUser.setReceiveType(String.valueOf(coupon.getReceiveType())); couponUser.setStatus(1L); - couponUserService.insertCouponUser(couponUser); + int flg= couponUserService.insertCouponUser(couponUser); + if (flg>0){ + if (coupon.getIsPermanent()!=1){ + CouponUser coupondata=new CouponUser(); + coupondata.setCouponId(coupon.getId()); + List couponUserList=couponUserService.selectCouponUserList(coupondata); + if (couponUserList.size()>=coupon.getCount()){ + coupon.setStatus(0L); + couponsService.updateCoupons(coupon); + } + } + } return AppletControllerUtil.appletSuccess("操作成功"); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java index 8d3f879..f7e7684 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java @@ -1181,12 +1181,15 @@ public class ApplePayController extends BaseController { if (newpayBefor!=null){ // 创建订单 newpayBefor.setStatus(2L); - usersPayBeforService.updateUsersPayBefor(newpayBefor); + int upuser= usersPayBeforService.updateUsersPayBefor(newpayBefor); + if (upuser>0){ + OrderUtil.prepayCallback(newpayBefor, user); + } } } //BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney()); //回调方法用来处理订单相关数据 - OrderUtil.prepayCallback(payBefor, user); + // OrderUtil.prepayCallback(payBefor, user); payResult.put("istowx", 1); return AppletControllerUtil.appletSuccess("支付成功"); } @@ -1218,12 +1221,16 @@ public class ApplePayController extends BaseController { UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo); if (newpayBefor!=null){ // 创建订单 + payBefor.setPaytime(new Date()); newpayBefor.setStatus(2L); - usersPayBeforService.updateUsersPayBefor(newpayBefor); + int upuser= usersPayBeforService.updateUsersPayBefor(newpayBefor); + if (upuser>0){ + OrderUtil.prepayCallback(newpayBefor, user); + } } } //回调方法用来处理订单相关数据 - OrderUtil.prepayCallback(payBefor, user); + // OrderUtil.prepayCallback(payBefor, user); //IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId()); payResult.put("istowx", 2); @@ -1240,7 +1247,7 @@ public class ApplePayController extends BaseController { // payBefor.setStatus(2L); // 已支付 // payBefor.setPaytime(new Date()); // usersPayBeforService.updateUsersPayBefor(payBefor); - OrderUtil.prepayCallback(payBefor, user); + //扣减消费金服务金 int flg= BenefitPointsUtil.creatServerOrderData(payBefor); if (flg==0){ @@ -1249,7 +1256,10 @@ public class ApplePayController extends BaseController { // 创建订单 newpayBefor.setStatus(2L); newpayBefor.setPaytime(new Date()); - usersPayBeforService.updateUsersPayBefor(newpayBefor); + int updata=usersPayBeforService.updateUsersPayBefor(newpayBefor); + if (updata>0){ + OrderUtil.prepayCallback(newpayBefor, user); + } } } //BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney()); @@ -1265,10 +1275,10 @@ public class ApplePayController extends BaseController { // 组合支付 if (wxMoney.compareTo(BigDecimal.ZERO) <= 0 && yeMoney.compareTo(BigDecimal.ZERO) <= 0) { // 两项都为0,直接走后续逻辑 - payBefor.setStatus(2L); // 已支付 - payBefor.setPaytime(new Date()); - usersPayBeforService.updateUsersPayBefor(payBefor); - OrderUtil.prepayCallback(payBefor, user); +// payBefor.setStatus(2L); // 已支付 +// payBefor.setPaytime(new Date()); +// usersPayBeforService.updateUsersPayBefor(payBefor); + //扣减消费金服务金 // BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney()); // IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId()); @@ -1279,7 +1289,10 @@ public class ApplePayController extends BaseController { // 创建订单 newpayBefor.setStatus(2L); newpayBefor.setPaytime(new Date()); - usersPayBeforService.updateUsersPayBefor(newpayBefor); + int updat= usersPayBeforService.updateUsersPayBefor(newpayBefor); + if (updat>0){ + OrderUtil.prepayCallback(newpayBefor, user); + } } } payResult.put("istowx", 1); @@ -1311,9 +1324,8 @@ public class ApplePayController extends BaseController { payBefor.getOrderid() ); if (balanceResult != null && Boolean.TRUE.equals(balanceResult.get("success"))) { - payBefor.setStatus(2L); // 已支付 - usersPayBeforService.updateUsersPayBefor(payBefor); - OrderUtil.prepayCallback(payBefor, user); +// payBefor.setStatus(2L); // 已支付 +// usersPayBeforService.updateUsersPayBefor(payBefor); //扣减消费金服务金 int flg= BenefitPointsUtil.creatServerOrderData(payBefor); if (flg==0){ @@ -1322,7 +1334,10 @@ public class ApplePayController extends BaseController { // 创建订单 newpayBefor.setStatus(2L); newpayBefor.setPaytime(new Date()); - usersPayBeforService.updateUsersPayBefor(newpayBefor); + int updata= usersPayBeforService.updateUsersPayBefor(newpayBefor); + if (updata>0){ + OrderUtil.prepayCallback(newpayBefor, user); + } } } //BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java index 5566529..7f0943c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java @@ -1580,15 +1580,16 @@ public class AppletController extends BaseController { userInfo.put("tx_time", txTimeArr); // 新增:查询该用户可用优惠券数量 - int couponNum = 0; - try { - com.ruoyi.system.domain.CouponUser queryCoupon = new com.ruoyi.system.domain.CouponUser(); - queryCoupon.setUid(user.getId()); - queryCoupon.setStatus(0L); // 0=可用 - java.util.List couponList = couponUserService.selectCouponUserList(queryCoupon); - couponNum = couponList != null ? couponList.size() : 0; - } catch (Exception e) { - } + // int couponNum = CouponUtil.iscoupon(user.getId(), couponsService, couponUserService).size(); + int couponNum = couponUserService.selectCountCouponsByUid(user.getId(), 1L); +// try { +// com.ruoyi.system.domain.CouponUser queryCoupon = new com.ruoyi.system.domain.CouponUser(); +// queryCoupon.setUid(user.getId()); +// queryCoupon.setStatus(0L); // 0=可用 +// java.util.List couponList = couponUserService.selectCouponUserList(queryCoupon); +// couponNum = couponList != null ? couponList.size() : 0; +// } catch (Exception e) { +// } userInfo.put("couponNum", couponNum); return AppletControllerUtil.appletSuccess(userInfo); @@ -6137,7 +6138,6 @@ public class AppletController extends BaseController { /** * 报价获取服务项目 - * GET /api/worker/quote/craft/{goodsId} */ @GetMapping("/api/worker/quote/craft/{goodsId}") public Object getWorkerQuoteCraft(@PathVariable("goodsId") Long goodsId) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java index bf8703a..db2505b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java @@ -2,24 +2,24 @@ package com.ruoyi.system.controller; import java.math.BigDecimal; import java.util.*; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.ControllerUtil.*; import com.ruoyi.system.domain.*; import com.ruoyi.system.service.*; import com.winnerlook.model.VoiceResponseResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -37,6 +37,7 @@ import com.ruoyi.system.domain.ServiceGoods; * @author ruoyi * @date 2025-05-13 */ +@Api(tags = "订单管理接口") @RestController @RequestMapping("/system/Order") public class OrderController extends BaseController { @@ -48,6 +49,19 @@ public class OrderController extends BaseController { @Autowired private IUsersPayBeforService usersPayBeforService; + @Autowired + private IQuoteTypeService quoteTypeService; + + @Autowired + private IQuoteCraftService quoteCraftService; + + + @Autowired + private IQuoteMaterialTypeService quoteMaterialTypeService; + + @Autowired + private IQuoteMaterialService quoteMaterialService; + @Autowired IUsersService usersService; @@ -1051,4 +1065,556 @@ public class OrderController extends BaseController { return error("项目报价失败:" + e.getMessage()); } } + + + //---------------------------------------------------------------报价相关----------------------------------------------------- + + // ... existing code ... + /** + * 获取基检项目和订单报价信息 + * GET /api/worker/basic/project?id=订单id&goodid=服务id + */ + @GetMapping("/basic/project/{id}") + public AjaxResult getWorkerBasicProject(@PathVariable("id") Long id ) { + + List basicList = new ArrayList<>(); + Map data = new HashMap<>(); + Long goodid = null; + Object quoteJson = null; + // 1. 如果订单id不为空,查订单和报价日志 + if (id != null) { + Order order = orderService.selectOrderById(id); + if (order != null) { + // 查 type=5.0 的订单日志 + OrderLog logQuery = new OrderLog(); + logQuery.setOid(order.getId()); + logQuery.setType(new BigDecimal("5.0")); + List logs = orderLogService.selectOrderLogList(logQuery); + if (logs != null && !logs.isEmpty()) { + String content = logs.getFirst().getContent(); + try { + quoteJson = JSON.parse(content); + } catch (Exception e) { + quoteJson = content; + } + } + // 取服务id + if (order.getProductId() != null) { + goodid = order.getProductId(); + } + } + } + // 2. 查服务信息 + if (goodid != null) { + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodid); + if (serviceGoods != null) { + String basic = serviceGoods.getBasic(); + if (basic != null && !basic.trim().isEmpty()) { + try { + JSONArray jsonArray = JSONArray.parse(basic); + for (int i = 0; i < jsonArray.size(); i++) { + String item = jsonArray.getString(i); + if (item != null && !item.trim().isEmpty()) { + basicList.add(item.trim()); + } + } + } catch (Exception e) { + String[] arr = basic.split("[\n,,]"); + for (String s : arr) { + if (!s.trim().isEmpty()) basicList.add(s.trim()); + } + } + } + } + } + + + + //查询报价的支付信息 + if (id != null) { + Order order = orderService.selectOrderById(id); + if (order != null) { + // 查 type=5.0 的订单日志 + OrderLog logQuery = new OrderLog(); + logQuery.setOid(order.getId()); + logQuery.setType(new BigDecimal("5.0")); + List logs = orderLogService.selectOrderLogList(logQuery); + if (logs != null && !logs.isEmpty()) { + OrderLog logdata = logs.getFirst(); + if (logdata != null) { + Map paydata = new HashMap<>(); + paydata.put("weikuan", logdata.getPaid()); + paydata.put("dingjin", logdata.getDepPaid()); + data.put("payStatusdata", paydata); + } + } + + + } + }else{ + Map paydata = new HashMap<>(); + paydata.put("weikuan", "1"); + paydata.put("dingjin", "1"); + data.put("payStatusdata", paydata); + } + + data.put("basic", basicList); + if (quoteJson != null) { + data.put("quote", quoteJson); + } + return AjaxResult.success(data); + } + + + +// /** +// * 获取基检项目 +// */ +// @ApiOperation("获取基检项目") +// @GetMapping("/basic/project/{id}") +// public AjaxResult getWorkerBasicProject(@PathVariable("id") Long id) { +// Order order = orderService.selectOrderById(id); +// if (order == null) { +// return AjaxResult.error("订单不存在"); +// } +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); +// if (serviceGoods == null) { +// return AjaxResult.error("商品不存在"); +// } +// +// String basic = serviceGoods.getBasic(); +// List basicList = new ArrayList<>(); +// if (basic != null && !basic.trim().isEmpty()) { +// try { +// JSONArray jsonArray = JSONArray.parseArray(basic); +// for (int i = 0; i < jsonArray.size(); i++) { +// String item = jsonArray.getString(i); +// if (item != null && !item.trim().isEmpty()) { +// basicList.add(item.trim()); +// } +// } +// } catch (Exception e) { +// String[] arr = basic.split("[\n,,]"); +// for (String s : arr) { +// if (!s.trim().isEmpty()) basicList.add(s.trim()); +// } +// } +// } +// Map data = new HashMap<>(); +// data.put("basic", basicList); +// return AjaxResult.success(data); +// } + + + + + /** + * 报价获取服务项目 + */ + @ApiOperation("获取取服务项目") + @GetMapping("/quote/craft/{goodsId}") + public AjaxResult getWorkerQuoteCraft(@PathVariable("goodsId") Long goodsId) { + // 1. 查询商品基本信息 + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsId); + if (serviceGoods == null) { + return AjaxResult.error("商品不存在"); + } + // 2. 查询服务分类(IQuoteTypeService) + QuoteType typeQuery = new QuoteType(); + typeQuery.setGoodId("\"" + goodsId + "\""); + List typeList = quoteTypeService.selectQuoteTypeList(typeQuery); + List dataArr = new ArrayList<>(); + for (QuoteType type : typeList) { + Map typeMap = new HashMap<>(); + typeMap.put("id", type.getId()); + typeMap.put("title", type.getTitle()); + // 3. 查询工艺(IQuoteCraftService) + QuoteCraft craftQuery = new QuoteCraft(); + craftQuery.setTypeId("[\"" + type.getId() + "\"]"); + List craftList = quoteCraftService.selectQuoteCraftList(craftQuery); + List> craftArr = new ArrayList<>(); + for (QuoteCraft craft : craftList) { + Map craftMap = new HashMap<>(); + craftMap.put("id", craft.getId()); + craftMap.put("title", craft.getTitle()); + craftMap.put("price", craft.getPrice() != null ? craft.getPrice().toString() : "0.00"); + craftMap.put("unit", craft.getUnit()); + // type_id为数组,需解析 + List typeIdList = new ArrayList<>(); + String typeIdStr = craft.getTypeId(); + if (typeIdStr != null && typeIdStr.trim().startsWith("[") && typeIdStr.trim().endsWith("]")) { + try { + typeIdList = JSON.parseArray(typeIdStr, String.class); + } catch (Exception e) { + typeIdList.add(typeIdStr); + } + } else if (typeIdStr != null) { + typeIdList.add(typeIdStr); + } + craftMap.put("type_id", typeIdList); + craftArr.add(craftMap); + } + typeMap.put("craft", craftArr); + dataArr.add(typeMap); + } + return AjaxResult.success(dataArr); + } + + + + + /** + * 报价所需物料查询 + * GET /api/worker/quote/material/{goodsId} + */ + @ApiOperation("获取所需物料") + @GetMapping("/quote/material/{goodsId}") + public AjaxResult getWorkerQuoteMaterial(@PathVariable("goodsId") Long goodsId) { + // 1. 查询商品基本信息 + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsId); + if (serviceGoods == null) { + return AjaxResult.error("商品不存在"); + } + // 2. 查询物料分类(IQuoteMaterialTypeService) + QuoteMaterialType typeQuery = new QuoteMaterialType(); + typeQuery.setGoodId("\"" + goodsId + "\""); + List typeList = quoteMaterialTypeService.selectQuoteMaterialTypeList(typeQuery); + List dataArr = new ArrayList<>(); + for (QuoteMaterialType type : typeList) { + Map typeMap = new HashMap<>(); + typeMap.put("id", type.getId()); + typeMap.put("title", type.getTitle()); + // 3. 查询物料信息(IQuoteMaterialService) + QuoteMaterial materialQuery = new QuoteMaterial(); + materialQuery.setTypeId("\"" + type.getId() + "\""); + List materialList = quoteMaterialService.selectQuoteMaterialList(materialQuery); + List> materialArr = new ArrayList<>(); + for (QuoteMaterial material : materialList) { + Map materialMap = new HashMap<>(); + materialMap.put("id", material.getId()); + materialMap.put("title", material.getTitle()); + materialMap.put("image",AppletControllerUtil.buildImageUrl(material.getImage())); + materialMap.put("price", material.getPrice() != null ? material.getPrice().toString() : "0.00"); + materialMap.put("unit", material.getUnit()); + // 格式化manyimages为数组 + if (material.getManyimages() != null && !material.getManyimages().trim().isEmpty()) { + materialMap.put("manyimages", JSONArray.parseArray(material.getManyimages())); + } else { + materialMap.put("manyimages", new JSONArray()); + } + if (org.apache.commons.lang3.StringUtils.isNotBlank(material.getContent())&& org.apache.commons.lang3.StringUtils.isNotBlank(material.getManyimages())){ + materialMap.put("showtype", 1); + }else{ + materialMap.put("showtype", 2); + } + materialMap.put("content", material.getContent()); + // type_id为数组,需解析 + List typeIdList = new ArrayList<>(); + String typeIdStr = material.getTypeId(); + if (typeIdStr != null && typeIdStr.trim().startsWith("[") && typeIdStr.trim().endsWith("]")) { + try { + typeIdList = JSON.parseArray(typeIdStr, String.class); + } catch (Exception e) { + typeIdList.add(typeIdStr); + } + } else if (typeIdStr != null) { + typeIdList.add(typeIdStr); + } + materialMap.put("type_id", typeIdList); + materialArr.add(materialMap); + } + typeMap.put("material", materialArr); + dataArr.add(typeMap); + } + return AjaxResult.success(dataArr); + } + + + + /** + * 师傅报价接口 + * POST /api/worker/estimate + */ + + @ApiOperation(value = "测试") + @PostMapping("/worker/estimate") + public AjaxResult workerEstimate(@RequestBody Map params, HttpServletRequest request) throws Exception { + if (params == null) { + return AjaxResult.error("参数错误"); + } + PayBeforeUtil payBeforeUtil = new PayBeforeUtil(); + // 1. 计算金额 + BigDecimal GoodsAllPrice = BigDecimal.ZERO; + BigDecimal ServiceAllPrice = BigDecimal.ZERO; + BigDecimal totalPrice = BigDecimal.ZERO; + List> craftList = (List>) params.get("craft"); + if (craftList != null) { + for (Map craft : craftList) { + Long craftId = null; + try { + craftId = Long.valueOf(craft.get("id").toString()); + } catch (Exception ignore) { + } + if (craftId != null) { + QuoteCraft quoteCraft = quoteCraftService.selectQuoteCraftById(craftId); + if (quoteCraft != null) { + BigDecimal price = new BigDecimal(craft.get("price").toString()); + Integer count = craft.get("count") == null ? 1 : Integer.parseInt(craft.get("count").toString()); + totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(count))); + ServiceAllPrice = ServiceAllPrice.add(price.multiply(BigDecimal.valueOf(count))); + } + } + } + } + List> materialList = (List>) params.get("material"); + if (materialList != null) { + for (Map material : materialList) { + Long materialId = null; + try { + materialId = Long.valueOf(material.get("id").toString()); + } catch (Exception ignore) { + } + if (materialId != null) { + QuoteMaterial quoteMaterial = quoteMaterialService.selectQuoteMaterialById(materialId); + if (quoteMaterial != null) { + BigDecimal price = new BigDecimal(material.get("price").toString()); + Integer count = material.get("count") == null ? 1 : Integer.parseInt(material.get("count").toString()); + totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(count))); + GoodsAllPrice = GoodsAllPrice.add(price.multiply(BigDecimal.valueOf(count))); + } + } + } + } + BigDecimal reductionPrice = BigDecimal.ZERO; + String reduction = params.get("reduction").toString(); + String reamk = null; + if (params.get("reamk") != null){ + reamk =params.get("reamk").toString(); + } + + + if (reduction != null && !reduction.trim().isEmpty()) { + reductionPrice = new BigDecimal(reduction); + // totalPrice = totalPrice.subtract(reductionPrice); + totalPrice = totalPrice; + } + // 2. 组装新json + Map resultJson = new LinkedHashMap<>(); + // project + Map project = new LinkedHashMap<>(); + project.put("name", "项目费用"); + project.put("price", totalPrice); + resultJson.put("project", project); + Map reductionproject = new LinkedHashMap<>(); + reductionproject.put("name", "优惠金额"); + reductionproject.put("price", params.get("reduction")); + resultJson.put("reduction", reductionproject); + Map depositproject = new LinkedHashMap<>(); + depositproject.put("name", "定金"); + depositproject.put("price", params.get("price")); + resultJson.put("deposit", depositproject); + // basic + resultJson.put("basic", params.get("basic")); + if (StringUtils.isNotBlank(reamk)){ + resultJson.put("reamk", reamk); + } + + // craft + List> craftListNew = new ArrayList<>(); + if (craftList != null) { + for (Map craft : craftList) { + Map item = new LinkedHashMap<>(); + item.put("name", craft.get("title") != null ? craft.get("title") : craft.get("name")); + item.put("price", craft.get("price")); + item.put("pid", craft.get("pid")); + + item.put("id", craft.get("id")); + item.put("count", craft.get("count")); + craftListNew.add(item); + } + } + resultJson.put("craft", craftListNew); + // material + List> materialListNew = new ArrayList<>(); + if (materialList != null) { + for (Map material : materialList) { + Map item = new LinkedHashMap<>(); + item.put("name", material.get("title") != null ? material.get("title") : material.get("name")); + item.put("price", material.get("price")); + item.put("id", material.get("id")); + item.put("pid", material.get("pid")); + item.put("count", material.get("count")); + materialListNew.add(item); + } + } + resultJson.put("material", materialListNew); + // 3. 转为字符串 + String contentStr = com.alibaba.fastjson2.JSONObject.toJSONString(resultJson); + + // 4. 订单相关处理 + Long orderId = null; + if (params.get("id") != null) { + try { + orderId = Long.valueOf(params.get("id").toString()); + } catch (Exception ignore) { + } + } + if (orderId == null) { + return AppletControllerUtil.appletError("订单ID格式错误"); + } + Order order = orderService.selectOrderById(orderId); + if (order == null) { + return AppletControllerUtil.appletError("订单不存在"); + } + // 查询最新订单日志 + OrderLog neworderLogdata =new OrderLog(); + neworderLogdata.setType(new BigDecimal(5.0)); + neworderLogdata.setOid(order.getId()); + List orderLogslist = orderLogService.selectOrderLogList(neworderLogdata); + if(!orderLogslist.isEmpty()){ + OrderLog neworderLog=orderLogslist.getFirst(); + neworderLog.setContent(contentStr); + if (params.get("price") != null) { + //String DepLogId = GenerateCustomCode.generCreateOrder("LOG"); + neworderLog.setDeposit(new BigDecimal(params.get("price").toString())); + neworderLog.setDepPaid(1); + + // neworderLog.setDepLogId(DepLogId); + //给尾款添加预支 + // BigDecimal totalAmount=neworderLog.getDeposit(); + + // PayBeforeUtil payBeforeUtil = new PayBeforeUtil(); +// payBeforeUtil.createPayBefore(userinfo, totalAmount, DepLogId, neworderLog.getId(), +// null, 7L, null, null, +// null, null, null,1L,null); +//// payBeforeUtil.createPayBefore(user, totalPrice.add(reductionPrice), order.getOrderId(), order.getId(),); + + + }else { + neworderLog.setDeposit(BigDecimal.ZERO); + } + +// neworderLog.setPrice(totalPrice.add(reductionPrice)); + neworderLog.setPaid(1L); + if (params.get("reduction") != null) { + neworderLog.setReductionPrice(new BigDecimal(params.get("reduction").toString())); + } else { + neworderLog.setReductionPrice(BigDecimal.ZERO); + } + System.out.println("neworderLog.getPrice():totalPrice"+totalPrice); + System.out.println("neworderLog.getPrice():reductionPrice"+reductionPrice); + System.out.println("neworderLog.getPrice():neworderLog.getDeposit()"+neworderLog.getDeposit()); + + BigDecimal WK=totalPrice.subtract(reductionPrice).subtract(neworderLog.getDeposit()); + System.out.println("neworderLog.getPrice():neworderLog.getDeposit()WKWKWK"+WK); + if(WK.compareTo(BigDecimal.ZERO)>0){ + System.out.println("111neworderLog.getPrice():neworderLog.getDeposit()WKWKWK"+WK); + neworderLog.setPrice(WK); + }else{ + neworderLog.setPrice(BigDecimal.ZERO); + } +// if (params.get("reduction") != null) { +// neworderLog.setReductionPrice(new BigDecimal(params.get("reduction").toString())); +// } else { +// neworderLog.setReductionPrice(BigDecimal.ZERO); +// } + neworderLog.setWorkerCost(BigDecimal.ZERO); + //log.set + neworderLog.setLogId(GenerateCustomCode.generCreateOrder("EST")); + //删除之前的预支付信息 + UsersPayBefor payBefore = new UsersPayBefor(); + payBefore.setOrderid(neworderLog.getDepLogId()); + List payBeforeList = usersPayBeforService.selectUsersPayBeforList(payBefore); + if(!payBeforeList.isEmpty()){ + for (UsersPayBefor payBefore1 : payBeforeList) { + usersPayBeforService.deleteUsersPayBeforById(payBefore1.getId()); + } + } + //删除之前的预支付信息 + UsersPayBefor payBefore3 = new UsersPayBefor(); + payBefore3.setOrderid(neworderLog.getLogOrderId()); + payBefore3.setType(9L); + List payBeforeList3 = usersPayBeforService.selectUsersPayBeforList(payBefore3); + if(!payBeforeList3.isEmpty()){ + for (UsersPayBefor payBefore4 : payBeforeList3) { + usersPayBeforService.deleteUsersPayBeforById(payBefore4.getId()); + } + } + Users userinfo = usersService.selectUsersById(order.getUid()); + payBeforeUtil.handleQuotationPayBefore(userinfo, neworderLog, contentStr, order.getOrderId()); + int flg= orderLogService.updateOrderLog(neworderLog); + if (flg > 0) { + order.setGoodPrice(GoodsAllPrice); + order.setServicePrice(ServiceAllPrice); + orderService.updateOrder(order); + } + //小程序推送报价成功 + Users user = usersService.selectUsersById(order.getUid()); + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); + WXsendMsgUtil.sendWorkerADDmoney(user.getOpenid(), order, serviceGoods); + return AjaxResult.success("报价成功"); + }else{ + order.setJsonStatus(6); + com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject(); + jsonObject.put("type", 5); + order.setLogJson(jsonObject.toJSONString()); + // order.setTotalPrice(totalPrice); + // order.setUpdatedAt(new Date()); + order.setGoodPrice(GoodsAllPrice); + order.setServicePrice(ServiceAllPrice); + int update = orderService.updateOrder(order); + if (update > 0) { + OrderLog log = new OrderLog(); + log.setOid(order.getId()); + log.setLogOrderId(GenerateCustomCode.generCreateOrder("DSB") ); + log.setOrderId(order.getOrderId()); + log.setType(new BigDecimal(5)); + log.setContent(contentStr); + log.setTitle("已检查评估报价"); + if (params.get("price") != null) { + log.setDeposit(new BigDecimal(params.get("price").toString())); + log.setDepPaid(1); + log.setDepLogId(GenerateCustomCode.generCreateOrder("RED")); + }else { + log.setDeposit(BigDecimal.ZERO); + } + BigDecimal WK=totalPrice.subtract(reductionPrice).subtract(log.getDeposit()); + if(WK.compareTo(BigDecimal.ZERO)>0){ + log.setPrice(WK); + }else{ + log.setPrice(BigDecimal.ZERO); + } +// log.setPrice(totalPrice.add(reductionPrice)); + log.setPaid(1L); + if (params.get("reduction") != null) { + log.setReductionPrice(new BigDecimal(params.get("reduction").toString())); + } else { + log.setReductionPrice(BigDecimal.ZERO); + } + //log.setPrice(ServiceAllPrice.subtract(reductionPrice)); + //log.set + log.setLogId(GenerateCustomCode.generCreateOrder("EST")); + log.setWorkerLogId(order.getWorkerId()); + log.setWorkerId(order.getWorkerId()); + int flg=orderLogService.insertOrderLog(log); + if (flg > 0) { + order.setGoodPrice(GoodsAllPrice); + order.setServicePrice(ServiceAllPrice); + orderService.updateOrder(order); + } + Users user = usersService.selectUsersById(order.getUid()); + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); + //小程序推送用户报价成功 + WXsendMsgUtil.sendWorkerADDmoney(user.getOpenid(), order, serviceGoods); + Users userinfo = usersService.selectUsersById(order.getUid()); + payBeforeUtil.handleQuotationPayBefore(userinfo, log, contentStr, order.getOrderId()); + return AjaxResult.success("报价成功"); + } else { + return AjaxResult.success("报价失败"); + } + } + } + + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayMoneyLogController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayMoneyLogController.java index ded1ca4..5854a6c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayMoneyLogController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayMoneyLogController.java @@ -88,6 +88,16 @@ public class PayMoneyLogController extends BaseController return success(payMoneyLogService.getPayMoneyLogStatistics()); } + /** + * 获取订单价格统计(按订单ID分组) + */ + @PreAuthorize("@ss.hasPermi('system:PayMoneyLog:query')") + @GetMapping(value = "/getOrderPriceStatistics") + public AjaxResult getOrderPriceStatistics() + { + return success(payMoneyLogService.getOrderPriceStatistics(1l)); + } + /** * 导出支付记录列表 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java index 60ba27e..8e3d307 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java @@ -518,13 +518,13 @@ public class PayNotifyController extends BaseController { } } - if (usersPayBefor != null) { - usersPayBefor.setStatus(2L); - usersPayBefor.setPaytime(new Date()); - usersPayBefor.setPaycode(transactionId); - usersPayBeforService.updateUsersPayBefor(usersPayBefor); - - } +// if (usersPayBefor != null) { +// usersPayBefor.setStatus(2L); +// usersPayBefor.setPaytime(new Date()); +// usersPayBefor.setPaycode(transactionId); +// usersPayBeforService.updateUsersPayBefor(usersPayBefor); +// +// } Users users = null; if (usersPayBefor != null) { users = usersService.selectUsersById(usersPayBefor.getUid()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ServiceCateController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ServiceCateController.java index 47c48fa..f07e366 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ServiceCateController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ServiceCateController.java @@ -97,7 +97,14 @@ public class ServiceCateController extends BaseController @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { - return success(serviceCateService.selectServiceCateById(id)); + + ServiceCate serviceCate= serviceCateService.selectServiceCateById(id); + if (serviceCate != null){ + serviceCate.setIcon(AppletControllerUtil.buildImageUrl(serviceCate.getIcon())); + } + + + return success(serviceCate); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java index 4907ef7..55b0d8c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java @@ -1868,6 +1868,10 @@ public class AppletControllerUtil { } } + + if (couponUser.getCateId() == null && couponUser.getProductId() == null){ + suitTitle="通用券"; + } if (couponUser.getReceiveType().equals("1")){ if (totalPrice!=null){ if (totalPrice.compareTo(new BigDecimal(couponUser.getMinPrice()))>0){ @@ -1896,7 +1900,7 @@ public class AppletControllerUtil { break; } } - couponData.put("tag", tag); + couponData.put("tag","tag"); resultList.add(couponData); } @@ -1916,7 +1920,7 @@ public class AppletControllerUtil { for (Coupons coupons : couponsList) { Map couponData = new HashMap<>(); couponData.put("id", coupons.getId()); - couponData.put("title", coupons.getId()); + couponData.put("title", coupons.getTitle()); couponData.put("price", coupons.getPrice()); couponData.put("min_price", coupons.getMinPrice()); couponData.put("start_time", coupons.getStartTime()); @@ -5542,6 +5546,7 @@ public class AppletControllerUtil { order.setProductId(serviceGoods.getId()); order.setBigtype(serviceGoods.getServicetype()); order.setProductName(serviceGoods.getTitle()); + order.setReamk(reamk); order.setSku(sku); if (userAddress != null) { @@ -5580,6 +5585,14 @@ public class AppletControllerUtil { order.setDeduction(new BigDecimal(0)); order.setFileData(attachments); // 设置附件数据 order.setType(1); + // 使用 Fastjson2 将实体安全序列化为JSON字符串,避免直接使用 toString() 解析导致的异常 + if (userAddress != null) { + try { + order.setAdressjson(JSON.toJSONString(userAddress)); + } catch (Exception e) { + order.setAdressjson(null); + } + } //order.setPayPrice(new BigDecimal(0)); int insertResult = orderService.insertOrder(order); if (insertResult <= 0) { @@ -5716,6 +5729,13 @@ public class AppletControllerUtil { order.setProductName(serviceGoods.getTitle()); order.setSku(sku); order.setBigtype(serviceGoods.getServicetype()); + if (userAddress != null) { + try { + order.setAdressjson(JSON.toJSONString(userAddress)); + } catch (Exception e) { + order.setAdressjson(null); + } + } if(StringUtils.isNotBlank(cikaid)){ order.setTotalPrice(serviceGoods.getFixedprice()); order.setCartid(cikaid); @@ -5923,7 +5943,13 @@ public class AppletControllerUtil { } } } - + if (userAddress != null) { + try { + order.setAdressjson(JSON.toJSONString(userAddress)); + } catch (Exception e) { + order.setAdressjson(null); + } + } order.setTotalPrice(itemPrice); order.setGoodPrice(BigDecimal.ZERO); order.setServicePrice(BigDecimal.ZERO); @@ -6007,6 +6033,13 @@ public class AppletControllerUtil { order.setProductName(serviceGoods.getTitle()); order.setSku(sku); order.setJsonStatus(0); + if (userAddress != null) { + try { + order.setAdressjson(JSON.toJSONString(userAddress)); + } catch (Exception e) { + order.setAdressjson(null); + } + } order.setType(1); order.setNum(Long.valueOf(num)); if (userAddress != null) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/BenefitPointsUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/BenefitPointsUtil.java index 4c158cd..d2cbed4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/BenefitPointsUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/BenefitPointsUtil.java @@ -167,7 +167,7 @@ public class BenefitPointsUtil { private static BenefitPointsResult processServiceOrder(Order order, Users user, BigDecimal money, Map config) { try { log.info("【服务订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money); - + Users userdata=usersService.selectUsersById(user.getId()); // 获取服务金转换为消费金的比例 BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0")); if (servicefeeRatio.compareTo(ZERO) <= 0) { @@ -179,21 +179,21 @@ public class BenefitPointsUtil { BigDecimal consumptionIncrease = money.multiply(servicefeeRatio).divide(new BigDecimal("100")); // 更新用户消费金余额 - BigDecimal beforeConsumption = user.getConsumption() != null ? user.getConsumption() : ZERO; + BigDecimal beforeConsumption = userdata.getConsumption() != null ? userdata.getConsumption() : ZERO; BigDecimal afterConsumption = beforeConsumption.add(consumptionIncrease); - user.setConsumption(afterConsumption); + userdata.setConsumption(afterConsumption); // 更新用户信息 - int updateResult = usersService.updateUsers(user); + int updateResult = usersService.updateUsers(userdata); if (updateResult <= 0) { - log.error("【错误】用户消费金更新失败,用户ID: {}", user.getId()); + log.error("【错误】用户消费金更新失败,用户ID: {}", userdata.getId()); return new BenefitPointsResult(false, "用户消费金更新失败", null); } // 记录日志 UserBenefitPoints benefitLog = createBenefitPointsLog( order.getId(), - user.getId(), + userdata.getId(), TYPE_CONSUMPTION, ORDER_TYPE_INCOME, money, @@ -205,12 +205,12 @@ public class BenefitPointsUtil { int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog); if (insertResult <= 0) { - log.error("【错误】消费金日志记录失败,用户ID: {}", user.getId()); + log.error("【错误】消费金日志记录失败,用户ID: {}", userdata.getId()); return new BenefitPointsResult(false, "消费金日志记录失败", null); } log.info("【服务订单处理完成】用户ID: {}, 消费金增加: {}, 更新前: {}, 更新后: {}", - user.getId(), consumptionIncrease, beforeConsumption, afterConsumption); + userdata.getId(), consumptionIncrease, beforeConsumption, afterConsumption); return new BenefitPointsResult(true, "服务订单消费金处理成功", benefitLog); @@ -225,7 +225,7 @@ public class BenefitPointsUtil { private static BenefitPointsResult processCikaOrder(UserUseSecondaryCard order, Users user, BigDecimal money, Map config) { try { log.info("【服务订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money); - + Users userdata = usersService.selectUsersById(user.getId()); // 获取服务金转换为消费金的比例 BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0")); if (servicefeeRatio.compareTo(ZERO) <= 0) { @@ -237,21 +237,21 @@ public class BenefitPointsUtil { BigDecimal consumptionIncrease = money.multiply(servicefeeRatio).divide(new BigDecimal("100")); // 更新用户消费金余额 - BigDecimal beforeConsumption = user.getConsumption() != null ? user.getConsumption() : ZERO; + BigDecimal beforeConsumption = userdata.getConsumption() != null ? userdata.getConsumption() : ZERO; BigDecimal afterConsumption = beforeConsumption.add(consumptionIncrease); - user.setConsumption(afterConsumption); + userdata.setConsumption(afterConsumption); // 更新用户信息 - int updateResult = usersService.updateUsers(user); + int updateResult = usersService.updateUsers(userdata); if (updateResult <= 0) { - log.error("【错误】用户消费金更新失败,用户ID: {}", user.getId()); + log.error("【错误】用户消费金更新失败,用户ID: {}", userdata.getId()); return new BenefitPointsResult(false, "用户消费金更新失败", null); } // 记录日志 UserBenefitPoints benefitLog = createBenefitPointsLog( order.getId(), - user.getId(), + userdata.getId(), TYPE_CONSUMPTION, ORDER_TYPE_INCOME, money, @@ -263,7 +263,7 @@ public class BenefitPointsUtil { int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog); if (insertResult <= 0) { - log.error("【错误】消费金日志记录失败,用户ID: {}", user.getId()); + log.error("【错误】消费金日志记录失败,用户ID: {}", userdata.getId()); return new BenefitPointsResult(false, "消费金日志记录失败", null); } @@ -283,7 +283,7 @@ public class BenefitPointsUtil { private static BenefitPointsResult processGoodsOrder(GoodsOrder order, Users user, BigDecimal money, Map config) { try { log.info("【商品订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money); - user=usersService.selectUsersById(order.getUid()); + Users userdata = usersService.selectUsersById(user.getId()); // 获取消费金转换为服务金的比例 BigDecimal consumptionRatio = getConfigValue(config, CONSUMPTION_KEY, new BigDecimal("0")); if (consumptionRatio.compareTo(ZERO) <= 0) { @@ -295,21 +295,21 @@ public class BenefitPointsUtil { BigDecimal servicefeeIncrease = money.multiply(consumptionRatio).divide(new BigDecimal("100")); // 更新用户服务金余额 - BigDecimal beforeServicefee = user.getServicefee() != null ? user.getServicefee() : ZERO; + BigDecimal beforeServicefee = userdata.getServicefee() != null ? userdata.getServicefee() : ZERO; BigDecimal afterServicefee = beforeServicefee.add(servicefeeIncrease); - user.setServicefee(afterServicefee); + userdata.setServicefee(afterServicefee); // 更新用户信息 - int updateResult = usersService.updateUsers(user); + int updateResult = usersService.updateUsers(userdata); if (updateResult <= 0) { - log.error("【错误】用户服务金更新失败,用户ID: {}", user.getId()); + log.error("【错误】用户服务金更新失败,用户ID: {}", userdata.getId()); return new BenefitPointsResult(false, "用户服务金更新失败", null); } // 记录日志 UserBenefitPoints benefitLog = createBenefitPointsLog( order.getId(), - user.getId(), + userdata.getId(), TYPE_SERVICE_FEE, ORDER_TYPE_INCOME, money, @@ -321,12 +321,12 @@ public class BenefitPointsUtil { int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog); if (insertResult <= 0) { - log.error("【错误】服务金日志记录失败,用户ID: {}", user.getId()); + log.error("【错误】服务金日志记录失败,用户ID: {}", userdata.getId()); return new BenefitPointsResult(false, "服务金日志记录失败", null); } log.info("【商品订单处理完成】用户ID: {}, 服务金增加: {}, 更新前: {}, 更新后: {}", - user.getId(), servicefeeIncrease, beforeServicefee, afterServicefee); + userdata.getId(), servicefeeIncrease, beforeServicefee, afterServicefee); return new BenefitPointsResult(true, "商品订单服务金处理成功", benefitLog); @@ -1268,6 +1268,7 @@ public class BenefitPointsUtil { } //type 1增加(用户增加,就是退款的时候用) 0减少 if(type==1){ + user.setServicefee(user.getServicefee().add(amountService)); UserBenefitPoints benefitLog = new UserBenefitPoints(); benefitLog.setOrderid(usersPayBefor.getId()); @@ -1292,7 +1293,13 @@ public class BenefitPointsUtil { return remap; }else{ - user.setServicefee(user.getServicefee().subtract(amountService)); + //如果计算下来小于0则修改值为0,不能出现负数 + if(user.getServicefee().subtract(amountService).compareTo(BigDecimal.ZERO)<0){ + user.setServicefee(new BigDecimal("0")); + }else{ + user.setServicefee(user.getServicefee().subtract(amountService)); + } + UserBenefitPoints benefitLog = new UserBenefitPoints(); benefitLog.setOrderid(usersPayBefor.getId()); benefitLog.setUid(usersPayBefor.getUid()); @@ -1420,7 +1427,13 @@ public class BenefitPointsUtil { }else{ System.out.println("抵扣区间-------"+user.getConsumption().subtract(amountGoodsmoney)); - user.setConsumption(user.getConsumption().subtract(amountGoodsmoney)); + //如果计算下来小于0则修改值为0,不能出现负数 + if(user.getConsumption().subtract(amountGoodsmoney).compareTo(BigDecimal.ZERO)<0){ + user.setConsumption(BigDecimal.ZERO); + }else{ + user.setConsumption(user.getConsumption().subtract(amountGoodsmoney)); + } + // user.setConsumption(user.getConsumption().subtract(amountGoodsmoney)); UserBenefitPoints benefitLog = new UserBenefitPoints(); benefitLog.setOrderid(usersPayBefor.getId()); benefitLog.setUid(usersPayBefor.getUid()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java index e0030fd..ff3fcee 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CartOrderUtil.java @@ -106,6 +106,7 @@ public class CartOrderUtil { order.setBigtype(serviceGoods.getServicetype()); order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单 order.setCreatePhone(user.getPhone()); + order.setAdressjson(JSONObject.parseObject(userAddress.toString()).toJSONString()); int insertResult = orderService.insertOrder(order); if (insertResult <= 0) { result.put("success", false); @@ -277,6 +278,7 @@ public class CartOrderUtil { goodsOrder.setStatus(1L); // 待支付 goodsOrder.setPostage(serviceGoods.getPostage()); goodsOrder.setMainOrderId(maincorid); + // goodsOrder.setAdressjson(JSONObject.parseObject(userAddress.toString()).toJSONString()); //goodsOrder.setIsmany(1L); int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder); if (insertResult <= 0) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CouponUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CouponUtil.java index bb3ef31..d541987 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CouponUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/CouponUtil.java @@ -73,4 +73,60 @@ public class CouponUtil { return canReceiveList; } + + /** + * 处理过期优惠券 + * 规则:查询当前有效(status = 1)的优惠券,按 end_time + coupon_time(天) 计算到期时间, + * 如果已到期,则将优惠券状态置为 0,并将该优惠券下的领取记录(coupon_user)置为 3(失效,已使用的保留原状态)。 + * + * @param couponsService 优惠券服务 + * @param couponUserService 优惠券领取记录服务 + * @return 结果统计:expiredCoupons 过期的优惠券数量;updatedCouponUsers 被置为失效的领取记录数量 + */ + public static Map processExpiredCoupons(ICouponsService couponsService, ICouponUserService couponUserService) { + long now = System.currentTimeMillis() / 1000; // 秒 + + // 查询当前有效的优惠券(status = 1) + Coupons query = new Coupons(); + query.setStatus(1L); + List activeCoupons = couponsService.selectCouponsList(query); + + int expiredCouponCount = 0; + int updatedCouponUserCount = 0; + + for (Coupons coupon : activeCoupons) { + // 若未设置结束时间,视为永久有效,直接跳过 + if (coupon.getEndTime() == null || coupon.getEndTime() == 0L) { + continue; + } + + long endTime = coupon.getEndTime(); // 秒 + long extraSeconds = coupon.getCouponTime() != null ? coupon.getCouponTime() * 24 * 60 * 60 : 0L; // 天 -> 秒 + long expireAt = endTime + extraSeconds; + + if (expireAt > 0 && now >= expireAt) { + // 1) 更新优惠券状态为关闭 + coupon.setStatus(0L); + couponsService.updateCoupons(coupon); + expiredCouponCount++; + + // 2) 将该优惠券下未使用/未失效的领取记录置为失效(status = 3) + CouponUser cuQuery = new CouponUser(); + cuQuery.setCouponId(coupon.getId()); + List couponUsers = couponUserService.selectCouponUserList(cuQuery); + for (CouponUser cu : couponUsers) { + // status: 1未使用 2已使用 3已失效 —— 仅把非已使用的置为失效 + if (cu.getStatus() == null || cu.getStatus() != 2L) { + cu.setStatus(3L); + updatedCouponUserCount += couponUserService.updateCouponUser(cu); + } + } + } + } + + Map result = new HashMap<>(); + result.put("expiredCoupons", expiredCouponCount); + result.put("updatedCouponUsers", updatedCouponUserCount); + return result; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/IntegralAndBenefitUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/IntegralAndBenefitUtil.java index 3917ee6..4e7197d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/IntegralAndBenefitUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/IntegralAndBenefitUtil.java @@ -90,8 +90,7 @@ public class IntegralAndBenefitUtil { users.setIntegral(newIntegral); users.setTotalIntegral(newTotalIntegral); - logger.error("更新用户积分失败,用户ID: {}", users.getIntegral()); - logger.error("更新用户积分失败,用户ID: {}", users.getTotalIntegral()); + System.out.println("开始计算增加积分,这里开始处理" + orderid + "----------------------------------------------------------"); // 更新用户信息 int updateResult = usersService.updateUsers(users); if (updateResult > 0) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java index 8513946..ad17468 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java @@ -287,13 +287,13 @@ public class InvoiceUtil { failedOrders.add(orderId + "(订单不存在或不属于当前用户)"); continue; } - + // 检查是否已开票 if (isOrderInvoiced(orderId)) { failedOrders.add(orderId + "(已开过发票)"); continue; } - + // 累计金额和开票内容 BigDecimal orderAmount = (BigDecimal) orderInfo.get("amount"); if (orderAmount != null) { @@ -301,12 +301,12 @@ public class InvoiceUtil { } invoiceTexts.add((String) orderInfo.get("title")); successOrders.add(orderId); - + } catch (Exception e) { failedOrders.add(orderId + "(处理异常: " + e.getMessage() + ")"); } } - + // 4. 如果没有可开票的订单 if (successOrders.isEmpty()) { return AppletControllerUtil.appletWarning("没有可开票的订单:" + String.join(", ", failedOrders)); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java index 7879bb9..30628a1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderUtil.java @@ -34,6 +34,7 @@ public class OrderUtil { private static IQuoteMaterialService quoteMaterialService = SpringUtils.getBean(IQuoteMaterialService.class); private static IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class); private static IOrderCallService orderCallService = SpringUtils.getBean(IOrderCallService.class); + private static IUserUseSecondaryCardService userUseSecondaryCardService = SpringUtils.getBean(IUserUseSecondaryCardService.class); private static OrderLogHandler orderLogHandler = SpringUtils.getBean(OrderLogHandler.class); @@ -886,10 +887,13 @@ public class OrderUtil { jsonObject.put("name", "报价订单支付成功,待服务,师傅"+users.getName()); orderLog.setContent(jsonObject.toJSONString()); int logInsertResult = orderLogService.insertOrderLog(orderLog); - //开始派单 - if (logInsertResult>0){ - DispatchUtil.dispatchOrder(order.getId()); - } + //绑定号码,打电话通知 + Map map= OrderBindWorkerUtil.getOrderBindWorker(order.getId()); + YunXinPhoneUtilAPI.httpsAxbTransfer(order.getWorkerPhone(), order.getId()); +// //开始派单 +// if (logInsertResult>0){ +// DispatchUtil.dispatchOrder(order.getId()); +// } System.out.println("订单日志插入结果: " + logInsertResult); System.out.println("需求报价订单处理完成"); } else { @@ -1026,6 +1030,7 @@ public class OrderUtil { order.setType(1); // 服务订单 order.setCreateType(1); // 用户自主下单 order.setUname(user.getName()); + //20250809处理过的一个故障 order.setPayPrice(payBefor.getAllmoney()); order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单 @@ -1051,6 +1056,7 @@ public class OrderUtil { UserAddress userAddress = userAddressService.selectUserAddressById(payBefor.getAddressid()); System.out.println("查询到的地址信息: " + (userAddress != null ? userAddress.toString() : "null")); if (userAddress != null) { + order.setAdressjson(com.alibaba.fastjson2.JSONObject.parseObject(userAddress.toString()).toJSONString()); order.setAddressId(userAddress.getId()); order.setName(userAddress.getName()); order.setPhone(userAddress.getPhone()); @@ -1332,6 +1338,26 @@ public class OrderUtil { System.out.println("师傅佣金处理完成,师傅ID: " + order.getWorkerId()); } } + System.out.println("开始计算增加积分" + orderid + "----------------------------------------------------------"); + //次卡下的服务不用给客户添加购物金 + if (com.ruoyi.common.utils.StringUtils.isBlank(order.getCartid())){ + //增加购物金 + BenefitPointsUtil.processBenefitPoints(order.getId(),order.getPayPrice(),"1"); + } + if (com.ruoyi.common.utils.StringUtils.isNotBlank(order.getCartid())){ + //次卡进行分佣操作,次卡的分佣只有一次, + UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(order.getCartid()); + if (userUseSecondaryCard.getUsenum().intValue() >= userUseSecondaryCard.getNum().intValue()){ + //次卡在这个时候就需要进行积分和购物金以的处理 + if (userUseSecondaryCard.getStatus()==1){ + BenefitPointsUtil.processBenefitPoints(userUseSecondaryCard.getId(), userUseSecondaryCard.getPaymoney(),"3"); + // JSONObject integralAndBenefitResult = IntegralAndBenefitUtil.processIntegralAndBenefit(totalAmount, orderId, user.getId()); + userUseSecondaryCard.setStatus(2L);//设置不可用 + } + + userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard); + } + } // // 处理用户通知(可选) // if (order.getUid() != null) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/ScheduledTaskUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/ScheduledTaskUtil.java index 458b5af..6a04d27 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/ScheduledTaskUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/ScheduledTaskUtil.java @@ -5,9 +5,7 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.domain.Order; import com.ruoyi.system.domain.Users; -import com.ruoyi.system.service.IOrderService; -import com.ruoyi.system.service.IUsersService; -import com.ruoyi.system.service.IWorkerMoneyLogService; +import com.ruoyi.system.service.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; @@ -62,6 +60,9 @@ public class ScheduledTaskUtil implements CommandLineRunner { // 任务执行统计 private final Map taskStats = new ConcurrentHashMap<>(); + + private static ICouponsService couponsService = SpringUtils.getBean(ICouponsService.class); + private static ICouponUserService couponUserService = SpringUtils.getBean(ICouponUserService.class); /** * 初始化方法,在Bean创建后执行 */ @@ -221,6 +222,34 @@ public class ScheduledTaskUtil implements CommandLineRunner { } } + + /** + * 订单状态超时检查任务 + * 每10分钟执行一次,检查各种状态的订单是否超时 + * + * 使用说明: + * - 检查服务中订单是否超过预期时间 + * - 检查待支付订单是否超时 + * - 处理异常状态订单 + */ + @Scheduled(fixedRate = 60 * 60 * 1000) // 每60分钟执行一次 + public void checkcouponsStatusTimeout() { + String taskName = "优惠券过期检查时检查"; + long startTime = System.currentTimeMillis(); + + try { + log.info("开始执行{}任务", taskName); + + Map stat = CouponUtil.processExpiredCoupons(couponsService, couponUserService); + + } catch (Exception e) { + log.error("{}任务执行失败", taskName, e); + updateTaskStatistics(taskName, false, System.currentTimeMillis() - startTime); + } + } + + + /** * 系统数据清理任务 * 每天凌晨2点执行,清理过期数据 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WorkerCommissionUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WorkerCommissionUtil.java index 94c3021..b01f0d6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WorkerCommissionUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/WorkerCommissionUtil.java @@ -721,25 +721,25 @@ public class WorkerCommissionUtil { // 15. 计算并更新订单总金额(用于开票) updateOrderTotalPriceForInvoice(order, amountComposition); - //次卡下的服务不用给客户添加购物金 - if (StringUtils.isBlank(order.getCartid())){ - //增加购物金 - BenefitPointsUtil.processBenefitPoints(order.getId(),getOrderTotalAmount(order),"1"); - } - if (StringUtils.isNotBlank(order.getCartid())){ - //次卡进行分佣操作,次卡的分佣只有一次, - UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(order.getCartid()); - if (userUseSecondaryCard.getUsenum().intValue() >= userUseSecondaryCard.getNum().intValue()){ - //次卡在这个时候就需要进行积分和购物金以的处理 - if (userUseSecondaryCard.getStatus()==1){ - BenefitPointsUtil.processBenefitPoints(userUseSecondaryCard.getId(), userUseSecondaryCard.getPaymoney(),"3"); - // JSONObject integralAndBenefitResult = IntegralAndBenefitUtil.processIntegralAndBenefit(totalAmount, orderId, user.getId()); - userUseSecondaryCard.setStatus(2L);//设置不可用 - } - - userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard); - } - } +// //次卡下的服务不用给客户添加购物金 +// if (StringUtils.isBlank(order.getCartid())){ +// //增加购物金 +// BenefitPointsUtil.processBenefitPoints(order.getId(),order.getPayPrice(),"1"); +// } +// if (StringUtils.isNotBlank(order.getCartid())){ +// //次卡进行分佣操作,次卡的分佣只有一次, +// UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(order.getCartid()); +// if (userUseSecondaryCard.getUsenum().intValue() >= userUseSecondaryCard.getNum().intValue()){ +// //次卡在这个时候就需要进行积分和购物金以的处理 +// if (userUseSecondaryCard.getStatus()==1){ +// BenefitPointsUtil.processBenefitPoints(userUseSecondaryCard.getId(), userUseSecondaryCard.getPaymoney(),"3"); +// // JSONObject integralAndBenefitResult = IntegralAndBenefitUtil.processIntegralAndBenefit(totalAmount, orderId, user.getId()); +// userUseSecondaryCard.setStatus(2L);//设置不可用 +// } +// +// userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard); +// } +// } //修改库存及销量 OrderUtil.updateInventoryAndSales(order.getOrderId(), 1); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PayMoneyLogMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PayMoneyLogMapper.java index 5d2b999..4592334 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PayMoneyLogMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/PayMoneyLogMapper.java @@ -73,4 +73,11 @@ public interface PayMoneyLogMapper * @return 支付记录集合 */ public List selectPayMoneyLogListForExport(PayMoneyLog payMoneyLog); + + /** + * 按照订单ID分组统计价格总和 + * + * @return 订单价格统计列表 + */ + public List> selectOrderPriceStatistics(Long uid); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IPayMoneyLogService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IPayMoneyLogService.java index 6affdc1..49ffa82 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IPayMoneyLogService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IPayMoneyLogService.java @@ -73,4 +73,11 @@ public interface IPayMoneyLogService * @return 支付记录集合 */ public List selectPayMoneyLogListForExport(PayMoneyLog payMoneyLog); + + /** + * 按照订单ID分组统计支付价格总和 + * + * @return 订单价格统计列表,包含orderId和totalPrice + */ + public List> getOrderPriceStatistics(Long uid); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PayMoneyLogServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PayMoneyLogServiceImpl.java index c0075be..0b0a239 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PayMoneyLogServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PayMoneyLogServiceImpl.java @@ -113,4 +113,15 @@ public class PayMoneyLogServiceImpl implements IPayMoneyLogService { return payMoneyLogMapper.selectPayMoneyLogListForExport(payMoneyLog); } + + /** + * 按照订单ID分组统计支付价格总和 + * + * @return 订单价格统计列表,包含orderId和totalPrice + */ + @Override + public List> getOrderPriceStatistics(Long uid) + { + return payMoneyLogMapper.selectOrderPriceStatistics(uid); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/PayMoneyLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/PayMoneyLogMapper.xml index e221d47..ee6106a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/PayMoneyLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/PayMoneyLogMapper.xml @@ -128,4 +128,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by pml.id desc + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml index 0b810ba..24abb32 100644 --- a/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/WorkerMoneyLogMapper.xml @@ -106,8 +106,6 @@ cr, mergin, door_price, - created_at, - updated_at, status, status_type, beginlook, @@ -118,6 +116,8 @@ look_money, gongshi, clmoney, + created_at, + updated_at #{workerId}, @@ -130,8 +130,6 @@ #{cr}, #{mergin}, #{doorPrice}, - #{createdAt}, - #{updatedAt}, #{status}, #{statusType}, #{beginlook}, @@ -142,6 +140,8 @@ #{lookMoney}, #{gongshi}, #{clmoney}, + NOW(), + NOW() diff --git a/ruoyi-ui/.env.production b/ruoyi-ui/.env.production index f2a937e..6d033e0 100644 --- a/ruoyi-ui/.env.production +++ b/ruoyi-ui/.env.production @@ -5,4 +5,4 @@ VUE_APP_TITLE = 华府人家 ENV = 'production' # 西安华府人家装饰工程有限公司/生产环境 -VUE_APP_BASE_API = '/prod-api' +VUE_APP_BASE_API = '/api' diff --git a/ruoyi-ui/dist.7z b/ruoyi-ui/dist.7z deleted file mode 100644 index 300984f..0000000 Binary files a/ruoyi-ui/dist.7z and /dev/null differ diff --git a/ruoyi-ui/dist.zip b/ruoyi-ui/dist.zip deleted file mode 100644 index bf622ce..0000000 Binary files a/ruoyi-ui/dist.zip and /dev/null differ diff --git a/ruoyi-ui/src/views/system/Coupons/index.vue b/ruoyi-ui/src/views/system/Coupons/index.vue index 561b4de..b067e51 100644 --- a/ruoyi-ui/src/views/system/Coupons/index.vue +++ b/ruoyi-ui/src/views/system/Coupons/index.vue @@ -401,7 +401,7 @@ style="width: 200px;" placeholder="请输入数量" /> - 领取后至少30天有效 + @@ -854,7 +854,7 @@ export default { handleUpdate(row) { this.reset(); const id = row.id || this.ids; - this.getDataUserListByCoupon(id); + //this.getDataUserListByCoupon(id); getCoupons(id).then(response => { this.form = response.data; // 处理日期字段 diff --git a/ruoyi-ui/src/views/system/Order/components/OrderDetailDialog.vue b/ruoyi-ui/src/views/system/Order/components/OrderDetailDialog.vue index 8fb0a70..a1e8997 100644 --- a/ruoyi-ui/src/views/system/Order/components/OrderDetailDialog.vue +++ b/ruoyi-ui/src/views/system/Order/components/OrderDetailDialog.vue @@ -1,9 +1,9 @@ - - diff --git a/ruoyi-ui/src/views/system/Order/index.vue b/ruoyi-ui/src/views/system/Order/index.vue index 0a9c01f..24455af 100644 --- a/ruoyi-ui/src/views/system/Order/index.vue +++ b/ruoyi-ui/src/views/system/Order/index.vue @@ -5346,7 +5346,7 @@ export default { try { // 这里后续替换为真实接口调用 // await request.post('/system/Order/project-quote', payload) - this.$message.success('报价已生成(待接入接口)') + // 刷新订单详情与列表 this.refreshOrderDetail() this.getList() @@ -5383,6 +5383,7 @@ export default { cancelReason: row.cancelReason, mark: row.mark, fileData: row.fileData, + productId:row.productId, servicePhotos: row.servicePhotos || [], // 订单基本信息 userName: row.uname || row.name,