Compare commits

...

4 Commits

Author SHA1 Message Date
张潘 862d245b4e 202507251746 2025-07-25 17:46:41 +08:00
张潘 4f8fe174ad 202507251746 2025-07-25 17:46:32 +08:00
张潘 8c064d6657 202507241748 2025-07-24 17:48:12 +08:00
张潘 02a4d1438b 202507231802 2025-07-23 18:02:28 +08:00
54 changed files with 6202 additions and 1436 deletions

View File

@ -99,8 +99,8 @@ public class CommonController
// 使用七牛云上传
String fileUrl = QiniuUploadUtil.uploadFile(file);
AjaxResult ajax = AjaxResult.success();
ajax.put("url", fileUrl);
ajax.put("EditorURL", "https://" + getQiniuConfig().getDomain() + "/" +fileUrl);
ajax.put("url", fileUrl);
ajax.put("EditorURL",fileUrl);
ajax.put("fileName", fileUrl);
ajax.put("newFileName", FileUtils.getName(file.getOriginalFilename()));
ajax.put("originalFilename", file.getOriginalFilename());

View File

@ -61,13 +61,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 获取分页参数
@ -98,13 +98,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 获取分页参数
@ -135,13 +135,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 获取分页参数
@ -175,13 +175,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 验证必要参数
@ -256,13 +256,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 获取用户发票信息列表
@ -288,13 +288,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 获取统计数据
@ -321,13 +321,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 验证必要参数
@ -410,13 +410,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 获取用户发票信息列表
@ -443,13 +443,13 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("");
}
// 3. 删除发票信息简化实现
@ -472,7 +472,7 @@ public class AppleInvoiceController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("");
}
UsersInvoiceInfo invoiceInfo = usersInvoiceInfoService.selectUsersInvoiceInfoById(id);
if (invoiceInfo == null) {

View File

@ -1,6 +1,7 @@
package com.ruoyi.system.controller;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
@ -87,6 +88,12 @@ public class AppleMemberController extends BaseController {
@Autowired
private IUserBenefitPointsService userBenefitPointsService;
@Autowired
private IGoodsOrderService goodsOrderService;
@Autowired
private WechatPayUtil wechatPayUtil;
@ -566,13 +573,13 @@ public class AppleMemberController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 参数验证
@ -581,78 +588,145 @@ public class AppleMemberController extends BaseController {
}
String orderId = params.get("order_id").toString();
String type = params.get("type").toString();
String content = params.get("content").toString();
Integer num = Integer.parseInt(params.get("num").toString());
// 4. 获取订单信息并验证
Order order = orderService.selectOrderByOrderId(orderId);
if (order == null) {
return AppletControllerUtil.appletWarning("订单不存在");
if (type.equals("service")){
// 4. 获取订单信息并验证
Order order = orderService.selectOrderById(Long.valueOf(orderId));
if (order == null) {
return AppletControllerUtil.appletWarning("订单不存在");
}
// 5. 检查是否已经评价过
int count = orderCommentService.selectCountOrderCommentByOid(order.getId());
if (count > 0) {
return AppletControllerUtil.appletWarning("请勿重复提交");
}
// 6. 计算评分类型
Integer numType;
if (num == 1) {
numType = 3; // 差评
} else if (num == 2 || num == 3) {
numType = 2; // 中评
} else {
numType = 1; // 好评
}
// 7. 构建评价数据
OrderComment comment = new OrderComment();
comment.setOid(order.getId());
comment.setOrderId(order.getOrderId());
comment.setProductId(order.getProductId());
comment.setContent(content);
comment.setNum(Long.valueOf(num));
comment.setNumType(Long.valueOf(numType));
comment.setUid(user.getId());
comment.setWorkerId(order.getWorkerId());
comment.setStatus(1);
//JSONArray jsonArrayimg=new JSONArray();
// 8. 处理图片附件
if (params.containsKey("images") && params.get("images") != null) {
String images = JSON.toJSONString(params.get("images"));
comment.setImages(images);
//jsonArrayimg
}
JSONArray jsonArray=new JSONArray();
// 9. 处理评价标签
if (params.containsKey("labels") && params.get("labels") != null) {
String labels = JSON.toJSONString(params.get("labels"));
comment.setLabels(labels);
// jsonArray = JSON.parseArray(labels);
}
// 10. 保存评价并更新订单状态
// 保存评价
orderCommentService.insertOrderComment(comment);
// 添加订单日志
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(orderId);
orderLog.setTitle("订单评价");
orderLog.setType(BigDecimal.valueOf(8)); // 8=评价类型
Map<String, Object> logContent = new HashMap<>();
logContent.put("text", content);
logContent.put("image", params.get("images"));
logContent.put("labels", params.get("labels"));
logContent.put("num", num);
orderLog.setContent(JSON.toJSONString(logContent));
orderLogService.insertOrderLog(orderLog);
// 更新订单状态
order.setStatus(4L); // 4=完成状态
order.setIsComment(1); // 1=已评价
orderService.updateOrder(order);
}
// 5. 检查是否已经评价过
int count = orderCommentService.selectCountOrderCommentByOid(order.getId());
if (count > 0) {
return AppletControllerUtil.appletWarning("请勿重复提交");
if (type.equals("goods")){{
GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(Long.valueOf(orderId));
// 4. 获取订单信息并验证
if (goodsOrder == null) {
return AppletControllerUtil.appletWarning("订单不存在");
}
// 5. 检查是否已经评价过
int count = orderCommentService.selectCountOrderCommentByOid(goodsOrder.getId());
if (count > 0) {
return AppletControllerUtil.appletWarning("请勿重复提交");
}
// 6. 计算评分类型
Integer numType;
if (num == 1) {
numType = 3; // 差评
} else if (num == 2 || num == 3) {
numType = 2; // 中评
} else {
numType = 1; // 好评
}
// 7. 构建评价数据
OrderComment comment = new OrderComment();
comment.setOid(goodsOrder.getId());
comment.setOrderId(goodsOrder.getOrderId());
comment.setProductId(goodsOrder.getProductId());
comment.setContent(content);
comment.setNum(Long.valueOf(num));
comment.setNumType(Long.valueOf(numType));
comment.setUid(user.getId());
comment.setStatus(1);
// 8. 处理图片附件
if (params.containsKey("images") && params.get("images") != null) {
String images = JSON.toJSONString(params.get("images"));
comment.setImages(images);
}
// 9. 处理评价标签
if (params.containsKey("labels") && params.get("labels") != null) {
String labels = JSON.toJSONString(params.get("labels"));
comment.setLabels(labels);
}
// 10. 保存评价并更新订单状态
// 保存评价
int result= orderCommentService.insertOrderComment(comment);
if (result > 0) {
goodsOrder.setStatus(5L); // 订单状态改为已收货
goodsOrderService.updateGoodsOrder(goodsOrder);
return AjaxResult.success();
} else {
return AppletControllerUtil.appletWarning("操作失败");
}
}
// 6. 计算评分类型
Integer numType;
if (num == 1) {
numType = 3; // 差评
} else if (num == 2 || num == 3) {
numType = 2; // 中评
} else {
numType = 1; // 好评
}
// 7. 构建评价数据
OrderComment comment = new OrderComment();
comment.setOid(order.getId());
comment.setOrderId(orderId);
comment.setProductId(order.getProductId());
comment.setContent(content);
comment.setNum(Long.valueOf(num));
comment.setNumType(Long.valueOf(numType));
comment.setUid(user.getId());
comment.setWorkerId(order.getWorkerId());
// 8. 处理图片附件
if (params.containsKey("images") && params.get("images") != null) {
String images = JSON.toJSONString(params.get("images"));
comment.setImages(images);
}
// 9. 处理评价标签
if (params.containsKey("labels") && params.get("labels") != null) {
String labels = JSON.toJSONString(params.get("labels"));
comment.setLabels(labels);
}
// 10. 保存评价并更新订单状态
// 保存评价
orderCommentService.insertOrderComment(comment);
// 添加订单日志
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(orderId);
orderLog.setTitle("订单评价");
orderLog.setType(BigDecimal.valueOf(8)); // 8=评价类型
Map<String, Object> logContent = new HashMap<>();
logContent.put("text", content);
logContent.put("image", params.get("images"));
logContent.put("num", num);
orderLog.setContent(JSON.toJSONString(logContent));
orderLogService.insertOrderLog(orderLog);
// 更新订单状态
order.setStatus(4L); // 4=完成状态
order.setIsComment(1); // 1=已评价
orderService.updateOrder(order);
return AjaxResult.success("评价提交成功");
} catch (Exception e) {
@ -679,13 +753,13 @@ public class AppleMemberController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证图像和昵称是否为系统默认
@ -753,13 +827,13 @@ public class AppleMemberController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
@ -786,7 +860,7 @@ public class AppleMemberController extends BaseController {
// 7. 处理报价
UserDemandQuotation quoteRecord;
boolean isFirstQuote = false;
//boolean isFirstQuote = false;
if (existingQuotes != null && !existingQuotes.isEmpty()) {
// 已有报价更新
quoteRecord = existingQuotes.getFirst();
@ -799,6 +873,7 @@ public class AppleMemberController extends BaseController {
quoteRecord = new UserDemandQuotation();
quoteRecord.setWorkerid(user.getId());
quoteRecord.setOrderid(orderId);
quoteRecord.setOid(order.getId());
quoteRecord.setMoney(quoteMoney);
quoteRecord.setQuotationTime(new Date());
quoteRecord.setStatus(1L); // 设置状态为有效
@ -806,14 +881,14 @@ public class AppleMemberController extends BaseController {
quoteRecord.setWorkerimage(user.getAvatar());
quoteRecord.setCreateTime(new Date());
userDemandQuotationService.insertUserDemandQuotation(quoteRecord);
isFirstQuote = true;
// isFirstQuote = true;
}
// 8. 如果是第一次报价更新订单状态为待选择12
if (isFirstQuote) {
order.setStatus(12L);
orderService.updateOrder(order);
}
// // 8. 如果是第一次报价更新订单状态为待选择12
// if (isFirstQuote) {
// order.setStatus(12L);
// orderService.updateOrder(order);
// }
return AppletControllerUtil.appletSuccess("报价成功");
@ -858,13 +933,13 @@ public class AppleMemberController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletUnauthorized();
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 4. 设置分页参数

View File

@ -151,7 +151,7 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 验证必要参数
@ -214,7 +214,7 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 验证必要参数
@ -345,13 +345,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 验证必要参数
if (params == null || params.get("orderNo") == null || params.get("refundNo") == null
|| params.get("totalFee") == null || params.get("refundFee") == null) {
return AppletControllerUtil.appletWarning("退款参数不完整");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证退款金额
@ -405,12 +405,12 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 验证必要参数
if (params == null || params.get("orderNo") == null) {
return AppletControllerUtil.appletWarning("订单号不能为空");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 查询支付结果
@ -461,13 +461,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 参数验证逻辑id和money必须有一个有值如果都有值则优先使用id
Object idObj = params.get("id");
@ -569,12 +569,12 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
if (params == null || params.get("order_id") == null || params.get("worker_id") == null) {
@ -665,13 +665,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
@ -754,13 +754,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
@ -830,13 +830,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
@ -909,13 +909,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
@ -995,7 +995,7 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 验证必要参数
@ -1050,13 +1050,13 @@ public class ApplePayController extends BaseController {
String token = request.getHeader("token");
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return AppletControllerUtil.appletWarning("用户未登录或token无效");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 2. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return AppletControllerUtil.appletWarning("用户信息获取失败");
return AppletControllerUtil.appletdengluWarning("用户信息获取失败");
}
// 3. 验证必要参数
@ -1077,12 +1077,7 @@ public class ApplePayController extends BaseController {
}else{
}
}
// 4. 获取订单日志信息
Long orderId = Long.valueOf(params.get("id").toString());
OrderLog orderLog = orderLogService.selectOrderLogById(orderId);
@ -1122,7 +1117,6 @@ public class ApplePayController extends BaseController {
return AppletControllerUtil.appletError("支付失败:" + e.getMessage());
}
}
/**
* 订单支付接口
* 根据订单号查询预支付信息并根据预支付信息中的支付方式和金额进行支付
@ -1174,7 +1168,13 @@ public class ApplePayController extends BaseController {
if (paytype == 1) {
// 微信支付
if (wxMoney.compareTo(BigDecimal.ZERO) <= 0) {
return AppletControllerUtil.appletWarning("微信支付金额不能为0");
// 金额为0直接走后续逻辑
payBefor.setStatus(2L); // 已支付
payBefor.setPaytime(new Date());
usersPayBeforService.updateUsersPayBefor(payBefor);
OrderUtil.prepayCallback(payBefor, user);
payResult.put("istowx", 1);
return AppletControllerUtil.appletSuccess("支付成功");
}
payResult = wechatPayUtil.createBatchOrderAndPay(
user.getOpenid(),
@ -1193,7 +1193,13 @@ public class ApplePayController extends BaseController {
} else if (paytype == 2) {
// 余额支付
if (yeMoney.compareTo(BigDecimal.ZERO) <= 0) {
return AppletControllerUtil.appletWarning("余额支付金额不能为0");
// 金额为0直接走后续逻辑
payBefor.setStatus(2L); // 已支付
payBefor.setPaytime(new Date());
usersPayBeforService.updateUsersPayBefor(payBefor);
OrderUtil.prepayCallback(payBefor, user);
payResult.put("istowx", 2);
return AppletControllerUtil.appletSuccess("支付成功");
}
Map<String, Object> balanceResult = BalancePayUtil.processBalancePayment(
user.getId(),
@ -1215,6 +1221,15 @@ public class ApplePayController extends BaseController {
}
} else if (paytype == 3) {
// 组合支付
if (wxMoney.compareTo(BigDecimal.ZERO) <= 0 && yeMoney.compareTo(BigDecimal.ZERO) <= 0) {
// 两项都为0直接走后续逻辑
payBefor.setStatus(2L); // 已支付
payBefor.setPaytime(new Date());
usersPayBeforService.updateUsersPayBefor(payBefor);
OrderUtil.prepayCallback(payBefor, user);
payResult.put("istowx", 1);
return AppletControllerUtil.appletSuccess("支付成功");
}
if (wxMoney.compareTo(BigDecimal.ZERO) > 0 && yeMoney.compareTo(BigDecimal.ZERO) > 0) {
// // 先扣余额
// Map<String, Object> balanceResult = BalancePayUtil.processBalancePayment(
@ -1366,4 +1381,82 @@ public class ApplePayController extends BaseController {
}
}
/**
* 好友代付接口
* @param params {orderid, code}
* @param request
* @return 支付参数
*/
@PostMapping("/friend/pay")
public AjaxResult friendPay(@RequestBody Map<String, Object> params, HttpServletRequest request) {
try {
// 1. 校验参数
if (params == null || params.get("orderid") == null || params.get("code") == null) {
return AppletControllerUtil.appletWarning("参数orderid和code不能为空");
}
String orderid = params.get("orderid").toString();
String code = params.get("code").toString();
Map<String, Object> openidResult = WechatApiUtil.getWechatUserOpenidInfo(code);
if (!(Boolean) openidResult.get("success")) {
System.err.println("获取openid失败" + openidResult.get("errorMsg"));
return null;
}
String openid = (String) openidResult.get("openid");
if (openid == null || openid.trim().isEmpty()) {
System.err.println("微信API返回的openid为空");
return null;
}
// // 2. 用code获取openid
// String openid = WechatApiUtil.getWechatUserOpenidInfo(code);
// if (openid == null || openid.isEmpty()) {
// return AppletControllerUtil.appletWarning("获取openid失败");
// }
// 3. 查询预支付数据
UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderid);
if (payBefor == null) {
return AppletControllerUtil.appletWarning("预支付订单不存在");
}
if (payBefor.getAllmoney() == null || payBefor.getAllmoney().compareTo(BigDecimal.ZERO) <= 0) {
return AppletControllerUtil.appletWarning("支付金额无效");
}
// 4. 调用微信支付接口
Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(
openid,
payBefor.getOrderid(),
new BigDecimal("0.01"),
1,
WechatPayUtil.PAY_FH + "api/order/friend/paydata/notify"
);
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
Map<String, Object> responseData = new HashMap<>();
responseData.put("orderid", orderid);
responseData.put("totalAmount", payBefor.getAllmoney());
responseData.put("prepayId", payResult.get("prepayId"));
responseData.putAll(payResult);
return AppletControllerUtil.appletSuccess(responseData);
} else {
String errorMsg = payResult != null ? (String) payResult.get("message") : "微信支付下单失败";
return AppletControllerUtil.appletWarning("支付下单失败:" + errorMsg);
}
// if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
// payResult.put("istowx", 1);
// return AppletControllerUtil.appletSuccess(payResult);
// } else {
// String errorMsg = payResult != null ? (String) payResult.get("message") : "微信支付下单失败";
// return AppletControllerUtil.appletWarning("支付下单失败:" + errorMsg);
// }
} catch (Exception e) {
logger.error("好友代付异常:", e);
return AppletControllerUtil.appletError("好友代付失败:" + e.getMessage());
}
}
}

View File

@ -340,7 +340,79 @@ public class PayNotifyController extends BaseController {
}
}
/**
* 拼团支付的回调接口
*
* @param request HTTP请求对象
* @return XML格式响应给微信服务器
*IUserGroupBuyingService userGroupBuyingService;
* 处理商品订单的支付成功回调
* 1. 验证支付签名
* 2. 更新商品订单支付状态
* 3. 更新订单支付时间和交易号
* 4. 处理库存扣减等业务逻辑
*/
@PostMapping(value = "/api/order/friend/paydata/notify")
public String apiorderfriendpaydatanotify(HttpServletRequest request) {
try {
logger.info("收到商品支付回调通知,开始处理...");
// 1. 使用WechatPayUtil处理支付回调
Map<String, Object> notifyResult = wechatPayUtil.handlePayNotify(request);
// 2. 检查处理结果
boolean success = (Boolean) notifyResult.get("success");
String message = (String) notifyResult.get("message");
if (!success) {
logger.error("商品支付回调处理失败:{}", message);
return buildFailResponse("商品支付回调处理失败");
}
// 3. 获取支付信息
Map<String, Object> paymentInfo = (Map<String, Object>) notifyResult.get("paymentInfo");
String outTradeNo = (String) paymentInfo.get("outTradeNo");
String transactionId = (String) paymentInfo.get("transactionId");
String totalFee = (String) paymentInfo.get("totalFee");
UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(outTradeNo);
if (usersPayBefor!=null){
usersPayBefor.setStatus(2L);
usersPayBefor.setPaytype(4L);
usersPayBefor.setPaytime(new Date());
usersPayBefor.setPaycode(transactionId);
usersPayBeforService.updateUsersPayBefor(usersPayBefor);
}
Users users = null;
if (usersPayBefor != null) {
users = usersService.selectUsersById(usersPayBefor.getUid());
}
//订单回调处理拼团创建订单其他订单修改状态
OrderUtil.prepayCallback(usersPayBefor, users);
// //最后无论如何平台流水需要添加让平台看到流水和账目
PayMoneyLog payMoneyLog = new PayMoneyLog();
if (usersPayBefor != null) {
payMoneyLog.setOid(usersPayBefor.getId());
}
payMoneyLog.setOrderId(usersPayBefor.getOrderid());
payMoneyLog.setUid(usersPayBefor.getUid());
if (users != null) {
payMoneyLog.setUname(users.getName());
}
payMoneyLog.setPrice(usersPayBefor.getWxmoney());
payMoneyLog.setMark("订单支付");
payMoneyLog.setPayTime(new Date());
payMoneyLogService.insertPayMoneyLog(payMoneyLog);
//sendWechatMessage(users,outTradeNo);
logger.info("商品支付回调处理成功,订单号:{}", outTradeNo);
return buildSuccessResponse();
} catch (Exception e) {
logger.error("商品支付回调处理异常:", e);
return buildFailResponse("商品支付回调处理异常");
}
}
/**

View File

@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.system.ControllerUtil.AppletControllerUtil;
import com.ruoyi.system.domain.QuoteCraft;
import com.ruoyi.system.domain.QuoteType;
import com.ruoyi.system.service.IQuoteMaterialTypeService;
@ -59,6 +60,7 @@ public class QuoteMaterialController extends BaseController
}
List<QuoteMaterial> list = quoteMaterialService.selectQuoteMaterialList(quoteMaterial);
for(QuoteMaterial QuoteMaterialData:list){
QuoteMaterialData.setImage(AppletControllerUtil.buildImageUrl(QuoteMaterialData.getImage()));
List<String> idslist = Arrays.asList(
QuoteMaterialData.getGoodId().replaceAll("[\\[\\]\"]", "").split(", "));
QuoteMaterialData.setServiceName(serviceGoodsService.selectTitlesByIds(idslist));

View File

@ -49,7 +49,47 @@ public class UserSecondaryCardController extends BaseController
@Autowired
private IServiceCateService serviceCateService;
/**
* 数字转中文工具方法
*/
private String numberToChinese(Long num) {
if (num == null || num <= 0) {
return "";
}
String[] chineseNumbers = {"", "", "", "", "", "", "", "", "", "", ""};
if (num <= 10) {
return chineseNumbers[num.intValue()];
} else if (num < 20) {
return "" + (num > 10 ? chineseNumbers[Math.toIntExact((num - 10))] : "");
} else if (num < 100) {
long tens = num / 10;
long ones = num % 10;
String result = chineseNumbers[(int)tens] + "";
if (ones > 0) {
result += chineseNumbers[(int)ones];
}
return result;
} else {
// 对于大于100的数字直接返回阿拉伯数字
return num.toString();
}
}
/**
* 生成introduction字段
*/
private String generateIntroduction(Long allnum, Long num) {
if (allnum == null || num == null) {
return "";
}
String allnumChinese = numberToChinese(allnum);
String numChinese = numberToChinese(num);
return allnumChinese + "" + numChinese;
}
/**
* 查询次卡管理列表
@ -107,6 +147,11 @@ public class UserSecondaryCardController extends BaseController
{
userSecondaryCard.setOrderid(GenerateCustomCode.generCreateOrder("CIKA"));
userSecondaryCard.setCreattime(new Date());
// 自动生成introduction字段
String introduction = generateIntroduction(userSecondaryCard.getAllnum(), userSecondaryCard.getNum());
userSecondaryCard.setIntroduction(introduction);
return toAjax(userSecondaryCardService.insertUserSecondaryCard(userSecondaryCard));
}
@ -118,6 +163,10 @@ public class UserSecondaryCardController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody UserSecondaryCard userSecondaryCard)
{
// 自动生成introduction字段
String introduction = generateIntroduction(userSecondaryCard.getAllnum(), userSecondaryCard.getNum());
userSecondaryCard.setIntroduction(introduction);
return toAjax(userSecondaryCardService.updateUserSecondaryCard(userSecondaryCard));
}

View File

@ -1,53 +1,92 @@
// 评价订单
public function comment(Request $request)
// 个人中心
public function index(Request $request)
{
$validator = Validator::make($request->all(),$this->comment_rule()['rules'],$this->comment_rule()['messages']);
if($validator->fails()){
return $this->error($validator->errors()->all()[0]);
}
$param = $request->post();
// 是否已经评价过
$info = Comment::where(['uid'=>$this->user_info['id'],'order_id'=>$param['order_id']])->first();
if($info){
return $this->error('请勿重复提交');
$limit = isset($param['limit']) && $param['limit'] ? $param['limit'] : env('PAGE_LIMIT');
if($this->user_info['level'])
{
$this->user_info['level_info'] = WorkerLevel::select('id','image')->find($this->user_info['level']);
}
$num_type = $param['num'] == 1 ? 3 : (in_array($param['num'],[2,3]) ? 2 : 1);
// 商品id
$order_info = Order::select('product_id','id','worker_id')->where(['order_id'=>$param['order_id']])->first();
$data = [
'oid' => $order_info['id'],
'order_id' => $param['order_id'],
'product_id' => $order_info['product_id'],
'content' => $param['content'],
'num' => $param['num'],
'uid' => $this->user_info['id'],
'images' => $param['images'] ? json_encode($param['images']) : null,
'num_type' => $num_type,
'worker_id' => $order_info['worker_id'],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
];
DB::beginTransaction();
try{
Comment::insert($data);
// 订单评价记录
$log_data = [
'oid' => $order_info['id'],
'order_id' => $param['order_id'],
'title' => '订单评价',
'type' => 8,
'content' => json_encode(['text'=>$param['content'],'image'=>$param['images'],'num'=>$data['num']]),
'created_at'=> date('Y-m-d H:i:s'),
'updated_at'=> date('Y-m-d H:i:s'),
];
Log::insert($log_data);
// 更改订单状态为完成--评价状态改为已评价
Order::where(['order_id'=>$param['order_id']])->update(['status'=>4,'is_comment'=>1]);
DB::commit();
return $this->success();
}catch(\Exception $e){
DB::rollBack();
return $this->error('操作失败'.$e->getMessage());
// 个人基本信息
$data['user'] = $this->user_info;
// 质保金
if(!$this->user_info['margin']){
$data['user']['margin'] = 0;
}
// 累计佣金
if(!$this->user_info['total_comm'])
{
$data['user']['total_comm'] = 0;
}
// 佣金
if(!$this->user_info['commission'])
{
$data['user']['commission'] = 0;
}
// 师傅技能
if($this->user_info['skill_ids'])
{
$skill_ids = array_filter(json_decode($this->user_info['skill_ids'],true));
$this->user_info['skill_arr'] = skill::whereIn('id',$skill_ids)->select('id','title')->get();
}
// 师傅服务地区
if($this->user_info['service_city_ids'])
{
$this->user_info['service_city_arr'] = DiyCity::whereIn('id',json_decode($this->user_info['service_city_ids'],true))->select('id','title')->get();
}
// 等级信息
if($this->user_info['level'])
{
$level = WorkerLevel::select('image')->find($this->user_info['level']);
if($level) $data['user']['level_img'] = $level['image'];
}
// 是否禁止接单
if(strtotime($this->user_info['prohibit_time']) < time() && strtotime($this->user_info['prohibit_time']) + $this->user_info['prohibit_time_num']*3600 > time()){
// 禁止剩余是啊金
$residue_time = strtotime($this->user_info['prohibit_time']) + $this->user_info['prohibit_time_num']*3600 - time();
$hours = intval($residue_time / 3600);
$minutes = intval(($residue_time % 3600) / 60);
$seconds = $residue_time % 60;
$str = '';
if($hours > 0) $str .= $hours.'小时';
if($minutes > 0) $str .= $minutes.'分钟';
if($seconds > 0) $str .= $seconds.'秒';
$this->user_info['prohibit'] = '因违反平台规定,'.$this->user_info['prohibit_time_num'].'小时内禁止接单,剩余'.$str;
}
// 我的服务订单
// $oids = Log::where(['worker_id'=>$this->user_info['id'],'type'=>8])->pluck('oid')->toArray();
$oids = Log::where(['worker_id'=>$this->user_info['id']])->pluck('oid')->toArray();
// 我的评价
if($oids){
$model = new Comment();
if(isset($param['type']) && $param['type'])
{
$model = $model->where(['num_type'=>$param['type']]);
}
$data['data'] = $model->whereIn('oid',$oids)
->with(['user'=>function($query){
$query->select('id','name','avatar');
}])
->select('id','uid','images','content','num','created_at')
->paginate($limit);
// 总评分
$total_num = 0;
foreach($data['data'] as &$val)
{
// 时间转换
$val['time'] = $this->mdate($val['created_at']);
$total_num += $val['num'];
}
// 评价数量
$data['comment']['one'] = Comment::where(['num_type'=>1])->whereIn('oid',$oids)->count();
$data['comment']['two'] = Comment::where(['num_type'=>2])->whereIn('oid',$oids)->count();
$data['comment']['three'] = Comment::where(['num_type'=>3])->whereIn('oid',$oids)->count();
if(count($data['data']) < 1) $data['comment']['total'] = 0;
else $data['comment']['total'] = round($total_num/count($data['data']),1);
}
return $this->success($data);
}

View File

@ -42,8 +42,12 @@ public class AppletControllerUtil {
private static final IUsersService usersService = SpringUtils.getBean(IUsersService.class);
private static final IOrderService orderService = SpringUtils.getBean(IOrderService.class);
private static final IUserAddressService userAddressService = SpringUtils.getBean(IUserAddressService.class);
private static final IOrderCommentService orderCommentService = SpringUtils.getBean(IOrderCommentService.class);
private static final IOrderLogService orderLogService = SpringUtils.getBean(IOrderLogService.class);
// ============================== 统一响应处理方法 ==============================
@ -94,7 +98,19 @@ public class AppletControllerUtil {
return result;
}
/**
* 业务提示响应 - code: 422
*
* @param message 提示消息
* @return AjaxResult
*/
public static AjaxResult appletdengluWarning(String message) {
AjaxResult result = new AjaxResult();
result.put("code", 422);
result.put("msg", message);
result.put("data", new ArrayList<>());
return result;
}
/**
* 业务提示响应 - code:500
@ -126,28 +142,28 @@ public class AppletControllerUtil {
return result;
}
/**
* Token验证失败响应 - code: 332
*
* @return AjaxResult
*/
public static AjaxResult appletUnauthorized() {
return appletUnauthorized("用户未登录或token无效请重新登录");
}
// /**
// * Token验证失败响应 - code: 332
// *
// * @return AjaxResult
// */
// public static AjaxResult appletUnauthorized() {
// return appletUnauthorized("用户未登录或token无效请重新登录");
// }
/**
* Token验证失败响应 - code: 332自定义消息
*
* @param message 提示消息
* @return AjaxResult
*/
public static AjaxResult appletUnauthorized(String message) {
AjaxResult result = new AjaxResult();
result.put("code", 332);
result.put("msg", message);
result.put("data", new ArrayList<>());
return result;
}
// /**
// * Token验证失败响应 - code: 332自定义消息
// *
// * @param message 提示消息
// * @return AjaxResult
// */
// public static AjaxResult appletUnauthorized(String message) {
// AjaxResult result = new AjaxResult();
// result.put("code", 422);
// result.put("msg", message);
// result.put("data", new ArrayList<>());
// return result;
// }
/**
* 系统错误响应 - code: 500
@ -2625,22 +2641,74 @@ public class AppletControllerUtil {
* @param order 订单主键
* @return 是否可用
*/
public static Users creatWorkerForOrder(Order order) {
GaoDeMapUtil gaoDeMapUtil = new GaoDeMapUtil();
public static Users creatWorkerForOrder(Order order,Users worker) {
order.setWorkerId(worker.getId());
order.setStatus(1L);
order.setIsPause(1);
order.setReceiveTime(new Date());
order.setWorkerPhone(worker.getPhone());
UserAddress userAddress = userAddressService.selectUserAddressById(order.getAddressId());
// if (userAddress != null){
// String city = gaoDeMapUtil.getCityByLocation(userAddress.getLongitude(), userAddress.getLatitude());
// if (city != null){
//
// }else{
//
// }
// }
Users worker = usersService.selectUsersById(2l);
if (userAddress != null){
order.setUserPhone(userAddress.getPhone());
}
order.setMiddlePhone("18339212639");
order.setReceiveType(3l);
order.setLogStatus(9);
JSONObject jSONObject = new JSONObject();
jSONObject.put("type", 9);
order.setLogJson(jSONObject.toJSONString());
orderService.updateOrder(order);
OrderLog orderLognew = new OrderLog();
orderLognew.setOid(order.getId());
orderLognew.setOrderId(order.getOrderId());
orderLognew.setTitle("系统派单");
orderLognew.setType(new BigDecimal(1.1));
JSONObject jSONObject1 = new JSONObject();
jSONObject1.put("name", "师傅收到派单信息");
orderLognew.setContent(jSONObject1.toJSONString());
orderLognew.setWorkerId(worker.getId());
orderLognew.setWorkerLogId(worker.getId());
orderLogService.insertOrderLog(orderLognew);
// GaoDeMapUtil gaoDeMapUtil = new GaoDeMapUtil();
// UserAddress userAddress = userAddressService.selectUserAddressById(order.getAddressId());
//// if (userAddress != null){
//// String city = gaoDeMapUtil.getCityByLocation(userAddress.getLongitude(), userAddress.getLatitude());
//// if (city != null){
////
//// }else{
////
//// }
//// }
// // Users worker = usersService.selectUsersById(2l);
return worker;
}
// Users worker = AppletControllerUtil.creatWorkerForOrder(orderNewData);
//
// if (worker != null) {
// // 更新订单状态为已派单
// // 添加派单日志
// // 发送通知
// WXsendMsgUtil.sendMsgForWorkerInfo(worker.getOpenid(), orderNewData, serviceGoods);
// YunXinPhoneUtilAPI.httpsAxbTransfer(worker.getPhone());
// }
/**
* 判断时间段是否可用
*
@ -4492,7 +4560,7 @@ public class AppletControllerUtil {
// 1. 验证用户token
Map<String, Object> tokenValidation = validateUserToken(token, usersService);
if (!(Boolean) tokenValidation.get("valid")) {
return appletUnauthorized((String) tokenValidation.get("message"));
return appletdengluWarning((String) tokenValidation.get("message"));
}
// 从tokenValidation中获取用户信息Map然后提取userId
@ -4894,4 +4962,225 @@ public class AppletControllerUtil {
* - data字段可能为null或空数组
* - 金额字段可能为null需要默认值处理
*/
/**
* 将字符串格式化为JSON支持数组类型字符串的处理
* <p>
* 该方法可以将各种格式的字符串转换为标准JSON格式
* 1. 普通字符串 -> JSON字符串
* 2. 数组字符串"1,2,3" -> JSON数组字符串
* 3. 对象字符串 -> JSON对象字符串
* 4. 已经是JSON格式的字符串 -> 格式化后的JSON字符串
*
* @param inputString 输入字符串
* @return 格式化后的JSON字符串如果输入为空或处理失败返回null
*/
public static String formatStringToJson(String inputString) {
if (inputString == null || inputString.trim().isEmpty()) {
return null;
}
String trimmedString = inputString.trim();
try {
// 如果已经是有效的JSON格式直接格式化返回
if (isValidJson(trimmedString)) {
return formatJsonString(trimmedString);
}
// 检查是否是数组格式的字符串用逗号分隔
if (isArrayFormatString(trimmedString)) {
return formatArrayStringToJson(trimmedString);
}
// 检查是否是对象格式的字符串key=value格式
if (isObjectFormatString(trimmedString)) {
return formatObjectStringToJson(trimmedString);
}
// 普通字符串包装为JSON字符串
return JSON.toJSONString(trimmedString);
} catch (Exception e) {
System.err.println("字符串格式化JSON失败原始字符串: [" + inputString + "], 错误: " + e.getMessage());
return null;
}
}
/**
* 检查字符串是否是有效的JSON格式
*
* @param jsonString JSON字符串
* @return 是否是有效JSON
*/
private static boolean isValidJson(String jsonString) {
try {
// 尝试解析为JSON对象或数组
if (jsonString.startsWith("{") && jsonString.endsWith("}")) {
JSONObject.parseObject(jsonString);
return true;
} else if (jsonString.startsWith("[") && jsonString.endsWith("]")) {
JSONArray.parseArray(jsonString);
return true;
}
return false;
} catch (Exception e) {
return false;
}
}
/**
* 格式化JSON字符串使其更易读
*
* @param jsonString JSON字符串
* @return 格式化后的JSON字符串
*/
private static String formatJsonString(String jsonString) {
try {
if (jsonString.startsWith("{")) {
JSONObject jsonObject = JSONObject.parseObject(jsonString);
return JSON.toJSONString(jsonObject, String.valueOf(true)); // true表示格式化输出
} else if (jsonString.startsWith("[")) {
JSONArray jsonArray = JSONArray.parseArray(jsonString);
return JSON.toJSONString(jsonArray, String.valueOf(true)); // true表示格式化输出
}
return jsonString;
} catch (Exception e) {
return jsonString;
}
}
/**
* 检查字符串是否是数组格式用逗号分隔
*
* @param inputString 输入字符串
* @return 是否是数组格式
*/
private static boolean isArrayFormatString(String inputString) {
// 检查是否包含逗号分隔符且不是JSON对象格式
return inputString.contains(",") && !inputString.startsWith("{") && !inputString.startsWith("[");
}
/**
* 将数组格式的字符串转换为JSON数组字符串
*
* @param arrayString 数组格式字符串"1,2,3""a,b,c"
* @return JSON数组字符串
*/
private static String formatArrayStringToJson(String arrayString) {
String[] items = arrayString.split(",");
List<Object> result = new ArrayList<>();
for (String item : items) {
String trimmedItem = item.trim();
if (trimmedItem.isEmpty()) {
continue;
}
// 尝试转换为数字
if (isNumeric(trimmedItem)) {
if (trimmedItem.contains(".")) {
result.add(Double.parseDouble(trimmedItem));
} else {
result.add(Long.parseLong(trimmedItem));
}
} else {
// 字符串类型
result.add(trimmedItem);
}
}
return JSON.toJSONString(result, String.valueOf(true));
}
/**
* 检查字符串是否是对象格式key=value格式
*
* @param inputString 输入字符串
* @return 是否是对象格式
*/
private static boolean isObjectFormatString(String inputString) {
// 检查是否包含等号分隔符且不是JSON格式
return inputString.contains("=") && !inputString.startsWith("{") && !inputString.startsWith("[");
}
/**
* 将对象格式的字符串转换为JSON对象字符串
*
* @param objectString 对象格式字符串"key1=value1,key2=value2"
* @return JSON对象字符串
*/
private static String formatObjectStringToJson(String objectString) {
Map<String, Object> result = new HashMap<>();
// 先按逗号分割再按等号分割
String[] pairs = objectString.split(",");
for (String pair : pairs) {
String trimmedPair = pair.trim();
if (trimmedPair.isEmpty()) {
continue;
}
String[] keyValue = trimmedPair.split("=", 2); // 最多分割2次避免值中包含等号
if (keyValue.length == 2) {
String key = keyValue[0].trim();
String value = keyValue[1].trim();
if (!key.isEmpty()) {
// 尝试转换值的类型
if (isNumeric(value)) {
if (value.contains(".")) {
result.put(key, Double.parseDouble(value));
} else {
result.put(key, Long.parseLong(value));
}
} else if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) {
result.put(key, Boolean.parseBoolean(value));
} else {
result.put(key, value);
}
}
}
}
return JSON.toJSONString(result, String.valueOf(true));
}
/**
* 检查字符串是否是数字
*
* @param str 字符串
* @return 是否是数字
*/
private static boolean isNumeric(String str) {
if (str == null || str.trim().isEmpty()) {
return false;
}
try {
Double.parseDouble(str.trim());
return true;
} catch (NumberFormatException e) {
return false;
}
}
/**
* 将字符串格式化为JSON带默认值
* <p>
* 如果格式化失败返回提供的默认值
*
* @param inputString 输入字符串
* @param defaultValue 格式化失败时的默认值
* @return 格式化后的JSON字符串失败返回默认值
*/
public static String formatStringToJson(String inputString, String defaultValue) {
String result = formatStringToJson(inputString);
return result != null ? result : defaultValue;
}
public static void main(String[] args) {
System.out.println(formatStringToJson("{\"image\":\"['https:img.huafurenjia.cn/images/2024-10-13/dKriAtS3HHsM0JAm6DdQEPQvAFnnuPcnOxau6SSy.jpg']\",\"num\":1,\"text\":\"你很好我爱你\" ,\"labels\":[\"技术专业\",\"作业规范\",\"价格合理\"] }"));
}
}

View File

@ -118,6 +118,13 @@ public class CartOrderUtil {
result.put("orderId", order.getOrderId());
result.put("productName", serviceGoods.getTitle());
result.put("allprice", itemPrice.toString());
PayBeforeUtil payBeforeUtil = new PayBeforeUtil();
//一口价金额大于0的时候进行支付
if (order.getTotalPrice().compareTo(BigDecimal.ZERO)>0){
String payBeforeId = payBeforeUtil.createPayBefore(user, itemPrice, order.getOrderId(), null, order.getProductId(), cart.getOrdertype(), order.getSku(), null, null, null, null,1L, null, null);
}
return result;
} catch (Exception e) {
logger.error("服务类购物车下单异常:", e);
@ -126,7 +133,76 @@ public class CartOrderUtil {
return result;
}
}
/**
* 商品类购物车下单
* @param user 用户
* @param serviceGoods 商品
* @param userAddress 地址
* @param goodsOrderService 商品订单service
* @return 下单结果Map
*/
public static Map<String, Object> createGoodsOrderFromOnes(Users user, String sku,int num, String reamk,ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid) {
Map<String, Object> result = new HashMap<>();
try {
BigDecimal itemPrice=BigDecimal.ZERO;
String skuStr = sku;
if (skuStr != null && !skuStr.trim().isEmpty()) {
try {
JSONObject skuJson = JSONObject.parseObject(skuStr);
if (skuJson.containsKey("price")) {
BigDecimal skuPrice = new BigDecimal(skuJson.getString("price"));
itemPrice = skuPrice.multiply(BigDecimal.valueOf(num));
} else {
// 没有price字段回退用商品price
itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num));
}
} catch (Exception e) {
// 解析失败回退用商品price
itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num));
}
} else {
// sku为空直接用商品price
itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num));
}
GoodsOrder goodsOrder = new GoodsOrder();
goodsOrder.setType(2);
goodsOrder.setOrderId(GenerateCustomCode.generCreateOrder("B"));
goodsOrder.setUid(user.getId());
goodsOrder.setUname(user.getName());
goodsOrder.setProductId(serviceGoods.getId());
goodsOrder.setProductName(serviceGoods.getTitle());
goodsOrder.setNum((long) num);
goodsOrder.setSku(sku);
goodsOrder.setIsforservice(serviceGoods.getIsforservice());
goodsOrder.setForserviceid(serviceGoods.getForserviceid());
goodsOrder.setMark(reamk);
goodsOrder.setAddressId(userAddress.getId());
goodsOrder.setName(userAddress.getName());
goodsOrder.setPhone(userAddress.getPhone());
goodsOrder.setAddress(userAddress.getAddressInfo());
goodsOrder.setTotalPrice(itemPrice);
goodsOrder.setGoodPrice(serviceGoods.getPrice());
goodsOrder.setPayPrice(itemPrice);
goodsOrder.setStatus(1L); // 待支付
goodsOrder.setMainOrderId(maincorid);
int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder);
if (insertResult <= 0) {
result.put("success", false);
result.put("msg", "商品订单创建失败");
return result;
}
result.put("success", true);
result.put("orderId", goodsOrder.getOrderId());
result.put("productName", serviceGoods.getTitle());
result.put("allprice", itemPrice.toString());
return result;
} catch (Exception e) {
logger.error("商品类购物车下单异常:", e);
result.put("success", false);
result.put("msg", "商品类购物车下单异常:" + e.getMessage());
return result;
}
}
/**
* 商品类购物车下单
* @param user 用户
@ -190,6 +266,9 @@ public class CartOrderUtil {
result.put("orderId", goodsOrder.getOrderId());
result.put("productName", serviceGoods.getTitle());
result.put("allprice", itemPrice.toString());
PayBeforeUtil payBeforeUtil = new PayBeforeUtil();
String payBeforeId = payBeforeUtil.createPayBefore(user, itemPrice, goodsOrder.getOrderId(), null, goodsOrder.getProductId(), 11L, goodsOrder.getSku(), null, null, null, null,2L, null, null);
return result;
} catch (Exception e) {
logger.error("商品类购物车下单异常:", e);

View File

@ -0,0 +1,165 @@
package com.ruoyi.system.ControllerUtil;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* 美团工具类
* 主要用于美团码的核销抵扣等相关操作
*
* @author ruoyi
*/
public class MeituanUtil {
// ====== 美团API配置请补充实际值 ======
public static String appId = "你的美团appId";
public static String appKey = "你的美团appKey";
public static String meituanApiUrl = "https://api-open-cater.meituan.com"; // 示例
public static String privateKeyPem = "-----BEGIN PRIVATE KEY-----\n你的私钥内容\n-----END PRIVATE KEY-----";
public static String publicKeyPem = "-----BEGIN PUBLIC KEY-----\n你的公钥内容\n-----END PUBLIC KEY-----";
// ========== 通用签名生成 =============
/**
* 生成签名示例具体算法请参考美团开放平台文档
* @param data 待签名数据
* @param privateKey 私钥对象
* @return 签名字符串
*/
public static String sign(String data, PrivateKey privateKey) throws Exception {
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initSign(privateKey);
signature.update(data.getBytes(StandardCharsets.UTF_8));
byte[] signBytes = signature.sign();
return Base64.getEncoder().encodeToString(signBytes);
}
// ========== HTTP请求工具 =============
/**
* 发送POST请求
* @param apiUrl 接口地址
* @param jsonBody 请求体
* @return 响应字符串
*/
public static String doPost(String apiUrl, String jsonBody) throws Exception {
URL url = new URL(apiUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
conn.setDoOutput(true);
try (OutputStream os = conn.getOutputStream()) {
os.write(jsonBody.getBytes(StandardCharsets.UTF_8));
}
StringBuilder response = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
response.append(line);
}
}
return response.toString();
}
// ========== 美团业务API实现 =============
/**
* 美团码核销
* @param code 美团券码
* @param orderId 订单号
* @return 核销结果
*/
public static Map<String, Object> verifyMeituanCode(String code, String orderId) {
Map<String, Object> result = new HashMap<>();
try {
// 1. 构造请求参数
Map<String, Object> param = new HashMap<>();
param.put("app_id", appId);
param.put("order_id", orderId);
param.put("code", code);
// TODO: 其他必需参数
// 2. 生成签名具体字段顺序和内容请参考美团文档
// String sign = sign(待签名字符串, 私钥对象);
// param.put("sign", sign);
// 3. 转为JSON
String jsonBody = com.alibaba.fastjson2.JSON.toJSONString(param);
// 4. 发送请求
String apiUrl = meituanApiUrl + "/your/verify/api/path"; // TODO: 替换为实际核销接口路径
String response = doPost(apiUrl, jsonBody);
// 5. 解析响应
// TODO: 按美团返回格式解析
result.put("success", true);
result.put("msg", "核销成功");
result.put("response", response);
} catch (Exception e) {
result.put("success", false);
result.put("msg", "核销失败: " + e.getMessage());
}
return result;
}
/**
* 美团码抵扣
* @param code 美团券码
* @param amount 抵扣金额
* @return 抵扣结果
*/
public static Map<String, Object> deductMeituanCode(String code, double amount) {
Map<String, Object> result = new HashMap<>();
try {
Map<String, Object> param = new HashMap<>();
param.put("app_id", appId);
param.put("code", code);
param.put("amount", amount);
// TODO: 其他必需参数和签名
String jsonBody = com.alibaba.fastjson2.JSON.toJSONString(param);
String apiUrl = meituanApiUrl + "/your/deduct/api/path"; // TODO: 替换为实际抵扣接口路径
String response = doPost(apiUrl, jsonBody);
result.put("success", true);
result.put("msg", "抵扣成功");
result.put("response", response);
} catch (Exception e) {
result.put("success", false);
result.put("msg", "抵扣失败: " + e.getMessage());
}
return result;
}
/**
* 查询美团码状态
* @param code 美团券码
* @return 状态结果
*/
public static Map<String, Object> queryMeituanCodeStatus(String code) {
Map<String, Object> result = new HashMap<>();
try {
Map<String, Object> param = new HashMap<>();
param.put("app_id", appId);
param.put("code", code);
// TODO: 其他必需参数和签名
String jsonBody = com.alibaba.fastjson2.JSON.toJSONString(param);
String apiUrl = meituanApiUrl + "/your/query/api/path"; // TODO: 替换为实际查询接口路径
String response = doPost(apiUrl, jsonBody);
result.put("success", true);
result.put("msg", "查询成功");
result.put("response", response);
} catch (Exception e) {
result.put("success", false);
result.put("msg", "查询失败: " + e.getMessage());
}
return result;
}
// ========== 私钥公钥加载工具可选 =============
// 可根据需要实现PEM字符串转PrivateKey/公钥对象的方法
// ...
// 可根据实际美团API文档继续扩展更多方法
}

View File

@ -6,6 +6,7 @@ import com.ruoyi.common.utils.AmapUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import java.math.BigDecimal;
@ -24,6 +25,9 @@ public class OrderUtil {
private static IUsersService usersService = SpringUtils.getBean(IUsersService.class);
private static IOrderLogService orderLogService = SpringUtils.getBean(IOrderLogService.class);
private static IGoodsOrderService goodsOrderService = SpringUtils.getBean(IGoodsOrderService.class);
private static IUserDemandQuotationService userDemandQuotationService = SpringUtils.getBean(IUserDemandQuotationService.class);
private static IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
private static IQuoteMaterialService quoteMaterialService = SpringUtils.getBean(IQuoteMaterialService.class);
private static OrderLogHandler orderLogHandler = SpringUtils.getBean(OrderLogHandler.class);
@ -31,6 +35,43 @@ public class OrderUtil {
private static final String PREFIX = "C";
private static final int FIXED_LENGTH = 15; // 总长度为15
/**
* 创建新用户对象
*
* @return 新用户对象
*/
public static JSONObject getbaojiajson(String json) {
if (StringUtils.isNotBlank(json)) {
JSONObject jsonObject = JSONObject.parseObject(json);
JSONArray material = jsonObject.getJSONArray("material");
if (material != null) {
for (int i = 0; i < material.size(); i++) {
JSONObject jsonObjectmaterial = material.getJSONObject(i);
String id = jsonObjectmaterial.getString("id");
if (StringUtils.isNotBlank(id)) {
QuoteMaterial quoteMaterial = quoteMaterialService.selectQuoteMaterialById(Long.parseLong(id));
if (quoteMaterial != null) {
jsonObjectmaterial.put("manyimages", JSONArray.parseArray(quoteMaterial.getManyimages()));
jsonObjectmaterial.put("image", AppletControllerUtil.buildImageUrl(quoteMaterial.getImage()));
if (StringUtils.isNotBlank(quoteMaterial.getContent()) && StringUtils.isNotBlank(quoteMaterial.getManyimages())) {
jsonObjectmaterial.put("showtype", 1);
} else {
jsonObjectmaterial.put("showtype", 2);
}
jsonObjectmaterial.put("content", quoteMaterial.getContent());
}
}
}
}
// 直接返回原始jsonObject其他字段都保留
return jsonObject;
}
return new JSONObject();
}
/**
* 生成订单编码的工具
*
@ -585,50 +626,215 @@ public class OrderUtil {
* @return 新建的订单对象仅拼团或处理结果Map
*/
public static Object prepayCallback(UsersPayBefor payBefor, Users user) {
System.out.println("=== prepayCallback 方法开始 ===");
System.out.println("输入参数 - payBefor: " + (payBefor != null ? payBefor.toString() : "null"));
System.out.println("输入参数 - user: " + (user != null ? user.toString() : "null"));
if (payBefor == null || user == null) {
System.out.println("参数验证失败 - payBefor或user为空");
return null;
}
int type = payBefor.getType() != null ? payBefor.getType().intValue() : 0;
System.out.println("支付类型 - type: " + type);
System.out.println("服务类型 - servicetype: " + payBefor.getServicetype());
IOrderService orderService = SpringUtils.getBean(IOrderService.class);
// 拼团
if (payBefor.getServicetype()==2){
if (type == 6){
GoodsOrder gorder = new GoodsOrder();
gorder.setMainOrderId(payBefor.getOrderid());
System.out.println("查询拼团商品订单 - orderid: " + payBefor.getOrderid());
List<GoodsOrder> orderslist =goodsOrderService.selectGoodsOrderList(gorder);
System.out.println("查询到的商品订单数量: " + (orderslist != null ? orderslist.size() : 0));
if (!orderslist.isEmpty()){
for (GoodsOrder goodsOrder : orderslist){
goodsOrder.setStatus(2L);
goodsOrder.setTransactionId(payBefor.getPaycode());
goodsOrderService.updateGoodsOrder(goodsOrder);
}
System.out.println("开始更新商品订单状态");
for (GoodsOrder goodsOrder : orderslist){
System.out.println("更新商品订单 - ID: " + goodsOrder.getId() + ", 原状态: " + goodsOrder.getStatus());
goodsOrder.setStatus(2L);
goodsOrder.setTransactionId(payBefor.getPaycode());
int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
System.out.println("商品订单更新结果: " + updateResult);
}
} else {
System.out.println("未找到相关商品订单");
}
System.out.println("拼团商品订单处理完成返回orderid: " + payBefor.getOrderid());
return payBefor.getOrderid();
}
//需求报价
if (type == 4) {
// 查询订单
Order order = orderService.selectOrderByOrderId(payBefor.getOrderid());
// 7上门费 8定金 9尾款 10差价
if (type == 11) {
GoodsOrder order = goodsOrderService.selectGoodsOrderByorderId(payBefor.getOrderid());
if (order != null) {
// 更新订单状态为待服务2
order.setStatus(2L);
orderService.updateOrder(order);
// 添加订单日志
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(order.getOrderId());
orderLog.setTitle("报价订单支付成功");
orderLog.setType(new BigDecimal("1.1"));
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "报价订单支付成功,待服务");
orderLog.setContent(jsonObject.toJSONString());
orderLogService.insertOrderLog(orderLog);
return order;
order.setTransactionId(payBefor.getPaycode());
int updateResult = goodsOrderService.updateGoodsOrder(order);
}
return null;
}
if (type == 7) {
// 4. 查询对应的订单日志上门费记录
OrderLog orderLog = orderLogService.selectOrderLogById(payBefor.getOid());
if (orderLog != null) {
// 6. 更新上门费支付状态
orderLog.setPaid(2L); // 1已支付
//orderLog.setWorkerCost(new BigDecimal(totalFee));
orderLog.setPayTime(System.currentTimeMillis()/1000);
//orderLog.setUpdateTime(new Date());
int updateResult = orderLogService.updateOrderLog(orderLog);
if (updateResult > 0){
ISTOPAYSIZE(payBefor.getLastorderid());
}
// int paynum=usersPayBeforService.countByLastOrderIdAndStatus(order.getOrderId(), 1);
// Order order = orderService.selectOrderByOrderId(payBefor.getLastorderid());
// if (order != null) {
// if (order.getStatus() == 6){
//
// }
// }
}
return 1;
}
if (type == 8) {
// 4. 查询对应的订单日志定金记录
OrderLog orderLog = orderLogService.selectOrderLogById(payBefor.getOid());
if (orderLog != null) {
// 6. 更新定金支付状态
orderLog.setDepPaid(2); // 1已支付
orderLog.setDepPayTime(System.currentTimeMillis()/1000);
int updateResult = orderLogService.updateOrderLog(orderLog);
if (updateResult > 0){
ISTOPAYSIZE(payBefor.getLastorderid());
}
}
return 1;
}
if (type == 9) {
// 4. 查询对应的服务订单
Order order = orderService.selectOrderByOrderId(payBefor.getOrderid());
if (order != null) {
//更新最新的一条日志信息
OrderLog orderLog = orderLogService.selectDataTheFirstNew(order.getId());
orderLog.setPayTime(System.currentTimeMillis()/1000);
orderLog.setPaid(2L);
int updateResult = orderLogService.updateOrderLog(orderLog);
// OrderLog orderLog1 = orderLogService.selectOrderLogById(payBefor.getOid());
// 6. 更新订单支付状态
// order.setStatus(4L); // 2已支付
// // order.setTransactionId(transactionId);
// order.setPayTime(new Date());
// //order.setUpdateTime(new Date());
// // 计算实际支付金额分转换为元
// BigDecimal paidAmount = orderLog1.getPrice();
// order.setPayPrice(paidAmount);
// int updateResult = orderService.updateOrder(order);
if (updateResult > 0){
ISTOPAYSIZE(payBefor.getLastorderid());
}
}
return 1;
}
if (type == 10) {
OrderLog orderLog = orderLogService.selectOrderLogById(payBefor.getOid());
if (orderLog != null) {
// 6. 更新定金支付状态
orderLog.setCjPaid(2L);
orderLog.setDepPayTime(System.currentTimeMillis()/1000);
int updateResult = orderLogService.updateOrderLog(orderLog);
if (updateResult > 0){
ISTOPAYSIZE(payBefor.getLastorderid());
}
}
return 1;
}
//需求报价
if (type == 4) {
System.out.println("=== 处理需求报价订单 ===");
System.out.println("查询订单 - orderid: " + payBefor.getOrderid());
// 查询订单
Order order = orderService.selectOrderByOrderId(payBefor.getOrderid());
System.out.println("查询到的订单: " + (order != null ? order.toString() : "null"));
if (order != null) {
UserDemandQuotation userDemandQuotation=userDemandQuotationService.selectUserDemandQuotationById(payBefor.getBaojiaid());
if (userDemandQuotation!=null) {
System.out.println("找到报价记录,开始处理");
//UserDemandQuotation userDemandQuotation=userDemandQuotationList.getFirst();
System.out.println("报价记录详情: " + userDemandQuotation.toString());
System.out.println("更新报价状态为被选中");
userDemandQuotation.setStatus(2L);//被选中状态
int quotationUpdateResult = userDemandQuotationService.updateUserDemandQuotation(userDemandQuotation);
System.out.println("报价状态更新结果: " + quotationUpdateResult);
System.out.println("查询师傅信息 - workerId: " + userDemandQuotation.getWorkerid());
Users users = usersService.selectUsersById(userDemandQuotation.getWorkerid());
System.out.println("查询到的师傅信息: " + (users != null ? users.toString() : "null"));
if (users != null){
order.setStatus(2L);
order.setJsonStatus(2);
order.setFirstWorkerId(users.getId());
order.setIsAccept(1);
order.setWorkerPhone(users.getPhone());
order.setWorkerId(users.getId());
int orderUpdateResult = orderService.updateOrder(order);
System.out.println("订单更新结果: " + orderUpdateResult);
// 添加订单日志
System.out.println("添加订单日志");
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(order.getOrderId());
orderLog.setTitle("报价订单支付成功");
orderLog.setType(new BigDecimal("2.0"));
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "报价订单支付成功,待服务,师傅"+users.getName());
orderLog.setContent(jsonObject.toJSONString());
int logInsertResult = orderLogService.insertOrderLog(orderLog);
System.out.println("订单日志插入结果: " + logInsertResult);
System.out.println("需求报价订单处理完成");
} else {
System.out.println("未找到师傅信息,处理失败");
}
} else {
System.out.println("未找到报价记录,处理失败");
}
System.out.println("需求报价订单处理完成返回order: " + (order != null ? order.getOrderId() : "null"));
//dispatchOrderCheck(order);
return order;
} else {
System.out.println("未找到订单,处理失败");
}
System.out.println("需求报价订单处理失败返回null");
return null;
}
if (type == 2) {
System.out.println("处理次卡订单");
IUserUseSecondaryCardService userUseSecondaryCardService = SpringUtils.getBean(IUserUseSecondaryCardService.class);
UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(payBefor.getOrderid());
System.out.println("查询到的次卡记录: " + (userUseSecondaryCard != null ? userUseSecondaryCard.toString() : "null"));
if (userUseSecondaryCard != null) {
System.out.println("更新次卡状态");
userUseSecondaryCard.setStatus(1L);
int cardUpdateResult = userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard);
System.out.println("次卡状态更新结果: " + cardUpdateResult);
}
return null;
}
if (type == 1) {
System.out.println("=== 处理拼团订单 ===");
String ptorderid= payBefor.getOrderid();
System.out.println("拼团订单ID: " + ptorderid);
//第一步创建订单状态为待成团
Order order = new Order();
order.setOdertype(1); // 拼团
@ -638,23 +844,32 @@ public class OrderUtil {
order.setNum(1L); // 默认1可根据业务调整
//order.setProductId(payBefor.getSku() != null ? Long.valueOf(payBefor.getSku()) : null); // 假设sku字段存储商品ID
order.setProductId(payBefor.getServiceid()); // 假设sku字段存储商品ID
System.out.println("商品ID: " + payBefor.getServiceid());
IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class);
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(payBefor.getServiceid());
System.out.println("查询到的商品信息: " + (serviceGoods != null ? serviceGoods.toString() : "null"));
// 商品名图片类型价格等
String productName = "";
if (serviceGoods != null) {
productName = serviceGoods.getTitle();
System.out.println("商品名称: " + productName);
}
order.setProductName(productName);
order.setSku(payBefor.getSku());
order.setTotalPrice(payBefor.getAllmoney());
order.setBigtype(3);
order.setPayPrice(payBefor.getWxmoney());
order.setCreateTime(new Date());
order.setType(1); // 服务订单
order.setCreateType(1); // 用户自主下单
order.setUname(user.getName());
System.out.println("订单基本信息设置完成");
// 预约时间
System.out.println("预约时间: " + payBefor.getMaketime());
if (payBefor.getMaketime() != null && !payBefor.getMaketime().isEmpty()) {
String[] makeTimeArr = payBefor.getMaketime().split(" ");
if (makeTimeArr.length == 2) {
@ -668,19 +883,26 @@ public class OrderUtil {
}
}
}
System.out.println("地址ID: " + payBefor.getAddressid());
if (payBefor.getAddressid() != null) {
IUserAddressService userAddressService = SpringUtils.getBean(IUserAddressService.class);
UserAddress userAddress = userAddressService.selectUserAddressById(payBefor.getAddressid());
System.out.println("查询到的地址信息: " + (userAddress != null ? userAddress.toString() : "null"));
if (userAddress != null) {
order.setAddressId(userAddress.getId());
order.setName(userAddress.getName());
order.setPhone(userAddress.getPhone());
order.setAddress(userAddress.getAddressInfo());
System.out.println("地址信息设置完成");
}
}
// 可补充其它字段如拼团价优惠券备注等
orderService.insertOrder(order);
System.out.println("开始插入订单");
int orderInsertResult = orderService.insertOrder(order);
System.out.println("订单插入结果: " + orderInsertResult + ", 订单ID: " + order.getId());
// 添加订单日志
System.out.println("添加订单日志");
IOrderLogService orderLogService = SpringUtils.getBean(IOrderLogService.class);
//IOrderService orderService = SpringUtils.getBean(IOrderService.class);
OrderLog orderLog = new OrderLog();
@ -691,49 +913,100 @@ public class OrderUtil {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "订单创建成功,待成团");
orderLog.setContent(jsonObject.toJSONString());
orderLogService.insertOrderLog(orderLog);
int logInsertResult = orderLogService.insertOrderLog(orderLog);
System.out.println("订单日志插入结果: " + logInsertResult);
//第二步修改拼团时候的状态
System.out.println("=== 第二步:修改拼团状态 ===");
IUserGroupBuyingService userGroupBuyingService = SpringUtils.getBean(IUserGroupBuyingService.class);
UserGroupBuying userGroupBuying = userGroupBuyingService.selectUserGroupBuyingByptorderid(ptorderid);
System.out.println("查询到的拼团记录: " + (userGroupBuying != null ? userGroupBuying.toString() : "null"));
if (userGroupBuying != null){
System.out.println("更新拼团状态");
userGroupBuying.setStatus(1L);
userGroupBuying.setPaystatus(1L);
userGroupBuyingService.updateUserGroupBuying(userGroupBuying);
int groupUpdateResult = userGroupBuyingService.updateUserGroupBuying(userGroupBuying);
System.out.println("拼团状态更新结果: " + groupUpdateResult);
} else {
System.out.println("未找到拼团记录");
}
//第三步核验团数据如果满足条件都修改为待预约
System.out.println("=== 第三步:核验团数据 ===");
System.out.println("团订单ID: " + payBefor.getGrouporderid());
System.out.println("商品拼团人数要求: " + (serviceGoods != null ? serviceGoods.getGroupnum() : "null"));
UserGroupBuying userGroupBuyingData = new UserGroupBuying();
userGroupBuyingData.setOrderid(payBefor.getGrouporderid());
userGroupBuyingData.setPaystatus(1L);
userGroupBuyingData.setStatus(1L);
List<UserGroupBuying> userGroupBuyingList = userGroupBuyingService.selectUserGroupBuyingList(userGroupBuyingData);
if (userGroupBuyingList.size() >= serviceGoods.getGroupnum()) {
for (UserGroupBuying groupBuying1 : userGroupBuyingList){
groupBuying1.setStatus(1L);
System.out.println("已支付的拼团人数: " + (userGroupBuyingList != null ? userGroupBuyingList.size() : 0));
if (userGroupBuyingList != null && serviceGoods != null && userGroupBuyingList.size() >= serviceGoods.getGroupnum()) {
System.out.println("拼团人数已满足要求,开始更新所有拼团订单状态");
for (UserGroupBuying groupBuying1 : userGroupBuyingList) {
System.out.println("更新拼团记录 - ID: " + groupBuying1.getId() + ", 订单ID: " + groupBuying1.getPtorderid());
groupBuying1.setStatus(2L);
groupBuying1.setPaystatus(1L);
userGroupBuyingService.updateUserGroupBuying(groupBuying1);
int groupUpdateResult = userGroupBuyingService.updateUserGroupBuying(groupBuying1);
System.out.println("拼团记录更新结果: " + groupUpdateResult);
Order orderdata = orderService.selectOrderByOrderId(groupBuying1.getPtorderid());
if (orderdata != null){
System.out.println("查询到的订单: " + (orderdata != null ? orderdata.getOrderId() : "null"));
if (orderdata != null) {
System.out.println("更新订单状态为已成团待预约");
orderdata.setStatus(10L);//已成团待预约
orderService.updateOrder(orderdata);
int orderUpdateResult = orderService.updateOrder(orderdata);
System.out.println("订单状态更新结果: " + orderUpdateResult);
}
}
System.out.println("拼团成功,所有订单状态已更新");
}
System.out.println("拼团订单处理完成返回order: " + order.getOrderId());
dispatchOrderCheck(order);
return order;
} else { // 其他类型
System.out.println("=== 处理其他类型订单 ===");
System.out.println("订单ID: " + payBefor.getOrderid());
// 只更新订单状态为待预约假设为1
if (payBefor.getOrderid() != null) {
if (type == 2){
System.out.println("处理次卡订单");
IUserUseSecondaryCardService userUseSecondaryCardService = SpringUtils.getBean(IUserUseSecondaryCardService.class);
UserUseSecondaryCard userUseSecondaryCard = userUseSecondaryCardService.selectUserUseSecondaryCardByorderId(payBefor.getOrderid());
System.out.println("查询到的次卡记录: " + (userUseSecondaryCard != null ? userUseSecondaryCard.toString() : "null"));
if (userUseSecondaryCard != null){
System.out.println("更新次卡状态");
userUseSecondaryCard.setStatus(1L);
userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard);
int cardUpdateResult = userUseSecondaryCardService.updateUserUseSecondaryCard(userUseSecondaryCard);
System.out.println("次卡状态更新结果: " + cardUpdateResult);
} else {
Order order = orderService.selectOrderByOrderId(payBefor.getOrderid());
System.out.println("添加订单日志");
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(order.getOrderId());
orderLog.setTitle("订单支付");
orderLog.setType(new BigDecimal("1.1"));
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "一口价订单支付成功,待派单");
orderLog.setContent(jsonObject.toJSONString());
int logInsertResult = orderLogService.insertOrderLog(orderLog);
order.setStatus(1L); // 1=待预约
int orderUpdateResult = orderService.updateOrder(order);
dispatchOrderCheck(order);
return order;
}
System.out.println("次卡订单处理完成,返回: " + (userUseSecondaryCard != null ? userUseSecondaryCard.getId() : "null"));
return userUseSecondaryCard;
}else{
System.out.println("处理普通订单");
Order order = orderService.selectOrderByOrderId(payBefor.getOrderid());
System.out.println("查询到的订单: " + (order != null ? order.toString() : "null"));
if (order != null) {
System.out.println("添加订单日志");
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(order.getOrderId());
@ -742,14 +1015,24 @@ public class OrderUtil {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "订单支付成功,待派单");
orderLog.setContent(jsonObject.toJSONString());
orderLogService.insertOrderLog(orderLog);
order.setStatus(1L); // 1=待预约
orderService.updateOrder(order);
return order;
}
int logInsertResult = orderLogService.insertOrderLog(orderLog);
System.out.println("订单日志插入结果: " + logInsertResult);
System.out.println("更新订单状态为待派单");
order.setStatus(1L); // 1=待预约
int orderUpdateResult = orderService.updateOrder(order);
System.out.println("订单状态更新结果: " + orderUpdateResult);
System.out.println("普通订单处理完成返回order: " + order.getOrderId());
dispatchOrderCheck(order);
return order;
} else {
System.out.println("未找到订单");
}
}
} else {
System.out.println("订单ID为空无法处理");
}
System.out.println("其他类型订单处理失败返回null");
return null;
}
}
@ -807,4 +1090,172 @@ public class OrderUtil {
}
return false;
}
public static int ISTOPAYSIZE(String orderid) {
IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
IOrderService orderService = SpringUtils.getBean(IOrderService.class);
int count = usersPayBeforService.countByLastOrderIdAndStatus(orderid);
System.out.println("count订单日志: " +count);
if(count <= 0){
Order order = orderService.selectOrderByOrderId(orderid);
if(order != null){
OrderLog orderLog = orderLogService.selectDataTheFirstNew(order.getId());
System.out.println("订单日志: " + (orderLog != null ? orderLog.toString() : "null"));
System.out.println("orderLog.getType()订单日志: " + orderLog.getType());
if(orderLog.getType().compareTo(new BigDecimal("6")) > 0){
// 修改订单状态为6
order.setStatus(6L);
orderService.updateOrder(order);
}
}
}
return count;
}
/**
* 派单效验方法
* @param order 订单对象需包含 productId
* @return 处理结果Map包含派单方式绑定工人等信息
*/
public static Map<String, Object> dispatchOrderCheck(Order order) {
IOrderService orderService = SpringUtils.getBean(IOrderService.class);
Map<String, Object> result = new HashMap<>();
if (order == null || order.getProductId() == null) {
result.put("success", false);
result.put("msg", "订单或商品ID为空");
return result;
}
IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class);
IOrderLogService orderLogService = SpringUtils.getBean(IOrderLogService.class);
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId());
if (serviceGoods == null) {
result.put("success", false);
result.put("msg", "未找到对应服务商品");
return result;
}
if(order.getOdertype()==4){
return result;
}
Integer dispatchType = serviceGoods.getDispatchtype();
result.put("dispatchtype", dispatchType);
if (dispatchType != null && dispatchType == 3) {
// 指定工人派单
String workerIdsStr = serviceGoods.getWorkerids();
result.put("workerids", workerIdsStr);
if (workerIdsStr != null) {
Users users = usersService.selectUsersById(Long.valueOf(workerIdsStr));
order.setStatus(1L);
order.setFirstWorkerId(users.getId());
order.setIsAccept(1);
order.setWorkerPhone(users.getPhone());
order.setWorkerId(users.getId());
int orderUpdateResult = orderService.updateOrder(order);
// 添加订单日志
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(order.getOrderId());
orderLog.setTitle("订单支付成功");
orderLog.setType(new BigDecimal("1.0"));
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "一口价订单支付成功,待服务,师傅"+users.getName());
orderLog.setContent(jsonObject.toJSONString());
int logInsertResult = orderLogService.insertOrderLog(orderLog);
return result;
} else {
result.put("success", false);
result.put("msg", "服务未配置指定工人");
return result;
}
}
// 其他派单类型可扩展
result.put("success", true);
result.put("msg", "无需指定工人派单");
return result;
}
/**
* 获取维修订单派单师傅列表
* @param orderId 订单id
* @return 符合条件的师傅列表
*/
public static List<Users> getDispatchWorkerList(Long orderId) {
IUsersService usersService = SpringUtils.getBean(IUsersService.class);
IOrderService orderService = SpringUtils.getBean(IOrderService.class);
IServiceGoodsService serviceGoodsService = SpringUtils.getBean(IServiceGoodsService.class);
IUserAddressService userAddressService = SpringUtils.getBean(IUserAddressService.class);
List<Users> result = new ArrayList<>();
// 2. 查询订单服务地址
Order order = orderService.selectOrderById(orderId);
if (order == null) return result;
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId());
if (serviceGoods == null) return result;
UserAddress address = userAddressService.selectUserAddressById(order.getAddressId());
if (address == null) return result;
// 服务技能要求
List<String> requiredSkills = new ArrayList<>();
if (serviceGoods.getSkillIds() != null && !serviceGoods.getSkillIds().trim().isEmpty()) {
requiredSkills = JSONArray.parseArray(serviceGoods.getSkillIds(), String.class);
}
// 1. 查找当日签到过的师傅type=2is_stop=0worker_time为当天
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
Users query = new Users();
query.setType("2");
query.setWorkerTimeStr(today);
query.setSkillArr(requiredSkills);
query.setIsStop(0);
List<Users> signedWorkers = usersService.selectUsersList(query);
if (signedWorkers.isEmpty()) return result;
// 3. 逐个师傅筛选技能和服务区域
for (Users worker : signedWorkers) {
// // 技能匹配
// boolean skillMatch = false;
// if (worker.getSkillIds() != null && !worker.getSkillIds().trim().isEmpty() && !requiredSkills.isEmpty()) {
// List<String> workerSkills = com.alibaba.fastjson.JSONArray.parseArray(worker.getSkillIds(), String.class);
// for (String s : requiredSkills) {
// if (workerSkills.contains(s)) {
// skillMatch = true;
// break;
// }
// }
// }
// if (!skillMatch) continue;
// // 区域匹配
// boolean areaMatch = false;
// // 假设addressInfo字段中包含城市ID如有cityId字段请替换
// String addressCityId = null;
// if (address.getAddressInfo() != null) {
// addressCityId = address.getAddressInfo(); // 这里请根据实际情况提取城市ID
// }
// if (worker.getServiceCityIds() != null && !worker.getServiceCityIds().trim().isEmpty() && addressCityId != null) {
// List<String> workerAreas = com.alibaba.fastjson.JSONArray.parseArray(worker.getServiceCityIds(), String.class);
// if (workerAreas.contains(addressCityId)) {
// areaMatch = true;
// }
// }
// if (!areaMatch) continue;
result.add(worker);
}
// 排序先按等级降序再按质保金降序
result.sort((a, b) -> {
int levelA = a.getLevel() != null ? a.getLevel() : 0;
int levelB = b.getLevel() != null ? b.getLevel() : 0;
int cmp = Integer.compare(levelB, levelA);
if (cmp != 0) return cmp;
BigDecimal marginA = a.getMargin() != null ? a.getMargin() : BigDecimal.ZERO;
BigDecimal marginB = b.getMargin() != null ? b.getMargin() : BigDecimal.ZERO;
return marginB.compareTo(marginA);
});
return result;
}
public static void main(String[] args) {
// 构造一个测试用的json字符串
String testJson = "{\"project\":{\"name\":\"项目费用\",\"price\":1132.00},\"reduction\":{\"name\":\"优惠金额\",\"price\":\"1\"},\"deposit\":{\"name\":\"定金\",\"price\":\"10\"},\"basic\":[{\"name\":\"测试基建2\",\"select\":true},{\"name\":\"测试基建5\",\"select\":true},{\"name\":\"测试基建8\",\"select\":true}],\"craft\":[{\"name\":\"三挂一方柜\",\"price\":\"336.00\",\"pid\":192,\"id\":1889,\"count\":3}],\"material\":[{\"name\":\"其他辅料面议项\",\"price\":\"1.00\",\"id\":1241,\"pid\":93,\"count\":1},{\"name\":\"除味剂\",\"price\":\"28.00\",\"id\":1240,\"pid\":93,\"count\":1},{\"name\":\"除味剂\",\"price\":\"28.00\",\"id\":1196,\"pid\":93,\"count\":1},{\"name\":\"其他辅料面议项\",\"price\":\"1.00\",\"id\":1197,\"pid\":93,\"count\":1},{\"name\":\"其他辅料面议项\",\"price\":\"1.00\",\"id\":1197,\"pid\":92,\"count\":1},{\"name\":\"111\",\"price\":\"10.00\",\"id\":1250,\"pid\":92,\"count\":1},{\"name\":\"除味剂\",\"price\":\"28.00\",\"id\":1196,\"pid\":92,\"count\":2}]}";
OrderUtil util = new OrderUtil();
JSONObject result = util.getbaojiajson(testJson);
System.out.println("处理后的结果: " + result.toJSONString());
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.ControllerUtil;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SiteConfig;
import com.ruoyi.system.domain.Users;
@ -13,6 +14,7 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.ruoyi.system.domain.OrderLog;
/**
* 预支付工具类
@ -48,7 +50,7 @@ public class PayBeforeUtil {
*/
public String createPayBefore(Users user, BigDecimal amount, String orderId, Long oid,
Long serviceId, Long orderType, String sku, String grouporderid,
Long addressid, String maketime, String attachments,Long servicetype) {
Long addressid, String maketime, String attachments,Long servicetype,Long baojiaid,String lastorderid) {
try {
// 计算会员优惠和服务金抵扣
BigDecimal memberMoney = BigDecimal.ZERO;
@ -83,7 +85,6 @@ public class PayBeforeUtil {
}
// 购物金抵扣当servicetype=2时
if (servicetype != null && servicetype == 2) {
orderType= 5L;
Integer consumption = configJson.getInteger("consumption");
if (consumption != null && consumption > 0) {
Users userDb = usersService.selectUsersById(user.getId());
@ -123,8 +124,10 @@ public class PayBeforeUtil {
payBefore.setAddressid(addressid);
payBefore.setMaketime(maketime != null ? maketime : "");
payBefore.setAttachments(attachments != null ? attachments : "");
payBefore.setBaojiaid(baojiaid);
payBefore.setStatus(1L); // 1待支付
payBefore.setPaytype(1L); // 默认微信支付
payBefore.setLastorderid(lastorderid != null ? lastorderid : "");
int result = usersPayBeforService.insertUsersPayBefor(payBefore);
if (result > 0) {
return payBefore.getOrderid();
@ -236,7 +239,7 @@ public class PayBeforeUtil {
* @return 预支付记录ID失败返回null
*/
public String createPayBefore(Users user, BigDecimal amount) {
return createPayBefore(user, amount, null, null, 0L, 0L, null, null, null, null, null,null);
return createPayBefore(user, amount, null, null, 0L, 0L, null, null, null, null, null,null, null,null);
}
/**
@ -252,7 +255,7 @@ public class PayBeforeUtil {
*/
public String createPayBefore(Users user, BigDecimal amount, String orderId, Long oid,
Long serviceId, Long orderType) {
return createPayBefore(user, amount, orderId, oid, serviceId, orderType, null, null, null, null, null,null);
return createPayBefore(user, amount, orderId, oid, serviceId, orderType, null, null, null, null, null,null, null, null);
}
/**
@ -335,4 +338,78 @@ public class PayBeforeUtil {
return false;
}
}
/**
* 报价预支付数据处理
* @param user 用户实体
* @param orderLog 订单日志实体
* @param baojiajson 报价json字符串
*/
public void handleQuotationPayBefore(Users user, OrderLog orderLog, String baojiajson,String lastorderid) {
if (user == null || orderLog == null || baojiajson == null || baojiajson.trim().isEmpty()) {
return;
}
try {
com.alibaba.fastjson2.JSONObject json = com.alibaba.fastjson2.JSONObject.parseObject(baojiajson);
// 处理定金
JSONObject deposit = json.getJSONObject("deposit");
if (deposit != null) {
String depositPriceStr = deposit.getString("price");
BigDecimal depositPrice = null;
try {
depositPrice = new BigDecimal(depositPriceStr);
} catch (Exception ignore) {}
if (depositPrice != null && depositPrice.compareTo(BigDecimal.ZERO) > 0) {
// 添加定金预支付信息
this.createPayBefore(
user,
depositPrice,
orderLog.getDepLogId(), // orderid
orderLog.getId(), // oid
null, // serviceId
8L, // type=8 定金
null, null, null, null, null, 1L, null, lastorderid
);
}
}
// 处理尾款
JSONObject project = json.getJSONObject("project");
if (project != null) {
String projectPriceStr = project.getString("price");
BigDecimal projectPrice = null;
try {
projectPrice = new BigDecimal(projectPriceStr);
} catch (Exception ignore) {}
if (projectPrice != null && projectPrice.compareTo(BigDecimal.ZERO) > 0) {
// 判断优惠金额
JSONObject reduction = json.getJSONObject("reduction");
BigDecimal reductionPrice = BigDecimal.ZERO;
if (reduction != null) {
String reductionPriceStr = reduction.getString("price");
try {
reductionPrice = new BigDecimal(reductionPriceStr);
} catch (Exception ignore) {}
}
BigDecimal finalTail = projectPrice;
if (reductionPrice != null && reductionPrice.compareTo(BigDecimal.ZERO) > 0) {
finalTail = projectPrice.subtract(reductionPrice);
}
if (finalTail.compareTo(BigDecimal.ZERO) > 0) {
// 添加尾款预支付信息
this.createPayBefore(
user,
finalTail,
orderLog.getLogOrderId(), // orderid
orderLog.getId(), // oid
null, // serviceId
9L, // type=9 尾款
null, null, null, null, null, 1L, null, lastorderid
);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.system.ControllerUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import com.ruoyi.system.ControllerUtil.WechatPayV3Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Map;
@Component
public class RefundUtil {
private static IUsersService usersService = SpringUtils.getBean(IUsersService.class);
private static WechatPayV3Util wechatPayV3Util = SpringUtils.getBean(WechatPayV3Util.class);
private static IGoodsOrderService goodsOrderService = SpringUtils.getBean(IGoodsOrderService.class);
private static IUserDemandQuotationService userDemandQuotationService = SpringUtils.getBean(IUserDemandQuotationService.class);
private static IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
private static IUserMemnerConsumptionLogService userMemnerConsumptionLogService = SpringUtils.getBean(IUserMemnerConsumptionLogService.class);
private static IUserGroupBuyingService userGroupBuyingService = SpringUtils.getBean(IUserGroupBuyingService.class);
// 退款方法
public boolean refundOrder(String orderid) {
// 查询预支付记录
UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderid);
if (payBefor == null) {
return false;
}
boolean refundSuccess = false;
// paytype=4微信退款金额为allmoney
if (payBefor.getPaytype() != null && payBefor.getPaytype() == 4) {
if (payBefor.getAllmoney() != null && payBefor.getAllmoney().compareTo(BigDecimal.ZERO) > 0) {
Map<String, Object> refundSuccessdata = wechatPayV3Util.refund(payBefor.getOrderid(), payBefor.getPaycode(), payBefor.getAllmoney().intValue(), payBefor.getAllmoney().intValue(), "退款", "");
refundSuccess = true; // 可根据refundSuccessdata内容判断
}
} else {
boolean wxRefunded = false;
boolean yeRefunded = false;
if (payBefor.getWxmoney() != null && payBefor.getWxmoney().compareTo(BigDecimal.ZERO) > 0) {
Map<String, Object> refundSuccessdata = wechatPayV3Util.refund(
payBefor.getOrderid(),
payBefor.getPaycode(),
payBefor.getWxmoney().intValue(),
payBefor.getWxmoney().intValue(),
"退款",
""
);
wxRefunded = true; // 可根据refundSuccessdata内容判断
}
if (payBefor.getYemoney() != null && payBefor.getYemoney().compareTo(BigDecimal.ZERO) > 0) {
yeRefunded = refundBalance(payBefor);
}
refundSuccess = wxRefunded || yeRefunded; // 或者 wxRefunded && yeRefunded
}
// 退款成功后修改状态为3
if (refundSuccess) {
payBefor.setStatus(3L);
usersPayBeforService.updateUsersPayBefor(payBefor);
}
return refundSuccess;
}
// 余额退款逻辑及流水记录
private boolean refundBalance(UsersPayBefor payBefor) {
if (payBefor.getUid() == null || payBefor.getYemoney() == null || payBefor.getYemoney().compareTo(BigDecimal.ZERO) <= 0) {
return false;
}
Users user = usersService.selectUsersById(payBefor.getUid());
if (user == null) return false;
BigDecimal before = user.getBalance();
user.setBalance(user.getBalance().add(payBefor.getYemoney()));
int update = usersService.updateUsers(user);
if (update <= 0) return false;
// 写入退款流水
UserMemnerConsumptionLog log = new UserMemnerConsumptionLog();
log.setUid(Math.toIntExact(user.getId()));
log.setConsumptiontype(4); // 4=余额退款
log.setConsumptiontime(new java.util.Date());
log.setConsumptionmoney(payBefor.getYemoney());
log.setReamk("余额退款,订单号:" + payBefor.getOrderid());
log.setBeformoney(before);
log.setAftermoney(user.getBalance());
log.setNowmoney(user.getBalance());
log.setType(1); // 1=收入
userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(log);
UserGroupBuying groupBuying = userGroupBuyingService.selectUserGroupBuyingByptorderid(payBefor.getOrderid());
if (groupBuying != null) {
groupBuying.setStatus(3L);
userGroupBuyingService.updateUserGroupBuying(groupBuying);
}
// 可选推送退款消息
// WXsendMsgUtil.sendUserPayMoney(user.getOpenid(), "余额退款成功", payBefor.getYemoney().toString(), "1", "余额退款成功");
return true;
}
}

View File

@ -81,7 +81,7 @@ public class WechatPayUtil {
private static final String WECHAT_TRANSFER_URL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; // 企业付款
public static final String PAY_FH = "https://c5ed8e7.r3.cpolar.top/";
public static final String PAY_FH = "https://4a8ed13a.r3.cpolar.top/";
/**
* 其他配置常量
*/

View File

@ -177,7 +177,7 @@ public class WechatPayV3Util {
// 根据微信支付V3文档对于转账接口可以暂时不设置Wechatpay-Serial头
String wechatpaySerial = getWechatpayPlatformSerial();
if (wechatpaySerial != null && !wechatpaySerial.trim().isEmpty() &&
!wechatpaySerial.equals(wechatConfig().getSerialNo())) {
!wechatpaySerial.equals(wechatConfig().getSerialNo())) {
// 只有当平台证书序列号与商户证书序列号不同时才设置
headers.set("Wechatpay-Serial", wechatpaySerial);
log.info(" ├─ 已添加微信支付平台证书序列号: {}", maskSensitiveData(wechatpaySerial));
@ -837,8 +837,8 @@ public class WechatPayV3Util {
if (value instanceof JSONObject) {
JSONObject encryptedField = (JSONObject) value;
if (encryptedField.containsKey("algorithm") &&
encryptedField.containsKey("ciphertext") &&
encryptedField.containsKey("nonce")) {
encryptedField.containsKey("ciphertext") &&
encryptedField.containsKey("nonce")) {
// 这是一个加密字段进行解密
log.info("🔍 发现加密字段: {}", key);

View File

@ -2,6 +2,8 @@ package com.ruoyi.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -200,6 +202,16 @@ public class Order extends BaseEntity
/** 订单附件 */
@Excel(name = "订单附件")
private String fileData;
private String ispay;
private Long baojiasf;
private Long baojiayh;
private List<String> ids;
/** 录音文件 */
@Excel(name = "订单类别 1预约 2报价 3一口价 4拼团 5普通订单")
private int odertype;
@ -255,6 +267,25 @@ public class Order extends BaseEntity
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Date deletedAt;
private Long makeTimeStart;
private Long makeTimeEnd;
public Long getMakeTimeStart() { return makeTimeStart; }
public void setMakeTimeStart(Long makeTimeStart) { this.makeTimeStart = makeTimeStart; }
public Long getMakeTimeEnd() { return makeTimeEnd; }
public void setMakeTimeEnd(Long makeTimeEnd) { this.makeTimeEnd = makeTimeEnd; }
private String dayDate;
public String getDayDate() { return dayDate; }
public void setDayDate(String dayDate) { this.dayDate = dayDate; }
private Date receiveTimeStart;
private Date receiveTimeEnd;
public Date getReceiveTimeStart() { return receiveTimeStart; }
public void setReceiveTimeStart(Date receiveTimeStart) { this.receiveTimeStart = receiveTimeStart; }
public Date getReceiveTimeEnd() { return receiveTimeEnd; }
public void setReceiveTimeEnd(Date receiveTimeEnd) { this.receiveTimeEnd = receiveTimeEnd; }
public void setId(Long id)
{
this.id = id;
@ -887,6 +918,41 @@ public class Order extends BaseEntity
this.bigtype = bigtype;
}
public Long getBaojiasf() {
return baojiasf;
}
public void setBaojiasf(Long baojiasf) {
this.baojiasf = baojiasf;
}
public Long getBaojiayh() {
return baojiayh;
}
public void setBaojiayh(Long baojiayh) {
this.baojiayh = baojiayh;
}
public List<String> getIds() {
return ids;
}
public void setIds(List<String> ids) {
this.ids = ids;
}
public String getIspay() {
return ispay;
}
public void setIspay(String ispay) {
this.ispay = ispay;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -81,6 +81,14 @@ public class OrderLog extends BaseEntity
@Excel(name = "工人id")
private Long workerId;
/** 工人id */
@Excel(name = "补差价金额")
private BigDecimal cjMoney;
/** 工人id */
@Excel(name = "补差价状态")
private Long cjPaid;
/** 工人id */
@Excel(name = "工人id")
@ -408,6 +416,23 @@ public class OrderLog extends BaseEntity
this.workerName = workerName;
}
public BigDecimal getCjMoney() {
return cjMoney;
}
public void setCjMoney(BigDecimal cjMoney) {
this.cjMoney = cjMoney;
}
public Long getCjPaid() {
return cjPaid;
}
public void setCjPaid(Long cjPaid) {
this.cjPaid = cjPaid;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -0,0 +1,18 @@
package com.ruoyi.system.domain;
public class OrderTypeCount {
private int bigtype;
private int count;
public OrderTypeCount() {}
public OrderTypeCount(int bigtype, int count) {
this.bigtype = bigtype;
this.count = count;
}
public int getBigtype() { return bigtype; }
public void setBigtype(int bigtype) { this.bigtype = bigtype; }
public int getCount() { return count; }
public void setCount(int count) { this.count = count; }
}

View File

@ -66,6 +66,14 @@ public class QuoteMaterial extends BaseEntity
@Excel(name = "附件图片")
private String image;
@Excel(name = "附件图片")
private String manyimages;
@Excel(name = "附件图片")
private String content;
@Excel(name = "是否有分佣 1:有 2:无 (默认有分佣)")
private Integer iscommissions;
@ -249,6 +257,23 @@ public class QuoteMaterial extends BaseEntity
this.image = image;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getManyimages() {
return manyimages;
}
public void setManyimages(String manyimages) {
this.manyimages = manyimages;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -40,6 +40,10 @@ public class UserDemandQuotation extends BaseEntity
/** 状态 1报价 2被选中 */
private Long status;
/** 状态 1报价 2被选中 */
private Long oid;
/** 师傅图像 */
@Excel(name = "师傅图像")
private String workerimage;
@ -155,6 +159,15 @@ public class UserDemandQuotation extends BaseEntity
return updatedAt;
}
public Long getOid() {
return oid;
}
public void setOid(Long oid) {
this.oid = oid;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -3,6 +3,7 @@ package com.ruoyi.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -182,11 +183,38 @@ public class Users extends BaseEntity
private BigDecimal commissionMin;
private BigDecimal commissionMax;
private String remember_token;
private String workerTimeStr;
private Map<String, Object> order_num;
private Map<String, Object> goods_order_num;
private List<String> areaList;
private String skill;
// 个人中心接口扩展字段
private Object levelInfo;
private String levelImg;
private String prohibit;
private List<String> skillArr;
private List<Object> serviceCityArr;
public Object getLevelInfo() { return levelInfo; }
public void setLevelInfo(Object levelInfo) { this.levelInfo = levelInfo; }
public String getLevelImg() { return levelImg; }
public void setLevelImg(String levelImg) { this.levelImg = levelImg; }
public String getProhibit() { return prohibit; }
public void setProhibit(String prohibit) { this.prohibit = prohibit; }
public List<String> getSkillArr() { return skillArr; }
public void setSkillArr(List<String> skillArr) { this.skillArr = skillArr; }
public List<Object> getServiceCityArr() { return serviceCityArr; }
public void setServiceCityArr(List<Object> serviceCityArr) { this.serviceCityArr = serviceCityArr; }
public String getWorkerTimeStr() {
return workerTimeStr;
}
public void setWorkerTimeStr(String workerTimeStr) {
this.workerTimeStr = workerTimeStr;
}
public void setId(Long id)
{
@ -625,6 +653,11 @@ public class Users extends BaseEntity
this.birthday = birthday;
}
public List<String> getAreaList() { return areaList; }
public void setAreaList(List<String> areaList) { this.areaList = areaList; }
public String getSkill() { return skill; }
public void setSkill(String skill) { this.skill = skill; }
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -66,6 +66,13 @@ public class UsersPayBefor extends BaseEntity
@Excel(name = "美团号")
private String mtcode;
/** 美团号 */
@Excel(name = "")
private String lastorderid;
/** 美团抵扣金额 */
@Excel(name = "美团抵扣金额")
private BigDecimal mtmoney;
@ -98,6 +105,8 @@ public class UsersPayBefor extends BaseEntity
private Long servicetype;
private Long baojiaid;
private String sku;
private Long addressid;
private String maketime;
@ -355,6 +364,23 @@ public class UsersPayBefor extends BaseEntity
this.servicetype = servicetype;
}
public Long getBaojiaid() {
return baojiaid;
}
public void setBaojiaid(Long baojiaid) {
this.baojiaid = baojiaid;
}
public String getLastorderid() {
return lastorderid;
}
public void setLastorderid(String lastorderid) {
this.lastorderid = lastorderid;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -29,6 +29,14 @@ public interface GoodsOrderMapper
public int selectAllCountGoodsOrderByUid(Long uid);
/**
* 统计指定用户和状态的商品订单数量
* @param uid 用户id
* @param status 订单状态
* @return 订单数量
*/
Integer countGoodsOrderByUidAndStatus(@Param("uid") Long uid, @Param("status") Integer status);
/**
* 查询商品订单列表

View File

@ -64,4 +64,22 @@ public interface OrderCommentMapper
* @return 结果
*/
public int deleteOrderCommentByIds(Long[] ids);
/**
* 根据oid列表和type分页查询评价
* @param oids 订单id列表
* @param type 评价类型可为null
* @param offset 分页起始
* @param limit 分页大小
* @return 评价列表
*/
List<OrderComment> selectOrderCommentListByOidsAndType(List<Long> oids, Long type, int offset, int limit);
/**
* 根据oid列表和type统计数量
* @param oids 订单id列表
* @param type 评价类型
* @return 数量
*/
int countByOidsAndType(List<Long> oids, Long type);
}

View File

@ -70,4 +70,11 @@ public interface OrderLogMapper
* @return 结果
*/
public int deleteOrderLogByIds(Long[] ids);
/**
* 根据师傅ID查询所有服务订单oid
* @param workerId 师傅ID
* @return oid列表
*/
List<Long> selectOidListByWorkerId(Long workerId);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.ruoyi.system.domain.AppleDoMain.OrderApple;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.domain.OrderTypeCount;
import org.apache.ibatis.annotations.Param;
/**
@ -76,4 +77,12 @@ public interface OrderMapper
* @return 结果
*/
public int deleteOrderByIds(Long[] ids);
/**
* 统计指定用户和类型的订单数量
* @param uid 用户id
* @param type 订单类型
* @return 订单数量
*/
Integer selectOrderCountByBigtype(@Param("uid") Long uid, @Param("type") Integer type);
}

View File

@ -63,4 +63,11 @@ public interface UsersPayBeforMapper
* @return 结果
*/
public int deleteUsersPayBeforByIds(Long[] ids);
/**
* 统计lastorderid=orderid且status=status的数量
* @param orderid 订单id
* @return 数量
*/
public Integer countByLastOrderIdAndStatus(String orderid);
}

View File

@ -33,6 +33,14 @@ public interface IGoodsOrderService
public int selectAllCountGoodsOrderByUid(Long uid);
/**
* 统计指定用户和状态的商品订单数量
* @param uid 用户id
* @param status 订单状态
* @return 订单数量
*/
Integer countGoodsOrderByUidAndStatus(Long uid, Integer status);
/**
* 新增商品订单

View File

@ -59,4 +59,22 @@ public interface IOrderCommentService
* @return 结果
*/
public int deleteOrderCommentById(Long id);
/**
* 根据oid列表和type分页查询评价
* @param oids 订单id列表
* @param type 评价类型可为null
* @param offset 分页起始
* @param limit 分页大小
* @return 评价列表
*/
List<OrderComment> selectOrderCommentListByOidsAndType(List<Long> oids, Long type, int offset, int limit);
/**
* 根据oid列表和type统计数量
* @param oids 订单id列表
* @param type 评价类型
* @return 数量
*/
int countByOidsAndType(List<Long> oids, Long type);
}

View File

@ -85,4 +85,11 @@ public interface IOrderLogService
* @return 结果
*/
public int deleteOrderLogById(Long id);
/**
* 根据师傅ID查询所有服务订单oid
* @param workerId 师傅ID
* @return oid列表
*/
List<Long> selectOidListByWorkerId(Long workerId);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.ruoyi.system.domain.AppleDoMain.OrderApple;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.domain.OrderTypeCount;
/**
* 服务订单Service接口
@ -74,4 +75,12 @@ public interface IOrderService
* @return 结果
*/
public int deleteOrderById(Long id);
/**
* 统计指定用户和类型的订单数量
* @param uid 用户id
* @param type 订单类型
* @return 订单数量
*/
Integer selectOrderCountByBigtype(Long uid, Integer type);
}

View File

@ -62,4 +62,12 @@ public interface IUsersPayBeforService
* @return 结果
*/
public int deleteUsersPayBeforById(Long id);
/**
* 统计lastorderid=orderid且status=status的数量
* @param orderid 订单id
* @return 数量
*/
public Integer countByLastOrderIdAndStatus(String orderid);
}

View File

@ -46,6 +46,11 @@ public class GoodsOrderServiceImpl implements IGoodsOrderService
return goodsOrderMapper.selectAllCountGoodsOrderByUid(uid);
}
@Override
public Integer countGoodsOrderByUidAndStatus(Long uid, Integer status) {
return goodsOrderMapper.countGoodsOrderByUidAndStatus(uid, status);
}
/**
* 查询商品订单列表
*

View File

@ -51,6 +51,16 @@ public class OrderCommentServiceImpl implements IOrderCommentService
return orderCommentMapper.selectOrderCommentList(orderComment);
}
@Override
public List<OrderComment> selectOrderCommentListByOidsAndType(List<Long> oids, Long type, int offset, int limit) {
return orderCommentMapper.selectOrderCommentListByOidsAndType(oids, type, offset, limit);
}
@Override
public int countByOidsAndType(List<Long> oids, Long type) {
return orderCommentMapper.countByOidsAndType(oids, type);
}
/**
* 新增订单评价
*

View File

@ -1,6 +1,8 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.ControllerUtil.GenerateCustomCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OrderLogMapper;
@ -89,6 +91,7 @@ public class OrderLogServiceImpl implements IOrderLogService
@Override
public int insertOrderLog(OrderLog orderLog)
{
return orderLogMapper.insertOrderLog(orderLog);
}
@ -127,4 +130,14 @@ public class OrderLogServiceImpl implements IOrderLogService
{
return orderLogMapper.deleteOrderLogById(id);
}
/**
* 根据师傅ID查询所有服务订单oid
* @param workerId 师傅ID
* @return oid列表
*/
@Override
public List<Long> selectOidListByWorkerId(Long workerId) {
return orderLogMapper.selectOidListByWorkerId(workerId);
}
}

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OrderMapper;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.service.IOrderService;
import com.ruoyi.system.domain.OrderTypeCount;
/**
* 服务订单Service业务层处理
@ -69,6 +70,10 @@ public class OrderServiceImpl implements IOrderService
return orderMapper.selectOrderList(order);
}
@Override
public Integer selectOrderCountByBigtype(Long uid, Integer type) {
return orderMapper.selectOrderCountByBigtype(uid, type);
}
/**
* 新增服务订单
*

View File

@ -95,4 +95,9 @@ public class UsersPayBeforServiceImpl implements IUsersPayBeforService
{
return usersPayBeforMapper.deleteUsersPayBeforById(id);
}
@Override
public Integer countByLastOrderIdAndStatus(String orderid) {
return usersPayBeforMapper.countByLastOrderIdAndStatus(orderid);
}
}

View File

@ -88,6 +88,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(1) from goods_order where uid = #{uid}
</select>
<select id="countGoodsOrderByUidAndStatus" resultType="Integer">
select count(1) from goods_order where uid = #{uid} and status = #{status}
</select>
<insert id="insertGoodsOrder" parameterType="GoodsOrder" useGeneratedKeys="true" keyProperty="id">

View File

@ -121,4 +121,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="selectOrderCommentListByOidsAndType" resultMap="OrderCommentResult">
select * from order_comment
<where>
<if test="oids != null and oids.size > 0">
and oid in
<foreach collection="oids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="type != null">
and num_type = #{type}
</if>
</where>
order by id desc
limit #{offset}, #{limit}
</select>
<select id="countByOidsAndType" resultType="int">
select count(1) from order_comment
<where>
<if test="oids != null and oids.size > 0">
and oid in
<foreach collection="oids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="type != null">
and num_type = #{type}
</if>
</where>
</select>
</mapper>

View File

@ -17,6 +17,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="depPayTime" column="dep_pay_time" />
<result property="depLogId" column="dep_log_id" />
<result property="price" column="price" />
<result property="cjMoney" column="cj_money" />
<result property="cjPaid" column="cj_paid" />
<result property="paid" column="paid" />
<result property="payTime" column="pay_time" />
<result property="logId" column="log_id" />
@ -35,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectOrderLogVo">
select id, oid, order_id, log_order_id, title, type, content, deposit, dep_paid, dep_pay_time, dep_log_id, price, paid, pay_time, log_id, worker_id, first_worker_id, give_up, worker_cost, reduction_price, is_pause, coupon_id, deduction, worker_log_id, created_at, updated_at, deleted_at from order_log
select id, oid, order_id, log_order_id,cj_money,cj_paid, title, type, content, deposit, dep_paid, dep_pay_time, dep_log_id, price, paid, pay_time, log_id, worker_id, first_worker_id, give_up, worker_cost, reduction_price, is_pause, coupon_id, deduction, worker_log_id, created_at, updated_at, deleted_at from order_log
</sql>
<select id="selectOrderLogList" parameterType="OrderLog" resultMap="OrderLogResult">
@ -104,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDataTheFirstNew" parameterType="Long" resultMap="OrderLogResult">
<include refid="selectOrderLogVo"/>
where oid = #{oid}
ORDER BY updated_at DESC LIMIT 1;
ORDER BY id DESC LIMIT 1;
</select>
@ -112,6 +116,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from order_log where order_id = #{orderId} order by id DESC
</select>
<select id="selectOidListByWorkerId" parameterType="java.lang.Long" resultType="java.lang.Long">
select DISTINCT oid from order_log where worker_id = #{workerId}
</select>
<insert id="insertOrderLog" parameterType="OrderLog" useGeneratedKeys="true" keyProperty="id">
insert into order_log
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -139,6 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deduction != null">deduction,</if>
<if test="workerLogId != null">worker_log_id,</if>
<if test="deletedAt != null">deleted_at,</if>
<if test="cjMoney != null">cj_money,</if>
<if test="cjPaid != null">cj_paid,</if>
created_at,
updated_at
@ -168,6 +178,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deduction != null">#{deduction},</if>
<if test="workerLogId != null">#{workerLogId},</if>
<if test="deletedAt != null">#{deletedAt},</if>
<if test="cjMoney != null">#{cjMoney},</if>
<if test="cjPaid != null">#{cjPaid},</if>
NOW(),
NOW()
@ -201,6 +213,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deduction != null">deduction = #{deduction},</if>
<if test="workerLogId != null">worker_log_id = #{workerLogId},</if>
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
<if test="cjMoney != null">cj_money = #{cjMoney},</if>
<if test="cjPaid != null">cj_paid = #{cjPaid},</if>
updated_at = NOW()
</trim>

View File

@ -182,6 +182,23 @@
<if test="bigtype != null and bigtype != null">
and bigtype = #{bigtype}
</if>
<if test="makeTimeStart != null and makeTimeEnd != null">
and make_time &gt;= #{makeTimeStart} and make_time &lt; #{makeTimeEnd}
</if>
<if test="dayDate != null and dayDate != ''">
AND FROM_UNIXTIME(make_time, '%Y-%m-%d') = #{dayDate}
</if>
<if test="baojiasf != null and baojiasf != null">
and id in (select oid from user_demand_quotation b where b.workerid=#{baojiasf} and b.status=1)
</if>
<if test="baojiayh != null and baojiayh != null">
and id in ( select b.oid from user_demand_quotation b where b.status=1)
</if>
<if test="isComment != null and isComment != ''">
and is_comment =#{isComment}
</if>
<if test="orderId != null and orderId != ''">
and order_id like concat('%', #{orderId}, '%')
@ -195,7 +212,14 @@
<if test="uid != null">
and uid = #{uid}
</if>
<if test="status != null">
<!-- 新增优先用ids in (...)否则用status= -->
<if test="ids != null and ids.size > 0">
and status in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="(ids == null or ids.size == 0) and status != null">
and status = #{status}
</if>
@ -208,6 +232,15 @@
<if test="cartid != null">
and cartid = #{cartid}
</if>
<!-- 新增ispay逻辑存在users_pay_befor表status=1的lastorderid则排除 -->
<!-- <if test="ispay != null and ispay != ''">-->
<!-- AND (SELECT COUNT(1) FROM users_pay_befor upb WHERE upb.lastorderid = order_id AND upb.STATUS = 1)=0-->
<!-- -->
<!-- </if>-->
<if test="receiveTimeStart != null and receiveTimeEnd != null">
and receive_time BETWEEN #{receiveTimeStart} AND #{receiveTimeEnd}
</if>
</where>
order by id desc
@ -220,7 +253,7 @@
<select id="selectCountOrderByUid" resultType="Integer">
select count(1) from order_data where uid = #{uid} and status=#{status}
select count(1) from order_data where uid = #{uid} and status !=4
</select>
<select id="selectAllCountOrderByUid" resultType="Integer">
@ -233,6 +266,14 @@
where order_id = #{orderId}
</select>
<select id="selectOrderCountByBigtype" resultType="Integer" parameterType="map">
select count(1)
from order_data
where bigtype = #{type}
and status != 4
and uid = #{uid}
</select>
<insert id="insertOrder" parameterType="Order" useGeneratedKeys="true" keyProperty="id">
insert into order_data
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -12,6 +12,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="price" column="price" />
<result property="unit" column="unit" />
<result property="image" column="image" />
<result property="manyimages" column="manyimages" />
<result property="content" column="content" />
<result property="iscommissions" column="iscommissions" />
<result property="commissions" column="commissions" />
<result property="profit" column="profit" />
@ -19,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updatedAt" column="updated_at" />
</resultMap>
<sql id="selectQuoteMaterialVo">
select id, good_id, type_id, title, price, unit,profit,commissions,iscommissions,image, created_at, updated_at from quote_material
select id, good_id, type_id, title, price, unit,manyimages,content,profit,commissions,iscommissions,image, created_at, updated_at from quote_material
</sql>
<select id="selectQuoteMaterialList" parameterType="QuoteMaterial" resultMap="QuoteMaterialResult">
<include refid="selectQuoteMaterialVo"/>
@ -58,6 +60,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="title != null and title != ''">title,</if>
<if test="price != null">price,</if>
<if test="unit != null and unit != ''">unit,</if>
<if test="manyimages != null and manyimages != ''">manyimages,</if>
<if test="content != null and content != ''">content,</if>
<if test="image != null and image != ''">image,</if>
<if test="iscommissions != null and iscommissions != ''">iscommissions,</if>
<if test="commissions != null and commissions != ''">commissions,</if>
@ -71,6 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="title != null and title != ''">#{title},</if>
<if test="price != null">#{price},</if>
<if test="unit != null and unit != ''">#{unit},</if>
<if test="manyimages != null and manyimages != ''">#{manyimages},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="image != null and image != ''">#{image},</if>
<if test="iscommissions != null and iscommissions != ''">#{iscommissions},</if>
<if test="commissions != null and commissions != ''">#{commissions},</if>
@ -88,6 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="title != null and title != ''">title = #{title},</if>
<if test="price != null">price = #{price},</if>
<if test="unit != null and unit != ''">unit = #{unit},</if>
<if test="manyimages != null and manyimages != ''">manyimages = #{manyimages},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="image != null and image != ''">image = #{image},</if>
<if test="iscommissions != null and iscommissions != ''">iscommissions = #{iscommissions},</if>
<if test="commissions != null and commissions != ''">commissions = #{commissions},</if>

View File

@ -11,6 +11,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="workerid" column="workerid" />
<result property="workername" column="workername" />
<result property="status" column="status" />
<result property="oid" column="oid" />
<result property="workerimage" column="workerimage" />
<result property="quotationTime" column="quotation_time" />
<result property="createdAt" column="created_at" />
@ -28,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="workerid != null "> and workerid = #{workerid}</if>
<if test="workername != null and workername != ''"> and workername like concat('%', #{workername}, '%')</if>
<if test="status != null "> and status = #{status}</if>
<if test="oid != null "> and oid = #{oid}</if>
<if test="workerimage != null and workerimage != ''"> and workerimage = #{workerimage}</if>
<if test="quotationTime != null "> and quotation_time = #{quotationTime}</if>
</where>
@ -49,6 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if>
<if test="workerimage != null">workerimage,</if>
<if test="quotationTime != null">quotation_time,</if>
<if test="oid != null">oid,</if>
created_at,
updated_at
</trim>
@ -61,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="workerimage != null">#{workerimage},</if>
<if test="quotationTime != null">#{quotationTime},</if>
<if test="oid != null">#{oid},</if>
NOW(),
NOW()
</trim>
@ -76,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if>
<if test="workerimage != null">workerimage = #{workerimage},</if>
<if test="quotationTime != null">quotation_time = #{quotationTime},</if>
<if test="oid != null">oid = #{oid},</if>
updated_at = NOW(),
</trim>
where id = #{id}

View File

@ -49,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectUserGroupBuyingByptorderid" parameterType="String" resultMap="UserGroupBuyingResult">
<include refid="selectUserGroupBuyingVo"/>
where ptorderid = #{ptorderid}
where ptorderid = #{ptorderid} limit 1
</select>
<insert id="insertUserGroupBuying" parameterType="UserGroupBuying">

View File

@ -191,6 +191,28 @@
<if test="updatedAt != null">
and updated_at = #{updatedAt}
</if>
<if test="areaList != null and areaList.size > 0">
and (
<foreach collection="areaList" item="area" separator=" or ">
service_city_ids like concat('%"', #{area}, '"%')
</foreach>
)
</if>
<if test="skill != null and skill != ''">
and skill_ids like concat('%"', #{skill}, '"%')
</if>
<if test="workerTimeStr != null and workerTimeStr != ''">
and DATE_FORMAT(worker_time, '%Y-%m-%d') = #{workerTimeStr}
</if>
<if test="skillArr != null and skillArr.size > 0">
and (
<foreach collection="skillArr" item="sid" separator=" OR ">
JSON_CONTAINS(skill_ids, CONCAT('"', #{sid}, '"'), '$')
OR FIND_IN_SET(#{sid}, REPLACE(REPLACE(REPLACE(skill_ids, '[', ''), ']', ''), '"', ''))
OR skill_ids = #{sid}
</foreach>
)
</if>
</where>
order by id desc
</select>

View File

@ -19,6 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="mtmoney" column="mtmoney" />
<result property="allmoney" column="allmoney" />
<result property="servicetype" column="servicetype" />
<result property="baojiaid" column="baojiaid" />
<result property="lastorderid" column="lastorderid" />
<result property="sku" column="sku" />
<result property="addressid" column="addressid" />
@ -37,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUsersPayBeforVo">
select id, uid, paytype,grouporderid, wxmoney,serviceid,servicetype,sku,addressid,maketime,attachments, yemoney, allmoney,membermoney, shopmoney, servicemoney, couponid, couponmoney, mtcode, mtmoney, type, orderid, oid, status, paytime, paycode from users_pay_befor
select id, uid, paytype,grouporderid,baojiaid, lastorderid,wxmoney,serviceid,servicetype,sku,addressid,maketime,attachments, yemoney, allmoney,membermoney, shopmoney, servicemoney, couponid, couponmoney, mtcode, mtmoney, type, orderid, oid, status, paytime, paycode from users_pay_befor
</sql>
<select id="selectUsersPayBeforList" parameterType="UsersPayBefor" resultMap="UsersPayBeforResult">
@ -55,6 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mtcode != null and mtcode != ''"> and mtcode = #{mtcode}</if>
<if test="mtmoney != null "> and mtmoney = #{mtmoney}</if>
<if test="type != null "> and type = #{type}</if>
<if test="lastorderid != null "> and lastorderid = #{lastorderid}</if>
<if test="orderid != null and orderid != ''"> and orderid = #{orderid}</if>
<if test="oid != null "> and oid = #{oid}</if>
<if test="status != null "> and status = #{status}</if>
@ -77,6 +81,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where orderid = #{orderid} limit 1
</select>
<select id="countByLastOrderIdAndStatus" parameterType="String" resultType="Integer">
select count(1) from users_pay_befor where lastorderid = #{orderid} and status = 1
</select>
<insert id="insertUsersPayBefor" parameterType="UsersPayBefor" useGeneratedKeys="true" keyProperty="id">
insert into users_pay_befor
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -106,6 +114,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="grouporderid != null">grouporderid,</if>
<if test="serviceid != null">serviceid,</if>
<if test="servicetype != null">servicetype,</if>
<if test="baojiaid != null">baojiaid,</if>
<if test="lastorderid != null">lastorderid,</if>
@ -137,6 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="grouporderid != null">#{grouporderid},</if>
<if test="serviceid != null">#{serviceid},</if>
<if test="servicetype != null">#{servicetype},</if>
<if test="baojiaid != null">#{baojiaid},</if>
<if test="lastorderid != null">#{lastorderid},</if>
</trim>
</insert>
@ -163,6 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="paycode != null">paycode = #{paycode},</if>
<if test="allmoney != null">allmoney = #{allmoney},</if>
<if test="serviceid != null">serviceid = #{serviceid},</if>
<if test="baojiaid != null">baojiaid = #{baojiaid},</if>
<if test="sku != null">sku = #{sku},</if>
<if test="addressid != null">addressid = #{addressid},</if>
@ -170,6 +183,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attachments != null">attachments = #{attachments},</if>
<if test="grouporderid != null">grouporderid = #{grouporderid},</if>
<if test="servicetype != null">servicetype = #{servicetype},</if>
<if test="lastorderid != null">lastorderid = #{lastorderid},</if>
</trim>
where id = #{id}

View File

@ -64,7 +64,7 @@ export default {
//
limit: {
type: Number,
default: 5
default: 9
},
// (MB)
fileSize: {

View File

@ -525,6 +525,7 @@ export default {
}
// skuType
this.skuType = 1;
this.form.skuType = 1;
//
this.activeTab = 'base';
this.resetForm("form");
@ -571,6 +572,8 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.skuType = 1; //
this.form.skuType = 1;
this.open = true
this.title = "添加服务内容"
},
@ -580,6 +583,20 @@ export default {
const id = row.id || this.ids
getServiceGoods(id).then(response => {
this.form = response.data
// icon
if (Array.isArray(this.form.icon)) {
this.form.icon = this.form.icon.length > 0 ? this.form.icon[0] : '';
}
// imgs
if (typeof this.form.imgs === 'string' && this.form.imgs) {
if (this.form.imgs.includes(',')) {
this.form.imgs = this.form.imgs.split(',').filter(Boolean);
} else {
this.form.imgs = [this.form.imgs];
}
} else if (!Array.isArray(this.form.imgs)) {
this.form.imgs = [];
}
//
if (this.form.questions) {
@ -629,6 +646,14 @@ export default {
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
// icon
if (Array.isArray(this.form.icon)) {
this.form.icon = this.form.icon.length > 0 ? this.form.icon[0] : '';
}
// imgs
if (Array.isArray(this.form.imgs)) {
this.form.imgs = this.form.imgs.filter(Boolean).join(',');
}
//
if (this.form.questionsArray && Array.isArray(this.form.questionsArray)) {
const validQuestions = this.form.questionsArray.filter(qa =>
@ -642,9 +667,6 @@ export default {
this.form.questions = null;
}
//
this.form.skuType = this.skuType;
//
if (this.skuType === 2) {
//
@ -660,16 +682,9 @@ export default {
return;
}
} else {
//
if (!this.form.skuName || !this.form.skuValue) {
this.$modal.msgError("请完善单规格信息");
return;
}
const singleSku = {
name: this.form.skuName,
value: this.form.skuValue
};
this.form.sku = JSON.stringify(singleSku);
// {"type":"single"}
this.form.sku = JSON.stringify({ type: "single" });
this.form.skuType = 1;
}
// sku
@ -735,234 +750,65 @@ export default {
handleExport() {
this.download('system/ServiceGoods/export', {
...this.queryParams
}, `ServiceGoods_${new Date().getTime()}.xlsx`)
},
playAudio(url) {
this.currentAudioUrl = url
this.audioDialogVisible = true
},
openEditDialog(row, field, label) {
this.editRow = row;
this.editField = field;
this.editFieldLabel = label;
this.editFieldValue = row[field];
this.editDialogVisible = true;
},
async saveEditField() {
if (!this.editRow) return;
//
let value = this.editFieldValue;
if (['price', 'margin'].includes(this.editField)) {
//
const numValue = parseFloat(value);
if (isNaN(numValue) || numValue < 0) {
this.$message.error('请输入有效的价格');
return;
}
value = numValue;
} else if (['sales', 'stock', 'sort'].includes(this.editField)) {
//
const numValue = parseInt(value);
if (isNaN(numValue) || numValue < 0) {
this.$message.error('请输入有效的数字');
return;
}
value = numValue;
}
const payload = {
id: this.editRow.id,
[this.editField]: value
};
try {
await updateServiceGoods(payload);
this.$message.success('修改成功');
//
this.editRow[this.editField] = value;
this.getList();
//
this.editDialogVisible = false;
} catch (error) {
console.error('快捷编辑失败:', error);
this.$message.error('修改失败,请稍后重试');
}
},
addSpec() {
this.specList.push({ name: '', values: [''] });
this.updateSkuTable();
},
removeSpec(idx) {
this.specList.splice(idx, 1);
this.updateSkuTable();
},
addSpecValue(specIdx) {
this.specList[specIdx].values.push('');
this.updateSkuTable();
},
removeSpecValue(specIdx, valIdx) {
this.specList[specIdx].values.splice(valIdx, 1);
this.updateSkuTable();
},
updateSkuTable() {
if (this.specList.length === 0) {
this.skuTable = [];
return;
}
const valueArr = this.specList.map(spec => spec.values.filter(v => v));
if (valueArr.some(arr => arr.length === 0)) {
this.skuTable = [];
return;
}
const cartesian = (arr) => arr.reduce((a, b) => a.flatMap(d => b.map(e => [].concat(d, e))));
const combos = cartesian(valueArr);
this.skuTable = combos.map(combo => {
const row = {};
this.specList.forEach((spec, i) => row[spec.name] = combo[i]);
return Object.assign(row, { imageUrl: '', price: 0, stock: 0 });
});
},
handleImageSuccess(idx, file) {
// url
this.$set(this.skuTable[idx], 'imageUrl', URL.createObjectURL(file.raw));
},
removeSkuImage(idx) {
this.$set(this.skuTable[idx], 'imageUrl', '');
},
//
addQuestion() {
if (!this.form.questionsArray) {
this.$set(this.form, 'questionsArray', []);
}
this.form.questionsArray.push({
question: '',
answer: ''
});
},
//
removeQuestion(index) {
this.form.questionsArray.splice(index, 1);
//
this.handleQuestionChange();
},
//
async silentSave() {
try {
//
if (!this.form.questionsArray || !Array.isArray(this.form.questionsArray)) {
return;
}
//
if (!this.form.id) {
return;
}
//
const validQuestions = this.form.questionsArray.filter(qa =>
qa && qa.question && qa.question.trim() && qa.answer && qa.answer.trim()
).map(qa => ({
question: qa.question.trim(),
answer: qa.answer.trim()
}));
//
const submitData = {
id: this.form.id,
questions: JSON.stringify(validQuestions)
};
//
await updateServiceGoods(submitData);
} catch (error) {
console.error('问答数据静默保存失败:', error);
}
},
//
//
handleQuestionChange() {
// 使
if (this.saveTimeout) {
clearTimeout(this.saveTimeout);
}
this.saveTimeout = setTimeout(() => {
this.silentSave();
}, 1000); // 1
//
this.$nextTick(() => {
this.$refs.form.validateField('questionsArray');
});
},
getForServiceList (cb) {
getselectTypeList(1).then(res => {
this.forServiceList = res.data || [];
if (typeof cb === 'function') cb();
})
//
openEditDialog(row, field, label) {
//
this.editRow = JSON.parse(JSON.stringify(row));
this.editField = field;
this.editFieldLabel = label;
this.editFieldValue = row[field];
this.editDialogVisible = true;
},
//
saveEditField() {
//
this.editRow[this.editField] = this.editFieldValue;
//
updateServiceGoods(this.editRow).then(response => {
this.$modal.msgSuccess("保存成功");
this.editDialogVisible = false;
this.getList(); //
}).catch(error => {
this.$modal.msgError("保存失败,请稍后重试");
});
},
//
cancelEdit() {
this.editDialogVisible = false;
},
//
getForServiceList(callback) {
getselectTypeList(1).then(response => {
this.forServiceList = response.data;
if (callback) {
callback();
}
});
},
// getForServiceList() {
// // type=1
// listServiceGoods({ type: 1, status: 1 }).then(res => {
// this.forServiceList = res.rows || [];
// });
// },
}
}
</script>
<style scoped>
/* 问答样式 */
.qa-container {
padding: 5px;
}
.qa-header {
margin-bottom: 15px;
}
.qa-item {
margin-bottom: 10px;
padding: 10px;
border: 1px solid #EBEEF5;
border-radius: 4px;
background-color: #fafafa;
}
.qa-item:hover {
box-shadow: 0 2px 8px 0 rgba(0,0,0,.05);
}
.qa-item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.qa-index {
font-size: 14px;
font-weight: bold;
color: #606266;
}
.qa-item :deep(.el-form-item) {
margin-bottom: 10px;
}
.qa-item :deep(.el-form-item__label) {
padding: 0 5px 0 0;
line-height: 32px;
}
.qa-item :deep(.el-form-item__content) {
line-height: 32px;
}
.qa-item :deep(.el-textarea__inner) {
padding: 5px 8px;
}
.qa-item :deep(.el-divider--horizontal) {
margin: 10px 0;
}
/* 你的样式代码 */
</style>

View File

@ -124,6 +124,16 @@
<image-preview :src="scope.row.image" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="轮播图" align="center" prop="manyimages" width="120">
<template slot-scope="scope">
<image-preview v-for="img in (scope.row.manyimages ? scope.row.manyimages.split(',') : [])" :key="img" :src="img" :width="40" :height="40" style="margin-right:2px;" />
</template>
</el-table-column>
<el-table-column label="简介" align="center" prop="content" width="200">
<template slot-scope="scope">
<div v-html="scope.row.content"></div>
</template>
</el-table-column>
<el-table-column label="是否有分佣" align="center" prop="iscommissions">
<template slot-scope="scope">
<dict-tag :options="dict.type.iscommissions" :value="scope.row.iscommissions"/>
@ -161,68 +171,75 @@
/>
<!-- 添加或修改项目报价--物料信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="服务项目" prop="goodsintids">
<el-select v-model="form.goodsintids" multiple filterable placeholder="请选择服务项目" style="width: 100%">
<el-option
v-for="type in typeDataList"
:key="type.id"
:label="type.title"
:value="type.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="类型" prop="typeintids">
<el-select v-model="form.typeintids" multiple filterable placeholder="请选择类型" style="width: 100%">
<el-option
v-for="type in materialTypeList"
:key="type.id"
:label="type.title"
:value="type.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="价格" prop="price">
<div style="position: relative;">
<el-input v-model="form.price" placeholder="请输入价格" />
<span style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #E6A23C; font-weight: bold; pointer-events: none;">¥</span>
</div>
</el-form-item>
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入单位" />
</el-form-item>
<el-form-item label="附件图片" prop="image">
<image-upload v-model="form.image"/>
</el-form-item>
<el-form-item label="是否有分佣" prop="iscommissions">
<el-radio-group v-model="form.iscommissions" >
<el-radio
v-for="dict in dict.type.iscommissions"
:key="dict.value"
:label="parseInt(dict.value)"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="form.iscommissions == 1">
<el-form-item label="分佣比例" prop="commissions">
<el-input-number v-model="form.commissions" placeholder="请输入分佣比例" />
<span style="margin-left: 8px; color: #888; font-size: 12px;">系统默认分佣比例为 {{ material_commissions }}%</span>
<el-drawer :title="title" :visible.sync="open" size="600px" direction="rtl" :with-header="true" append-to-body>
<div style="padding: 0 20px;">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="服务项目" prop="goodsintids">
<el-select v-model="form.goodsintids" multiple filterable placeholder="请选择服务项目" style="width: 100%">
<el-option
v-for="type in typeDataList"
:key="type.id"
:label="type.title"
:value="type.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="净利润" prop="profit">
<el-input-number v-model="form.profit" placeholder="请输入净利润" />
<el-form-item label="类型" prop="typeintids">
<el-select v-model="form.typeintids" multiple filterable placeholder="请选择类型" style="width: 100%">
<el-option
v-for="type in materialTypeList"
:key="type.id"
:label="type.title"
:value="type.id"
></el-option>
</el-select>
</el-form-item>
</template>
</el-form>
<div class="dialog-footer" style="text-align:left;margin-top:20px;">
<el-button @click="reset">重置</el-button>
<el-button type="primary" @click="submitForm">提交</el-button>
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="价格" prop="price">
<div style="position: relative;">
<el-input v-model="form.price" placeholder="请输入价格" />
<span style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #E6A23C; font-weight: bold; pointer-events: none;">¥</span>
</div>
</el-form-item>
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入单位" />
</el-form-item>
<el-form-item label="附件图片" prop="image">
<image-upload v-model="form.image"/>
</el-form-item>
<el-form-item label="轮播图" prop="manyimages">
<image-upload v-model="form.manyimages" multiple />
</el-form-item>
<el-form-item label="简介" prop="content">
<editor v-model="form.content" :height="200" />
</el-form-item>
<el-form-item label="是否有分佣" prop="iscommissions">
<el-radio-group v-model="form.iscommissions" >
<el-radio
v-for="dict in dict.type.iscommissions"
:key="dict.value"
:label="parseInt(dict.value)"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="form.iscommissions == 1">
<el-form-item label="分佣比例" prop="commissions">
<el-input-number v-model="form.commissions" placeholder="请输入分佣比例" />
<span style="margin-left: 8px; color: #888; font-size: 12px;">系统默认分佣比例为 {{ material_commissions }}%</span>
</el-form-item>
<el-form-item label="净利润" prop="profit">
<el-input-number v-model="form.profit" placeholder="请输入净利润" />
</el-form-item>
</template>
</el-form>
<div class="dialog-footer" style="text-align:left;margin-top:20px;">
<el-button @click="reset">重置</el-button>
<el-button type="primary" @click="submitForm">提交</el-button>
</div>
</div>
</el-dialog>
</el-drawer>
</div>
</template>
@ -286,6 +303,8 @@ export default {
iscommissions: null,
commissions: null,
profit: null,
manyimages: [],
content: '',
createdAt: null,
updatedAt: null
},
@ -344,6 +363,8 @@ export default {
iscommissions: null,
commissions: null,
profit: null,
manyimages: [],
content: '',
createdAt: null,
updatedAt: null
}
@ -418,7 +439,9 @@ export default {
this.form = {
...response.data,
goodsintids: response.data.goodsintids || [],
typeintids: response.data.typeintids || []
typeintids: response.data.typeintids || [],
manyimages: Array.isArray(response.data.manyimages) ? response.data.manyimages : (typeof response.data.manyimages === 'string' && response.data.manyimages ? response.data.manyimages.split(',') : []),
content: response.data.content || ''
}
// material_commissions
if (this.form.commissions === null || this.form.commissions === undefined || this.form.commissions === '') {
@ -436,6 +459,10 @@ export default {
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
// JSON
if (Array.isArray(this.form.manyimages)) {
this.form.manyimages = JSON.stringify(this.form.manyimages.filter(Boolean));
}
if (this.form.id != null) {
updateQuoteMaterial(this.form).then(response => {
this.$modal.msgSuccess("修改成功")

View File

@ -522,7 +522,7 @@
</el-radio-group>
</el-form-item>
<el-form-item label="指定工人集合" prop="workerids" v-if="form.dispatchtype === 3">
<el-select v-model="form.workerids" multiple filterable placeholder="请选择工人" style="width: 100%">
<el-select v-model="form.workerids" filterable placeholder="请选择工人" style="width: 100%">
<el-option
v-for="worker in listworkerlist"
:key="worker.id"
@ -920,7 +920,7 @@ export default {
status: "1",
description: null,
skuType: 1,
sku: "{}",
sku: JSON.stringify({ type: "single" }),
skuName: '',
skuValue: '',
latitude: null,
@ -1023,32 +1023,25 @@ export default {
handleAdd() {
this.reset()
this.getlistworkerdatalist();
//
this.$set(this.form, 'skillIdsArray', []);
this.$set(this.form, 'basicArray', []);
//
this.basicOptions = [];
//
this.showBasicInput = false;
this.newBasicTag = '';
// workerids
this.form.workerids = [];
//
// workerids null
this.form.workerids = null;
this.$set(this.form, 'questionsArray', []);
// ID
this.$set(this.form, 'firstCateId', null);
this.$set(this.form, 'secondCateId', null);
console.log('新增时初始化form:', this.form);
//
if (this.siteSkillList.length === 0) {
console.warn('技能列表未加载,重新获取...');
this.getSiteSkillList();
}
this.open = true
this.title = "添加服务内容"
this.handleServiceTypeChange(this.form.servicetype);
this.form.skuType = 1;
this.skuType = 1;
this.form.sku = JSON.stringify({ type: "single" });
},
getSiteSkillList(){
@ -1094,11 +1087,9 @@ export default {
this.reset()
const id = row.id || this.ids
this.getlistworkerdatalist();
//
const skillPromise = this.siteSkillList.length > 0 ?
Promise.resolve(this.siteSkillList) :
this.getSiteSkillList();
Promise.all([
getServiceGoods(id),
skillPromise
@ -1278,21 +1269,39 @@ export default {
}
});
// workerids
// workerids
if (this.form.workerids && typeof this.form.workerids === 'string') {
try {
const arr = JSON.parse(this.form.workerids);
this.form.workerids = Array.isArray(arr) ? arr.map(id => Number(id)).filter(id => !isNaN(id)) : [];
} catch (e) {
this.form.workerids = [];
//
if (!isNaN(this.form.workerids)) {
this.form.workerids = Number(this.form.workerids);
} else {
this.form.workerids = null;
}
} else if (Array.isArray(this.form.workerids) && this.form.workerids.length > 0) {
//
this.form.workerids = Number(this.form.workerids[0]);
} else if (!this.form.workerids) {
this.form.workerids = [];
this.form.workerids = null;
}
this.open = true
this.title = "修改服务内容"
this.handleServiceTypeChange(this.form.servicetype);
// icon
if (Array.isArray(this.form.icon)) {
this.form.icon = this.form.icon.length > 0 ? this.form.icon[0] : '';
}
// imgs
if (typeof this.form.imgs === 'string' && this.form.imgs) {
if (this.form.imgs.includes(',')) {
this.form.imgs = this.form.imgs.split(',').filter(Boolean);
} else {
this.form.imgs = [this.form.imgs];
}
} else if (!Array.isArray(this.form.imgs)) {
this.form.imgs = [];
}
}).catch(error => {
console.error('编辑数据加载失败:', error);
this.$message.error('编辑数据加载失败,请重试');
@ -1382,12 +1391,22 @@ export default {
this.form.sort = parseInt(this.form.sort);
}
// icon
if (Array.isArray(this.form.icon)) {
this.form.icon = this.form.icon.length > 0 ? this.form.icon[0] : '';
}
// imgs
if (Array.isArray(this.form.imgs)) {
this.form.imgs = this.form.imgs.filter(Boolean).join(',');
}
// this.form
const submitData = { ...this.form };
// workerids
if (Array.isArray(submitData.workerids)) {
const arr = submitData.workerids.map(id => Number(id)).filter(id => !isNaN(id));
submitData.workerids = JSON.stringify(arr);
// workerids
if (this.form.workerids !== null && this.form.workerids !== undefined) {
submitData.workerids = JSON.stringify([Number(this.form.workerids)]);
} else {
submitData.workerids = null;
}
// ID

View File

@ -560,6 +560,17 @@
<el-button type="success" @click="saveSiteLinks" style="margin-left: 12px;">保存</el-button>
</el-form>
</el-tab-pane>
<el-tab-pane label="上门标准" name="serviceStandard">
<el-form :model="serviceStandardForm" label-width="120px" class="tab-form">
<el-form-item label="上门标准说明">
<Editor v-model="serviceStandardForm.serviceStandard" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveAllConfig('serviceStandard')">提交</el-button>
<el-button @click="resetServiceStandard">重置</el-button>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
<el-button type="primary" style="margin-top: 24px;" @click="saveAllConfig">保存全部配置</el-button>
</div>
@ -660,6 +671,10 @@ export default {
config_eight: {},
config_nine: {}, //
siteLinks: [], //
config_ten: {}, //
serviceStandardForm: {
serviceStandard: ''
},
}
},
@ -812,6 +827,21 @@ export default {
this.siteLinks = [];
}
// config_ten
this.config_ten = response.rows.find(item => item.name === 'config_ten')
if (this.config_ten && this.config_ten.value) {
try {
const configTenObj = JSON.parse(this.config_ten.value)
this.serviceStandardForm = {
serviceStandard: configTenObj.serviceStandard || ''
}
} catch (e) {
this.serviceStandardForm = { serviceStandard: '' }
}
} else {
this.serviceStandardForm = { serviceStandard: '' }
}
this.total = response.total
this.loading = false
})
@ -891,6 +921,9 @@ export default {
goods: ['商品质量好', '包装完整', '物流快速', '性价比高', '描述相符']
}
},
resetServiceStandard() {
this.serviceStandardForm = { serviceStandard: '' }
},
async saveAllConfig(e) {
// 1. config_one
const config_one = {
@ -1019,9 +1052,29 @@ export default {
} catch (error) {
this.$message.error('保存失败,请重试');
}
}else if(e=='serviceStandard'){
const config_ten = {
serviceStandard: this.serviceStandardForm.serviceStandard
};
try {
if (!this.config_ten || !this.config_ten.id) {
await addSiteConfig({ name: 'config_ten', value: JSON.stringify(config_ten), status: 1 });
} else {
await updateSiteConfig({ name: 'config_ten', id: this.config_ten.id, value: JSON.stringify(config_ten) });
}
this.$message.success('上门标准已保存!');
await this.getList();
} catch (error) {
this.$message.error('保存失败,请重试');
}
return; //
}
//
if (!e) {
this.$message.success('保存成功!');
await this.getList();
}
this.$message.success('保存成功!');
await this.getList();
} catch (error) {
console.error('保存失败:', error);
console.error('错误详情:', error.response || error.message || error);