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
40ba1ab7
Commit
40ba1ab7
authored
Jan 11, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加重新验卷的自动任务
parent
6a4878f3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
11 deletions
+56
-11
ConsumerCouponStatusEnum.java
...ain/java/share/common/enums/ConsumerCouponStatusEnum.java
+2
-0
QPServiceImplAspect.java
...ain/java/share/framework/aspectj/QPServiceImplAspect.java
+3
-1
CouponRetryTask.java
...artz/src/main/java/share/quartz/task/CouponRetryTask.java
+38
-8
QPServiceImpl.java
...rc/main/java/share/system/service/impl/QPServiceImpl.java
+12
-1
SConsumerCouponMapper.xml
...rc/main/resources/mapper/system/SConsumerCouponMapper.xml
+1
-1
No files found.
share-common/src/main/java/share/common/enums/ConsumerCouponStatusEnum.java
View file @
40ba1ab7
...
@@ -5,6 +5,8 @@ public enum ConsumerCouponStatusEnum {
...
@@ -5,6 +5,8 @@ public enum ConsumerCouponStatusEnum {
WECHAT
(
"2"
,
"微信回调"
),
WECHAT
(
"2"
,
"微信回调"
),
SERVICE
(
"3"
,
"SERVICE回调"
),
SERVICE
(
"3"
,
"SERVICE回调"
),
ORDER
(
"4"
,
"订单下单"
),
ORDER
(
"4"
,
"订单下单"
),
//任务
TASK
(
"5"
,
"任务"
),
;
;
ConsumerCouponStatusEnum
()
{
ConsumerCouponStatusEnum
()
{
...
...
share-framework/src/main/java/share/framework/aspectj/QPServiceImplAspect.java
View file @
40ba1ab7
...
@@ -39,6 +39,8 @@ public class QPServiceImplAspect {
...
@@ -39,6 +39,8 @@ public class QPServiceImplAspect {
@Autowired
@Autowired
private
ISStoreService
sStoreService
;
private
ISStoreService
sStoreService
;
private
static
final
Integer
TRY_NUMBER
=
3
;
/**
/**
* 切点函数,用于标识需要记录操作日志的方法。
* 切点函数,用于标识需要记录操作日志的方法。
...
@@ -127,7 +129,7 @@ public class QPServiceImplAspect {
...
@@ -127,7 +129,7 @@ public class QPServiceImplAspect {
JSONObject
jsonObject
=
JSON
.
parseObject
(
params
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
params
);
saveLog
(
couponLog
,
jsonObject
);
saveLog
(
couponLog
,
jsonObject
);
couponLog
.
setStatus
(
YesNoEnum
.
no
.
getDisplay_3
());
couponLog
.
setStatus
(
YesNoEnum
.
no
.
getDisplay_3
());
couponLog
.
setNumber
(
3
);
couponLog
.
setNumber
(
TRY_NUMBER
);
couponLog
.
setCreateTime
(
new
Date
());
couponLog
.
setCreateTime
(
new
Date
());
couponLog
.
setMessage
(
stackTraceToString
(
e
.
getClass
().
getName
(),
e
.
getMessage
(),
e
.
getStackTrace
()));
couponLog
.
setMessage
(
stackTraceToString
(
e
.
getClass
().
getName
(),
e
.
getMessage
(),
e
.
getStackTrace
()));
}
catch
(
Exception
e2
)
{
}
catch
(
Exception
e2
)
{
...
...
share-quartz/src/main/java/share/quartz/task/CouponRetryTask.java
View file @
40ba1ab7
package
share
.
quartz
.
task
;
package
share
.
quartz
.
task
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
share.common.enums.ConsumerCouponStatusEnum
;
import
share.common.enums.ConsumerCouponStatusEnum
;
import
share.common.enums.UserStatusEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.enums.YesNoEnum
;
import
share.system.domain.CouponLog
;
import
share.system.domain.CouponLog
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SStore
;
import
share.system.domain.SStore
;
import
share.system.service.CouponLogService
;
import
share.system.service.CouponLogService
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISStoreService
;
import
share.system.service.ISStoreService
;
import
share.system.service.QPService
;
import
share.system.service.QPService
;
import
share.system.service.impl.QPServiceImpl
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
(
"couponRetryTask"
)
@Component
(
"couponRetryTask"
)
...
@@ -22,27 +30,49 @@ public class CouponRetryTask {
...
@@ -22,27 +30,49 @@ public class CouponRetryTask {
private
QPService
qpService
;
private
QPService
qpService
;
@Autowired
@Autowired
private
ISStoreService
sStoreService
;
private
ISStoreService
sStoreService
;
@Autowired
private
ISConsumerCouponService
sConsumerCouponService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QPServiceImpl
.
class
);
private
static
final
Integer
TRY_NUMBER
=
3
;
public
void
AuToRetryCoupon
()
{
public
void
AuToRetryCoupon
()
{
//查询异常的优惠券日志
LambdaQueryWrapper
<
CouponLog
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
CouponLog
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
CouponLog:
:
getStatus
,
YesNoEnum
.
no
.
getDisplay_3
());
queryWrapper
.
eq
(
CouponLog:
:
getStatus
,
YesNoEnum
.
no
.
getDisplay_3
());
//去重
queryWrapper
.
eq
(
CouponLog:
:
getNumber
,
TRY_NUMBER
);
queryWrapper
.
groupBy
(
CouponLog:
:
getCode
);
List
<
CouponLog
>
list
=
couponLogService
.
list
(
queryWrapper
);
List
<
CouponLog
>
list
=
couponLogService
.
list
(
queryWrapper
);
//根据code分组
Map
<
String
,
List
<
CouponLog
>>
collect
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
CouponLog:
:
getCode
));
//门店id集合
//门店id集合
List
<
Long
>
storeIds
=
list
.
stream
().
map
(
CouponLog:
:
getStoreId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
Long
>
storeIds
=
list
.
stream
().
map
(
CouponLog:
:
getStoreId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
SStore
>
sStoreList
=
sStoreService
.
listByIds
(
storeIds
);
List
<
SStore
>
sStoreList
=
sStoreService
.
listByIds
(
storeIds
);
list
.
stream
().
forEach
(
couponLog
->
{
//遍历Map
collect
.
forEach
((
k
,
v
)
->
{
CouponLog
couponLog
=
v
.
get
(
0
);
SStore
sStore
=
sStoreList
.
stream
().
filter
(
s
->
s
.
getId
().
equals
(
couponLog
.
getStoreId
())).
findFirst
().
get
();
SStore
sStore
=
sStoreList
.
stream
().
filter
(
s
->
s
.
getId
().
equals
(
couponLog
.
getStoreId
())).
findFirst
().
get
();
if
(
couponLog
.
getNumber
()
>
0
)
{
if
(
couponLog
.
getNumber
().
equals
(
TRY_NUMBER
))
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
TRY_NUMBER
;
i
++)
{
qpService
.
consume
(
couponLog
.
getCode
(),
1
,
sStore
.
getOpenShopUuid
(),
ConsumerCouponStatusEnum
.
WECHAT
.
getCode
());
try
{
qpService
.
consume
(
couponLog
.
getCode
(),
1
,
sStore
.
getOpenShopUuid
(),
ConsumerCouponStatusEnum
.
TASK
.
getCode
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"验卷失败:{}"
,
e
.
getMessage
());
}
finally
{
couponLog
.
setNumber
(
couponLog
.
getNumber
()
-
1
);
couponLog
.
setNumber
(
couponLog
.
getNumber
()
-
1
);
couponLogService
.
updateById
(
couponLog
);
couponLogService
.
updateById
(
couponLog
);
}
}
}
}
//根据code批量更新状态
LambdaUpdateWrapper
<
CouponLog
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
updateWrapper
.
eq
(
CouponLog:
:
getCode
,
k
);
//设置number为0
updateWrapper
.
set
(
CouponLog:
:
getNumber
,
0
);
couponLogService
.
update
(
updateWrapper
);
//更新优惠卷领取状态
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
sConsumerCoupon
.
setId
(
couponLog
.
getCouponId
());
sConsumerCoupon
.
setUseStatus
(
UserStatusEnum
.
EXPIRED
.
getCode
());
sConsumerCouponService
.
updateById
(
sConsumerCoupon
);
}
});
});
}
}
}
}
share-system/src/main/java/share/system/service/impl/QPServiceImpl.java
View file @
40ba1ab7
...
@@ -81,6 +81,10 @@ public class QPServiceImpl implements QPService {
...
@@ -81,6 +81,10 @@ public class QPServiceImpl implements QPService {
//默认门槛金额
//默认门槛金额
private
static
final
BigDecimal
DEFAULT_MIN_PRICE
=
BigDecimal
.
valueOf
(
0.00
);
private
static
final
BigDecimal
DEFAULT_MIN_PRICE
=
BigDecimal
.
valueOf
(
0.00
);
private
static
final
String
ACCOUNT
=
"13888888888"
;
private
static
final
String
NAME
=
"管理人员"
;
/**
/**
* 用户验卷接口
* 用户验卷接口
*/
*/
...
@@ -253,12 +257,19 @@ public class QPServiceImpl implements QPService {
...
@@ -253,12 +257,19 @@ public class QPServiceImpl implements QPService {
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
String
requestid
=
UUID
.
randomUUID
().
toString
();
String
requestid
=
UUID
.
randomUUID
().
toString
();
TuangouReceiptConsumeRequest
request
=
new
TuangouReceiptConsumeRequest
(
APP_KEY
,
APP_SECRET
,
session
,
TuangouReceiptConsumeRequest
request
=
null
;
if
(
ObjectUtils
.
isEmpty
(
user
))
{
request
=
new
TuangouReceiptConsumeRequest
(
APP_KEY
,
APP_SECRET
,
session
,
requestid
,
code
,
count
,
""
,
ACCOUNT
,
NAME
,
openShopUuid
);
}
else
{
request
=
new
TuangouReceiptConsumeRequest
(
APP_KEY
,
APP_SECRET
,
session
,
requestid
,
code
,
count
,
""
,
user
.
getAccount
(),
user
.
getNickName
(),
openShopUuid
);
requestid
,
code
,
count
,
""
,
user
.
getAccount
(),
user
.
getNickName
(),
openShopUuid
);
}
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
TuangouReceiptConsume
tuangouReceiptConsume
=
new
TuangouReceiptConsume
(
request
);
TuangouReceiptConsume
tuangouReceiptConsume
=
new
TuangouReceiptConsume
(
request
);
TuangouReceiptConsumeResponse
invoke
=
openAPIClient
.
invoke
(
tuangouReceiptConsume
);
TuangouReceiptConsumeResponse
invoke
=
openAPIClient
.
invoke
(
tuangouReceiptConsume
);
if
(
invoke
.
getCode
()
!=
200
)
{
if
(
invoke
.
getCode
()
!=
200
)
{
redisUtil
.
delete
(
ReceiptRdeisEnum
.
PREPARE
.
getValue
()
+
code
);
logger
.
error
(
"验卷失败:{}"
,
invoke
.
getMsg
());
logger
.
error
(
"验卷失败:{}"
,
invoke
.
getMsg
());
throw
new
RuntimeException
(
invoke
.
getMsg
());
throw
new
RuntimeException
(
invoke
.
getMsg
());
}
}
...
...
share-system/src/main/resources/mapper/system/SConsumerCouponMapper.xml
View file @
40ba1ab7
...
@@ -101,7 +101,7 @@
...
@@ -101,7 +101,7 @@
<if
test=
"startDate != null "
>
and start_date = #{startDate}
</if>
<if
test=
"startDate != null "
>
and start_date = #{startDate}
</if>
<if
test=
"endDate != null "
>
and end_date = #{endDate}
</if>
<if
test=
"endDate != null "
>
and end_date = #{endDate}
</if>
<if
test=
"useDate != null "
>
and use_date = #{useDate}
</if>
<if
test=
"useDate != null "
>
and use_date = #{useDate}
</if>
<if
test=
"useStatus != null and useStatus != ''
"
>
and use_status = #{useStatus}
</if>
<if
test=
"useStatus != null and useStatus != ''
or useStatus==0"
>
and use_status = #{useStatus}
</if>
<if
test=
"isDelete != null "
>
and is_delete = #{isDelete}
</if>
<if
test=
"isDelete != null "
>
and is_delete = #{isDelete}
</if>
<if
test=
"deleteBy != null and deleteBy != ''"
>
and delete_by = #{deleteBy}
</if>
<if
test=
"deleteBy != null and deleteBy != ''"
>
and delete_by = #{deleteBy}
</if>
<if
test=
"deleteTime != null "
>
and delete_time = #{deleteTime}
</if>
<if
test=
"deleteTime != null "
>
and delete_time = #{deleteTime}
</if>
...
...
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