2025008071805
This commit is contained in:
parent
840e32f7ca
commit
1aab36f046
|
|
@ -77,6 +77,12 @@
|
||||||
<artifactId>xmlbeans</artifactId>
|
<artifactId>xmlbeans</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.6.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,22 @@ import com.ruoyi.system.domain.Users;
|
||||||
import com.ruoyi.system.domain.UsersInvoiceInfo;
|
import com.ruoyi.system.domain.UsersInvoiceInfo;
|
||||||
import com.ruoyi.system.service.IUsersService;
|
import com.ruoyi.system.service.IUsersService;
|
||||||
import com.ruoyi.system.service.IUsersInvoiceInfoService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发票管理控制器
|
* 发票管理控制器
|
||||||
|
|
@ -45,10 +52,13 @@ public class AppleInvoiceController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUsersInvoiceInfoService usersInvoiceInfoService;
|
private IUsersInvoiceInfoService usersInvoiceInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPayMoneyLogService payMoneyLogService;
|
||||||
|
|
||||||
private ObjectMapper objectMapper = new ObjectMapper();
|
private ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户发票中心数据
|
* 获取用户发票中心数据(基于支付记录数据源)
|
||||||
*
|
*
|
||||||
* @param params 请求参数
|
* @param params 请求参数
|
||||||
* @param request HTTP请求对象
|
* @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 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;
|
int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 10;
|
||||||
|
|
||||||
// 4. 获取发票中心数据
|
// 4. 基于支付记录获取发票中心数据
|
||||||
Map<String, Object> invoiceCenterData = InvoiceUtil.getUserInvoiceCenter(user.getId(), page, limit);
|
Map<String, Object> invoiceCenterData = getInvoiceCenterDataFromPayLogs(user.getId(), page, limit);
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess(invoiceCenterData);
|
return AppletControllerUtil.appletSuccess(invoiceCenterData);
|
||||||
|
|
||||||
|
|
@ -85,7 +95,205 @@ public class AppleInvoiceController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取待开票订单列表
|
* 基于支付记录获取发票中心数据
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param page 页码
|
||||||
|
* @param limit 每页数量
|
||||||
|
* @return 发票中心数据
|
||||||
|
*/
|
||||||
|
private Map<String, Object> getInvoiceCenterDataFromPayLogs(Long userId, int page, int limit) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. 获取所有支付记录统计(按订单ID分组)
|
||||||
|
List<Map<String, Object>> allOrderStats = payMoneyLogService.getOrderPriceStatistics(userId);
|
||||||
|
|
||||||
|
// 2. 获取已开票记录
|
||||||
|
List<Map<String, Object>> completedInvoices = getCompletedInvoicesFromPayLogs(userId, page, limit);
|
||||||
|
|
||||||
|
// 3. 获取待开票订单(过滤掉已开票的)
|
||||||
|
List<Map<String, Object>> pendingInvoices = getPendingInvoicesFromPayLogs(allOrderStats, completedInvoices, page, limit);
|
||||||
|
|
||||||
|
// 4. 统计数据
|
||||||
|
Map<String, Object> 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<Map<String, Object>> getCompletedInvoicesFromPayLogs(Long userId, int page, int limit) {
|
||||||
|
try {
|
||||||
|
// 设置分页
|
||||||
|
com.github.pagehelper.PageHelper.startPage(page, limit);
|
||||||
|
|
||||||
|
UsersInvoiceInfo query = new UsersInvoiceInfo();
|
||||||
|
query.setUid(userId.intValue());
|
||||||
|
List<UsersInvoiceInfo> invoiceList = usersInvoiceInfoService.selectUsersInvoiceInfoList(query);
|
||||||
|
|
||||||
|
List<Map<String, Object>> completedInvoices = new ArrayList<>();
|
||||||
|
for (UsersInvoiceInfo invoice : invoiceList) {
|
||||||
|
Map<String, Object> 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<Map<String, Object>> getPendingInvoicesFromPayLogs(
|
||||||
|
List<Map<String, Object>> allOrderStats,
|
||||||
|
List<Map<String, Object>> completedInvoices,
|
||||||
|
int page, int limit) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Map<String, Object>> pendingInvoices = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取已开票的订单ID集合
|
||||||
|
Set<String> invoicedOrderIds = new HashSet<>();
|
||||||
|
for (Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> getInvoiceStatisticsFromPayLogs(
|
||||||
|
List<Map<String, Object>> pendingInvoices,
|
||||||
|
List<Map<String, Object>> completedInvoices) {
|
||||||
|
|
||||||
|
Map<String, Object> 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 params 请求参数
|
||||||
* @param request HTTP请求对象
|
* @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 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;
|
int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 10;
|
||||||
|
|
||||||
// 4. 获取待开票订单列表
|
// 4. 基于支付记录获取待开票订单列表
|
||||||
List<Map<String, Object>> pendingOrders = InvoiceUtil.getPendingInvoiceOrders(user.getId(), page, limit);
|
List<Map<String, Object>> allOrderStats = payMoneyLogService.getOrderPriceStatistics(user.getId());
|
||||||
|
List<Map<String, Object>> completedInvoices = getCompletedInvoicesFromPayLogs(user.getId(), 1, 1000);
|
||||||
|
List<Map<String, Object>> pendingOrders = getPendingInvoicesFromPayLogs(allOrderStats, completedInvoices, page, limit);
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess(pendingOrders);
|
return AppletControllerUtil.appletSuccess(pendingOrders);
|
||||||
|
|
||||||
|
|
@ -122,7 +332,7 @@ public class AppleInvoiceController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取已开票列表
|
* 获取已开票列表(基于支付记录数据源)
|
||||||
*
|
*
|
||||||
* @param params 请求参数
|
* @param params 请求参数
|
||||||
* @param request HTTP请求对象
|
* @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 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;
|
int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 10;
|
||||||
|
|
||||||
// 4. 获取已开票列表
|
// 4. 基于支付记录获取已开票列表
|
||||||
List<Map<String, Object>> completedInvoices = InvoiceUtil.getCompletedInvoices(user.getId(), page, limit);
|
List<Map<String, Object>> completedInvoices = getCompletedInvoicesFromPayLogs(user.getId(), page, limit);
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess(completedInvoices);
|
return AppletControllerUtil.appletSuccess(completedInvoices);
|
||||||
|
|
||||||
|
|
@ -158,6 +368,197 @@ public class AppleInvoiceController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 开具发票接口
|
||||||
|
// *
|
||||||
|
// * @param params 发票参数
|
||||||
|
// * @param request HTTP请求对象
|
||||||
|
// * @return 开票结果
|
||||||
|
// */
|
||||||
|
// @PostMapping("/create")
|
||||||
|
// public AjaxResult createInvoice(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
|
// try {
|
||||||
|
// // 1. 验证用户登录状态
|
||||||
|
// String token = request.getHeader("token");
|
||||||
|
// Map<String, Object> 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<Map<String, Object>> orderStats = payMoneyLogService.getOrderPriceStatistics();
|
||||||
|
// BigDecimal invoiceAmount = null;
|
||||||
|
//
|
||||||
|
// for (Map<String, Object> 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<String, Object> params, HttpServletRequest request) {
|
||||||
|
// try {
|
||||||
|
// // 1. 验证用户登录状态
|
||||||
|
// String token = request.getHeader("token");
|
||||||
|
// Map<String, Object> 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<String> orderIds;
|
||||||
|
// if (orderIdsObj instanceof List) {
|
||||||
|
// orderIds = (List<String>) orderIdsObj;
|
||||||
|
// } else if (orderIdsObj instanceof String) {
|
||||||
|
// // 如果是字符串,尝试解析
|
||||||
|
// String orderIdsStr = orderIdsObj.toString();
|
||||||
|
// orderIds = objectMapper.readValue(orderIdsStr, new TypeReference<List<String>>() {});
|
||||||
|
// } else {
|
||||||
|
// return AppletControllerUtil.appletWarning("订单ID格式错误");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (orderIds.isEmpty()) {
|
||||||
|
// return AppletControllerUtil.appletWarning("订单ID列表不能为空");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 4. 调用IPayMoneyLogService查询开票金额
|
||||||
|
// List<Map<String, Object>> orderStats = payMoneyLogService.getOrderPriceStatistics();
|
||||||
|
// List<String> validOrderIds = new ArrayList<>();
|
||||||
|
// BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
//
|
||||||
|
// for (String orderId : orderIds) {
|
||||||
|
// for (Map<String, Object> 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<String, Object> params, HttpServletRequest request) {
|
||||||
|
// try {
|
||||||
|
// // 1. 验证用户登录状态
|
||||||
|
// String token = request.getHeader("token");
|
||||||
|
// Map<String, Object> 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<String> orderIds;
|
||||||
|
// if (orderIdsObj instanceof List) {
|
||||||
|
// orderIds = (List<String>) orderIdsObj;
|
||||||
|
// } else if (orderIdsObj instanceof String) {
|
||||||
|
// // 如果是字符串,尝试解析
|
||||||
|
// String orderIdsStr = orderIdsObj.toString();
|
||||||
|
// orderIds = objectMapper.readValue(orderIdsStr, new TypeReference<List<String>>() {});
|
||||||
|
// } 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());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开具发票接口(支持批量开票)
|
* 开具发票接口(支持批量开票)
|
||||||
*
|
*
|
||||||
|
|
@ -168,9 +569,6 @@ public class AppleInvoiceController extends BaseController {
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public AjaxResult createInvoice(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
public AjaxResult createInvoice(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
// 调试日志:输出接收到的原始参数
|
|
||||||
System.out.println("接收到的原始参数: " + params);
|
|
||||||
|
|
||||||
// 1. 验证用户登录状态
|
// 1. 验证用户登录状态
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
|
|
@ -184,65 +582,109 @@ public class AppleInvoiceController extends BaseController {
|
||||||
return AppletControllerUtil.appletdengluWarning("");
|
return AppletControllerUtil.appletdengluWarning("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证必要参数
|
// 3. 获取订单ID数组
|
||||||
List<String> orderIds = new ArrayList<>();
|
Object orderIdsObj = params.get("orderIds");
|
||||||
|
if (orderIdsObj == null) {
|
||||||
|
return AppletControllerUtil.appletWarning("订单ID列表不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
// 支持多种参数格式:orderIds数组、orderIds字符串数组、单个orderId
|
List<String> orderIds;
|
||||||
if (params.get("orderIds") != null) {
|
if (orderIdsObj instanceof List) {
|
||||||
Object orderIdsObj = params.get("orderIds");
|
orderIds = (List<String>) orderIdsObj;
|
||||||
|
} else if (orderIdsObj instanceof String) {
|
||||||
if (orderIdsObj instanceof List) {
|
String orderIdsStr = orderIdsObj.toString();
|
||||||
// 批量开票:orderIds数组
|
orderIds = objectMapper.readValue(orderIdsStr, new TypeReference<List<String>>() {});
|
||||||
List<?> orderIdList = (List<?>) orderIdsObj;
|
} else {
|
||||||
for (Object orderIdObj : orderIdList) {
|
return AppletControllerUtil.appletWarning("订单ID格式错误");
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (params.get("orderId") != null) {
|
|
||||||
// 单个开票:orderId字符串(兼容旧版本)
|
|
||||||
orderIds.add(params.get("orderId").toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderIds.isEmpty()) {
|
if (orderIds.isEmpty()) {
|
||||||
return AppletControllerUtil.appletWarning("请选择要开票的订单");
|
return AppletControllerUtil.appletWarning("订单ID列表不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调试日志:输出解析后的订单ID列表
|
// 4. 使用IPayMoneyLogService查询订单金额
|
||||||
System.out.println("解析后的订单ID列表: " + orderIds);
|
List<Map<String, Object>> orderStats = payMoneyLogService.getOrderPriceStatistics(user.getId());
|
||||||
|
List<String> validOrderIds = new ArrayList<>();
|
||||||
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
// 4. 调用批量开票方法
|
for (String orderId : orderIds) {
|
||||||
return InvoiceUtil.createBatchInvoice(user.getId(), orderIds, params);
|
for (Map<String, Object> 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. 直接创建发票记录,不使用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<String, Object> result = new HashMap<>();
|
||||||
|
result.put("message", "发票开具成功");
|
||||||
|
result.put("orderIds", validOrderIds);
|
||||||
|
result.put("totalAmount", totalAmount);
|
||||||
|
|
||||||
|
return AppletControllerUtil.appletSuccess(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AppletControllerUtil.appletError("开具发票失败:" + e.getMessage());
|
return AppletControllerUtil.appletError("开具发票失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户已保存的发票信息
|
* 获取用户已保存的发票信息
|
||||||
*
|
*
|
||||||
|
|
@ -276,7 +718,7 @@ public class AppleInvoiceController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取发票统计数据
|
* 获取发票统计数据(基于支付记录数据源)
|
||||||
*
|
*
|
||||||
* @param request HTTP请求对象
|
* @param request HTTP请求对象
|
||||||
* @return 统计数据
|
* @return 统计数据
|
||||||
|
|
@ -297,8 +739,11 @@ public class AppleInvoiceController extends BaseController {
|
||||||
return AppletControllerUtil.appletdengluWarning("");
|
return AppletControllerUtil.appletdengluWarning("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 获取统计数据
|
// 3. 基于支付记录获取统计数据
|
||||||
Map<String, Object> statistics = InvoiceUtil.getInvoiceStatistics(user.getId());
|
List<Map<String, Object>> allOrderStats = payMoneyLogService.getOrderPriceStatistics(user.getId());
|
||||||
|
List<Map<String, Object>> completedInvoices = getCompletedInvoicesFromPayLogs(user.getId(), 1, 1000);
|
||||||
|
List<Map<String, Object>> pendingInvoices = getPendingInvoicesFromPayLogs(allOrderStats, completedInvoices, 1, 1000);
|
||||||
|
Map<String, Object> statistics = getInvoiceStatisticsFromPayLogs(pendingInvoices, completedInvoices);
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess(statistics);
|
return AppletControllerUtil.appletSuccess(statistics);
|
||||||
|
|
||||||
|
|
@ -502,4 +947,5 @@ public class AppleInvoiceController extends BaseController {
|
||||||
return AppletControllerUtil.appletError("获取发票详情失败:" + e.getMessage());
|
return AppletControllerUtil.appletError("获取发票详情失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6147,6 +6147,7 @@ public class AppleOrderController extends BaseController {
|
||||||
@PostMapping(value = "/api/coupon/add")
|
@PostMapping(value = "/api/coupon/add")
|
||||||
public AjaxResult apicouponadd(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
public AjaxResult apicouponadd(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
Long id = Long.parseLong(params.get("coupon_id").toString());
|
Long id = Long.parseLong(params.get("coupon_id").toString());
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
// 获取token
|
// 获取token
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
if (StringUtils.isEmpty(token)) {
|
if (StringUtils.isEmpty(token)) {
|
||||||
|
|
@ -6166,6 +6167,11 @@ public class AppleOrderController extends BaseController {
|
||||||
if (coupon == null) {
|
if (coupon == null) {
|
||||||
AppletControllerUtil.appletWarning("优惠券不存在");
|
AppletControllerUtil.appletWarning("优惠券不存在");
|
||||||
}
|
}
|
||||||
|
if (coupon.getStatus()==0){
|
||||||
|
AppletControllerUtil.appletWarning("优惠券已领用结束!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CouponUser couponUser = new CouponUser();
|
CouponUser couponUser = new CouponUser();
|
||||||
|
|
||||||
couponUser.setUid(user.getId());
|
couponUser.setUid(user.getId());
|
||||||
|
|
@ -6174,12 +6180,28 @@ public class AppleOrderController extends BaseController {
|
||||||
couponUser.setCouponPrice(coupon.getPrice().intValue());
|
couponUser.setCouponPrice(coupon.getPrice().intValue());
|
||||||
couponUser.setMinPrice(coupon.getMinPrice().longValue());
|
couponUser.setMinPrice(coupon.getMinPrice().longValue());
|
||||||
couponUser.setAddTime(new Date().getTime()/1000);
|
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.setCateId(coupon.getCateId());
|
||||||
couponUser.setProductId(coupon.getProductId());
|
couponUser.setProductId(coupon.getProductId());
|
||||||
couponUser.setReceiveType(String.valueOf(coupon.getReceiveType()));
|
couponUser.setReceiveType(String.valueOf(coupon.getReceiveType()));
|
||||||
couponUser.setStatus(1L);
|
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<CouponUser> couponUserList=couponUserService.selectCouponUserList(coupondata);
|
||||||
|
if (couponUserList.size()>=coupon.getCount()){
|
||||||
|
coupon.setStatus(0L);
|
||||||
|
couponsService.updateCoupons(coupon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess("操作成功");
|
return AppletControllerUtil.appletSuccess("操作成功");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1181,12 +1181,15 @@ public class ApplePayController extends BaseController {
|
||||||
if (newpayBefor!=null){
|
if (newpayBefor!=null){
|
||||||
// 创建订单
|
// 创建订单
|
||||||
newpayBefor.setStatus(2L);
|
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());
|
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||||
//回调方法用来处理订单相关数据
|
//回调方法用来处理订单相关数据
|
||||||
OrderUtil.prepayCallback(payBefor, user);
|
// OrderUtil.prepayCallback(payBefor, user);
|
||||||
payResult.put("istowx", 1);
|
payResult.put("istowx", 1);
|
||||||
return AppletControllerUtil.appletSuccess("支付成功");
|
return AppletControllerUtil.appletSuccess("支付成功");
|
||||||
}
|
}
|
||||||
|
|
@ -1218,12 +1221,16 @@ public class ApplePayController extends BaseController {
|
||||||
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
||||||
if (newpayBefor!=null){
|
if (newpayBefor!=null){
|
||||||
// 创建订单
|
// 创建订单
|
||||||
|
payBefor.setPaytime(new Date());
|
||||||
newpayBefor.setStatus(2L);
|
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());
|
//IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
|
||||||
payResult.put("istowx", 2);
|
payResult.put("istowx", 2);
|
||||||
|
|
@ -1240,7 +1247,7 @@ public class ApplePayController extends BaseController {
|
||||||
// payBefor.setStatus(2L); // 已支付
|
// payBefor.setStatus(2L); // 已支付
|
||||||
// payBefor.setPaytime(new Date());
|
// payBefor.setPaytime(new Date());
|
||||||
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||||
OrderUtil.prepayCallback(payBefor, user);
|
|
||||||
//扣减消费金服务金
|
//扣减消费金服务金
|
||||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||||
if (flg==0){
|
if (flg==0){
|
||||||
|
|
@ -1249,7 +1256,10 @@ public class ApplePayController extends BaseController {
|
||||||
// 创建订单
|
// 创建订单
|
||||||
newpayBefor.setStatus(2L);
|
newpayBefor.setStatus(2L);
|
||||||
newpayBefor.setPaytime(new Date());
|
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());
|
//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) {
|
if (wxMoney.compareTo(BigDecimal.ZERO) <= 0 && yeMoney.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
// 两项都为0,直接走后续逻辑
|
// 两项都为0,直接走后续逻辑
|
||||||
payBefor.setStatus(2L); // 已支付
|
// payBefor.setStatus(2L); // 已支付
|
||||||
payBefor.setPaytime(new Date());
|
// payBefor.setPaytime(new Date());
|
||||||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||||
OrderUtil.prepayCallback(payBefor, user);
|
|
||||||
//扣减消费金服务金
|
//扣减消费金服务金
|
||||||
// BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
// BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||||
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
|
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
|
||||||
|
|
@ -1279,7 +1289,10 @@ public class ApplePayController extends BaseController {
|
||||||
// 创建订单
|
// 创建订单
|
||||||
newpayBefor.setStatus(2L);
|
newpayBefor.setStatus(2L);
|
||||||
newpayBefor.setPaytime(new Date());
|
newpayBefor.setPaytime(new Date());
|
||||||
usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
int updat= usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
||||||
|
if (updat>0){
|
||||||
|
OrderUtil.prepayCallback(newpayBefor, user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
payResult.put("istowx", 1);
|
payResult.put("istowx", 1);
|
||||||
|
|
@ -1311,9 +1324,8 @@ public class ApplePayController extends BaseController {
|
||||||
payBefor.getOrderid()
|
payBefor.getOrderid()
|
||||||
);
|
);
|
||||||
if (balanceResult != null && Boolean.TRUE.equals(balanceResult.get("success"))) {
|
if (balanceResult != null && Boolean.TRUE.equals(balanceResult.get("success"))) {
|
||||||
payBefor.setStatus(2L); // 已支付
|
// payBefor.setStatus(2L); // 已支付
|
||||||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||||
OrderUtil.prepayCallback(payBefor, user);
|
|
||||||
//扣减消费金服务金
|
//扣减消费金服务金
|
||||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||||
if (flg==0){
|
if (flg==0){
|
||||||
|
|
@ -1322,7 +1334,10 @@ public class ApplePayController extends BaseController {
|
||||||
// 创建订单
|
// 创建订单
|
||||||
newpayBefor.setStatus(2L);
|
newpayBefor.setStatus(2L);
|
||||||
newpayBefor.setPaytime(new Date());
|
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());
|
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||||
|
|
|
||||||
|
|
@ -1580,15 +1580,16 @@ public class AppletController extends BaseController {
|
||||||
userInfo.put("tx_time", txTimeArr);
|
userInfo.put("tx_time", txTimeArr);
|
||||||
|
|
||||||
// 新增:查询该用户可用优惠券数量
|
// 新增:查询该用户可用优惠券数量
|
||||||
int couponNum = 0;
|
// int couponNum = CouponUtil.iscoupon(user.getId(), couponsService, couponUserService).size();
|
||||||
try {
|
int couponNum = couponUserService.selectCountCouponsByUid(user.getId(), 1L);
|
||||||
com.ruoyi.system.domain.CouponUser queryCoupon = new com.ruoyi.system.domain.CouponUser();
|
// try {
|
||||||
queryCoupon.setUid(user.getId());
|
// com.ruoyi.system.domain.CouponUser queryCoupon = new com.ruoyi.system.domain.CouponUser();
|
||||||
queryCoupon.setStatus(0L); // 0=可用
|
// queryCoupon.setUid(user.getId());
|
||||||
java.util.List<com.ruoyi.system.domain.CouponUser> couponList = couponUserService.selectCouponUserList(queryCoupon);
|
// queryCoupon.setStatus(0L); // 0=可用
|
||||||
couponNum = couponList != null ? couponList.size() : 0;
|
// java.util.List<com.ruoyi.system.domain.CouponUser> couponList = couponUserService.selectCouponUserList(queryCoupon);
|
||||||
} catch (Exception e) {
|
// couponNum = couponList != null ? couponList.size() : 0;
|
||||||
}
|
// } catch (Exception e) {
|
||||||
|
// }
|
||||||
userInfo.put("couponNum", couponNum);
|
userInfo.put("couponNum", couponNum);
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess(userInfo);
|
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}")
|
@GetMapping("/api/worker/quote/craft/{goodsId}")
|
||||||
public Object getWorkerQuoteCraft(@PathVariable("goodsId") Long goodsId) {
|
public Object getWorkerQuoteCraft(@PathVariable("goodsId") Long goodsId) {
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,24 @@ package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.ControllerUtil.*;
|
import com.ruoyi.system.ControllerUtil.*;
|
||||||
import com.ruoyi.system.domain.*;
|
import com.ruoyi.system.domain.*;
|
||||||
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.service.*;
|
||||||
import com.winnerlook.model.VoiceResponseResult;
|
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.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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 com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
|
@ -37,6 +37,7 @@ import com.ruoyi.system.domain.ServiceGoods;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-05-13
|
* @date 2025-05-13
|
||||||
*/
|
*/
|
||||||
|
@Api(tags = "订单管理接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/Order")
|
@RequestMapping("/system/Order")
|
||||||
public class OrderController extends BaseController {
|
public class OrderController extends BaseController {
|
||||||
|
|
@ -48,6 +49,19 @@ public class OrderController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUsersPayBeforService usersPayBeforService;
|
private IUsersPayBeforService usersPayBeforService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IQuoteTypeService quoteTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IQuoteCraftService quoteCraftService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IQuoteMaterialTypeService quoteMaterialTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IQuoteMaterialService quoteMaterialService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IUsersService usersService;
|
IUsersService usersService;
|
||||||
|
|
@ -1051,4 +1065,556 @@ public class OrderController extends BaseController {
|
||||||
return error("项目报价失败:" + e.getMessage());
|
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<String> basicList = new ArrayList<>();
|
||||||
|
Map<String, Object> 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<OrderLog> 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<OrderLog> logs = orderLogService.selectOrderLogList(logQuery);
|
||||||
|
if (logs != null && !logs.isEmpty()) {
|
||||||
|
OrderLog logdata = logs.getFirst();
|
||||||
|
if (logdata != null) {
|
||||||
|
Map<String, Object> paydata = new HashMap<>();
|
||||||
|
paydata.put("weikuan", logdata.getPaid());
|
||||||
|
paydata.put("dingjin", logdata.getDepPaid());
|
||||||
|
data.put("payStatusdata", paydata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Map<String, Object> 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<String> 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<String, Object> 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<QuoteType> typeList = quoteTypeService.selectQuoteTypeList(typeQuery);
|
||||||
|
List<Object> dataArr = new ArrayList<>();
|
||||||
|
for (QuoteType type : typeList) {
|
||||||
|
Map<String, Object> typeMap = new HashMap<>();
|
||||||
|
typeMap.put("id", type.getId());
|
||||||
|
typeMap.put("title", type.getTitle());
|
||||||
|
// 3. 查询工艺(IQuoteCraftService)
|
||||||
|
QuoteCraft craftQuery = new QuoteCraft();
|
||||||
|
craftQuery.setTypeId("[\"" + type.getId() + "\"]");
|
||||||
|
List<QuoteCraft> craftList = quoteCraftService.selectQuoteCraftList(craftQuery);
|
||||||
|
List<Map<String, Object>> craftArr = new ArrayList<>();
|
||||||
|
for (QuoteCraft craft : craftList) {
|
||||||
|
Map<String, Object> 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<String> 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<QuoteMaterialType> typeList = quoteMaterialTypeService.selectQuoteMaterialTypeList(typeQuery);
|
||||||
|
List<Object> dataArr = new ArrayList<>();
|
||||||
|
for (QuoteMaterialType type : typeList) {
|
||||||
|
Map<String, Object> typeMap = new HashMap<>();
|
||||||
|
typeMap.put("id", type.getId());
|
||||||
|
typeMap.put("title", type.getTitle());
|
||||||
|
// 3. 查询物料信息(IQuoteMaterialService)
|
||||||
|
QuoteMaterial materialQuery = new QuoteMaterial();
|
||||||
|
materialQuery.setTypeId("\"" + type.getId() + "\"");
|
||||||
|
List<QuoteMaterial> materialList = quoteMaterialService.selectQuoteMaterialList(materialQuery);
|
||||||
|
List<Map<String, Object>> materialArr = new ArrayList<>();
|
||||||
|
for (QuoteMaterial material : materialList) {
|
||||||
|
Map<String, Object> 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<String> 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<String, Object> 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<Map<String, Object>> craftList = (List<Map<String, Object>>) params.get("craft");
|
||||||
|
if (craftList != null) {
|
||||||
|
for (Map<String, Object> 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<Map<String, Object>> materialList = (List<Map<String, Object>>) params.get("material");
|
||||||
|
if (materialList != null) {
|
||||||
|
for (Map<String, Object> 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<String, Object> resultJson = new LinkedHashMap<>();
|
||||||
|
// project
|
||||||
|
Map<String, Object> project = new LinkedHashMap<>();
|
||||||
|
project.put("name", "项目费用");
|
||||||
|
project.put("price", totalPrice);
|
||||||
|
resultJson.put("project", project);
|
||||||
|
Map<String, Object> reductionproject = new LinkedHashMap<>();
|
||||||
|
reductionproject.put("name", "优惠金额");
|
||||||
|
reductionproject.put("price", params.get("reduction"));
|
||||||
|
resultJson.put("reduction", reductionproject);
|
||||||
|
Map<String, Object> 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<Map<String, Object>> craftListNew = new ArrayList<>();
|
||||||
|
if (craftList != null) {
|
||||||
|
for (Map<String, Object> craft : craftList) {
|
||||||
|
Map<String, Object> 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<Map<String, Object>> materialListNew = new ArrayList<>();
|
||||||
|
if (materialList != null) {
|
||||||
|
for (Map<String, Object> material : materialList) {
|
||||||
|
Map<String, Object> 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<OrderLog> 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<UsersPayBefor> 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<UsersPayBefor> 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("报价失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,16 @@ public class PayMoneyLogController extends BaseController
|
||||||
return success(payMoneyLogService.getPayMoneyLogStatistics());
|
return success(payMoneyLogService.getPayMoneyLogStatistics());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单价格统计(按订单ID分组)
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:PayMoneyLog:query')")
|
||||||
|
@GetMapping(value = "/getOrderPriceStatistics")
|
||||||
|
public AjaxResult getOrderPriceStatistics()
|
||||||
|
{
|
||||||
|
return success(payMoneyLogService.getOrderPriceStatistics(1l));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出支付记录列表
|
* 导出支付记录列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -518,13 +518,13 @@ public class PayNotifyController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usersPayBefor != null) {
|
// if (usersPayBefor != null) {
|
||||||
usersPayBefor.setStatus(2L);
|
// usersPayBefor.setStatus(2L);
|
||||||
usersPayBefor.setPaytime(new Date());
|
// usersPayBefor.setPaytime(new Date());
|
||||||
usersPayBefor.setPaycode(transactionId);
|
// usersPayBefor.setPaycode(transactionId);
|
||||||
usersPayBeforService.updateUsersPayBefor(usersPayBefor);
|
// usersPayBeforService.updateUsersPayBefor(usersPayBefor);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
Users users = null;
|
Users users = null;
|
||||||
if (usersPayBefor != null) {
|
if (usersPayBefor != null) {
|
||||||
users = usersService.selectUsersById(usersPayBefor.getUid());
|
users = usersService.selectUsersById(usersPayBefor.getUid());
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,14 @@ public class ServiceCateController extends BaseController
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1868,6 +1868,10 @@ public class AppletControllerUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (couponUser.getCateId() == null && couponUser.getProductId() == null){
|
||||||
|
suitTitle="通用券";
|
||||||
|
}
|
||||||
if (couponUser.getReceiveType().equals("1")){
|
if (couponUser.getReceiveType().equals("1")){
|
||||||
if (totalPrice!=null){
|
if (totalPrice!=null){
|
||||||
if (totalPrice.compareTo(new BigDecimal(couponUser.getMinPrice()))>0){
|
if (totalPrice.compareTo(new BigDecimal(couponUser.getMinPrice()))>0){
|
||||||
|
|
@ -1896,7 +1900,7 @@ public class AppletControllerUtil {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
couponData.put("tag", tag);
|
couponData.put("tag","tag");
|
||||||
|
|
||||||
resultList.add(couponData);
|
resultList.add(couponData);
|
||||||
}
|
}
|
||||||
|
|
@ -1916,7 +1920,7 @@ public class AppletControllerUtil {
|
||||||
for (Coupons coupons : couponsList) {
|
for (Coupons coupons : couponsList) {
|
||||||
Map<String, Object> couponData = new HashMap<>();
|
Map<String, Object> couponData = new HashMap<>();
|
||||||
couponData.put("id", coupons.getId());
|
couponData.put("id", coupons.getId());
|
||||||
couponData.put("title", coupons.getId());
|
couponData.put("title", coupons.getTitle());
|
||||||
couponData.put("price", coupons.getPrice());
|
couponData.put("price", coupons.getPrice());
|
||||||
couponData.put("min_price", coupons.getMinPrice());
|
couponData.put("min_price", coupons.getMinPrice());
|
||||||
couponData.put("start_time", coupons.getStartTime());
|
couponData.put("start_time", coupons.getStartTime());
|
||||||
|
|
@ -5542,6 +5546,7 @@ public class AppletControllerUtil {
|
||||||
order.setProductId(serviceGoods.getId());
|
order.setProductId(serviceGoods.getId());
|
||||||
order.setBigtype(serviceGoods.getServicetype());
|
order.setBigtype(serviceGoods.getServicetype());
|
||||||
order.setProductName(serviceGoods.getTitle());
|
order.setProductName(serviceGoods.getTitle());
|
||||||
|
|
||||||
order.setReamk(reamk);
|
order.setReamk(reamk);
|
||||||
order.setSku(sku);
|
order.setSku(sku);
|
||||||
if (userAddress != null) {
|
if (userAddress != null) {
|
||||||
|
|
@ -5580,6 +5585,14 @@ public class AppletControllerUtil {
|
||||||
order.setDeduction(new BigDecimal(0));
|
order.setDeduction(new BigDecimal(0));
|
||||||
order.setFileData(attachments); // 设置附件数据
|
order.setFileData(attachments); // 设置附件数据
|
||||||
order.setType(1);
|
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));
|
//order.setPayPrice(new BigDecimal(0));
|
||||||
int insertResult = orderService.insertOrder(order);
|
int insertResult = orderService.insertOrder(order);
|
||||||
if (insertResult <= 0) {
|
if (insertResult <= 0) {
|
||||||
|
|
@ -5716,6 +5729,13 @@ public class AppletControllerUtil {
|
||||||
order.setProductName(serviceGoods.getTitle());
|
order.setProductName(serviceGoods.getTitle());
|
||||||
order.setSku(sku);
|
order.setSku(sku);
|
||||||
order.setBigtype(serviceGoods.getServicetype());
|
order.setBigtype(serviceGoods.getServicetype());
|
||||||
|
if (userAddress != null) {
|
||||||
|
try {
|
||||||
|
order.setAdressjson(JSON.toJSONString(userAddress));
|
||||||
|
} catch (Exception e) {
|
||||||
|
order.setAdressjson(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(StringUtils.isNotBlank(cikaid)){
|
if(StringUtils.isNotBlank(cikaid)){
|
||||||
order.setTotalPrice(serviceGoods.getFixedprice());
|
order.setTotalPrice(serviceGoods.getFixedprice());
|
||||||
order.setCartid(cikaid);
|
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.setTotalPrice(itemPrice);
|
||||||
order.setGoodPrice(BigDecimal.ZERO);
|
order.setGoodPrice(BigDecimal.ZERO);
|
||||||
order.setServicePrice(BigDecimal.ZERO);
|
order.setServicePrice(BigDecimal.ZERO);
|
||||||
|
|
@ -6007,6 +6033,13 @@ public class AppletControllerUtil {
|
||||||
order.setProductName(serviceGoods.getTitle());
|
order.setProductName(serviceGoods.getTitle());
|
||||||
order.setSku(sku);
|
order.setSku(sku);
|
||||||
order.setJsonStatus(0);
|
order.setJsonStatus(0);
|
||||||
|
if (userAddress != null) {
|
||||||
|
try {
|
||||||
|
order.setAdressjson(JSON.toJSONString(userAddress));
|
||||||
|
} catch (Exception e) {
|
||||||
|
order.setAdressjson(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
order.setType(1);
|
order.setType(1);
|
||||||
order.setNum(Long.valueOf(num));
|
order.setNum(Long.valueOf(num));
|
||||||
if (userAddress != null) {
|
if (userAddress != null) {
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ public class BenefitPointsUtil {
|
||||||
private static BenefitPointsResult processServiceOrder(Order order, Users user, BigDecimal money, Map<String, Object> config) {
|
private static BenefitPointsResult processServiceOrder(Order order, Users user, BigDecimal money, Map<String, Object> config) {
|
||||||
try {
|
try {
|
||||||
log.info("【服务订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money);
|
log.info("【服务订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money);
|
||||||
|
Users userdata=usersService.selectUsersById(user.getId());
|
||||||
// 获取服务金转换为消费金的比例
|
// 获取服务金转换为消费金的比例
|
||||||
BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0"));
|
BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0"));
|
||||||
if (servicefeeRatio.compareTo(ZERO) <= 0) {
|
if (servicefeeRatio.compareTo(ZERO) <= 0) {
|
||||||
|
|
@ -179,21 +179,21 @@ public class BenefitPointsUtil {
|
||||||
BigDecimal consumptionIncrease = money.multiply(servicefeeRatio).divide(new BigDecimal("100"));
|
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);
|
BigDecimal afterConsumption = beforeConsumption.add(consumptionIncrease);
|
||||||
user.setConsumption(afterConsumption);
|
userdata.setConsumption(afterConsumption);
|
||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
int updateResult = usersService.updateUsers(user);
|
int updateResult = usersService.updateUsers(userdata);
|
||||||
if (updateResult <= 0) {
|
if (updateResult <= 0) {
|
||||||
log.error("【错误】用户消费金更新失败,用户ID: {}", user.getId());
|
log.error("【错误】用户消费金更新失败,用户ID: {}", userdata.getId());
|
||||||
return new BenefitPointsResult(false, "用户消费金更新失败", null);
|
return new BenefitPointsResult(false, "用户消费金更新失败", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
UserBenefitPoints benefitLog = createBenefitPointsLog(
|
UserBenefitPoints benefitLog = createBenefitPointsLog(
|
||||||
order.getId(),
|
order.getId(),
|
||||||
user.getId(),
|
userdata.getId(),
|
||||||
TYPE_CONSUMPTION,
|
TYPE_CONSUMPTION,
|
||||||
ORDER_TYPE_INCOME,
|
ORDER_TYPE_INCOME,
|
||||||
money,
|
money,
|
||||||
|
|
@ -205,12 +205,12 @@ public class BenefitPointsUtil {
|
||||||
|
|
||||||
int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||||
if (insertResult <= 0) {
|
if (insertResult <= 0) {
|
||||||
log.error("【错误】消费金日志记录失败,用户ID: {}", user.getId());
|
log.error("【错误】消费金日志记录失败,用户ID: {}", userdata.getId());
|
||||||
return new BenefitPointsResult(false, "消费金日志记录失败", null);
|
return new BenefitPointsResult(false, "消费金日志记录失败", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("【服务订单处理完成】用户ID: {}, 消费金增加: {}, 更新前: {}, 更新后: {}",
|
log.info("【服务订单处理完成】用户ID: {}, 消费金增加: {}, 更新前: {}, 更新后: {}",
|
||||||
user.getId(), consumptionIncrease, beforeConsumption, afterConsumption);
|
userdata.getId(), consumptionIncrease, beforeConsumption, afterConsumption);
|
||||||
|
|
||||||
return new BenefitPointsResult(true, "服务订单消费金处理成功", benefitLog);
|
return new BenefitPointsResult(true, "服务订单消费金处理成功", benefitLog);
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ public class BenefitPointsUtil {
|
||||||
private static BenefitPointsResult processCikaOrder(UserUseSecondaryCard order, Users user, BigDecimal money, Map<String, Object> config) {
|
private static BenefitPointsResult processCikaOrder(UserUseSecondaryCard order, Users user, BigDecimal money, Map<String, Object> config) {
|
||||||
try {
|
try {
|
||||||
log.info("【服务订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money);
|
log.info("【服务订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money);
|
||||||
|
Users userdata = usersService.selectUsersById(user.getId());
|
||||||
// 获取服务金转换为消费金的比例
|
// 获取服务金转换为消费金的比例
|
||||||
BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0"));
|
BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0"));
|
||||||
if (servicefeeRatio.compareTo(ZERO) <= 0) {
|
if (servicefeeRatio.compareTo(ZERO) <= 0) {
|
||||||
|
|
@ -237,21 +237,21 @@ public class BenefitPointsUtil {
|
||||||
BigDecimal consumptionIncrease = money.multiply(servicefeeRatio).divide(new BigDecimal("100"));
|
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);
|
BigDecimal afterConsumption = beforeConsumption.add(consumptionIncrease);
|
||||||
user.setConsumption(afterConsumption);
|
userdata.setConsumption(afterConsumption);
|
||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
int updateResult = usersService.updateUsers(user);
|
int updateResult = usersService.updateUsers(userdata);
|
||||||
if (updateResult <= 0) {
|
if (updateResult <= 0) {
|
||||||
log.error("【错误】用户消费金更新失败,用户ID: {}", user.getId());
|
log.error("【错误】用户消费金更新失败,用户ID: {}", userdata.getId());
|
||||||
return new BenefitPointsResult(false, "用户消费金更新失败", null);
|
return new BenefitPointsResult(false, "用户消费金更新失败", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
UserBenefitPoints benefitLog = createBenefitPointsLog(
|
UserBenefitPoints benefitLog = createBenefitPointsLog(
|
||||||
order.getId(),
|
order.getId(),
|
||||||
user.getId(),
|
userdata.getId(),
|
||||||
TYPE_CONSUMPTION,
|
TYPE_CONSUMPTION,
|
||||||
ORDER_TYPE_INCOME,
|
ORDER_TYPE_INCOME,
|
||||||
money,
|
money,
|
||||||
|
|
@ -263,7 +263,7 @@ public class BenefitPointsUtil {
|
||||||
|
|
||||||
int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||||
if (insertResult <= 0) {
|
if (insertResult <= 0) {
|
||||||
log.error("【错误】消费金日志记录失败,用户ID: {}", user.getId());
|
log.error("【错误】消费金日志记录失败,用户ID: {}", userdata.getId());
|
||||||
return new BenefitPointsResult(false, "消费金日志记录失败", null);
|
return new BenefitPointsResult(false, "消费金日志记录失败", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,7 +283,7 @@ public class BenefitPointsUtil {
|
||||||
private static BenefitPointsResult processGoodsOrder(GoodsOrder order, Users user, BigDecimal money, Map<String, Object> config) {
|
private static BenefitPointsResult processGoodsOrder(GoodsOrder order, Users user, BigDecimal money, Map<String, Object> config) {
|
||||||
try {
|
try {
|
||||||
log.info("【商品订单处理】订单ID: {}, 用户ID: {}, 金额: {}", order.getId(), user.getId(), money);
|
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"));
|
BigDecimal consumptionRatio = getConfigValue(config, CONSUMPTION_KEY, new BigDecimal("0"));
|
||||||
if (consumptionRatio.compareTo(ZERO) <= 0) {
|
if (consumptionRatio.compareTo(ZERO) <= 0) {
|
||||||
|
|
@ -295,21 +295,21 @@ public class BenefitPointsUtil {
|
||||||
BigDecimal servicefeeIncrease = money.multiply(consumptionRatio).divide(new BigDecimal("100"));
|
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);
|
BigDecimal afterServicefee = beforeServicefee.add(servicefeeIncrease);
|
||||||
user.setServicefee(afterServicefee);
|
userdata.setServicefee(afterServicefee);
|
||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
int updateResult = usersService.updateUsers(user);
|
int updateResult = usersService.updateUsers(userdata);
|
||||||
if (updateResult <= 0) {
|
if (updateResult <= 0) {
|
||||||
log.error("【错误】用户服务金更新失败,用户ID: {}", user.getId());
|
log.error("【错误】用户服务金更新失败,用户ID: {}", userdata.getId());
|
||||||
return new BenefitPointsResult(false, "用户服务金更新失败", null);
|
return new BenefitPointsResult(false, "用户服务金更新失败", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
UserBenefitPoints benefitLog = createBenefitPointsLog(
|
UserBenefitPoints benefitLog = createBenefitPointsLog(
|
||||||
order.getId(),
|
order.getId(),
|
||||||
user.getId(),
|
userdata.getId(),
|
||||||
TYPE_SERVICE_FEE,
|
TYPE_SERVICE_FEE,
|
||||||
ORDER_TYPE_INCOME,
|
ORDER_TYPE_INCOME,
|
||||||
money,
|
money,
|
||||||
|
|
@ -321,12 +321,12 @@ public class BenefitPointsUtil {
|
||||||
|
|
||||||
int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
int insertResult = userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||||
if (insertResult <= 0) {
|
if (insertResult <= 0) {
|
||||||
log.error("【错误】服务金日志记录失败,用户ID: {}", user.getId());
|
log.error("【错误】服务金日志记录失败,用户ID: {}", userdata.getId());
|
||||||
return new BenefitPointsResult(false, "服务金日志记录失败", null);
|
return new BenefitPointsResult(false, "服务金日志记录失败", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("【商品订单处理完成】用户ID: {}, 服务金增加: {}, 更新前: {}, 更新后: {}",
|
log.info("【商品订单处理完成】用户ID: {}, 服务金增加: {}, 更新前: {}, 更新后: {}",
|
||||||
user.getId(), servicefeeIncrease, beforeServicefee, afterServicefee);
|
userdata.getId(), servicefeeIncrease, beforeServicefee, afterServicefee);
|
||||||
|
|
||||||
return new BenefitPointsResult(true, "商品订单服务金处理成功", benefitLog);
|
return new BenefitPointsResult(true, "商品订单服务金处理成功", benefitLog);
|
||||||
|
|
||||||
|
|
@ -1268,6 +1268,7 @@ public class BenefitPointsUtil {
|
||||||
}
|
}
|
||||||
//type 1增加(用户增加,就是退款的时候用) 0减少
|
//type 1增加(用户增加,就是退款的时候用) 0减少
|
||||||
if(type==1){
|
if(type==1){
|
||||||
|
|
||||||
user.setServicefee(user.getServicefee().add(amountService));
|
user.setServicefee(user.getServicefee().add(amountService));
|
||||||
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
||||||
benefitLog.setOrderid(usersPayBefor.getId());
|
benefitLog.setOrderid(usersPayBefor.getId());
|
||||||
|
|
@ -1292,7 +1293,13 @@ public class BenefitPointsUtil {
|
||||||
return remap;
|
return remap;
|
||||||
|
|
||||||
}else{
|
}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();
|
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
||||||
benefitLog.setOrderid(usersPayBefor.getId());
|
benefitLog.setOrderid(usersPayBefor.getId());
|
||||||
benefitLog.setUid(usersPayBefor.getUid());
|
benefitLog.setUid(usersPayBefor.getUid());
|
||||||
|
|
@ -1420,7 +1427,13 @@ public class BenefitPointsUtil {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
System.out.println("抵扣区间-------"+user.getConsumption().subtract(amountGoodsmoney));
|
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();
|
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
||||||
benefitLog.setOrderid(usersPayBefor.getId());
|
benefitLog.setOrderid(usersPayBefor.getId());
|
||||||
benefitLog.setUid(usersPayBefor.getUid());
|
benefitLog.setUid(usersPayBefor.getUid());
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ public class CartOrderUtil {
|
||||||
order.setBigtype(serviceGoods.getServicetype());
|
order.setBigtype(serviceGoods.getServicetype());
|
||||||
order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单
|
order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单
|
||||||
order.setCreatePhone(user.getPhone());
|
order.setCreatePhone(user.getPhone());
|
||||||
|
order.setAdressjson(JSONObject.parseObject(userAddress.toString()).toJSONString());
|
||||||
int insertResult = orderService.insertOrder(order);
|
int insertResult = orderService.insertOrder(order);
|
||||||
if (insertResult <= 0) {
|
if (insertResult <= 0) {
|
||||||
result.put("success", false);
|
result.put("success", false);
|
||||||
|
|
@ -277,6 +278,7 @@ public class CartOrderUtil {
|
||||||
goodsOrder.setStatus(1L); // 待支付
|
goodsOrder.setStatus(1L); // 待支付
|
||||||
goodsOrder.setPostage(serviceGoods.getPostage());
|
goodsOrder.setPostage(serviceGoods.getPostage());
|
||||||
goodsOrder.setMainOrderId(maincorid);
|
goodsOrder.setMainOrderId(maincorid);
|
||||||
|
// goodsOrder.setAdressjson(JSONObject.parseObject(userAddress.toString()).toJSONString());
|
||||||
//goodsOrder.setIsmany(1L);
|
//goodsOrder.setIsmany(1L);
|
||||||
int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder);
|
int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder);
|
||||||
if (insertResult <= 0) {
|
if (insertResult <= 0) {
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,60 @@ public class CouponUtil {
|
||||||
return canReceiveList;
|
return canReceiveList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理过期优惠券
|
||||||
|
* 规则:查询当前有效(status = 1)的优惠券,按 end_time + coupon_time(天) 计算到期时间,
|
||||||
|
* 如果已到期,则将优惠券状态置为 0,并将该优惠券下的领取记录(coupon_user)置为 3(失效,已使用的保留原状态)。
|
||||||
|
*
|
||||||
|
* @param couponsService 优惠券服务
|
||||||
|
* @param couponUserService 优惠券领取记录服务
|
||||||
|
* @return 结果统计:expiredCoupons 过期的优惠券数量;updatedCouponUsers 被置为失效的领取记录数量
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> processExpiredCoupons(ICouponsService couponsService, ICouponUserService couponUserService) {
|
||||||
|
long now = System.currentTimeMillis() / 1000; // 秒
|
||||||
|
|
||||||
|
// 查询当前有效的优惠券(status = 1)
|
||||||
|
Coupons query = new Coupons();
|
||||||
|
query.setStatus(1L);
|
||||||
|
List<Coupons> 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<CouponUser> 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<String, Object> result = new HashMap<>();
|
||||||
|
result.put("expiredCoupons", expiredCouponCount);
|
||||||
|
result.put("updatedCouponUsers", updatedCouponUserCount);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,7 @@ public class IntegralAndBenefitUtil {
|
||||||
|
|
||||||
users.setIntegral(newIntegral);
|
users.setIntegral(newIntegral);
|
||||||
users.setTotalIntegral(newTotalIntegral);
|
users.setTotalIntegral(newTotalIntegral);
|
||||||
logger.error("更新用户积分失败,用户ID: {}", users.getIntegral());
|
System.out.println("开始计算增加积分,这里开始处理" + orderid + "----------------------------------------------------------");
|
||||||
logger.error("更新用户积分失败,用户ID: {}", users.getTotalIntegral());
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
int updateResult = usersService.updateUsers(users);
|
int updateResult = usersService.updateUsers(users);
|
||||||
if (updateResult > 0) {
|
if (updateResult > 0) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ public class OrderUtil {
|
||||||
private static IQuoteMaterialService quoteMaterialService = SpringUtils.getBean(IQuoteMaterialService.class);
|
private static IQuoteMaterialService quoteMaterialService = SpringUtils.getBean(IQuoteMaterialService.class);
|
||||||
private static IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class);
|
private static IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class);
|
||||||
private static IOrderCallService orderCallService = SpringUtils.getBean(IOrderCallService.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);
|
private static OrderLogHandler orderLogHandler = SpringUtils.getBean(OrderLogHandler.class);
|
||||||
|
|
||||||
|
|
@ -886,10 +887,13 @@ public class OrderUtil {
|
||||||
jsonObject.put("name", "报价订单支付成功,待服务,师傅"+users.getName());
|
jsonObject.put("name", "报价订单支付成功,待服务,师傅"+users.getName());
|
||||||
orderLog.setContent(jsonObject.toJSONString());
|
orderLog.setContent(jsonObject.toJSONString());
|
||||||
int logInsertResult = orderLogService.insertOrderLog(orderLog);
|
int logInsertResult = orderLogService.insertOrderLog(orderLog);
|
||||||
//开始派单
|
//绑定号码,打电话通知
|
||||||
if (logInsertResult>0){
|
Map<String, Object> map= OrderBindWorkerUtil.getOrderBindWorker(order.getId());
|
||||||
DispatchUtil.dispatchOrder(order.getId());
|
YunXinPhoneUtilAPI.httpsAxbTransfer(order.getWorkerPhone(), order.getId());
|
||||||
}
|
// //开始派单
|
||||||
|
// if (logInsertResult>0){
|
||||||
|
// DispatchUtil.dispatchOrder(order.getId());
|
||||||
|
// }
|
||||||
System.out.println("订单日志插入结果: " + logInsertResult);
|
System.out.println("订单日志插入结果: " + logInsertResult);
|
||||||
System.out.println("需求报价订单处理完成");
|
System.out.println("需求报价订单处理完成");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1026,6 +1030,7 @@ public class OrderUtil {
|
||||||
order.setType(1); // 服务订单
|
order.setType(1); // 服务订单
|
||||||
order.setCreateType(1); // 用户自主下单
|
order.setCreateType(1); // 用户自主下单
|
||||||
order.setUname(user.getName());
|
order.setUname(user.getName());
|
||||||
|
|
||||||
//20250809处理过的一个故障
|
//20250809处理过的一个故障
|
||||||
order.setPayPrice(payBefor.getAllmoney());
|
order.setPayPrice(payBefor.getAllmoney());
|
||||||
order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单
|
order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单
|
||||||
|
|
@ -1051,6 +1056,7 @@ public class OrderUtil {
|
||||||
UserAddress userAddress = userAddressService.selectUserAddressById(payBefor.getAddressid());
|
UserAddress userAddress = userAddressService.selectUserAddressById(payBefor.getAddressid());
|
||||||
System.out.println("查询到的地址信息: " + (userAddress != null ? userAddress.toString() : "null"));
|
System.out.println("查询到的地址信息: " + (userAddress != null ? userAddress.toString() : "null"));
|
||||||
if (userAddress != null) {
|
if (userAddress != null) {
|
||||||
|
order.setAdressjson(com.alibaba.fastjson2.JSONObject.parseObject(userAddress.toString()).toJSONString());
|
||||||
order.setAddressId(userAddress.getId());
|
order.setAddressId(userAddress.getId());
|
||||||
order.setName(userAddress.getName());
|
order.setName(userAddress.getName());
|
||||||
order.setPhone(userAddress.getPhone());
|
order.setPhone(userAddress.getPhone());
|
||||||
|
|
@ -1332,6 +1338,26 @@ public class OrderUtil {
|
||||||
System.out.println("师傅佣金处理完成,师傅ID: " + order.getWorkerId());
|
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) {
|
// if (order.getUid() != null) {
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.system.domain.Order;
|
import com.ruoyi.system.domain.Order;
|
||||||
import com.ruoyi.system.domain.Users;
|
import com.ruoyi.system.domain.Users;
|
||||||
import com.ruoyi.system.service.IOrderService;
|
import com.ruoyi.system.service.*;
|
||||||
import com.ruoyi.system.service.IUsersService;
|
|
||||||
import com.ruoyi.system.service.IWorkerMoneyLogService;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
|
@ -62,6 +60,9 @@ public class ScheduledTaskUtil implements CommandLineRunner {
|
||||||
// 任务执行统计
|
// 任务执行统计
|
||||||
private final Map<String, TaskStatistics> taskStats = new ConcurrentHashMap<>();
|
private final Map<String, TaskStatistics> taskStats = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
private static ICouponsService couponsService = SpringUtils.getBean(ICouponsService.class);
|
||||||
|
private static ICouponUserService couponUserService = SpringUtils.getBean(ICouponUserService.class);
|
||||||
/**
|
/**
|
||||||
* 初始化方法,在Bean创建后执行
|
* 初始化方法,在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<String, Object> stat = CouponUtil.processExpiredCoupons(couponsService, couponUserService);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("{}任务执行失败", taskName, e);
|
||||||
|
updateTaskStatistics(taskName, false, System.currentTimeMillis() - startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统数据清理任务
|
* 系统数据清理任务
|
||||||
* 每天凌晨2点执行,清理过期数据
|
* 每天凌晨2点执行,清理过期数据
|
||||||
|
|
|
||||||
|
|
@ -721,25 +721,25 @@ public class WorkerCommissionUtil {
|
||||||
// 15. 计算并更新订单总金额(用于开票)
|
// 15. 计算并更新订单总金额(用于开票)
|
||||||
updateOrderTotalPriceForInvoice(order, amountComposition);
|
updateOrderTotalPriceForInvoice(order, amountComposition);
|
||||||
|
|
||||||
//次卡下的服务不用给客户添加购物金
|
// //次卡下的服务不用给客户添加购物金
|
||||||
if (StringUtils.isBlank(order.getCartid())){
|
// if (StringUtils.isBlank(order.getCartid())){
|
||||||
//增加购物金
|
// //增加购物金
|
||||||
BenefitPointsUtil.processBenefitPoints(order.getId(),getOrderTotalAmount(order),"1");
|
// BenefitPointsUtil.processBenefitPoints(order.getId(),order.getPayPrice(),"1");
|
||||||
}
|
// }
|
||||||
if (StringUtils.isNotBlank(order.getCartid())){
|
// if (StringUtils.isNotBlank(order.getCartid())){
|
||||||
//次卡进行分佣操作,次卡的分佣只有一次,
|
// //次卡进行分佣操作,次卡的分佣只有一次,
|
||||||
UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(order.getCartid());
|
// UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(order.getCartid());
|
||||||
if (userUseSecondaryCard.getUsenum().intValue() >= userUseSecondaryCard.getNum().intValue()){
|
// if (userUseSecondaryCard.getUsenum().intValue() >= userUseSecondaryCard.getNum().intValue()){
|
||||||
//次卡在这个时候就需要进行积分和购物金以的处理
|
// //次卡在这个时候就需要进行积分和购物金以的处理
|
||||||
if (userUseSecondaryCard.getStatus()==1){
|
// if (userUseSecondaryCard.getStatus()==1){
|
||||||
BenefitPointsUtil.processBenefitPoints(userUseSecondaryCard.getId(), userUseSecondaryCard.getPaymoney(),"3");
|
// BenefitPointsUtil.processBenefitPoints(userUseSecondaryCard.getId(), userUseSecondaryCard.getPaymoney(),"3");
|
||||||
// JSONObject integralAndBenefitResult = IntegralAndBenefitUtil.processIntegralAndBenefit(totalAmount, orderId, user.getId());
|
// // JSONObject integralAndBenefitResult = IntegralAndBenefitUtil.processIntegralAndBenefit(totalAmount, orderId, user.getId());
|
||||||
userUseSecondaryCard.setStatus(2L);//设置不可用
|
// userUseSecondaryCard.setStatus(2L);//设置不可用
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard);
|
// userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//修改库存及销量
|
//修改库存及销量
|
||||||
OrderUtil.updateInventoryAndSales(order.getOrderId(), 1);
|
OrderUtil.updateInventoryAndSales(order.getOrderId(), 1);
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,11 @@ public interface PayMoneyLogMapper
|
||||||
* @return 支付记录集合
|
* @return 支付记录集合
|
||||||
*/
|
*/
|
||||||
public List<PayMoneyLog> selectPayMoneyLogListForExport(PayMoneyLog payMoneyLog);
|
public List<PayMoneyLog> selectPayMoneyLogListForExport(PayMoneyLog payMoneyLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照订单ID分组统计价格总和
|
||||||
|
*
|
||||||
|
* @return 订单价格统计列表
|
||||||
|
*/
|
||||||
|
public List<java.util.Map<String, Object>> selectOrderPriceStatistics(Long uid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,11 @@ public interface IPayMoneyLogService
|
||||||
* @return 支付记录集合
|
* @return 支付记录集合
|
||||||
*/
|
*/
|
||||||
public List<PayMoneyLog> selectPayMoneyLogListForExport(PayMoneyLog payMoneyLog);
|
public List<PayMoneyLog> selectPayMoneyLogListForExport(PayMoneyLog payMoneyLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照订单ID分组统计支付价格总和
|
||||||
|
*
|
||||||
|
* @return 订单价格统计列表,包含orderId和totalPrice
|
||||||
|
*/
|
||||||
|
public List<java.util.Map<String, Object>> getOrderPriceStatistics(Long uid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,4 +113,15 @@ public class PayMoneyLogServiceImpl implements IPayMoneyLogService
|
||||||
{
|
{
|
||||||
return payMoneyLogMapper.selectPayMoneyLogListForExport(payMoneyLog);
|
return payMoneyLogMapper.selectPayMoneyLogListForExport(payMoneyLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照订单ID分组统计支付价格总和
|
||||||
|
*
|
||||||
|
* @return 订单价格统计列表,包含orderId和totalPrice
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<java.util.Map<String, Object>> getOrderPriceStatistics(Long uid)
|
||||||
|
{
|
||||||
|
return payMoneyLogMapper.selectOrderPriceStatistics(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,4 +128,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
order by pml.id desc
|
order by pml.id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 按照订单ID分组统计价格总和 -->
|
||||||
|
<select id="selectOrderPriceStatistics" parameterType="Long" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
order_id as orderId,
|
||||||
|
SUM(price) as totalPrice
|
||||||
|
FROM pay_money_log
|
||||||
|
WHERE order_id IS NOT NULL AND order_id != '' and uid = #{uid}
|
||||||
|
GROUP BY order_id
|
||||||
|
ORDER BY totalPrice DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -106,8 +106,6 @@
|
||||||
<if test="cr != null">cr,</if>
|
<if test="cr != null">cr,</if>
|
||||||
<if test="mergin != null">mergin,</if>
|
<if test="mergin != null">mergin,</if>
|
||||||
<if test="doorPrice != null">door_price,</if>
|
<if test="doorPrice != null">door_price,</if>
|
||||||
<if test="createdAt != null">created_at,</if>
|
|
||||||
<if test="updatedAt != null">updated_at,</if>
|
|
||||||
<if test="status != null">status,</if>
|
<if test="status != null">status,</if>
|
||||||
<if test="statusType != null">status_type,</if>
|
<if test="statusType != null">status_type,</if>
|
||||||
<if test="beginlook != null">beginlook,</if>
|
<if test="beginlook != null">beginlook,</if>
|
||||||
|
|
@ -118,6 +116,8 @@
|
||||||
<if test="lookMoney != null">look_money,</if>
|
<if test="lookMoney != null">look_money,</if>
|
||||||
<if test="gongshi != null">gongshi,</if>
|
<if test="gongshi != null">gongshi,</if>
|
||||||
<if test="clmoney != null">clmoney,</if>
|
<if test="clmoney != null">clmoney,</if>
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="workerId != null">#{workerId},</if>
|
<if test="workerId != null">#{workerId},</if>
|
||||||
|
|
@ -130,8 +130,6 @@
|
||||||
<if test="cr != null">#{cr},</if>
|
<if test="cr != null">#{cr},</if>
|
||||||
<if test="mergin != null">#{mergin},</if>
|
<if test="mergin != null">#{mergin},</if>
|
||||||
<if test="doorPrice != null">#{doorPrice},</if>
|
<if test="doorPrice != null">#{doorPrice},</if>
|
||||||
<if test="createdAt != null">#{createdAt},</if>
|
|
||||||
<if test="updatedAt != null">#{updatedAt},</if>
|
|
||||||
<if test="status != null">#{status},</if>
|
<if test="status != null">#{status},</if>
|
||||||
<if test="statusType != null">#{statusType},</if>
|
<if test="statusType != null">#{statusType},</if>
|
||||||
<if test="beginlook != null">#{beginlook},</if>
|
<if test="beginlook != null">#{beginlook},</if>
|
||||||
|
|
@ -142,6 +140,8 @@
|
||||||
<if test="lookMoney != null">#{lookMoney},</if>
|
<if test="lookMoney != null">#{lookMoney},</if>
|
||||||
<if test="gongshi != null">#{gongshi},</if>
|
<if test="gongshi != null">#{gongshi},</if>
|
||||||
<if test="clmoney != null">#{clmoney},</if>
|
<if test="clmoney != null">#{clmoney},</if>
|
||||||
|
NOW(),
|
||||||
|
NOW()
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ VUE_APP_TITLE = 华府人家
|
||||||
ENV = 'production'
|
ENV = 'production'
|
||||||
|
|
||||||
# 西安华府人家装饰工程有限公司/生产环境
|
# 西安华府人家装饰工程有限公司/生产环境
|
||||||
VUE_APP_BASE_API = '/prod-api'
|
VUE_APP_BASE_API = '/api'
|
||||||
|
|
|
||||||
BIN
ruoyi-ui/dist.7z
BIN
ruoyi-ui/dist.7z
Binary file not shown.
Binary file not shown.
|
|
@ -401,7 +401,7 @@
|
||||||
style="width: 200px;"
|
style="width: 200px;"
|
||||||
placeholder="请输入数量"
|
placeholder="请输入数量"
|
||||||
/>
|
/>
|
||||||
<span style="margin-left: 8px; color: #909399; font-size: 12px;">领取后至少30天有效</span>
|
<!-- <span style="margin-left: 8px; color: #909399; font-size: 12px;">领取后至少30天有效</span>-->
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
@ -854,7 +854,7 @@ export default {
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
const id = row.id || this.ids;
|
const id = row.id || this.ids;
|
||||||
this.getDataUserListByCoupon(id);
|
//this.getDataUserListByCoupon(id);
|
||||||
getCoupons(id).then(response => {
|
getCoupons(id).then(response => {
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
// 处理日期字段
|
// 处理日期字段
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="项目报价"
|
title="项目报价"
|
||||||
:visible.sync="visibleInner"
|
:visible.sync="visibleInner"
|
||||||
width="420px"
|
width="50%"
|
||||||
top="6vh"
|
top="6vh"
|
||||||
append-to-body
|
append-to-body
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
|
|
@ -14,14 +14,14 @@
|
||||||
<div class="group-sub">请和用户确认基础现象</div>
|
<div class="group-sub">请和用户确认基础现象</div>
|
||||||
<div class="chip-list">
|
<div class="chip-list">
|
||||||
<el-button
|
<el-button
|
||||||
v-for="opt in inspectionOptions"
|
v-for="item in form.basic"
|
||||||
:key="opt.id"
|
:key="item.name"
|
||||||
:type="selectedInspectionIds.includes(opt.id) ? 'primary' : 'default'"
|
:type="item.select ? 'primary' : 'default'"
|
||||||
size="mini"
|
size="mini"
|
||||||
class="chip"
|
class="chip"
|
||||||
@click="toggleInspection(opt.id)"
|
@click="item.select = !item.select"
|
||||||
>
|
>
|
||||||
{{ opt.name }}
|
{{ item.name }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -31,18 +31,22 @@
|
||||||
<div class="group-title">服务项目</div>
|
<div class="group-title">服务项目</div>
|
||||||
<div class="group-sub">请和用户确认基础项目</div>
|
<div class="group-sub">请和用户确认基础项目</div>
|
||||||
<el-card class="slot-card" shadow="never">
|
<el-card class="slot-card" shadow="never">
|
||||||
|
<div v-if="form.craft.length > 0" class="list">
|
||||||
|
<div v-for="(item, idx) in form.craft" :key="idx" class="list-item">
|
||||||
|
<span class="name">{{ item.title }}</span>
|
||||||
|
<span class="price">¥{{ item.price }}</span>
|
||||||
|
|
||||||
|
<el-input-number v-model="item.count" :min="1"></el-input-number>
|
||||||
|
<el-button type="text" @click="form.craft.splice(idx, 1)"
|
||||||
|
>移除</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="slot-row">
|
<div class="slot-row">
|
||||||
<el-button type="text" @click="projectPickerVisible = true">
|
<el-button type="text" @click="projectPickerVisible = true">
|
||||||
去添加服务项目
|
去添加服务项目
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="projectItems.length > 0" class="list">
|
|
||||||
<div v-for="(item, idx) in projectItems" :key="idx" class="list-item">
|
|
||||||
<span class="name">{{ item.name }}</span>
|
|
||||||
<span class="price">¥{{ toMoney(item.price) }}</span>
|
|
||||||
<el-button type="text" @click="removeProject(idx)">移除</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
</el-card>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
@ -51,19 +55,39 @@
|
||||||
<div class="group-title">所需物料</div>
|
<div class="group-title">所需物料</div>
|
||||||
<div class="group-sub">如需物料,请添加并向用户一并报价</div>
|
<div class="group-sub">如需物料,请添加并向用户一并报价</div>
|
||||||
<el-card class="slot-card" shadow="never">
|
<el-card class="slot-card" shadow="never">
|
||||||
|
<div v-if="form.material.length > 0" class="list">
|
||||||
|
<div
|
||||||
|
v-for="(item, idx) in form.material"
|
||||||
|
:key="idx"
|
||||||
|
class="list-item"
|
||||||
|
>
|
||||||
|
<span class="name">{{ item.title }}</span>
|
||||||
|
<span class="price">{{ item.price }}</span>
|
||||||
|
<el-input-number v-model="item.count" :min="1"></el-input-number>
|
||||||
|
<el-button type="text" @click="form.material.splice(idx, 1)"
|
||||||
|
>移除</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="slot-row">
|
<div class="slot-row">
|
||||||
<el-button type="text" @click="materialPickerVisible = true">
|
<el-button type="text" @click="materialPickerVisible = true">
|
||||||
去添加所需物料
|
去添加所需物料
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="materialItems.length > 0" class="list">
|
</el-card>
|
||||||
<div v-for="(item, idx) in materialItems" :key="idx" class="list-item">
|
</section>
|
||||||
<span class="name">{{ item.name }}</span>
|
<!-- 所需物料 -->
|
||||||
<span class="qty">x{{ item.quantity }}</span>
|
<section class="group">
|
||||||
<span class="price">¥{{ toMoney(item.price * item.quantity) }}</span>
|
<div class="group-title">备注</div>
|
||||||
<el-button type="text" @click="removeMaterial(idx)">移除</el-button>
|
<div class="group-sub">如有特殊情况说明,请填写备注信息</div>
|
||||||
</div>
|
<el-card class="slot-card" shadow="never">
|
||||||
</div>
|
<el-input
|
||||||
|
type="textarea"
|
||||||
|
:rows="2"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
v-model="form.reamk"
|
||||||
|
>
|
||||||
|
</el-input>
|
||||||
</el-card>
|
</el-card>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
@ -76,26 +100,22 @@
|
||||||
<el-radio v-model="payType" label="stage">定金 + 尾款</el-radio>
|
<el-radio v-model="payType" label="stage">定金 + 尾款</el-radio>
|
||||||
<el-radio v-model="payType" label="once">一次性付清</el-radio>
|
<el-radio v-model="payType" label="once">一次性付清</el-radio>
|
||||||
</div>
|
</div>
|
||||||
|
<el-form v-show="payType == 'stage'">
|
||||||
|
<el-form-item label="定金金额">
|
||||||
|
<el-input-number v-model="form.price" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- 优惠 -->
|
<!-- 优惠 -->
|
||||||
<section class="group">
|
<section class="group">
|
||||||
<el-button type="text" @click="discountVisible = !discountVisible">添加优惠</el-button>
|
<el-button type="text">添加优惠</el-button>
|
||||||
<transition name="el-fade-in">
|
<transition name="el-fade-in">
|
||||||
<div v-show="discountVisible" class="discount-box">
|
<div class="discount-box">
|
||||||
<el-form :model="discount" label-width="80px" size="small">
|
<el-form label-width="80px" size="small">
|
||||||
<el-form-item label="优惠类型">
|
<el-form-item label="立减金额">
|
||||||
<el-select v-model="discount.type" placeholder="请选择">
|
<el-input-number v-model="form.reduction" :min="0" />
|
||||||
<el-option label="立减" value="minus" />
|
|
||||||
<el-option label="折扣(%)" value="rate" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-if="discount.type === 'minus'" label="立减金额">
|
|
||||||
<el-input-number v-model="discount.amount" :min="0" :step="1" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-else label="折扣比例">
|
|
||||||
<el-input-number v-model="discount.rate" :min="0" :max="100" :step="1" />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -103,11 +123,6 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- 底部报价 -->
|
<!-- 底部报价 -->
|
||||||
<div class="footer">
|
|
||||||
<el-button type="primary" class="btn-generate" @click="handleGenerate">
|
|
||||||
生成报价(报价:¥{{ toMoney(grandTotal) }})
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 服务项目选择弹窗(临时简化版,后续替换为接口数据) -->
|
<!-- 服务项目选择弹窗(临时简化版,后续替换为接口数据) -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
|
|
@ -116,18 +131,35 @@
|
||||||
width="520px"
|
width="520px"
|
||||||
append-to-body
|
append-to-body
|
||||||
>
|
>
|
||||||
<el-form :model="tempProject" label-width="90px" size="small">
|
<el-tabs v-model="craid">
|
||||||
<el-form-item label="项目名称">
|
<el-tab-pane
|
||||||
<el-input v-model="tempProject.name" placeholder="请输入项目名称" />
|
:label="item.title"
|
||||||
</el-form-item>
|
:name="item.id"
|
||||||
<el-form-item label="项目单价">
|
v-for="item in craftlist"
|
||||||
<el-input-number v-model="tempProject.price" :min="0" :step="1" />
|
>
|
||||||
</el-form-item>
|
<div class="wullistbox">
|
||||||
</el-form>
|
<div v-for="value in item.craft" class="li">
|
||||||
<div slot="footer" class="dialog-footer">
|
<div class="left">
|
||||||
<el-button @click="projectPickerVisible = false">取消</el-button>
|
<p>{{ value.title }}</p>
|
||||||
<el-button type="primary" @click="addProject">添加</el-button>
|
<span>{{ value.price }}{{ value.unit }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="right"
|
||||||
|
v-if="!form.craft.find((r) => r.id == value.id)"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="craftselect(value, item.craft.id)"
|
||||||
|
>选择</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="right" v-else>
|
||||||
|
<el-button disabled>已选</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 物料选择弹窗(临时简化版,后续替换为接口数据) -->
|
<!-- 物料选择弹窗(临时简化版,后续替换为接口数据) -->
|
||||||
|
|
@ -137,21 +169,36 @@
|
||||||
width="520px"
|
width="520px"
|
||||||
append-to-body
|
append-to-body
|
||||||
>
|
>
|
||||||
<el-form :model="tempMaterial" label-width="90px" size="small">
|
<el-tabs v-model="materialid">
|
||||||
<el-form-item label="物料名称">
|
<el-tab-pane
|
||||||
<el-input v-model="tempMaterial.name" placeholder="请输入物料名称" />
|
:label="item.title"
|
||||||
</el-form-item>
|
:name="item.id"
|
||||||
<el-form-item label="物料单价">
|
v-for="item in materiallist"
|
||||||
<el-input-number v-model="tempMaterial.price" :min="0" :step="1" />
|
>
|
||||||
</el-form-item>
|
<div class="wulist">
|
||||||
<el-form-item label="数量">
|
<div v-for="value in item.material" class="li">
|
||||||
<el-input-number v-model="tempMaterial.quantity" :min="1" :step="1" />
|
<div class="left">
|
||||||
</el-form-item>
|
<img :src="value.image" />
|
||||||
</el-form>
|
<div>
|
||||||
<div slot="footer" class="dialog-footer">
|
<p>{{ value.title }}</p>
|
||||||
<el-button @click="materialPickerVisible = false">取消</el-button>
|
<span>{{ value.price }}{{ value.unit }}</span>
|
||||||
<el-button type="primary" @click="addMaterial">添加</el-button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="right"
|
||||||
|
v-if="!form.material.find((r) => r.id == value.id)"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="materialselect(value, item.material.id)"
|
||||||
|
>选择</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div v-else><el-button disabled>已选</el-button></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -160,17 +207,22 @@
|
||||||
<el-button type="primary" @click="handleGenerate">生成报价</el-button>
|
<el-button type="primary" @click="handleGenerate">生成报价</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import request from '@/utils/request'
|
import {
|
||||||
|
Orderbasicproject,
|
||||||
|
Orderquotecraft,
|
||||||
|
Orderquotematerial,
|
||||||
|
Orderworkerestimate
|
||||||
|
} from "@/api/system/Order";
|
||||||
export default {
|
export default {
|
||||||
name: 'ProjectQuoteDialog',
|
name: "ProjectQuoteDialog",
|
||||||
props: {
|
props: {
|
||||||
visible: { type: Boolean, default: false },
|
visible: { type: Boolean, default: false },
|
||||||
orderId: { type: String, default: '' },
|
orderId: { type: String, default: "" },
|
||||||
workerId: { type: [String, Number], default: '' },
|
workerId: { type: [String, Number], default: "" },
|
||||||
goodId: { type: [String, Number], default: '' }
|
goodId: { type: [String, Number], default: "" },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -185,165 +237,346 @@ export default {
|
||||||
materialItems: [],
|
materialItems: [],
|
||||||
|
|
||||||
// 付款方式
|
// 付款方式
|
||||||
payType: 'stage', // stage: 定金+尾款, once: 一次性
|
payType: "stage", // stage: 定金+尾款, once: 一次性
|
||||||
|
|
||||||
// 优惠
|
// 优惠
|
||||||
discountVisible: false,
|
|
||||||
discount: {
|
discount: {
|
||||||
type: 'minus', // minus | rate
|
type: "minus", // minus | rate
|
||||||
amount: 0,
|
amount: 0,
|
||||||
rate: 0
|
rate: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
form: {
|
||||||
|
basic: [], //基检现象
|
||||||
|
craft: [], //工艺费用
|
||||||
|
material: [], //物料费用
|
||||||
|
price: 0, //定金
|
||||||
|
reduction: 0, //优惠券
|
||||||
|
reamk: "",
|
||||||
|
},
|
||||||
|
craid: "",
|
||||||
|
materialid: "",
|
||||||
|
craftlist: [],
|
||||||
|
materiallist: [],
|
||||||
// 选择弹窗临时模型
|
// 选择弹窗临时模型
|
||||||
projectPickerVisible: false,
|
projectPickerVisible: false,
|
||||||
materialPickerVisible: false,
|
materialPickerVisible: false,
|
||||||
tempProject: { name: '', price: 0 },
|
tempProject: { name: "", price: 0 },
|
||||||
tempMaterial: { name: '', price: 0, quantity: 1 }
|
tempMaterial: { name: "", price: 0, quantity: 1 },
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
visible: {
|
visible: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(val) {
|
handler(val) {
|
||||||
this.visibleInner = val
|
this.visibleInner = val;
|
||||||
if (val) {
|
if (val) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.loadInspectionOptions()
|
this.loadInspectionOptions();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
workerId() {
|
||||||
|
if (this.visibleInner) this.loadInspectionOptions();
|
||||||
|
},
|
||||||
|
orderId() {
|
||||||
|
if (this.visibleInner) this.loadInspectionOptions();
|
||||||
|
},
|
||||||
|
goodId() {
|
||||||
|
if (this.visibleInner) this.loadInspectionOptions();
|
||||||
},
|
},
|
||||||
workerId() { if (this.visibleInner) this.loadInspectionOptions() },
|
|
||||||
orderId() { if (this.visibleInner) this.loadInspectionOptions() },
|
|
||||||
goodId() { if (this.visibleInner) this.loadInspectionOptions() }
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
projectTotal() {
|
projectTotal() {
|
||||||
return this.projectItems.reduce((sum, it) => sum + (Number(it.price) || 0), 0)
|
return this.projectItems.reduce(
|
||||||
|
(sum, it) => sum + (Number(it.price) || 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
},
|
},
|
||||||
materialTotal() {
|
materialTotal() {
|
||||||
return this.materialItems.reduce((sum, it) => sum + (Number(it.price) || 0) * (Number(it.quantity) || 0), 0)
|
return this.materialItems.reduce(
|
||||||
|
(sum, it) => sum + (Number(it.price) || 0) * (Number(it.quantity) || 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
},
|
},
|
||||||
subtotal() {
|
subtotal() {
|
||||||
return this.projectTotal + this.materialTotal
|
return this.projectTotal + this.materialTotal;
|
||||||
},
|
},
|
||||||
discountAmount() {
|
discountAmount() {
|
||||||
if (this.discount.type === 'minus') {
|
if (this.discount.type === "minus") {
|
||||||
return Number(this.discount.amount) || 0
|
return Number(this.discount.amount) || 0;
|
||||||
}
|
}
|
||||||
const rate = Number(this.discount.rate) || 0
|
const rate = Number(this.discount.rate) || 0;
|
||||||
return (this.subtotal * rate) / 100
|
return (this.subtotal * rate) / 100;
|
||||||
},
|
},
|
||||||
grandTotal() {
|
grandTotal() {
|
||||||
const val = this.subtotal - this.discountAmount
|
const val = this.subtotal - this.discountAmount;
|
||||||
return val > 0 ? val : 0
|
return val > 0 ? val : 0;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async loadInspectionOptions() {
|
async loadInspectionOptions() {
|
||||||
// 允许仅凭 goodId 加载(后端支持仅传 goodid 返回基础项目)
|
// 允许仅凭 goodId 加载(后端支持仅传 goodid 返回基础项目)
|
||||||
if (!this.goodId && !this.orderId) {
|
if (!this.goodId && !this.orderId) {
|
||||||
// 缺少必要参数时不请求
|
// 缺少必要参数时不请求
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.loadingInspections = true
|
this.loadingInspections = true;
|
||||||
const res = await request.get('/api/worker/basic/project', {
|
const res = await Orderbasicproject(this.orderId);
|
||||||
params: { id: this.orderId || undefined, goodid: this.goodId || undefined }
|
if (!res.data.quote) {
|
||||||
})
|
res.data.basic = res.data.basic.map((r) => {
|
||||||
if (res && res.code === 200 && res.data && Array.isArray(res.data.basic)) {
|
return {
|
||||||
this.inspectionOptions = res.data.basic.map((name, idx) => ({ id: idx + 1, name }))
|
name: r,
|
||||||
this.selectedInspectionIds = []
|
select: false,
|
||||||
} else {
|
};
|
||||||
this.inspectionOptions = []
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 已报价
|
||||||
|
if (res.data.quote) {
|
||||||
|
res.data.basic = res.data.basic.map((r) => {
|
||||||
|
return {
|
||||||
|
name: r,
|
||||||
|
select:
|
||||||
|
res.data.quote.basic.findIndex((rr) => rr.name == r) != -1
|
||||||
|
? true
|
||||||
|
: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// 备注回显
|
||||||
|
this.form.reamk = res.data.quote.reamk;
|
||||||
|
|
||||||
|
// 服务回显
|
||||||
|
this.form.craft = res.data.quote.craft.map((r) => {
|
||||||
|
r["title"] = r.name;
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 物料回显
|
||||||
|
this.form.material = res.data.quote.material.map((r) => {
|
||||||
|
r["title"] = r.name;
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 付款类型
|
||||||
|
if (res.data.quote.deposit.price) {
|
||||||
|
this.payType = 'stage';
|
||||||
|
this.form.price = res.data.quote.deposit.price;
|
||||||
|
// 定金存在并且用户已支付不可修改付款方式和定金
|
||||||
|
// if(res.data.payStatusdata.dingjin==2){
|
||||||
|
// isset.value=false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
// 优惠金额
|
||||||
|
if (res.data.quote.project.price) {
|
||||||
|
this.form.reduction= res.data.quote.reduction.price;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.form = { ...this.form, ...res.data };
|
||||||
|
|
||||||
|
// 获取服务列表
|
||||||
|
Orderquotecraft(this.goodId).then((r) => {
|
||||||
|
this.craftlist = r.data;
|
||||||
|
if (r.data.length) {
|
||||||
|
this.craid = r.data[0].id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 获取物料列表
|
||||||
|
Orderquotematerial(this.goodId).then((r) => {
|
||||||
|
this.materiallist = r.data;
|
||||||
|
if (r.data.length) {
|
||||||
|
this.materialid = r.data[0].id;
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('获取基检现象失败:', e)
|
console.error("获取基检现象失败:", e);
|
||||||
this.$message.error('获取基检现象失败')
|
this.$message.error("获取基检现象失败");
|
||||||
this.inspectionOptions = []
|
this.inspectionOptions = [];
|
||||||
} finally {
|
} finally {
|
||||||
this.loadingInspections = false
|
this.loadingInspections = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
craftselect(item, pid) {
|
||||||
|
this.form.craft.push({
|
||||||
|
...item,
|
||||||
|
count: 1,
|
||||||
|
pid: pid,
|
||||||
|
});
|
||||||
|
this.projectPickerVisible = false;
|
||||||
|
},
|
||||||
|
materialselect(item, pid) {
|
||||||
|
this.form.material.push({
|
||||||
|
...item,
|
||||||
|
count: 1,
|
||||||
|
pid: pid,
|
||||||
|
});
|
||||||
|
this.materialPickerVisible = false;
|
||||||
|
},
|
||||||
toMoney(v) {
|
toMoney(v) {
|
||||||
const num = Number(v) || 0
|
const num = Number(v) || 0;
|
||||||
return num.toFixed(2)
|
return num.toFixed(2);
|
||||||
},
|
},
|
||||||
toggleInspection(id) {
|
toggleInspection(id) {
|
||||||
const idx = this.selectedInspectionIds.indexOf(id)
|
const idx = this.selectedInspectionIds.indexOf(id);
|
||||||
if (idx >= 0) this.selectedInspectionIds.splice(idx, 1)
|
if (idx >= 0) this.selectedInspectionIds.splice(idx, 1);
|
||||||
else this.selectedInspectionIds.push(id)
|
else this.selectedInspectionIds.push(id);
|
||||||
},
|
},
|
||||||
addProject() {
|
addProject() {
|
||||||
if (!this.tempProject.name) return this.$message.warning('请输入项目名称')
|
if (!this.tempProject.name)
|
||||||
this.projectItems.push({ ...this.tempProject })
|
return this.$message.warning("请输入项目名称");
|
||||||
this.tempProject = { name: '', price: 0 }
|
this.projectItems.push({ ...this.tempProject });
|
||||||
this.projectPickerVisible = false
|
this.tempProject = { name: "", price: 0 };
|
||||||
|
this.projectPickerVisible = false;
|
||||||
},
|
},
|
||||||
removeProject(index) {
|
removeProject(index) {
|
||||||
this.projectItems.splice(index, 1)
|
this.projectItems.splice(index, 1);
|
||||||
},
|
},
|
||||||
addMaterial() {
|
addMaterial() {
|
||||||
if (!this.tempMaterial.name) return this.$message.warning('请输入物料名称')
|
if (!this.tempMaterial.name)
|
||||||
this.materialItems.push({ ...this.tempMaterial })
|
return this.$message.warning("请输入物料名称");
|
||||||
this.tempMaterial = { name: '', price: 0, quantity: 1 }
|
this.materialItems.push({ ...this.tempMaterial });
|
||||||
this.materialPickerVisible = false
|
this.tempMaterial = { name: "", price: 0, quantity: 1 };
|
||||||
|
this.materialPickerVisible = false;
|
||||||
},
|
},
|
||||||
removeMaterial(index) {
|
removeMaterial(index) {
|
||||||
this.materialItems.splice(index, 1)
|
this.materialItems.splice(index, 1);
|
||||||
},
|
},
|
||||||
handleGenerate() {
|
async handleGenerate() {
|
||||||
const payload = {
|
const payload = {
|
||||||
orderId: this.orderId,
|
id: this.orderId,
|
||||||
inspections: this.selectedInspectionIds,
|
basic: this.form.basic.filter((r) => r.select), //基检现象
|
||||||
projects: this.projectItems,
|
craft: this.form.craft, //工艺费用
|
||||||
materials: this.materialItems,
|
material: this.form.material, //物料费用
|
||||||
payType: this.payType,
|
price: this.payType == "stage" ? this.form.price : undefined, //定金
|
||||||
discount: { ...this.discount },
|
reduction: this.form.reduction, //优惠券
|
||||||
amount: this.grandTotal
|
reamk: this.form.reamk,
|
||||||
}
|
};
|
||||||
this.$emit('submit', payload)
|
await Orderworkerestimate(payload)
|
||||||
this.visibleInner = false
|
this.$message.success('报价已生成')
|
||||||
this.$emit('update:visible', false)
|
this.$emit("submit", payload);
|
||||||
|
this.visibleInner = false;
|
||||||
|
this.$emit("update:visible", false);
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.visibleInner = false
|
this.visibleInner = false;
|
||||||
this.$emit('update:visible', false)
|
this.$emit("update:visible", false);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.wullistbox,
|
||||||
|
.wulist {
|
||||||
|
max-height: 600px;
|
||||||
|
overflow: auto;
|
||||||
|
.li {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: 15px 0;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.wulist {
|
||||||
|
.left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
img {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin: 0px 0px 15px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.quote-wrapper {
|
.quote-wrapper {
|
||||||
.group { margin-bottom: 16px; }
|
.group {
|
||||||
.group-title { font-weight: 600; color: #2c3e50; margin-bottom: 4px; }
|
margin-bottom: 16px;
|
||||||
.group-sub { font-size: 12px; color: #909399; margin-bottom: 8px; }
|
}
|
||||||
|
.group-title {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #2c3e50;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
.group-sub {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.chip-list {
|
.chip-list {
|
||||||
display: flex; flex-wrap: wrap; gap: 8px;
|
display: flex;
|
||||||
.chip { min-width: 84px; }
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
.chip {
|
||||||
|
min-width: 84px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.slot-card {
|
.slot-card {
|
||||||
background: #f7fbff;
|
background: #f7fbff;
|
||||||
.slot-row { padding: 6px 0; }
|
.slot-row {
|
||||||
.list { margin-top: 8px; }
|
padding: 6px 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.list {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
.list-item {
|
.list-item {
|
||||||
display: flex; align-items: center; justify-content: space-between;
|
display: flex;
|
||||||
padding: 6px 0; border-bottom: 1px dashed #ebeef5;
|
align-items: center;
|
||||||
.name { color: #303133; }
|
justify-content: space-between;
|
||||||
.qty { color: #606266; margin: 0 6px; }
|
padding: 6px 0;
|
||||||
.price { color: #409EFF; font-weight: 600; }
|
border-bottom: 1px dashed #ebeef5;
|
||||||
|
.name {
|
||||||
|
color: #303133;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
.qty {
|
||||||
|
color: #606266;
|
||||||
|
margin: 0 6px;
|
||||||
|
}
|
||||||
|
.price {
|
||||||
|
color: #409eff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.pay-row { display: flex; align-items: center; gap: 12px; }
|
.pay-row {
|
||||||
.discount-box { background: #f8f9fb; border: 1px solid #ebeef5; padding: 10px; border-radius: 6px; }
|
display: flex;
|
||||||
.footer { display: flex; justify-content: center; margin-top: 12px; }
|
align-items: center;
|
||||||
.btn-generate { width: 100%; }
|
gap: 12px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.discount-box {
|
||||||
|
background: #f8f9fb;
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
padding: 20px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
.btn-generate {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5346,7 +5346,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
// 这里后续替换为真实接口调用
|
// 这里后续替换为真实接口调用
|
||||||
// await request.post('/system/Order/project-quote', payload)
|
// await request.post('/system/Order/project-quote', payload)
|
||||||
this.$message.success('报价已生成(待接入接口)')
|
|
||||||
// 刷新订单详情与列表
|
// 刷新订单详情与列表
|
||||||
this.refreshOrderDetail()
|
this.refreshOrderDetail()
|
||||||
this.getList()
|
this.getList()
|
||||||
|
|
@ -5383,6 +5383,7 @@ export default {
|
||||||
cancelReason: row.cancelReason,
|
cancelReason: row.cancelReason,
|
||||||
mark: row.mark,
|
mark: row.mark,
|
||||||
fileData: row.fileData,
|
fileData: row.fileData,
|
||||||
|
productId:row.productId,
|
||||||
servicePhotos: row.servicePhotos || [],
|
servicePhotos: row.servicePhotos || [],
|
||||||
// 订单基本信息
|
// 订单基本信息
|
||||||
userName: row.uname || row.name,
|
userName: row.uname || row.name,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue