记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
e7b0b866
Commit
e7b0b866
authored
Sep 22, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通用券逻辑
parent
b1aa25ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
28 deletions
+100
-28
CandyCouponServiceImpl.java
...et/service/candy/service/impl/CandyCouponServiceImpl.java
+94
-23
RedisDataUtils.java
...java/com/liquidnet/service/candy/util/RedisDataUtils.java
+6
-5
No files found.
liquidnet-bus-service/liquidnet-service-candy/liquidnet-service-candy-impl/src/main/java/com/liquidnet/service/candy/service/impl/CandyCouponServiceImpl.java
View file @
e7b0b866
...
@@ -47,7 +47,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -47,7 +47,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
CandyMyCouponListVo
myCoupon
(
Integer
type
)
{
public
CandyMyCouponListVo
myCoupon
(
Integer
type
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
CandyMyCouponListVo
vo
=
CandyMyCouponListVo
.
getNew
();
CandyMyCouponListVo
vo
=
CandyMyCouponListVo
.
getNew
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
myCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
myCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
...
@@ -80,8 +86,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -80,8 +86,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
List
<
CandyCouponPreVo
>
memberCouponPre
(
String
uid
)
{
public
List
<
CandyCouponPreVo
>
memberCouponPre
(
String
uid
)
{
ArrayList
<
CandyCouponPreVo
>
voArrayList
=
ObjectUtil
.
getCandyCouponPreVoArrayList
();
ArrayList
<
CandyCouponPreVo
>
voArrayList
=
ObjectUtil
.
getCandyCouponPreVoArrayList
();
LocalDateTime
userCreateTime
;
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
if
(!
CollectionUtil
.
isEmpty
(
dtoList
))
{
if
(!
CollectionUtil
.
isEmpty
(
dtoList
))
{
Map
<
String
,
Long
>
mCouponCountMap
=
dtoList
.
parallelStream
()
Map
<
String
,
Long
>
mCouponCountMap
=
dtoList
.
parallelStream
()
.
filter
(
r
->
(
r
.
getExclusive
()
==
1
&&
r
.
getState
()
==
1
))
.
filter
(
r
->
(
r
.
getExclusive
()
==
1
&&
r
.
getState
()
==
1
))
...
@@ -95,7 +106,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -95,7 +106,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
List
<
CandyCouponVo
>
memberCoupon
(
String
mCouponId
)
{
public
List
<
CandyCouponVo
>
memberCoupon
(
String
mCouponId
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
...
@@ -115,7 +132,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -115,7 +132,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
CandyMyCouponListVo
preUsePerformanceCoupon
(
BigDecimal
priceTotal
,
String
performanceId
,
String
timeId
,
String
ticketId
,
Integer
type
)
{
public
CandyMyCouponListVo
preUsePerformanceCoupon
(
BigDecimal
priceTotal
,
String
performanceId
,
String
timeId
,
String
ticketId
,
Integer
type
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
CandyMyCouponListVo
vo
=
CandyMyCouponListVo
.
getNew
();
CandyMyCouponListVo
vo
=
CandyMyCouponListVo
.
getNew
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
myCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
myCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
...
@@ -131,7 +154,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -131,7 +154,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
continue
;
continue
;
}
}
}
}
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
continue
;
continue
;
}
}
if
(
dtoItem
.
getExclusive
().
equals
(
1
))
{
//会员券
if
(
dtoItem
.
getExclusive
().
equals
(
1
))
{
//会员券
...
@@ -152,11 +175,17 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -152,11 +175,17 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
Integer
preCanUsePerformanceCoupon
(
BigDecimal
priceTotal
,
String
performanceId
,
String
timeId
,
String
ticketId
)
{
public
Integer
preCanUsePerformanceCoupon
(
BigDecimal
priceTotal
,
String
performanceId
,
String
timeId
,
String
ticketId
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
int
canUse
=
0
;
int
canUse
=
0
;
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
CandyCouponVo
baseVo
=
CouponBaseUtil
.
getPerformanceCouponUserVo
(
dtoItem
,
priceTotal
,
performanceId
,
timeId
,
ticketId
);
CandyCouponVo
baseVo
=
CouponBaseUtil
.
getPerformanceCouponUserVo
(
dtoItem
,
priceTotal
,
performanceId
,
timeId
,
ticketId
);
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
continue
;
continue
;
}
}
if
(
baseVo
.
getState
().
equals
(
1
))
{
//可用
if
(
baseVo
.
getState
().
equals
(
1
))
{
//可用
...
@@ -172,7 +201,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -172,7 +201,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
CandyMyCouponListVo
preUseGoodCoupon
(
BigDecimal
priceTotal
,
String
goodId
,
Integer
type
)
{
public
CandyMyCouponListVo
preUseGoodCoupon
(
BigDecimal
priceTotal
,
String
goodId
,
Integer
type
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
CandyMyCouponListVo
vo
=
CandyMyCouponListVo
.
getNew
();
CandyMyCouponListVo
vo
=
CandyMyCouponListVo
.
getNew
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
memberCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
myCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
myCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
...
@@ -189,7 +224,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -189,7 +224,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
continue
;
continue
;
}
}
}
}
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
continue
;
continue
;
}
}
if
(
dtoItem
.
getExclusive
().
equals
(
1
))
{
//会员券
if
(
dtoItem
.
getExclusive
().
equals
(
1
))
{
//会员券
...
@@ -210,11 +245,17 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -210,11 +245,17 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
Integer
preCanUseGoodCoupon
(
BigDecimal
priceTotal
,
String
goodId
)
{
public
Integer
preCanUseGoodCoupon
(
BigDecimal
priceTotal
,
String
goodId
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
int
canUse
=
0
;
int
canUse
=
0
;
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
CandyCouponVo
baseVo
=
CouponBaseUtil
.
getGoodCouponUserVo
(
dtoItem
,
priceTotal
,
goodId
,
dtoList
.
size
());
CandyCouponVo
baseVo
=
CouponBaseUtil
.
getGoodCouponUserVo
(
dtoItem
,
priceTotal
,
goodId
,
dtoList
.
size
());
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
if
(
baseVo
.
getCouType
().
equals
(
101
))
{
continue
;
continue
;
}
}
if
(
baseVo
.
getState
().
equals
(
1
))
{
//可用
if
(
baseVo
.
getState
().
equals
(
1
))
{
//可用
...
@@ -230,7 +271,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -230,7 +271,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
List
<
CandyCouponVo
>
myAdvanceCoupon
(
String
performanceId
)
{
public
List
<
CandyCouponVo
>
myAdvanceCoupon
(
String
performanceId
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
List
<
CandyCouponVo
>
advanceCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
advanceCoupon
=
ObjectUtil
.
getCandyCouponVoArrayList
();
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
if
(
dtoItem
.
getBusiType
().
equals
(
3
))
{
if
(
dtoItem
.
getBusiType
().
equals
(
3
))
{
...
@@ -250,7 +297,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -250,7 +297,13 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
Integer
stateCoupon
(
String
uCouponId
)
{
public
Integer
stateCoupon
(
String
uCouponId
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
CandyUserCouponBasicDto
dto
=
CouponBaseUtil
.
getSingleDtoByUCouponId
(
redisDataUtils
.
getCouponByUid
(
uid
),
uCouponId
);
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
CandyUserCouponBasicDto
dto
=
CouponBaseUtil
.
getSingleDtoByUCouponId
(
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
),
uCouponId
);
if
(
dto
==
null
)
{
if
(
dto
==
null
)
{
return
null
;
//券不存在
return
null
;
//券不存在
}
}
...
@@ -260,13 +313,19 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -260,13 +313,19 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
CandyUseResultVo
useCoupon
(
String
uCouponId
,
String
content
,
String
totalPrice
,
String
performanceId
,
String
timesId
,
String
ticketId
,
String
goodId
)
{
public
CandyUseResultVo
useCoupon
(
String
uCouponId
,
String
content
,
String
totalPrice
,
String
performanceId
,
String
timesId
,
String
ticketId
,
String
goodId
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
CandyUseResultVo
vo
=
CandyUseResultVo
.
getNew
();
CandyUseResultVo
vo
=
CandyUseResultVo
.
getNew
();
List
<
CandyUserCouponBasicDto
>
dtoList
=
CouponBaseUtil
.
useCoupon
(
redisDataUtils
.
getCouponByUid
(
uid
),
uCouponId
,
content
);
List
<
CandyUserCouponBasicDto
>
dtoList
=
CouponBaseUtil
.
useCoupon
(
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
),
uCouponId
,
content
);
if
(
dtoList
==
null
)
{
if
(
dtoList
==
null
)
{
vo
.
setCouType
(-
1
);
vo
.
setCouType
(-
1
);
vo
.
setValue
(
BigDecimal
.
ZERO
);
vo
.
setValue
(
BigDecimal
.
ZERO
);
}
else
{
}
else
{
CandyUserCouponBasicDto
dto
=
CouponBaseUtil
.
getSingleDtoByUCouponId
(
redisDataUtils
.
getCouponByUid
(
uid
),
uCouponId
);
CandyUserCouponBasicDto
dto
=
CouponBaseUtil
.
getSingleDtoByUCouponId
(
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
),
uCouponId
);
if
(
dto
.
getBusiType
().
equals
(
3
))
{
if
(
dto
.
getBusiType
().
equals
(
3
))
{
dto
.
setCouType
(
101
);
dto
.
setCouType
(
101
);
}
else
{
}
else
{
...
@@ -323,7 +382,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -323,7 +382,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
}
}
}
}
if
(
dto
.
getBusiType
().
equals
(
0
))
{
if
(
dto
.
getBusiType
().
equals
(
0
))
{
isTarget
=
true
;
isTarget
=
true
;
}
}
...
@@ -359,8 +418,14 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -359,8 +418,14 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
public
Boolean
useBackCoupon
(
List
<
BackCouponParam
>
backCouponParams
)
{
public
Boolean
useBackCoupon
(
List
<
BackCouponParam
>
backCouponParams
)
{
for
(
BackCouponParam
item
:
backCouponParams
)
{
for
(
BackCouponParam
item
:
backCouponParams
)
{
String
uid
=
item
.
getUid
();
String
uid
=
item
.
getUid
();
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
ArrayList
<
String
>
uCouponIdList
=
new
ArrayList
(
Arrays
.
asList
(
item
.
getuCouponIds
().
split
(
","
)));
ArrayList
<
String
>
uCouponIdList
=
new
ArrayList
(
Arrays
.
asList
(
item
.
getuCouponIds
().
split
(
","
)));
List
<
CandyUserCouponBasicDto
>
dtoList
=
CouponBaseUtil
.
backCoupon
(
redisDataUtils
.
getCouponByUid
(
uid
),
uCouponIdList
);
List
<
CandyUserCouponBasicDto
>
dtoList
=
CouponBaseUtil
.
backCoupon
(
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
),
uCouponIdList
);
if
(
dtoList
==
null
)
{
if
(
dtoList
==
null
)
{
return
false
;
return
false
;
}
else
{
}
else
{
...
@@ -419,7 +484,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -419,7 +484,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
SqlMapping
.
gets
(
toMqSqls
,
objsUserCoupon
,
objsCouponCode
)
SqlMapping
.
gets
(
toMqSqls
,
objsUserCoupon
,
objsCouponCode
)
);
);
return
ResponseDto
.
success
(
uCouponId
);
return
ResponseDto
.
success
(
uCouponId
);
}
else
if
(
dto
.
getState
().
equals
(
1
))
{
}
else
if
(
dto
.
getState
().
equals
(
1
))
{
return
ResponseDto
.
failure
(
"兑换已使用"
);
return
ResponseDto
.
failure
(
"兑换已使用"
);
}
else
{
}
else
{
return
ResponseDto
.
failure
(
"兑换失败,请稍后再试"
);
return
ResponseDto
.
failure
(
"兑换失败,请稍后再试"
);
...
@@ -439,7 +504,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -439,7 +504,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
}
}
String
uCouponId
=
IDGenerator
.
get32UUID
();
String
uCouponId
=
IDGenerator
.
get32UUID
();
//构建baseDto
//构建baseDto
CandyUserCouponBasicDto
baseDto
=
CandyUserCouponBasicDto
.
getNew
().
copyToRedisBaseCoupon
(
uCouponId
,
uid
,
ccode
,
infoDto
,
LocalDateTime
.
now
().
plusDays
(
infoDto
.
getRedeemValidity
()));
CandyUserCouponBasicDto
baseDto
=
CandyUserCouponBasicDto
.
getNew
().
copyToRedisBaseCoupon
(
uCouponId
,
uid
,
ccode
,
infoDto
,
LocalDateTime
.
now
().
plusDays
(
infoDto
.
getRedeemValidity
()));
return
ResponseDto
.
success
(
CouponBaseUtil
.
getBaseCouponUserVo
(
baseDto
));
return
ResponseDto
.
success
(
CouponBaseUtil
.
getBaseCouponUserVo
(
baseDto
));
}
else
{
}
else
{
return
ResponseDto
.
failure
(
"兑换失败,请稍后再试"
);
return
ResponseDto
.
failure
(
"兑换失败,请稍后再试"
);
...
@@ -449,15 +514,21 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
...
@@ -449,15 +514,21 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
@Override
public
ResponseDto
<
List
<
CandyCouponVo
>>
couponListById
(
String
uCouponIds
)
{
public
ResponseDto
<
List
<
CandyCouponVo
>>
couponListById
(
String
uCouponIds
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
LocalDateTime
userCreateTime
;
try
{
userCreateTime
=
(
LocalDateTime
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_UCREATED
);
}
catch
(
Exception
e
)
{
userCreateTime
=
null
;
}
ArrayList
<
String
>
uCouponIdList
=
new
ArrayList
(
Arrays
.
asList
(
uCouponIds
.
split
(
","
)));
ArrayList
<
String
>
uCouponIdList
=
new
ArrayList
(
Arrays
.
asList
(
uCouponIds
.
split
(
","
)));
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
);
List
<
CandyUserCouponBasicDto
>
dtoList
=
redisDataUtils
.
getCouponByUid
(
uid
,
userCreateTime
);
List
<
CandyCouponVo
>
vo
=
ObjectUtil
.
getCandyCouponVoArrayList
();
List
<
CandyCouponVo
>
vo
=
ObjectUtil
.
getCandyCouponVoArrayList
();
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
for
(
CandyUserCouponBasicDto
dtoItem
:
dtoList
)
{
if
(
uCouponIdList
.
contains
(
dtoItem
.
getUcouponId
()))
{
if
(
uCouponIdList
.
contains
(
dtoItem
.
getUcouponId
()))
{
CandyCouponVo
baseVo
=
CouponBaseUtil
.
getBaseCouponUserVo
(
dtoItem
);
CandyCouponVo
baseVo
=
CouponBaseUtil
.
getBaseCouponUserVo
(
dtoItem
);
vo
.
add
(
baseVo
);
vo
.
add
(
baseVo
);
}
else
{
}
else
{
continue
;
continue
;
}
}
}
}
...
...
liquidnet-bus-service/liquidnet-service-candy/liquidnet-service-candy-impl/src/main/java/com/liquidnet/service/candy/util/RedisDataUtils.java
View file @
e7b0b866
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
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
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -23,7 +24,7 @@ public class RedisDataUtils {
...
@@ -23,7 +24,7 @@ public class RedisDataUtils {
RedisUtil
redisUtil
;
RedisUtil
redisUtil
;
// 获取 CandyUserCouponBasicDto数组 根据用户id
// 获取 CandyUserCouponBasicDto数组 根据用户id
public
List
<
CandyUserCouponBasicDto
>
getCouponByUid
(
String
uid
)
{
public
List
<
CandyUserCouponBasicDto
>
getCouponByUid
(
String
uid
,
LocalDateTime
userCreateTime
)
{
String
redisKey
=
CandyRedisConst
.
BASIC_USER_COUPON
.
concat
(
uid
);
String
redisKey
=
CandyRedisConst
.
BASIC_USER_COUPON
.
concat
(
uid
);
String
publicRedisKey
=
CandyRedisConst
.
BASIC_COMMON_COUPON
;
String
publicRedisKey
=
CandyRedisConst
.
BASIC_COMMON_COUPON
;
...
@@ -47,14 +48,14 @@ public class RedisDataUtils {
...
@@ -47,14 +48,14 @@ public class RedisDataUtils {
}
}
boolean
needSet
=
false
;
boolean
needSet
=
false
;
if
(
userCreateTime
==
null
)
{
userCreateTime
=
LocalDateTime
.
MIN
;
}
List
<
String
>
userIds
=
userDto
.
stream
().
map
(
CandyUserCouponBasicDto:
:
getCcouponId
).
collect
(
Collectors
.
toList
());
List
<
String
>
userIds
=
userDto
.
stream
().
map
(
CandyUserCouponBasicDto:
:
getCcouponId
).
collect
(
Collectors
.
toList
());
log
.
info
(
"userIds = "
+
userIds
.
toString
());
for
(
CandyCommonCouponBasicDto
item
:
pubDto
)
{
for
(
CandyCommonCouponBasicDto
item
:
pubDto
)
{
log
.
info
(
"pubDto = "
+
item
.
getCcouponId
());
if
(
userIds
.
contains
(
item
.
getCcouponId
())
||
userCreateTime
.
isAfter
(
item
.
getCreatedAt
()))
{
if
(
userIds
.
contains
(
item
.
getCcouponId
()))
{
continue
;
continue
;
}
else
{
}
else
{
log
.
info
(
"pubDto = add"
);
CandyUserCouponBasicDto
userCouponBasicDto
=
CandyUserCouponBasicDto
.
getNew
().
copyToRedisCommonBaseCoupon
(
IDGenerator
.
get32UUID
(),
uid
,
item
);
CandyUserCouponBasicDto
userCouponBasicDto
=
CandyUserCouponBasicDto
.
getNew
().
copyToRedisCommonBaseCoupon
(
IDGenerator
.
get32UUID
(),
uid
,
item
);
userDto
.
add
(
userCouponBasicDto
);
userDto
.
add
(
userCouponBasicDto
);
needSet
=
true
;
needSet
=
true
;
...
...
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