记得上下班打卡 | 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
f9bf9bee
Commit
f9bf9bee
authored
Sep 01, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发放券:全体会员调整;
parent
f15d15d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
57 deletions
+90
-57
PlatformCandyCouponService.java
...atform/service/impl/candy/PlatformCandyCouponService.java
+90
-57
No files found.
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/service/impl/candy/PlatformCandyCouponService.java
View file @
f9bf9bee
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.constant.AdamRedisConst
;
import
com.liquidnet.service.adam.constant.AdamRedisConst
;
import
com.liquidnet.service.adam.entity.AdamUserMember
;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.constant.CandyRedisConst
;
import
com.liquidnet.service.candy.dto.*
;
import
com.liquidnet.service.candy.dto.*
;
import
com.liquidnet.service.candy.entity.*
;
import
com.liquidnet.service.candy.entity.*
;
import
com.liquidnet.service.candy.mapper.CandyCouponMapper
;
import
com.liquidnet.service.candy.mapper.CandyCouponMapper
;
import
com.liquidnet.service.platform.service.impl.adam.PlatformAdamUserMemberService
;
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
;
...
@@ -33,6 +37,8 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -33,6 +37,8 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
@Autowired
@Autowired
private
PlatformCandyCommonCouponService
platformCandyCommonCouponService
;
private
PlatformCandyCommonCouponService
platformCandyCommonCouponService
;
@Autowired
@Autowired
private
PlatformAdamUserMemberService
platformAdamUserMemberService
;
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
private
void
issueCouponProcessing
(
final
CandyMgtCoupon
mgtCoupon
,
final
CandyCoupon
coupon
)
{
private
void
issueCouponProcessing
(
final
CandyMgtCoupon
mgtCoupon
,
final
CandyCoupon
coupon
)
{
...
@@ -52,64 +58,13 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -52,64 +58,13 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
case
1
:
case
1
:
switch
(
mgtCoupon
.
getEventType
())
{
// 发放类型[1-会员|2-手机号|10-全体用户]
switch
(
mgtCoupon
.
getEventType
())
{
// 发放类型[1-会员|2-手机号|10-全体用户]
case
1
:
case
1
:
this
.
processingCommonCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
this
.
processForAllMember
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
// LocalDateTime nowEndTime = now.withHour(23).withMinute(59).withSecond(59);
// LambdaQueryWrapper<AdamUserMember> queryWrapper = Wrappers.lambdaQuery(AdamUserMember.class).eq(AdamUserMember::getState, 1)
// .gt(AdamUserMember::getExpiryAt, nowEndTime);
// int userMemberCount = platformAdamUserMemberService.count(queryWrapper), num = 0, pSize = 1000;
// log.info("发放券任务:userMemberCount:{}", userMemberCount);
//
// while (userMemberCount > 0) {
// initUserCouponList.clear();
// String lastLimitSql = "LIMIT " + (num * pSize) + "," + pSize;
// queryWrapper.orderByAsc(AdamUserMember::getMid).last(lastLimitSql);
// queryWrapper.select(AdamUserMember::getUid);
// List<AdamUserMember> userMemberList = platformAdamUserMemberService.list(queryWrapper);
// int userMemberListSize = CollectionUtils.isEmpty(userMemberList) ? -1 : userMemberList.size();
// for (int i = 0; i < userMemberListSize; i++) {
// AdamUserMember userMember = userMemberList.get(i);
//
// CandyUserCoupon userCoupon = new CandyUserCoupon();
// userCoupon.setUcouponId(IDGenerator.get32UUID());
// userCoupon.setMcouponId(mgtCoupon.getMcouponId());
// userCoupon.setUid(userMember.getUid());
// 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", "券发放失败");
// }
// }
//
// num++;
// userMemberCount -= pSize;
// log.info("发放券任务:userMemberCount:{}," + lastLimitSql, userMemberCount);
// }
break
;
break
;
case
2
:
case
2
:
this
.
processForUserCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
this
.
processForUserCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
break
;
break
;
case
10
:
case
10
:
this
.
process
ing
CommonCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
this
.
process
For
CommonCoupon
(
mgtCoupon
,
coupon
,
couponRuleDtoList
);
break
;
break
;
default
:
default
:
log
.
warn
(
"发放券任务:无法处理,无效的发放类型[mcouponId:{},eventType:{}]"
,
mgtCoupon
.
getMcouponId
(),
mgtCoupon
.
getEventType
());
log
.
warn
(
"发放券任务:无法处理,无效的发放类型[mcouponId:{},eventType:{}]"
,
mgtCoupon
.
getMcouponId
(),
mgtCoupon
.
getEventType
());
...
@@ -159,17 +114,20 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -159,17 +114,20 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
/**
/**
* <p>
* <p>
*
公有券发放处理
*
发放处理-公有券
* </p>
* </p>
*
*
* @param mgtCoupon CandyMgtCoupon
* @param mgtCoupon CandyMgtCoupon
* @param coupon CandyCoupon
* @param coupon CandyCoupon
* @param couponRuleDtoList List<CandyCouponRuleDto>
* @param couponRuleDtoList List<CandyCouponRuleDto>
*/
*/
private
void
process
ing
CommonCoupon
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
private
void
process
For
CommonCoupon
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
List
<
CandyCommonCoupon
>
initCommonCouponList
=
new
ArrayList
<>();
List
<
CandyCommonCoupon
>
initCommonCouponList
=
new
ArrayList
<>();
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
log
.
info
(
"发放券处理中:目标全体用户[发放量:{}]"
,
eventAmt
);
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
CandyCommonCoupon
commonCoupon
=
new
CandyCommonCoupon
();
CandyCommonCoupon
commonCoupon
=
new
CandyCommonCoupon
();
commonCoupon
.
setCcouponId
(
IDGenerator
.
nextMilliId
());
commonCoupon
.
setCcouponId
(
IDGenerator
.
nextMilliId
());
...
@@ -200,11 +158,82 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -200,11 +158,82 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
}
}
}
}
log
.
info
(
"发放券处理中:目标全体用户[发放量:{},实际发放:{}]"
,
eventAmt
,
initCommonCouponList
.
size
());
}
/**
* <p>
* 发放处理-全体会员
* </p>
*
* @param mgtCoupon CandyMgtCoupon
* @param coupon CandyCoupon
* @param couponRuleDtoList List<CandyCouponRuleDto>
*/
private
void
processForAllMember
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
List
<
CandyUserCoupon
>
initUserCouponList
=
new
ArrayList
<>();
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
nowEndTime
=
now
.
withHour
(
23
).
withMinute
(
59
).
withSecond
(
59
);
LambdaQueryWrapper
<
AdamUserMember
>
queryWrapper
=
Wrappers
.
lambdaQuery
(
AdamUserMember
.
class
).
eq
(
AdamUserMember:
:
getState
,
1
)
.
gt
(
AdamUserMember:
:
getExpiryAt
,
nowEndTime
);
int
userMemberCount
=
platformAdamUserMemberService
.
count
(
queryWrapper
),
num
=
0
,
pSize
=
1000
;
int
totalCount
=
userMemberCount
,
eventAmt
=
mgtCoupon
.
getEventAmt
();
log
.
info
(
"发放券处理中:目标全体会员[总数:{},发放量:{}]"
,
userMemberCount
,
eventAmt
);
while
(
totalCount
>
0
)
{
initUserCouponList
.
clear
();
String
lastLimitSql
=
"LIMIT "
+
(
num
*
pSize
)
+
","
+
pSize
;
queryWrapper
.
orderByAsc
(
AdamUserMember:
:
getMid
).
last
(
lastLimitSql
);
queryWrapper
.
select
(
AdamUserMember:
:
getUid
);
List
<
AdamUserMember
>
userMemberList
=
platformAdamUserMemberService
.
list
(
queryWrapper
);
int
userMemberListSize
=
CollectionUtils
.
isEmpty
(
userMemberList
)
?
-
1
:
userMemberList
.
size
();
for
(
int
j
=
0
;
j
<
eventAmt
;
j
++)
{
for
(
int
i
=
0
;
i
<
userMemberListSize
;
i
++)
{
AdamUserMember
userMember
=
userMemberList
.
get
(
i
);
CandyUserCoupon
userCoupon
=
new
CandyUserCoupon
();
userCoupon
.
setUcouponId
(
IDGenerator
.
get32UUID
());
userCoupon
.
setMcouponId
(
mgtCoupon
.
getMcouponId
());
userCoupon
.
setUid
(
userMember
.
getUid
());
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"
,
"券发放失败"
);
}
}
num
++;
totalCount
-=
pSize
;
log
.
info
(
"发放券处理中:目标全体会员[总数:{},发放量:{},单次处理:{},剩余:{}]"
,
userMemberCount
,
eventAmt
,
lastLimitSql
,
totalCount
);
}
}
}
/**
/**
* <p>
* <p>
*
私有券发放处理
*
发放处理-私有券(指定手机号)
* </p>
* </p>
*
*
* @param mgtCoupon CandyMgtCoupon
* @param mgtCoupon CandyMgtCoupon
...
@@ -214,10 +243,11 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -214,10 +243,11 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
private
void
processForUserCoupon
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
private
void
processForUserCoupon
(
CandyMgtCoupon
mgtCoupon
,
CandyCoupon
coupon
,
List
<
CandyCouponRuleDto
>
couponRuleDtoList
)
{
List
<
CandyUserCoupon
>
initUserCouponList
=
new
ArrayList
<>();
List
<
CandyUserCoupon
>
initUserCouponList
=
new
ArrayList
<>();
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
Integer
eventAmt
=
mgtCoupon
.
getEventAmt
();
String
eventLimit
=
mgtCoupon
.
getEventLimit
();
String
eventLimit
=
mgtCoupon
.
getEventLimit
();
String
[]
eventLimitArr
=
eventLimit
.
split
(
","
);
String
[]
eventLimitArr
=
eventLimit
.
split
(
","
);
int
eventAmt
=
mgtCoupon
.
getEventAmt
(),
pl
=
0
,
limitSize
=
eventLimitArr
.
length
;
log
.
info
(
"发放券处理中:目标指定手机号[总数:{},发放量:{}]"
,
limitSize
,
eventAmt
);
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
for
(
int
i
=
0
;
i
<
eventAmt
;
i
++)
{
for
(
String
r
:
eventLimitArr
)
{
for
(
String
r
:
eventLimitArr
)
{
...
@@ -233,6 +263,8 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -233,6 +263,8 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
userCoupon
.
setBindAt
(
now
);
userCoupon
.
setBindAt
(
now
);
initUserCouponList
.
add
(
userCoupon
);
initUserCouponList
.
add
(
userCoupon
);
pl
++;
}
}
}
}
}
}
...
@@ -255,6 +287,7 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
...
@@ -255,6 +287,7 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
throw
new
LiquidnetServiceException
(
"-1"
,
String
.
format
(
"券发放失败[mcouponId=%s]"
,
mgtCoupon
.
getMcouponId
()));
}
}
}
}
log
.
info
(
"发放券处理中:目标指定手机号[总数:{},发放量:{},实际处理:{}]"
,
limitSize
,
eventAmt
,
pl
);
}
}
/**
/**
...
...
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