This commit is contained in:
aiShuiJiaoDeXioShou 2024-10-01 09:11:14 +08:00
parent 2c7e87daa7
commit eeed81935a
17 changed files with 249 additions and 229 deletions

View File

@ -100,10 +100,6 @@
<groupId>cn.yskj.dev</groupId>
<artifactId>yskj-spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>cn.yskj.dev</groupId>
<artifactId>yskj-spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,7 @@
package cn.yskj.linghe.module.acdr.config;
public class Config {
public static Long PAY_APP_NO = 9L;
}

View File

@ -187,5 +187,11 @@
<version>2.1.0-snapshot</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.yskj.dev</groupId>
<artifactId>yskj-module-pay-api</artifactId>
<version>2.1.0-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -47,7 +47,9 @@ public class ChinaAddressController {
@ApiOperation(value = "中国地址表分页列表", response = ChinaAddress.class)
@PostMapping(value = "/page")
public GlobalResponse<ChinaAddress> list(GlobalResponse<ChinaAddress> page) {
return service.lambdaQuery().page(page);
return service.lambdaQuery()
.eq(ChinaAddress::getUserId, AuthApi.getLoginIdAsLong())
.page(page);
}
/**

View File

@ -1,28 +1,29 @@
package cn.yskj.linghe.module.acdr.controller.app.order.controller;
import cn.yskj.linghe.module.acdr.api.AuthApi;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.yskj.linghe.framework.common.util.servlet.ServletUtils;
import cn.yskj.linghe.module.acdr.api.AuthApi;
import cn.yskj.linghe.module.acdr.common.response.GlobalResponse;
import cn.yskj.linghe.module.acdr.config.Config;
import cn.yskj.linghe.module.acdr.controller.app.address.service.ChinaAddressService;
import cn.yskj.linghe.module.acdr.controller.app.config.service.ServiceConfig;
import cn.yskj.linghe.module.acdr.controller.app.file.entity.FileMap;
import cn.yskj.linghe.module.acdr.controller.app.file.service.FileMapService;
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.entity.PayInfo;
import cn.yskj.linghe.module.acdr.controller.app.order.entity.QrCode;
import cn.yskj.linghe.module.acdr.controller.app.order.mapper.QrCodeMapper;
import cn.yskj.linghe.module.acdr.controller.app.order.orderenum.OrderState;
import cn.yskj.linghe.module.acdr.controller.app.order.orderenum.PayType;
import cn.yskj.linghe.module.acdr.controller.app.order.service.OrderService;
import cn.yskj.linghe.module.acdr.common.response.GlobalResponse;
import cn.yskj.linghe.module.acdr.controller.app.order.service.AcdrOrderService;
import cn.yskj.linghe.module.acdr.controller.app.order.service.PayInfoService;
import cn.yskj.linghe.module.acdr.controller.app.personal.service.PersonalServiceService;
import cn.yskj.linghe.module.acdr.controller.app.pet.service.PetInfoService;
import cn.yskj.linghe.module.acdr.controller.app.user.service.UsersService;
import cn.yskj.linghe.module.pay.api.order.PayOrderApi;
import cn.yskj.linghe.module.pay.api.order.dto.PayOrderCreateReqDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
@ -30,7 +31,6 @@ import jakarta.validation.groups.Default;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -38,10 +38,9 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -58,7 +57,7 @@ import java.util.Map;
@RequestMapping("/order")
@Validated
@Slf4j
public class OrderController {
public class AcdrOrderController {
@Resource
private FileMapService fileService;
@ -79,7 +78,7 @@ public class OrderController {
private PersonalServiceService personalServiceService;
@Resource
private OrderService orderService;
private AcdrOrderService orderService;
@Resource
private PayInfoService payService;
@ -90,7 +89,10 @@ public class OrderController {
@Resource
private QrCodeMapper qrCodeMapper;
@ApiOperation(value = "详情", response = Order.class)
@Resource
private PayOrderApi payOrderApi;
@ApiOperation(value = "详情", response = AcdrOrder.class)
@GetMapping(value = "/info/{id}")
public GlobalResponse<Map<String, Object>> info(
@PathVariable Long id) {
@ -101,44 +103,44 @@ public class OrderController {
@ApiOperation(value = "订单创建,服务预约")
@PostMapping(value = "/create")
@Transactional(rollbackFor = Exception.class)
public GlobalResponse<Map<Object, Object>> create(
public GlobalResponse<AcdrOrder> create(
@Validated({PostMapping.class, Default.class})
@RequestBody Order order) {
@RequestBody AcdrOrder acdrOrder) {
// 判断当前被预约用户是否有时间, 没有时间就返回相关错误信息
if (orderService.isBooking(order)) {
if (orderService.isBooking(acdrOrder)) {
return GlobalResponse.failure("该宠托师已经有预约时间了");
}
// 不能让顾客预约到自己创建的服务
if (order.getPersonalServiceUserId().equals(AuthApi.getLoginIdAsLong())) {
if (acdrOrder.getPersonalServiceUserId().equals(AuthApi.getLoginIdAsLong())) {
return GlobalResponse.failure("你不能预约自己创建的服务!");
}
order.setUserId(AuthApi.getLoginIdAsLong())
acdrOrder.setUserId(AuthApi.getLoginIdAsLong())
.setState(OrderState.待支付);
// 判断创建订单是否成功
boolean createOrder = orderService.save(order);
var map = new HashMap<String, Serializable>(
Map.of(
"appId", appId,
"provider", "wxpay",
"timeStamp", DateUtil.current(),
"nonceStr", RandomUtil.randomString(32),
"package", "prepay_id=WXPay",
"signType", "MD5"
)
);
String keyvalue = MapUtil.join(map, "&", "=").toUpperCase();
map.put("paySign", DigestUtils.md5DigestAsHex(keyvalue.getBytes(StandardCharsets.UTF_8)).toUpperCase());
boolean createOrder = orderService.save(acdrOrder);
if (!createOrder) {
return GlobalResponse.failure("创建订单失败");
}
// 如果创建订单成功就把数据记录在后台管理系统里面
PayOrderCreateReqDTO dto = new PayOrderCreateReqDTO();
BigDecimal money = acdrOrder.getPrice().multiply(new BigDecimal("100"));
dto.setAppId(Config.PAY_APP_NO)
.setPrice(money.intValue())
.setSubject("宠物师服务")
.setBody("宠物是服务")
.setMerchantOrderId(String.valueOf(acdrOrder.getId()))
.setUserIp(ServletUtils.getClientIP())
.setExpireTime(acdrOrder.getExpireTime());
Long platformOrderId = payOrderApi.createOrder(dto);
acdrOrder.setPlatformOrderId(platformOrderId);
orderService.updateById(acdrOrder);
// 创建订单成功
return GlobalResponse.success("新增成功!", MapUtil.ofEntries(
MapUtil.entry("payData", map),
MapUtil.entry("orderData", order)
));
return GlobalResponse.success("新增成功!", acdrOrder);
}
@ApiOperation(value = "订单支付")
@ -147,29 +149,31 @@ public class OrderController {
public GlobalResponse<String> pay(@PathVariable Long orderId,
// 这个是发送支付的信息过来
@RequestBody Map<String, Object> payData) {
// 获取该支付的订单号
Order order = orderService.getById(orderId);
AcdrOrder acdrOrder = orderService.getById(orderId);
// 判断订单的状态如果不为等待支付则返回错误
if (!order.getState().equals(OrderState.待支付)) {
return GlobalResponse.failure("您无法支付已经取消或者已经支付的订单");
if (!acdrOrder.getState().equals(OrderState.待支付)) {
throw new RuntimeException("您无法支付已经取消或者已经支付的订单");
}
if (order.getState().equals(OrderState.已取消)) {
return GlobalResponse.failure("该订单已取消请重新生成");
}
order.setState(OrderState.已支付)
acdrOrder.setState(OrderState.已支付)
.setIsPay(true);
boolean update = orderService.updateById(order);
if (update) {
return GlobalResponse.failure("支付失败!");
boolean update = orderService.updateById(acdrOrder);
if (!update) {
throw new RuntimeException("订单支付失败");
}
// 保存每一笔支付日志
payService.save(new PayInfo()
.setAmount(order.getPrice())
.setPaymentOrder(order.getId())
.setPayee(order.getPersonalServiceUserId())
.setAmount(acdrOrder.getPrice())
.setPaymentOrder(acdrOrder.getId())
.setPayee(acdrOrder.getPersonalServiceUserId())
.setPaymentInfo("宠托师服务支付")
.setType(PayType.支出));
// TODO 这里应该编写逻辑通知宠托师用户已经支付了订单
acdrOrder.setState(OrderState.待接单);
// 更新数据状态
orderService.updateById(acdrOrder);
return GlobalResponse.success("订单支付成功!");
}
@ -183,31 +187,31 @@ public class OrderController {
public GlobalResponse<String> confirm(
@PathVariable Long orderId) throws IOException {
// 判断是否是自己的订单信息,如果不是则该用户没有权限确认订单信息
Order order = orderService.lambdaQuery()
.eq(Order::getPersonalServiceUserId, AuthApi.getLoginIdAsLong())
.eq(Order::getId, orderId).one();
if (order == null) {
AcdrOrder acdrOrder = orderService.lambdaQuery()
.eq(AcdrOrder::getPersonalServiceUserId, AuthApi.getLoginIdAsLong())
.eq(AcdrOrder::getId, orderId).one();
if (acdrOrder == null) {
return GlobalResponse.failure("该订单信息已失效或者不是属于您的预约订单!");
}
// 判断该订单是否过期
if (order.getState().equals(OrderState.已取消)) {
if (acdrOrder.getState().equals(OrderState.已取消)) {
return GlobalResponse.failure("该订单信息已过期!");
}
// 判断该订单是否已经被确定
if (order.getState().equals(OrderState.已接单)) {
if (acdrOrder.getState().equals(OrderState.已接单)) {
return GlobalResponse.failure("确定过的订单无法再次确定!");
}
// 判断该订单是否已经生成的二维码信息
if (!StrUtil.isBlank(order.getQrcode())) {
if (!StrUtil.isBlank(acdrOrder.getQrcode())) {
return GlobalResponse.failure("该订单已经确定过了!");
}
// 判断是否已经生成的二维码
order.setState(OrderState.已接单);
acdrOrder.setState(OrderState.已接单);
// 生成唯一ID
QrCode qrCode = new QrCode().setCreateTime(LocalDateTime.now())
.setServiceUserId(order.getPersonalServiceUserId())
.setExpiredTime(order.getReservationTime().plusHours(serviceConfig.getServiceExpiredTime()))
.setData(order.getId().toString())
.setServiceUserId(acdrOrder.getPersonalServiceUserId())
.setExpiredTime(acdrOrder.getReservationTime().plusHours(serviceConfig.getServiceExpiredTime()))
.setData(acdrOrder.getId().toString())
.setIsUse(false);
qrCodeMapper.insert(qrCode);
@ -221,8 +225,8 @@ public class OrderController {
qrCode.setImgUrl(file.getUrl());
qrCodeMapper.updateById(qrCode);
order.setQrcode(file.getUrl());
orderService.updateById(order);
acdrOrder.setQrcode(file.getUrl());
orderService.updateById(acdrOrder);
return GlobalResponse.success("确认客户预约成功!");
}
@ -246,21 +250,27 @@ public class OrderController {
}
// 获取订单信息
String orderId = qrCode.getData();
Order order = orderService.getById(orderId);
AcdrOrder acdrOrder = orderService.getById(orderId);
// 更新二维码状态
qrCode.setIsUse(true);
qrCodeMapper.updateById(qrCode);
// 更新订单状态
order.setState(OrderState.执行中);
orderService.updateById(order);
// 生成给宠托师的支付信息
acdrOrder.setState(OrderState.执行中);
orderService.updateById(acdrOrder);
// TODO 理论上这个到时间了才给分润的不过在这里就直接完成方便测试
// TODO 生成给宠托师的支付信息
PayInfo payInfo = new PayInfo()
.setUserId(AuthApi.getLoginIdAsLong())
.setType(PayType.收入)
.setPaymentOrder(order.getId())
.setPayee(order.getUserId())
.setAmount(order.getPrice());
.setPaymentOrder(acdrOrder.getId())
.setPayee(acdrOrder.getUserId())
.setAmount(acdrOrder.getPrice()
.subtract(acdrOrder.getPrice().multiply(new BigDecimal("0.1")))
.setScale(2, RoundingMode.UP)); // 设置小数位数并进一
payService.save(payInfo);
// 更新订单状态
acdrOrder.setState(OrderState.已完成);
orderService.updateById(acdrOrder);
return GlobalResponse.success("二维码扫描成功,该订单已完成!");
}
@ -277,20 +287,20 @@ public class OrderController {
public GlobalResponse<String> bookingCancel(@PathVariable Long orderId,
@RequestParam String shopRemark) {
Order order = orderService.lambdaQuery()
.eq(Order::getPersonalServiceUserId, AuthApi.getLoginIdAsLong())
.eq(Order::getId, orderId).one();
if (order == null) {
AcdrOrder acdrOrder = orderService.lambdaQuery()
.eq(AcdrOrder::getPersonalServiceUserId, AuthApi.getLoginIdAsLong())
.eq(AcdrOrder::getId, orderId).one();
if (acdrOrder == null) {
return GlobalResponse.failure("没有该订单信息!");
}
// 判断该订单是否过期
if (order.getState().equals(OrderState.已取消)) {
if (acdrOrder.getState().equals(OrderState.已取消)) {
return GlobalResponse.failure("该订单信息已过期!");
}
// 设置该订单状态为取消
order.setState(OrderState.被商家_宠托师取消)
acdrOrder.setState(OrderState.被商家_宠托师取消)
.setShopRemark(shopRemark);
orderService.updateById(order);
orderService.updateById(acdrOrder);
return GlobalResponse.success("取消客户预约成功!");
}
@ -304,19 +314,19 @@ public class OrderController {
@PostMapping(value = "/cancel/{orderId}")
@Transactional(rollbackFor = Exception.class)
public GlobalResponse<String> cancel(@PathVariable Long orderId) {
Order order = orderService.lambdaQuery()
.eq(Order::getUserId, AuthApi.getLoginIdAsLong())
.eq(Order::getId, orderId).one();
if (order == null) {
AcdrOrder acdrOrder = orderService.lambdaQuery()
.eq(AcdrOrder::getUserId, AuthApi.getLoginIdAsLong())
.eq(AcdrOrder::getId, orderId).one();
if (acdrOrder == null) {
return GlobalResponse.failure("没有该订单信息!");
}
// 判断该订单是否过期
if (order.getState().equals(OrderState.已取消)) {
if (acdrOrder.getState().equals(OrderState.已取消)) {
return GlobalResponse.failure("该订单信息已过期,或者已取消!");
}
// 设置该订单状态为取消
order.setState(OrderState.已取消);
orderService.updateById(order);
acdrOrder.setState(OrderState.已取消);
orderService.updateById(acdrOrder);
return GlobalResponse.success("取消客户预约成功!");
}
@ -329,17 +339,16 @@ public class OrderController {
@ApiOperation(value = "查询指定用户所有的订单信息")
@PostMapping("/query")
public GlobalResponse<Map<String, Object>> orders(
@RequestBody GlobalResponse<Order> page,
@RequestBody GlobalResponse<AcdrOrder> page,
@RequestParam String state) {
// 判断是否要查询全部的数据
boolean isAll = StrUtil.isBlank(state);
OrderState orderState = OrderState.valueOf(state);
// 这个接口只能查自己的订单信息
GlobalResponse<Order> res = orderService.lambdaQuery()
.eq(Order::getUserId, AuthApi.getLoginIdAsLong())
.eq(!isAll, Order::getState,
GlobalResponse<AcdrOrder> res = orderService.lambdaQuery()
.eq(AcdrOrder::getUserId, AuthApi.getLoginIdAsLong())
.eq(!isAll, AcdrOrder::getState,
isAll ? OrderState.待支付 : OrderState.valueOf(state))
// .ge(isAll, Order::getState, OrderState.WAIT_PAY)
// .le(isAll, Order::getState, OrderState.EVALUATED)
.page(page);
GlobalResponse<Map<String, Object>> response = new GlobalResponse<>();
response.setTotal(res.getTotal())
@ -363,19 +372,20 @@ public class OrderController {
/**
* 获取目前宠托师所有的订单信息
*
* @author 林河
*/
@ApiOperation(value = "查询指定用户所有的订单信息")
@PostMapping("/ptOrdersInfo")
public GlobalResponse<Map<String, Object>> ptOrdersInfo() {
List<Order> orders = orderService.lambdaQuery()
.eq(Order::getPersonalServiceUserId, AuthApi.getLoginIdAsLong())
.and(wrapper -> wrapper.eq(Order::getState, OrderState.已支付)
.or()
.eq(Order::getState, OrderState.已接单))
List<AcdrOrder> 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);
}
}

View File

@ -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;
/**
* <p>
@ -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;
}

View File

@ -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<Order> {
public interface AppOrderMapper extends BaseMapper<AcdrOrder> {
}

View File

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

View File

@ -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<Order> {
public interface AcdrOrderService extends IService<AcdrOrder> {
Map<String, Object> orderInfo(Order order);
Map<String, Object> orderInfo(AcdrOrder acdrOrder);
// 判断该宠托师是否已经被预约
boolean isBooking(Order order);
boolean isBooking(AcdrOrder acdrOrder);
// 检查订单状态并且更新
boolean checkStateAndUpdate();

View File

@ -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<AppOrderMapper, Order> implements OrderService {
public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AcdrOrder> implements AcdrOrderService {
@Resource
private ChinaAddressService addressService;
@ -48,8 +48,8 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, Order> impleme
private PersonalServiceService personalServiceService;
@Override
public Map<String, Object> orderInfo(Order order) {
Map<String, Object> obj = BeanUtil.beanToMap(order);
public Map<String, Object> orderInfo(AcdrOrder acdrOrder) {
Map<String, Object> 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<AppOrderMapper, Order> impleme
// 判断该宠托师是否已经被预约
@Override
public boolean isBooking(Order order) {
public boolean isBooking(AcdrOrder acdrOrder) {
// 判断当前被预约用户是否有时间, 没有时间就返回相关错误信息
var wrapper = new LambdaQueryWrapper<Order>();
LocalDateTime rtInterval = order.getReservationTime();
LocalDateTime addAfterTime = rtInterval.plusHours(order.getServiceHours());
wrapper.eq(Order::getPersonalServiceUserId, order.getPersonalServiceUserId())
var wrapper = new LambdaQueryWrapper<AcdrOrder>();
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<AppOrderMapper, Order> impleme
// 这一块逻辑是判断订单是否支付
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(Order::getState, OrderState.已取消)
.eq(Order::getState, OrderState.待支付)
LambdaUpdateWrapper<AcdrOrder> 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<AppOrderMapper, Order> impleme
// 判断宠托师是否接单
// 这里是处理如果没有被接单的情况(10小时之内)
LambdaUpdateWrapper<Order> payE = new LambdaUpdateWrapper<>();
payE.set(Order::getState, OrderState.已超时)
.eq(Order::getState, OrderState.待接单)
LambdaUpdateWrapper<AcdrOrder> 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<AppOrderMapper, Order> impleme
// 判断购买的订单(服务劵)是否过期
// 判断宠托师是否在指定的时间内服务了
// 如果超过了服务时间
LambdaUpdateWrapper<Order> timeIf = new LambdaUpdateWrapper<>();
timeIf.set(Order::getState, OrderState.已超时)
.eq(Order::getState, OrderState.已接单)
LambdaUpdateWrapper<AcdrOrder> 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<Order> execIf = new LambdaUpdateWrapper<>();
execIf.set(Order::getFinishTime, now)
.set(Order::getState, OrderState.待分润)
.eq(Order::getState, OrderState.已接单)
LambdaUpdateWrapper<AcdrOrder> 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("已接单服务时间更新为空");

View File

@ -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")
@ -214,32 +210,32 @@ public class PersonalServiceController {
// 获取该宠托师以往的订单评论信息, 只获取历史数据的前一条
// 获取服务次数
long commitNums = orderService.count(new LambdaQueryWrapper<Order>()
.eq(Order::getPersonalServiceUserId, userId)
.eq(Order::getState, OrderState.已评价)
.isNotNull(Order::getFeedback)
.isNotNull(Order::getStar));
long commitNums = orderService.count(new LambdaQueryWrapper<AcdrOrder>()
.eq(AcdrOrder::getPersonalServiceUserId, userId)
.eq(AcdrOrder::getState, OrderState.已评价)
.isNotNull(AcdrOrder::getFeedback)
.isNotNull(AcdrOrder::getStar));
// 获取之后获取该用户的评论信息
Order commentsOrder = null;
if(commitNums > 0) {
commentsOrder = orderService.lambdaQuery()
.eq(Order::getPersonalServiceUserId, userId)
.eq(Order::getState, OrderState.已评价)
.isNotNull(Order::getFeedback)
.isNotNull(Order::getStar)
.orderByDesc(Order::getStar)
.orderByDesc(Order::getCreateTime)
AcdrOrder commentsAcdrOrder = null;
if (commitNums > 0) {
commentsAcdrOrder = orderService.lambdaQuery()
.eq(AcdrOrder::getPersonalServiceUserId, userId)
.eq(AcdrOrder::getState, OrderState.已评价)
.isNotNull(AcdrOrder::getFeedback)
.isNotNull(AcdrOrder::getStar)
.orderByDesc(AcdrOrder::getStar)
.orderByDesc(AcdrOrder::getCreateTime)
.last("LIMIT 1")
.one();
}
Map<String, Object> comments = null;
if (commentsOrder != null) {
if (commentsAcdrOrder != null) {
comments = new HashMap<>();
Users users = usersService.getById(commentsOrder.getUserId());
comments.put("star", commentsOrder.getStar());
comments.put("comment", commentsOrder.getFeedback());
Users users = usersService.getById(commentsAcdrOrder.getUserId());
comments.put("star", commentsAcdrOrder.getStar());
comments.put("comment", commentsAcdrOrder.getFeedback());
comments.put("commentNum", commitNums);
comments.put("userName", users.getNickname());
comments.put("userAvatar", users.getAvatar());
@ -354,9 +350,11 @@ public class PersonalServiceController {
// 构建查询条件
LambdaQueryWrapper<PersonalService> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PersonalService::getProvince, province)
.eq(PersonalService::getCity, city)
.eq(PersonalService::getDistrict, district);
wrapper.eq(StrUtil.isNotBlank(province), PersonalService::getProvince, province)
.eq(StrUtil.isNotBlank(city), PersonalService::getCity, city)
.eq(StrUtil.isNotBlank(district)
&& !district.equals("[]"),
PersonalService::getDistrict, district);
// 根据服务名称过滤如果提供
if (serviceName != null && !serviceName.trim().isEmpty()) {

View File

@ -6,7 +6,7 @@
<parent>
<groupId>cn.yskj.dev</groupId>
<artifactId>yskj-module-contact</artifactId>
<version>2.1.0-snapshot</version>
<version>${revision}</version>
</parent>
<artifactId>yskj-module-contact-api</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>cn.yskj.dev</groupId>
<artifactId>yskj-module-contact</artifactId>
<version>2.1.0-snapshot</version>
<version>${revision}</version>
</parent>
<artifactId>yskj-module-contact-biz</artifactId>

View File

@ -3,11 +3,8 @@ package cn.yskj.linghe.module.pay.dal.mysql.channel;
import cn.yskj.linghe.framework.mybatis.core.mapper.BaseMapperX;
import cn.yskj.linghe.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.yskj.linghe.module.pay.dal.dataobject.channel.PayChannelDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

View File

@ -45,7 +45,9 @@ spring:
primary: master
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/cwet?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/cwet?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
url: jdbc:mysql://116.204.119.171:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/cwet?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
@ -53,19 +55,20 @@ spring:
# url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例
# url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
username: root
password: root
username: acdr
password: linghe2024
# username: sa # SQL Server 连接的示例
# password: Yskj@2024 # SQL Server 连接的示例
# username: SYSDBA # DM 连接的示例
# password: SYSDBA001 # DM 连接的示例
# username: root # OpenGauss 连接的示例
# password: Yskj@2024 # OpenGauss 连接的示例
slave: # 模拟从库,可根据自己需要修改
# slave: # 模拟从库,可根据自己需要修改
# lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: root
# url: jdbc:mysql://116.204.119.171:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# url: jdbc:mysql://127.0.0.1:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: acdr
# password: linghe2024
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
data:

View File

@ -45,7 +45,9 @@ spring:
primary: master
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/cwet?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/cwet?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://116.204.119.171:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
url: jdbc:mysql://127.0.0.1:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
@ -53,19 +55,20 @@ spring:
# url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例
# url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
username: root
password: root
username: acdr
password: linghe2024
# username: sa # SQL Server 连接的示例
# password: Yskj@2024 # SQL Server 连接的示例
# username: SYSDBA # DM 连接的示例
# password: SYSDBA001 # DM 连接的示例
# username: root # OpenGauss 连接的示例
# password: Yskj@2024 # OpenGauss 连接的示例
slave: # 模拟从库,可根据自己需要修改
# slave: # 模拟从库,可根据自己需要修改
# lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: root
# url: jdbc:mysql://116.204.119.171:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# url: jdbc:mysql://127.0.0.1:3306/acdr?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: acdr
# password: linghe2024
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
data:
@ -221,12 +224,6 @@ yskj:
wxa-code:
env-version: develop # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop"
tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m #方便测试
send-maximum-quantity-per-day: 10 #方便测试
begin-code: 1111 # 这里配置 9999 的原因是,测试方便。
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
justauth:
enabled: true
@ -263,6 +260,11 @@ path:
file: ${path.home}file\
profile: ${path.home}profile\
phone:
key: e1bc0661299f1303aef1c5659d0ae1c6
model: 263680
url: http://v.juhe.cn/sms/send
sky:
wechat:
appid: wxbcbdfd32af81ee15

View File

@ -1,15 +1,16 @@
# 生产环境:只在打包时使用
NODE_ENV=production
VITE_PORT=8088
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://localhost:48080'
VITE_BASE_URL='https://api.cwzoonest.cn'
# 文件上传类型server - 后端上传, client - 前端直连上传仅支持S3服务
VITE_UPLOAD_TYPE=server
# 上传路径
VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload'
VITE_UPLOAD_URL='https://api.cwzoonest.cn/admin-api/infra/file/upload'
# 接口地址
VITE_API_URL=/admin-api