Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
b447f2b4
Commit
b447f2b4
authored
Jan 18, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改优惠卷添加日志
parent
5520acfc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
48 deletions
+44
-48
QPServiceImplAspect.java
...ain/java/share/framework/aspectj/QPServiceImplAspect.java
+43
-47
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+1
-1
No files found.
share-framework/src/main/java/share/framework/aspectj/QPServiceImplAspect.java
View file @
b447f2b4
...
@@ -71,50 +71,47 @@ public class QPServiceImplAspect {
...
@@ -71,50 +71,47 @@ public class QPServiceImplAspect {
* @param result 返回结果
* @param result 返回结果
*/
*/
@AfterReturning
(
value
=
"operLogPoinCut()"
,
returning
=
"result"
)
@AfterReturning
(
value
=
"operLogPoinCut()"
,
returning
=
"result"
)
public
void
save
Oper
Log
(
JoinPoint
joinPoint
,
Object
result
)
{
public
void
save
CouponOperation
Log
(
JoinPoint
joinPoint
,
Object
result
)
{
// 获取RequestAttributes
try
{
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
// 从获取RequestAttributes中获取HttpServletRequest的信息
if
(
requestAttributes
==
null
)
{
logger
.
warn
(
"无法获取RequestAttributes"
);
return
;
}
HttpServletRequest
request
=
(
HttpServletRequest
)
requestAttributes
.
resolveReference
(
RequestAttributes
.
REFERENCE_REQUEST
);
HttpServletRequest
request
=
(
HttpServletRequest
)
requestAttributes
.
resolveReference
(
RequestAttributes
.
REFERENCE_REQUEST
);
if
(
request
==
null
)
{
logger
.
warn
(
"无法获取HttpServletRequest"
);
return
;
}
CouponLog
couponLog
=
new
CouponLog
();
CouponLog
couponLog
=
new
CouponLog
();
try
{
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
// 获取切入点所在的方法
Method
method
=
signature
.
getMethod
();
Method
method
=
signature
.
getMethod
();
//获得方法名
String
methodName
=
method
.
getName
();
String
methodName
=
method
.
getName
();
// 将入参转换成json // 请求参数
String
[]
paramNames
=
signature
.
getParameterNames
();
//获得请求参数名称
String
[]
paramNames
=
((
MethodSignature
)
joinPoint
.
getSignature
()).
getParameterNames
();
String
params
=
argsArrayToString
(
paramNames
,
joinPoint
.
getArgs
());
String
params
=
argsArrayToString
(
paramNames
,
joinPoint
.
getArgs
());
//转JSON
JSONObject
jsonObject
=
JSON
.
parseObject
(
params
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
params
);
//获得出参
String
outParams
=
JSON
.
toJSONString
(
result
);
String
outParams
=
JSON
.
toJSONString
(
result
);
saveLog
(
couponLog
,
jsonObject
,
UserStatusEnum
.
UNUSED
.
getCode
());
saveLog
(
couponLog
,
jsonObject
,
UserStatusEnum
.
UNUSED
.
getCode
());
couponLog
.
setStatus
(
YesNoEnum
.
yes
.
getDisplay_3
());
couponLog
.
setStatus
(
YesNoEnum
.
yes
.
getDisplay_3
());
couponLog
.
setMessage
(
outParams
);
couponLog
.
setMessage
(
outParams
);
couponLog
.
setCreateTime
(
new
Date
());
couponLog
.
setCreateTime
(
new
Date
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
logger
.
info
(
"优惠卷操作日志:{}"
,
couponLog
);
logger
.
info
(
"优惠卷操作日志:{}"
,
couponLog
);
logger
.
info
(
"开始异步执行新增正常日志"
);
logger
.
info
(
"开始异步执行新增正常日志"
);
// 异步执行
boolean
isSaved
=
couponLogService
.
save
(
couponLog
);
CompletableFuture
.
supplyAsync
(()
->
{
if
(
isSaved
)
{
boolean
i
=
couponLogService
.
save
(
couponLog
);
if
(
i
)
{
logger
.
info
(
"新增日志成功"
);
logger
.
info
(
"新增日志成功"
);
return
true
;
}
else
{
}
else
{
logger
.
info
(
"新增日志失败"
);
logger
.
warn
(
"新增日志失败"
);
return
false
;
}
}
});
}
catch
(
Exception
e
)
{
logger
.
error
(
"在保存优惠券操作日志时出错"
,
e
);
}
}
}
}
/**
* 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行
*/
/**
/**
* 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行
* 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行
*/
*/
...
@@ -128,52 +125,64 @@ public class QPServiceImplAspect {
...
@@ -128,52 +125,64 @@ public class QPServiceImplAspect {
Method
method
=
signature
.
getMethod
();
Method
method
=
signature
.
getMethod
();
//获得方法名
//获得方法名
String
methodName
=
method
.
getName
();
String
methodName
=
method
.
getName
();
// 将入参转换成json // 请求参数
// 将入参转换成json // 请求参数
String
[]
paramNames
=
((
MethodSignature
)
joinPoint
.
getSignature
()).
getParameterNames
();
String
[]
paramNames
=
((
MethodSignature
)
joinPoint
.
getSignature
()).
getParameterNames
();
String
params
=
argsArrayToString
(
paramNames
,
joinPoint
.
getArgs
());
String
params
=
argsArrayToString
(
paramNames
,
joinPoint
.
getArgs
());
//转JSON
//转JSON
JSONObject
jsonObject
=
JSON
.
parseObject
(
params
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
params
);
saveLog
(
couponLog
,
jsonObject
,
UserStatusEnum
.
UNUSED
.
getCode
());
// 设置基本属性
couponLog
.
setStatus
(
YesNoEnum
.
no
.
getDisplay_3
());
couponLog
.
setStatus
(
YesNoEnum
.
no
.
getDisplay_3
());
couponLog
.
setNumber
(
TRY_NUMBER
);
couponLog
.
setNumber
(
TRY_NUMBER
);
couponLog
.
setCreateTime
(
new
Date
());
couponLog
.
setCreateTime
(
new
Date
());
couponLog
.
setMessage
(
e
.
getMessage
());
couponLog
.
setMessage
(
e
.
getMessage
());
// 记录日志
saveLog
(
couponLog
,
jsonObject
,
UserStatusEnum
.
UNUSED
.
getCode
());
}
catch
(
Exception
e2
)
{
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
(
);
logger
.
error
(
"Error while processing exception log"
,
e2
);
}
finally
{
}
finally
{
logger
.
info
(
"优惠卷操作日志:{}"
,
couponLog
);
logger
.
info
(
"优惠卷操作日志:{}"
,
couponLog
);
logger
.
info
(
"开始异步执行新增错误日志"
);
logger
.
info
(
"开始异步执行新增错误日志"
);
CompletableFuture
.
supplyAsync
(()
->
{
boolean
i
=
couponLogService
.
save
(
couponLog
);
boolean
i
=
couponLogService
.
save
(
couponLog
);
if
(
i
)
{
if
(
i
)
{
logger
.
info
(
"新增日志成功"
);
logger
.
info
(
"新增日志成功"
);
return
true
;
}
else
{
}
else
{
logger
.
info
(
"新增日志失败"
);
logger
.
info
(
"新增日志失败"
);
return
false
;
}
}
});
}
}
}
}
private
void
saveLog
(
CouponLog
couponLog
,
JSONObject
jsonObject
,
Integer
code
)
{
private
void
saveLog
(
CouponLog
couponLog
,
JSONObject
jsonObject
,
Integer
code
)
{
couponLog
.
setCode
(
jsonObject
.
getString
(
"code"
));
String
couponCode
=
jsonObject
.
getString
(
"code"
);
couponLog
.
setCode
(
couponCode
);
// 查询SConsumerCoupon
LambdaQueryWrapper
<
SConsumerCoupon
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
SConsumerCoupon
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
lambdaQueryWrapper
.
eq
(
SConsumerCoupon:
:
getCouponCode
,
coupon
Log
.
getCode
()
);
lambdaQueryWrapper
.
eq
(
SConsumerCoupon:
:
getCouponCode
,
coupon
Code
);
lambdaQueryWrapper
.
eq
(
SConsumerCoupon:
:
getUseStatus
,
code
);
lambdaQueryWrapper
.
eq
(
SConsumerCoupon:
:
getUseStatus
,
code
);
SConsumerCoupon
one
=
sConsumerCouponService
.
getOne
(
lambdaQueryWrapper
);
SConsumerCoupon
one
=
sConsumerCouponService
.
getOne
(
lambdaQueryWrapper
);
if
(
one
==
null
)
{
// 处理查询不到SConsumerCoupon的情况,例如抛出异常或记录日志
logger
.
error
(
"Failed to find SConsumerCoupon for code: "
+
couponCode
);
}
couponLog
.
setConsumerId
(
one
.
getConsumerId
());
couponLog
.
setConsumerId
(
one
.
getConsumerId
());
couponLog
.
setCouponId
(
one
.
getId
());
couponLog
.
setCouponId
(
one
.
getId
());
couponLog
.
setCouponName
(
one
.
getName
());
couponLog
.
setCouponValue
(
one
.
getSubPrice
());
// 查询SStore
LambdaQueryWrapper
<
SStore
>
sStoreLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
SStore
>
sStoreLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sStoreLambdaQueryWrapper
.
eq
(
SStore:
:
getOpenShopUuid
,
jsonObject
.
getString
(
"openShopUuid"
));
sStoreLambdaQueryWrapper
.
eq
(
SStore:
:
getOpenShopUuid
,
jsonObject
.
getString
(
"openShopUuid"
));
SStore
sStore
=
sStoreService
.
getOne
(
sStoreLambdaQueryWrapper
);
SStore
sStore
=
sStoreService
.
getOne
(
sStoreLambdaQueryWrapper
);
if
(
sStore
==
null
)
{
logger
.
error
(
"Failed to find SStore for openShopUuid: "
+
jsonObject
.
getString
(
"openShopUuid"
));
// 处理查询不到SStore的情况,例如抛出异常或记录日志
}
couponLog
.
setStoreId
(
sStore
.
getId
());
couponLog
.
setStoreId
(
sStore
.
getId
());
couponLog
.
setCouponName
(
one
.
getName
());
couponLog
.
setCouponValue
(
one
.
getSubPrice
());
// 设置其他属性
couponLog
.
setCouponType
(
jsonObject
.
getString
(
"status"
));
couponLog
.
setCouponType
(
jsonObject
.
getString
(
"status"
));
}
}
/**
/**
* 参数拼装
* 参数拼装
*/
*/
...
@@ -197,19 +206,6 @@ public class QPServiceImplAspect {
...
@@ -197,19 +206,6 @@ public class QPServiceImplAspect {
return
JSONUtil
.
toJsonStr
(
map
);
return
JSONUtil
.
toJsonStr
(
map
);
}
}
/**
* 转换异常信息为字符串
*/
public
String
stackTraceToString
(
String
exceptionName
,
String
exceptionMessage
,
StackTraceElement
[]
elements
)
{
StringBuffer
strbuff
=
new
StringBuffer
();
for
(
StackTraceElement
stet
:
elements
)
{
strbuff
.
append
(
stet
+
"\n"
);
}
String
message
=
exceptionName
+
":"
+
exceptionMessage
+
"\n\t"
+
strbuff
.
toString
();
message
=
substring
(
message
,
0
,
2000
);
return
message
;
}
//字符串截取
//字符串截取
public
static
String
substring
(
String
str
,
int
start
,
int
end
)
{
public
static
String
substring
(
String
str
,
int
start
,
int
end
)
{
if
(
str
==
null
)
{
if
(
str
==
null
)
{
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
b447f2b4
...
@@ -300,7 +300,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -300,7 +300,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
@Override
@Override
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
OrderPayResultResponse
createOrder
(
CreateOrderRequest
request
)
{
public
OrderPayResultResponse
createOrder
(
CreateOrderRequest
request
)
{
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
if
(
ObjectUtil
.
isNull
(
user
))
{
if
(
ObjectUtil
.
isNull
(
user
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment