Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
xunj
/
festival-activites
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7e121f3f
authored
Feb 02, 2021
by
xunj
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化
1 parent
cf96304f
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
613 additions
and
47 deletions
activity-admin/src/main/java/com/polysoft/activity/mapper/ActivityMapper.java
activity-admin/src/main/java/com/polysoft/activity/model/param/ShareLinkParam.java
activity-admin/src/main/java/com/polysoft/activity/model/vo/GrapRedPackResultVO.java
activity-admin/src/main/java/com/polysoft/activity/model/vo/RedAmountConfVO.java
activity-admin/src/main/java/com/polysoft/activity/service/impl/CattleBrandServiceImpl.java
activity-admin/src/main/java/com/polysoft/activity/service/impl/UserInfoServiceImpl.java
activity-admin/src/main/java/com/polysoft/activity/task/CattleBrandCarveUpTask.java
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask1.java
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask.java → activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask2.java
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask3.java
activity-admin/src/main/java/com/polysoft/activity/task/UserSignTask.java
activity-admin/src/main/java/com/polysoft/activity/task/WishLuckDrawTask.java
activity-admin/src/main/resources/mapper/ActivityMapper.xml
activity-common/src/main/java/com/polysoft/activity/utils/ApiResult.java
activity-admin/src/main/java/com/polysoft/activity/mapper/ActivityMapper.java
View file @
7e121f3
...
@@ -8,6 +8,7 @@ import com.polysoft.activity.model.dto.GrapRedPackResultDto;
...
@@ -8,6 +8,7 @@ import com.polysoft.activity.model.dto.GrapRedPackResultDto;
import
com.polysoft.activity.model.dto.QueryRedRainDto
;
import
com.polysoft.activity.model.dto.QueryRedRainDto
;
import
com.polysoft.activity.model.vo.ActItemVO
;
import
com.polysoft.activity.model.vo.ActItemVO
;
import
com.polysoft.activity.model.vo.GrapRedPackResultVO
;
import
com.polysoft.activity.model.vo.GrapRedPackResultVO
;
import
com.polysoft.activity.model.vo.RedAmountConfVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedPackInfoVO
;
import
com.polysoft.activity.model.vo.RedPackInfoVO
;
import
com.polysoft.activity.model.vo.RedRainVO
;
import
com.polysoft.activity.model.vo.RedRainVO
;
...
@@ -41,5 +42,7 @@ public interface ActivityMapper extends BaseMapper<ActItemDto> {
...
@@ -41,5 +42,7 @@ public interface ActivityMapper extends BaseMapper<ActItemDto> {
List
<
SmashBasinVO
>
getGrapRedPackMoney
();
List
<
SmashBasinVO
>
getGrapRedPackMoney
();
GrapRedPackResultVO
getGrapRedPackResult
(
GrapRedPackResultDto
dto
);
GrapRedPackResultVO
getGrapRedPackResult
(
GrapRedPackResultDto
dto
);
List
<
GrapRedPackResultVO
>
getGrapRedRainRank
(
GrapRedPackResultDto
dto
);
List
<
GrapRedPackResultVO
>
getGrapRedRainRank
(
GrapRedPackResultDto
dto
);
RedAmountConfVO
getRedAmountConf
(
@Param
(
"redSource"
)
String
redSource
,
@Param
(
"batchNum"
)
Long
batchNum
);
List
<
Long
>
getRedIdToCattle
();
}
}
activity-admin/src/main/java/com/polysoft/activity/model/param/ShareLinkParam.java
View file @
7e121f3
...
@@ -18,4 +18,6 @@ public class ShareLinkParam {
...
@@ -18,4 +18,6 @@ public class ShareLinkParam {
@ApiModelProperty
(
"牛牌ID"
)
@ApiModelProperty
(
"牛牌ID"
)
private
Long
cattleId
;
private
Long
cattleId
;
private
String
cardType
;
private
String
cardType
;
//链接上的牛牌Id
private
Long
cattleBrandId
;
}
}
activity-admin/src/main/java/com/polysoft/activity/model/vo/GrapRedPackResultVO.java
View file @
7e121f3
...
@@ -13,4 +13,5 @@ public class GrapRedPackResultVO {
...
@@ -13,4 +13,5 @@ public class GrapRedPackResultVO {
private
int
redNum
;
private
int
redNum
;
private
int
cattleNum
;
private
int
cattleNum
;
private
BigDecimal
totalMoney
;
private
BigDecimal
totalMoney
;
private
String
userName
;
}
}
activity-admin/src/main/java/com/polysoft/activity/model/vo/RedAmountConfVO.java
0 → 100644
View file @
7e121f3
package
com
.
polysoft
.
activity
.
model
.
vo
;
import
lombok.Data
;
/**
* @author lvyp
* @date 2021/2/2
*/
@Data
public
class
RedAmountConfVO
{
private
Long
id
;
private
double
totalMoney
;
private
double
redMaxAmonut
;
private
double
redMinAmount
;
private
String
redSource
;
}
activity-admin/src/main/java/com/polysoft/activity/service/impl/CattleBrandServiceImpl.java
View file @
7e121f3
package
com
.
polysoft
.
activity
.
service
.
impl
;
package
com
.
polysoft
.
activity
.
service
.
impl
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.CattleBrandMapper
;
import
com.polysoft.activity.mapper.CattleBrandMapper
;
...
@@ -83,6 +84,7 @@ public class CattleBrandServiceImpl implements CattleBrandService {
...
@@ -83,6 +84,7 @@ public class CattleBrandServiceImpl implements CattleBrandService {
@Override
@Override
public
ApiResult
saveComposeCattleBrand
(
ComposeCattleBrandParam
param
)
{
public
ApiResult
saveComposeCattleBrand
(
ComposeCattleBrandParam
param
)
{
JSONObject
object
=
new
JSONObject
();
try
{
try
{
List
<
UserCattleVO
>
list
=
cattleBrandMapper
.
getComposeCattleBrand
(
param
.
getUserId
());
List
<
UserCattleVO
>
list
=
cattleBrandMapper
.
getComposeCattleBrand
(
param
.
getUserId
());
if
(
list
!=
null
&&
list
.
size
()
==
5
){
if
(
list
!=
null
&&
list
.
size
()
==
5
){
...
@@ -98,9 +100,11 @@ public class CattleBrandServiceImpl implements CattleBrandService {
...
@@ -98,9 +100,11 @@ public class CattleBrandServiceImpl implements CattleBrandService {
rainDto
.
setIsEnble
(
"0"
);
rainDto
.
setIsEnble
(
"0"
);
rainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE4
.
getCode
());
rainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE4
.
getCode
());
activityMapper
.
saveRedRainForOne
(
rainDto
);
activityMapper
.
saveRedRainForOne
(
rainDto
);
return
ApiResult
.
ok
(
"恭喜合成牛牌"
);
object
.
put
(
"isCompose"
,
true
);
return
ApiResult
.
ok
(
"200"
,
"恭喜合成牛牌"
,
object
);
}
else
{
}
else
{
return
ApiResult
.
ok
(
"请继续收集牛牌"
);
object
.
put
(
"isCompose"
,
false
);
return
ApiResult
.
ok
(
"200"
,
"请继续收集牛牌"
,
object
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
activity-admin/src/main/java/com/polysoft/activity/service/impl/UserInfoServiceImpl.java
View file @
7e121f3
...
@@ -126,7 +126,7 @@ public class UserInfoServiceImpl implements UserInfoService {
...
@@ -126,7 +126,7 @@ public class UserInfoServiceImpl implements UserInfoService {
try
{
try
{
//查询牛牌是否存
//查询牛牌是否存
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
UserCattleVO
cattleVO
=
cattleBrandMapper
.
getUserCattleVOById
(
param
.
getCattleId
());
UserCattleVO
cattleVO
=
cattleBrandMapper
.
getUserCattleVOById
(
param
.
getCattle
Brand
Id
());
if
(
cattleVO
==
null
){
if
(
cattleVO
==
null
){
object
.
put
(
"cardType"
,
param
.
getCardType
());
object
.
put
(
"cardType"
,
param
.
getCardType
());
object
.
put
(
"isReceived"
,
false
);
object
.
put
(
"isReceived"
,
false
);
...
...
activity-admin/src/main/java/com/polysoft/activity/task/CattleBrandCarveUpTask.java
View file @
7e121f3
package
com
.
polysoft
.
activity
.
task
;
package
com
.
polysoft
.
activity
.
task
;
import
com.polysoft.activity.common.log.LoggerHelper
;
import
com.polysoft.activity.common.log.LoggerHelper
;
import
com.polysoft.activity.common.utils.BeanTransferUtils
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.UserInfoMapper
;
import
com.polysoft.activity.mapper.UserInfoMapper
;
import
com.polysoft.activity.model.dto.AddRedRainDto
;
import
com.polysoft.activity.model.dto.CalculateAmoutDto
;
import
com.polysoft.activity.model.dto.CalculateAmoutDto
;
import
com.polysoft.activity.model.vo.RedAmountConfVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.utils.RedPacketUtil
;
import
com.polysoft.activity.utils.RedPacketUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Set
;
/**
/**
* @author lvyp
* @author lvyp
...
@@ -20,12 +29,13 @@ import java.util.List;
...
@@ -20,12 +29,13 @@ import java.util.List;
*/
*/
@Component
@Component
@EnableScheduling
@EnableScheduling
@Slf4j
public
class
CattleBrandCarveUpTask
{
public
class
CattleBrandCarveUpTask
{
@Resource
@Resource
private
ActivityMapper
activityMapper
;
private
ActivityMapper
activityMapper
;
@Scheduled
(
cron
=
"0 21 20 * * ? "
)
@Scheduled
(
cron
=
"0 21 20 * * ? "
)
// @Scheduled( cron = "0 1 0 18 2 ? ") 2021年2月18号
凌晨零点1分
执行
// @Scheduled( cron = "0 1 0 18 2 ? ") 2021年2月18号
0时1分0秒
执行
public
void
execute
()
{
public
void
execute
()
{
try
{
try
{
sendWechat
();
sendWechat
();
...
@@ -35,13 +45,120 @@ public class CattleBrandCarveUpTask {
...
@@ -35,13 +45,120 @@ public class CattleBrandCarveUpTask {
}
}
private
static
final
double
totalMoney
=
20000.00
;
private
static
final
double
totalMoney
=
20000.00
;
private
void
sendWechat
()
{
private
void
sendWechat
()
{
log
.
info
(
"牛牌瓜分红包任务开始"
);
//查询已经合成牛牌的红包
//查询已经合成牛牌的红包
CalculateAmoutDto
calculateAmoutDto
=
new
CalculateAmoutDto
();
List
<
Long
>
list
=
activityMapper
.
getRedIdToCattle
();
calculateAmoutDto
.
setIsEnble
(
"0"
);
//第一批 牛牌瓜分
calculateAmoutDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE4
.
getCode
());
//生成数量
List
<
RedAmountTotalVO
>
list
=
activityMapper
.
getCattleCarveUp
(
calculateAmoutDto
);
int
count_1
=
(
int
)
(
list
.
size
()*
0.05
);
//生成范围
int
random_1
=
list
.
size
();
HashSet
<
Integer
>
set_1
=
getLuckUser
(
count_1
,
random_1
);
//第一批瓜分
RedPacketUtil
redpack
=
new
RedPacketUtil
();
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
,
list
.
size
(),
0.01
,
100
,
2.1
);
//查询第一批红包配置
RedAmountConfVO
confVO_1
=
activityMapper
.
getRedAmountConf
(
"4"
,
1L
);
List
<
Double
>
redAmount_1
=
redpack
.
getMoney
(
confVO_1
.
getTotalMoney
(),
count_1
,
confVO_1
.
getRedMinAmount
(),
confVO_1
.
getRedMaxAmonut
(),
2.1
);
List
<
AddRedRainDto
>
batchList_1
=
new
ArrayList
<>();
int
bt_1
=
0
;
for
(
Integer
s:
set_1
)
{
AddRedRainDto
addRedRainDto
=
new
AddRedRainDto
();
addRedRainDto
.
setRedId
(
list
.
get
(
s
));
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount_1
.
get
(
bt_1
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"0"
);
batchList_1
.
add
(
addRedRainDto
);
bt_1
++;
}
activityMapper
.
updateRedPackage
(
batchList_1
);
//第二批 牛牌瓜分
//生成数量
int
count_2
=
(
int
)
(
list
.
size
()*
0.15
);
//生成范围
int
random_2
=
list
.
size
();
HashSet
<
Integer
>
set_2
=
getLuckUser
(
count_2
,
random_2
);
//第一批瓜分
//查询第二批红包配置
RedAmountConfVO
confVO_2
=
activityMapper
.
getRedAmountConf
(
"4"
,
2L
);
List
<
Double
>
redAmount_2
=
redpack
.
getMoney
(
confVO_2
.
getTotalMoney
(),
count_2
,
confVO_2
.
getRedMinAmount
(),
confVO_2
.
getRedMaxAmonut
(),
2.1
);
List
<
AddRedRainDto
>
batchList_2
=
new
ArrayList
<>();
int
bt_2
=
0
;
for
(
Integer
s:
set_2
)
{
AddRedRainDto
addRedRainDto
=
new
AddRedRainDto
();
addRedRainDto
.
setRedId
(
list
.
get
(
s
));
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount_2
.
get
(
bt_2
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"0"
);
batchList_2
.
add
(
addRedRainDto
);
bt_2
++;
}
activityMapper
.
updateRedPackage
(
batchList_2
);
//第三批 牛牌瓜分
//生成数量
int
count_3
=
(
int
)
(
list
.
size
()*
0.40
);
//生成范围
int
random_3
=
list
.
size
();
HashSet
<
Integer
>
set_3
=
getLuckUser
(
count_3
,
random_3
);
//查询第三批红包配置
RedAmountConfVO
confVO_3
=
activityMapper
.
getRedAmountConf
(
"4"
,
3L
);
List
<
Double
>
redAmount_3
=
redpack
.
getMoney
(
confVO_3
.
getTotalMoney
(),
count_3
,
confVO_3
.
getRedMinAmount
(),
confVO_3
.
getRedMaxAmonut
(),
2.1
);
List
<
AddRedRainDto
>
batchList_3
=
new
ArrayList
<>();
int
bt_3
=
0
;
for
(
Integer
s:
set_3
)
{
AddRedRainDto
addRedRainDto
=
new
AddRedRainDto
();
addRedRainDto
.
setRedId
(
list
.
get
(
s
));
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount_3
.
get
(
bt_3
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"0"
);
batchList_3
.
add
(
addRedRainDto
);
bt_3
++;
}
activityMapper
.
updateRedPackage
(
batchList_3
);
//第四批 牛牌瓜分
//生成数量
int
count_4
=
(
int
)
(
list
.
size
()*
0.25
);
//生成范围
int
random_4
=
list
.
size
();
HashSet
<
Integer
>
set_4
=
getLuckUser
(
count_4
,
random_4
);
//查询第四批红包配置
RedAmountConfVO
confVO_4
=
activityMapper
.
getRedAmountConf
(
"4"
,
4L
);
List
<
Double
>
redAmount_4
=
redpack
.
getMoney
(
confVO_4
.
getTotalMoney
(),
count_4
,
confVO_4
.
getRedMinAmount
(),
confVO_4
.
getRedMaxAmonut
(),
2.1
);
List
<
AddRedRainDto
>
batchList_4
=
new
ArrayList
<>();
int
bt_4
=
0
;
for
(
Integer
s:
set_4
)
{
AddRedRainDto
addRedRainDto
=
new
AddRedRainDto
();
addRedRainDto
.
setRedId
(
list
.
get
(
s
));
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount_4
.
get
(
bt_4
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"0"
);
batchList_4
.
add
(
addRedRainDto
);
bt_4
++;
}
activityMapper
.
updateRedPackage
(
batchList_4
);
log
.
info
(
"牛牌瓜分红包任务结束"
);
}
/**
*
* @param count 生成的数量
* @param random 数值范围
* @return
*/
private
HashSet
<
Integer
>
getLuckUser
(
int
count
,
int
random
){
HashSet
<
Integer
>
has
=
new
HashSet
<
Integer
>();
Integer
i
=
0
;
for
(
int
j
=
1
;
j
!=
0
;
j
++)
{
i
=
new
Random
().
nextInt
(
random
);
has
.
add
(
i
);
if
(
count
==
has
.
size
())
{
break
;
}
}
return
has
;
}
public
static
void
main
(
String
[]
args
)
{
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
2500
,
15
,
50
,
300
,
2.1
);
redAmount
.
forEach
(
a
->
System
.
out
.
println
(
a
));
}
}
}
}
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask1.java
0 → 100644
View file @
7e121f3
package
com
.
polysoft
.
activity
.
task
;
import
com.polysoft.activity.common.log.LoggerHelper
;
import
com.polysoft.activity.common.utils.BeanTransferUtils
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.UserInfoMapper
;
import
com.polysoft.activity.model.dto.*
;
import
com.polysoft.activity.model.vo.CattleBrandVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedRainVO
;
import
com.polysoft.activity.service.CattleBrandService
;
import
com.polysoft.activity.utils.RedPacketUtil
;
import
com.polysoft.activity.utils.SnowFlakeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Random
;
/**
* @author lvyp
* @date 2021/1/21
*/
@Component
@EnableScheduling
@Slf4j
public
class
InitRedPackageTask1
{
@Resource
private
ActivityMapper
activityMapper
;
@Resource
private
CattleBrandService
cattleBrandService
;
@Resource
private
UserInfoMapper
userInfoMapper
;
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "20 17 21 * * ? ")
@Scheduled
(
cron
=
"0,32 0 20 11 2 ? "
)
// 2月11日 20点0分32秒执行
public
void
execute
()
{
sendWechat
();
}
private
void
sendWechat
(){
log
.
info
(
"第一批红包雨任务开始"
);
//查询出没有初始化的红包
final
int
batchNum
=
1
;
final
double
totalMoney
=
5000.00
;
if
(
1
==
1
){
QueryRedRainDto
dto1
=
new
QueryRedRainDto
();
List
<
AddRedRainDto
>
batchList
=
new
ArrayList
<>();
dto1
.
setIsEnble
(
"0"
);
dto1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto1
);
//前10%红包
int
redNum
=
(
int
)(
list
.
size
()*
0.1
);
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
*
0.25
,
redNum
,
0.01
,
100
,
2.1
);
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list
.
size
());
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list
.
get
(
s
),
AddRedRainDto
.
class
);
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount
.
get
(
i
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackage
(
batchList
);
}
//20%红包
if
(
2
==
2
){
//获取红包总数
QueryRedRainDto
dto2
=
new
QueryRedRainDto
();
dto2
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto2
);
List
<
AddRedRainDto
>
batchList2
=
new
ArrayList
<>();
//获取未结算的红包数
QueryRedRainDto
dto2_1
=
new
QueryRedRainDto
();
dto2_1
.
setIsEnble
(
"0"
);
dto2_1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list2
=
activityMapper
.
queryRedRainList
(
dto2_1
);
//前20%红包
int
redNum
=
(
int
)(
list
.
size
()*
0.2
);
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
*
0.25
,
redNum
,
0.01
,
100
,
2.1
);
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list2
.
size
());
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list2
.
get
(
s
),
AddRedRainDto
.
class
);
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount
.
get
(
i
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList2
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackage
(
batchList2
);
}
if
(
3
==
3
){
//获取红包总数
QueryRedRainDto
dto3
=
new
QueryRedRainDto
();
dto3
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto3
);
List
<
AddRedRainDto
>
batchList2
=
new
ArrayList
<>();
//获取未结算的红包数
QueryRedRainDto
dto3_1
=
new
QueryRedRainDto
();
dto3_1
.
setIsEnble
(
"0"
);
dto3_1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list2
=
activityMapper
.
queryRedRainList
(
dto3_1
);
//前65%红包
int
redNum
=
(
int
)(
list
.
size
()*
0.65
);
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
*
0.5
,
redNum
,
0.01
,
100
,
2.1
);
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list2
.
size
());
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list2
.
get
(
s
),
AddRedRainDto
.
class
);
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount
.
get
(
i
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList2
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackage
(
batchList2
);
}
if
(
4
==
4
){
//获取红包总数
QueryRedRainDto
dto4
=
new
QueryRedRainDto
();
dto4
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto4
);
List
<
AddRedRainDto
>
batchList2
=
new
ArrayList
<>();
//获取未结算的红包数
QueryRedRainDto
dto4_1
=
new
QueryRedRainDto
();
dto4_1
.
setIsEnble
(
"0"
);
dto4_1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list2
=
activityMapper
.
queryRedRainList
(
dto4_1
);
//前5%红包牛牌
int
redNum
=
list2
.
size
();
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list2
.
size
());
List
<
CattleBrandVO
>
cattleList
=
(
List
<
CattleBrandVO
>)
cattleBrandService
.
queryCattleBrandList
(
null
).
get
(
"data"
);
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list2
.
get
(
s
),
AddRedRainDto
.
class
);
int
k
=
new
Random
().
nextInt
(
5
);
addRedRainDto
.
setCattleBrandId
(
cattleList
.
get
(
k
).
getCattleId
());
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE2
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList2
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackageForCattle
(
batchList2
);
}
//更新聚宝盆
CalculateAmoutDto
calculateAmoutDto
=
new
CalculateAmoutDto
();
calculateAmoutDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
calculateAmoutDto
.
setBatchNum
(
batchNum
);
calculateAmoutDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
List
<
RedAmountTotalVO
>
lastList
=
activityMapper
.
calculateRedAmountTatol
(
calculateAmoutDto
);
List
<
UserInfoDto
>
userInfoDtoList
=
new
ArrayList
<>();
lastList
.
forEach
(
item
->{
UserInfoDto
dto
=
new
UserInfoDto
();
dto
.
setUserId
(
item
.
getUserId
());
dto
.
setRedBalance
(
item
.
getRedAmountTatol
());
userInfoDtoList
.
add
(
dto
);
});
userInfoMapper
.
updateRedBalace
(
userInfoDtoList
);
//更新户牛牌
CalculateAmoutDto
calculateAmoutDto2
=
new
CalculateAmoutDto
();
calculateAmoutDto2
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE2
.
getCode
());
calculateAmoutDto2
.
setBatchNum
(
batchNum
);
calculateAmoutDto2
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
List
<
RedAmountTotalVO
>
lastList2
=
activityMapper
.
calculateCattleBrand
(
calculateAmoutDto2
);
List
<
SaveUserCattleDto
>
saveUserCattleDtos
=
new
ArrayList
<>();
lastList2
.
forEach
(
item
->{
SaveUserCattleDto
dto
=
new
SaveUserCattleDto
();
dto
.
setId
(
SnowFlakeUtil
.
nextId
());
dto
.
setUserId
(
item
.
getUserId
());
dto
.
setCattleBrandId
(
item
.
getCattleBrandId
());
saveUserCattleDtos
.
add
(
dto
);
});
userInfoMapper
.
saveCattleBrand
(
saveUserCattleDtos
);
log
.
info
(
"第一批红包雨任务结束"
);
}
private
HashSet
<
Integer
>
getLuckUser
(
int
count
,
int
random
){
HashSet
<
Integer
>
has
=
new
HashSet
<
Integer
>();
Integer
i
=
0
;
for
(
int
j
=
1
;
j
!=
0
;
j
++)
{
i
=
new
Random
().
nextInt
(
random
);
has
.
add
(
i
);
if
(
count
==
has
.
size
())
{
break
;
}
}
return
has
;
}
}
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask.java
→
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask
2
.java
View file @
7e121f3
package
com
.
polysoft
.
activity
.
task
;
package
com
.
polysoft
.
activity
.
task
;
import
com.polysoft.activity.common.log.LoggerHelper
;
import
com.polysoft.activity.common.utils.BeanTransferUtils
;
import
com.polysoft.activity.common.utils.BeanTransferUtils
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.UserInfoMapper
;
import
com.polysoft.activity.mapper.UserInfoMapper
;
import
com.polysoft.activity.model.dto.*
;
import
com.polysoft.activity.model.dto.AddRedRainDto
;
import
com.polysoft.activity.model.dto.CalculateAmoutDto
;
import
com.polysoft.activity.model.dto.QueryRedRainDto
;
import
com.polysoft.activity.model.dto.SaveUserCattleDto
;
import
com.polysoft.activity.model.dto.UserInfoDto
;
import
com.polysoft.activity.model.vo.CattleBrandVO
;
import
com.polysoft.activity.model.vo.CattleBrandVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedRainVO
;
import
com.polysoft.activity.model.vo.RedRainVO
;
import
com.polysoft.activity.service.CattleBrandService
;
import
com.polysoft.activity.service.CattleBrandService
;
import
com.polysoft.activity.utils.RedPacketUtil
;
import
com.polysoft.activity.utils.RedPacketUtil
;
import
com.polysoft.activity.utils.SnowFlakeUtil
;
import
com.polysoft.activity.utils.SnowFlakeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -30,7 +34,8 @@ import java.util.Random;
...
@@ -30,7 +34,8 @@ import java.util.Random;
*/
*/
@Component
@Component
@EnableScheduling
@EnableScheduling
public
class
InitRedPackageTask
{
@Slf4j
public
class
InitRedPackageTask2
{
@Resource
@Resource
private
ActivityMapper
activityMapper
;
private
ActivityMapper
activityMapper
;
...
@@ -40,34 +45,16 @@ public class InitRedPackageTask {
...
@@ -40,34 +45,16 @@ public class InitRedPackageTask {
private
UserInfoMapper
userInfoMapper
;
private
UserInfoMapper
userInfoMapper
;
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
@Scheduled
(
cron
=
"20 17 21 * * ? "
)
// @Scheduled( cron = "20 17 21 * * ? ")
@Scheduled
(
cron
=
"0,32 0 22 11 2 ? "
)
// 2月11日 22点0分32秒执行
public
void
execute
()
{
public
void
execute
()
{
sendWechat
();
sendWechat
();
}
}
private
void
sendWechat
(){
private
void
sendWechat
(){
Long
stime
=
System
.
currentTimeMillis
()/
1000
;
log
.
info
(
"第二批红包雨任务开始"
);
//红包雨开始时间
// Long batch1 = DateUtil.parse("2021-02-11 20:00:00","yyyy-MM-dd HH:mm:ss").getTime()/1000;
// Long batch2 = DateUtil.parse("2021-02-11 22:00:00","yyyy-MM-dd HH:mm:ss").getTime()/1000;
// Long batch3 = DateUtil.parse("2021-02-12 00:00:00","yyyy-MM-dd HH:mm:ss").getTime()/1000;
// Long currentTime = System.currentTimeMillis()/1000;
// int batchNum = 0;
// if(currentTime < batch1){
// return;
// }
// if(currentTime > batch1 && currentTime<batch2){
// batchNum = 1;
// }
// if(currentTime > batch2 && currentTime<batch3){
// batchNum = 2;
// }
// if(currentTime > batch3 ){
// batchNum = 3;
// }
LoggerHelper
.
debug
(
this
.
getClass
(),
"任务开始"
);
//查询出没有初始化的红包
//查询出没有初始化的红包
final
int
batchNum
=
1
;
final
int
batchNum
=
2
;
final
double
totalMoney
=
5000.00
;
final
double
totalMoney
=
5000.00
;
if
(
1
==
1
){
if
(
1
==
1
){
QueryRedRainDto
dto1
=
new
QueryRedRainDto
();
QueryRedRainDto
dto1
=
new
QueryRedRainDto
();
...
@@ -207,9 +194,7 @@ public class InitRedPackageTask {
...
@@ -207,9 +194,7 @@ public class InitRedPackageTask {
saveUserCattleDtos
.
add
(
dto
);
saveUserCattleDtos
.
add
(
dto
);
});
});
userInfoMapper
.
saveCattleBrand
(
saveUserCattleDtos
);
userInfoMapper
.
saveCattleBrand
(
saveUserCattleDtos
);
Long
endTime
=
System
.
currentTimeMillis
()/
1000
;
log
.
info
(
"第二批红包雨任务结束"
);
System
.
out
.
println
(
endTime
-
stime
);
LoggerHelper
.
debug
(
this
.
getClass
(),
"任务结束"
);
}
}
private
HashSet
<
Integer
>
getLuckUser
(
int
count
,
int
random
){
private
HashSet
<
Integer
>
getLuckUser
(
int
count
,
int
random
){
HashSet
<
Integer
>
has
=
new
HashSet
<
Integer
>();
HashSet
<
Integer
>
has
=
new
HashSet
<
Integer
>();
...
@@ -224,9 +209,4 @@ public class InitRedPackageTask {
...
@@ -224,9 +209,4 @@ public class InitRedPackageTask {
return
has
;
return
has
;
}
}
public
static
void
main
(
String
[]
args
)
{
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
4000
,
227
,
5
,
100
,
2.1
);
redAmount
.
forEach
(
item
->
System
.
out
.
println
(
item
));
}
}
}
activity-admin/src/main/java/com/polysoft/activity/task/InitRedPackageTask3.java
0 → 100644
View file @
7e121f3
package
com
.
polysoft
.
activity
.
task
;
import
com.polysoft.activity.common.utils.BeanTransferUtils
;
import
com.polysoft.activity.constant.CommonTypeEnum
;
import
com.polysoft.activity.mapper.ActivityMapper
;
import
com.polysoft.activity.mapper.UserInfoMapper
;
import
com.polysoft.activity.model.dto.AddRedRainDto
;
import
com.polysoft.activity.model.dto.CalculateAmoutDto
;
import
com.polysoft.activity.model.dto.QueryRedRainDto
;
import
com.polysoft.activity.model.dto.SaveUserCattleDto
;
import
com.polysoft.activity.model.dto.UserInfoDto
;
import
com.polysoft.activity.model.vo.CattleBrandVO
;
import
com.polysoft.activity.model.vo.RedAmountTotalVO
;
import
com.polysoft.activity.model.vo.RedRainVO
;
import
com.polysoft.activity.service.CattleBrandService
;
import
com.polysoft.activity.utils.RedPacketUtil
;
import
com.polysoft.activity.utils.SnowFlakeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Random
;
/**
* @author lvyp
* @date 2021/1/21
*/
@Component
@EnableScheduling
@Slf4j
public
class
InitRedPackageTask3
{
@Resource
private
ActivityMapper
activityMapper
;
@Resource
private
CattleBrandService
cattleBrandService
;
@Resource
private
UserInfoMapper
userInfoMapper
;
// @Scheduled(initialDelay = 10000, fixedRate = 1*15*60*1000)
// @Scheduled( cron = "20 17 21 * * ? ")
@Scheduled
(
cron
=
"0,32 0 0 12 2 ? "
)
// 2月12日 0时0点0分32秒执行
public
void
execute
()
{
sendWechat
();
}
private
void
sendWechat
(){
log
.
info
(
"第三批红包雨任务开始"
);
//查询出没有初始化的红包
final
int
batchNum
=
3
;
final
double
totalMoney
=
5000.00
;
if
(
1
==
1
){
QueryRedRainDto
dto1
=
new
QueryRedRainDto
();
List
<
AddRedRainDto
>
batchList
=
new
ArrayList
<>();
dto1
.
setIsEnble
(
"0"
);
dto1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto1
);
//前10%红包
int
redNum
=
(
int
)(
list
.
size
()*
0.1
);
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
*
0.25
,
redNum
,
0.01
,
100
,
2.1
);
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list
.
size
());
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list
.
get
(
s
),
AddRedRainDto
.
class
);
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount
.
get
(
i
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackage
(
batchList
);
}
//20%红包
if
(
2
==
2
){
//获取红包总数
QueryRedRainDto
dto2
=
new
QueryRedRainDto
();
dto2
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto2
);
List
<
AddRedRainDto
>
batchList2
=
new
ArrayList
<>();
//获取未结算的红包数
QueryRedRainDto
dto2_1
=
new
QueryRedRainDto
();
dto2_1
.
setIsEnble
(
"0"
);
dto2_1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list2
=
activityMapper
.
queryRedRainList
(
dto2_1
);
//前20%红包
int
redNum
=
(
int
)(
list
.
size
()*
0.2
);
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
*
0.25
,
redNum
,
0.01
,
100
,
2.1
);
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list2
.
size
());
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list2
.
get
(
s
),
AddRedRainDto
.
class
);
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount
.
get
(
i
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList2
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackage
(
batchList2
);
}
if
(
3
==
3
){
//获取红包总数
QueryRedRainDto
dto3
=
new
QueryRedRainDto
();
dto3
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto3
);
List
<
AddRedRainDto
>
batchList2
=
new
ArrayList
<>();
//获取未结算的红包数
QueryRedRainDto
dto3_1
=
new
QueryRedRainDto
();
dto3_1
.
setIsEnble
(
"0"
);
dto3_1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list2
=
activityMapper
.
queryRedRainList
(
dto3_1
);
//前65%红包
int
redNum
=
(
int
)(
list
.
size
()*
0.65
);
RedPacketUtil
redpack
=
new
RedPacketUtil
();
List
<
Double
>
redAmount
=
redpack
.
getMoney
(
totalMoney
*
0.5
,
redNum
,
0.01
,
100
,
2.1
);
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list2
.
size
());
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list2
.
get
(
s
),
AddRedRainDto
.
class
);
addRedRainDto
.
setRedAmount
(
BigDecimal
.
valueOf
(
redAmount
.
get
(
i
)));
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList2
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackage
(
batchList2
);
}
if
(
4
==
4
){
//获取红包总数
QueryRedRainDto
dto4
=
new
QueryRedRainDto
();
dto4
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list
=
activityMapper
.
queryRedRainList
(
dto4
);
List
<
AddRedRainDto
>
batchList2
=
new
ArrayList
<>();
//获取未结算的红包数
QueryRedRainDto
dto4_1
=
new
QueryRedRainDto
();
dto4_1
.
setIsEnble
(
"0"
);
dto4_1
.
setBatchNum
(
batchNum
);
List
<
RedRainVO
>
list2
=
activityMapper
.
queryRedRainList
(
dto4_1
);
//前5%红包牛牌
int
redNum
=
list2
.
size
();
HashSet
<
Integer
>
set
=
getLuckUser
(
redNum
,
list2
.
size
());
List
<
CattleBrandVO
>
cattleList
=
(
List
<
CattleBrandVO
>)
cattleBrandService
.
queryCattleBrandList
(
null
).
get
(
"data"
);
int
i
=
0
;
for
(
Integer
s
:
set
)
{
AddRedRainDto
addRedRainDto
=
BeanTransferUtils
.
transfer
(
list2
.
get
(
s
),
AddRedRainDto
.
class
);
int
k
=
new
Random
().
nextInt
(
5
);
addRedRainDto
.
setCattleBrandId
(
cattleList
.
get
(
k
).
getCattleId
());
addRedRainDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE2
.
getCode
());
addRedRainDto
.
setIsEnble
(
"1"
);
addRedRainDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
batchList2
.
add
(
addRedRainDto
);
i
++;
}
activityMapper
.
updateRedPackageForCattle
(
batchList2
);
}
//更新聚宝盆
CalculateAmoutDto
calculateAmoutDto
=
new
CalculateAmoutDto
();
calculateAmoutDto
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE1
.
getCode
());
calculateAmoutDto
.
setBatchNum
(
batchNum
);
calculateAmoutDto
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
List
<
RedAmountTotalVO
>
lastList
=
activityMapper
.
calculateRedAmountTatol
(
calculateAmoutDto
);
List
<
UserInfoDto
>
userInfoDtoList
=
new
ArrayList
<>();
lastList
.
forEach
(
item
->{
UserInfoDto
dto
=
new
UserInfoDto
();
dto
.
setUserId
(
item
.
getUserId
());
dto
.
setRedBalance
(
item
.
getRedAmountTatol
());
userInfoDtoList
.
add
(
dto
);
});
userInfoMapper
.
updateRedBalace
(
userInfoDtoList
);
//更新户牛牌
CalculateAmoutDto
calculateAmoutDto2
=
new
CalculateAmoutDto
();
calculateAmoutDto2
.
setRedType
(
CommonTypeEnum
.
REDPACK_TYPE2
.
getCode
());
calculateAmoutDto2
.
setBatchNum
(
batchNum
);
calculateAmoutDto2
.
setSourceType
(
CommonTypeEnum
.
REDPACK_SOURCE_TYPE1
.
getCode
());
List
<
RedAmountTotalVO
>
lastList2
=
activityMapper
.
calculateCattleBrand
(
calculateAmoutDto2
);
List
<
SaveUserCattleDto
>
saveUserCattleDtos
=
new
ArrayList
<>();
lastList2
.
forEach
(
item
->{
SaveUserCattleDto
dto
=
new
SaveUserCattleDto
();
dto
.
setId
(
SnowFlakeUtil
.
nextId
());
dto
.
setUserId
(
item
.
getUserId
());
dto
.
setCattleBrandId
(
item
.
getCattleBrandId
());
saveUserCattleDtos
.
add
(
dto
);
});
userInfoMapper
.
saveCattleBrand
(
saveUserCattleDtos
);
log
.
info
(
"第三批红包雨任务结束"
);
}
private
HashSet
<
Integer
>
getLuckUser
(
int
count
,
int
random
){
HashSet
<
Integer
>
has
=
new
HashSet
<
Integer
>();
Integer
i
=
0
;
for
(
int
j
=
1
;
j
!=
0
;
j
++)
{
i
=
new
Random
().
nextInt
(
random
);
has
.
add
(
i
);
if
(
count
==
has
.
size
())
{
break
;
}
}
return
has
;
}
}
activity-admin/src/main/java/com/polysoft/activity/task/UserSignTask.java
View file @
7e121f3
...
@@ -26,8 +26,11 @@ public class UserSignTask {
...
@@ -26,8 +26,11 @@ public class UserSignTask {
@Resource
@Resource
private
UserInfoMapper
userInfoMapper
;
private
UserInfoMapper
userInfoMapper
;
@Scheduled
(
cron
=
"0 21 20 * * ? "
)
/**
// @Scheduled( cron = "0 55 10 * * ? ")
* 补签任务
*/
// @Scheduled( cron = "0 21 20 * * ? ")
@Scheduled
(
cron
=
"0 1 0 12,13,14,15,16,17,18 2 ? "
)
//2月12,13,14,15,16,17,18 0时1分0秒执行
public
void
execute
()
{
public
void
execute
()
{
try
{
try
{
sendWechat
();
sendWechat
();
...
...
activity-admin/src/main/java/com/polysoft/activity/task/WishLuckDrawTask.java
View file @
7e121f3
...
@@ -31,8 +31,8 @@ public class WishLuckDrawTask {
...
@@ -31,8 +31,8 @@ public class WishLuckDrawTask {
@Resource
@Resource
private
WishRealPrizeMapper
wishRealPrizeMapper
;
private
WishRealPrizeMapper
wishRealPrizeMapper
;
@Scheduled
(
cron
=
"0 21 20 * * ? "
)
//
@Scheduled( cron = "0 21 20 * * ? ")
// @Scheduled( cron = "0 55 10 * * ? ")
@Scheduled
(
cron
=
"0 21 20 11,12,13,14,15,16,17 2 ? "
)
//2月11,12,13,14,15,16,17, 020时21分0秒执行
public
void
execute
()
{
public
void
execute
()
{
try
{
try
{
sendWechat
();
sendWechat
();
...
...
activity-admin/src/main/resources/mapper/ActivityMapper.xml
View file @
7e121f3
...
@@ -227,14 +227,36 @@
...
@@ -227,14 +227,36 @@
<select
id=
"getGrapRedRainRank"
resultType=
"com.polysoft.activity.model.vo.GrapRedPackResultVO"
<select
id=
"getGrapRedRainRank"
resultType=
"com.polysoft.activity.model.vo.GrapRedPackResultVO"
parameterType=
"com.polysoft.activity.model.dto.GrapRedPackResultDto"
>
parameterType=
"com.polysoft.activity.model.dto.GrapRedPackResultDto"
>
SELECT
SELECT
t2.user_name,
count(t.red_type = '1' or null) AS redNum ,
count(t.red_type = '1' or null) AS redNum ,
count(t.red_type = '2' or null) AS cattleNum ,
count(t.red_type = '2' or null) AS cattleNum ,
sum(t.red_amount) AS totalMoney
sum(t.red_amount) AS totalMoney
FROM
FROM
t_red_rain t
t_red_rain t
left join t_user t2 on(t2.user_id = t.user_id)
WHERE
WHERE
t.batch_num = #{batchNum}
t.batch_num = #{batchNum}
AND t.is_enble = #{isEnble}
AND t.is_enble = #{isEnble}
GROUP BY t.user_id order by totalMoney desc
GROUP BY t.user_id order by totalMoney desc
</select>
</select>
<select
id=
"getRedAmountConf"
resultType=
"com.polysoft.activity.model.vo.RedAmountConfVO"
>
select
id,
total_money,
red_max_amonut,
red_min_amount,
red_source,
batch_num
from t_red_amount_conf t where red_source = #{redSource} and batch_num = #{batchNum}
</select>
<select
id=
"getRedIdToCattle"
resultType=
"java.lang.Long"
>
SELECT
red_id
FROM
t_red_rain
WHERE
red_amount = 0.00
AND source_type = '4' and is_enble='0'
</select>
</mapper>
</mapper>
activity-common/src/main/java/com/polysoft/activity/utils/ApiResult.java
View file @
7e121f3
...
@@ -29,7 +29,6 @@ public class ApiResult extends HashMap<String, Object> {
...
@@ -29,7 +29,6 @@ public class ApiResult extends HashMap<String, Object> {
public
static
ApiResult
error
()
{
public
static
ApiResult
error
()
{
return
error
(
500
,
"未知异常,请联系管理员"
);
return
error
(
500
,
"未知异常,请联系管理员"
);
}
}
public
static
ApiResult
error
(
String
msg
)
{
public
static
ApiResult
error
(
String
msg
)
{
return
error
(
500
,
msg
);
return
error
(
500
,
msg
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment