diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java index 1728140..af19c63 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleInvoiceController.java @@ -7,6 +7,7 @@ import com.ruoyi.system.ControllerUtil.AppletControllerUtil; import com.ruoyi.system.ControllerUtil.AppletLoginUtil; import com.ruoyi.system.ControllerUtil.InvoiceUtil; import com.ruoyi.system.domain.Users; +import com.ruoyi.system.domain.UsersInvoiceInfo; import com.ruoyi.system.service.IUsersService; import com.ruoyi.system.service.IUsersInvoiceInfoService; import org.springframework.beans.factory.annotation.Autowired; @@ -458,4 +459,47 @@ public class AppleInvoiceController extends BaseController { return AppletControllerUtil.appletError("删除发票信息失败:" + e.getMessage()); } } + + /** + * 根据发票ID获取发票详情 + * @param id 发票ID + * @param request HTTP请求对象 + * @return 发票详情 + */ + @GetMapping("/detail/{id}") + public Object getInvoiceDetail(@PathVariable("id") Integer id, HttpServletRequest request) { + try { + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletUnauthorized(); + } + UsersInvoiceInfo invoiceInfo = usersInvoiceInfoService.selectUsersInvoiceInfoById(id); + if (invoiceInfo == null) { + return AppletControllerUtil.appletWarning("未找到该发票信息"); + } + // 只返回指定字段 + Map data = new java.util.HashMap<>(); + data.put("id", invoiceInfo.getId()); + data.put("uid", invoiceInfo.getUid()); + data.put("invoiceTitle", invoiceInfo.getInvoiceTitle()); + data.put("taxNumber", invoiceInfo.getTaxNumber()); + data.put("bankName", invoiceInfo.getBankName()); + data.put("bankAccount", invoiceInfo.getBankAccount()); + data.put("address", invoiceInfo.getAddress()); + data.put("phone", invoiceInfo.getPhone()); + data.put("email", invoiceInfo.getEmail()); + data.put("wechat", invoiceInfo.getWechat()); + data.put("type", invoiceInfo.getType()); + data.put("category", invoiceInfo.getCategory()); + data.put("invoicemoney", invoiceInfo.getInvoicemoney()); + data.put("invoicetext", invoiceInfo.getInvoicetext()); + data.put("orderid", invoiceInfo.getOrderid()); + data.put("status", invoiceInfo.getStatus()); + data.put("filedata", invoiceInfo.getFiledata()); + return AppletControllerUtil.appletSuccess(data); + } catch (Exception e) { + return AppletControllerUtil.appletError("获取发票详情失败:" + e.getMessage()); + } + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java index 6c9590b..113288a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleMemberController.java @@ -726,61 +726,7 @@ public class AppleMemberController extends BaseController { } } - /** - * 获取次卡列表(支持分页) - * - * 查询用户次卡列表,支持按类型筛选和分页 - * 每个次卡会包含对应的服务商品详情 - * - * @param params 查询参数(page, limit, type) - * @param request HTTP请求对象 - * @return 次卡列表(分页格式) - */ - @PostMapping("/secondary/card/list") - public AjaxResult getSecondaryCardList(@RequestBody Map params, HttpServletRequest request) { - try { - // 1. 获取并验证分页参数 - int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; - int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 15; - Map pageValidation = PageUtil.validatePageParams(page, limit); - if (!(Boolean) pageValidation.get("valid")) { - return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); - } - - // 2. 获取type参数 - Long type = params.get("type") != null ? Long.parseLong(params.get("type").toString()) : null; - - // 3. 创建查询对象 - UserSecondaryCard queryParams = new UserSecondaryCard(); - queryParams.setStatus(1L); // 只查询状态为1的数据 - if (type != null) { - queryParams.setType(type); - } - - // 4. 设置分页参数 - PageHelper.startPage(page, limit); - - // 5. 执行查询 - List list = userSecondaryCardService.selectUserSecondaryCardList(queryParams); - - // 6. 为每个次卡填充服务商品详情 - for (UserSecondaryCard card : list) { - List idsList = com.alibaba.fastjson2.JSONArray.parseArray(card.getGoodsids(), String.class); - card.setServiceDetail(serviceGoodsService.selectServiceGoodsfrocikaList(idsList)); - } - - // 7. 获取分页信息并构建响应 - TableDataInfo tableDataInfo = getDataTable(list); - Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); - - return AppletControllerUtil.appletSuccess(pageData); - - } catch (Exception e) { - System.err.println("查询次卡列表异常:" + e.getMessage()); - return AppletControllerUtil.appletError("获取次卡列表失败:" + e.getMessage()); - } - } // ==================== 师傅报价相关接口 ==================== diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java new file mode 100644 index 0000000..f67287f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java @@ -0,0 +1,655 @@ +package com.ruoyi.system.controller; + +import com.alibaba.fastjson2.JSONObject; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.ControllerUtil.AppletControllerUtil; +import com.ruoyi.system.ControllerUtil.AppletLoginUtil; +import com.ruoyi.system.ControllerUtil.GenerateCustomCode; +import com.ruoyi.system.domain.*; +import com.ruoyi.system.service.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 苹果订单控制器 + * + * @author ruoyi + * @date 2025-01-26 + */ +@RestController +public class AppleOrderController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(AppleOrderController.class); + + @Autowired + private IUsersService usersService; + + @Autowired + private IServiceGoodsService serviceGoodsService; + + @Autowired + private IUserAddressService userAddressService; + + @Autowired + private ICouponUserService couponUserService; + + @Autowired + private IOrderService orderService; + + + + @Autowired + private IUserGroupBuyingService userGroupBuyingService; + + @Autowired + private IUsersPayBeforService usersPayBeforService; + + @Autowired + private IOrderLogService orderLogService; + + @Autowired + private IUserUseSecondaryCardService userUseSecondaryCardService; + + /** + * 通用订单预支接口 + * + * 创建订单但不执行支付,将订单状态设置为未支付,并在预支付表中记录支付信息 + * + * @param params 预支付参数 + * @param request HTTP请求对象 + * @return 预支付结果 + * + * 请求参数说明: + * - id: 产品或次卡主键ID(必填) + * - sku: 购买的规格(可选) + * - ordertype: 订单类别 1=拼团 2=次卡 3=秒杀 4=报价 0=普通预约(必填) + * - address_id: 地址ID(可选) + * - num: 购买数量(可选,默认1) + * - make_time: 预约时间(可选,格式:yyyy-MM-dd HH:mm) + * - attachments: 附件数组(可选,最多9个附件) + */ + @PostMapping("/api/universal/order/presupport") + @Log(title = "订单预支", businessType = BusinessType.INSERT) + public AjaxResult universalOrderPresupport(@RequestBody Map params, HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletWarning("用户未登录或token无效"); + } + + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletWarning("用户信息获取失败"); + } + + // 2. 验证必填参数 + if (params == null || params.isEmpty()) { + return AppletControllerUtil.appletWarning("参数不能为空"); + } + + if (params.get("id") == null) { + return AppletControllerUtil.appletWarning("产品ID不能为空"); + } + + if (params.get("ordertype") == null) { + return AppletControllerUtil.appletWarning("订单类别不能为空"); + } + + // 3. 解析参数 + Long productId = Long.valueOf(params.get("id").toString()); + Integer ordertype = Integer.valueOf(params.get("ordertype").toString()); + String sku = params.get("sku") != null ? params.get("sku").toString() : ""; + Long addressId = params.get("address_id") != null ? Long.valueOf(params.get("address_id").toString()) : null; + Integer num = params.get("num") != null ? Integer.valueOf(params.get("num").toString()) : 1; + String makeTime = params.get("make_time") != null ? params.get("make_time").toString() : ""; + + // 处理附件数组 + String attachments = ""; + if (params.get("attachments") != null) { + try { + @SuppressWarnings("unchecked") + List attachmentList = (List) params.get("attachments"); + if (attachmentList != null && !attachmentList.isEmpty()) { + // 限制最多9个附件 + if (attachmentList.size() > 9) { + return AppletControllerUtil.appletWarning("附件数量不能超过9个"); + } + attachments = String.join(",", attachmentList); + } + } catch (Exception e) { + logger.warn("附件参数解析失败: " + e.getMessage()); + attachments = ""; + } + } + + // 4. 验证订单类型 + if (ordertype < 0 || ordertype > 4) { + return AppletControllerUtil.appletWarning("订单类别无效:0=普通预约 1=拼团 2=次卡 3=秒杀 4=报价"); + } + + // 5. 查询商品信息 + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); + if (serviceGoods == null) { + return AppletControllerUtil.appletWarning("商品不存在"); + } + + // 6. 查询地址信息(如果提供了地址ID) + UserAddress userAddress = null; + if (addressId != null) { + userAddress = userAddressService.selectUserAddressById(addressId); + if (userAddress == null) { + return AppletControllerUtil.appletWarning("地址不存在"); + } + } + + // 7. 根据订单类型创建相应的订单 + Map orderResult = createOrderByType( + ordertype, user, serviceGoods, userAddress, sku, num, + makeTime, null, BigDecimal.ZERO, BigDecimal.ZERO, "", "", attachments + ); + + if (!(Boolean) orderResult.get("success")) { + return AppletControllerUtil.appletWarning((String) orderResult.get("message")); + } + + // 8. 获取订单信息 + String orderId = (String) orderResult.get("orderId"); + Long oid = (Long) orderResult.get("oid"); + BigDecimal totalAmount = (BigDecimal) orderResult.get("totalAmount"); + + // 如果是报价订单,直接返回结果,不插入UsersPayBefor + if (ordertype == 4) { + Map result = new HashMap<>(); + result.put("orderId", orderId); + result.put("oid", oid); + result.put("totalAmount", totalAmount); + result.put("orderType", ordertype); + result.put("attachments", attachments); + return AppletControllerUtil.appletSuccess(result); + } + + // 9. 创建预支付记录 + UsersPayBefor usersPayBefor = new UsersPayBefor(); + usersPayBefor.setUid(user.getId()); + usersPayBefor.setOrderid(orderId); + usersPayBefor.setOid(oid); + usersPayBefor.setPaycode(GenerateCustomCode.generCreateOrder("PAY")); + usersPayBefor.setAllmoney(totalAmount); + usersPayBefor.setWxmoney(totalAmount); + usersPayBefor.setYemoney(BigDecimal.ZERO); + usersPayBefor.setCouponmoney(BigDecimal.ZERO); + usersPayBefor.setMembermoney(BigDecimal.ZERO); + usersPayBefor.setType(Long.valueOf(ordertype)); + usersPayBefor.setStatus(1L); // 1=待支付 + usersPayBefor.setPaytype(1L); // 默认微信支付 + + int payBeforResult = usersPayBeforService.insertUsersPayBefor(usersPayBefor); + if (payBeforResult <= 0) { + return AppletControllerUtil.appletWarning("预支付记录创建失败"); + } + + // 10. 返回预支付信息 + Map result = new HashMap<>(); + result.put("orderId", orderId); + result.put("oid", oid); + result.put("payBeforId", usersPayBefor.getId()); + result.put("paycode", usersPayBefor.getPaycode()); + result.put("totalAmount", totalAmount); + result.put("wxMoney", totalAmount); + result.put("yeMoney", BigDecimal.ZERO); + result.put("couponMoney", BigDecimal.ZERO); + result.put("memberMoney", BigDecimal.ZERO); + result.put("orderType", ordertype); + result.put("attachments", attachments); + + return AppletControllerUtil.appletSuccess(result); + + } catch (Exception e) { + logger.error("订单预支付创建失败:", e); + return AppletControllerUtil.appletError("订单预支付创建失败:" + e.getMessage()); + } + } + + /** + * 根据订单类型创建相应的订单 + */ + private Map createOrderByType(Integer ordertype, Users user, ServiceGoods serviceGoods, + UserAddress userAddress, String sku, Integer num, String makeTime, + CouponUser couponUser, BigDecimal couponDiscount, + BigDecimal memberMoney, String mtcode, String ptcode, String attachments) { + Map result = new HashMap<>(); + + try { + switch (ordertype) { + case 0: // 普通预约 + return createNormalOrder(user, serviceGoods, userAddress, sku, num, makeTime, couponUser, couponDiscount, memberMoney, mtcode, attachments); + case 1: // 拼团 + return createGroupBuyingOrder(user, serviceGoods, sku, num, couponUser, couponDiscount, memberMoney, mtcode, ptcode, attachments); + case 2: // 次卡 + return createCardOrder(user, serviceGoods, userAddress, sku, num, makeTime, couponUser, couponDiscount, memberMoney, mtcode, attachments); + case 3: // 秒杀 + return createSeckillOrder(user, serviceGoods, userAddress, sku, num, makeTime, couponUser, couponDiscount, memberMoney, mtcode, attachments); + case 4: // 报价 + return createQuoteOrder(user, serviceGoods, userAddress, sku, num, makeTime, couponUser, couponDiscount, memberMoney, mtcode, attachments); + default: + result.put("success", false); + result.put("message", "不支持的订单类型"); + return result; + } + } catch (Exception e) { + logger.error("创建订单失败:", e); + result.put("success", false); + result.put("message", "创建订单失败:" + e.getMessage()); + return result; + } + } + + /** + * 创建普通预约订单 + * 1预约 2报价 3一口价 4拼团 5普通订单 + */ + private Map createNormalOrder(Users user, ServiceGoods serviceGoods, UserAddress userAddress, + String sku, Integer num, String makeTime, CouponUser couponUser, + BigDecimal couponDiscount, BigDecimal memberMoney, String mtcode, String attachments) { + Map result = new HashMap<>(); + + try { + // 计算订单金额 + BigDecimal itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num)); + + // 生成订单号 + String orderId = GenerateCustomCode.generCreateOrder("N"); + + // 创建普通预约订单(统一使用服务订单表) + Order order = new Order(); + order.setNum(Long.valueOf(num)); + order.setType(1); // 普通预约订单 + order.setCreateType(1); // 用户自主下单 + order.setOrderId(orderId); + order.setUid(user.getId()); + order.setUname(user.getName()); + order.setProductId(serviceGoods.getId()); + order.setProductName(serviceGoods.getTitle()); + order.setSku(sku); + + if (userAddress != null) { + order.setAddressId(userAddress.getId()); + order.setName(userAddress.getName()); + order.setPhone(userAddress.getPhone()); + order.setAddress(userAddress.getAddressInfo()); + } + + // 处理预约时间 + if (makeTime != null && !makeTime.isEmpty()) { + String[] makeTimeArr = makeTime.split(" "); + if (makeTimeArr.length == 2) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sdf.parse(makeTimeArr[0]); + order.setMakeTime(date.getTime() / 1000); + order.setMakeHour(makeTimeArr[1]); + } catch (Exception e) { + logger.warn("预约时间格式错误: " + makeTime); + } + } + } + + order.setTotalPrice(itemPrice); + order.setGoodPrice(serviceGoods.getPrice()); + order.setServicePrice(BigDecimal.ZERO); + order.setPayPrice(itemPrice); + order.setStatus(1L); // 待支付 + order.setReceiveType(1L); // 自由抢单 + order.setIsAccept(0); + order.setIsComment(0); + order.setIsPause(1); + order.setDeduction(couponDiscount.add(memberMoney)); + order.setFileData(attachments); // 设置附件数据 + order.setType(1); + int insertResult = orderService.insertOrder(order); + if (insertResult <= 0) { + result.put("success", false); + result.put("message", "普通预约订单创建失败"); + return result; + } + + // 添加订单日志 + OrderLog orderLog = new OrderLog(); + orderLog.setOid(order.getId()); + orderLog.setOrderId(order.getOrderId()); + orderLog.setTitle("订单生成"); + orderLog.setType(BigDecimal.valueOf(1.0)); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("name", "订单创建成功"); + orderLog.setContent(jsonObject.toJSONString()); + orderLog.setRemark("订单预支付创建"); + orderLogService.insertOrderLog(orderLog); + + result.put("success", true); + result.put("orderId", orderId); + result.put("oid", order.getId()); + result.put("totalAmount", itemPrice); + + return result; + + } catch (Exception e) { + logger.error("创建普通预约订单失败:", e); + result.put("success", false); + result.put("message", "创建普通预约订单失败:" + e.getMessage()); + return result; + } + } + + /** + * 创建拼团订单 + */ + private Map createGroupBuyingOrder(Users user, ServiceGoods serviceGoods, String sku, Integer num, + CouponUser couponUser, BigDecimal couponDiscount, + BigDecimal memberMoney, String mtcode, String ptcode, String attachments) { + Map result = new HashMap<>(); + + try { + // 验证拼团价格 + if (serviceGoods.getGroupprice() == null) { + result.put("success", false); + result.put("message", "该商品不支持拼团"); + return result; + } + + // 计算订单金额 + BigDecimal itemPrice = serviceGoods.getGroupprice().multiply(BigDecimal.valueOf(num)); + + // 处理拼团单号 + String finalPtcode = ptcode; + if (finalPtcode == null || finalPtcode.trim().isEmpty()) { + // 如果没有提供拼团单号,生成新的拼团单号 + finalPtcode = GenerateCustomCode.generCreateOrder("PT"); + } + + // 创建拼团订单(预支付状态) + UserGroupBuying userGroupBuying = new UserGroupBuying(); + userGroupBuying.setOrderid(finalPtcode); // 使用拼团单号作为订单号 + userGroupBuying.setUid(user.getId()); + userGroupBuying.setUname(user.getName()); + userGroupBuying.setProductId(serviceGoods.getId()); + userGroupBuying.setMoney(itemPrice); + userGroupBuying.setStatus(1L); // 待支付 + userGroupBuying.setPaystatus(1L); // 待支付 + userGroupBuying.setPaytype(1L); // 默认微信支付 + userGroupBuying.setDeduction(couponDiscount.add(memberMoney)); + + int insertResult = userGroupBuyingService.insertUserGroupBuying(userGroupBuying); + if (insertResult <= 0) { + result.put("success", false); + result.put("message", "拼团订单创建失败"); + return result; + } + + // 预支付接口不需要检查拼团人数,只需要记录预支付信息 + + result.put("success", true); + result.put("orderId", finalPtcode); + result.put("oid", userGroupBuying.getId()); + result.put("totalAmount", itemPrice); + + return result; + + } catch (Exception e) { + logger.error("创建拼团订单失败:", e); + result.put("success", false); + result.put("message", "创建拼团订单失败:" + e.getMessage()); + return result; + } + } + + /** + * 创建次卡订单 + */ + private Map createCardOrder(Users user, ServiceGoods serviceGoods, UserAddress userAddress, + String sku, Integer num, String makeTime, CouponUser couponUser, + BigDecimal couponDiscount, BigDecimal memberMoney, String mtcode, String attachments) { + Map result = new HashMap<>(); + try { + // 计算订单金额 + BigDecimal itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num)); + // 生成订单号 + String orderId = GenerateCustomCode.generCreateOrder("C"); + // 创建次卡使用记录 + UserUseSecondaryCard card = new UserUseSecondaryCard(); + card.setUid(user.getId()); + card.setCarid(String.valueOf(serviceGoods.getId())); // 假设商品ID即为次卡ID + card.setGoodsids(String.valueOf(serviceGoods.getId())); // 如有多个服务ID可调整 + card.setNum(Long.valueOf(num)); + card.setUsenum(0L); + card.setOrderid(orderId); + card.setTransactionId(""); + card.setPaymoney(itemPrice); + card.setStatus(4L); // 1可用 2已用完 3已退款 4未支付 + card.setRemark(attachments); // 附件信息存remark + int insertResult = userUseSecondaryCardService.insertUserUseSecondaryCard(card); + if (insertResult <= 0) { + result.put("success", false); + result.put("message", "次卡订单创建失败"); + return result; + } + result.put("success", true); + result.put("orderId", orderId); + result.put("oid", card.getId()); + result.put("totalAmount", itemPrice); + return result; + } catch (Exception e) { + logger.error("创建次卡订单失败:", e); + result.put("success", false); + result.put("message", "创建次卡订单失败:" + e.getMessage()); + return result; + } + } + + /** + * 创建秒杀订单 + */ + private Map createSeckillOrder(Users user, ServiceGoods serviceGoods, UserAddress userAddress, + String sku, Integer num, String makeTime, CouponUser couponUser, + BigDecimal couponDiscount, BigDecimal memberMoney, String mtcode, String attachments) { + Map result = new HashMap<>(); + + try { + // 验证秒杀价格 + if (serviceGoods.getFixedprice() == null) { + result.put("success", false); + result.put("message", "该商品不支持秒杀"); + return result; + } + + // 计算订单金额 + BigDecimal itemPrice = serviceGoods.getFixedprice().multiply(BigDecimal.valueOf(num)); + + // 生成订单号 + String orderId = GenerateCustomCode.generCreateOrder("S"); + + // 创建秒杀订单(使用服务订单表) + Order order = new Order(); + order.setType(3); // 秒杀类型 + order.setCreateType(1); // 用户自主下单 + order.setOrderId(orderId); + order.setUid(user.getId()); + order.setUname(user.getName()); + order.setProductId(serviceGoods.getId()); + order.setProductName(serviceGoods.getTitle()); + order.setSku(sku); + order.setNum(Long.valueOf(num)); + if (userAddress != null) { + order.setAddressId(userAddress.getId()); + order.setName(userAddress.getName()); + order.setPhone(userAddress.getPhone()); + order.setAddress(userAddress.getAddressInfo()); + } + + // 处理预约时间 + if (makeTime != null && !makeTime.isEmpty()) { + String[] makeTimeArr = makeTime.split(" "); + if (makeTimeArr.length == 2) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sdf.parse(makeTimeArr[0]); + order.setMakeTime(date.getTime() / 1000); + order.setMakeHour(makeTimeArr[1]); + } catch (Exception e) { + logger.warn("预约时间格式错误: " + makeTime); + } + } + } + + order.setTotalPrice(itemPrice); + order.setGoodPrice(serviceGoods.getFixedprice()); + order.setServicePrice(BigDecimal.ZERO); + order.setPayPrice(itemPrice); + order.setStatus(1L); // 待支付 + order.setReceiveType(1L); // 自由抢单 + order.setIsAccept(0); + order.setIsComment(0); + order.setIsPause(1); + order.setDeduction(couponDiscount.add(memberMoney)); + order.setFileData(attachments); // 设置附件数据 + order.setType(1); + int insertResult = orderService.insertOrder(order); + if (insertResult <= 0) { + result.put("success", false); + result.put("message", "秒杀订单创建失败"); + return result; + } + + // 添加订单日志 + OrderLog orderLog = new OrderLog(); + orderLog.setOid(order.getId()); + orderLog.setOrderId(order.getOrderId()); + orderLog.setTitle("秒杀订单生成"); + orderLog.setContent("用户创建秒杀订单"); + orderLog.setRemark("订单预支付创建"); + orderLogService.insertOrderLog(orderLog); + + result.put("success", true); + result.put("orderId", orderId); + result.put("oid", order.getId()); + result.put("totalAmount", itemPrice); + + return result; + + } catch (Exception e) { + logger.error("创建秒杀订单失败:", e); + result.put("success", false); + result.put("message", "创建秒杀订单失败:" + e.getMessage()); + return result; + } + } + + /** + * 创建报价订单 + */ + private Map createQuoteOrder(Users user, ServiceGoods serviceGoods, UserAddress userAddress, + String sku, Integer num, String makeTime, CouponUser couponUser, + BigDecimal couponDiscount, BigDecimal memberMoney, String mtcode, String attachments) { + Map result = new HashMap<>(); + + try { + // 计算订单金额 + BigDecimal itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num)); + + // 生成订单号 + String orderId = GenerateCustomCode.generCreateOrder("Q"); + + // 创建报价订单(使用服务订单表) + Order order = new Order(); + order.setType(4); // 报价订单 + order.setCreateType(1); // 用户自主下单 + order.setOrderId(orderId); + order.setUid(user.getId()); + order.setUname(user.getName()); + order.setProductId(serviceGoods.getId()); + order.setProductName(serviceGoods.getTitle()); + order.setSku(sku); + order.setType(1); + order.setNum(Long.valueOf(num)); + if (userAddress != null) { + order.setAddressId(userAddress.getId()); + order.setName(userAddress.getName()); + order.setPhone(userAddress.getPhone()); + order.setAddress(userAddress.getAddressInfo()); + } + + // 处理预约时间 + if (makeTime != null && !makeTime.isEmpty()) { + String[] makeTimeArr = makeTime.split(" "); + if (makeTimeArr.length == 2) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sdf.parse(makeTimeArr[0]); + order.setMakeTime(date.getTime() / 1000); + order.setMakeHour(makeTimeArr[1]); + } catch (Exception e) { + logger.warn("预约时间格式错误: " + makeTime); + } + } + } + + //order.setNum(num); + order.setTotalPrice(itemPrice); + order.setGoodPrice(serviceGoods.getPrice()); + order.setServicePrice(BigDecimal.ZERO); + order.setPayPrice(itemPrice); + order.setStatus(1L); // 待支付 + order.setReceiveType(1L); // 自由抢单 + order.setIsAccept(0); + order.setIsComment(0); + order.setIsPause(1); + order.setDeduction(couponDiscount.add(memberMoney)); + order.setFileData(attachments); // 设置附件数据 + + int insertResult = orderService.insertOrder(order); + if (insertResult <= 0) { + result.put("success", false); + result.put("message", "报价订单创建失败"); + return result; + } + + // 添加订单日志 + OrderLog orderLog = new OrderLog(); + orderLog.setOid(order.getId()); + orderLog.setOrderId(order.getOrderId()); + orderLog.setTitle("报价订单生成"); + orderLog.setContent("用户创建报价订单"); + orderLog.setRemark("订单预支付创建"); + orderLogService.insertOrderLog(orderLog); + + result.put("success", true); + result.put("orderId", orderId); + result.put("oid", order.getId()); + result.put("totalAmount", itemPrice); + + return result; + + } catch (Exception e) { + logger.error("创建报价订单失败:", e); + result.put("success", false); + result.put("message", "创建报价订单失败:" + e.getMessage()); + return result; + } + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java index 9e58582..1a4dcf1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApplePayController.java @@ -1281,4 +1281,894 @@ public class ApplePayController extends BaseController { } } + + + + /** + * 上门费支付接口 + *

+ * 用于支付服务订单的上门费用 + *

+ * 业务逻辑: + * 1. 验证用户登录状态 + * 2. 根据订单日志ID获取上门费信息 + * 3. 调用微信支付 + * 4. 返回支付参数 + * + * @param params 请求参数,包含id(订单日志ID) + * @param request HTTP请求对象(需要包含token) + * @return 支付结果,包含prepayId等微信支付参数 + */ + @PostMapping("/service/activity/pay") + public AjaxResult activitypay(@RequestBody Map params, HttpServletRequest request) { + try { + // 1. 验证用户登录状态 + String token = request.getHeader("token"); + Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); + if (!(Boolean) userValidation.get("valid")) { + return AppletControllerUtil.appletWarning("用户未登录或token无效"); + } + + // 2. 获取用户信息 + Users user = (Users) userValidation.get("user"); + if (user == null) { + return AppletControllerUtil.appletWarning("用户信息获取失败"); + } + + // 3. 验证必要参数 + if (params == null || params.get("id") == null) { + return AppletControllerUtil.appletWarning("订单参数不能为空"); + } + // 3. 验证必要参数 + if (params.get("type") == null) { + return AppletControllerUtil.appletWarning("付款类型参数不能为空"); + } + Long type = Long.valueOf(params.get("type").toString()); + Long id = Long.valueOf(params.get("id").toString()); + // 1查拼团 2查次卡 3查秒杀 4查报价 + if (type == 1){//拼团 + //没有订单ID,就是创建 + if (params.get("orderid") == null){ + + }else{ + + } + + } + + + + + // 4. 获取订单日志信息 + Long orderId = Long.valueOf(params.get("id").toString()); + OrderLog orderLog = orderLogService.selectOrderLogById(orderId); + + if (orderLog != null) { + logger.info("上门费支付 - 用户ID: {}, 订单日志ID: {}, 上门费: {}", + user.getId(), orderId, orderLog.getPrice()); + + // 5. 调用微信支付(测试环境使用0.01元) + Map payResult = wechatPayUtil.createBatchOrderAndPay( + user.getOpenid(), + String.valueOf(orderLog.getId()), + new BigDecimal("0.01"), // 测试金额 + 1, + WechatPayUtil.PAY_FH + "api/door/fee/pay/notify"); + + if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) { + // 6. 构建支付响应数据 + Map responseData = new HashMap<>(); + responseData.put("mainOrderId", String.valueOf(orderLog.getId())); + responseData.put("totalAmount", orderLog.getPrice()); + 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); + } + } else { + return AppletControllerUtil.appletWarning("订单日志不存在"); + } + + } catch (Exception e) { + logger.error("上门费支付异常 - 用户ID: {}, 参数: {}, 异常: {}", + request.getHeader("token"), params, e.getMessage()); + return AppletControllerUtil.appletError("支付失败:" + e.getMessage()); + } + } + +// /** +// * 通用订单支付接口 +// * +// * 支持多种订单类型和支付方式的统一支付接口 +// * +// * @param params 支付参数 +// * @param request HTTP请求对象 +// * @return 支付结果 +// * +// * 请求参数说明: +// * - id: 产品或次卡主键ID(必填) +// * - sku: 购买的规格(可选) +// * - paytype: 支付类型 1=微信支付 2=余额支付 3=组合支付(必填) +// * - ordertype: 订单类别 1=拼团 2=次卡 3=秒杀 4=报价 0=普通预约(必填) +// * - coupon_id: 优惠券ID(可选) +// * - address_id: 地址ID(可选) +// * - mtcode: 美团核销码(可选) +// * - membermoney: 会员优惠金额(可选) +// * - num: 购买数量(可选,默认1) +// * - make_time: 预约时间(可选,格式:yyyy-MM-dd HH:mm) +// * - wechat_pay_amount: 微信支付金额(组合支付时必填) +// * - balance_pay_amount: 余额支付金额(组合支付时必填) +// */ +// @PostMapping("/api/universal/order/pay") +// public AjaxResult universalOrderPay(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 验证用户登录状态 +// String token = request.getHeader("token"); +// Map userValidation = AppletLoginUtil.validateUserToken(token, usersService); +// if (!(Boolean) userValidation.get("valid")) { +// return AppletControllerUtil.appletWarning("用户未登录或token无效"); +// } +// +// // 2. 获取用户信息 +// Users user = (Users) userValidation.get("user"); +// if (user == null) { +// return AppletControllerUtil.appletWarning("用户信息获取失败"); +// } +// +// // 3. 验证必要参数 +// if (params == null || params.get("id") == null || params.get("paytype") == null || params.get("ordertype") == null) { +// return AppletControllerUtil.appletWarning("必要参数不能为空:id、paytype、ordertype"); +// } +// +// // 4. 解析参数 +// Long productId = Long.valueOf(params.get("id").toString()); +// Integer paytype = Integer.valueOf(params.get("paytype").toString()); +// Integer ordertype = Integer.valueOf(params.get("ordertype").toString()); +// String sku = params.get("sku") != null ? params.get("sku").toString() : ""; +// Long couponId = params.get("coupon_id") != null ? Long.valueOf(params.get("coupon_id").toString()) : null; +// Long addressId = params.get("address_id") != null ? Long.valueOf(params.get("address_id").toString()) : null; +// String mtcode = params.get("mtcode") != null ? params.get("mtcode").toString() : ""; +// BigDecimal memberMoney = params.get("membermoney") != null ? new BigDecimal(params.get("membermoney").toString()) : BigDecimal.ZERO; +// Integer num = params.get("num") != null ? Integer.valueOf(params.get("num").toString()) : 1; +// String makeTime = params.get("make_time") != null ? params.get("make_time").toString() : ""; +// +// // 5. 验证支付类型 +// if (paytype < 1 || paytype > 3) { +// return AppletControllerUtil.appletWarning("支付类型无效:1=微信支付 2=余额支付 3=组合支付"); +// } +// +// // 6. 验证订单类型 +// if (ordertype < 0 || ordertype > 4) { +// return AppletControllerUtil.appletWarning("订单类型无效:0=普通预约 1=拼团 2=次卡 3=秒杀 4=报价"); +// } +// +// // 7. 根据订单类型处理不同的业务逻辑 +// Map orderResult = null; +// switch (ordertype) { +// case 0: // 普通预约 +// orderResult = handleNormalOrder(user, productId, sku, addressId, couponId, memberMoney, num, makeTime, mtcode); +// break; +// case 1: // 拼团 +// orderResult = handleGroupBuyingOrder(user, productId, sku, couponId, memberMoney, num); +// break; +// case 2: // 次卡 +// orderResult = handleCardOrder(user, productId, sku, couponId, memberMoney, num); +// break; +// case 3: // 秒杀 +// orderResult = handleSeckillOrder(user, productId, sku, addressId, couponId, memberMoney, num); +// break; +// case 4: // 报价 +// orderResult = handleQuoteOrder(user, productId, sku, addressId, couponId, memberMoney, num); +// break; +// default: +// return AppletControllerUtil.appletWarning("不支持的订单类型"); +// } +// +// if (orderResult == null || !(Boolean) orderResult.get("success")) { +// String errorMsg = orderResult != null ? (String) orderResult.get("message") : "订单创建失败"; +// return AppletControllerUtil.appletWarning(errorMsg); +// } +// +// // 8. 获取订单信息 +// String orderId = (String) orderResult.get("orderId"); +// BigDecimal totalAmount = (BigDecimal) orderResult.get("totalAmount"); +// String orderDescription = (String) orderResult.get("description"); +// +// // 9. 根据支付类型处理支付 +// Map paymentResult = null; +// switch (paytype) { +// case 1: // 微信支付 +// paymentResult = handleWechatPayment(user, orderId, totalAmount, orderDescription, ordertype); +// break; +// case 2: // 余额支付 +// paymentResult = handleBalancePayment(user, orderId, totalAmount, orderDescription); +// break; +// case 3: // 组合支付 +// paymentResult = handleCombinedPayment(user, orderId, totalAmount, orderDescription, params, ordertype); +// break; +// default: +// return AppletControllerUtil.appletWarning("不支持的支付类型"); +// } +// +// if (paymentResult == null || !(Boolean) paymentResult.get("success")) { +// String errorMsg = paymentResult != null ? (String) paymentResult.get("message") : "支付处理失败"; +// return AppletControllerUtil.appletWarning(errorMsg); +// } +// +// // 10. 返回支付结果 +// Map responseData = new HashMap<>(); +// responseData.put("orderId", orderId); +// responseData.put("totalAmount", totalAmount); +// responseData.put("paytype", paytype); +// responseData.put("ordertype", ordertype); +// responseData.putAll(paymentResult); +// +// return AppletControllerUtil.appletSuccess(responseData); +// +// } catch (Exception e) { +// logger.error("通用订单支付异常:", e); +// return AppletControllerUtil.appletError("订单支付失败:" + e.getMessage()); +// } +// } +// +// /** +// * 处理普通预约订单 +// */ +// private Map handleNormalOrder(Users user, Long productId, String sku, Long addressId, +// Long couponId, BigDecimal memberMoney, Integer num, +// String makeTime, String mtcode) { +// Map result = new HashMap<>(); +// try { +// // 1. 查询商品信息 +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); +// if (serviceGoods == null) { +// result.put("success", false); +// result.put("message", "商品不存在"); +// return result; +// } +// +// // 2. 验证地址信息(如果需要) +// UserAddress userAddress = null; +// if (addressId != null) { +// userAddress = userAddressService.selectUserAddressById(addressId); +// if (userAddress == null) { +// result.put("success", false); +// result.put("message", "地址不存在"); +// return result; +// } +// } +// +// // 3. 计算订单金额 +// BigDecimal itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num)); +// BigDecimal totalAmount = itemPrice.subtract(memberMoney); +// +// // 4. 处理优惠券 +// BigDecimal couponDiscount = BigDecimal.ZERO; +// if (couponId != null) { +// CouponUser coupon = couponUserService.selectCouponUserById(couponId); +// if (coupon != null && coupon.getStatus() == 1) { +// couponDiscount = new BigDecimal(coupon.getCouponPrice()); +// totalAmount = totalAmount.subtract(couponDiscount); +// // 标记优惠券为已使用 +// coupon.setStatus(2L); +// couponUserService.updateCouponUser(coupon); +// } +// } +// +// // 5. 创建订单 +// String orderId = GenerateCustomCode.generCreateOrder("B"); +// +// if (serviceGoods.getType() == 2) { +// // 创建商品订单 +// GoodsOrder goodsOrder = new GoodsOrder(); +// goodsOrder.setType(1); +// goodsOrder.setOrderId(orderId); +// goodsOrder.setUid(user.getId()); +// goodsOrder.setProductId(productId); +// goodsOrder.setNum(Long.valueOf(num)); +// goodsOrder.setTotalPrice(itemPrice); +// goodsOrder.setGoodPrice(serviceGoods.getPrice()); +// goodsOrder.setPayPrice(totalAmount); +// goodsOrder.setDeduction(couponDiscount.add(memberMoney)); +// goodsOrder.setStatus(1L); // 待支付 +// goodsOrder.setSku(sku); +// goodsOrder.setMtcode(mtcode); +// if (addressId != null) { +// goodsOrder.setAddressId(addressId); +// goodsOrder.setName(userAddress.getName()); +// goodsOrder.setPhone(userAddress.getPhone()); +// goodsOrder.setAddress(userAddress.getAddressName()); +// } +// if (couponId != null) { +// goodsOrder.setCouponId(couponId); +// } +// +// int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder); +// if (insertResult <= 0) { +// result.put("success", false); +// result.put("message", "订单创建失败"); +// return result; +// } +// } else { +// // 创建服务订单 +// Order order = new Order(); +// order.setType(1); +// order.setCreateType(1); +// order.setOrderId(orderId); +// order.setUid(user.getId()); +// order.setUname(user.getName()); +// order.setProductId(productId); +// order.setProductName(serviceGoods.getTitle()); +// order.setNum(Long.valueOf(num)); +// order.setTotalPrice(itemPrice); +// order.setGoodPrice(serviceGoods.getPrice()); +// order.setPayPrice(totalAmount); +// order.setDeduction(couponDiscount.add(memberMoney)); +// order.setStatus(1L); // 待接单 +// order.setReceiveType(1L); // 自由抢单 +// order.setSku(sku); +// order.setMtcode(mtcode); +// if (addressId != null) { +// order.setAddressId(addressId); +// order.setName(userAddress.getName()); +// order.setPhone(userAddress.getPhone()); +// order.setAddress(userAddress.getAddressInfo()); +// } +// if (couponId != null) { +// order.setCouponId(couponId); +// } +// +// // 处理预约时间 +// if (makeTime != null && !makeTime.isEmpty()) { +// String[] makeTimeArr = makeTime.split(" "); +// if (makeTimeArr.length == 2) { +// try { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// Date date = sdf.parse(makeTimeArr[0]); +// order.setMakeTime(date.getTime() / 1000); +// order.setMakeHour(makeTimeArr[1]); +// } catch (Exception e) { +// logger.warn("预约时间格式错误: " + makeTime); +// } +// } +// } +// +// int insertResult = orderService.insertOrder(order); +// if (insertResult <= 0) { +// result.put("success", false); +// result.put("message", "订单创建失败"); +// return result; +// } +// } +// +// result.put("success", true); +// result.put("orderId", orderId); +// result.put("totalAmount", totalAmount); +// result.put("description", "普通预约-" + serviceGoods.getTitle()); +// return result; +// +// } catch (Exception e) { +// logger.error("处理普通预约订单异常:", e); +// result.put("success", false); +// result.put("message", "订单处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理拼团订单 +// */ +// private Map handleGroupBuyingOrder(Users user, Long productId, String sku, +// Long couponId, BigDecimal memberMoney, Integer num) { +// Map result = new HashMap<>(); +// try { +// // 1. 查询商品信息 +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); +// if (serviceGoods == null) { +// result.put("success", false); +// result.put("message", "商品不存在"); +// return result; +// } +// +// // 2. 验证拼团价格 +// if (serviceGoods.getGroupprice() == null) { +// result.put("success", false); +// result.put("message", "该商品不支持拼团"); +// return result; +// } +// +// // 3. 计算订单金额 +// BigDecimal itemPrice = serviceGoods.getGroupprice().multiply(BigDecimal.valueOf(num)); +// BigDecimal totalAmount = itemPrice.subtract(memberMoney); +// +// // 4. 处理优惠券 +// if (couponId != null) { +// CouponUser coupon = couponUserService.selectCouponUserById(couponId); +// if (coupon != null && coupon.getStatus() == 1) { +// BigDecimal couponDiscount = new BigDecimal(coupon.getCouponPrice()); +// totalAmount = totalAmount.subtract(couponDiscount); +// coupon.setStatus(2L); +// couponUserService.updateCouponUser(coupon); +// } +// } +// +// // 5. 创建拼团订单 +// String orderId = GenerateCustomCode.generCreateOrder("G"); +// UserGroupBuying userGroupBuying = new UserGroupBuying(); +// userGroupBuying.setUid(user.getId()); +// userGroupBuying.setStatus(4L); // 待支付 +// userGroupBuying.setUname(user.getName()); +// userGroupBuying.setProductId(productId); +// userGroupBuying.setPaytype(1L); // 微信支付 +// userGroupBuying.setMoney(totalAmount); +// userGroupBuying.setOrderid(orderId); +// userGroupBuying.setSku(sku); +// if (couponId != null) { +// userGroupBuying.setCouponId(couponId); +// } +// +// int insertResult = userGroupBuyingService.insertUserGroupBuying(userGroupBuying); +// if (insertResult <= 0) { +// result.put("success", false); +// result.put("message", "拼团订单创建失败"); +// return result; +// } +// +// result.put("success", true); +// result.put("orderId", orderId); +// result.put("totalAmount", totalAmount); +// result.put("description", "拼团-" + serviceGoods.getTitle()); +// return result; +// +// } catch (Exception e) { +// logger.error("处理拼团订单异常:", e); +// result.put("success", false); +// result.put("message", "拼团订单处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理次卡订单 +// */ +// private Map handleCardOrder(Users user, Long productId, String sku, +// Long couponId, BigDecimal memberMoney, Integer num) { +// Map result = new HashMap<>(); +// try { +// // 1. 查询商品信息 +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); +// if (serviceGoods == null) { +// result.put("success", false); +// result.put("message", "商品不存在"); +// return result; +// } +// +// // 2. 验证次卡类型 +// if (serviceGoods.getType() != 3) { // 假设type=3表示次卡 +// result.put("success", false); +// result.put("message", "该商品不是次卡类型"); +// return result; +// } +// +// // 3. 计算订单金额 +// BigDecimal itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(num)); +// BigDecimal totalAmount = itemPrice.subtract(memberMoney); +// +// // 4. 处理优惠券 +// if (couponId != null) { +// CouponUser coupon = couponUserService.selectCouponUserById(couponId); +// if (coupon != null && coupon.getStatus() == 1) { +// BigDecimal couponDiscount = new BigDecimal(coupon.getCouponPrice()); +// totalAmount = totalAmount.subtract(couponDiscount); +// coupon.setStatus(2L); +// couponUserService.updateCouponUser(coupon); +// } +// } +// +// // 5. 创建次卡订单(使用商品订单表) +// String orderId = GenerateCustomCode.generCreateOrder("C"); +// GoodsOrder goodsOrder = new GoodsOrder(); +// goodsOrder.setType(3); // 次卡类型 +// goodsOrder.setOrderId(orderId); +// goodsOrder.setUid(user.getId()); +// goodsOrder.setProductId(productId); +// goodsOrder.setNum(Long.valueOf(num)); +// goodsOrder.setTotalPrice(itemPrice); +// goodsOrder.setGoodPrice(serviceGoods.getPrice()); +// goodsOrder.setPayPrice(totalAmount); +// goodsOrder.setDeduction(memberMoney); +// goodsOrder.setStatus(1L); // 待支付 +// goodsOrder.setSku(sku); +// if (couponId != null) { +// goodsOrder.setCouponId(couponId); +// } +// +// int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder); +// if (insertResult <= 0) { +// result.put("success", false); +// result.put("message", "次卡订单创建失败"); +// return result; +// } +// +// result.put("success", true); +// result.put("orderId", orderId); +// result.put("totalAmount", totalAmount); +// result.put("description", "次卡-" + serviceGoods.getTitle()); +// return result; +// +// } catch (Exception e) { +// logger.error("处理次卡订单异常:", e); +// result.put("success", false); +// result.put("message", "次卡订单处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理秒杀订单 +// */ +// private Map handleSeckillOrder(Users user, Long productId, String sku, Long addressId, +// Long couponId, BigDecimal memberMoney, Integer num) { +// Map result = new HashMap<>(); +// try { +// // 1. 查询商品信息 +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); +// if (serviceGoods == null) { +// result.put("success", false); +// result.put("message", "商品不存在"); +// return result; +// } +// +// // 2. 验证秒杀价格 +// if (serviceGoods.getSeckillprice() == null) { +// result.put("success", false); +// result.put("message", "该商品不支持秒杀"); +// return result; +// } +// +// // 3. 验证库存 +// if (serviceGoods.getStock() != null && serviceGoods.getStock() < num) { +// result.put("success", false); +// result.put("message", "库存不足"); +// return result; +// } +// +// // 4. 计算订单金额 +// BigDecimal itemPrice = serviceGoods.getSeckillprice().multiply(BigDecimal.valueOf(num)); +// BigDecimal totalAmount = itemPrice.subtract(memberMoney); +// +// // 5. 处理优惠券 +// if (couponId != null) { +// CouponUser coupon = couponUserService.selectCouponUserById(couponId); +// if (coupon != null && coupon.getStatus() == 1) { +// BigDecimal couponDiscount = new BigDecimal(coupon.getCouponPrice()); +// totalAmount = totalAmount.subtract(couponDiscount); +// coupon.setStatus(2L); +// couponUserService.updateCouponUser(coupon); +// } +// } +// +// // 6. 验证地址信息 +// UserAddress userAddress = null; +// if (addressId != null) { +// userAddress = userAddressService.selectUserAddressById(addressId); +// if (userAddress == null) { +// result.put("success", false); +// result.put("message", "地址不存在"); +// return result; +// } +// } +// +// // 7. 创建秒杀订单 +// String orderId = GenerateCustomCode.generCreateOrder("S"); +// GoodsOrder goodsOrder = new GoodsOrder(); +// goodsOrder.setType(4); // 秒杀类型 +// goodsOrder.setOrderId(orderId); +// goodsOrder.setUid(user.getId()); +// goodsOrder.setProductId(productId); +// goodsOrder.setNum(Long.valueOf(num)); +// goodsOrder.setTotalPrice(itemPrice); +// goodsOrder.setGoodPrice(serviceGoods.getSeckillprice()); +// goodsOrder.setPayPrice(totalAmount); +// goodsOrder.setDeduction(memberMoney); +// goodsOrder.setStatus(1L); // 待支付 +// goodsOrder.setSku(sku); +// if (addressId != null) { +// goodsOrder.setAddressId(addressId); +// goodsOrder.setName(userAddress.getName()); +// goodsOrder.setPhone(userAddress.getPhone()); +// goodsOrder.setAddress(userAddress.getAddressName()); +// } +// if (couponId != null) { +// goodsOrder.setCouponId(couponId); +// } +// +// int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder); +// if (insertResult <= 0) { +// result.put("success", false); +// result.put("message", "秒杀订单创建失败"); +// return result; +// } +// +// result.put("success", true); +// result.put("orderId", orderId); +// result.put("totalAmount", totalAmount); +// result.put("description", "秒杀-" + serviceGoods.getTitle()); +// return result; +// +// } catch (Exception e) { +// logger.error("处理秒杀订单异常:", e); +// result.put("success", false); +// result.put("message", "秒杀订单处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理报价订单 +// */ +// private Map handleQuoteOrder(Users user, Long productId, String sku, Long addressId, +// Long couponId, BigDecimal memberMoney, Integer num) { +// Map result = new HashMap<>(); +// try { +// // 报价订单通常是先创建订单,后续师傅报价后再支付 +// // 这里创建一个待报价的订单 +// +// // 1. 查询商品信息 +// ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId); +// if (serviceGoods == null) { +// result.put("success", false); +// result.put("message", "商品不存在"); +// return result; +// } +// +// // 2. 验证地址信息 +// UserAddress userAddress = null; +// if (addressId != null) { +// userAddress = userAddressService.selectUserAddressById(addressId); +// if (userAddress == null) { +// result.put("success", false); +// result.put("message", "地址不存在"); +// return result; +// } +// } +// +// // 3. 创建报价订单(初始金额为0,等待师傅报价) +// String orderId = GenerateCustomCode.generCreateOrder("Q"); +// Order order = new Order(); +// order.setType(1); +// order.setCreateType(1); +// order.setOrderId(orderId); +// order.setUid(user.getId()); +// order.setUname(user.getName()); +// order.setProductId(productId); +// order.setProductName(serviceGoods.getTitle()); +// order.setNum(Long.valueOf(num)); +// order.setTotalPrice(BigDecimal.ZERO); // 待报价 +// order.setGoodPrice(serviceGoods.getPrice()); +// order.setPayPrice(BigDecimal.ZERO); // 待报价 +// order.setDeduction(memberMoney); +// order.setStatus(1L); // 待接单 +// order.setReceiveType(1L); // 自由抢单 +// order.setSku(sku); +// if (addressId != null) { +// order.setAddressId(addressId); +// order.setName(userAddress.getName()); +// order.setPhone(userAddress.getPhone()); +// order.setAddress(userAddress.getAddressInfo()); +// } +// if (couponId != null) { +// order.setCouponId(couponId); +// } +// +// int insertResult = orderService.insertOrder(order); +// if (insertResult <= 0) { +// result.put("success", false); +// result.put("message", "报价订单创建失败"); +// return result; +// } +// +// result.put("success", true); +// result.put("orderId", orderId); +// result.put("totalAmount", BigDecimal.ZERO); // 报价订单暂时为0 +// result.put("description", "报价订单-" + serviceGoods.getTitle()); +// return result; +// +// } catch (Exception e) { +// logger.error("处理报价订单异常:", e); +// result.put("success", false); +// result.put("message", "报价订单处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理微信支付 +// */ +// private Map handleWechatPayment(Users user, String orderId, BigDecimal totalAmount, +// String description, Integer ordertype) { +// Map result = new HashMap<>(); +// try { +// if (totalAmount.compareTo(BigDecimal.ZERO) <= 0) { +// result.put("success", false); +// result.put("message", "支付金额必须大于0"); +// return result; +// } +// +// // 根据订单类型选择不同的回调地址 +// String notifyUrl = getNotifyUrlByOrderType(ordertype); +// +// // 调用微信支付 +// Map payResult = wechatPayUtil.createBatchOrderAndPay( +// user.getOpenid(), +// orderId, +// new BigDecimal("0.01"), // 测试环境使用0.01元 +// 1, +// notifyUrl); +// +// if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) { +// result.put("success", true); +// result.put("paytype", "wechat"); +// result.put("prepayId", payResult.get("prepayId")); +// result.putAll(payResult); +// } else { +// String errorMsg = payResult != null ? (String) payResult.get("message") : "微信支付下单失败"; +// result.put("success", false); +// result.put("message", errorMsg); +// } +// +// return result; +// +// } catch (Exception e) { +// logger.error("处理微信支付异常:", e); +// result.put("success", false); +// result.put("message", "微信支付处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理余额支付 +// */ +// private Map handleBalancePayment(Users user, String orderId, BigDecimal totalAmount, +// String description) { +// Map result = new HashMap<>(); +// try { +// if (totalAmount.compareTo(BigDecimal.ZERO) <= 0) { +// result.put("success", false); +// result.put("message", "支付金额必须大于0"); +// return result; +// } +// +// // 调用余额支付工具类 +// Map balanceResult = BalancePayUtil.processBalancePayment( +// user.getId(), +// totalAmount, +// description); +// +// if (balanceResult != null && Boolean.TRUE.equals(balanceResult.get("success"))) { +// result.put("success", true); +// result.put("paytype", "balance"); +// result.put("message", "余额支付成功"); +// result.put("beforeBalance", balanceResult.get("beforeBalance")); +// result.put("afterBalance", balanceResult.get("afterBalance")); +// } else { +// result.put("success", false); +// result.put("message", balanceResult != null ? (String) balanceResult.get("message") : "余额支付失败"); +// if (balanceResult != null && balanceResult.containsKey("insufficientAmount")) { +// result.put("insufficientAmount", balanceResult.get("insufficientAmount")); +// } +// } +// +// return result; +// +// } catch (Exception e) { +// logger.error("处理余额支付异常:", e); +// result.put("success", false); +// result.put("message", "余额支付处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 处理组合支付 +// */ +// private Map handleCombinedPayment(Users user, String orderId, BigDecimal totalAmount, +// String description, Map params, +// Integer ordertype) { +// Map result = new HashMap<>(); +// try { +// if (totalAmount.compareTo(BigDecimal.ZERO) <= 0) { +// result.put("success", false); +// result.put("message", "支付金额必须大于0"); +// return result; +// } +// +// // 获取组合支付参数 +// BigDecimal wechatAmount = params.get("wechat_pay_amount") != null ? +// new BigDecimal(params.get("wechat_pay_amount").toString()) : BigDecimal.ZERO; +// BigDecimal balanceAmount = params.get("balance_pay_amount") != null ? +// new BigDecimal(params.get("balance_pay_amount").toString()) : BigDecimal.ZERO; +// +// // 验证金额 +// if (wechatAmount.add(balanceAmount).compareTo(totalAmount) != 0) { +// result.put("success", false); +// result.put("message", "组合支付金额不匹配"); +// return result; +// } +// +// // 先处理余额支付部分 +// if (balanceAmount.compareTo(BigDecimal.ZERO) > 0) { +// Map balanceResult = BalancePayUtil.processBalancePayment( +// user.getId(), +// balanceAmount, +// description + "-余额支付部分"); +// +// if (balanceResult == null || !Boolean.TRUE.equals(balanceResult.get("success"))) { +// result.put("success", false); +// result.put("message", balanceResult != null ? (String) balanceResult.get("message") : "余额支付失败"); +// return result; +// } +// } +// +// // 再处理微信支付部分 +// if (wechatAmount.compareTo(BigDecimal.ZERO) > 0) { +// String notifyUrl = getNotifyUrlByOrderType(ordertype); +// Map wechatResult = wechatPayUtil.createBatchOrderAndPay( +// user.getOpenid(), +// orderId, +// new BigDecimal("0.01"), // 测试环境使用0.01元 +// 1, +// notifyUrl); +// +// if (wechatResult == null || !Boolean.TRUE.equals(wechatResult.get("success"))) { +// result.put("success", false); +// result.put("message", wechatResult != null ? (String) wechatResult.get("message") : "微信支付失败"); +// return result; +// } +// +// result.put("prepayId", wechatResult.get("prepayId")); +// result.putAll(wechatResult); +// } +// +// result.put("success", true); +// result.put("paytype", "combined"); +// result.put("wechatAmount", wechatAmount); +// result.put("balanceAmount", balanceAmount); +// result.put("message", "组合支付处理成功"); +// +// return result; +// +// } catch (Exception e) { +// logger.error("处理组合支付异常:", e); +// result.put("success", false); +// result.put("message", "组合支付处理异常:" + e.getMessage()); +// return result; +// } +// } +// +// /** +// * 根据订单类型获取回调地址 +// */ +// private String getNotifyUrlByOrderType(Integer ordertype) { +// switch (ordertype) { +// case 0: // 普通预约 +// return WechatPayUtil.PAY_FH + "api/goods/pay/notify"; +// case 1: // 拼团 +// return WechatPayUtil.PAY_FH + "api/group/pay/notify"; +// case 2: // 次卡 +// return WechatPayUtil.PAY_FH + "api/card/pay/notify"; +// case 3: // 秒杀 +// return WechatPayUtil.PAY_FH + "api/seckill/pay/notify"; +// case 4: // 报价 +// return WechatPayUtil.PAY_FH + "api/quote/pay/notify"; +// default: +// return WechatPayUtil.PAY_FH + "api/goods/pay/notify"; +// } +// } + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java index edfacb0..60702cd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java @@ -110,6 +110,16 @@ public class AppletController extends BaseController { private IWorkerApplyService workerApplyService; @Autowired private IUserMemberRechargeProgramService userMemberRechargeProgramService; + + @Autowired + private IUserSecondaryCardService userSecondaryCardService; + @Autowired + private IUserGroupBuyingService userGroupBuyingService; + + + + + /** * 获取服务分类列表 * 功能说明: @@ -928,7 +938,9 @@ public class AppletController extends BaseController { * - 包含图片、基础信息等数组数据 */ @GetMapping(value = "/api/service/info/id/{id}") - public AjaxResult serviceGoodsQuery(@PathVariable("id") long id, HttpServletRequest request) { + public AjaxResult serviceGoodsQuery(@PathVariable("id") long id, + @RequestParam(value = "type", required = false) Integer type, + HttpServletRequest request) { try { // 参数验证 if (id <= 0) { @@ -940,16 +952,95 @@ public class AppletController extends BaseController { if (serviceGoodsData == null) { return AppletControllerUtil.appletError("商品不存在或已下架"); } + if (type != null && type == 1) { + if (serviceGoodsData.getIsgroup()!=1){ + return AppletControllerUtil.appletError("改服务不是拼团服务"); + } + } + //次卡详情 + if (type != null && type == 2) { + UserSecondaryCard goods = userSecondaryCardService.selectUserSecondaryCardById(id); + Map map = new HashMap<>(); + map.put("id", goods.getId()); + map.put("allsellnum", 10); + map.put("orderid", goods.getOrderid()); + map.put("title", goods.getTitle()); + map.put("goodsids", goods.getGoodsids()); + map.put("show_money", goods.getShowMoney()); + map.put("real_money", goods.getRealMoney()); + map.put("showimage", AppletControllerUtil.buildImageUrl(goods.getShowimage())); + map.put("carouselImage", AppletControllerUtil.parseImagesStringToArray(goods.getCarouselImage())); + map.put("status", goods.getStatus()); + map.put("creattime", goods.getCreattime()); + map.put("type", goods.getType()); + map.put("num", goods.getNum()); + map.put("allnum", goods.getAllnum()); + map.put("introduction", goods.getIntroduction()); + List idsList = JSONArray.parseArray(goods.getGoodsids(), String.class); + List serviceGoodsList = serviceGoodsService.selectServiceGoodsfrocikaList(idsList); + List> serviceDetail = new ArrayList<>(); + if(serviceGoodsList != null && !serviceGoodsList.isEmpty()) { + for(ServiceGoods serviceGoods : serviceGoodsList) { + Map card = new HashMap<>(); + card.put("icon", AppletControllerUtil.buildImageUrl(serviceGoods.getIcon())); + card.put("title", serviceGoods.getTitle()); + card.put("price", serviceGoods.getPrice()); + card.put("id", serviceGoods.getId()); + serviceDetail.add( card); + } + } + map.put("serviceDetail", serviceDetail); + // card.setServiceDetail(serviceGoodsService.selectServiceGoodsfrocikaList(idsList)); + return AppletControllerUtil.appletSuccess(map); + } + //拼团详情 - // 根据商品类型返回不同格式的数据 + + + // 原有逻辑:普通服务详情 if (serviceGoodsData.getType() != null && serviceGoodsData.getType().intValue() == 2) { // type=2时返回json.txt格式 Map goodsData = AppletControllerUtil.buildType2ServiceGoodsResponse(serviceGoodsData); return AppletControllerUtil.appletSuccess(goodsData); } else { // type=1时返回ServiceGoodsResponse格式 - AppletControllerUtil.ServiceGoodsResponse response = new AppletControllerUtil.ServiceGoodsResponse(serviceGoodsData); - return AppletControllerUtil.appletSuccess(response); + Map goodsData = AppletControllerUtil.buildType2ServiceGoodsResponse(serviceGoodsData); + //根据需求就要添加拼团相关数据 + if (type != null) { + //拼团独有数据 + if (type == 1) { + // 拼团服务详情 + goodsData.put("allsellnum", 10); + goodsData.put("isgroup", serviceGoodsData.getIsgroup()); + goodsData.put("groupprice", serviceGoodsData.getGroupprice()); + List> groupBuyingList = userGroupBuyingService.selectGroupBuyingGroupByProductAndOrder(Math.toIntExact(serviceGoodsData.getId())); + for (Map groupBuying : groupBuyingList) { + //还差几人成团 + JSONArray groupBuyingArray = JSONArray.parseArray(groupBuying.get("name").toString()); + groupBuying.put("neednum", serviceGoodsData.getGroupnum() - groupBuyingArray.size()); + groupBuying.put("image", AppletControllerUtil.parseImagesStringToArray(groupBuying.get("image").toString())); + //parseImagesStringToArray(goods.getImgs()) + //groupBuying.put("neednum", AppletControllerUtil.buildImageUrl(groupBuying.get("image").toString())); + } + goodsData.put("groupBuyData", groupBuyingList); + } + //秒杀独有数据 + if (type == 3) { + // 秒杀服务详情 + goodsData.put("allsellnum", 10); + goodsData.put("isfixed", serviceGoodsData.getIsfixed()); + goodsData.put("fixedprice", serviceGoodsData.getFixedprice()); + } + //报价数据下师傅的报价详情 + if (type == 3) { + // 秒杀服务详情 +// List> quoteList = new List>() ; +// +// goodsData.put("isfixed", serviceGoodsData.getIsfixed()); +// goodsData.put("fixedprice", serviceGoodsData.getFixedprice()); + } + } + return AppletControllerUtil.appletSuccess(goodsData); } } catch (Exception e) { return AppletControllerUtil.appletError("查询商品详情失败:" + e.getMessage()); @@ -1007,8 +1098,8 @@ public class AppletController extends BaseController { * - 保持原有排序不变 * - 无需用户登录验证 */ - @GetMapping(value = "/api/mall/cate/lst") - public AjaxResult getMallCategoryList(HttpServletRequest request) { + @GetMapping(value = "/api/mall/cate/lst/{type}") + public AjaxResult getMallCategoryList(@PathVariable("type") int type, HttpServletRequest request) { try { // 构建查询条件 ServiceCate serviceCateQuery = new ServiceCate(); @@ -1108,14 +1199,10 @@ public class AppletController extends BaseController { int page = params.get("page") != null ? (Integer) params.get("page") : 1; int limit = params.get("limit") != null ? (Integer) params.get("limit") : 15; String cateId = params.get("cateId").toString(); -// // 1. 参数验证 -// if (cateId == null) { -// return AppletControllerUtil.appletWarning("分类ID不能为空"); -// } // 验证分页参数 -// if (page < 1) page = 1; -// if (limit < 1) limit = 15; + if (page < 1) page = 1; + if (limit < 1) limit = 15; // if (limit > 100) limit = 100; // 限制最大每页数量 // 2. 设置分页参数 @@ -1425,6 +1512,7 @@ public class AppletController extends BaseController { @GetMapping(value = "/api/user/info") public AjaxResult apiuserinfo(HttpServletRequest request) { try { + SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd"); Map order_num = new HashMap<>(); Map goods_order_num = new HashMap<>(); // 1. 验证用户登录状态 @@ -1541,7 +1629,7 @@ public class AppletController extends BaseController { userInfo.put("balance", user.getBalance()); userInfo.put("shop_money", user.getConsumption()); userInfo.put("service_money", user.getServicefee()); - userInfo.put("birthday", user.getBirthday()); + userInfo.put("birthday",user.getBirthday() != null ? sdfday.format(user.getBirthday()) : null); // 头像处理 String avatar = user.getAvatar(); if (avatar != null && !avatar.isEmpty()) { @@ -6567,4 +6655,268 @@ public class AppletController extends BaseController { return AppletControllerUtil.appletSuccess(responseData); } + + + + /** + * 首页接口汇总 + */ + @GetMapping(value = "/api/public/group/catelst") + public AjaxResult groupCatelst(@RequestParam(value = "type", required = false, defaultValue = "1") int type) { + List cateList; + // 根据type调用不同的分类查询方法 + if (type == 1) { + cateList = serviceCateService.selectServiceCatepintuanList(); // 拼团 + } else if (type == 2) { + cateList = serviceCateService.selectServiceCateCiKaList(); // 次卡 + } else if (type == 3) { + cateList = serviceCateService.selectServiceCateMiaoshaList(); // 秒杀 + } else if (type == 4) { + cateList = serviceCateService.selectServiceCateBaojiaList(); // 报价 + } else { + cateList = new ArrayList<>(); + } + List> cateDataList = new ArrayList<>(); + for (ServiceCate cate : cateList) { + Map cateData = new HashMap<>(); + cateData.put("id", cate.getId()); + cateData.put("title", cate.getTitle()); + cateData.put("icon", AppletControllerUtil.buildImageUrl(cate.getIcon())); + cateDataList.add(cateData); + } + return AppletControllerUtil.appletSuccess(cateDataList); + } + + + + /** + * 获取拼团服务列表 + * 查询status=1、type=1、isgroup=1的服务商品,分页返回 + * 只返回图标、标题、原价、拼团价、拼团人数 + * @param params 请求参数,包含page和limit + * @return 拼团服务分页列表 + * + * 1查拼团 2查次卡 3查秒杀 4查报价 + */ + @PostMapping("/api/group/service/list") + public AjaxResult getGroupServiceList(@RequestBody Map params) { + try { + int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; + int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 15; + Long cateId = null; + if (params.get("cateid") != null && !params.get("cateid").toString().isEmpty()) { + cateId = Long.parseLong(params.get("cateid").toString()); + } + int type = params.get("type") != null ? Integer.parseInt(params.get("type").toString()) : 1; + + // 分页参数校验 + Map pageValidation = PageUtil.validatePageParams(page, limit); + if (!(Boolean) pageValidation.get("valid")) { + return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); + } + + //拼团数据 + if (type == 1) { + // 设置分页 + PageHelper.startPage(page, limit); + // 构造查询条件 + ServiceGoods query = new ServiceGoods(); + query.setStatus("1"); + query.setType(1); + query.setIsgroup(1);//1是拼团 + if (cateId != null) { + query.setCateId(cateId); + } + List goodsList = serviceGoodsService.selectServiceGoodsList(query); + // 只返回需要的字段 + List> resultList = new ArrayList<>(); + for (ServiceGoods goods : goodsList) { + Map map = new HashMap<>(); + map.put("icon", AppletControllerUtil.buildImageUrl(goods.getIcon())); + map.put("title", goods.getTitle()); + map.put("price", goods.getPrice()); + map.put("groupprice", goods.getGroupprice()); + map.put("groupnum", goods.getGroupnum()); + resultList.add(map); + } + + // 分页封装 + TableDataInfo tableDataInfo = getDataTable(goodsList); + tableDataInfo.setRows(resultList); // 只返回精简字段 + Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + return AppletControllerUtil.appletSuccess(pageData); + } + //次卡数据 + if (type == 2) { + // 设置分页 + PageHelper.startPage(page, limit); + // 构造查询条件 + UserSecondaryCard queryParams = new UserSecondaryCard(); + queryParams.setStatus(1L); + if (cateId != null) { + queryParams.setType(cateId); + } + List goodsList = userSecondaryCardService.selectUserSecondaryCardList(queryParams); + // 只返回需要的字段 + List> resultList = new ArrayList<>(); + for (UserSecondaryCard goods : goodsList) { + Map map = new HashMap<>(); + map.put("id", goods.getId()); + map.put("orderid", goods.getOrderid()); + map.put("title", goods.getTitle()); + map.put("goodsids", goods.getGoodsids()); + map.put("show_money", goods.getShowMoney()); + map.put("real_money", goods.getRealMoney()); + map.put("showimage", AppletControllerUtil.buildImageUrl(goods.getShowimage())); + map.put("status", goods.getStatus()); + map.put("creattime", goods.getCreattime()); + map.put("type", goods.getType()); + map.put("num", goods.getNum()); + map.put("allnum", goods.getAllnum()); + map.put("introduction", goods.getIntroduction()); + List idsList = JSONArray.parseArray(goods.getGoodsids(), String.class); + List serviceGoodsList = serviceGoodsService.selectServiceGoodsfrocikaList(idsList); + List> serviceDetail = new ArrayList<>(); + if(serviceGoodsList != null && !serviceGoodsList.isEmpty()) { + for(ServiceGoods serviceGoods : serviceGoodsList) { + Map card = new HashMap<>(); + card.put("icon", AppletControllerUtil.buildImageUrl(serviceGoods.getIcon())); + card.put("title", serviceGoods.getTitle()); + card.put("price", serviceGoods.getPrice()); + card.put("id", serviceGoods.getId()); + serviceDetail.add( card); + } + } + map.put("serviceDetail", serviceDetail); + // card.setServiceDetail(serviceGoodsService.selectServiceGoodsfrocikaList(idsList)); + resultList.add(map); + } + + // 分页封装 + TableDataInfo tableDataInfo = getDataTable(goodsList); + tableDataInfo.setRows(resultList); // 只返回精简字段 + Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + return AppletControllerUtil.appletSuccess(pageData); + } + //秒杀数据 + if (type == 3) { + // 设置分页 + PageHelper.startPage(page, limit); + // 构造查询条件 + ServiceGoods query = new ServiceGoods(); + query.setStatus("1"); + query.setType(1); + query.setIsfixed(1);//秒杀 + if (cateId != null) { + query.setCateId(cateId); + } + List goodsList = serviceGoodsService.selectServiceGoodsList(query); + // 只返回需要的字段 + List> resultList = new ArrayList<>(); + for (ServiceGoods goods : goodsList) { + Map map = new HashMap<>(); + map.put("icon", AppletControllerUtil.buildImageUrl(goods.getIcon())); + map.put("title", goods.getTitle()); + map.put("price", goods.getPrice()); + map.put("fixedprice", goods.getFixedprice()); + resultList.add(map); + } + + // 分页封装 + TableDataInfo tableDataInfo = getDataTable(goodsList); + tableDataInfo.setRows(resultList); // 只返回精简字段 + Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + return AppletControllerUtil.appletSuccess(pageData); + } + + //报价数据 + if (type == 4) { + // 设置分页 + PageHelper.startPage(page, limit); + // 构造查询条件 + ServiceGoods query = new ServiceGoods(); + query.setStatus("1"); + query.setType(1); + query.setServicetype(2);//报价 + if (cateId != null) { + query.setCateId(cateId); + } + List goodsList = serviceGoodsService.selectServiceGoodsList(query); + // 只返回需要的字段 + List> resultList = new ArrayList<>(); + for (ServiceGoods goods : goodsList) { + Map map = new HashMap<>(); + map.put("icon", AppletControllerUtil.buildImageUrl(goods.getIcon())); + map.put("title", goods.getTitle()); + resultList.add(map); + } + + // 分页封装 + TableDataInfo tableDataInfo = getDataTable(goodsList); + tableDataInfo.setRows(resultList); // 只返回精简字段 + Map pageData = PageUtil.buildSimplePageResponse(tableDataInfo, page, limit); + return AppletControllerUtil.appletSuccess(pageData); + } + + } catch (Exception e) { + return AppletControllerUtil.appletError("获取拼团服务列表失败:" + e.getMessage()); + } + return null; + } + +// /** +// * 获取次卡列表(支持分页) +// * +// * 查询用户次卡列表,支持按类型筛选和分页 +// * 每个次卡会包含对应的服务商品详情 +// * +// * @param params 查询参数(page, limit, type) +// * @param request HTTP请求对象 +// * @return 次卡列表(分页格式) +// */ +// @PostMapping("/secondary/card/list") +// public AjaxResult getSecondaryCardList(@RequestBody Map params, HttpServletRequest request) { +// try { +// // 1. 获取并验证分页参数 +// int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; +// int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 15; +// +// Map pageValidation = PageUtil.validatePageParams(page, limit); +// if (!(Boolean) pageValidation.get("valid")) { +// return AppletControllerUtil.appletWarning((String) pageValidation.get("message")); +// } +// +// // 2. 获取type参数 +// Long type = params.get("type") != null ? Long.parseLong(params.get("type").toString()) : null; +// +// // 3. 创建查询对象 +// UserSecondaryCard queryParams = new UserSecondaryCard(); +// queryParams.setStatus(1L); // 只查询状态为1的数据 +// if (type != null) { +// queryParams.setType(type); +// } +// +// // 4. 设置分页参数 +// PageHelper.startPage(page, limit); +// +// // 5. 执行查询 +// List list = userSecondaryCardService.selectUserSecondaryCardList(queryParams); +// +// // 6. 为每个次卡填充服务商品详情 +// for (UserSecondaryCard card : list) { +// List idsList = com.alibaba.fastjson2.JSONArray.parseArray(card.getGoodsids(), String.class); +// card.setServiceDetail(serviceGoodsService.selectServiceGoodsfrocikaList(idsList)); +// } +// +// // 7. 获取分页信息并构建响应 +// TableDataInfo tableDataInfo = getDataTable(list); +// Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit); +// +// return AppletControllerUtil.appletSuccess(pageData); +// +// } catch (Exception e) { +// System.err.println("查询次卡列表异常:" + e.getMessage()); +// return AppletControllerUtil.appletError("获取次卡列表失败:" + e.getMessage()); +// } +// } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java index 00fb611..5f14bdf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PayNotifyController.java @@ -21,7 +21,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Calendar; - import java.util.Date; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersPayBeforController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersPayBeforController.java new file mode 100644 index 0000000..10d0fd4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersPayBeforController.java @@ -0,0 +1,104 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.UsersPayBefor; +import com.ruoyi.system.service.IUsersPayBeforService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 预支付Controller + * + * @author ruoyi + * @date 2025-07-11 + */ +@RestController +@RequestMapping("/system/UsersPayBefor") +public class UsersPayBeforController extends BaseController +{ + @Autowired + private IUsersPayBeforService usersPayBeforService; + + /** + * 查询预支付列表 + */ + @PreAuthorize("@ss.hasPermi('system:UsersPayBefor:list')") + @GetMapping("/list") + public TableDataInfo list(UsersPayBefor usersPayBefor) + { + startPage(); + List list = usersPayBeforService.selectUsersPayBeforList(usersPayBefor); + return getDataTable(list); + } + + /** + * 导出预支付列表 + */ + @PreAuthorize("@ss.hasPermi('system:UsersPayBefor:export')") + @Log(title = "预支付", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, UsersPayBefor usersPayBefor) + { + List list = usersPayBeforService.selectUsersPayBeforList(usersPayBefor); + ExcelUtil util = new ExcelUtil(UsersPayBefor.class); + util.exportExcel(response, list, "预支付数据"); + } + + /** + * 获取预支付详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:UsersPayBefor:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(usersPayBeforService.selectUsersPayBeforById(id)); + } + + /** + * 新增预支付 + */ + @PreAuthorize("@ss.hasPermi('system:UsersPayBefor:add')") + @Log(title = "预支付", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody UsersPayBefor usersPayBefor) + { + return toAjax(usersPayBeforService.insertUsersPayBefor(usersPayBefor)); + } + + /** + * 修改预支付 + */ + @PreAuthorize("@ss.hasPermi('system:UsersPayBefor:edit')") + @Log(title = "预支付", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody UsersPayBefor usersPayBefor) + { + return toAjax(usersPayBeforService.updateUsersPayBefor(usersPayBefor)); + } + + /** + * 删除预支付 + */ + @PreAuthorize("@ss.hasPermi('system:UsersPayBefor:remove')") + @Log(title = "预支付", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(usersPayBeforService.deleteUsersPayBeforByIds(ids)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java index 06e6faf..1d652f9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java @@ -1,5 +1,6 @@ package com.ruoyi.system.ControllerUtil; +import ch.qos.logback.core.util.CachingDateFormatter; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; @@ -17,6 +18,7 @@ import java.math.BigDecimal; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -42,6 +44,7 @@ public class AppletControllerUtil { private static final IUsersService usersService = SpringUtils.getBean(IUsersService.class); private static final IUserAddressService userAddressService = SpringUtils.getBean(IUserAddressService.class); + private static final IOrderCommentService orderCommentService = SpringUtils.getBean(IOrderCommentService.class); // ============================== 统一响应处理方法 ============================== @@ -3132,6 +3135,7 @@ public class AppletControllerUtil { */ public static Map buildType2ServiceGoodsResponse(ServiceGoods goods) { Map data = new HashMap<>(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 基础信息 data.put("id", goods.getId()); @@ -3145,33 +3149,86 @@ public class AppletControllerUtil { data.put("stock", goods.getStock() != null ? goods.getStock().intValue() : 0); data.put("status", goods.getStatus() != null ? goods.getStatus() : "1"); data.put("description", goods.getDescription()); - data.put("sku_type", goods.getSkuType() != null ? goods.getSkuType().intValue() : 1); + data.put("sku_type", goods.getSkuType() != null ? goods.getSkuType() : 1); + if (goods.getSkuType() == 1){ + JSONObject sku = new JSONObject(); + sku.put("type", "single"); + data.put("sku", sku); + }else{ + data.put("sku", parseSkuStringToObject(goods.getSku())); + } + // 处理SKU数据 + // data.put("sku", parseSkuStringToObject(goods.getSku())); data.put("latitude", goods.getLatitude()); data.put("longitude", goods.getLongitude()); - data.put("type", goods.getType() != null ? goods.getType().intValue() : 2); + data.put("type", goods.getType() != null ? goods.getType() : 2); data.put("cate_id", goods.getCateId()); data.put("project", goods.getProject()); - data.put("sort", goods.getSort() != null ? goods.getSort().intValue() : 1); + data.put("sort", goods.getSort() != null ? goods.getSort() : 1); data.put("material", goods.getMaterial()); data.put("postage", goods.getPostage() != null ? goods.getPostage().toString() : null); data.put("basic", parseBasicStringToArray(goods.getBasic())); data.put("margin", goods.getMargin() != null ? goods.getMargin().toString() : null); data.put("skill_ids", goods.getSkillIds()); - // 处理图片数组 data.put("imgs", parseImagesStringToArray(goods.getImgs())); - - // 处理SKU数据 - data.put("sku", parseSkuStringToObject(goods.getSku())); - // 时间字段 - data.put("created_at", formatDateToString(goods.getCreatedAt())); - data.put("updated_at", formatDateToString(goods.getUpdatedAt())); +// data.put("created_at", formatDateToString(goods.getCreatedAt())); +// data.put("updated_at", formatDateToString(goods.getUpdatedAt())); + data.put("created_at", goods.getCreatedAt() != null ? formatDateToString(goods.getCreatedAt()) : null); + data.put("updated_at", goods.getUpdatedAt() != null ? formatDateToString(goods.getUpdatedAt()) : null); data.put("deleted_at", goods.getDeletedAt() != null ? formatDateToString(goods.getDeletedAt()) : null); + //问答 + if (goods.getQuestions() != null){ + data.put("questions", JSONArray.parseArray(goods.getQuestions())); + }else{ + data.put("questions", null); + } - // 评论对象(预留) - data.put("comment", null); + //获取这个产品当前的第一条好评 + OrderComment orderComment =new OrderComment(); + orderComment.setProductId(goods.getId()); + orderComment.setStatus(1); + orderComment.setNumType(1L); + List orderCommentslist = orderCommentService.selectOrderCommentList(orderComment); + if(!orderCommentslist.isEmpty()){ + JSONObject comment = new JSONObject(); + comment.put("content", orderCommentslist.getFirst().getContent()); + comment.put("id", orderCommentslist.getFirst().getId()); + comment.put("labels", JSONArray.parseArray(orderCommentslist.getFirst().getLabels()) ); + comment.put("num", orderCommentslist.getFirst().getNum()); + comment.put("uid", orderCommentslist.getFirst().getUid()); + comment.put("images",JSONArray.parseArray(orderCommentslist.getFirst().getImages()) ); + //comment.put("images",parseImagesStringToArray(orderCommentslist.getFirst().getImages())); + comment.put("commenttime", sdf.format(orderCommentslist.getFirst().getCreatedAt())); + Users u = usersService.selectUsersById(orderCommentslist.getFirst().getUid()); + if (u != null){ + JSONObject user = new JSONObject(); + user.put("id", u.getId()); + user.put("name", u.getName()); + user.put("avatar", u.getAvatar()); + comment.put("user", user); + } + data.put("comment", comment); + }else{ + data.put("comment", null); + } + OrderComment orderComment1 =new OrderComment(); + orderComment1.setProductId(goods.getId()); + List orderCommentslist1 = orderCommentService.selectOrderCommentList(orderComment1); + data.put("allcommentnum", orderCommentslist1.size()); +// if (goods.getIsgroup() != null){ +// data.put("isgroup", goods.getIsgroup()); +// }else{ +// goods.setIsgroup(2); +// data.put("isgroup", 2); +// } +// +// if (goods.getIsgroup() == 1){ +// data.put("group_price", goods.getGroupprice()); +// data.put("groupnum", goods.getGroupnum()); +// } return data; } @@ -3190,7 +3247,12 @@ public class AppletControllerUtil { for (int i = 0; i < jsonArray.size(); i++) { String img = jsonArray.getString(i); if (img != null && !img.trim().isEmpty()) { - imageList.add(buildImageUrl(img)); + String trimmedImg = img.trim(); + if (trimmedImg.contains("https://img.")) { + imageList.add(trimmedImg); + } else { + imageList.add(buildImageUrl(trimmedImg)); + } } } } catch (Exception e) { @@ -3198,7 +3260,12 @@ public class AppletControllerUtil { String[] imgArray = imgs.split("[,,]"); for (String img : imgArray) { if (img != null && !img.trim().isEmpty()) { - imageList.add(buildImageUrl(img.trim())); + String trimmedImg = img.trim(); + if (trimmedImg.contains("https://img.")) { + imageList.add(trimmedImg); + } else { + imageList.add(buildImageUrl(trimmedImg)); + } } } } @@ -3404,10 +3471,10 @@ public class AppletControllerUtil { * @param userId 用户ID * @return 用户更新对象 */ - public static Users buildUpdateUserFromdataParams(Map params, Long userId) { + public static Users buildUpdateUserFromdataParams(Map params, Long userId) throws ParseException { Users updateUser = new Users(); updateUser.setId(userId); - + SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd"); // 基本信息字段 if (params.get("name") != null) { updateUser.setName(params.get("name").toString().trim()); @@ -3460,6 +3527,12 @@ public class AppletControllerUtil { updateUser.setJobNumber(jobNumber); } + // 字符串和其他字段 + if (params.get("birthday") != null) { + + updateUser.setBirthday(sdfday.parse(params.get("birthday").toString().trim())); + } + if (params.get("level") != null && !params.get("level").toString().trim().isEmpty()) { Integer level = parseToIntegerForEdit(params.get("level")); updateUser.setLevel(level); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AttendanceUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AttendanceUtil.java new file mode 100644 index 0000000..51674a0 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AttendanceUtil.java @@ -0,0 +1,20 @@ +package com.ruoyi.system.ControllerUtil; + +import java.time.LocalTime; + +/** + * 考勤工具类 + * 规定:每天上班时间为8:00--18:00,其余时间不允许打卡 + */ +public class AttendanceUtil { + /** + * 判断当前时间是否允许打卡(8:00-18:00) + * @return true=允许打卡,false=不允许 + */ + public static boolean isAllowCheckIn() { + LocalTime now = LocalTime.now(); + LocalTime start = LocalTime.of(8, 0); + LocalTime end = LocalTime.of(18, 0); + return !now.isBefore(start) && !now.isAfter(end); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java index 62fa43d..f1eb51e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/InvoiceUtil.java @@ -92,7 +92,7 @@ public class InvoiceUtil { orderMap.put("orderType", "service"); // 服务订单 orderMap.put("orderTypeText", "服务订单"); orderMap.put("amount", order.getTotalPrice()); - orderMap.put("title", order.getOrderId()+ "服务订单"); + orderMap.put("title", "服务订单"+order.getTotalPrice()+"元" ); orderMap.put("createTime", order.getCreateTime()); orderMap.put("canInvoice", true); pendingOrders.add(orderMap); @@ -113,7 +113,7 @@ public class InvoiceUtil { orderMap.put("orderType", "goods"); // 商品订单 orderMap.put("orderTypeText", "商品订单"); orderMap.put("amount", goodsOrder.getTotalPrice()); - orderMap.put("title", "商品订单"); + orderMap.put("title", "购买商品"+goodsOrder.getTotalPrice()+"元"); orderMap.put("createTime", goodsOrder.getCreateTime()); orderMap.put("canInvoice", true); pendingOrders.add(orderMap); @@ -134,7 +134,7 @@ public class InvoiceUtil { orderMap.put("orderType", "recharge"); // 充值订单 orderMap.put("orderTypeText", "充值订单"); orderMap.put("amount", recharge.getInmoney()); - orderMap.put("title", recharge.getReamk() != null ? recharge.getReamk() : "会员充值"); + orderMap.put("title", "会员充值"+recharge.getInmoney()+"元"); orderMap.put("createTime", recharge.getCreatedAt()); orderMap.put("canInvoice", true); pendingOrders.add(orderMap); @@ -479,6 +479,8 @@ public class InvoiceUtil { if (invoiceData.get("category") == null) { return "发票类别不能为空"; } + + Integer category = (Integer) invoiceData.get("category"); String invoiceTitle = invoiceData.get("invoiceTitle").toString(); @@ -490,17 +492,24 @@ public class InvoiceUtil { } // 检查是否填写了企业字段 - if (StringUtils.isNotEmpty((String) invoiceData.get("taxNumber"))) { - return "个人发票不能填写纳税人识别号"; +// if (StringUtils.isNotEmpty((String) invoiceData.get("taxNumber"))) { +// return "个人发票不能填写纳税人识别号"; +// } +// if (StringUtils.isNotEmpty((String) invoiceData.get("address"))) { +// return "个人发票不能填写单位地址"; +// } +// if (StringUtils.isNotEmpty((String) invoiceData.get("phone"))) { +// return "个人发票不能填写联系电话"; +// } +// if (StringUtils.isNotEmpty((String) invoiceData.get("wechat"))) { +// return "个人发票不能填写微信号"; +// } + if (StringUtils.isEmpty((String) invoiceData.get("email"))) { + return "邮箱不能为空"; } - if (StringUtils.isNotEmpty((String) invoiceData.get("address"))) { - return "个人发票不能填写单位地址"; - } - if (StringUtils.isNotEmpty((String) invoiceData.get("phone"))) { - return "个人发票不能填写联系电话"; - } - if (StringUtils.isNotEmpty((String) invoiceData.get("wechat"))) { - return "个人发票不能填写微信号"; + + if (StringUtils.isEmpty((String) invoiceData.get("wechat"))) { + return "微信号不能为空"; } } // 企业发票验证 @@ -519,19 +528,34 @@ public class InvoiceUtil { if (StringUtils.isEmpty((String) invoiceData.get("phone"))) { return "企业发票的联系电话不能为空"; } - + + if (StringUtils.isEmpty((String) invoiceData.get("bankName"))) { + return "企业发票的开户银行不能为空"; + } + + if (StringUtils.isEmpty((String) invoiceData.get("bankAccount"))) { + return "企业发票的银行账号不能为空"; + } + // 格式验证 String taxNumber = (String) invoiceData.get("taxNumber"); if (!taxNumber.matches("^[A-Z0-9]{15,20}$")) { - return "纳税人识别号格式不正确"; + return "税号格式不正确"; } String phone = (String) invoiceData.get("phone"); if (!phone.matches("^1[3-9]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$|^400-?\\d{3}-?\\d{4}$")) { return "联系电话格式不正确"; } + if (StringUtils.isEmpty((String) invoiceData.get("email"))) { + return "邮箱不能为空"; + } + + if (StringUtils.isEmpty((String) invoiceData.get("wechat"))) { + return "微信号不能为空"; + } } - + return null; // 验证通过 } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserGroupBuying.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserGroupBuying.java index 51dee9c..a3a6b06 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserGroupBuying.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserGroupBuying.java @@ -53,6 +53,14 @@ public class UserGroupBuying extends BaseEntity @Excel(name = "支付订单号") private String transactionId; + /** 支付订单号 */ + @Excel(name = "头像") + private String image; + + + /** 支付类别 */ + @Excel(name = "支付状态 1成功 2不成功") + private Long paystatus; /** 支付类别 */ @Excel(name = "支付类别") private Long paytype; @@ -196,6 +204,22 @@ public class UserGroupBuying extends BaseEntity return updatedAt; } + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public Long getPaystatus() { + return paystatus; + } + + public void setPaystatus(Long paystatus) { + this.paystatus = paystatus; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserSecondaryCard.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserSecondaryCard.java index 11293e4..c8ccd37 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserSecondaryCard.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UserSecondaryCard.java @@ -40,6 +40,10 @@ public class UserSecondaryCard extends BaseEntity @Excel(name = "服务名称") private String goodsname; + /** 服务id */ + @Excel(name = "轮播图") + private String carouselImage; + /** 服务id */ @Excel(name = "简介") @@ -270,6 +274,14 @@ public class UserSecondaryCard extends BaseEntity ServiceDetail = serviceDetail; } + public String getCarouselImage() { + return carouselImage; + } + + public void setCarouselImage(String carouselImage) { + this.carouselImage = carouselImage; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java new file mode 100644 index 0000000..3b91f68 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/UsersPayBefor.java @@ -0,0 +1,309 @@ +package com.ruoyi.system.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 预支付对象 users_pay_befor + * + * @author ruoyi + * @date 2025-07-11 + */ +public class UsersPayBefor extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 用户id */ + @Excel(name = "用户id") + private Long uid; + + /** 支付类别1=微信支付 2=余额支付 3=组合支付 */ + @Excel(name = "支付类别1=微信支付 2=余额支付 3=组合支付") + private Long paytype; + + /** 微信支付金额 */ + @Excel(name = "微信支付金额") + private BigDecimal wxmoney; + + /** 余额支付金额 */ + @Excel(name = "余额支付金额") + private BigDecimal yemoney; + + /** 会员优惠金额 */ + @Excel(name = "会员优惠金额") + private BigDecimal membermoney; + + /** 购物金抵扣金额 */ + @Excel(name = "购物金抵扣金额") + private BigDecimal shopmoney; + + /** 服务金抵扣金额 */ + @Excel(name = "服务金抵扣金额") + private BigDecimal servicemoney; + + /** 服务金抵扣金额 */ + @Excel(name = "总金额") + private BigDecimal allmoney; + + + /** 优惠券id */ + @Excel(name = "优惠券id") + private Long couponid; + + /** 优惠券金额 */ + @Excel(name = "优惠券金额") + private BigDecimal couponmoney; + + /** 美团号 */ + @Excel(name = "美团号") + private String mtcode; + + /** 美团抵扣金额 */ + @Excel(name = "美团抵扣金额") + private BigDecimal mtmoney; + + /** 订类别 1=拼团 2=次卡 3=秒杀 4=报价 0=普通预约(必填) */ + @Excel(name = "订类别 1=拼团 2=次卡 3=秒杀 4=报价 0=普通预约", readConverterExp = "必=填") + private Long type; + + /** 订单号码 */ + @Excel(name = "订单号码") + private String orderid; + + /** 订单id */ + @Excel(name = "订单id") + private Long oid; + + /** 状态 1待支付 2支付成功 */ + @Excel(name = "状态 1待支付 2支付成功") + private Long status; + + /** 支付时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date paytime; + + /** 支付订单号 */ + @Excel(name = "支付订单号") + private String paycode; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setUid(Long uid) + { + this.uid = uid; + } + + public Long getUid() + { + return uid; + } + + public void setPaytype(Long paytype) + { + this.paytype = paytype; + } + + public Long getPaytype() + { + return paytype; + } + + public void setWxmoney(BigDecimal wxmoney) + { + this.wxmoney = wxmoney; + } + + public BigDecimal getWxmoney() + { + return wxmoney; + } + + public void setYemoney(BigDecimal yemoney) + { + this.yemoney = yemoney; + } + + public BigDecimal getYemoney() + { + return yemoney; + } + + public void setMembermoney(BigDecimal membermoney) + { + this.membermoney = membermoney; + } + + public BigDecimal getMembermoney() + { + return membermoney; + } + + public void setShopmoney(BigDecimal shopmoney) + { + this.shopmoney = shopmoney; + } + + public BigDecimal getShopmoney() + { + return shopmoney; + } + + public void setServicemoney(BigDecimal servicemoney) + { + this.servicemoney = servicemoney; + } + + public BigDecimal getServicemoney() + { + return servicemoney; + } + + public void setCouponid(Long couponid) + { + this.couponid = couponid; + } + + public Long getCouponid() + { + return couponid; + } + + public void setCouponmoney(BigDecimal couponmoney) + { + this.couponmoney = couponmoney; + } + + public BigDecimal getCouponmoney() + { + return couponmoney; + } + + public void setMtcode(String mtcode) + { + this.mtcode = mtcode; + } + + public String getMtcode() + { + return mtcode; + } + + public void setMtmoney(BigDecimal mtmoney) + { + this.mtmoney = mtmoney; + } + + public BigDecimal getMtmoney() + { + return mtmoney; + } + + public void setType(Long type) + { + this.type = type; + } + + public Long getType() + { + return type; + } + + public void setOrderid(String orderid) + { + this.orderid = orderid; + } + + public String getOrderid() + { + return orderid; + } + + public void setOid(Long oid) + { + this.oid = oid; + } + + public Long getOid() + { + return oid; + } + + public void setStatus(Long status) + { + this.status = status; + } + + public Long getStatus() + { + return status; + } + + public void setPaytime(Date paytime) + { + this.paytime = paytime; + } + + public Date getPaytime() + { + return paytime; + } + + public void setPaycode(String paycode) + { + this.paycode = paycode; + } + + public String getPaycode() + { + return paycode; + } + + public BigDecimal getAllmoney() { + return allmoney; + } + + public void setAllmoney(BigDecimal allmoney) { + this.allmoney = allmoney; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("uid", getUid()) + .append("paytype", getPaytype()) + .append("wxmoney", getWxmoney()) + .append("yemoney", getYemoney()) + .append("membermoney", getMembermoney()) + .append("shopmoney", getShopmoney()) + .append("servicemoney", getServicemoney()) + .append("couponid", getCouponid()) + .append("couponmoney", getCouponmoney()) + .append("mtcode", getMtcode()) + .append("mtmoney", getMtmoney()) + .append("type", getType()) + .append("orderid", getOrderid()) + .append("oid", getOid()) + .append("status", getStatus()) + .append("paytime", getPaytime()) + .append("paycode", getPaycode()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceCateMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceCateMapper.java index f4bcf01..15ede6e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceCateMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ServiceCateMapper.java @@ -31,6 +31,17 @@ public interface ServiceCateMapper public List selectServiceCateCiKaList(); + public List selectServiceCatepintuanList(); + + + public List selectServiceCateMiaoshaList(); + + + + public List selectServiceCateBaojiaList(); + + + /** * 新增服务分类 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserGroupBuyingMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserGroupBuyingMapper.java index 2116115..22828d9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserGroupBuyingMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserGroupBuyingMapper.java @@ -1,7 +1,10 @@ package com.ruoyi.system.mapper; import java.util.List; +import java.util.Map; + import com.ruoyi.system.domain.UserGroupBuying; +import org.apache.ibatis.annotations.Param; /** * 拼团专区管理Mapper接口 @@ -58,4 +61,11 @@ public interface UserGroupBuyingMapper * @return 结果 */ public int deleteUserGroupBuyingByIds(Long[] ids); + + /** + * 分组查询,返回name和image为字符串数组,按product_id和orderid分组 + * @param productId 产品ID,可为null + * @return List> + */ + List> selectGroupBuyingGroupByProductAndOrder(@Param("productId") Integer productId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UsersPayBeforMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UsersPayBeforMapper.java new file mode 100644 index 0000000..8e66ff0 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UsersPayBeforMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.UsersPayBefor; + +/** + * 预支付Mapper接口 + * + * @author ruoyi + * @date 2025-07-11 + */ +public interface UsersPayBeforMapper +{ + /** + * 查询预支付 + * + * @param id 预支付主键 + * @return 预支付 + */ + public UsersPayBefor selectUsersPayBeforById(Long id); + + /** + * 查询预支付列表 + * + * @param usersPayBefor 预支付 + * @return 预支付集合 + */ + public List selectUsersPayBeforList(UsersPayBefor usersPayBefor); + + /** + * 新增预支付 + * + * @param usersPayBefor 预支付 + * @return 结果 + */ + public int insertUsersPayBefor(UsersPayBefor usersPayBefor); + + /** + * 修改预支付 + * + * @param usersPayBefor 预支付 + * @return 结果 + */ + public int updateUsersPayBefor(UsersPayBefor usersPayBefor); + + /** + * 删除预支付 + * + * @param id 预支付主键 + * @return 结果 + */ + public int deleteUsersPayBeforById(Long id); + + /** + * 批量删除预支付 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteUsersPayBeforByIds(Long[] ids); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceCateService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceCateService.java index 8a43180..4f285fe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceCateService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IServiceCateService.java @@ -30,6 +30,17 @@ public interface IServiceCateService */ public List selectServiceCateList(ServiceCate serviceCate); + + + public List selectServiceCatepintuanList(); + + public List selectServiceCateMiaoshaList(); + + + + public List selectServiceCateBaojiaList(); + + /** * 新增服务分类 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IUserGroupBuyingService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IUserGroupBuyingService.java index 677cc24..6b461ef 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IUserGroupBuyingService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IUserGroupBuyingService.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service; import java.util.List; +import java.util.Map; + import com.ruoyi.system.domain.UserGroupBuying; /** @@ -58,4 +60,11 @@ public interface IUserGroupBuyingService * @return 结果 */ public int deleteUserGroupBuyingById(Long id); + + /** + * 分组查询,返回name和image为字符串数组,按product_id和orderid分组 + * @param productId 产品ID,可为null + * @return List> + */ + List> selectGroupBuyingGroupByProductAndOrder(Integer productId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IUsersPayBeforService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IUsersPayBeforService.java new file mode 100644 index 0000000..3181cb1 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IUsersPayBeforService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.UsersPayBefor; + +/** + * 预支付Service接口 + * + * @author ruoyi + * @date 2025-07-11 + */ +public interface IUsersPayBeforService +{ + /** + * 查询预支付 + * + * @param id 预支付主键 + * @return 预支付 + */ + public UsersPayBefor selectUsersPayBeforById(Long id); + + /** + * 查询预支付列表 + * + * @param usersPayBefor 预支付 + * @return 预支付集合 + */ + public List selectUsersPayBeforList(UsersPayBefor usersPayBefor); + + /** + * 新增预支付 + * + * @param usersPayBefor 预支付 + * @return 结果 + */ + public int insertUsersPayBefor(UsersPayBefor usersPayBefor); + + /** + * 修改预支付 + * + * @param usersPayBefor 预支付 + * @return 结果 + */ + public int updateUsersPayBefor(UsersPayBefor usersPayBefor); + + /** + * 批量删除预支付 + * + * @param ids 需要删除的预支付主键集合 + * @return 结果 + */ + public int deleteUsersPayBeforByIds(Long[] ids); + + /** + * 删除预支付信息 + * + * @param id 预支付主键 + * @return 结果 + */ + public int deleteUsersPayBeforById(Long id); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceCateServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceCateServiceImpl.java index 3aa0427..7cbf1bf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceCateServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ServiceCateServiceImpl.java @@ -35,6 +35,26 @@ public class ServiceCateServiceImpl implements IServiceCateService public List selectServiceCateCiKaList(){ return serviceCateMapper.selectServiceCateCiKaList(); } + + + public List selectServiceCatepintuanList(){ + return serviceCateMapper.selectServiceCatepintuanList(); + } + + + + + public List selectServiceCateMiaoshaList(){ + return serviceCateMapper.selectServiceCateMiaoshaList(); + } + + + + public List selectServiceCateBaojiaList(){ + return serviceCateMapper.selectServiceCateBaojiaList(); + } + + /** * 查询服务分类列表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserGroupBuyingServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserGroupBuyingServiceImpl.java index 9dac2aa..a75b896 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserGroupBuyingServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserGroupBuyingServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service.impl; import java.util.List; +import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.UserGroupBuyingMapper; @@ -90,4 +92,14 @@ public class UserGroupBuyingServiceImpl implements IUserGroupBuyingService { return userGroupBuyingMapper.deleteUserGroupBuyingById(id); } + + /** + * 分组查询,返回name和image为字符串数组,按product_id和orderid分组 + * @param productId 产品ID,可为null + * @return List> + */ + @Override + public List> selectGroupBuyingGroupByProductAndOrder(Integer productId) { + return userGroupBuyingMapper.selectGroupBuyingGroupByProductAndOrder(productId); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsersPayBeforServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsersPayBeforServiceImpl.java new file mode 100644 index 0000000..64a289f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsersPayBeforServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.UsersPayBeforMapper; +import com.ruoyi.system.domain.UsersPayBefor; +import com.ruoyi.system.service.IUsersPayBeforService; + +/** + * 预支付Service业务层处理 + * + * @author ruoyi + * @date 2025-07-11 + */ +@Service +public class UsersPayBeforServiceImpl implements IUsersPayBeforService +{ + @Autowired + private UsersPayBeforMapper usersPayBeforMapper; + + /** + * 查询预支付 + * + * @param id 预支付主键 + * @return 预支付 + */ + @Override + public UsersPayBefor selectUsersPayBeforById(Long id) + { + return usersPayBeforMapper.selectUsersPayBeforById(id); + } + + /** + * 查询预支付列表 + * + * @param usersPayBefor 预支付 + * @return 预支付 + */ + @Override + public List selectUsersPayBeforList(UsersPayBefor usersPayBefor) + { + return usersPayBeforMapper.selectUsersPayBeforList(usersPayBefor); + } + + /** + * 新增预支付 + * + * @param usersPayBefor 预支付 + * @return 结果 + */ + @Override + public int insertUsersPayBefor(UsersPayBefor usersPayBefor) + { + return usersPayBeforMapper.insertUsersPayBefor(usersPayBefor); + } + + /** + * 修改预支付 + * + * @param usersPayBefor 预支付 + * @return 结果 + */ + @Override + public int updateUsersPayBefor(UsersPayBefor usersPayBefor) + { + return usersPayBeforMapper.updateUsersPayBefor(usersPayBefor); + } + + /** + * 批量删除预支付 + * + * @param ids 需要删除的预支付主键 + * @return 结果 + */ + @Override + public int deleteUsersPayBeforByIds(Long[] ids) + { + return usersPayBeforMapper.deleteUsersPayBeforByIds(ids); + } + + /** + * 删除预支付信息 + * + * @param id 预支付主键 + * @return 结果 + */ + @Override + public int deleteUsersPayBeforById(Long id) + { + return usersPayBeforMapper.deleteUsersPayBeforById(id); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml index 014a7ca..63dd615 100644 --- a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml @@ -342,7 +342,7 @@ deleted_at, - file_data = #{fileData}, + file_data, created_at, updated_at diff --git a/ruoyi-system/src/main/resources/mapper/system/ServiceCateMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ServiceCateMapper.xml index c36b70b..9bac7cd 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ServiceCateMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ServiceCateMapper.xml @@ -39,6 +39,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by parent_id ASC, sort ASC + + + + + + + + + + + @@ -53,6 +55,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" transaction_id, paytype, product_id, + image, + paystatus, + created_at, updated_at @@ -68,6 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{transactionId}, #{paytype}, #{productId}, + #{image}, + #{paystatus}, NOW(), NOW() @@ -78,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" orderid = #{orderid}, uid = #{uid}, + image = #{image}, money = #{money}, status = #{status}, deduction = #{deduction}, @@ -86,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" transaction_id = #{transactionId}, paytype = #{paytype}, product_id = #{productId}, + paystatus = #{paystatus}, updated_at = NOW(), where id = #{id} @@ -101,4 +110,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/UserSecondaryCardMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UserSecondaryCardMapper.xml index ed05015..a9a503e 100644 --- a/ruoyi-system/src/main/resources/mapper/system/UserSecondaryCardMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/UserSecondaryCardMapper.xml @@ -18,12 +18,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + - select id, orderid, title, goodsids, show_money, real_money, introduction,showimage, status, creattime, created_at, updated_at, type, num, allnum from user_secondary_card + select id, orderid, title, goodsids, show_money, real_money, carouselImage,introduction,showimage, status, creattime, created_at, updated_at, type, num, allnum from user_secondary_card - where id = #{id} diff --git a/ruoyi-system/src/main/resources/mapper/system/UsersMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UsersMapper.xml index 07be350..df4eace 100644 --- a/ruoyi-system/src/main/resources/mapper/system/UsersMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/UsersMapper.xml @@ -40,7 +40,6 @@ - diff --git a/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml new file mode 100644 index 0000000..ecc551d --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/UsersPayBeforMapper.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, uid, paytype, wxmoney, yemoney, allmoney,membermoney, shopmoney, servicemoney, couponid, couponmoney, mtcode, mtmoney, type, orderid, oid, status, paytime, paycode from users_pay_befor + + + + + + + + insert into users_pay_befor + + uid, + paytype, + wxmoney, + yemoney, + membermoney, + shopmoney, + servicemoney, + couponid, + couponmoney, + mtcode, + mtmoney, + type, + orderid, + oid, + status, + paytime, + paycode, + allmoney, + + + + + #{uid}, + #{paytype}, + #{wxmoney}, + #{yemoney}, + #{membermoney}, + #{shopmoney}, + #{servicemoney}, + #{couponid}, + #{couponmoney}, + #{mtcode}, + #{mtmoney}, + #{type}, + #{orderid}, + #{oid}, + #{status}, + #{paytime}, + #{paycode}, + #{allmoney}, + + + + + + update users_pay_befor + + uid = #{uid}, + paytype = #{paytype}, + wxmoney = #{wxmoney}, + yemoney = #{yemoney}, + membermoney = #{membermoney}, + shopmoney = #{shopmoney}, + servicemoney = #{servicemoney}, + couponid = #{couponid}, + couponmoney = #{couponmoney}, + mtcode = #{mtcode}, + mtmoney = #{mtmoney}, + type = #{type}, + orderid = #{orderid}, + oid = #{oid}, + status = #{status}, + paytime = #{paytime}, + paycode = #{paycode}, + allmoney = #{allmoney}, + + + where id = #{id} + + + + delete from users_pay_befor where id = #{id} + + + + delete from users_pay_befor where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-ui/src/components/ImageUpload/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue index 9218a7d..f35ca68 100644 --- a/ruoyi-ui/src/components/ImageUpload/index.vue +++ b/ruoyi-ui/src/components/ImageUpload/index.vue @@ -115,7 +115,7 @@ export default { onEnd: (evt) => { const movedItem = this.fileList.splice(evt.oldIndex, 1)[0] this.fileList.splice(evt.newIndex, 0, movedItem) - this.$emit("input", this.listToString(this.fileList)) + this.$emit("input", this.fileList.map(f => this.getPureUrl(f.url))) } }) }) @@ -226,7 +226,7 @@ export default { const findex = this.fileList.map(f => f.name).indexOf(file.name) if (findex > -1) { this.fileList.splice(findex, 1) - this.$emit("input", this.listToString(this.fileList)) + this.$emit("input", this.fileList.map(f => this.getPureUrl(f.url))) } }, // 上传失败 @@ -240,7 +240,7 @@ export default { this.fileList = this.fileList.concat(this.uploadList) this.uploadList = [] this.number = 0 - this.$emit("input", this.listToString(this.fileList)) + this.$emit("input", this.fileList.map(f => this.getPureUrl(f.url))) this.$modal.closeLoading() } }, @@ -265,6 +265,17 @@ export default { } } return strs != '' ? strs.substr(0, strs.length - 1) : '' + }, + // 去除baseUrl和/dev-api前缀,返回纯相对路径或外链 + getPureUrl(url) { + if (!url) return ''; + if (url.startsWith(this.baseUrl)) { + return url.replace(this.baseUrl, ""); + } + if (url.startsWith("/dev-api")) { + return url.replace("/dev-api", ""); + } + return url; } } } diff --git a/ruoyi-ui/src/views/system/AdvImg/index.vue b/ruoyi-ui/src/views/system/AdvImg/index.vue index 101c865..a38f8bb 100644 --- a/ruoyi-ui/src/views/system/AdvImg/index.vue +++ b/ruoyi-ui/src/views/system/AdvImg/index.vue @@ -149,6 +149,9 @@ 首页宣传 积分商城 商城轮播 + 次卡 + 秒杀 + 拼团 diff --git a/ruoyi-ui/src/views/system/ServiceGoods/index.vue b/ruoyi-ui/src/views/system/ServiceGoods/index.vue index 94c73fd..357ebf6 100644 --- a/ruoyi-ui/src/views/system/ServiceGoods/index.vue +++ b/ruoyi-ui/src/views/system/ServiceGoods/index.vue @@ -237,12 +237,12 @@ - + - + - + @@ -188,7 +197,7 @@ - + - - + + + + + + { this.form = response.data + // 主图showimage处理 + if (this.form.showimage) { + if (Array.isArray(this.form.showimage)) { + this.form.showimage = this.form.showimage.length > 0 ? this.form.showimage[0] : ''; + } else if (typeof this.form.showimage === 'string') { + // 保持字符串 + } else if (this.form.showimage && this.form.showimage.url) { + this.form.showimage = this.form.showimage.url; + } + } else { + this.form.showimage = ''; + } + // 轮播图处理为数组,兼容字符串和数组 + if (this.form.carouselImage) { + try { + const arr = JSON.parse(this.form.carouselImage) + if (Array.isArray(arr)) { + this.form.carouselImage = arr.map(item => { + if (typeof item === 'string') return item; + if (item && item.url) return item.url; + return ''; + }).filter(Boolean); + } else { + this.form.carouselImage = [] + } + } catch (e) { + this.form.carouselImage = [] + } + } else { + this.form.carouselImage = [] + } + // 展示图片处理为数组,兼容对象数组和字符串数组 + if (this.form.showimage) { + try { + const arr = JSON.parse(this.form.showimage) + if (Array.isArray(arr)) { + this.form.showimage = arr.map(item => { + if (typeof item === 'string') return item; + if (item && item.url) return item.url; + return ''; + }).filter(Boolean); + } else { + this.form.showimage = [] + } + } catch (e) { + this.form.showimage = [] + } + } else { + this.form.showimage = [] + } // 兼容后端返回goodsids为JSON字符串数组或逗号分隔字符串,全部转为字符串数组 if (this.form.goodsids) { if (typeof this.form.goodsids === 'string') { @@ -480,8 +554,31 @@ export default { submitForm() { this.$refs["form"].validate(valid => { if (valid) { - // 提交前将goodsids转为JSON字符串数组 - const submitForm = { ...this.form, goodsids: Array.isArray(this.form.goodsids) ? JSON.stringify(this.form.goodsids.map(String)) : this.form.goodsids } + // 主图(showimage)只允许一张,取第一个 + let showimageVal = ''; + if (Array.isArray(this.form.showimage)) { + showimageVal = this.form.showimage.length > 0 ? this.form.showimage[0] : ''; + } else if (typeof this.form.showimage === 'string') { + showimageVal = this.form.showimage; + } else if (this.form.showimage && this.form.showimage.url) { + showimageVal = this.form.showimage.url; + } + // 处理轮播图为URL数组 + let carouselArr = []; + if (Array.isArray(this.form.carouselImage)) { + carouselArr = this.form.carouselImage.map(item => { + if (typeof item === 'string') return item; + if (item && item.url) return item.url; + return ''; + }).filter(Boolean); + } + + const submitForm = { + ...this.form, + showimage: showimageVal, + carouselImage: JSON.stringify(carouselArr), + goodsids: Array.isArray(this.form.goodsids) ? JSON.stringify(this.form.goodsids.map(String)) : this.form.goodsids + } if (this.form.id != null) { updateUserSecondaryCard(submitForm).then(response => { this.$modal.msgSuccess("修改成功")