Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
4911674e
Commit
4911674e
authored
Nov 25, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改抽奖逻辑
parent
1e1d4dc8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
15 deletions
+78
-15
LotteryRecordsLog.java
.../src/main/java/share/system/domain/LotteryRecordsLog.java
+3
-0
PrizeMapper.java
...system/src/main/java/share/system/mapper/PrizeMapper.java
+2
-0
PrizeService.java
...stem/src/main/java/share/system/service/PrizeService.java
+2
-0
WheelGameService.java
.../src/main/java/share/system/service/WheelGameService.java
+2
-1
ConsumerWalletServiceImpl.java
.../share/system/service/impl/ConsumerWalletServiceImpl.java
+18
-0
PrizeServiceImpl.java
...main/java/share/system/service/impl/PrizeServiceImpl.java
+5
-0
WheelGameServiceImpl.java
.../java/share/system/service/impl/WheelGameServiceImpl.java
+41
-14
PrizeMapper.xml
...e-system/src/main/resources/mapper/system/PrizeMapper.xml
+5
-0
No files found.
share-system/src/main/java/share/system/domain/LotteryRecordsLog.java
View file @
4911674e
package
share
.
system
.
domain
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
...
...
@@ -24,6 +26,7 @@ public class LotteryRecordsLog extends BaseEntity {
/**
* 主键
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
...
...
share-system/src/main/java/share/system/mapper/PrizeMapper.java
View file @
4911674e
...
...
@@ -60,4 +60,6 @@ public interface PrizeMapper extends BaseMapper<Prize> {
* @return 结果
*/
public
int
deletePrizeByIds
(
Long
[]
ids
);
void
updateCurrentNum
(
Prize
prize
);
}
share-system/src/main/java/share/system/service/PrizeService.java
View file @
4911674e
...
...
@@ -60,4 +60,6 @@ public interface PrizeService extends IService<Prize> {
* @return 结果
*/
public
int
deletePrizeById
(
Long
id
);
void
updateCurrentNum
(
Prize
prize
);
}
share-system/src/main/java/share/system/service/WheelGameService.java
View file @
4911674e
package
share
.
system
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
share.system.domain.Prize
;
import
share.system.domain.WheelGame
;
import
java.util.List
;
...
...
@@ -60,5 +61,5 @@ public interface WheelGameService extends IService<WheelGame> {
*/
public
int
deleteWheelGameById
(
Long
id
);
String
draw
(
WheelGame
wheelGame
);
Prize
draw
(
WheelGame
wheelGame
);
}
share-system/src/main/java/share/system/service/impl/ConsumerWalletServiceImpl.java
View file @
4911674e
...
...
@@ -596,9 +596,18 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
giftAmountLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
giftAmountLog
.
setOperationTime
(
new
Date
());
giftAmountLog
.
setCreateTime
(
new
Date
());
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
oldConsumerWallet
.
getBalance
());
balanceLog
.
setVariableAmount
(
consumerWallet
.
getGiftAmount
());
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setCreateTime
(
new
Date
());
oldConsumerWallet
.
setGiftAmount
(
oldConsumerWallet
.
getGiftAmount
().
add
(
consumerWallet
.
getGiftAmount
()));
oldConsumerWallet
.
setBalance
(
oldConsumerWallet
.
getRechargeAmount
().
add
(
oldConsumerWallet
.
getGiftAmount
()));
giftAmountLogService
.
save
(
giftAmountLog
);
balanceLogService
.
save
(
balanceLog
);
consumerWalletService
.
updateById
(
oldConsumerWallet
);
return
1
;
}
else
{
...
...
@@ -615,6 +624,14 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
giftAmountLog
.
setOperationTime
(
new
Date
());
giftAmountLog
.
setCreateTime
(
new
Date
());
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
BigDecimal
.
ZERO
);
balanceLog
.
setVariableAmount
(
consumerWallet
.
getGiftAmount
());
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setCreateTime
(
new
Date
());
newConsumerWallet
.
setBalance
(
consumerWallet
.
getGiftAmount
());
newConsumerWallet
.
setGiftAmount
(
consumerWallet
.
getGiftAmount
());
newConsumerWallet
.
setRemainingDuration
(
BigDecimal
.
ZERO
);
...
...
@@ -634,6 +651,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
newConsumerMember
.
setCreateTime
(
new
Date
());
consumerWalletService
.
save
(
newConsumerWallet
);
giftAmountLogService
.
save
(
giftAmountLog
);
balanceLogService
.
save
(
balanceLog
);
consumerMemberService
.
save
(
newConsumerMember
);
return
1
;
}
...
...
share-system/src/main/java/share/system/service/impl/PrizeServiceImpl.java
View file @
4911674e
...
...
@@ -89,4 +89,9 @@ public class PrizeServiceImpl extends ServiceImpl<PrizeMapper, Prize> implements
public
int
deletePrizeById
(
Long
id
)
{
return
prizeMapper
.
deletePrizeById
(
id
);
}
@Override
public
void
updateCurrentNum
(
Prize
prize
)
{
prizeMapper
.
updateCurrentNum
(
prize
);
}
}
share-system/src/main/java/share/system/service/impl/WheelGameServiceImpl.java
View file @
4911674e
package
share
.
system
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -16,7 +17,6 @@ import share.common.enums.YesNoEnum;
import
share.common.exception.base.BaseException
;
import
share.common.utils.DateUtils
;
import
share.system.domain.*
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.mapper.WheelGameMapper
;
import
share.system.service.*
;
...
...
@@ -24,7 +24,6 @@ import java.math.BigDecimal;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Random
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -48,6 +47,9 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
private
LotteryRecordsLogService
lotteryRecordsLogService
;
@Autowired
private
ConsumerWalletService
consumerWalletService
;
@Autowired
private
SConsumerService
sConsumerService
;
/**
* 查询转盘游戏
...
...
@@ -118,12 +120,12 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
}
@Override
public
String
draw
(
WheelGame
wheelGame
)
{
public
Prize
draw
(
WheelGame
wheelGame
)
{
if
(
wheelGame
==
null
||
wheelGame
.
getId
()
==
null
)
{
throw
new
IllegalArgumentException
(
"无效的游戏对象或游戏ID为空"
);
}
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumer
user
=
sConsumerService
.
getInfo
();
if
(
ObjectUtil
.
isNull
(
user
))
{
throw
new
BaseException
(
"您的登录已过期,请先登录"
);
}
...
...
@@ -156,6 +158,10 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
log
.
setHitPrize
(
prize
.
getPrizeName
()
+
":"
+
give
.
getName
());
log
.
setSendMsg
(
PrizeTypeEnum
.
COUPON
.
getName
()
+
":"
+
give
.
getName
()
+
"以发放"
);
lotteryRecordsLogService
.
save
(
log
);
prize
.
setCurrentNum
(
prize
.
getCurrentNum
()
+
YesNoEnum
.
yes
.
getIndex
());
prizeService
.
updateCurrentNum
(
prize
);
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
break
;
case
GOODS:
log
.
setIsHit
(
YesNoEnum
.
yes
.
getIndex
());
...
...
@@ -163,6 +169,10 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
log
.
setHitPrize
(
PrizeTypeEnum
.
GOODS
.
getName
()
+
":"
+
prize
.
getPrizeName
());
log
.
setSendMsg
(
PrizeTypeEnum
.
GOODS
.
getName
()
+
":"
+
prize
.
getPrizeName
()
+
"以发放"
);
lotteryRecordsLogService
.
save
(
log
);
prize
.
setCurrentNum
(
prize
.
getCurrentNum
()
+
YesNoEnum
.
yes
.
getIndex
());
prizeService
.
updateCurrentNum
(
prize
);
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
break
;
case
INTEGRAL:
ConsumerWallet
consumerWallet
=
new
ConsumerWallet
();
...
...
@@ -172,8 +182,12 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
log
.
setIsHit
(
YesNoEnum
.
yes
.
getIndex
());
log
.
setIsSend
(
YesNoEnum
.
yes
.
getIndex
());
log
.
setHitPrize
(
PrizeTypeEnum
.
INTEGRAL
.
getName
());
log
.
setSendMsg
(
prize
.
getPrizeValue
()
+
":"
+
PrizeTypeEnum
.
INTEGRAL
.
getNam
e
()
+
"以发放"
);
log
.
setSendMsg
(
PrizeTypeEnum
.
INTEGRAL
.
getName
()
+
":"
+
prize
.
getPrizeValu
e
()
+
"以发放"
);
lotteryRecordsLogService
.
save
(
log
);
prize
.
setCurrentNum
(
prize
.
getCurrentNum
()
+
YesNoEnum
.
yes
.
getIndex
());
prizeService
.
updateCurrentNum
(
prize
);
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
break
;
case
TIME:
ConsumerWallet
durationrWallet
=
new
ConsumerWallet
();
...
...
@@ -183,8 +197,12 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
log
.
setIsHit
(
YesNoEnum
.
yes
.
getIndex
());
log
.
setIsSend
(
YesNoEnum
.
yes
.
getIndex
());
log
.
setHitPrize
(
PrizeTypeEnum
.
TIME
.
getName
());
log
.
setSendMsg
(
prize
.
getPrizeValue
()
+
":"
+
PrizeTypeEnum
.
TIME
.
getNam
e
()
+
"以发放"
);
log
.
setSendMsg
(
PrizeTypeEnum
.
TIME
.
getName
()
+
":"
+
prize
.
getPrizeValu
e
()
+
"以发放"
);
lotteryRecordsLogService
.
save
(
log
);
prize
.
setCurrentNum
(
prize
.
getCurrentNum
()
+
YesNoEnum
.
yes
.
getIndex
());
prizeService
.
updateCurrentNum
(
prize
);
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
break
;
case
MONEY:
ConsumerWallet
giveAmountWallet
=
new
ConsumerWallet
();
...
...
@@ -194,8 +212,12 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
log
.
setIsHit
(
YesNoEnum
.
yes
.
getIndex
());
log
.
setIsSend
(
YesNoEnum
.
yes
.
getIndex
());
log
.
setHitPrize
(
PrizeTypeEnum
.
MONEY
.
getName
());
log
.
setSendMsg
(
prize
.
getPrizeValue
()
+
":"
+
PrizeTypeEnum
.
MONEY
.
getNam
e
()
+
"以发放"
);
log
.
setSendMsg
(
PrizeTypeEnum
.
MONEY
.
getName
()
+
":"
+
prize
.
getPrizeValu
e
()
+
"以发放"
);
lotteryRecordsLogService
.
save
(
log
);
prize
.
setCurrentNum
(
prize
.
getCurrentNum
()
+
YesNoEnum
.
yes
.
getIndex
());
prizeService
.
updateCurrentNum
(
prize
);
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
break
;
case
THANK:
log
.
setIsHit
(
YesNoEnum
.
no
.
getIndex
());
...
...
@@ -203,6 +225,10 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
log
.
setHitPrize
(
"谢谢参与"
);
log
.
setSendMsg
(
"谢谢参与"
);
lotteryRecordsLogService
.
save
(
log
);
prize
.
setCurrentNum
(
prize
.
getCurrentNum
()
+
YesNoEnum
.
yes
.
getIndex
());
prizeService
.
updateCurrentNum
(
prize
);
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
break
;
default
:
throw
new
BaseException
(
"奖品类型异常"
);
...
...
@@ -215,14 +241,16 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
throw
new
RuntimeException
(
e
);
}
}
else
{
user
.
setPrizeDrawNumbr
(
user
.
getPrizeDrawNumbr
()
-
YesNoEnum
.
yes
.
getIndex
());
sConsumerService
.
updateById
(
user
);
log
.
setIsHit
(
YesNoEnum
.
no
.
getIndex
());
log
.
setIsSend
(
YesNoEnum
.
no
.
getIndex
());
log
.
setHitPrize
(
"谢谢参与"
);
log
.
setSendMsg
(
"谢谢参与"
);
lotteryRecordsLogService
.
save
(
log
);
return
"谢谢参与"
;
return
new
Prize
()
;
}
return
null
;
return
prize
;
}
private
Prize
luckDraw
(
List
<
Prize
>
prizeList
,
Long
gameId
)
{
...
...
@@ -242,10 +270,9 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
newList
.
add
(
newEntity
);
}
// 生成一个随机数
Random
random
=
new
Random
();
Double
userSelect
=
random
.
nextDouble
()
*
10000
;
for
(
Prize
prize
:
prizeList
)
{
// 生成一个0到sum随机数
double
userSelect
=
RandomUtil
.
randomDouble
(
0
,
sum
);
for
(
Prize
prize
:
newList
)
{
// 随机数小于中奖几率,则中奖
if
(
userSelect
<
prize
.
getRatio
())
{
// 最大中奖数(0:代表不限制次数)
...
...
@@ -260,7 +287,7 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
}
}
// 谢谢参与
List
<
Prize
>
prize
=
prizeList
.
stream
().
filter
(
item
->
item
.
getPrizeType
()
==
4
).
collect
(
Collectors
.
toList
());
List
<
Prize
>
prize
=
prizeList
.
stream
().
filter
(
item
->
item
.
getPrizeType
()
==
PrizeTypeEnum
.
THANK
.
getCode
()
).
collect
(
Collectors
.
toList
());
if
(
prize
.
size
()
>
0
)
{
return
prize
.
get
(
0
);
}
...
...
share-system/src/main/resources/mapper/system/PrizeMapper.xml
View file @
4911674e
...
...
@@ -130,6 +130,11 @@
</trim>
where id = #{id}
</update>
<update
id=
"updateCurrentNum"
>
update s_prize
set current_num = #{currentNum}
where id = #{id}
</update>
<delete
id=
"deletePrizeById"
parameterType=
"Long"
>
delete
...
...
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