记得上下班打卡 | 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
21faf334
Commit
21faf334
authored
Aug 30, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
券发放+全体用户|全体会员操作逻辑;
parent
561562b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
221 additions
and
140 deletions
+221
-140
CandyCommonCoupon.java
...com/liquidnet/service/candy/entity/CandyCommonCoupon.java
+11
-0
db_ln_candy_initialdata.sql
...idnet-service-candy-impl/docu/db_ln_candy_initialdata.sql
+5
-1
PlatformCandyCommonCouponService.java
.../service/impl/candy/PlatformCandyCommonCouponService.java
+10
-0
PlatformCandyCouponService.java
...atform/service/impl/candy/PlatformCandyCouponService.java
+195
-139
No files found.
liquidnet-bus-do/liquidnet-service-candy-do/src/main/java/com/liquidnet/service/candy/entity/CandyCommonCoupon.java
View file @
21faf334
...
@@ -3,6 +3,8 @@ package com.liquidnet.service.candy.entity;
...
@@ -3,6 +3,8 @@ package com.liquidnet.service.candy.entity;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -45,6 +47,15 @@ public class CandyCommonCoupon implements Serializable {
...
@@ -45,6 +47,15 @@ public class CandyCommonCoupon implements Serializable {
*/
*/
private
Integer
ranged
;
private
Integer
ranged
;
/**
* 操作人
*/
private
String
operator
;
private
LocalDateTime
createdAt
;
private
LocalDateTime
updatedAt
;
private
String
comment
;
private
String
comment
;
...
...
liquidnet-bus-service/liquidnet-service-candy/liquidnet-service-candy-impl/docu/db_ln_candy_initialdata.sql
View file @
21faf334
...
@@ -132,7 +132,11 @@ create table candy_common_coupon
...
@@ -132,7 +132,11 @@ create table candy_common_coupon
mcoupon_id
varchar
(
64
)
not
null
comment
'~candy_mgt_coupon.mcoupon_id'
,
mcoupon_id
varchar
(
64
)
not
null
comment
'~candy_mgt_coupon.mcoupon_id'
,
coupon_id
varchar
(
64
)
not
null
comment
'~candy_coupon.coupon_id'
,
coupon_id
varchar
(
64
)
not
null
comment
'~candy_coupon.coupon_id'
,
state
tinyint
comment
'公有券状态[1-可用|2-无效|3-已过期]'
,
state
tinyint
comment
'公有券状态[1-可用|2-无效|3-已过期]'
,
ranged
tinyint
comment
'公有券范围[10-全体用户|20-全体会员]'
,
ranged
tinyint
comment
'公有券范围(~candy_mgt_coupon.event_type)'
,
operator
varchar
(
64
)
not
null
comment
'操作人'
,
created_at
datetime
(
3
)
not
null
,
updated_at
datetime
(
3
),
comment
varchar
(
255
)
comment
varchar
(
255
)
)
engine
=
InnoDB
comment
'公有券信息'
;
)
engine
=
InnoDB
comment
'公有券信息'
;
-- >>------------------------------------------------------------------------------------
-- >>------------------------------------------------------------------------------------
...
...
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/service/impl/candy/PlatformCandyCommonCouponService.java
0 → 100644
View file @
21faf334
package
com
.
liquidnet
.
service
.
platform
.
service
.
impl
.
candy
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.liquidnet.service.candy.entity.CandyCommonCoupon
;
import
com.liquidnet.service.candy.mapper.CandyCommonCouponMapper
;
import
org.springframework.stereotype.Service
;
@Service
public
class
PlatformCandyCommonCouponService
extends
ServiceImpl
<
CandyCommonCouponMapper
,
CandyCommonCoupon
>
{
}
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/service/impl/candy/PlatformCandyCouponService.java
View file @
21faf334
package
com
.
liquidnet
.
service
.
platform
.
service
.
impl
.
candy
;
package
com
.
liquidnet
.
service
.
platform
.
service
.
impl
.
candy
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.service.adam.
entity.AdamUserMember
;
import
com.liquidnet.service.adam.
constant.AdamRedisConst
;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.dto.CandyCouponCodeDto
;
import
com.liquidnet.service.candy.dto.*
;
import
com.liquidnet.service.candy.dto.CandyCouponInfoDto
;
import
com.liquidnet.service.candy.entity.*
;
import
com.liquidnet.service.candy.dto.CandyCouponRuleDto
;
import
com.liquidnet.service.candy.dto.CandyUserCouponBasicDto
;
import
com.liquidnet.service.candy.entity.CandyCoupon
;
import
com.liquidnet.service.candy.entity.CandyCouponCode
;
import
com.liquidnet.service.candy.entity.CandyMgtCoupon
;
import
com.liquidnet.service.candy.entity.CandyUserCoupon
;
import
com.liquidnet.service.candy.mapper.CandyCouponMapper
;
import
com.liquidnet.service.candy.mapper.CandyCouponMapper
;
import
com.liquidnet.service.platform.service.impl.adam.PlatformAdamUserMemberService
;
import
com.liquidnet.service.platform.service.impl.adam.dm.DMRdmService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -41,9 +31,7 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -41,9 +31,7 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
@Autowired
@Autowired
private
PlatformCandyUserCouponService
platformCandyUserCouponService
;
private
PlatformCandyUserCouponService
platformCandyUserCouponService
;
@Autowired
@Autowired
private
PlatformAdamUserMemberService
platformAdamUserMemberService
;
private
PlatformCandyCommonCouponService
platformCandyCommonCouponService
;
@Autowired
private
DMRdmService
dmRdmService
;
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
...
@@ -57,138 +45,71 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -57,138 +45,71 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
String
couponInfoDtoKey
=
CandyRedisConst
.
BASIC_COUPON_INFO
.
concat
(
couponInfoDto
.
getCouponId
());
String
couponInfoDtoKey
=
CandyRedisConst
.
BASIC_COUPON_INFO
.
concat
(
couponInfoDto
.
getCouponId
());
redisUtil
.
set
(
couponInfoDtoKey
,
couponInfoDto
);
redisUtil
.
set
(
couponInfoDtoKey
,
couponInfoDto
);
LocalDateTime
now
=
LocalDateTime
.
now
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
switch
(
coupon
.
getBindType
())
{
// 领取方式[0-用户输入兑换|1-发放至用户]
switch
(
coupon
.
getBindType
())
{
// 领取方式[0-用户输入兑换|1-发放至用户]
case
0
:
case
0
:
List
<
CandyCouponCode
>
initCouponCodeList
=
new
ArrayList
<>();
this
.
processingCouponCode
(
mgtCoupon
,
coupon
);
boolean
batchFlag
=
eventAmt
>
1000
;
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
CandyCouponCode
couponCode
=
new
CandyCouponCode
();
couponCode
.
setCcode
(
RandomStringUtils
.
randomAlphanumeric
(
16
));
couponCode
.
setCouponId
(
coupon
.
getCouponId
());
couponCode
.
setState
(
0
);
couponCode
.
setCreatedAt
(
now
);
initCouponCodeList
.
add
(
couponCode
);
if
(
batchFlag
&&
initCouponCodeList
.
size
()
>=
1000
)
{
if
(
platformCandyCouponCodeService
.
saveBatch
(
initCouponCodeList
))
{
initCouponCodeList
.
forEach
(
r
->
{
redisUtil
.
set
(
CandyRedisConst
.
BASIC_COUPON_CODE
.
concat
(
r
.
getCcode
()),
CandyCouponCodeDto
.
getNew
().
copy
(
r
));
});
initCouponCodeList
.
clear
();
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
"券发放失败"
);
}
}
}
if
(
initCouponCodeList
.
size
()
>
0
&&
platformCandyCouponCodeService
.
saveBatch
(
initCouponCodeList
))
{
initCouponCodeList
.
forEach
(
r
->
{
redisUtil
.
set
(
CandyRedisConst
.
BASIC_COUPON_CODE
.
concat
(
r
.
getCcode
()),
CandyCouponCodeDto
.
getNew
().
copy
(
r
));
});
initCouponCodeList
.
clear
();
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
"券发放失败"
);
}
break
;
break
;
case
1
:
case
1
:
List
<
CandyUserCoupon
>
initUserCouponList
=
new
ArrayList
<>();
switch
(
mgtCoupon
.
getEventType
())
{
// 发放类型[1-会员|2-手机号|10-全体用户]
switch
(
mgtCoupon
.
getEventType
())
{
// 发放类型[1-会员|2-手机号|10-全体用户]
case
1
:
case
1
:
LocalDateTime
nowEndTime
=
now
.
withHour
(
23
).
withMinute
(
59
).
withSecond
(
59
);
this
.
processingCommonCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
LambdaQueryWrapper
<
AdamUserMember
>
queryWrapper
=
Wrappers
.
lambdaQuery
(
AdamUserMember
.
class
).
eq
(
AdamUserMember:
:
getState
,
1
)
.
gt
(
AdamUserMember:
:
getExpiryAt
,
nowEndTime
);
// LocalDateTime nowEndTime = now.withHour(23).withMinute(59).withSecond(59);
int
userMemberCount
=
platformAdamUserMemberService
.
count
(
queryWrapper
),
num
=
0
,
pSize
=
1000
;
// LambdaQueryWrapper<AdamUserMember> queryWrapper = Wrappers.lambdaQuery(AdamUserMember.class).eq(AdamUserMember::getState, 1)
log
.
info
(
"发放券任务:userMemberCount:{}"
,
userMemberCount
);
// .gt(AdamUserMember::getExpiryAt, nowEndTime);
// int userMemberCount = platformAdamUserMemberService.count(queryWrapper), num = 0, pSize = 1000;
while
(
userMemberCount
>
0
)
{
// log.info("发放券任务:userMemberCount:{}", userMemberCount);
initUserCouponList
.
clear
();
//
String
lastLimitSql
=
"LIMIT "
+
(
num
*
pSize
)
+
","
+
pSize
;
// while (userMemberCount > 0) {
queryWrapper
.
orderByAsc
(
AdamUserMember:
:
getMid
).
last
(
lastLimitSql
);
// initUserCouponList.clear();
queryWrapper
.
select
(
AdamUserMember:
:
getUid
);
// String lastLimitSql = "LIMIT " + (num * pSize) + "," + pSize;
List
<
AdamUserMember
>
userMemberList
=
platformAdamUserMemberService
.
list
(
queryWrapper
);
// queryWrapper.orderByAsc(AdamUserMember::getMid).last(lastLimitSql);
int
userMemberListSize
=
CollectionUtils
.
isEmpty
(
userMemberList
)
?
-
1
:
userMemberList
.
size
();
// queryWrapper.select(AdamUserMember::getUid);
for
(
int
i
=
0
;
i
<
userMemberListSize
;
i
++)
{
// List<AdamUserMember> userMemberList = platformAdamUserMemberService.list(queryWrapper);
AdamUserMember
userMember
=
userMemberList
.
get
(
i
);
// int userMemberListSize = CollectionUtils.isEmpty(userMemberList) ? -1 : userMemberList.size();
// for (int i = 0; i < userMemberListSize; i++) {
CandyUserCoupon
userCoupon
=
new
CandyUserCoupon
();
// AdamUserMember userMember = userMemberList.get(i);
userCoupon
.
setUcouponId
(
IDGenerator
.
get32UUID
());
//
userCoupon
.
setMcouponId
(
mgtCoupon
.
getMcouponId
());
// CandyUserCoupon userCoupon = new CandyUserCoupon();
userCoupon
.
setUid
(
userMember
.
getUid
());
// userCoupon.setUcouponId(IDGenerator.get32UUID());
userCoupon
.
setCouponId
(
coupon
.
getCouponId
());
// userCoupon.setMcouponId(mgtCoupon.getMcouponId());
userCoupon
.
setState
(
1
);
// userCoupon.setUid(userMember.getUid());
userCoupon
.
setBindAt
(
now
);
// userCoupon.setCouponId(coupon.getCouponId());
// userCoupon.setState(1);
initUserCouponList
.
add
(
userCoupon
);
// userCoupon.setBindAt(now);
}
//
// initUserCouponList.add(userCoupon);
if
(!
initUserCouponList
.
isEmpty
())
{
// }
if
(
platformCandyUserCouponService
.
saveBatch
(
initUserCouponList
))
{
//
initUserCouponList
.
forEach
(
r
->
{
// if (!initUserCouponList.isEmpty()) {
String
uckey
=
CandyRedisConst
.
BASIC_USER_COUPON
.
concat
(
r
.
getUid
());
// if (platformCandyUserCouponService.saveBatch(initUserCouponList)) {
// initUserCouponList.forEach(r -> {
List
<
CandyUserCouponBasicDto
>
vos
=
(
List
<
CandyUserCouponBasicDto
>)
redisUtil
.
get
(
uckey
);
// String uckey = CandyRedisConst.BASIC_USER_COUPON.concat(r.getUid());
//
if
(
CollectionUtils
.
isEmpty
(
vos
))
{
// List<CandyUserCouponBasicDto> vos = (List<CandyUserCouponBasicDto>) redisUtil.get(uckey);
vos
=
new
ArrayList
<>();
//
}
// if (CollectionUtils.isEmpty(vos)) {
vos
.
add
(
CandyUserCouponBasicDto
.
getNew
().
copy
(
r
,
coupon
,
couponRuleDtoList
));
// vos = new ArrayList<>();
// }
redisUtil
.
set
(
uckey
,
vos
);
// vos.add(CandyUserCouponBasicDto.getNew().copy(r, coupon, couponRuleDtoList));
});
//
}
else
{
// redisUtil.set(uckey, vos);
throw
new
LiquidnetServiceException
(
"-1"
,
"券发放失败"
);
// });
}
// } else {
}
// throw new LiquidnetServiceException("-1", "券发放失败");
// }
num
++;
// }
userMemberCount
-=
pSize
;
//
log
.
info
(
"发放券任务:userMemberCount:{},"
+
lastLimitSql
,
userMemberCount
);
// num++;
}
// userMemberCount -= pSize;
// log.info("发放券任务:userMemberCount:{}," + lastLimitSql, userMemberCount);
// }
break
;
break
;
case
2
:
case
2
:
String
eventLimit
=
mgtCoupon
.
getEventLimit
();
this
.
processForUserCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
String
[]
eventLimitArr
=
eventLimit
.
split
(
","
);
log
.
info
(
"发放券任务:eventLimitArrLength:{}"
,
eventLimitArr
.
length
);
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
for
(
String
r
:
eventLimitArr
)
{
String
uid
=
dmRdmService
.
getUidByMobile
(
r
);
if
(
StringUtils
.
isNotEmpty
(
uid
))
{
CandyUserCoupon
userCoupon
=
new
CandyUserCoupon
();
userCoupon
.
setUcouponId
(
IDGenerator
.
get32UUID
());
userCoupon
.
setMcouponId
(
mgtCoupon
.
getMcouponId
());
userCoupon
.
setUid
(
uid
);
userCoupon
.
setCouponId
(
coupon
.
getCouponId
());
userCoupon
.
setState
(
1
);
userCoupon
.
setBindAt
(
now
);
initUserCouponList
.
add
(
userCoupon
);
}
}
}
if
(!
initUserCouponList
.
isEmpty
()
&&
platformCandyUserCouponService
.
saveBatch
(
initUserCouponList
))
{
initUserCouponList
.
forEach
(
r
->
{
String
uckey
=
CandyRedisConst
.
BASIC_USER_COUPON
.
concat
(
r
.
getUid
());
List
<
CandyUserCouponBasicDto
>
vos
=
(
List
<
CandyUserCouponBasicDto
>)
redisUtil
.
get
(
uckey
);
if
(
CollectionUtils
.
isEmpty
(
vos
))
{
vos
=
new
ArrayList
<>();
}
vos
.
add
(
CandyUserCouponBasicDto
.
getNew
().
copy
(
r
,
coupon
,
couponRuleDtoList
));
redisUtil
.
set
(
uckey
,
vos
);
});
}
break
;
break
;
case
10
:
// TODO: 2021/8/24 具体发放方式待定
case
10
:
this
.
processingCommonCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
break
;
break
;
default
:
default
:
log
.
warn
(
"发放券任务:无法处理,无效的发放类型[mcouponId:{},eventType:{}]"
,
mgtCoupon
.
getMcouponId
(),
mgtCoupon
.
getEventType
());
log
.
warn
(
"发放券任务:无法处理,无效的发放类型[mcouponId:{},eventType:{}]"
,
mgtCoupon
.
getMcouponId
(),
mgtCoupon
.
getEventType
());
...
@@ -201,6 +122,141 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -201,6 +122,141 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
}
}
}
}
/**
* <p>
* 券码生成处理
* </p>
*
* @param mgtCoupon CandyMgtCoupon
* @param coupon CandyCoupon
*/
private
void
processingCouponCode
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
)
{
List
<
CandyCouponCode
>
initCouponCodeList
=
new
ArrayList
<>();
LocalDateTime
now
=
LocalDateTime
.
now
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
CandyCouponCode
couponCode
=
new
CandyCouponCode
();
couponCode
.
setCcode
(
RandomStringUtils
.
randomAlphanumeric
(
16
));
couponCode
.
setCouponId
(
coupon
.
getCouponId
());
couponCode
.
setState
(
0
);
couponCode
.
setCreatedAt
(
now
);
initCouponCodeList
.
add
(
couponCode
);
}
if
(!
initCouponCodeList
.
isEmpty
())
{
if
(
platformCandyCouponCodeService
.
saveBatch
(
initCouponCodeList
))
{
initCouponCodeList
.
forEach
(
r
->
{
redisUtil
.
set
(
CandyRedisConst
.
BASIC_COUPON_CODE
.
concat
(
r
.
getCcode
()),
CandyCouponCodeDto
.
getNew
().
copy
(
r
));
});
initCouponCodeList
.
clear
();
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
}
}
}
/**
* <p>
* 公有券发放处理
* </p>
*
* @param mgtCoupon CandyMgtCoupon
* @param coupon CandyCoupon
* @param couponRuleDtoList List<CandyCouponRuleDto>
*/
private
void
processingCommonCoupon
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
List
<
CandyCommonCoupon
>
initCommonCouponList
=
new
ArrayList
<>();
LocalDateTime
now
=
LocalDateTime
.
now
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
CandyCommonCoupon
commonCoupon
=
new
CandyCommonCoupon
();
commonCoupon
.
setCcouponId
(
IDGenerator
.
nextMilliId
());
commonCoupon
.
setMcouponId
(
mgtCoupon
.
getMcouponId
());
commonCoupon
.
setCouponId
(
coupon
.
getCouponId
());
commonCoupon
.
setState
(
1
);
commonCoupon
.
setRanged
(
mgtCoupon
.
getEventType
());
commonCoupon
.
setOperator
(
"system"
);
commonCoupon
.
setCreatedAt
(
now
);
initCommonCouponList
.
add
(
commonCoupon
);
}
if
(!
initCommonCouponList
.
isEmpty
())
{
if
(
platformCandyCommonCouponService
.
saveBatch
(
initCommonCouponList
,
initCommonCouponList
.
size
()))
{
initCommonCouponList
.
forEach
(
r
->
{
String
ccKey
=
CandyRedisConst
.
BASIC_COMMON_COUPON
;
List
<
CandyCommonCouponBasicDto
>
vos
=
(
List
<
CandyCommonCouponBasicDto
>)
redisUtil
.
get
(
ccKey
);
if
(
CollectionUtils
.
isEmpty
(
vos
))
{
vos
=
new
ArrayList
<>();
}
vos
.
add
(
CandyCommonCouponBasicDto
.
getNew
().
copy
(
r
,
coupon
,
couponRuleDtoList
));
redisUtil
.
set
(
ccKey
,
vos
);
});
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
}
}
}
/**
* <p>
* 私有券发放处理
* </p>
*
* @param mgtCoupon CandyMgtCoupon
* @param coupon CandyCoupon
* @param couponRuleDtoList List<CandyCouponRuleDto>
*/
private
void
processForUserCoupon
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
List
<
CandyUserCoupon
>
initUserCouponList
=
new
ArrayList
<>();
LocalDateTime
now
=
LocalDateTime
.
now
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
String
eventLimit
=
mgtCoupon
.
getEventLimit
();
String
[]
eventLimitArr
=
eventLimit
.
split
(
","
);
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
for
(
String
r
:
eventLimitArr
)
{
String
uid
=
(
String
)
redisUtil
.
get
(
AdamRedisConst
.
IDENTITY_MOBILE
.
concat
(
r
));
if
(
StringUtils
.
isNotEmpty
(
uid
))
{
CandyUserCoupon
userCoupon
=
new
CandyUserCoupon
();
userCoupon
.
setUcouponId
(
IDGenerator
.
get32UUID
());
userCoupon
.
setMcouponId
(
mgtCoupon
.
getMcouponId
());
userCoupon
.
setUid
(
uid
);
userCoupon
.
setCouponId
(
coupon
.
getCouponId
());
userCoupon
.
setState
(
1
);
userCoupon
.
setBindAt
(
now
);
initUserCouponList
.
add
(
userCoupon
);
}
}
}
if
(!
initUserCouponList
.
isEmpty
())
{
if
(
platformCandyUserCouponService
.
saveBatch
(
initUserCouponList
))
{
initUserCouponList
.
forEach
(
r
->
{
String
uckey
=
CandyRedisConst
.
BASIC_USER_COUPON
.
concat
(
r
.
getUid
());
List
<
CandyUserCouponBasicDto
>
vos
=
(
List
<
CandyUserCouponBasicDto
>)
redisUtil
.
get
(
uckey
);
if
(
CollectionUtils
.
isEmpty
(
vos
))
{
vos
=
new
ArrayList
<>();
}
vos
.
add
(
CandyUserCouponBasicDto
.
getNew
().
copy
(
r
,
coupon
,
couponRuleDtoList
));
redisUtil
.
set
(
uckey
,
vos
);
});
}
else
{
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
}
}
}
/**
/**
* <p>
* <p>
* 发放代金券
* 发放代金券
...
...
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