202507231802

This commit is contained in:
张潘 2025-07-23 18:02:28 +08:00
parent ad786a8b0d
commit 02a4d1438b
28 changed files with 3961 additions and 476 deletions

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;
@ -86,6 +87,12 @@ public class AppleMemberController extends BaseController {
@Autowired
private IUserBenefitPointsService userBenefitPointsService;
@Autowired
private IGoodsOrderService goodsOrderService;
@Autowired
private WechatPayUtil wechatPayUtil;
@ -581,11 +588,12 @@ 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);
Order order = orderService.selectOrderById(Long.valueOf(orderId));
if (order == null) {
return AppletControllerUtil.appletWarning("订单不存在");
}
@ -609,7 +617,7 @@ public class AppleMemberController extends BaseController {
// 7. 构建评价数据
OrderComment comment = new OrderComment();
comment.setOid(order.getId());
comment.setOrderId(orderId);
comment.setOrderId(order.getOrderId());
comment.setProductId(order.getProductId());
comment.setContent(content);
comment.setNum(Long.valueOf(num));
@ -617,41 +625,54 @@ public class AppleMemberController extends BaseController {
comment.setUid(user.getId());
comment.setWorkerId(order.getWorkerId());
//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);
if (type.equals("service")){
// 添加订单日志
OrderLog orderLog = new OrderLog();
orderLog.setOid(order.getId());
orderLog.setOrderId(orderId);
orderLog.setTitle("订单评价");
orderLog.setType(BigDecimal.valueOf(8)); // 8=评价类型
// 添加订单日志
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));
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);
orderLogService.insertOrderLog(orderLog);
// 更新订单状态
order.setStatus(4L); // 4=完成状态
order.setIsComment(1); // 1=已评价
orderService.updateOrder(order);
// 更新订单状态
order.setStatus(4L); // 4=完成状态
order.setIsComment(1); // 1=已评价
orderService.updateOrder(order);
}
if (type.equals("goods")){{
GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderByorderId(orderId);
if (goodsOrder != null){
// goodsOrder.setis
}
}
}
return AjaxResult.success("评价提交成功");
@ -786,7 +807,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 +820,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 +828,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("报价成功");

View File

@ -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

@ -4894,4 +4894,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

@ -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

@ -24,6 +24,7 @@ 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 OrderLogHandler orderLogHandler = SpringUtils.getBean(OrderLogHandler.class);
@ -585,50 +586,192 @@ 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){
System.out.println("=== 处理拼团商品订单 ===");
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();
}
// 7上门费 8定金 9尾款 10差价
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());
}
// 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);
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) {
// 更新订单状态为待服务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);
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 == 1) {
System.out.println("=== 处理拼团订单 ===");
String ptorderid= payBefor.getOrderid();
System.out.println("拼团订单ID: " + ptorderid);
//第一步创建订单状态为待成团
Order order = new Order();
order.setOdertype(1); // 拼团
@ -638,23 +781,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 +820,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 +850,102 @@ 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(2L);
List<UserGroupBuying> userGroupBuyingList = userGroupBuyingService.selectUserGroupBuyingList(userGroupBuyingData);
System.out.println("已支付的拼团人数: " + (userGroupBuyingList != null ? userGroupBuyingList.size() : 0));
if (userGroupBuyingList.size() >= serviceGoods.getGroupnum()) {
System.out.println("拼团人数已满足要求,开始更新所有拼团订单状态");
for (UserGroupBuying groupBuying1 : userGroupBuyingList){
groupBuying1.setStatus(1L);
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());
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("拼团成功,所有订单状态已更新");
} else {
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 +954,24 @@ 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("更新订单状态为待派单");
order.setStatus(1L); // 1=待预约
orderService.updateOrder(order);
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 +1029,88 @@ public class OrderUtil {
}
return false;
}
public static int ISTOPAYSIZE(String orderid) {
IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
IOrderService orderService = SpringUtils.getBean(IOrderService.class);
UsersPayBefor payBefore = new UsersPayBefor();
payBefore.setLastorderid(orderid);
payBefore.setStatus(1L);
List<UsersPayBefor> payBeforeList = usersPayBeforService.selectUsersPayBeforList(payBefore);
Order order = orderService.selectOrderByOrderId(orderid);
if (order != null) {
if (order.getStatus() == 6){
if (payBeforeList.isEmpty()){
order.setStatus(4L);
orderService.updateOrder(order);
}
}
}
return payBeforeList.size();
}
/**
* 派单效验方法
* @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;
}
}

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) {
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, orderLog.getOrderId()
);
}
}
// 处理尾款
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, orderLog.getOrderId()
);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

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,13 @@ public class Order extends BaseEntity
/** 订单附件 */
@Excel(name = "订单附件")
private String fileData;
private Long baojiasf;
private Long baojiayh;
private List<String> ids;
/** 录音文件 */
@Excel(name = "订单类别 1预约 2报价 3一口价 4拼团 5普通订单")
private int odertype;
@ -255,6 +264,18 @@ 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; }
public void setId(Long id)
{
this.id = id;
@ -887,6 +908,45 @@ 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 static class OrderTypeCount {
private int bigtype;
private int count;
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; }
}
@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

@ -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;
@ -186,6 +187,8 @@ public class Users extends BaseEntity
private Map<String, Object> order_num;
private Map<String, Object> goods_order_num;
private List<String> areaList;
private String skill;
public void setId(Long id)
@ -625,6 +628,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

@ -76,4 +76,11 @@ public interface OrderMapper
* @return 结果
*/
public int deleteOrderByIds(Long[] ids);
/**
* 统计bigtype为123且status!=4的订单数量按bigtype分组指定用户
* @param uid 用户id
* @return 统计结果
*/
List<Order.OrderTypeCount> selectOrderCountByBigtype(Long uid);
}

View File

@ -74,4 +74,11 @@ public interface IOrderService
* @return 结果
*/
public int deleteOrderById(Long id);
/**
* 统计bigtype为123且status!=4的订单数量按bigtype分组指定用户
* @param uid 用户id
* @return 统计结果
*/
List<Order.OrderTypeCount> selectOrderCountByBigtype(Long uid);
}

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);
}

View File

@ -69,6 +69,10 @@ public class OrderServiceImpl implements IOrderService
return orderMapper.selectOrderList(order);
}
@Override
public List<Order.OrderTypeCount> selectOrderCountByBigtype(Long uid) {
return orderMapper.selectOrderCountByBigtype(uid);
}
/**
* 新增服务订单
*

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">
@ -139,6 +143,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 +174,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 +209,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>
@ -220,7 +244,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 +257,15 @@
where order_id = #{orderId}
</select>
<select id="selectOrderCountByBigtype" resultType="com.ruoyi.system.domain.Order.OrderTypeCount" parameterType="map">
select bigtype, count(1) as count
from order_data
where bigtype in (1,2,3)
and status != 4
and uid = #{uid}
group by bigtype
</select>
<insert id="insertOrder" parameterType="Order" useGeneratedKeys="true" keyProperty="id">
insert into order_data
<trim prefix="(" suffix=")" suffixOverrides=",">

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" />
@ -23,11 +26,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectUserDemandQuotationList" parameterType="UserDemandQuotation" resultMap="UserDemandQuotationResult">
<include refid="selectUserDemandQuotationVo"/>
<where>
<where>
<if test="orderid != null and orderid != ''"> and orderid = #{orderid}</if>
<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,16 @@
<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>
</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>
@ -106,6 +110,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 +143,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 +171,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 +179,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

@ -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"
@ -1023,29 +1023,19 @@ 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);
@ -1094,11 +1084,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,16 +1266,19 @@ 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
@ -1384,10 +1375,11 @@ export default {
// 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);