更新版本

This commit is contained in:
tsukiyalo 2025-05-12 15:21:36 +08:00
parent 251e98bb68
commit 30e68a1c6b
125 changed files with 1696 additions and 772 deletions

View File

@ -1,37 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
<version>3.2.5</version>
<relativePath/>
</parent>
<groupId>com.bsz</groupId>
<artifactId>school_send_back_end</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>school_send_back_end</name>
<description>school_send_back_end</description>
<properties>
<java.version>21</java.version>
<java.version>17</java.version>
<spring-ai.version>1.0.0-M2</spring-ai.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
<version>3.5.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@ -43,99 +51,229 @@
<artifactId>alipay-sdk-java</artifactId>
<version>4.38.0.ALL</version>
</dependency>
<!--hutool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 阿里云oss依赖 -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.15.1</version>
</dependency>
<!--日期工具栏依赖-->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.1</version>
</dependency>
<!-- https://doc.xiaominfo.com/knife4j/documentation/get_start.html-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
<version>3.0.3</version> <!-- 推荐稳定版 -->
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.21</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.3</version>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<!-- websocket-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.5.12</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.109.Final</version>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>1.1.13</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.16</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId>
<version>0.23.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version> <!-- 或使用其他 Jakarta 版本,根据需要 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
<version>2.1.0</version> <!-- 使用 Jakarta 版本的 WebSocket API -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version> <!-- 或者选择最新的兼容版本 -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>2.2.20</version>
</dependency>
<!--阿里AI-->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter</artifactId>
<version>1.0.0-M2.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/release</url>
</repository>
<repository>
<id>knife4j</id>
<url>https://s01.oss.sonatype.org/content/repositories/releases/</url>
</repository>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -174,12 +174,14 @@ create table if not exists orders
phone varchar(64) not null comment '手机号',
userId bigint not null comment '下单用户id',
businessId bigint not null comment '商家id',
errandId bigint null comment '跑腿id',
location varchar(256) null comment '配送地址',
totalPrice decimal(10, 2) not null comment '订单实际总价',
pickupMethod tinyint not null comment '取餐方式(0堂食 1自提)',
payMethod tinyint not null comment '支付方式0微信支付',
pickupTime datetime null comment '取餐时间',
notes varchar(128) null comment '备注',
state tinyint default 0 not null comment '订单状态:0未支付 1已完成 2已退款 3已取消 4已出餐 5已完成',
state tinyint default 0 not null comment '订单状态: 0未支付 1已完成 2已退款 3已取消 4已出餐 5已完成',
createTime datetime default CURRENT_TIMESTAMP not null comment '下单时间',
updateTime datetime default CURRENT_TIMESTAMP not null comment '支付时间',
isDelete tinyint default 0 not null comment '是否删除',
@ -261,8 +263,8 @@ create table collect
-- 用户评分表
create table user_rating
(
id bigint auto_increment primary key comment 'id',
businessId bigint not null comment '商家id',
id bigint auto_increment comment 'id' primary key,
ratedEntityId bigint not null comment '评分对象的ID商家 跑腿',
userId bigint not null comment '用户id',
orderId bigint not null comment '订单id',
rating tinyint not null comment '评分',
@ -280,4 +282,110 @@ create table business_level
level tinyint not null comment '等级',
createTime DATETIME default CURRENT_TIMESTAMP comment '创建时间',
updateTime DATETIME default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '更新时间'
)
);
-- 系统信息表
create table if not exists businessInfo
(
id bigint auto_increment comment 'id' primary key,
businessId bigint not null comment '商家id',
content varchar(256) not null comment '功能内容',
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间'
) comment '系统信息' collate = utf8mb4_unicode_ci;
-- 跑腿表
create table if not exists errand
(
id bigint auto_increment comment 'id' primary key,
userId bigint not null comment '用户id',
errandName varchar(256) not null comment '跑腿姓名',
errandAvatarUrl varchar(256) default 'http://154.8.193.216:9494/system/0/MRiFcIbr-R.jpg' comment '跑腿头像',
gender tinyint not null comment '性别',
phone varchar(128) not null comment '手机号',
distributionScope tinyint not null comment '配送范围',
totalOrders tinyint default 0 not null comment '接单量',
maxOrders tinyint default 15 not null comment '最大接单量',
totalPrice decimal(10, 2) default 0.00 not null comment '总金额',
state tinyint default 0 not null comment '审核状态 0-未审核 1-审核通过',
createTime DATETIME default CURRENT_TIMESTAMP comment '创建时间',
updateTime DATETIME default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '更新时间',
isDelete tinyint default 0 not null comment '是否删除'
) comment '跑腿' collate = utf8mb4_unicode_ci;
-- 跑腿认证表
create table if not exists errand_auth
(
id bigint auto_increment primary key comment 'id',
errandId bigint not null comment '跑腿id',
bankCard varchar(64) not null comment '银行卡号',
frontIdCard varchar(1024) not null comment '身份证正面',
backIdCard varchar(1024) not null comment '身份证反面',
healthCertificate varchar(1024) null comment '健康证',
certificateStartTime datetime null comment '健康证开始时间',
certificateEndTime datetime null comment '健康证结束时间',
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
isDelete tinyint default 0 not null comment '逻辑删除'
) comment '跑腿认证' collate = utf8mb4_unicode_ci;
-- 跑腿等级表
create table if not exists errand_level
(
id bigint auto_increment primary key comment 'id',
errandId bigint not null comment '跑腿Id',
averageScore DECIMAL(3, 2) not null default 0 comment '综合评分',
level tinyint not null comment '等级',
createTime DATETIME default CURRENT_TIMESTAMP comment '创建时间',
updateTime DATETIME default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '更新时间'
) comment '跑腿等级' collate = utf8mb4_unicode_ci;
create table if not exists errand_income
(
id bigint auto_increment primary key comment 'id',
errandId bigint not null comment '跑腿id',
orderId bigint not null comment '订单id',
income decimal(10, 2) default 0 comment '综合评分',
state tinyint default 0 not null comment '0未结算 1已结算 2已提现',
createTime datetime default CURRENT_TIMESTAMP comment '创建时间'
) comment '跑腿收入' collate = utf8mb4_unicode_ci;
create table if not exists errand_order
(
id bigint auto_increment primary key comment 'id',
orderId bigint not null comment '订单ID',
errandState tinyint default 0 null comment '跑腿状态: 0无跑腿 1待抢单 2待取货 3待送达 4已送达 5再次抢单',
startTime datetime null comment '送餐开始时间',
endTime datetime null comment '送餐结束时间',
errandId bigint null comment '跑腿员ID',
createTime datetime default current_timestamp not null comment '任务创建时间',
updateTime datetime default current_timestamp not null on update current_timestamp comment '任务更新时间',
isDelete tinyint default 0 not null comment '是否删除'
) comment '跑腿任务表' collate = utf8mb4_unicode_ci;
create table if not exists order_image
(
orderId bigint auto_increment primary key comment 'id',
imageAddress varchar(256) not null comment '外卖地址'
) comment '外卖图片' collate = utf8mb4_unicode_ci;
create table if not exists errand_bill
(
id bigint auto_increment primary key comment 'id',
orderId bigint not null comment '订单Id',
userPhone varchar(128) not null comment '用户手机号',
income decimal(3, 2) default 0 comment '综合评分',
errandState tinyint default 0 comment '收入状态0-待结算 1-已结算',
orderStartTime Date not null comment '订单创建时间'
) comment '跑腿账单表' collate = utf8mb4_unicode_ci;
create table order_refunds (
id bigint auto_increment primary key comment '退款申请ID',
orderId bigint not null unique comment '订单号,唯一标识',
userId bigint not null comment '用户ID',
reason varchar(255) default null comment '退款原因',
amount decimal(10,2) not null comment '退款金额',
status tinyint not null default 0 comment '退款状态0-待审核, 1-已同意, 2-已拒绝',
createTime timestamp default current_timestamp comment '申请时间',
updateTime timestamp default current_timestamp on update current_timestamp comment '更新时间',
index idx_order_id (orderId),
index idx_user_id (userId)
) comment='退款申请表' collate = utf8mb4_unicode_ci;

View File

@ -1,8 +1,11 @@
package com.bsz.school_send_back_end;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
@ -14,4 +17,9 @@ public class UserCenterApplication {
public static void main(String[] args) {
SpringApplication.run(UserCenterApplication.class, args);
}
@Bean
public ChatMemory chatMemory(){
return new InMemoryChatMemory();
}
}

View File

@ -15,8 +15,9 @@ import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 权限校验 AOP
@ -33,9 +34,15 @@ public class AuthInterceptor {
*/
@Around("@annotation(authCheck)")
public Object doInterceptor(ProceedingJoinPoint joinPoint, AuthCheck authCheck) throws Throwable {
String mustRole = authCheck.mustRole();
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
String uri = request.getRequestURI();
// 如果是 Swagger OpenAPI 相关请求直接放行
if (uri.startsWith("/v3/api-docs") || uri.contains("/swagger") || uri.contains("/swagger-ui")) {
return joinPoint.proceed(); // 直接放行
}
// 当前登录用户
User loginUser = userService.getLoginUser(request);
// 必须有该权限才通过
@ -62,13 +69,23 @@ public class AuthInterceptor {
}
// 必须有商家或管理员权限
if (UserRoleEnum.BUSINESS.equals(mustUserRoleEnum)) {
if (!mustRole.equals(userRole)
&& !UserConstant.ADMIN_ROLE.equals(userRole)
&&!UserConstant.BOSS_ROLE.equals(userRole)) {
if (!Arrays.asList(mustRole, UserConstant.ADMIN_ROLE, UserConstant.BOSS_ROLE).contains(userRole)) {
throw new BusinessException(ErrorCode.NO_AUTH);
}
}
//
if (UserRoleEnum.ERRAND.equals(mustUserRoleEnum)) {
if (!Arrays.asList(mustRole, UserConstant.ADMIN_ROLE, UserConstant.BOSS_ROLE).contains(userRole)) {
throw new BusinessException(ErrorCode.NO_AUTH);
}
}
if (UserRoleEnum.USER.equals(mustUserRoleEnum)) {
if (!Arrays.asList(mustRole, UserConstant.ADMIN_ROLE, UserConstant.BOSS_ROLE).contains(userRole)) {
throw new BusinessException(ErrorCode.NO_AUTH);
}
}
// 通过权限校验放行
return joinPoint.proceed();
}

View File

@ -19,8 +19,8 @@ import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
/**
* 日志AOP
@ -41,12 +41,18 @@ public class SystemLogInterceptor {
*/
@Around("@annotation(systemLog)")
public Object doInterceptor(ProceedingJoinPoint joinPoint, SystemLog systemLog) throws Throwable {
// 获取执行操作
String executeStep = systemLog.executeStep();
ThrowUtils.throwIf(StringUtils.isEmpty(executeStep), ErrorCode.PARAMS_ERROR);
//获取请求
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
HttpServletRequest httpServletRequest = ((ServletRequestAttributes) requestAttributes).getRequest();
String uri = httpServletRequest.getRequestURI();
// 如果是 Swagger OpenAPI 相关请求直接放行
if (uri.startsWith("/v3/api-docs") || uri.contains("/swagger") || uri.contains("/swagger-ui")) {
return joinPoint.proceed(); // 直接放行
}
//获取登录用户
User loginUser = userService.getLoginUser(httpServletRequest);
//写入系统日志

View File

@ -1,31 +1,24 @@
package com.bsz.school_send_back_end.common;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
*通用返回类
*
* @author bsz
*/
@Data
@Schema(description = "通用返回对象")
public class BaseResponse<T> implements Serializable {
/**
* 状态码
*/
@Schema(description = "状态码例如200 表示成功")
private int code;
/**
* 数据
*/
@Schema(description = "返回的数据内容")
private T data;
/**
* 消息
*/
@Schema(description = "提示消息")
private String message;
/**
* 描述
*/
@Schema(description = "错误描述")
private String description;
public BaseResponse(int code, T data, String message, String description) {

View File

@ -3,7 +3,7 @@ package com.bsz.school_send_back_end.config;
import com.alipay.api.internal.util.AlipaySignature;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

View File

@ -10,12 +10,12 @@ public class AlipayClients {
public String appId = "2021004151684053";
//私钥
//沙箱公钥 支付宝公钥
public String PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3JKMG3clg/1MqewlIK/koEhiQiSLagckb/2/Dyvg+rJ2snGiAgzNvhvvc1GdVC+Xnn/P+U+2tAytyuvbOuhmGgNZjeObczJXpo/0D6LBdYDrg4PVMDxpStCxLUpaShHbc/l/IquaorBwd94UJxIPAbUQkUBCbo94mGbhDX+yU4FQ6k1yeUtn03jvZ3AY0BEHpenCxWKgr5S/CUAYEitMbi/r7extBy6f4FCR120NM7VaNEK1xpHbGHo6rDpyiAOR1lWFuiqOJ1hv14UL/SfOLlzvUZiiPysIxdNjycZyiyRvFRHP3n8GBAaJDm9vVHwDfgQ5s3Ig2ggBeYXkFHZqWwIDAQAB";
// public String PublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjqGlEXMznr4XlQ3hvbZnQmfj0i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tfKCzevPaqRxwrFkS8WUQTMOaQbJXATbPQDt7MoWGujFd37lYz7ESQZed2wIDAQAB";
//公钥appPrivateKey
//沙箱私钥 支付宝私钥
public String appPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCc1rWOaCHl7KnDDMctWIgFJqerq9ZU8QsxSA+wQC4nrTfoQVSVZn8fDNosilCHda7yv910A9aJYqZKx0+NOXY9YvMbKYifWtO8TtzAQ9Q0EQXce85gnVQ3yn9evE1MVwfmMIiXJ2jx/dmGrxuADrLcsNB/U4xsusKcNQaA76vALtAYTnKwOODaDt5Qd2OC25PRcGtKupKIbir/f62tNquBkCX+Z5URBpy0rZY2hCu30v3uPv8I3OlpxegFwNDHpKMIY3+wjQtqsogQTn20E5wzeV3VNabNxbORq6B6nh8mvxlo9q14XvmMJDPUoWiJgyUUpaAPZFWSpRCrLvWQY/klAgMBAAECggEAZJ/Ahig7L2gClriZBXfadOuTAapS7dZkpu6j2iGjOyOATgu0N9I11vcI9zCab/5KC0abzzYzK5vWMv3jBSmLueDFNnUUSaEdXaB/Mv+RowIU75ujEgt+n/jUdTR8p3DjCYWz7L6FL1T9fdLU4vkLOlpauoYg/xVnjI7cqFacq8SWr3jiGj/I31O18y02/eDiyAb5RMlSlNGnzvDuRwJ3h2Sn1u7znbMCi6CydG3hx+I0GE2iJqVPymc1f0T0vm7Jy3l/zL84oNKLTgPCqG9k+eriC7RaMkbvPQFjWCDCuWxgYM2pi1L9ZDG+FkReTFsZw6r/TWc4sl2xtj3GDSrHYQKBgQD1NwFBMQwsUQ/aJP63R0gILWSFR0+yQ314vfRRVKoZTujbQr7RBAzgQff97DirINIxXCBeV0zifpc2IaAPaY29YjDnQU+xGqIO91EWPjMkQ6XUvGGesKnKDYkA5yBMyD3/BH8BwJruidW2DwtC2rGTW1hatkXNtYccEI79/00UOQKBgQCjvKIySZdRolOYUfSPHHipOygWClFy1DlI54XDnj0gRBoOrFkeqrXr+G8dYeXP6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+NYgwL/FztMJVljfQsGY81mhgrQyPhmg/7NiWmLodJtwQgSj3UitDVtUGhZRnuidO8P1XW0sUyDwc8xMLb+0qVxX4gMpM4J1B0UaIp+oPg7hCXeFGxkWQl8bPY0RFa3GOfT2/D63NpXqYw8Fe1lZWoIMz+PBdx0YN90=";
//应用证书
private String appCertPath;
//支付宝证书
@ -25,7 +25,7 @@ public class AlipayClients {
//回调地址
private String notify;
//字符集 签名
private String gateway = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
private String gateway = "https://openapi.alipay.com/gateway.do";
// 公私钥模式

View File

@ -1,53 +1,25 @@
package com.bsz.school_send_back_end.config;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author bsz
* Knife4j 接口文档配置
* Springdoc OpenAPI 配置
*
* http://localhost:8080/api/doc.html#/home 接口文档地址
* https://localhost:9999/api/swagger-ui/index.html 接口文档地址
*/
@Configuration
@EnableSwagger2
@Profile({"dev", "test"}) //版本控制访问
@Profile({"dev", "test"}) // 版本控制访问
public class Knife4jConfig {
@Bean
public Docket defaultApi2() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
// 指定 Controller 扫描包路径
.apis(RequestHandlerSelectors.basePackage("com.bsz.school_send_back_end.controller"))
.paths(PathSelectors.any())
.build();
}
/**
* 自定义接口文档信息
* @return 接口文档
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
// 接口文档的标题
.title("校快送接口平台管理")
// 接口文档的描述信息
.description("校快送的接口文档,进行测试")
// 提供服务的是谁可以填写你自己的地址因为是你自己提供的服务
.termsOfServiceUrl("https://gitee.com/shir23zxc/school_lend_back-end")
.contact(new Contact("bsz", "https://account.bilibili.com/account/face/upload?spm_id_from=333.999.0.0", "1113832400@qq.com"))
// 版本
.version("1.0")
// 构建
public GroupedOpenApi defaultApi() {
return GroupedOpenApi.builder()
.group("xiaokuaisong")
.packagesToScan("com.bsz.school_send_back_end.controller") // 指定扫描的包路径
.build();
}
}

View File

@ -2,8 +2,11 @@ package com.bsz.school_send_back_end.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisSessionRepositoryConfig {
@ -13,4 +16,15 @@ public class RedisSessionRepositoryConfig {
{
return new GenericJackson2JsonRedisSerializer();
}
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
RedisTemplate redisTemplate = new RedisTemplate<>();
//设置redis的连接工厂对象
redisTemplate.setConnectionFactory(redisConnectionFactory);
//设置redis key的序列化器
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
return redisTemplate;
}
}

View File

@ -14,7 +14,7 @@ public interface FileConstant {
/**
* 服务器访问地址
*/
String SERVER_HOST = "154.8.193.216:9494";
String SERVER_HOST = "https://xiaoshitong.xyz";
/**
* 服务器上传路径

View File

@ -13,4 +13,5 @@ public interface RedisKeyConstant {
String USER_LOGIN_STATE = "xiaokuaisong_user";
String IP = "ip";
String SESSION_ID = "sessionId";
String APPNAME = "appName";
}

View File

@ -1,5 +1,11 @@
package com.bsz.school_send_back_end.contant;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Set;
import static java.util.Map.entry;
/**
* 用户常量
*/
@ -27,6 +33,10 @@ public interface UserConstant {
*/
String ADMIN_ROLE = "admin";
/**
* 跑腿角色
*/
String ERRAND_ROLE = "errand";
/**
* Boss
*/
@ -36,4 +46,39 @@ public interface UserConstant {
* 被封号
*/
String BAN_ROLE = "ban";
/**
* 配送地址
*/
Set<String> VALID_LOCATIONS = Set.of("1公寓", "2公寓", "3公寓","4公寓","5公寓","6公寓",
"7公寓","8公寓","9公寓","10公寓","11公寓","12公寓","育才大厦");
/**
* 公寓配送费
*/
Map<String, BigDecimal> DELIVERY_FEE_MAP = Map.ofEntries(
entry("1公寓", new BigDecimal("1.7")),
entry("2公寓", new BigDecimal("1.7")),
entry("11公寓", new BigDecimal("1.7")),
entry("12公寓", new BigDecimal("1.7")),
entry("5公寓", new BigDecimal("1.2")),
entry("6公寓", new BigDecimal("1.2")),
entry("7公寓", new BigDecimal("1.2")),
entry("3公寓", new BigDecimal("2.3")),
entry("4公寓", new BigDecimal("2.3")),
entry("9公寓", new BigDecimal("2.3")),
entry("10公寓", new BigDecimal("2.3")),
entry("8公寓", new BigDecimal("2.3")),
entry("育才大厦", new BigDecimal("2.5"))
);
/**
* 默认等级
*/
int DEFAULT_LEVEL = 1;
/**
* 默认平均分
*/
double DEFAULT_AVG_SCORE = 1.0;
}

View File

@ -12,25 +12,32 @@ import com.bsz.school_send_back_end.common.ResultUtils;
import com.bsz.school_send_back_end.contant.UserConstant;
import com.bsz.school_send_back_end.exception.BusinessException;
import com.bsz.school_send_back_end.exception.ThrowUtils;
import com.bsz.school_send_back_end.model.domain.*;
import com.bsz.school_send_back_end.model.domain.Business;
import com.bsz.school_send_back_end.model.domain.BusinessAuth;
import com.bsz.school_send_back_end.model.domain.Collect;
import com.bsz.school_send_back_end.model.domain.User;
import com.bsz.school_send_back_end.model.dto.business.BusinessAddRequest;
import com.bsz.school_send_back_end.model.dto.business.BusinessQueryRequest;
import com.bsz.school_send_back_end.model.dto.business.BusinessUpdateMyRequest;
import com.bsz.school_send_back_end.model.dto.business.BusinessUpdateRequest;
import com.bsz.school_send_back_end.model.vo.BusinessAdminVO;
import com.bsz.school_send_back_end.model.vo.BusinessVO;
import com.bsz.school_send_back_end.service.*;
import com.bsz.school_send_back_end.service.BusinessAuthService;
import com.bsz.school_send_back_end.service.BusinessService;
import com.bsz.school_send_back_end.service.CollectService;
import com.bsz.school_send_back_end.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import static com.bsz.school_send_back_end.contant.UserConstant.DEFAULT_ROLE;
import static com.bsz.school_send_back_end.contant.UserConstant.USER_SALT;
/**
@ -53,9 +60,6 @@ public class BusinessController {
@Resource
private CollectService collectService;
@Resource
private BusinessLevelService businessLevelService;
@PostMapping("/add")
public BaseResponse<Long> addBusiness(@RequestBody BusinessAddRequest businessAddRequest) {
@ -69,7 +73,7 @@ public class BusinessController {
BeanUtils.copyProperties(businessAddRequest, businessAuth);
//对每个应该校验的业务进行校验
businessService.validUser(user, true);
userService.validUser(user, true);
businessService.validBusiness(business, true);
businessService.validBusinessAuth(businessAuth, true);
@ -170,40 +174,6 @@ public class BusinessController {
return ResultUtils.success(businessAdminVO);
}
/**
* 根据id查询
*/
@GetMapping("/my/getById")
@AuthCheck(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<BusinessVO> getMyBusinessById(@RequestParam Long id, HttpServletRequest request) {
if (id <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
LambdaQueryWrapper<Business> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Business::getId, id);
Business business = businessService.getOne(queryWrapper);
ThrowUtils.throwIf(business == null, ErrorCode.OPERATION_ERROR, "没有找到商家");
BusinessVO businessVO = new BusinessVO();
BeanUtils.copyProperties(business, businessVO);
User loginUser = userService.getLoginUser(request);
Long loginUserId = loginUser.getId();
LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Collect::getUserId, loginUserId);
wrapper.eq(Collect::getBusinessId, id);
long count = collectService.count(wrapper);
Collect collect = collectService.getOne(wrapper);
if (count > 0) {
businessVO.setCollectId(collect.getId());
} else{
businessVO.setCollectId(0L);
}
BusinessLevel level = businessLevelService.getOne(Wrappers.<BusinessLevel>lambdaQuery()
.eq(BusinessLevel::getBusinessId, id));
businessVO.setLevel(level.getLevel());
return ResultUtils.success(businessVO);
}
/**
* 根据当前登录用户获取商家信息
*/
@ -252,6 +222,22 @@ public class BusinessController {
return ResultUtils.success(businessVOPage);
}
@GetMapping("/my/getById")
@AuthCheck(mustRole = DEFAULT_ROLE)
public BaseResponse<BusinessVO> getBusinessVO (@RequestParam Long businessId, HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
LambdaQueryWrapper<Business> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Business::getId, businessId);
long count = businessService.count(queryWrapper);
ThrowUtils.throwIf(count != 1, ErrorCode.PARAMS_ERROR, "商家id不正确");
Business business = businessService.getOne(queryWrapper);
BusinessVO businessVO = businessService.getBusinessVO(business);
long collect = collectService.count(Wrappers.<Collect>lambdaQuery()
.eq(Collect::getUserId, loginUser.getId())
.eq(Collect::getBusinessId, businessId));
businessVO.setIsCollected(collect > 0);
return ResultUtils.success(businessVO);
}
}

View File

@ -18,17 +18,14 @@ import com.bsz.school_send_back_end.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@Slf4j
@ -120,7 +117,7 @@ public class CartController {
queryWrapper.eq(Cart::getBusinessId, businessId);
queryWrapper.eq(Cart::getUserId, userId);
List<Cart> cartList = cartService.list(queryWrapper);
List<CartVO> cartVOList = this.getCartVOList(cartList);
List<CartVO> cartVOList = cartService.getCartVOList(cartList);
return ResultUtils.success(cartVOList);
}
@ -137,7 +134,7 @@ public class CartController {
wrapper.eq(Cart::getUserId, userId);
List<Cart> cartList = cartService.list(wrapper);
List<CartVO> cartVOList = this.getCartVOList(cartList);
List<CartVO> cartVOList = cartService.getCartVOList(cartList);
return ResultUtils.success(cartVOList);
}
@ -182,15 +179,4 @@ public class CartController {
return ResultUtils.success(true);
}
private List<CartVO> getCartVOList(List<Cart> cartList) {
if (CollectionUtils.isEmpty(cartList)) {
return new ArrayList<>();
}
return cartList.stream().map(item ->{
CartVO cartVO = new CartVO();
BeanUtils.copyProperties(item, cartVO);
return cartVO;
}).collect(Collectors.toList());
}
}

View File

@ -19,7 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.util.List;
@Slf4j

View File

@ -20,8 +20,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@RestController
@ -55,13 +56,16 @@ public class CollectController {
* 删除一条收藏
*/
@PostMapping("/delete")
public BaseResponse<Boolean> deleteCollect(@RequestBody CommonRequest commonRequest) {
public BaseResponse<Boolean> deleteCollect(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long id = commonRequest.getId();
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Collect::getId, id);
wrapper.eq(Collect::getUserId, userId);
wrapper.eq(Collect::getBusinessId, id);
boolean remove = collectService.remove(wrapper);
ThrowUtils.throwIf(!remove, ErrorCode.SYSTEM_ERROR);
return ResultUtils.success(true);
@ -87,6 +91,10 @@ public class CollectController {
@PostMapping("/list")
public BaseResponse<List<CollectVO>> listCollect(HttpServletRequest request) {
List<CollectVO> collectList = collectService.getCollectList(request);
if (collectList == null) {
collectList = new ArrayList<>();
}
return ResultUtils.success(collectList);
}
}

View File

@ -29,8 +29,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
@Slf4j

View File

@ -29,8 +29,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
@Slf4j

View File

@ -15,8 +15,8 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;

View File

@ -15,31 +15,31 @@ import com.bsz.school_send_back_end.contant.CommonConstant;
import com.bsz.school_send_back_end.contant.UserConstant;
import com.bsz.school_send_back_end.exception.BusinessException;
import com.bsz.school_send_back_end.exception.ThrowUtils;
import com.bsz.school_send_back_end.listener.RabbitMQSender;
import com.bsz.school_send_back_end.model.domain.*;
import com.bsz.school_send_back_end.model.dto.CommonRequest;
import com.bsz.school_send_back_end.model.dto.order.*;
import com.bsz.school_send_back_end.model.vo.OrdersExcelVO;
import com.bsz.school_send_back_end.model.vo.OrdersVO;
import com.bsz.school_send_back_end.model.vo.*;
import com.bsz.school_send_back_end.service.*;
import com.bsz.school_send_back_end.utils.ExcelUtils;
import com.bsz.school_send_back_end.utils.SqlUtils;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -67,6 +67,24 @@ public class OrdersController {
@Resource
private OrderDetailsService orderDetailsService;
@Resource
private WebsocketService websocketService;
@Resource
private ErrandService errandService;
@Resource
private ErrandIncomeService errandIncomeService;
@Resource
private ErrandOrderService errandOrderService;
@Resource
private ErrandBillService billService;
@Resource
private RabbitMQSender rabbitMQSender;
/**
* 创建订单
*
@ -100,6 +118,7 @@ public class OrdersController {
}).toList();
// 创建订单
long orderId = ordersService.addOrder(orders, orderDetailsList);
rabbitMQSender.sendCreateOrderMessage(orderId);
return ResultUtils.success(orderId, "订单创建成功");
}
@ -146,7 +165,6 @@ public class OrdersController {
* 根据 id 获取订单信息
*/
@GetMapping("/get/my")
@AuthCheck(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<OrdersVO> getOrderVOByMyId(@RequestParam Long id, HttpServletRequest request) {
if (id <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -241,18 +259,18 @@ public class OrdersController {
orderQueryRequest.setStartTime(date.format(startFormatter));
orderQueryRequest.setEndTime(date.format(endFormatter));
QueryWrapper<Orders> queryWrapper = ordersService.getQueryWrapper(orderQueryRequest);
List<Orders> ordertList = ordersService.list(queryWrapper);
List<Orders> orderList = ordersService.list(queryWrapper);
BigDecimal money = new BigDecimal("0");
for (Orders order : ordertList) {
for (Orders order : orderList) {
money = money.add(order.getTotalPrice());
}
moneyCountList.add(money);
}
} else {
QueryWrapper<Orders> queryWrapper = ordersService.getQueryWrapper(orderQueryRequest);
List<Orders> ordertList = ordersService.list(queryWrapper);
List<Orders> orderList = ordersService.list(queryWrapper);
BigDecimal money = new BigDecimal("0");
for (Orders order : ordertList) {
for (Orders order : orderList) {
money = money.add(order.getTotalPrice());
}
moneyCountList.add(money);
@ -355,12 +373,17 @@ public class OrdersController {
}).collect(Collectors.toList());
// 设置导出名称
ExcelUtils.setExcelResponseProp(response, "订单信息");
log.info("响应头 Content-Type: {}", response.getContentType());
// 获取输出流名称
OutputStream outputStream = response.getOutputStream();
// 这里 需要指定写用哪个class去写然后写到第一个sheet名字为模板 然后文件流会自动关闭
EasyExcel.write(outputStream, OrdersExcelVO.class) // 对应实体类
.sheet("订单数据") // sheet页名称
.doWrite(ordersExcelVOList); // 导出的数据集合
try (OutputStream outputStream = response.getOutputStream()) {
EasyExcel.write(outputStream, OrdersExcelVO.class)
.sheet("订单数据")
.doWrite(ordersExcelVOList);
response.flushBuffer();
} catch (Exception e) {
log.error("Excel 导出失败", e);
}
}
@PostMapping("/delete")
@ -400,49 +423,195 @@ public class OrdersController {
Orders orders = ordersService.getOne(queryWrapper);
Business loginBusiness = businessService.getLoginBusiness(request);
Long businessId = loginBusiness.getId();
ThrowUtils.throwIf(!businessId.equals(orders.getBusinessId()), ErrorCode.FORBIDDEN_ERROR,
"当前订单不属于当前登录用户");
ThrowUtils.throwIf(!orders.getState().equals(1), ErrorCode.OPERATION_ERROR,"当前订单状态不是已支付状态");
ThrowUtils.throwIf(!businessId.equals(orders.getBusinessId()), ErrorCode.FORBIDDEN_ERROR, "当前订单不属于当前登录用户");
LambdaUpdateWrapper<Orders> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(Orders::getState,4);
updateWrapper.eq(Orders::getId, id);
String location = orders.getLocation();
ErrandOrder errandOrder = errandOrderService.getOne(Wrappers.<ErrandOrder>lambdaQuery()
.eq(ErrandOrder::getOrderId, orders.getId()));
if (errandOrder != null) {
if (StringUtils.isNotBlank(location)) {
websocketService.sendOrderToErrand(orders);
errandOrder.setErrandState(1);//1待抢单
boolean update1 = errandOrderService.updateById(errandOrder);
ThrowUtils.throwIf(!update1, ErrorCode.OPERATION_ERROR, "更新跑腿关联失败");
}
boolean update = ordersService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR,"修改订单状态失败");
}
return ResultUtils.success(true);
}
@PostMapping("/update/user")
@AuthCheck(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<Boolean> updateOrderStateByUser (@RequestBody CommonRequest commonRequest, HttpServletRequest request){
@PostMapping("/updateOrder")
public BaseResponse<Boolean> updateOrder(@RequestBody OrderUpdateRequest orderUpdateRequest, HttpServletRequest request) {
return ResultUtils.success(ordersService.OrderToUpdate(orderUpdateRequest, request));
}
@PostMapping("/update/state/user")
public BaseResponse<Boolean> updateStateByUser(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long orderId = commonRequest.getId();
LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Orders::getId, orderId);
Orders orders = ordersService.getOne(queryWrapper);
User loginUser = userService.getLoginUser(request);
ThrowUtils.throwIf(!loginUser.getId().equals(orders.getUserId()), ErrorCode.OPERATION_ERROR,
"当前订单不属于该用户");
ThrowUtils.throwIf(!orders.getState().equals(4), ErrorCode.OPERATION_ERROR,"该订单未出餐");
LambdaUpdateWrapper<Orders> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(Orders::getState, 5);
updateWrapper.eq(Orders::getId, orderId);
boolean update = ordersService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR,"修改订单状态失败");
Orders orders = ordersService.getById(orderId);
ThrowUtils.throwIf(orders.getState().equals(5), ErrorCode.OPERATION_ERROR, "订单已完成");
ThrowUtils.throwIf(!orders.getUserId().equals(loginUser.getId()), ErrorCode.PARAMS_ERROR,
"当前传送的订单id不正确或不属于当前用户");
Long errandId = orders.getErrandId();
if (errandId != null) {
Errand errand = errandService.getById(errandId);
LambdaQueryWrapper<ErrandIncome> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ErrandIncome::getOrderId, orderId);
ErrandIncome errandIncome = errandIncomeService.getOne(queryWrapper);
errandIncome.setState(1); // 收入已结算
boolean update = errandIncomeService.updateById(errandIncome);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR,"修改跑腿收入失败");
BigDecimal totalPrice = errand.getTotalPrice();
BigDecimal income = errandIncome.getIncome();
totalPrice = totalPrice.add(income);
errand.setTotalPrice(totalPrice);
boolean update1 = errandService.updateById(errand);
ThrowUtils.throwIf(!update1, ErrorCode.OPERATION_ERROR, "修改跑腿总金额失败");
ErrandBill errandBill = new ErrandBill();
errandBill.setOrderId(orderId);
errandBill.setErrandState(errandIncome.getState());
errandBill.setIncome(errandIncome.getIncome());
errandBill.setUsername(loginUser.getUsername());
errandBill.setOrderStartTime(orders.getCreateTime());
boolean save = billService.save(errandBill);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "添加跑腿账单失败");
}
orders.setState(5);
boolean update = ordersService.updateById(orders);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "修改订单状态失败");
return ResultUtils.success(true);
}
@PostMapping("/list/errand")
@AuthCheck(mustRole = UserConstant.ERRAND_ROLE)
public BaseResponse<List<OrderErrandVO>> listOrderErrandVO (HttpServletRequest request) {
Errand loginErrand = errandService.getLoginErrand(request);
Long errandId = loginErrand.getId();
List<ErrandOrder> errandOrders = errandOrderService.list(Wrappers.<ErrandOrder>lambdaQuery()
.eq(ErrandOrder::getErrandId, errandId)
.eq(ErrandOrder::getErrandState, 4));
List<Long> orderIds = errandOrders.stream()
.map(ErrandOrder::getOrderId)
.collect(Collectors.toList());
LambdaQueryWrapper<Orders> wrapper = new LambdaQueryWrapper<>();
wrapper.in(Orders::getId, orderIds);
List<Orders> ordersList = ordersService.list(wrapper);
List<OrderErrandVO> listOrderErrandVO = ordersService.getListOrderErrandVO(ordersList);
return ResultUtils.success(listOrderErrandVO);
}
@PostMapping("/list/status")
@AuthCheck(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<List<OrderStatusVO>> listOrderStatus (HttpServletRequest request) {
List<OrderStatusVO> liststatus = ordersService.liststatus(request);
return ResultUtils.success(liststatus);
}
@PostMapping("/list/numnber")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<List<OrdersPickVO>> getPickUpNum () {
List<OrdersPickVO> ordernumbers = ordersService.getOrdernumber();
ThrowUtils.throwIf(ordernumbers == null, ErrorCode.OPERATION_ERROR, "获取单量失败");
return ResultUtils.success(ordernumbers);
}
@PostMapping("/download/errand")
public void downloadByErrand(@RequestBody OrderQueryRequest orderQueryRequest, HttpServletResponse response) throws IOException {
String startTime = orderQueryRequest.getStartTime();
String endTime = orderQueryRequest.getEndTime();
Long errandId = orderQueryRequest.getErrandId();
String sortOrder = orderQueryRequest.getSortOrder();
String sortField = orderQueryRequest.getSortField();
// 获取数据
QueryWrapper<Orders> wrapper = new QueryWrapper<>();
wrapper.ge(StringUtils.isNotBlank(startTime), "createTime", startTime);
wrapper.le(StringUtils.isNotBlank(endTime), "createTime", endTime);
wrapper.eq("errandId", errandId);
wrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC),
sortField);
List<Orders> ordersList = ordersService.list(wrapper);
Collection<Long> orderIds = ordersList.stream()
.map(Orders::getId)
.collect(Collectors.toList());
//获取errandState
LambdaQueryWrapper<ErrandOrder> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(ErrandOrder::getOrderId, orderIds);
List<ErrandOrder> errandOrders = errandOrderService.list(wrapper1);
//先将errandOrder数据变成MAP提高查询效率
Map<Long, Integer> map = errandOrders.stream()
.collect(Collectors.toMap(ErrandOrder::getOrderId, ErrandOrder::getErrandState));
//获取跑腿收入
LambdaQueryWrapper<ErrandIncome> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.in(ErrandIncome::getOrderId, orderIds);
List<ErrandIncome> errandIncomes = errandIncomeService.list(wrapper2);
Map<Long, BigDecimal> decimalMap = errandIncomes.stream()
.collect(Collectors.toMap(ErrandIncome::getOrderId, ErrandIncome::getIncome));
Collection<OrdersExcelByErrandVO> excelByErrandVOS = ordersList.stream()
.map(orders -> {
OrdersExcelByErrandVO ordersExcelByErrandVO = new OrdersExcelByErrandVO();
BeanUtils.copyProperties(orders, ordersExcelByErrandVO);
//改变订单支付状态
String stateText = ExcelUtils.getStateText(orders.getState());
ordersExcelByErrandVO.setState(stateText);
//改变跑腿订单状态
String errandStateText = ExcelUtils.getErrandStateText(map.getOrDefault(orders.getId(), 0));
ordersExcelByErrandVO.setErrandState(errandStateText);
ordersExcelByErrandVO.setErrandIncome(decimalMap.getOrDefault(orders.getId(), new BigDecimal("0.00")));
return ordersExcelByErrandVO;
}).collect(Collectors.toList());
// 设置导出名称
ExcelUtils.setExcelResponseProp(response, "跑腿订单信息");
// 获取输出流名称
try (OutputStream outputStream = response.getOutputStream()) {
EasyExcel.write(outputStream, OrdersExcelByErrandVO.class)
.sheet("订单数据")
.doWrite(excelByErrandVOS);
response.flushBuffer();
} catch (Exception e) {
log.error("Excel 导出失败", e);
}
}
@PostMapping("/count/errand")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<BigDecimal> countErrand (@RequestBody OrdersCountByErrandRequest errandRequest) {
if (errandRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long errandId = errandRequest.getErrandId();
Integer state = errandRequest.getState();
LambdaQueryWrapper<ErrandIncome> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ErrandIncome::getErrandId, errandId);
queryWrapper.eq(ObjectUtils.isNotEmpty(state), ErrandIncome::getState, state);
List<ErrandIncome> errandIncomes = errandIncomeService.list(queryWrapper);
// 计算 income 总和
BigDecimal totalIncome = errandIncomes.stream()
.map(ErrandIncome::getIncome) // 获取 income
.filter(Objects::nonNull) // 过滤掉 null
.reduce(BigDecimal.ZERO, BigDecimal::add); // 求和
return ResultUtils.success(totalIncome);
}
private BaseResponse<String> getStringBaseResponse(String type, String startTime, String endTime, QueryWrapper<Orders> queryWrapper) {
queryWrapper.ge(StringUtils.isNotBlank(startTime), "createTime", startTime);
queryWrapper.le(StringUtils.isNotBlank(endTime), "createTime", endTime);
if (type.equals("money")) {
List<Orders> ordertList = ordersService.list(queryWrapper);
List<Orders> orderList = ordersService.list(queryWrapper);
BigDecimal money = new BigDecimal("0");
for (Orders order : ordertList) {
for (Orders order : orderList) {
money = money.add(order.getTotalPrice());
}
String strMoney = String.valueOf(money);

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
@Api(tags = "阿里云文件管理")
@RestController

View File

@ -5,7 +5,7 @@ import com.bsz.school_send_back_end.service.WebsocketService;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
@RestController
public class PrivateChatController {

View File

@ -14,7 +14,7 @@ import com.bsz.school_send_back_end.service.UserService;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -32,8 +32,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
@Slf4j

View File

@ -7,8 +7,8 @@ import com.bsz.school_send_back_end.common.ResultUtils;
import com.bsz.school_send_back_end.exception.BusinessException;
import com.bsz.school_send_back_end.exception.ThrowUtils;
import com.bsz.school_send_back_end.model.domain.Systeminfo;
import com.bsz.school_send_back_end.model.dto.CommonRequest;
import com.bsz.school_send_back_end.model.dto.system.SystemAddRequest;
import com.bsz.school_send_back_end.model.dto.system.SystemDeleteRequest;
import com.bsz.school_send_back_end.model.dto.system.SystemQueryRequest;
import com.bsz.school_send_back_end.service.SysteminfoService;
import lombok.extern.slf4j.Slf4j;
@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.util.List;
@RestController
@ -49,12 +49,12 @@ public class SystemInfoController {
* 删除功能
*/
@PostMapping("/delete")
public BaseResponse<Boolean> deleteInfo (@RequestBody SystemDeleteRequest deleteRequest) {
if (deleteRequest == null) {
public BaseResponse<Boolean> deleteInfo (@RequestBody CommonRequest commonRequest) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
boolean remove = systeminfoService.removeById(deleteRequest.getId());
boolean remove = systeminfoService.removeById(commonRequest.getId());
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "添加失败");
return ResultUtils.success(true,"删除成功");
}

View File

@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -10,6 +10,7 @@ import com.alipay.api.request.*;
import com.alipay.api.response.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bsz.school_send_back_end.common.BaseResponse;
import com.bsz.school_send_back_end.common.ErrorCode;
import com.bsz.school_send_back_end.common.ResultUtils;
@ -17,14 +18,13 @@ import com.bsz.school_send_back_end.config.AlipayClients;
import com.bsz.school_send_back_end.contant.RedisKeyConstant;
import com.bsz.school_send_back_end.exception.BusinessException;
import com.bsz.school_send_back_end.exception.ThrowUtils;
import com.bsz.school_send_back_end.listener.RabbitMQSender;
import com.bsz.school_send_back_end.mapper.UserMapper;
import com.bsz.school_send_back_end.model.domain.OrderRefunds;
import com.bsz.school_send_back_end.model.domain.Orders;
import com.bsz.school_send_back_end.model.domain.User;
import com.bsz.school_send_back_end.model.vo.UserVO;
import com.bsz.school_send_back_end.service.AliPayService;
import com.bsz.school_send_back_end.service.OrdersService;
import com.bsz.school_send_back_end.service.UserService;
import com.bsz.school_send_back_end.service.WebsocketService;
import com.bsz.school_send_back_end.service.*;
import com.bsz.school_send_back_end.utils.RandomNumberGenerator;
import com.bsz.school_send_back_end.utils.UniqueNumberGenerator;
import lombok.extern.slf4j.Slf4j;
@ -34,9 +34,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.*;
@ -57,6 +57,12 @@ public class TestAlipayController {
@Resource
private WebsocketService websocketService;
@Resource
private OrderRefundsService refundsService;
@Resource
private RabbitMQSender rabbitMQSender;
@ -77,7 +83,7 @@ public class TestAlipayController {
private static String authToken;
public static final String NOURL = "http://39.101.78.35:6448/api/Alipay/notifyUrl";
public static final String NOURL = "https://xiaokuaisong.shop/api/Alipay/notifyUrl";
/**
* 解析code获取open_id和token
@ -85,28 +91,36 @@ public class TestAlipayController {
* @throws AlipayApiException 支付宝api异常
*/
@GetMapping("/parseCode")
public BaseResponse<UserVO> login(String authcode, long severId, HttpServletRequest req) throws AlipayApiException {
AlipayConfig alipayConfig = choiceServer(severId);
public BaseResponse<UserVO> login(String authcode, HttpServletRequest req) throws AlipayApiException {
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(appId);
alipayConfig.setPrivateKey(appPrivateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(PublicKey);
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
log.info("网关地址:" + alipayConfig.getServerUrl());
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode(authcode);
request.setGrantType("authorization_code");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
// System.out.println(response.getBody());打印所有响应
System.out.println( "AlipaySystemOauthTokenResponse返回数据" + response.getBody()); //打印所有响应
authToken = response.getAccessToken();
if (!response.isSuccess()) {
return ResultUtils.error(ErrorCode.PARAMS_ERROR);
}
AlipayUserInfoShareRequest request1 = new AlipayUserInfoShareRequest();
AlipayUserInfoShareResponse response1 = alipayClient.execute(request1, authToken);
System.out.println( "AlipayUserInfoShareResponse返回数据" + response1.getBody());
User oid = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getOpenId, response.getOpenId()));
UserVO userVO = new UserVO();
if (response1.isSuccess()) {
if (oid == null) {
User user = new User();
user.setOpenId(response.getOpenId());
user.setUsername(StringUtils.isAnyBlank(response1.getNickName()) ? "随机名字" + randomNumberGenerator.generateRandomNumber() : response1.getNickName());
user.setUsername(StringUtils.isAnyBlank(response1.getNickName()) ? "RandomName" + randomNumberGenerator.generateRandomNumber() : response1.getNickName());
user.setUserPassword("123456");
user.setUserAccount("yonghu" + randomNumberGenerator.generateRandomNumber());
user.setAvatarUrl(StringUtils.isAnyBlank(response1.getAvatar()) ? "https://tfs.alipayobjects.com/images/partner/ATuihpR50zu7UAAAAAAAAAAAAADtl2AA" : response1.getAvatar());
@ -142,7 +156,7 @@ public class TestAlipayController {
throw new BusinessException(ErrorCode.NO_AUTH, "你不是该订单用户!");
}
String tradeNo = aliPayService.createPayment(String.valueOf(orderId), miniOpenId, order.getTotalPrice(), order.getBusinessId());
String tradeNo = aliPayService.createPayment(String.valueOf(orderId), miniOpenId, order.getTotalPrice());
log.info("tradeNo:" + tradeNo);
return ResultUtils.success(tradeNo);
}
@ -170,7 +184,9 @@ public class TestAlipayController {
boolean update = ordersService.updateById(orders);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "修改订单状态失败");
AlipayTradeCloseResponse response = clients.alipayClient().execute(request);
if (!response.isSuccess()) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "支付宝修改订单失败");
}
//这里应该写进日志
log.info("订单已取消");
@ -178,6 +194,7 @@ public class TestAlipayController {
}
@GetMapping("/test/refund")
@Transactional(rollbackFor = Exception.class)
public String test_refund(String orderNo) throws AlipayApiException {
AlipayClients clients = new AlipayClients();
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
@ -190,7 +207,7 @@ public class TestAlipayController {
model.setOutTradeNo(orderNo);
model.setRefundAmount(String.valueOf(orders.getTotalPrice()));
//退款请求单号 要求唯一 需改
String number = UniqueNumberGenerator.generateNumber(orders.getBusinessId());
String number = UniqueNumberGenerator.generateNumber();
model.setOutRequestNo(number);
log.info("outRequestNo:" + number);
request.setBizModel(model);
@ -199,9 +216,18 @@ public class TestAlipayController {
boolean update = ordersService.updateById(orders);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "修改订单状态失败");
log.info("orderState:" + orders.getState());
OrderRefunds refunds = refundsService.getOne(Wrappers.<OrderRefunds>lambdaQuery()
.eq(OrderRefunds::getOrderId, orders.getId()));
ThrowUtils.throwIf(refunds == null, ErrorCode.OPERATION_ERROR, "没有退款");
refunds.setStatus(1); // 1-已同意
boolean updateById = refundsService.updateById(refunds);
ThrowUtils.throwIf(!updateById, ErrorCode.OPERATION_ERROR, "修改退款单失败");
AlipayTradeRefundResponse response = clients.alipayClient().execute(request);
log.info("退款成功");
String body = response.getBody();
if (!response.isSuccess()) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "支付宝退款失败");
}
log.info("退款成功");
return body;
}
@ -218,6 +244,9 @@ public class TestAlipayController {
AlipayTradeQueryResponse response = clients.alipayClient().execute(request);
String body = response.getBody();
if (!response.isSuccess()) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "支付宝查询订单失败");
}
return body;
}
@ -235,12 +264,16 @@ public class TestAlipayController {
QueryWrapper<Orders> ordersQueryWrapper = new QueryWrapper<>();
ordersQueryWrapper.eq("pickupCode", out_trade_no);
Orders orders = ordersService.getOne(ordersQueryWrapper);
if (orders.getPickupMethod() == 2) {
rabbitMQSender.sendCreateDeliveryOrderMessage(orders.getId());
}
orders.setState(1);
Date date = new Date();
orders.setUpdateTime(date);
boolean update = ordersService.updateById(orders);
log.info("orders:" + orders);
log.info("修改前orders:" + orders);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "修改订单状态失败");
log.info("修改后orders:" + orders);
//TODO 商家通知
websocketService.sendOrderMessage(orders);
@ -281,34 +314,4 @@ public class TestAlipayController {
}
}
private AlipayConfig choiceServer(long serverId) {
String testPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCc1rWOaCHl7KnDDMctWIgFJqerq9ZU8QsxSA+wQC4nrTfoQVSVZn8fDNosilCHda7yv910A9aJYqZKx0+NOXY9YvMbKYifWtO8TtzAQ9Q0EQXce85g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WPcjee45C4WEaQKBgHkUUeDb+JD+d9DIsg9uH3ANdcwunyJJ+36E7q7EgjEtCxPUsSZzWIoBsbFJppbDzbYRABA3BYjDOAPqNhJBWzeiu16cJmM28wRmqwQi+q+dPgx9EHJL/cW5b7XtkKihi3mY/AIVLI71UhfHR8JrQ9CC9oM62V2/vDNvU8AP9G91AoGANdvRubukeWgvWryBTaPuUTpjkP1mOuJuHiHEW5/XePsURwS6gGP/qJ9bSbhYhQ6iDaMOQ8vahfYM3Q4jvDxgcKS/N1fxFTohcN4bVdvekq62YdTNqcGhNzaxMNboFZYt2dPeDm8PRRMP+abddrS2NqgVSOC3Ru5Kh9iRIs2LOgE=";
String testAlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3JKMG3clg/1MqewlIK/koEhiQiSLagckb/2/Dyvg+rJ2snGiAgzNvhvvc1GdVC+Xnn/P+U+2tAytyuvbOuhmGgNZjeObczJXpo/0D6LBdYDrg4PVMDxpStCxLUpaShHbc/l/IquaorBwd94UJxIPAbUQkUBCbo94mGbhDX+yU4FQ6k1yeUtn03jvZ3AY0BEHpenCxWKgr5S/CUAYEitMbi/r7extBy6f4FCR120NM7VaNEK1xpHbGHo6rDpyiAOR1lWFuiqOJ1hv14UL/SfOLlzvUZiiPysIxdNjycZyiyRvFRHP3n8GBAaJDm9vVHwDfgQ5s3Ig2ggBeYXkFHZqWwIDAQAB";
String privateKey = appPrivateKey;
String alipayPublicKey = PublicKey;
AlipayConfig alipayConfig = new AlipayConfig();
if (serverId == 0) {
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(appId);
alipayConfig.setPrivateKey(privateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(alipayPublicKey);
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
}
else if (serverId == 1) {
alipayConfig.setServerUrl("https://openapi-sandbox.dl.alipaydev.com/gateway.do");
alipayConfig.setAppId(appId);
alipayConfig.setPrivateKey(testPrivateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(testAlipayPublicKey);
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
}
else {
throw new BusinessException(ErrorCode.PARAMS_ERROR,"网关选择错误");
}
return alipayConfig;
}
}

View File

@ -21,8 +21,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -82,12 +82,13 @@ public class UserController {
String userAccount = userLoginRequest.getUserAccount();
String userPassword = userLoginRequest.getUserPassword();
String appName = userLoginRequest.getAppName();
if (StringUtils.isAllBlank(userAccount, userPassword)){
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空");
}
String message = userService.userLogin(userAccount, userPassword, request);
String message = userService.userLogin(userAccount, userPassword, appName, request);
return ResultUtils.success(message);
}
@ -285,7 +286,7 @@ public class UserController {
*/
@GetMapping("/getById")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<User> getUserById(long id, HttpServletRequest request) {
public BaseResponse<User> getUserById(@RequestParam long id) {
if (id <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}

View File

@ -24,8 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@ -46,7 +46,6 @@ public class UserRatingController {
* @return 是否添加成功
*/
@PostMapping("/add")
@AuthCheck(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<Boolean> addRating (@RequestBody UserRatingAddRequest userRatingAddRequest, HttpServletRequest request) {
if (userRatingAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -66,18 +65,11 @@ public class UserRatingController {
* @return 是否删除成功
*/
@PostMapping("/delete")
@AuthCheck(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<Boolean> deleteUserRating (@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
public BaseResponse<Boolean> deleteUserRating (@RequestBody CommonRequest commonRequest) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long id = commonRequest.getId();
User loginUser = userService.getLoginUser(request);
Long loginUserId = loginUser.getId();
UserRating rating = userRatingService.getOne(Wrappers.<UserRating>lambdaQuery().eq(UserRating::getId, id));
ThrowUtils.throwIf(!rating.getUserId().equals(loginUserId), ErrorCode.OPERATION_ERROR,
"当前评分不属于该用户");
boolean remove = userRatingService.removeById(id);
boolean remove = userRatingService.removeById(commonRequest.getId());
ThrowUtils.throwIf(!remove, ErrorCode.SYSTEM_ERROR, "删除失败");
return ResultUtils.success(true);
@ -89,26 +81,27 @@ public class UserRatingController {
* @return 评分列表
*/
@PostMapping("/list")
public BaseResponse<List<UserRating>> listUserRating (HttpServletRequest request) {
public BaseResponse<List<UserRating>> listUserRating (@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long ratedEntityType = commonRequest.getId();
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
List<UserRating> list = userRatingService.list(Wrappers.<UserRating>lambdaQuery().eq(UserRating::getUserId, userId));
List<UserRating> list = userRatingService.list(Wrappers.<UserRating>lambdaQuery()
.eq(UserRating::getUserId, userId).eq(UserRating::getRatedEntityType, ratedEntityType) );
return ResultUtils.success(list);
}
/**
* 查看商家评分
* 展示当前用户评分
* @param request 当前用户
* @return 评分列表
*/
@PostMapping("/list/business")
public BaseResponse<List<UserRating>> listUserRatingByBusiness (@RequestBody CommonRequest commonRequest) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long businessId = commonRequest.getId();
List<UserRating> list = userRatingService.list(Wrappers.<UserRating>lambdaQuery()
.eq(UserRating::getBusinessId, businessId));
return ResultUtils.success(list);
@PostMapping("/list/user")
public BaseResponse<List<UserRating>> listUserRatingByUser (HttpServletRequest request) {
List<UserRating> userRatings = userRatingService.listUserRatingByUser(request);
return ResultUtils.success(userRatings);
}
@PostMapping("/business/reply")
@ -128,4 +121,16 @@ public class UserRatingController {
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
}
@PostMapping("/list/business")
public BaseResponse<List<UserRating>> listUserRatingByBusiness (@RequestBody CommonRequest commonRequest) {
if (commonRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long businessId = commonRequest.getId();
List<UserRating> list = userRatingService.list(Wrappers.<UserRating>lambdaQuery()
.eq(UserRating::getRatedEntityId, businessId));
return ResultUtils.success(list);
}
}

View File

@ -10,12 +10,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
import org.springframework.session.data.redis.RedisSessionRepository;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import java.util.concurrent.TimeUnit;
@ -29,7 +29,7 @@ public class SessionManager {
private StringRedisTemplate stringRedisTemplate;
@Resource
private RedisIndexedSessionRepository sessionRepository;
private RedisSessionRepository sessionRepository; // 正确类型匹配
@Value("${spring.session.timeout}")
private long sessionTimeout;
@ -41,7 +41,7 @@ public class SessionManager {
/**
* 登录
*/
public String login (User user, HttpServletRequest request) {
public String login (User user, String appName, HttpServletRequest request) {
String message = "登录成功";
String ipAddress = NetUtils.getIpAddress(request);
String oldSessionId = this.checkOtherLogin(user.getId(), ipAddress, request);
@ -54,7 +54,8 @@ public class SessionManager {
UserLoginRedisInfo build = UserLoginRedisInfo.builder()
.user(user)
.ip(ipAddress).
.ip(ipAddress)
.appName(appName).
build();
this.setLoginAttribute(request, USER_LOGIN_STATE, build);
return message;
@ -135,6 +136,7 @@ public class SessionManager {
String userExtraInfoKey = RedisKeyUtils.getUserExtraInfoKey(user.getId());
stringRedisTemplate.opsForHash().put(userExtraInfoKey, SESSION_ID, sessionId);
stringRedisTemplate.opsForHash().put(userExtraInfoKey, IP, userLoginRedisInfo.getIp());
stringRedisTemplate.opsForHash().put(userExtraInfoKey, APPNAME,userLoginRedisInfo.getAppName());
stringRedisTemplate.expire(userExtraInfoKey, sessionTimeout, TimeUnit.SECONDS);
}
else {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.BusinessAuth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Lenovo
* @description 针对表business_auth(商家认证)的数据库操作Mapper
* @createDate 2024-06-24 21:01:17
* @Entity com.bsz.school_send_back_end.model.domain.BusinessAuth
* @author xy
*/
public interface BusinessAuthMapper extends BaseMapper<BusinessAuth> {

View File

@ -7,10 +7,7 @@ import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @author pc
* @description 针对表business_level的数据库操作Mapper
* @createDate 2024-11-22 14:02:11
* @Entity com.bsz.school_send_back_end.model.domain.BusinessLevel
* @author xy
*/
public interface BusinessLevelMapper extends BaseMapper<BusinessLevel> {
}

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Business;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Lenovo
* @description 针对表business(商家)的数据库操作Mapper
* @createDate 2024-06-24 21:01:17
* @Entity com.bsz.school_send_back_end.model.domain.Business
* @author xy
*/
public interface BusinessMapper extends BaseMapper<Business> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Cart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author pc
* @description 针对表cart(购物车表)的数据库操作Mapper
* @createDate 2024-08-13 13:59:13
* @Entity com.bsz.school_send_back_end.model.domain.Cart
* @author xy
*/
public interface CartMapper extends BaseMapper<Cart> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Category;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author pc
* @description 针对表category(分类表)的数据库操作Mapper
* @createDate 2024-09-01 18:09:04
* @Entity com.bsz.school_send_back_end.model.domain.Category
* @author xy
*/
public interface CategoryMapper extends BaseMapper<Category> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author pc
* @description 针对表collect的数据库操作Mapper
* @createDate 2024-11-12 19:19:50
* @Entity com.bsz.school_send_back_end.model.domain.Collect
* @author xy
*/
public interface CollectMapper extends BaseMapper<Collect> {

View File

@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bsz.school_send_back_end.model.domain.Dishes;
/**
* @author pc
* @description 针对表dishes(菜品表)的数据库操作Mapper
* @createDate 2024-06-29 17:23:31
* @Entity com.bsz.school_send_back_end.model.domain.Dishes
* @author xy
*/
public interface DishesMapper extends BaseMapper<Dishes> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.OrderDetails;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Lenovo
* @description 针对表order_details(订单详情表)的数据库操作Mapper
* @createDate 2024-09-12 12:31:48
* @Entity com.bsz.school_send_back_end.model.domain.OrderDetails
* @author xy
*/
public interface OrderDetailsMapper extends BaseMapper<OrderDetails> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Orders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Lenovo
* @description 针对表orders(订单表)的数据库操作Mapper
* @createDate 2024-09-12 12:31:49
* @Entity com.bsz.school_send_back_end.model.domain.Orders
* @author xy
*/
public interface OrdersMapper extends BaseMapper<Orders> {

View File

@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bsz.school_send_back_end.model.domain.PrivateMessage;
/**
* @author pc
* @description 针对表private_message的数据库操作Mapper
* @createDate 2024-11-10 15:16:02
* @Entity com.bsz.school_send_back_end.model.domain.PrivateMessage
* @author xy
*/
public interface PrivateMessageMapper extends BaseMapper<PrivateMessage> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.SpecificationsDishes;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author pc
* @description 针对表specifications_dishes(菜品和规格的中间表)的数据库操作Mapper
* @createDate 2024-06-29 21:18:25
* @Entity generator.domain.SpecificationsDishes
* @author xy
*/
public interface SpecificationsDishesMapper extends BaseMapper<SpecificationsDishes> {

View File

@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bsz.school_send_back_end.model.domain.Specifications;
/**
* @author pc
* @description 针对表specifications(规格表)的数据库操作Mapper
* @createDate 2024-06-29 21:10:34
* @Entity com.bsz.school_send_back_end.model.domain.Specifications
* @author xy
*/
public interface SpecificationsMapper extends BaseMapper<Specifications> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Systeminfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author pc
* @description 针对表systeminfo(系统信息)的数据库操作Mapper
* @createDate 2024-09-23 19:16:42
* @Entity com.bsz.school_send_back_end.model.domain.Systeminfo
* @author xy
*/
public interface SysteminfoMapper extends BaseMapper<Systeminfo> {

View File

@ -4,10 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Systemlog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author pc
* @description 针对表systemlog(系统信息)的数据库操作Mapper
* @createDate 2024-09-25 15:40:09
* @Entity com.bsz.school_send_back_end.model.domain.Systemlog
* @author xy
*/
public interface SystemlogMapper extends BaseMapper<Systemlog> {

View File

@ -6,10 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/**
* @author bsz
* @description 针对表user(用户)的数据库操作Mapper
* @createDate 2024-05-09 20:59:59
*
* @author xy
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {

View File

@ -6,15 +6,12 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @author pc
* @description 针对表user_rating(用户评分)的数据库操作Mapper
* @createDate 2024-12-09 16:06:45
* @Entity com.bsz.school_send_back_end.model.domain.UserRating
* @author xy
*/
public interface UserRatingMapper extends BaseMapper<UserRating> {
// @Select("select avg(rating) from school_send.user_rating where businessId = #{businessId}")
@Select("select avg(rating) from xiaokuaisong.user_rating where businessId = #{businessId}")
Double findAvgByBusinessId(@Param("businessId") Long businessId);
@Select("select avg(rating) from xiaokuaisong.user_rating where ratedEntityId = #{ratedEntityId}")
Double findAvgByRatedEntityId(@Param("ratedEntityId") Long ratedEntityId);
}

View File

@ -1,9 +1,6 @@
package com.bsz.school_send_back_end.model.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serial;
import java.io.Serializable;
@ -72,6 +69,7 @@ public class Cart implements Serializable {
/**
* 是否删除
*/
@TableLogic
private Integer isDelete;
@Serial

View File

@ -1,9 +1,7 @@
package com.bsz.school_send_back_end.model.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@ -66,6 +64,7 @@ public class OrderDetails implements Serializable {
/**
* 是否删除
*/
@TableLogic
private Integer isDelete;
@TableField(exist = false)

View File

@ -1,12 +1,14 @@
package com.bsz.school_send_back_end.model.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
/**
@ -47,6 +49,18 @@ public class Orders implements Serializable {
*/
private Long businessId;
/**
* 跑腿id
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Long errandId;
/**
* 配送地址
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String location;
/**
* 订单实际总价
*/
@ -80,7 +94,8 @@ public class Orders implements Serializable {
/**
* 下单时间
*/
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime createTime;
/**
* 支付时间
@ -90,8 +105,10 @@ public class Orders implements Serializable {
/**
* 是否删除
*/
@TableLogic
private Integer isDelete;
@TableField(exist = false)
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -7,7 +7,18 @@ import lombok.Data;
@Builder
public class UserLoginRedisInfo {
/**
* 登录用户
*/
private User user;
/**
* 登录ip
*/
private String ip;
/**
* 登录app
*/
private String appName;
}

View File

@ -24,7 +24,12 @@ public class UserRating implements Serializable {
/**
* 商家id
*/
private Long businessId;
private Long ratedEntityId;
/**
* 评分对象类型0=商家1=跑腿
*/
private Integer ratedEntityType;
/**
* 用户id

View File

@ -6,7 +6,6 @@ import lombok.Data;
/**
* 分页请求
*
* @author bsz
*/
@Data
public class PageRequest {

View File

@ -4,7 +4,6 @@ package com.bsz.school_send_back_end.model.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serial;
import java.io.Serializable;
@ -14,7 +13,7 @@ public class UploadFileRequest implements Serializable {
/**
* 业务
*/
@Schema(description = "业务标识例如user_avatardishescardsystem")
@Schema(description = "业务标识例如user_avatardishescardsystem, takeout")
private String biz;
@Serial

View File

@ -38,6 +38,11 @@ public class OrderAddRequest implements Serializable {
*/
private Integer pickupMethod;
/**
* 配送地址
*/
private String location;
/**
* 支付方式
*/

View File

@ -1,5 +1,7 @@
package com.bsz.school_send_back_end.model.dto.order;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.bsz.school_send_back_end.model.dto.PageRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -28,6 +30,11 @@ public class OrderQueryRequest extends PageRequest implements Serializable {
*/
private Long businessId;
/**
* 跑腿id
*/
private Long errandId = null;
/**
* 取餐码
*/

View File

@ -6,7 +6,7 @@ import java.io.Serial;
import java.io.Serializable;
/**
* @author ASUS
* @author xy
*/
@Data
public class SpecificationsQueryRequest implements Serializable {

View File

@ -1,18 +0,0 @@
package com.bsz.school_send_back_end.model.dto.system;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class SystemDeleteRequest implements Serializable {
/**
* id
*/
private Long id;
@Serial
private static final long serialVersionUID = 8089646587314575974L;
}

View File

@ -10,7 +10,6 @@ import java.io.Serializable;
*
* 用户创建请求
*
* @author bsz
*/
@Data
public class UserAddRequest implements Serializable {

View File

@ -7,7 +7,6 @@ import java.io.Serializable;
/**
* 用户删除请求
*
* @author bsz
*/
@Data
public class UserDeleteRequest implements Serializable {

View File

@ -21,5 +21,10 @@ public class UserLoginRequest implements Serializable {
*/
private String userPassword;
/**
* 登录app
*/
private String appName;
}

View File

@ -9,7 +9,6 @@ import java.io.Serializable;
/**
* 用户查询请求
* @author 玄德
*/
@Data
@EqualsAndHashCode(callSuper = true)

View File

@ -9,7 +9,6 @@ import java.util.Date;
/**
* 用户查询请求
*
* @author bsz
*/
@Data
public class UserSearchRequest extends PageRequest implements Serializable {

View File

@ -5,8 +5,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* @author Shier
* CreateTime 2023/5/11 12:24
*
*/
@Data
public class UserUpdatePasswordRequest implements Serializable {

View File

@ -10,7 +10,6 @@ import java.util.Date;
/**
* 用户更新请求
*
* @author bsz
*/
@Data
public class UserUpdateRequest implements Serializable {

View File

@ -10,7 +10,12 @@ public class UserRatingAddRequest implements Serializable {
/**
* 商家id
*/
private Long businessId;
private Long ratedEntityId;
/**
* 评分对象类型1=商家2=跑腿
*/
private Integer ratedEntityType;
/**
* 用户id

View File

@ -15,7 +15,9 @@ public enum FileUploadBizEnum {
CARD_IMAGE("证件", "card"),
SYSTEM_IMAGE("系统", "system");
SYSTEM_IMAGE("系统", "system"),
TAKEOUT_IMAGE("外卖", "takeout");
private final String text;

View File

@ -15,6 +15,7 @@ public enum UserRoleEnum {
USER("用户", "user"),
BUSINESS("商家", "business"),
ERRAND("跑腿", "errand"),
ADMIN("管理员", "admin"),
BOSS("Boss", "boss"),
BAN("被封号", "ban");

View File

@ -97,8 +97,8 @@ public class BusinessVO implements Serializable {
private Integer level;
/**
* 收藏id
* 是否被收藏
*/
private Long collectId;
private Boolean isCollected;
}

View File

@ -2,6 +2,8 @@ package com.bsz.school_send_back_end.model.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bsz.school_send_back_end.model.domain.Business;
import com.bsz.school_send_back_end.model.domain.Dishes;
import lombok.Data;
import java.io.Serial;
@ -23,12 +25,12 @@ public class CartVO implements Serializable {
/**
* 商家id
*/
private Long businessId;
private Business business;
/**
* 菜品id
*/
private Long dishesId;
private Dishes dishes;
/**
* 商品数量

View File

@ -9,7 +9,6 @@ import java.util.Date;
/**
* 已登录用户视图脱敏
* @author bsz
*/
@Data
public class LoginUserVO implements Serializable {

View File

@ -6,6 +6,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Objects;
/**
* Excel订单信息导出
@ -47,6 +48,24 @@ public class OrdersExcelVO {
* 订单金额
*/
@NumberFormat("0.00")
@ExcelProperty(value = "订单金额")
@ExcelProperty(value = "订单金额", index = 4)
private BigDecimal totalPrice;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OrdersExcelVO that = (OrdersExcelVO) o;
return Objects.equals(id, that.getId()) &&
Objects.equals(createTime, that.getCreateTime()) &&
Objects.equals(phone, that.getPhone()) &&
Objects.equals(state, that.getState()) &&
Objects.equals(totalPrice.stripTrailingZeros(), that.getTotalPrice().stripTrailingZeros()); // 避免浮点精度误差
}
@Override
public int hashCode() {
return Objects.hash(id, createTime, phone, state, totalPrice.stripTrailingZeros());
}
}

View File

@ -5,6 +5,8 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@ -43,6 +45,16 @@ public class OrdersVO implements Serializable {
*/
private Long businessId;
/**
* 跑腿id
*/
private Long errandId;
/**
* 配送地址
*/
private String location;
/**
* 商家信息
*/
@ -81,7 +93,7 @@ public class OrdersVO implements Serializable {
/**
* 下单时间
*/
private Date createTime;
private LocalDateTime createTime;
/**
* 支付时间
@ -93,6 +105,26 @@ public class OrdersVO implements Serializable {
*/
private Integer number;
/**
* 店铺详细地址
*/
private String address;
/**
* 取餐开始时间
*/
private LocalDateTime pickupStartTime;
/**
* 取餐结束时间
*/
private LocalDateTime pickupEndTime;
/**
* 外卖图片
*/
private String imageAddress;
/**
* 订单详情
*/

View File

@ -2,7 +2,6 @@ package com.bsz.school_send_back_end.model.vo;
import lombok.Data;
import javax.servlet.http.HttpSession;
import java.io.Serializable;
@Data

View File

@ -1,31 +0,0 @@
package com.bsz.school_send_back_end.scheduler;
import com.bsz.school_send_back_end.model.domain.Business;
import com.bsz.school_send_back_end.service.BusinessLevelService;
import com.bsz.school_send_back_end.service.BusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Component
@Slf4j
public class UpdateBusiness {
@Resource
private BusinessService businessService;
@Resource
private BusinessLevelService businessLevelService;
@Scheduled(cron = "0 0 0 * * ?")
public void updateBusinessLevels() {
List<Business> list = businessService.list();
for (Business business : list) {
businessLevelService.updateBusinessLevel(business.getId());
}
log.info("更新时间:" + new Date());
}
}

View File

@ -1,32 +0,0 @@
package com.bsz.school_send_back_end.scheduler;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.bsz.school_send_back_end.model.domain.Orders;
import com.bsz.school_send_back_end.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
@Component
@Slf4j
public class UpdateOrderState {
@Resource
private OrdersService ordersService;
@Scheduled(cron = "0 0 */1 * * ?")
public void updateState() {
LocalDateTime twelveHoursAgo = LocalDateTime.now().minusHours(12);
LambdaUpdateWrapper<Orders> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Orders::getState, 4)
.le(Orders::getCreateTime, twelveHoursAgo);
Orders orders = new Orders();
orders.setState(5);
ordersService.update(orders, updateWrapper);
log.info("订单状态修改时间: " + new Date());
}
}

View File

@ -4,5 +4,5 @@ import java.math.BigDecimal;
public interface AliPayService {
String createPayment(String orderId, String miniOpenId, BigDecimal amount, Long businessId);
String createPayment(String orderId, String miniOpenId, BigDecimal amount);
}

View File

@ -10,7 +10,6 @@ import java.util.List;
/**
* @author Lenovo
* @description 针对表business_auth(商家认证)的数据库操作Service
* @createDate 2024-06-24 21:01:17
*/
public interface BusinessAuthService extends IService<BusinessAuth> {

View File

@ -8,7 +8,6 @@ import java.util.List;
/**
* @author pc
* @description 针对表business_level的数据库操作Service
* @createDate 2024-11-22 14:02:11
*/
public interface BusinessLevelService extends IService<BusinessLevel> {

View File

@ -8,13 +8,12 @@ import com.bsz.school_send_back_end.model.domain.User;
import com.bsz.school_send_back_end.model.dto.business.BusinessQueryRequest;
import com.bsz.school_send_back_end.model.vo.BusinessVO;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author Lenovo
* @description 针对表business(商家)的数据库操作Service
* @createDate 2024-06-24 21:01:17
*/
public interface BusinessService extends IService<Business> {
@ -26,10 +25,7 @@ public interface BusinessService extends IService<Business> {
*/
void addBusiness(User user, Business business, BusinessAuth businessAuth);
/**
*校验
*/
void validUser(User user, boolean add);
void validBusiness(Business business, boolean add);

View File

@ -5,14 +5,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsz.school_send_back_end.model.dto.cart.CartAddRequest;
import com.bsz.school_send_back_end.model.dto.cart.CartUpdateRequest;
import com.bsz.school_send_back_end.model.vo.CartVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author pc
* @description 针对表cart(购物车表)的数据库操作Service
* @createDate 2024-08-13 13:59:13
*/
public interface CartService extends IService<Cart> {
@ -36,4 +39,9 @@ public interface CartService extends IService<Cart> {
*/
Boolean deleteCart(Long cartId, HttpServletRequest request);
/**
* 获取购物车脱敏列表
*/
List<CartVO> getCartVOList(List<Cart> cartList);
}

View File

@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author pc
* @description 针对表category(分类表)的数据库操作Service
* @createDate 2024-09-01 18:09:04
*/
public interface CategoryService extends IService<Category> {
/**

View File

@ -7,14 +7,13 @@ import com.bsz.school_send_back_end.model.dto.collect.CollectAddRequest;
import com.bsz.school_send_back_end.model.vo.BusinessVO;
import com.bsz.school_send_back_end.model.vo.CollectVO;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.net.http.HttpClient;
import java.util.List;
/**
* @author pc
* @description 针对表collect的数据库操作Service
* @createDate 2024-11-12 19:19:50
*/
public interface CollectService extends IService<Collect> {

View File

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsz.school_send_back_end.model.domain.DishesGroup;
import com.bsz.school_send_back_end.model.vo.DishesGroupVO;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
/**

View File

@ -8,9 +8,7 @@ import com.bsz.school_send_back_end.model.vo.OrderDetailsVO;
import java.util.List;
/**
* @author 玄德
* @description 针对表order_details(订单详情表)的数据库操作Service
* @createDate 2024-04-05 17:57:44
* @author xy
*/
public interface OrderDetailsService extends IService<OrderDetails> {

View File

@ -5,15 +5,20 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsz.school_send_back_end.model.domain.OrderDetails;
import com.bsz.school_send_back_end.model.domain.Orders;
import com.bsz.school_send_back_end.model.dto.order.OrderQueryRequest;
import com.bsz.school_send_back_end.model.dto.order.OrderUpdateRequest;
import com.bsz.school_send_back_end.model.vo.OrderErrandVO;
import com.bsz.school_send_back_end.model.vo.OrderStatusVO;
import com.bsz.school_send_back_end.model.vo.OrdersPickVO;
import com.bsz.school_send_back_end.model.vo.OrdersVO;
import jakarta.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
* @author 玄德
* @description 针对表orders(订单表)的数据库操作Service
* @createDate 2024-04-05 17:57:44
* @author xy
*/
public interface OrdersService extends IService<Orders> {
@ -41,4 +46,45 @@ public interface OrdersService extends IService<Orders> {
*/
QueryWrapper<Orders> getQueryWrapper(OrderQueryRequest orderQueryRequest);
/**
* 悲观锁
*/
Orders getOrderWithPessimisticLock(Long ordersId);
/**
* 修改未支付订单内容
*/
Boolean OrderToUpdate(OrderUpdateRequest orderUpdateRequest, HttpServletRequest request);
/**
* 修改超时订单
*/
List<Orders> findExpiredOrders(LocalDateTime deadline);
/**
* 查询超过半个小时无人抢单的订单
*/
List<Orders> findCancelOrders(Date halfHourAgo);
/**
* 跑腿查看订单详情
*/
OrderErrandVO getOrderErrandVO(Orders orders);
/**
* 跑腿查看订单详情列表
*/
List<OrderErrandVO> getListOrderErrandVO(List<Orders> list);
/**
* 获取订单状态列表
*/
List<OrderStatusVO> liststatus(HttpServletRequest request);
/**
* 获取七天内的订单数量
*/
List<OrdersPickVO> getOrdernumber();
}

View File

@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsz.school_send_back_end.model.domain.PrivateMessage;
/**
* @author pc
* @description 针对表private_message的数据库操作Service
* @createDate 2024-11-10 15:16:02
* @author xy
*/
public interface PrivateMessageService extends IService<PrivateMessage> {

View File

@ -7,9 +7,7 @@ import com.bsz.school_send_back_end.model.vo.SpecificationsVO;
import java.util.List;
/**
* @author pc
* @description 针对表specifications_dishes(菜品和规格的中间表)的数据库操作Service
* @createDate 2024-06-29 21:18:25
* @author xy
*/
public interface SpecificationsDishesService extends IService<SpecificationsDishes> {

View File

@ -6,7 +6,7 @@ import com.bsz.school_send_back_end.model.dto.attribute.AttributeAddRequest;
import com.bsz.school_send_back_end.model.dto.attribute.AttributeUpdateRequest;
import com.bsz.school_send_back_end.model.vo.SpecificationsVO;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
/**

View File

@ -4,9 +4,7 @@ import com.bsz.school_send_back_end.model.domain.Systeminfo;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author pc
* @description 针对表systeminfo(系统信息)的数据库操作Service
* @createDate 2024-09-23 19:16:42
* @author xy
*/
public interface SysteminfoService extends IService<Systeminfo> {

View File

@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsz.school_send_back_end.model.dto.log.LogQueryRequest;
/**
* @author pc
* @description 针对表systemlog(系统信息)的数据库操作Service
* @createDate 2024-09-25 15:40:09
* @author xy
*/
public interface SystemlogService extends IService<Systemlog> {

View File

@ -3,12 +3,11 @@ package com.bsz.school_send_back_end.service;
import com.bsz.school_send_back_end.model.domain.UserRating;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author pc
* @description 针对表user_rating(用户评分)的数据库操作Service
* @createDate 2024-12-09 16:06:45
* @author xy
*/
public interface UserRatingService extends IService<UserRating> {
@ -21,4 +20,18 @@ public interface UserRatingService extends IService<UserRating> {
* 校验商家是否能够回复用户评分
*/
void validUserRatingByBusiness(Long userRatingId, HttpServletRequest request);
/**
* 根据当前用户获取评分
* @param request 当前用户
* @return 评分列表
*/
List<UserRating> listUserRatingByUser(HttpServletRequest request);
/**
* 获取等级
* @param averageScore
* @return
*/
int calculateLevel(Double averageScore);
}

View File

@ -9,12 +9,10 @@ import com.bsz.school_send_back_end.model.dto.user.UserSearchRequest;
import com.bsz.school_send_back_end.model.dto.user.UserUpdatePasswordRequest;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
/**
* @author bsz
* @description
* @createDate 2024-05-09 20:59:59
* @author xy
*/
@Service
public interface UserService extends IService<User> {
@ -37,7 +35,7 @@ public interface UserService extends IService<User> {
* @return 脱敏后的用户信息
*/
String userLogin(String userAccount, String userPassword, HttpServletRequest request);
String userLogin(String userAccount, String userPassword, String appName, HttpServletRequest request);
/**
@ -90,4 +88,9 @@ public interface UserService extends IService<User> {
LoginUserVO userLoginByAlipay(String openId, JSONObject userInfo, HttpServletRequest request);
public LoginUserVO getLoginUserVO(User user);
/**
*校验
*/
void validUser(User user, boolean add);
}

View File

@ -1,15 +1,17 @@
package com.bsz.school_send_back_end.service;
import com.bsz.school_send_back_end.common.ErrorCode;
import com.bsz.school_send_back_end.contant.UserConstant;
import com.bsz.school_send_back_end.exception.BusinessException;
import com.bsz.school_send_back_end.model.domain.Business;
import com.bsz.school_send_back_end.model.domain.Orders;
import com.bsz.school_send_back_end.model.domain.PrivateMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
@Service
@Slf4j
@ -24,6 +26,7 @@ public class WebsocketService {
@Resource
private BusinessService businessService;
private static final String ERRAND_TOPIC_PREFIX = "/topic/ServerToClient.errand.";
/**
* 简单点对点聊天
*/
@ -73,4 +76,30 @@ public class WebsocketService {
log.info("订单信息推送成功目标用户ID: {}", userId);
}
/**
* 商家将订单发送给跑腿
*/
@Async
public void sendOrderToErrand(Orders orders) {
if (orders == null || orders.getLocation() == null || orders.getLocation().trim().isEmpty()) {
log.error("订单信息或跑腿位置不完整,无法推送: {}", orders);
throw new BusinessException(ErrorCode.PARAMS_ERROR, "订单信息或位置信息不完整");
}
String location = orders.getLocation();
// 校验位置是否有效
if (!UserConstant.VALID_LOCATIONS.contains(location)) {
log.error("非法位置,无法推送订单: 位置 = {}", location);
throw new BusinessException(ErrorCode.PARAMS_ERROR, "位置不合法");
}
log.info("正在向跑腿推送订单信息, 订单ID: {}, 位置: {}", orders.getId(), location);
String destination = ERRAND_TOPIC_PREFIX + location;
template.convertAndSend(destination, orders);
log.info("订单推送成功,位置: {}", location);
}
}

View File

@ -17,10 +17,12 @@ import com.bsz.school_send_back_end.service.OrderDetailsService;
import com.bsz.school_send_back_end.service.OrdersService;
import com.bsz.school_send_back_end.utils.UniqueNumberGenerator;
import lombok.extern.slf4j.Slf4j;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
@ -37,18 +39,17 @@ public class AlipayServiceImpl implements AliPayService {
@Override
@Transactional(rollbackFor = Exception.class)
public synchronized String createPayment(String orderId, String miniOpenId, BigDecimal amount, Long businessId) {
public synchronized String createPayment(String orderId, String miniOpenId, BigDecimal amount) {
//创建客户
AlipayClients clients = new AlipayClients();
//AlipayClient client = clients.alipayClient();
//创建交易请求
AlipayTradeCreateRequest aliRequest = new AlipayTradeCreateRequest();
//创建实体类
AlipayTradeCreateModel model = new AlipayTradeCreateModel();
// 构造 JSON 字符串作为 biz_content
JSONObject bizContent = new JSONObject();
//请求参数 沙箱内部参数
String outTradeNo = UniqueNumberGenerator.generateNumber(businessId);
String outTradeNo = UniqueNumberGenerator.generateNumber();
Orders order = ordersService.getById(orderId);
if (order == null) {
@ -67,17 +68,19 @@ public class AlipayServiceImpl implements AliPayService {
boolean update = ordersService.updateById(order);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "修改订单状态失败");
model.setOutTradeNo(outTradeNo);
model.setTotalAmount(String.valueOf(amount));
model.setSubject(subject);
model.setProductCode("JSAPI_PAY");
model.setSellerId("2088721037756350");
model.setBuyerId("2088722037756360");
model.setOpAppId("2021004151684053");
try {
bizContent.put("out_trade_no", outTradeNo);
bizContent.put("total_amount", amount.toString());
bizContent.put("subject", subject);
bizContent.put("product_code", "JSAPI_PAY");
bizContent.put("seller_id", "2088932829893612");
bizContent.put("buyer_open_id", miniOpenId); // 关键字段放进 biz_content
} catch (JSONException e) {
throw new RuntimeException(e);
}
///回调地址
aliRequest.setNotifyUrl("http://39.101.78.35:6448/api/Alipay/notifyUrl");
aliRequest.setBizModel(model);
aliRequest.setBizContent(bizContent.toString());
aliRequest.setNotifyUrl("https://xiaokuaisong.shop:6448/api/Alipay/notifyUrl");
String trade_no = null;
try {
AlipayTradeCreateResponse response = clients.alipayClient().execute(aliRequest);
@ -88,6 +91,7 @@ public class AlipayServiceImpl implements AliPayService {
} catch (AlipayApiException e) {
e.printStackTrace();
}
log.info("trade_no:" + trade_no);
return trade_no;
}
}

View File

@ -13,9 +13,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
/**
* @author Lenovo
* @description 针对表business_auth(商家认证)的数据库操作Service实现
* @createDate 2024-06-24 21:01:17
* @author xy
*/
@Service
public class BusinessAuthServiceImpl extends ServiceImpl<BusinessAuthMapper, BusinessAuth>

View File

@ -2,6 +2,7 @@ package com.bsz.school_send_back_end.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsz.school_send_back_end.contant.UserConstant;
import com.bsz.school_send_back_end.mapper.UserRatingMapper;
import com.bsz.school_send_back_end.model.domain.BusinessLevel;
import com.bsz.school_send_back_end.service.BusinessLevelService;
@ -9,14 +10,12 @@ import com.bsz.school_send_back_end.mapper.BusinessLevelMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
/**
* @author pc
* @description 针对表business_level的数据库操作Service实现
* @createDate 2024-11-22 14:02:11
* @author xy
*/
@Service
@Slf4j
@ -31,9 +30,9 @@ public class BusinessLevelServiceImpl extends ServiceImpl<BusinessLevelMapper, B
@Override
public void updateBusinessLevel(Long businessId) {
Double avg = userRatingMapper.findAvgByBusinessId(businessId);
Double avg = userRatingMapper.findAvgByRatedEntityId(businessId);
if (avg == null) {
avg = 1.0;
avg = UserConstant.DEFAULT_AVG_SCORE;
log.info("warn: avg没有值将赋初始值1" + avg);
log.info("当前商家id" + businessId);
}
@ -44,7 +43,7 @@ public class BusinessLevelServiceImpl extends ServiceImpl<BusinessLevelMapper, B
if (businessLevel == null) {
businessLevel = new BusinessLevel();
businessLevel.setBusinessId(businessId);
businessLevel.setLevel(1);
businessLevel.setLevel(UserConstant.DEFAULT_LEVEL);
businessLevel.setAverageScore(BigDecimal.valueOf(1));
}
businessLevel.setAverageScore(BigDecimal.valueOf(avg));

View File

@ -2,6 +2,7 @@ package com.bsz.school_send_back_end.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsz.school_send_back_end.common.ErrorCode;
import com.bsz.school_send_back_end.contant.CommonConstant;
@ -26,8 +27,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@ -35,9 +36,7 @@ import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Lenovo
* @description 针对表business(商家)的数据库操作Service实现
* @createDate 2024-06-24 21:01:17
* @author xy
*/
@Service
public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
@ -69,35 +68,10 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
//添加认证信息
businessAuth.setBusinessId(business.getId());
boolean save2 = businessAuthService.save(businessAuth);
ThrowUtils.throwIf(!save1, ErrorCode.OPERATION_ERROR, "商家认证信息失败");
ThrowUtils.throwIf(!save2, ErrorCode.OPERATION_ERROR, "商家认证信息失败");
}
businessLevelService.updateBusinessLevel(business.getId());
@Override
public void validUser(User user, boolean add) {
ThrowUtils.throwIf(user == null , ErrorCode.NULL_ERROR);
String userAccount = user.getUserAccount();
String userPassword = user.getUserPassword();
if (add) {
ThrowUtils.throwIf(StringUtils.isAllBlank(userAccount, userPassword), ErrorCode.PARAMS_ERROR);
if (userAccount.length() < 4) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户账号不符合要求");
}
if(userPassword.length() < 8) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "用户密码不符合要求");
}
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userAccount", userAccount);
long count = userService.count(queryWrapper);
if (count > 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "账号重复");
}
}
}
@Override
@ -184,11 +158,18 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
@Override
public BusinessVO getBusinessVO(Business business) {
BusinessVO businessVO = new BusinessVO();
BusinessVO businessVO = new BusinessVO();
if (business == null) {
return null;
}
BeanUtils.copyProperties(business,businessVO);
BusinessLevel businessLevel = businessLevelService.getOne(Wrappers.<BusinessLevel>lambdaQuery()
.eq(BusinessLevel::getBusinessId, business.getId()));
if (businessLevel == null) {
throw new BusinessException(ErrorCode.OPERATION_ERROR,"当前商家没有等级");
}
Integer level = businessLevel.getLevel();
businessVO.setLevel(level);
return businessVO;
}
@ -197,7 +178,14 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
if (CollectionUtils.isEmpty(businessList)) {
return new ArrayList<>();
}
return businessList.stream().map(this::getBusinessVO).collect(Collectors.toList());
return businessList.stream().map(business -> {
BusinessVO businessVO = new BusinessVO();
BeanUtils.copyProperties(business, businessVO);
BusinessLevel businessLevel = businessLevelService.getOne(Wrappers.<BusinessLevel>lambdaQuery()
.eq(BusinessLevel::getBusinessId, business.getId()));
businessVO.setLevel(businessLevel.getLevel());
return businessVO;
}).collect(Collectors.toList());
}
@Override

View File

@ -11,19 +11,25 @@ import com.bsz.school_send_back_end.model.domain.Dishes;
import com.bsz.school_send_back_end.model.domain.User;
import com.bsz.school_send_back_end.model.dto.cart.CartAddRequest;
import com.bsz.school_send_back_end.model.dto.cart.CartUpdateRequest;
import com.bsz.school_send_back_end.model.vo.CartVO;
import com.bsz.school_send_back_end.service.BusinessService;
import com.bsz.school_send_back_end.service.CartService;
import com.bsz.school_send_back_end.mapper.CartMapper;
import com.bsz.school_send_back_end.service.DishesService;
import com.bsz.school_send_back_end.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author pc
* @author xy
*/
@Service
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart>
@ -131,6 +137,23 @@ public class CartServiceImpl extends ServiceImpl<CartMapper, Cart>
return true;
}
@Override
public List<CartVO> getCartVOList(List<Cart> cartList) {
if (CollectionUtils.isEmpty(cartList)) {
return new ArrayList<>();
}
return cartList.stream().map(item ->{
CartVO cartVO = new CartVO();
BeanUtils.copyProperties(item, cartVO);
Business business = businessService.getById(item.getBusinessId());
Dishes dishes = dishesService.getById(item.getDishesId());
cartVO.setBusiness(business);
cartVO.setDishes(dishes);
return cartVO;
}).collect(Collectors.toList());
}
}

View File

@ -11,7 +11,7 @@ import com.bsz.school_send_back_end.mapper.CategoryMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
/**
* @author xy

Some files were not shown because too many files have changed in this diff Show More