acdrOrders = orderService.lambdaQuery()
+ .eq(AcdrOrder::getPersonalServiceUserId, AuthApi.getLoginIdAsLong())
+ .and(wrapper ->
+ wrapper.eq(AcdrOrder::getState, OrderState.待接单)
+ .or().eq(AcdrOrder::getState, OrderState.已接单))
.list();
- var maps = orders.stream().map(orderService::orderInfo).toList();
- return GlobalResponse.success("获取订阅用户信息成功!", maps);
+ var maps = acdrOrders.stream().map(orderService::orderInfo).toList();
+ return GlobalResponse.success("获取当前用户手中所有订单成功!", maps);
}
}
diff --git a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/entity/Order.java b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/entity/AcdrOrder.java
similarity index 90%
rename from yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/entity/Order.java
rename to yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/entity/AcdrOrder.java
index 3de1d87..3c30f02 100644
--- a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/entity/Order.java
+++ b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/entity/AcdrOrder.java
@@ -12,9 +12,6 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import cn.yskj.linghe.module.acdr.controller.app.common.ExtendEntity;
-import cn.yskj.linghe.module.acdr.controller.app.order.orderenum.OrderState;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.*;
@@ -22,7 +19,6 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
-import org.springframework.format.annotation.DateTimeFormat;
/**
*
@@ -38,7 +34,7 @@ import org.springframework.format.annotation.DateTimeFormat;
@Accessors(chain = true)
@TableName("acdr_order")
@ApiModel(value = "Order对象", description = "订单实体类")
-public class Order extends ExtendEntity implements Serializable {
+public class AcdrOrder extends ExtendEntity implements Serializable {
private static final long serialVersionUID = 1L;
@@ -54,8 +50,6 @@ public class Order extends ExtendEntity implements Serializable {
@ApiModelProperty("预约时间")
@TableField("reservation_time")
@NotNull(message = "预约时间不能为空")
- @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime reservationTime;
@ApiModelProperty("服务的小时")
@@ -65,6 +59,8 @@ public class Order extends ExtendEntity implements Serializable {
@Max(value = 12, message = "服务的小时数不能大于12")
private Long serviceHours;
+ private LocalDateTime expireTime;
+
@ApiModelProperty("被预约的服务主键")
@TableField("personal_service_id")
@NotNull(message = "预约服务ID不能为空")
@@ -133,4 +129,7 @@ public class Order extends ExtendEntity implements Serializable {
@TableField("order_error")
private int orderError;
+ @TableField("platform_order_id")
+ private Long platformOrderId;
+
}
diff --git a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/mapper/AppOrderMapper.java b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/mapper/AppOrderMapper.java
index 95941cf..92deadb 100644
--- a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/mapper/AppOrderMapper.java
+++ b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/mapper/AppOrderMapper.java
@@ -1,6 +1,6 @@
package cn.yskj.linghe.module.acdr.controller.app.order.mapper;
-import cn.yskj.linghe.module.acdr.controller.app.order.entity.Order;
+import cn.yskj.linghe.module.acdr.controller.app.order.entity.AcdrOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2024-08-15
*/
@Mapper
-public interface AppOrderMapper extends BaseMapper {
+public interface AppOrderMapper extends BaseMapper {
}
diff --git a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/scheduling/OrderScheduledTasks.java b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/scheduling/OrderScheduledTasks.java
index 937cda9..0a42f53 100644
--- a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/scheduling/OrderScheduledTasks.java
+++ b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/scheduling/OrderScheduledTasks.java
@@ -1,6 +1,6 @@
package cn.yskj.linghe.module.acdr.controller.app.order.scheduling;
-import cn.yskj.linghe.module.acdr.controller.app.order.service.OrderService;
+import cn.yskj.linghe.module.acdr.controller.app.order.service.AcdrOrderService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
public class OrderScheduledTasks {
@Resource
- private OrderService orderService;
+ private AcdrOrderService orderService;
// 每隔5秒钟执行一次,在上一次执行完之后,等五秒再次执行
@Scheduled(fixedDelay = 5000)
diff --git a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/OrderService.java b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/AcdrOrderService.java
similarity index 56%
rename from yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/OrderService.java
rename to yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/AcdrOrderService.java
index 081aebf..9273034 100644
--- a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/OrderService.java
+++ b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/AcdrOrderService.java
@@ -1,7 +1,6 @@
package cn.yskj.linghe.module.acdr.controller.app.order.service;
-import cn.yskj.linghe.module.acdr.controller.app.order.entity.Order;
-import cn.yskj.linghe.module.acdr.controller.app.order.entity.Order;
+import cn.yskj.linghe.module.acdr.controller.app.order.entity.AcdrOrder;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
@@ -14,12 +13,12 @@ import java.util.Map;
* @author 林河
* @since 2024-08-15
*/
-public interface OrderService extends IService {
+public interface AcdrOrderService extends IService {
- Map orderInfo(Order order);
+ Map orderInfo(AcdrOrder acdrOrder);
// 判断该宠托师是否已经被预约
- boolean isBooking(Order order);
+ boolean isBooking(AcdrOrder acdrOrder);
// 检查订单状态并且更新
boolean checkStateAndUpdate();
diff --git a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/impl/OrderServiceImpl.java b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/impl/OrderServiceImpl.java
index d131c18..e830029 100644
--- a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/impl/OrderServiceImpl.java
+++ b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/order/service/impl/OrderServiceImpl.java
@@ -3,7 +3,7 @@ package cn.yskj.linghe.module.acdr.controller.app.order.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.yskj.linghe.module.acdr.controller.app.address.entity.ChinaAddress;
import cn.yskj.linghe.module.acdr.controller.app.address.service.ChinaAddressService;
-import cn.yskj.linghe.module.acdr.controller.app.order.entity.Order;
+import cn.yskj.linghe.module.acdr.controller.app.order.entity.AcdrOrder;
import cn.yskj.linghe.module.acdr.controller.app.order.orderenum.OrderState;
import cn.yskj.linghe.module.acdr.controller.app.personal.entity.PersonalService;
import cn.yskj.linghe.module.acdr.controller.app.personal.service.PersonalServiceService;
@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.yskj.linghe.module.acdr.controller.app.order.mapper.AppOrderMapper;
-import cn.yskj.linghe.module.acdr.controller.app.order.service.OrderService;
+import cn.yskj.linghe.module.acdr.controller.app.order.service.AcdrOrderService;
import cn.yskj.linghe.module.acdr.controller.app.pet.service.PetInfoService;
import cn.yskj.linghe.module.acdr.controller.app.user.entity.Users;
import jakarta.annotation.Resource;
@@ -33,7 +33,7 @@ import java.util.Map;
*/
@Service
@Slf4j
-public class OrderServiceImpl extends ServiceImpl implements OrderService {
+public class OrderServiceImpl extends ServiceImpl implements AcdrOrderService {
@Resource
private ChinaAddressService addressService;
@@ -48,8 +48,8 @@ public class OrderServiceImpl extends ServiceImpl impleme
private PersonalServiceService personalServiceService;
@Override
- public Map orderInfo(Order order) {
- Map obj = BeanUtil.beanToMap(order);
+ public Map orderInfo(AcdrOrder acdrOrder) {
+ Map obj = BeanUtil.beanToMap(acdrOrder);
PetInfo pet = petInfoService.getById((Long) obj.get("pet"));
obj.put("pet", pet);
ChinaAddress address = addressService.getById((Long) obj.get("address"));
@@ -65,19 +65,19 @@ public class OrderServiceImpl extends ServiceImpl impleme
// 判断该宠托师是否已经被预约
@Override
- public boolean isBooking(Order order) {
+ public boolean isBooking(AcdrOrder acdrOrder) {
// 判断当前被预约用户是否有时间, 没有时间就返回相关错误信息
- var wrapper = new LambdaQueryWrapper();
- LocalDateTime rtInterval = order.getReservationTime();
- LocalDateTime addAfterTime = rtInterval.plusHours(order.getServiceHours());
- wrapper.eq(Order::getPersonalServiceUserId, order.getPersonalServiceUserId())
+ var wrapper = new LambdaQueryWrapper();
+ LocalDateTime rtInterval = acdrOrder.getReservationTime();
+ LocalDateTime addAfterTime = rtInterval.plusHours(acdrOrder.getServiceHours());
+ wrapper.eq(AcdrOrder::getPersonalServiceUserId, acdrOrder.getPersonalServiceUserId())
// 判断当前订单状态
- .and(l -> l.ge(Order::getState, OrderState.已支付)
- .le(Order::getState, OrderState.已评价))
+ .and(l -> l.ge(AcdrOrder::getState, OrderState.已支付)
+ .le(AcdrOrder::getState, OrderState.已评价))
// 判断预约时间是否正确
- .and(l -> l.ge(Order::getReservationTime, order.getReservationTime())
- .le(Order::getReservationTime, addAfterTime));
- Order one = this.getOne(wrapper);
+ .and(l -> l.ge(AcdrOrder::getReservationTime, acdrOrder.getReservationTime())
+ .le(AcdrOrder::getReservationTime, addAfterTime));
+ AcdrOrder one = this.getOne(wrapper);
return one != null;
}
@@ -88,9 +88,9 @@ public class OrderServiceImpl extends ServiceImpl impleme
// 这一块逻辑是判断订单是否支付
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
- LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>();
- updateWrapper.set(Order::getState, OrderState.已取消)
- .eq(Order::getState, OrderState.待支付)
+ LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>();
+ updateWrapper.set(AcdrOrder::getState, OrderState.已取消)
+ .eq(AcdrOrder::getState, OrderState.待支付)
// 判断当前时间是不是大于订单过期时间
.apply("DATE_ADD(create_time, INTERVAL 15 MINUTE) < {0}", now);
// 执行更新操作
@@ -99,9 +99,9 @@ public class OrderServiceImpl extends ServiceImpl impleme
// 判断宠托师是否接单
// 这里是处理如果没有被接单的情况(10小时之内)
- LambdaUpdateWrapper payE = new LambdaUpdateWrapper<>();
- payE.set(Order::getState, OrderState.已超时)
- .eq(Order::getState, OrderState.待接单)
+ LambdaUpdateWrapper payE = new LambdaUpdateWrapper<>();
+ payE.set(AcdrOrder::getState, OrderState.已超时)
+ .eq(AcdrOrder::getState, OrderState.待接单)
.apply("DATE_ADD(create_time, INTERVAL 10 HOUR) < {0}", now);
boolean payEUpdate = this.update(null, payE);
//if (!payEUpdate) log.info("订单接单状态更新为空");
@@ -109,18 +109,18 @@ public class OrderServiceImpl extends ServiceImpl impleme
// 判断购买的订单(服务劵)是否过期
// 判断宠托师是否在指定的时间内服务了
// 如果超过了服务时间
- LambdaUpdateWrapper timeIf = new LambdaUpdateWrapper<>();
- timeIf.set(Order::getState, OrderState.已超时)
- .eq(Order::getState, OrderState.已接单)
+ LambdaUpdateWrapper timeIf = new LambdaUpdateWrapper<>();
+ timeIf.set(AcdrOrder::getState, OrderState.已超时)
+ .eq(AcdrOrder::getState, OrderState.已接单)
.apply("reservation_time < {0}", now);
boolean timeIfUpdate = this.update(null, timeIf);
//if (!timeIfUpdate) log.info("订单服务时间更新为空");
// 该订单如果一直在执行中(超过了24个小时)则触发程序保护机制强制让该订单完结,并缓存该订单
- LambdaUpdateWrapper execIf = new LambdaUpdateWrapper<>();
- execIf.set(Order::getFinishTime, now)
- .set(Order::getState, OrderState.待分润)
- .eq(Order::getState, OrderState.已接单)
+ LambdaUpdateWrapper execIf = new LambdaUpdateWrapper<>();
+ execIf.set(AcdrOrder::getFinishTime, now)
+ .set(AcdrOrder::getState, OrderState.待分润)
+ .eq(AcdrOrder::getState, OrderState.已接单)
.apply("DATE_ADD(reservation_time, INTERVAL 24 HOUR) < {0}", now);
boolean execIfUpdate = this.update(null, execIf);
//if (!execIfUpdate) log.error("已接单服务时间更新为空");
diff --git a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/personal/controller/PersonalServiceController.java b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/personal/controller/PersonalServiceController.java
index be7eae8..5c0b65f 100644
--- a/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/personal/controller/PersonalServiceController.java
+++ b/yskj-module-acdr/yskj-module-acdr-biz/src/main/java/cn/yskj/linghe/module/acdr/controller/app/personal/controller/PersonalServiceController.java
@@ -1,20 +1,12 @@
package cn.yskj.linghe.module.acdr.controller.app.personal.controller;
import cn.hutool.core.map.MapUtil;
-import cn.yskj.linghe.module.acdr.controller.app.address.service.ServiceAddressService;
-import cn.yskj.linghe.module.acdr.controller.app.personal.entity.PersonalService;
-import cn.yskj.linghe.module.acdr.controller.app.personal.service.PersonalServiceService;
-import cn.yskj.linghe.module.acdr.controller.app.pet.entity.PetInfo;
-import cn.yskj.linghe.module.acdr.controller.app.pet.entity.PetSpecialistCertificate;
-import com.alibaba.fastjson2.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import cn.hutool.core.util.StrUtil;
import cn.yskj.linghe.module.acdr.common.response.GlobalResponse;
import cn.yskj.linghe.module.acdr.controller.app.address.service.ServiceAddressService;
-import cn.yskj.linghe.module.acdr.controller.app.order.entity.Order;
+import cn.yskj.linghe.module.acdr.controller.app.order.entity.AcdrOrder;
import cn.yskj.linghe.module.acdr.controller.app.order.orderenum.OrderState;
-import cn.yskj.linghe.module.acdr.controller.app.order.service.OrderService;
+import cn.yskj.linghe.module.acdr.controller.app.order.service.AcdrOrderService;
import cn.yskj.linghe.module.acdr.controller.app.personal.entity.PersonalService;
import cn.yskj.linghe.module.acdr.controller.app.personal.service.PersonalServiceService;
import cn.yskj.linghe.module.acdr.controller.app.pet.entity.PetInfo;
@@ -23,6 +15,10 @@ import cn.yskj.linghe.module.acdr.controller.app.pet.service.PetInfoService;
import cn.yskj.linghe.module.acdr.controller.app.pet.service.PetSpecialistCertificateService;
import cn.yskj.linghe.module.acdr.controller.app.user.entity.Users;
import cn.yskj.linghe.module.acdr.controller.app.user.service.UsersService;
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import io.swagger.annotations.*;
import jakarta.annotation.Resource;
import jakarta.validation.groups.Default;
@@ -68,7 +64,7 @@ public class PersonalServiceController {
private PetSpecialistCertificateService pscs;
@Resource
- private OrderService orderService;
+ private AcdrOrderService orderService;
@PostMapping("/push")
@@ -160,29 +156,29 @@ public class PersonalServiceController {
* @author linghe
* 展示宠物个人服务详细信息
* 返回如下数据:
- * // 将这些数据都打散装配到Map当中
- * var map = MapUtil.builder()
- * .put("serviceId", p.getId())
- * .put("serviceName", p.getServiceName())
- * .put("bgUrl", p.getUrl())
- * .put("description", p.getDescription())
- * .put("serviceType", p.getType())
- * .put("latitude", p.getLatitude())
- * .put("longitude", p.getLongitude())
- * .put("address", p.getAddress())
- * .put("serviceState", p.getState())
- * .put("createTime", p.getCreateTime())
- * .put("updateTime", p.getUpdateTime())
- * .put("price", p.getPrice())
- * .put("serviceUserId", p.getUserId()) // 服务者ID
- * .put("userName", user.getNickname())
- * .put("userAvatar", user.getAvatar())
- * .put("pets", pets)
- * // 添加认证时间
- * .put("certificationTime", calculateTimeDifference(LocalDateTime.now(), psc.getCreateTime()))
- * .put("serviceNumber", psc.getServiceNumber())
- * .put("comments", comments)
- * .map();
+ * // 将这些数据都打散装配到Map当中
+ * var map = MapUtil.builder()
+ * .put("serviceId", p.getId())
+ * .put("serviceName", p.getServiceName())
+ * .put("bgUrl", p.getUrl())
+ * .put("description", p.getDescription())
+ * .put("serviceType", p.getType())
+ * .put("latitude", p.getLatitude())
+ * .put("longitude", p.getLongitude())
+ * .put("address", p.getAddress())
+ * .put("serviceState", p.getState())
+ * .put("createTime", p.getCreateTime())
+ * .put("updateTime", p.getUpdateTime())
+ * .put("price", p.getPrice())
+ * .put("serviceUserId", p.getUserId()) // 服务者ID
+ * .put("userName", user.getNickname())
+ * .put("userAvatar", user.getAvatar())
+ * .put("pets", pets)
+ * // 添加认证时间
+ * .put("certificationTime", calculateTimeDifference(LocalDateTime.now(), psc.getCreateTime()))
+ * .put("serviceNumber", psc.getServiceNumber())
+ * .put("comments", comments)
+ * .map();
*/
@GetMapping("/service/{id}")
public GlobalResponse