沙箱支付配置

This commit is contained in:
gaomusan 2025-02-25 14:13:52 +08:00
parent 030f4c7f3b
commit c8b3fffd82
32 changed files with 283 additions and 579 deletions

View File

@ -1,33 +0,0 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@ -1,259 +0,0 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.3.2
#
# Optional ENV vars
# -----------------
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
# MVNW_REPOURL - repo url base for downloading maven distribution
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
# ----------------------------------------------------------------------------
set -euf
[ "${MVNW_VERBOSE-}" != debug ] || set -x
# OS specific support.
native_path() { printf %s\\n "$1"; }
case "$(uname)" in
CYGWIN* | MINGW*)
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
native_path() { cygpath --path --windows "$1"; }
;;
esac
# set JAVACMD and JAVACCMD
set_java_home() {
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
if [ -n "${JAVA_HOME-}" ]; then
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACCMD="$JAVA_HOME/jre/sh/javac"
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACCMD="$JAVA_HOME/bin/javac"
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
return 1
fi
fi
else
JAVACMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v java
)" || :
JAVACCMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v javac
)" || :
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
return 1
fi
fi
}
# hash string like Java String::hashCode
hash_string() {
str="${1:-}" h=0
while [ -n "$str" ]; do
char="${str%"${str#?}"}"
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
str="${str#?}"
done
printf %x\\n $h
}
verbose() { :; }
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
die() {
printf %s\\n "$1" >&2
exit 1
}
trim() {
# MWRAPPER-139:
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
# Needed for removing poorly interpreted newline sequences when running in more
# exotic environments such as mingw bash on Windows.
printf "%s" "${1}" | tr -d '[:space:]'
}
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
while IFS="=" read -r key value; do
case "${key-}" in
distributionUrl) distributionUrl=$(trim "${value-}") ;;
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
esac
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
case "${distributionUrl##*/}" in
maven-mvnd-*bin.*)
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
*)
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
distributionPlatform=linux-amd64
;;
esac
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
;;
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
esac
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
distributionUrlName="${distributionUrl##*/}"
distributionUrlNameMain="${distributionUrlName%.*}"
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
exec_maven() {
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
}
if [ -d "$MAVEN_HOME" ]; then
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
exec_maven "$@"
fi
case "${distributionUrl-}" in
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
esac
# prepare tmp dir
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
trap clean HUP INT TERM EXIT
else
die "cannot create temp dir"
fi
mkdir -p -- "${MAVEN_HOME%/*}"
# Download and Install Apache Maven
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
verbose "Downloading from: $distributionUrl"
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
# select .zip or .tar.gz
if ! command -v unzip >/dev/null; then
distributionUrl="${distributionUrl%.zip}.tar.gz"
distributionUrlName="${distributionUrl##*/}"
fi
# verbose opt
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
# normalize http auth
case "${MVNW_PASSWORD:+has-password}" in
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
esac
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
verbose "Found wget ... using wget"
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
verbose "Found curl ... using curl"
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
elif set_java_home; then
verbose "Falling back to use Java to download"
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
cat >"$javaSource" <<-END
public class Downloader extends java.net.Authenticator
{
protected java.net.PasswordAuthentication getPasswordAuthentication()
{
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
}
public static void main( String[] args ) throws Exception
{
setDefault( new Downloader() );
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
}
}
END
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
verbose " - Compiling Downloader.java ..."
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
verbose " - Running Downloader.java ..."
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
fi
# If specified, validate the SHA-256 sum of the Maven distribution zip file
if [ -n "${distributionSha256Sum-}" ]; then
distributionSha256Result=false
if [ "$MVN_CMD" = mvnd.sh ]; then
echo "Checksum validation is not supported for maven-mvnd." >&2
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
elif command -v sha256sum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
elif command -v shasum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
fi
if [ $distributionSha256Result = false ]; then
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
exit 1
fi
fi
# unzip and move
if command -v unzip >/dev/null; then
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
else
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
fi
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
clean || :
exec_maven "$@"

View File

@ -1,149 +0,0 @@
<# : batch portion
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.3.2
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
@SET __MVNW_CMD__=
@SET __MVNW_ERROR__=
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
@SET PSModulePath=
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
)
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
@SET __MVNW_PSMODULEP_SAVE=
@SET __MVNW_ARG0_NAME__=
@SET MVNW_USERNAME=
@SET MVNW_PASSWORD=
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
@echo Cannot start maven from wrapper >&2 && exit /b 1
@GOTO :EOF
: end batch / begin powershell #>
$ErrorActionPreference = "Stop"
if ($env:MVNW_VERBOSE -eq "true") {
$VerbosePreference = "Continue"
}
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
if (!$distributionUrl) {
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
}
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
"maven-mvnd-*" {
$USE_MVND = $true
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
$MVN_CMD = "mvnd.cmd"
break
}
default {
$USE_MVND = $false
$MVN_CMD = $script -replace '^mvnw','mvn'
break
}
}
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
}
$distributionUrlName = $distributionUrl -replace '^.*/',''
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
if ($env:MAVEN_USER_HOME) {
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
}
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
exit $?
}
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
}
# prepare tmp dir
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
trap {
if ($TMP_DOWNLOAD_DIR.Exists) {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
}
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
# Download and Install Apache Maven
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
Write-Verbose "Downloading from: $distributionUrl"
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
$webclient = New-Object System.Net.WebClient
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
# If specified, validate the SHA-256 sum of the Maven distribution zip file
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
if ($distributionSha256Sum) {
if ($USE_MVND) {
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
}
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
}
}
# unzip and move
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
try {
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
} catch {
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
Write-Error "fail to move MAVEN_HOME"
}
} finally {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"

View File

@ -14,18 +14,7 @@
<name>jiaqingjiayi</name>
<description>jiaqingjiayi</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>

View File

@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cj.jiaqingjiayi.common.BaseResponse;
import com.cj.jiaqingjiayi.common.ErrorCode;
import com.cj.jiaqingjiayi.common.ResultUtils;
import com.cj.jiaqingjiayi.contant.RedisKeyConstant;
import com.cj.jiaqingjiayi.contant.UserConstant;
import com.cj.jiaqingjiayi.exception.BusinessException;
import com.cj.jiaqingjiayi.exception.ThrowUtils;
@ -21,12 +22,14 @@ import com.cj.jiaqingjiayi.model.domain.OrderItems;
import com.cj.jiaqingjiayi.model.domain.Orders;
import com.cj.jiaqingjiayi.model.domain.User;
import com.cj.jiaqingjiayi.model.request.CreateAlipayRequest;
import com.cj.jiaqingjiayi.model.vo.UserVO;
import com.cj.jiaqingjiayi.service.OrderItemsService;
import com.cj.jiaqingjiayi.service.OrdersService;
import com.cj.jiaqingjiayi.service.UserService;
import com.cj.jiaqingjiayi.utils.RandomNumberGenerator;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -75,28 +78,15 @@ public class AlipayController {
/**
* 解析code获取open_id和token
*
* @return aaa
* @throws AlipayApiException 支付宝api异常
*/
@GetMapping("/parseCode")
public BaseResponse<User> login(String authCode, HttpServletRequest req) throws AlipayApiException {
String privateKey = appPrivateKey;
String alipayPublicKey = PublicKey;
AlipayConfig alipayConfig = new AlipayConfig();
//沙箱网关
// alipayConfig.setServerUrl("https://openapi-sandbox.dl.alipaydev.com/gateway.do");
//支付宝网关
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");
public BaseResponse<UserVO> login(String authcode, long severId, HttpServletRequest req) throws AlipayApiException {
AlipayConfig alipayConfig = choiceServer(severId);
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode(authCode);
request.setCode(authcode);
request.setGrantType("authorization_code");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
// System.out.println(response.getBody());打印所有响应
@ -106,42 +96,50 @@ public class AlipayController {
}
AlipayUserInfoShareRequest request1 = new AlipayUserInfoShareRequest();
AlipayUserInfoShareResponse response1 = alipayClient.execute(request1, authToken);
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.setUserPassword("123456");
user.setUserAccount("用户" + randomNumberGenerator.generateRandomNumber());
user.setAvatarUrl(StringUtils.isAnyBlank(response1.getAvatar()) ? "https://tfs.alipayobjects.com/images/partner/ATuihpR50zu7UAAAAAAAAAAAAADtl2AA" : response1.getAvatar());
userMapper.insert(user);
req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE, user);
return ResultUtils.success(user, "注册成功");
req.getSession().setAttribute(RedisKeyConstant.USER_LOGIN_STATE,user);
BeanUtils.copyProperties(user, userVO);
userVO.setSessionId(req.getSession().getId());
return ResultUtils.success(userVO,"注册成功");
}
req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE, oid);
return ResultUtils.success(oid, "登录成功");
req.getSession().setAttribute(RedisKeyConstant.USER_LOGIN_STATE, oid);
BeanUtils.copyProperties(oid, userVO);
userVO.setSessionId(req.getSession().getId());
return ResultUtils.success(userVO,"登录成功");
}
req.getSession().setAttribute(UserConstant.USER_LOGIN_STATE, oid);
return ResultUtils.success(oid, "登录成功");
req.getSession().setAttribute(RedisKeyConstant.USER_LOGIN_STATE,oid);
BeanUtils.copyProperties(oid, userVO);
userVO.setSessionId(req.getSession().getId());
return ResultUtils.success(userVO,"登录成功");
}
/**
* 创建支付
* @param createAlipayRequest
* @param request
* @return
* @throws AlipayApiException
*/
@Transactional(rollbackFor = Exception.class)
@GetMapping("/create/alipay")
public BaseResponse<String> AlipayTradeCreate(@RequestBody CreateAlipayRequest createAlipayRequest, HttpServletRequest request) throws AlipayApiException {
public BaseResponse<String> AlipayTradeCreate(@RequestParam Long id, HttpServletRequest request) throws AlipayApiException {
User loginUser = userService.getLoginUser(request);
String miniOpenId = loginUser.getOpenId();
ThrowUtils.throwIf(miniOpenId == null, ErrorCode.NOT_FOUND_ERROR, "不是小程序用户");
QueryWrapper<Orders> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("orderNumber", createAlipayRequest.getOrderNumber());
queryWrapper.eq("orderNumber", id);
Orders order = ordersService.getOne(queryWrapper);
ThrowUtils.throwIf(order == null, ErrorCode.NOT_FOUND_ERROR, "订单不存在");
@ -269,4 +267,34 @@ public class AlipayController {
alipayConfig.setSignType("RSA2");
return alipayConfig;
}
private AlipayConfig choiceServer(long serverId) {
String testPrivateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7rWG3si4XQlDEHjSe/ot98aCn/R25fCSiCBIUTTA6Wy3Gs5lk1XERw1N6loq8u9zR8vTQwzLnFmepwJx2sMLHGfJT3F6Y7Lx0z7gLYksMe+LIAfc+KYsfs0IyDvoKvwsm7XAzl8AYiqk1/p2dxc5etdvkLO7bXquyCDOclR3lL9NBgbJ6tH0fvcVd3RPmZk5Tb2hfn5JK1s/tAanbvFtKhLNCwX8qZp25+AfPakx2tRZkSgjh+fjA6ZElUnwq9ftHy16vfSmnX3C3LuDSKduo3EBkDhpGjTD5+zOs8tKGofW2gn347ouzXWnTz71ftzVwAgFUcOh4Ib0GVC9SKZBrAgMBAAECggEBAJEK8R8/tEFDfhnjYjWScYm3KLtLciJ8n+8dn6NS+DfRabJL8PutvUHGHAj8uWIdKg6T3sJMaVWQyjK16fYMq6umENLg17cGFquMMSeTIn8Wa3C5nDPNdXjdWAZJ7tJJTTwbeoBVAh+1YgqZqYRacCBgGf3hAARHyRfBIOodkEojc4oyzlbUGOz+Ee6/b+A9BZd84YWkbg/KlD9mlqSAYSGCKBM9nd8l1YIvr/4OgBn679x+A8pB8i5kGxP4fertZl2mkt75LigJ3Ab/vwoHDj1AuPjlUIce+PcTdxHqgNtIJSDWbop70BGPp0XQE9BRefPIPQfS9+2LO+eFeo4ESeECgYEA+DzH4cLoMYG9Hfq9IIbQyq6VJeip4/Lbv8h4RevGPHqyFIKB3fX7bHRlBB8hCnyX+zj4T/K50LEoZmo4tpVCv7YmRkyGRoF0QwaMgbo3bkaaCZeQnuPeZFaqyhszcJL1nhLghSNKcU75orStqf4H2mLL67VH1PkjelAWMrY1JVsCgYEAwYvMNzPkLG+p9MqGlkxgu2gQ6F4SdQp35XLHjygyTMG+qt/cPAbviyOILUhTLHP1s++kgw7z/qJPcNCQVVMWL6aBM40aRb+FiMajHouGe/q26zuDdtgsuqoN84/9phs7495Oa8ROxu6eZPuvU+OJNCgf/NMVkURbOpXtbe+yXjECgYBZwhiAQGqW5BOO0IgsR7MdZm0VrQApJTpiKUmb9rnSSocztVDiAjysJZYVHHBlC1IlC591wQ2BMV2rUoM5OdVN3r4OM0NmIQ754VdS3ROH801lZIFtgnV6kH/m3lkGPo1DYA4A9hbHy8emFnCpA+qxA4I6s2zKzF8Qrf6ozYt/+wKBgChyjrr6nTSsIViG+pluXMjNdrsY7cKH7YaF9i50uA5SbwZGwj/JM0ZgppTQCJHBqhdwfXDmLxeH1BI/g+pQ8tICef3L/zGUVNPAr1Yy0mgWfSOrzE2J388iuserz9Zm2p1EWB8tZ0krlO6Fqp5dbs73k7fCZT92iZo0uum+rggBAoGBAIO74oQpY3lY6OgvjZJAHcr9RiGPB7qQ+zmROxCqzFXdtNZ5sHb1Jdg+IsBcI7ZadFT28x/ENNpfO78mC+1j56mmN9BUpORBIcCaEzp2KYgP7e4FnWTluMvFV/2yBMlCfUEYHPfPK1TfD05oBJY4lTMD2qsT5RhS1ipFqagZgQ1X";
String testAlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo9gmNSz8l/eH4Uem6hqNoK1t91Gu5evoooJKzZraxPYW9AyJwH8Mxbag3qVaRSalz+OIHHVqszUxah98DbvaxJbpY9tB2zaLSvxhXM4U5iGFR3TqdqqvxsXsfiu+a0JHauuGYtuuNmUwR7ZFVub8Ma/YBCHfELPvl1TcX8MgMlHqw3NQqcEXZZO8Ziyxel7CqgHDx5dFn1meHDFWTajbWN/0TWSzvYAOKrlrS3LjjwbDzTr3BQzH84TLbLkBaMVGEUkJZUrVVkiN3XEVBpBUs5Cv5INN4L+UJ4kDy1u6LICzUVSSrQmHItuA+YiFHZ/WVJ18jISn0W7YZVyRqTo2sQIDAQAB";
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,6 +21,12 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
@Slf4j
@ -39,16 +45,30 @@ public class AppointmentsController {
@PostMapping("/add")
public BaseResponse<Long> addAppointments(@RequestBody AppointmentsAddRequest appointmentsAddRequest, HttpServletRequest request){
//校验是否登录
User loginUser = userService.getLoginUser(request);
// User loginUser = userService.getLoginUser(request);
ThrowUtils.throwIf(appointmentsAddRequest== null, ErrorCode.NULL_ERROR);
String appointmentTime = appointmentsAddRequest.getAppointmentTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd HH:mm");
// 提取当前年份
int year = LocalDate.now().getYear();
// 解析成 LocalDate LocalTime
LocalDate date = LocalDate.parse(year + "-" + appointmentTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
LocalTime time = LocalTime.parse(appointmentTime, formatter);
// 合并为 LocalDateTime
LocalDateTime dateTime = LocalDateTime.of(date, time);
// LocalDateTime 转为 Date
Date date1 = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
Appointments appointments = new Appointments();
appointments.setAppointmentTime(date1);
//不传入默认用户昵称
if (appointmentsAddRequest.getUsername() == null) {
appointmentsAddRequest.setUsername(loginUser.getUsername());
}
// if (appointmentsAddRequest.getUsername() == null) {
// appointmentsAddRequest.setUsername(loginUser.getUsername());
// }
BeanUtils.copyProperties(appointmentsAddRequest, appointments);
appointments.setUserId(loginUser.getId());
appointments.setUserId(appointments.getUserId());
//校验是否输入必要的数据
appointmentsService.valid(appointments);
@ -60,12 +80,12 @@ public class AppointmentsController {
}
@ApiOperation(value = "查询我的预约")
@GetMapping("/query")
public BaseResponse<List<AppointmentsVO>> queryMyAppointments(HttpServletRequest request){
User loginUser = userService.getLoginUser(request);
@PostMapping("/query")
public BaseResponse<List<AppointmentsVO>> queryMyAppointments(@RequestBody CommonRequest commonRequest, HttpServletRequest request){
// User loginUser = userService.getLoginUser(request);
Long userid = commonRequest.getId();
QueryWrapper<Appointments> wrapper = new QueryWrapper<>();
wrapper.eq("userId", loginUser.getId());
wrapper.eq("userId", userid);
List<Appointments> appointmentsList = appointmentsService.list(wrapper);
List<AppointmentsVO> appointmentsVOList = appointmentsService.queryAppointmentsVO(appointmentsList);

View File

@ -19,6 +19,7 @@ import com.cj.jiaqingjiayi.model.vo.BusinessVO;
import com.cj.jiaqingjiayi.service.BusinessAuthService;
import com.cj.jiaqingjiayi.service.BusinessService;
import com.cj.jiaqingjiayi.service.UserService;
import com.cj.jiaqingjiayi.utils.BeanCopyUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -106,7 +107,8 @@ public class BusinessController {
Business business = new Business();
BeanUtils.copyProperties(businessUpdateRequest, business);
// BeanUtils.copyProperties(businessUpdateRequest, business);
BeanCopyUtils.copyPropertiesIgnoreEmpty(businessUpdateRequest, business);
//更新不添加 只需要判断修改符不符合逻辑
businessService.validBusiness(business, false);

View File

@ -7,15 +7,14 @@ import com.cj.jiaqingjiayi.common.ErrorCode;
import com.cj.jiaqingjiayi.common.ResultUtils;
import com.cj.jiaqingjiayi.exception.BusinessException;
import com.cj.jiaqingjiayi.exception.ThrowUtils;
import com.cj.jiaqingjiayi.model.domain.Cart;
import com.cj.jiaqingjiayi.model.domain.Commodities;
import com.cj.jiaqingjiayi.model.domain.User;
import com.cj.jiaqingjiayi.model.CommonRequest;
import com.cj.jiaqingjiayi.model.domain.*;
import com.cj.jiaqingjiayi.model.request.cart.CartAddRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartDeleteRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartQueryRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartUpdateRequest;
import com.cj.jiaqingjiayi.model.vo.CartVO;
import com.cj.jiaqingjiayi.model.vo.CommoditiesVO;
import com.cj.jiaqingjiayi.model.vo.*;
import com.cj.jiaqingjiayi.service.BusinessService;
import com.cj.jiaqingjiayi.service.CartService;
import com.cj.jiaqingjiayi.service.CommoditiesService;
import com.cj.jiaqingjiayi.service.UserService;
@ -48,6 +47,9 @@ public class CartController {
@Resource
private UserService userService;
@Resource
private BusinessService businessService;
@Resource
private CommoditiesService commoditiesService;
@ -116,8 +118,7 @@ public class CartController {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long id = cartDeleteRequest.getId();
Boolean cart = cartService.deleteCart(id, request);
Boolean cart = cartService.deleteCart(cartDeleteRequest, request);
ThrowUtils.throwIf(!cart, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
}
@ -130,22 +131,37 @@ public class CartController {
*/
@ApiOperation(value = "根据商户id获取购物车脱敏列表")
@PostMapping("/selectByBusinessId")
public BaseResponse<List<CartVO>> selectByBusinessId (@RequestBody CartQueryRequest cartQueryRequest, HttpServletRequest request) {
public BaseResponse<CartResponseVO> selectByBusinessId(@RequestBody CartQueryRequest cartQueryRequest, HttpServletRequest request) {
if (cartQueryRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long businessId = cartQueryRequest.getId();
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
Long userId = cartQueryRequest.getUserId();
// 查询购物车列表
LambdaQueryWrapper<Cart> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Cart::getBusinessId, businessId);
queryWrapper.eq(Cart::getUserId, userId);
List<Cart> cartList = cartService.list(queryWrapper);
// 查询对应的 Business 信息
Business business = businessService.getById(businessId);
if (business == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "商家不存在");
}
// 转换 Cart 数据为 CartVO
List<CartVO> cartVOList = this.getCartVOList(cartList);
return ResultUtils.success(cartVOList);
// 封装返回对象
CartResponseVO responseVO = new CartResponseVO();
responseVO.setBusiness(business);
responseVO.setCartList(cartVOList);
return ResultUtils.success(responseVO);
}
/**
* 根据用户查找购物车列表
* @param request 网络请求
@ -153,15 +169,28 @@ public class CartController {
*/
@ApiOperation(value = "根据用户查找购物车列表")
@PostMapping("/selectByUserId")
public BaseResponse<List<CartVO>> selectByUserId (HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
public BaseResponse<List<CartDTO>> selectByUserId (@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
// User loginUser = userService.getLoginUser(request);
// Long userId = loginUser.getId();
Long userId = commonRequest.getId();
LambdaQueryWrapper<Cart> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Cart::getUserId, userId);
List<CartDTO> cartDTOList = new ArrayList<>();
List<Cart> cartList = cartService.list(wrapper);
List<CartVO> cartVOList = this.getCartVOList(cartList);
return ResultUtils.success(cartVOList);
// 遍历 UserRating 列表根据 userId 查询 User 信息
for (CartVO cartVO : cartVOList) {
Business business = businessService.getById(cartVO.getBusinessId());
CartDTO cartDTO = new CartDTO();
cartDTO.setCartVO(cartVO);
cartDTO.setBusiness(business);
cartDTOList.add(cartDTO);
}
return ResultUtils.success(cartDTOList);
}
/**
@ -178,8 +207,9 @@ public class CartController {
}
Long businessId = cartQueryRequest.getId();
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
// User loginUser = userService.getLoginUser(request);
// Long userId = loginUser.getId();
Long userId = cartQueryRequest.getUserId();
LambdaQueryWrapper<Cart> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Cart::getBusinessId, businessId);
queryWrapper.eq(Cart::getUserId, userId);
@ -196,9 +226,10 @@ public class CartController {
*/
@ApiOperation(value = "清空用户购物车")
@PostMapping("/empty/user")
public BaseResponse<Boolean> emptyUserCart(HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
public BaseResponse<Boolean> emptyUserCart(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
// User loginUser = userService.getLoginUser(request);
// Long userId = loginUser.getId();
Long userId = commonRequest.getId();
LambdaQueryWrapper<Cart> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Cart::getUserId, userId);
boolean remove = cartService.remove(queryWrapper);

View File

@ -1,5 +1,6 @@
package com.cj.jiaqingjiayi.controller;
import com.alipay.api.domain.CPBillModifySet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cj.jiaqingjiayi.common.BaseResponse;
@ -49,6 +50,7 @@ public class CollectController {
}
collectService.validCollect(collectAddRequest);
Collect collect = new Collect();
collect.setUserId(collectAddRequest.getUserId());
BeanUtils.copyProperties(collectAddRequest, collect);
Boolean result = collectService.addCollect(collect, request);
ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR);
@ -77,11 +79,12 @@ public class CollectController {
*/
@PostMapping("/delete/all")
@ApiOperation(value = "删除所有收藏")
public BaseResponse<Boolean> deleteCollectAll(HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long loginUserId = loginUser.getId();
public BaseResponse<Boolean> deleteCollectAll(@RequestBody CommonRequest commonRequest,HttpServletRequest request) {
// User loginUser = userService.getLoginUser(request);
// Long loginUserId = loginUser.getId();
Long userId = commonRequest.getId();
LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Collect::getUserId, loginUserId);
wrapper.eq(Collect::getUserId, userId);
boolean remove = collectService.remove(wrapper);
ThrowUtils.throwIf(!remove, ErrorCode.SYSTEM_ERROR);
return ResultUtils.success(true);
@ -92,11 +95,12 @@ public class CollectController {
*/
@PostMapping("/list")
@ApiOperation(value = "查询所有收藏")
public BaseResponse<List<Collect>> listCollect(HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long loginUserId = loginUser.getId();
public BaseResponse<List<Collect>> listCollect(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
// User loginUser = userService.getLoginUser(request);
// Long loginUserId = loginUser.getId();
Long userId = commonRequest.getId();
LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Collect::getUserId, loginUserId);
wrapper.eq(Collect::getUserId, userId);
List<Collect> list = collectService.list(wrapper);
return ResultUtils.success(list);
}

View File

@ -84,13 +84,13 @@ public class ManicuristController {
public BaseResponse<Long> addManicurist(@RequestBody ManicuristAddRequest manicuristAddRequest, HttpServletRequest request) {
ThrowUtils.throwIf(manicuristAddRequest == null, ErrorCode.PARAMS_ERROR);
//获取登录的用户
User loginUser = userService.getLoginUser(request);
// User loginUser = userService.getLoginUser(request);
Manicurist manicurist = new Manicurist();
//如果不给美甲师名字默认为用户名字
if (manicuristAddRequest.getManicuristName() == null) {
manicuristAddRequest.setManicuristName(loginUser.getUsername());
}
// if (manicuristAddRequest.getManicuristName() == null) {
// manicuristAddRequest.setManicuristName(loginUser.getUsername());
// }
BeanUtils.copyProperties(manicuristAddRequest, manicurist);
ManicuristAuth manicuristAuth = new ManicuristAuth();
BeanUtils.copyProperties(manicuristAddRequest, manicuristAuth);
@ -98,7 +98,7 @@ public class ManicuristController {
manicuristService.validManicuristAuth(manicuristAuth, true);
//插入到表中
manicuristService.addManicurist(loginUser, manicurist, manicuristAuth);
manicuristService.addManicurist(manicuristAddRequest.getUserId(), manicurist, manicuristAuth);
return ResultUtils.success(manicurist.getId(),"添加美甲师成功");
}
@ -160,8 +160,8 @@ public class ManicuristController {
public BaseResponse<Boolean> MyUpdateManicurist(@RequestBody MyManicuristUpdateRequest myUpdateRequest, HttpServletRequest request){
ThrowUtils.throwIf(myUpdateRequest == null, ErrorCode.NULL_ERROR);
User logingUser = userService.getLoginUser(request);
Long userId = logingUser.getId();
// User logingUser = userService.getLoginUser(request);
Long userId = myUpdateRequest.getUserId();
QueryWrapper<Manicurist> manicuristQueryWrapper = new QueryWrapper<Manicurist>().eq("userId", userId);
Manicurist manicuristLog = manicuristService.getOne(manicuristQueryWrapper);
@ -180,12 +180,11 @@ public class ManicuristController {
}
/**
* 根据id查询美甲师(管理员)
* 根据id查询美甲师
*/
@ApiOperation(value = "根据id获取美甲师")
@GetMapping("/queryById")
public BaseResponse<Manicurist> QueryByIdManicurist(@RequestParam Integer manicuristId, HttpServletRequest request){
userService.isAdmin(request);
ThrowUtils.throwIf(manicuristId < 0, ErrorCode.NULL_ERROR, "id不符合规范");
Manicurist manicurist = manicuristService.getById(manicuristId);
@ -195,12 +194,12 @@ public class ManicuristController {
}
/**
* 查询全部美甲师管理员
* 查询全部美甲师
*/
@ApiOperation(value = "查询全部美甲师")
@PostMapping("/queryAll")
public BaseResponse<List<Manicurist>> QueryAllManicurist(HttpServletRequest request){
userService.isAdmin(request);
// userService.isAdmin(request);
List<Manicurist> manicuristList = manicuristService.list();
return ResultUtils.success(manicuristList);

View File

@ -71,9 +71,9 @@ public class OrdersController {
}
// 提取订单
Orders orders = new Orders();
User loginUser = userService.getLoginUser(request);
// User loginUser = userService.getLoginUser(request);
BeanUtils.copyProperties(orderAddRequest, orders);
orders.setUserId(loginUser.getId());
orders.setUserId(orders.getUserId());
ordersService.validOrder(orders);
// 提取订单详情
List<OrderItemsAddRequest> detailAddRequest = orderAddRequest.getOrderItemsAddRequest();
@ -100,8 +100,8 @@ public class OrdersController {
*/
@ApiOperation(value = "订单取消接口")
@PostMapping("/cancel")
public BaseResponse<Boolean> cancelOrder(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
Long orderId = commonRequest.getId();
public BaseResponse<Boolean> cancelOrder(@RequestBody OrderCancelRequest orderCancelRequest, HttpServletRequest request) {
Long orderId = orderCancelRequest.getId();
if (orderId == null || orderId <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
@ -110,8 +110,8 @@ public class OrdersController {
ThrowUtils.throwIf(orders == null, ErrorCode.NOT_FOUND_ERROR);
ThrowUtils.throwIf(orders.getPaymentStatus() != 0, ErrorCode.OPERATION_ERROR, "订单状态错误");
// 判断是否为自己的订单
User loginUser = userService.getLoginUser(request);
if (!orders.getUserId().equals(loginUser.getId())) {
// User loginUser = userService.getLoginUser(request);
if (!orders.getUserId().equals(orderCancelRequest.getUserId())) {
throw new BusinessException(ErrorCode.NO_AUTH);
}
// 修改订单状态
@ -160,17 +160,18 @@ public class OrdersController {
}
long current = myOrderQueryRequest.getCurrent();
long size = myOrderQueryRequest.getPageSize();
User loginUser = userService.getLoginUser(request);
// User loginUser = userService.getLoginUser(request);
Integer userRole = myOrderQueryRequest.getUserRole();
OrderQueryRequest orderQueryRequest = new OrderQueryRequest();
BeanUtils.copyProperties(myOrderQueryRequest, orderQueryRequest);
QueryWrapper<Orders> queryWrapper = ordersService.getQueryWrapper(orderQueryRequest);
if (loginUser.getUserRole().equals(UserConstant.BUSINESS_ROLE)) {
if (userRole.equals(UserConstant.BUSINESS_ROLE)) {
// 商家获取订单
Business loginBusiness = businessService.getLoginBusiness(request);
queryWrapper.eq("businessId", loginBusiness.getId());
} else {
// 用户获取订单
queryWrapper.eq("userId", loginUser.getId());
queryWrapper.eq("userId", myOrderQueryRequest.getUserId());
}
Page<Orders> ordersPage = ordersService.page(new Page<>(current, size),
queryWrapper);

View File

@ -15,6 +15,7 @@ import com.cj.jiaqingjiayi.model.domain.User;
import com.cj.jiaqingjiayi.model.domain.UserRating;
import com.cj.jiaqingjiayi.model.request.userRating.UserRatingAddRequest;
import com.cj.jiaqingjiayi.model.request.userRating.UserRatingReviewRequest;
import com.cj.jiaqingjiayi.model.vo.UserRatingDTO;
import com.cj.jiaqingjiayi.service.BusinessService;
import com.cj.jiaqingjiayi.service.UserRatingService;
import com.cj.jiaqingjiayi.service.UserService;
@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "用户评分接口")
@ -85,9 +87,9 @@ public class UserRatingController {
*/
@ApiOperation(value = "展示用户评分")
@PostMapping("/list")
public BaseResponse<List<UserRating>> listUserRating (HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
public BaseResponse<List<UserRating>> listUserRating (@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
// User loginUser = userService.getLoginUser(request);
Long userId = commonRequest.getId();
List<UserRating> list = userRatingService.list(Wrappers.<UserRating>lambdaQuery().eq(UserRating::getUserId, userId));
return ResultUtils.success(list);
}
@ -97,10 +99,26 @@ public class UserRatingController {
*/
@ApiOperation(value = "展示商家评论")
@GetMapping("/listBusinessRating")
public BaseResponse<List<UserRating>> listUserRatingBusiness (@RequestParam Long businessId) {
public BaseResponse<List<UserRatingDTO>> listUserRatingBusiness (@RequestParam Long businessId) {
// 查询 UserRating 列表
List<UserRating> userRatings = userRatingService.list(
Wrappers.<UserRating>lambdaQuery().eq(UserRating::getBusinessId, businessId)
);
List<UserRating> list = userRatingService.list(Wrappers.<UserRating>lambdaQuery().eq(UserRating::getBusinessId, businessId));
return ResultUtils.success(list);
// 创建返回的 DTO 列表
List<UserRatingDTO> userRatingDTOList = new ArrayList<>();
// 遍历 UserRating 列表根据 userId 查询 User 信息
for (UserRating userRating : userRatings) {
User user = userService.getById(userRating.getUserId());
UserRatingDTO userRatingDTO = new UserRatingDTO();
userRatingDTO.setUserRating(userRating);
userRatingDTO.setUser(user);
userRatingDTOList.add(userRatingDTO);
}
// 返回 DTO 列表
return ResultUtils.success(userRatingDTOList);
}

View File

@ -29,7 +29,7 @@ public class Appointments implements Serializable {
/**
* 用户姓名
*/
private String username;
private String userName;
/**
* 手机号

View File

@ -25,7 +25,7 @@ public class AppointmentsAddRequest implements Serializable {
/**
* 用户姓名
*/
private String username;
private String userName;
/**
* 手机号
@ -55,7 +55,7 @@ public class AppointmentsAddRequest implements Serializable {
/**
* 预约时间
*/
private Date appointmentTime;
private String appointmentTime;
/**
* 服务方式0 - 线上, 1 - 到店

View File

@ -19,6 +19,11 @@ public class CartAddRequest implements Serializable {
*/
private Long businessId;
/**
* 用户id
*/
private Long userId;
/**
* 关联的商品id
*/

View File

@ -1,5 +1,6 @@
package com.cj.jiaqingjiayi.model.request.cart;
import com.alipay.api.domain.PracticeEntity;
import lombok.Data;
import java.io.Serial;
@ -19,5 +20,10 @@ public class CartDeleteRequest implements Serializable {
*/
private Long id;
/**
* 用户id
*/
private Long userId;
}

View File

@ -19,5 +19,9 @@ public class CartQueryRequest implements Serializable {
*/
private Long id;
/**
* 用户Id
*/
private Long userId;
}

View File

@ -11,4 +11,9 @@ public class CollectAddRequest implements Serializable {
* 商家id
*/
private Long businessId;
/**
* 用户id
*/
private Long userId;
}

View File

@ -12,6 +12,11 @@ public class ManicuristAddRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1396365359119727782L;
/**
* 当前用户id
*/
private Long userId;
/**
* 美甲师姓名
*/

View File

@ -19,6 +19,11 @@ public class MyManicuristUpdateRequest implements Serializable {
*/
private String manicuristName;
/**
* 用户Id
*/
private Long userId;
/**
* 性别
*/

View File

@ -18,7 +18,17 @@ public class MyOrderQueryRequest extends PageRequest implements Serializable {
/**
* id
*/
private Long id;
// private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 用户角色 0 - 普通用户 1 - 管理员 2 - 商家
*/
private Integer userRole;
/**
* 抢单状态0 - 未抢单, 1 - 已抢单

View File

@ -28,6 +28,11 @@ public class OrderAddRequest implements Serializable {
*/
private Long businessId;
/**
* 用户id
*/
private Long userId;
/**
* 订单实际总价
*/

View File

@ -81,6 +81,11 @@ public class BusinessVO implements Serializable {
*/
private Integer storeStatus;
/**
* 状态:0审核中,1启用,2禁用
*/
private Integer state;
/**
* 创建时间
*/

View File

@ -1,6 +1,8 @@
package com.cj.jiaqingjiayi.model.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serial;
@ -10,6 +12,13 @@ import java.util.Date;
@Data
public class ManicuristVO implements Serializable {
/**
* 美甲师唯一标识主键自增
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 美甲师姓名
*/

View File

@ -3,6 +3,7 @@ package com.cj.jiaqingjiayi.service;
import com.cj.jiaqingjiayi.model.domain.Cart;
import com.baomidou.mybatisplus.extension.service.IService;
import com.cj.jiaqingjiayi.model.request.cart.CartAddRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartDeleteRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartUpdateRequest;
import javax.servlet.http.HttpServletRequest;
@ -30,6 +31,6 @@ public interface CartService extends IService<Cart> {
/**
* 删除购物车商品
*/
Boolean deleteCart(Long cartId, HttpServletRequest request);
Boolean deleteCart(CartDeleteRequest cartDeleteRequest, HttpServletRequest request);
}

View File

@ -24,7 +24,7 @@ public interface ManicuristService extends IService<Manicurist> {
/**
* 添加美甲师和认证信息
*/
void addManicurist(User loginUser, Manicurist manicurist, ManicuristAuth manicuristAuth);
void addManicurist(Long userId, Manicurist manicurist, ManicuristAuth manicuristAuth);
/**
*校验

View File

@ -47,7 +47,7 @@ public class AppointmentsServiceImpl extends ServiceImpl<AppointmentsMapper, App
@Override
public void valid(Appointments appointments) {
String userName = appointments.getUsername();
String userName = appointments.getUserName();
String phone = appointments.getPhone();
Date appointmentTime = appointments.getAppointmentTime();
@ -75,6 +75,7 @@ public class AppointmentsServiceImpl extends ServiceImpl<AppointmentsMapper, App
//拿到美甲师的id(是不是麻烦了呢)
QueryWrapper<Manicurist> manicuristQueryWrapper = new QueryWrapper<>();
manicuristQueryWrapper.eq("businessId", appointments.getBusinessId());
manicuristQueryWrapper.eq("manicuristName", manicuristName);
Manicurist manicurist = manicuristService.getOne(manicuristQueryWrapper);
if (manicurist != null){

View File

@ -10,6 +10,7 @@ import com.cj.jiaqingjiayi.model.domain.Cart;
import com.cj.jiaqingjiayi.model.domain.Commodities;
import com.cj.jiaqingjiayi.model.domain.User;
import com.cj.jiaqingjiayi.model.request.cart.CartAddRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartDeleteRequest;
import com.cj.jiaqingjiayi.model.request.cart.CartUpdateRequest;
import com.cj.jiaqingjiayi.service.BusinessService;
import com.cj.jiaqingjiayi.service.CartService;
@ -18,6 +19,7 @@ import com.cj.jiaqingjiayi.service.CommoditiesService;
import com.cj.jiaqingjiayi.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@ -71,9 +73,10 @@ public class CartServiceImpl extends ServiceImpl<CartMapper, Cart>
}
@Override
@Transactional(rollbackFor = Exception.class)
public Cart addCart(CartAddRequest cartAddRequest, HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
// User loginUser = userService.getLoginUser(request);
Long userId = cartAddRequest.getUserId();
Long businessId = cartAddRequest.getBusinessId();
Long commoditiesId = cartAddRequest.getCommoditiesId();
Integer quantity = cartAddRequest.getQuantity();
@ -125,16 +128,17 @@ public class CartServiceImpl extends ServiceImpl<CartMapper, Cart>
}
@Override
public Boolean deleteCart(Long cartId, HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId();
Cart cart = this.getById(cartId);
@Transactional(rollbackFor = Exception.class)
public Boolean deleteCart(CartDeleteRequest cartDeleteRequest, HttpServletRequest request) {
// User loginUser = userService.getLoginUser(request);
Long userId = cartDeleteRequest.getUserId();
Cart cart = this.getById(cartDeleteRequest.getId());
Long cartUserId = cart.getUserId();
if (!userId.equals(cartUserId)) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "该用户无权删除该购物车");
}
boolean remove = this.removeById(cartId);
boolean remove = this.removeById(cartDeleteRequest.getId());
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR);
return true;

View File

@ -44,15 +44,16 @@ public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect>
@Override
public Boolean addCollect(Collect collect, HttpServletRequest request) {
User loginUser = userService.getLoginUser(request);
Long loginUserId = loginUser.getId();
// User loginUser = userService.getLoginUser(request);
// Long loginUserId = loginUser.getId();
Long userId = collect.getUserId();
Long businessId = collect.getBusinessId();
LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Collect::getBusinessId, businessId);
wrapper.eq(Collect::getUserId, loginUserId);
wrapper.eq(Collect::getUserId, userId);
long count = this.count(wrapper);
ThrowUtils.throwIf(count > 0, ErrorCode.OPERATION_ERROR, "该商家已收藏");
collect.setUserId(loginUserId);
// collect.setUserId(userId);
return this.save(collect);
}
}

View File

@ -90,9 +90,9 @@ public class ManicuristServiceImpl extends ServiceImpl<ManicuristMapper, Manicur
//用户注册美甲师
@Override
@Transactional(rollbackFor = Exception.class)
public void addManicurist(User loginUser, Manicurist manicurist, ManicuristAuth manicuristAuth) {
public void addManicurist(Long userId, Manicurist manicurist, ManicuristAuth manicuristAuth) {
//美甲师绑定user
Long userId = loginUser.getId();
// Long userId = loginUser.getId();
manicurist.setUserId(userId);
// //更改用户权限为美甲师

View File

@ -47,8 +47,8 @@ public class UserRatingServiceImpl extends ServiceImpl<UserRatingMapper, UserRat
Orders ordersById = ordersService.getById(userRating.getOrderId());
User loginUser = userService.getLoginUser(request);
if (!loginUser.getId().equals(ordersById.getUserId())) {
// User loginUser = userService.getLoginUser(request);
if (!userRating.getUserId().equals(ordersById.getUserId())) {
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "当前登录用户与评分中的用户不匹配");
}
Orders orders = ordersService.getOne(Wrappers.<Orders>lambdaQuery().eq(Orders::getId, userRating.getOrderId()));

View File

@ -1,13 +0,0 @@
package com.cj.jiaqingjiayi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class JiaqingjiayiApplicationTests {
@Test
void contextLoads() {
}
}