Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
draw
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
draw
draw
Commits
d604c67c
Commit
d604c67c
authored
Oct 09, 2022
by
邓吉芬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
c37d9e37
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
193 deletions
+48
-193
DrawManagerImpl.java
src/main/java/com/miya/draw/manager/DrawManagerImpl.java
+20
-20
ActivityGoodsServiceImpl.java
.../com/miya/draw/service/impl/ActivityGoodsServiceImpl.java
+3
-4
application-dev.yml
src/main/resources/application-dev.yml
+0
-82
application-prod.yml
src/main/resources/application-prod.yml
+0
-87
bootstrap-prod.yml
src/main/resources/bootstrap-prod.yml
+25
-0
No files found.
src/main/java/com/miya/draw/manager/DrawManagerImpl.java
View file @
d604c67c
...
...
@@ -3,7 +3,7 @@ package com.miya.draw.manager;
import
cn.hutool.core.bean.copier.BeanCopier
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.miya.draw.config.business.BusinessConfig
;
import
com.miya.draw.config.business.BusinessConfig
Impl
;
import
com.miya.draw.config.constant.ConStants
;
import
com.miya.draw.config.exception.BusinessException
;
import
com.miya.draw.entity.Account
;
...
...
@@ -43,7 +43,7 @@ public class DrawManagerImpl implements IDrawManager {
private
IAccountService
accountService
;
@Autowired
private
BusinessConfig
businessConfig
;
private
BusinessConfig
Impl
businessConfigImpl
;
@Autowired
private
IAccountPrizeService
accountPrizeService
;
...
...
@@ -80,32 +80,32 @@ public class DrawManagerImpl implements IDrawManager {
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
LocalDateTime
start
=
nowTime
.
minusDays
(
3
);
LocalDateTime
end
=
LocalDateTimeUtil
.
endOfDay
(
nowTime
);
Integer
maxDrawCountLimit
=
businessConfig
.
getDrawMaxCount
();
Integer
alreadyDrawCount
=
accountPrizeService
.
gainAlreadyDrawCount
(
request
.
getPhone
(),
businessConfig
.
getActivityId
(),
start
,
end
);
Integer
maxDrawCountLimit
=
businessConfig
Impl
.
getDrawMaxCount
();
Integer
alreadyDrawCount
=
accountPrizeService
.
gainAlreadyDrawCount
(
request
.
getPhone
(),
businessConfigImpl
.
getActivityId
(),
start
,
end
);
List
<
String
>
storeIdList
=
activityStoreService
.
listAllActivityStoreId
();
List
<
String
>
goodCodeList
=
activityGoodsService
.
listAllActivityGoods
();
List
<
SyncTrade
>
buyGoodList
=
syncTradeService
.
listCanDrawGoods
(
request
.
getPhone
(),
start
,
end
,
storeIdList
,
goodCodeList
);
BigDecimal
buyTotal
=
gainBuyTotal
(
buyGoodList
);
Long
purchasedAmount
=
buyTotal
.
multiply
(
BigDecimal
.
valueOf
(
100
)).
longValue
();
Integer
drawCountTotal
=
0
;
if
(
businessConfig
.
getRaffle
()==
RaffleEnum
.
AMOUNTUNIT
.
getCode
()){
if
(
businessConfig
Impl
.
getRaffle
()==
RaffleEnum
.
AMOUNTUNIT
.
getCode
()){
buyTotal
=
getAmountTotal
(
buyGoodList
);
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
.
getAmountunit
()),
RoundingMode
.
DOWN
).
intValue
();
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
Impl
.
getAmountunit
()),
RoundingMode
.
DOWN
).
intValue
();
//足量抽奖
}
else
{
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
.
getDrawCountUnit
()),
RoundingMode
.
DOWN
).
intValue
();
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
Impl
.
getDrawCountUnit
()),
RoundingMode
.
DOWN
).
intValue
();
}
drawCountTotal
=
Math
.
min
(
businessConfig
.
getDrawMaxCount
(),
drawCountTotal
);
drawCountTotal
=
Math
.
min
(
businessConfig
Impl
.
getDrawMaxCount
(),
drawCountTotal
);
drawCountTotal
=
drawCountTotal
-
alreadyDrawCount
;
Integer
joinActivityPeopleNum
=
accountPrizeService
.
countJoinActivityPeople
(
businessConfig
.
getActivityId
());
Integer
joinActivityPeopleNum
=
accountPrizeService
.
countJoinActivityPeople
(
businessConfig
Impl
.
getActivityId
());
return
DrawModel
.
builder
()
.
alreadyDrawCount
(
alreadyDrawCount
)
.
drawCountTotal
(
drawCountTotal
>=
0
?
drawCountTotal:
0
)
.
maxDrawCountLimit
(
maxDrawCountLimit
)
.
numOfDrawCount
(
Math
.
max
(
0
,
maxDrawCountLimit
-
alreadyDrawCount
))
.
purchasedAmount
(
purchasedAmount
)
.
taxAmountCache
(
Math
.
max
(
0L
,
BigDecimal
.
valueOf
(
businessConfig
.
getDrawMaxMoney
()).
subtract
(
buyTotal
).
multiply
(
BigDecimal
.
valueOf
(
100
)).
longValue
()))
.
taxAmountCache
(
Math
.
max
(
0L
,
BigDecimal
.
valueOf
(
businessConfig
Impl
.
getDrawMaxMoney
()).
subtract
(
buyTotal
).
multiply
(
BigDecimal
.
valueOf
(
100
)).
longValue
()))
.
numOfJoinActivityPeople
(
joinActivityPeopleNum
)
.
build
();
}
...
...
@@ -141,7 +141,7 @@ public class DrawManagerImpl implements IDrawManager {
@Override
public
List
<
DrawModel
>
listMinePrizeList
(
String
phone
)
{
List
<
AccountPrize
>
prizeList
=
accountPrizeService
.
listMinePrize
(
phone
,
businessConfig
.
getActivityId
());
List
<
AccountPrize
>
prizeList
=
accountPrizeService
.
listMinePrize
(
phone
,
businessConfigImpl
.
getActivityId
());
return
getDrawModels
(
prizeList
);
}
...
...
@@ -182,24 +182,24 @@ public class DrawManagerImpl implements IDrawManager {
int
drawCountTotal
=
0
;
//判断抽奖方式
//满额抽奖
if
(
businessConfig
.
getRaffle
()==
RaffleEnum
.
AMOUNTUNIT
.
getCode
()){
if
(
businessConfig
Impl
.
getRaffle
()==
RaffleEnum
.
AMOUNTUNIT
.
getCode
()){
BigDecimal
buyTotal
=
getAmountTotal
(
buyGoodList
);
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
.
getAmountunit
()),
RoundingMode
.
DOWN
).
intValue
();
drawCountTotal
=
Math
.
min
(
businessConfig
.
getDrawMaxCount
(),
drawCountTotal
);
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
Impl
.
getAmountunit
()),
RoundingMode
.
DOWN
).
intValue
();
drawCountTotal
=
Math
.
min
(
businessConfig
Impl
.
getDrawMaxCount
(),
drawCountTotal
);
if
(
drawCountTotal
<=
0
)
{
throw
new
BusinessException
(
ErrorEnum
.
DRAW_CHECK_EXP
,
"抱歉,你的购物金额不足,已无抽奖次数"
);
}
//足量抽奖
}
else
{
BigDecimal
buyTotal
=
gainBuyTotal
(
buyGoodList
);
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
.
getDrawCountUnit
()),
RoundingMode
.
DOWN
).
intValue
();
drawCountTotal
=
Math
.
min
(
businessConfig
.
getDrawMaxCount
(),
drawCountTotal
);
drawCountTotal
=
buyTotal
.
divide
(
new
BigDecimal
(
businessConfig
Impl
.
getDrawCountUnit
()),
RoundingMode
.
DOWN
).
intValue
();
drawCountTotal
=
Math
.
min
(
businessConfig
Impl
.
getDrawMaxCount
(),
drawCountTotal
);
if
(
drawCountTotal
<=
0
)
{
throw
new
BusinessException
(
ErrorEnum
.
DRAW_CHECK_EXP
,
"抱歉,您购买的活动商品不足,已无抽奖次数"
);
}
}
Integer
alreadyDrawCount
=
accountPrizeService
.
gainAlreadyDrawCount
(
phone
,
businessConfig
.
getActivityId
(),
start
,
end
);
Integer
alreadyDrawCount
=
accountPrizeService
.
gainAlreadyDrawCount
(
phone
,
businessConfigImpl
.
getActivityId
(),
start
,
end
);
// 可抽奖次数> 已抽奖次数
Prize
prize
;
AccountPrize
accountPrize
;
...
...
@@ -221,7 +221,7 @@ public class DrawManagerImpl implements IDrawManager {
}
// 记录抽奖信息
accountPrize
=
new
AccountPrize
();
accountPrize
.
setActivityId
(
businessConfig
.
getActivityId
());
accountPrize
.
setActivityId
(
businessConfig
Impl
.
getActivityId
());
accountPrize
.
setPrizeId
(
prize
.
getId
());
accountPrize
.
setAccountName
(
phone
);
accountPrize
.
setAccountPhone
(
phone
);
...
...
@@ -233,7 +233,7 @@ public class DrawManagerImpl implements IDrawManager {
otherManager
.
sendCoupon
(
prize
.
getCouponId
(),
phone
,
accountPrize
.
getId
());
}
}
else
{
if
(
alreadyDrawCount
>=
businessConfig
.
getDrawMaxCount
())
{
if
(
alreadyDrawCount
>=
businessConfig
Impl
.
getDrawMaxCount
())
{
throw
new
BusinessException
(
ErrorEnum
.
DRAW_CHECK_EXP
,
"抱歉,你的今日可抽奖次数已用完,请明日再来哦"
);
}
else
{
throw
new
BusinessException
(
ErrorEnum
.
DRAW_CHECK_EXP
,
"抱歉,你的购物金额或购买活动商品不足,已无抽奖次数"
);
...
...
@@ -255,7 +255,7 @@ public class DrawManagerImpl implements IDrawManager {
@Override
public
List
<
DrawModel
>
listAllWinningInfo
(
Integer
size
)
{
List
<
AccountPrize
>
prizeList
=
accountPrizeService
.
listAllWinningInfo
(
size
,
businessConfig
.
getActivityId
());
List
<
AccountPrize
>
prizeList
=
accountPrizeService
.
listAllWinningInfo
(
size
,
businessConfigImpl
.
getActivityId
());
return
getDrawModels
(
prizeList
);
}
...
...
src/main/java/com/miya/draw/service/impl/ActivityGoodsServiceImpl.java
View file @
d604c67c
...
...
@@ -2,13 +2,12 @@ package com.miya.draw.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.miya.draw.config.business.BusinessConfig
;
import
com.miya.draw.config.business.BusinessConfig
Impl
;
import
com.miya.draw.config.constant.ConStants
;
import
com.miya.draw.entity.ActivityGoods
;
import
com.miya.draw.enums.YesOrNoEnum
;
import
com.miya.draw.mapper.ActivityGoodsMapper
;
import
com.miya.draw.service.IActivityGoodsService
;
import
com.netflix.discovery.converters.Auto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -41,7 +40,7 @@ public class ActivityGoodsServiceImpl extends ServiceImpl<ActivityGoodsMapper, A
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Resource
private
BusinessConfig
businessConfig
;
private
BusinessConfig
Impl
businessConfigImpl
;
@Override
public
List
<
String
>
listAllActivityGoods
()
{
...
...
@@ -56,7 +55,7 @@ public class ActivityGoodsServiceImpl extends ServiceImpl<ActivityGoodsMapper, A
}
LambdaQueryWrapper
<
ActivityGoods
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
ActivityGoods:
:
getValidState
,
YesOrNoEnum
.
YES
.
getCode
());
wrapper
.
eq
(
ActivityGoods:
:
getActivityId
,
businessConfig
.
getActivityId
());
wrapper
.
eq
(
ActivityGoods:
:
getActivityId
,
businessConfigImpl
.
getActivityId
());
List
<
ActivityGoods
>
activityGoodsList
=
activityGoodsMapper
.
selectList
(
wrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
activityGoodsList
))
{
goodList
=
activityGoodsList
.
stream
().
map
(
ActivityGoods:
:
getCode
).
collect
(
Collectors
.
toList
());
...
...
src/main/resources/application-dev.yml
deleted
100644 → 0
View file @
c37d9e37
spring
:
datasource
:
dynamic
:
hikari
:
connection-timeout
:
5000
idleTimeout
:
600000
maxLifetime
:
1800000
min-idle
:
10
max-pool-size
:
20
primary
:
db1
strict
:
true
datasource
:
db1
:
#mobox
url
:
jdbc:p6spy:mysql://47.98.165.99:3637/draw?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username
:
mycpos
password
:
mycpos@888
driver-class-name
:
com.p6spy.engine.spy.P6SpyDriver
type
:
com.zaxxer.hikari.HikariDataSource
db2
:
#十足
url
:
jdbc:p6spy:mysql://202.107.222.149:6306/szapplets?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username
:
sz_root
password
:
Sz20010526
driver-class-name
:
com.p6spy.engine.spy.P6SpyDriver
type
:
com.zaxxer.hikari.HikariDataSource
redis
:
database
:
0
host
:
47.98.165.99
port
:
6379
password
:
redis@888
lettuce
:
pool
:
max-idle
:
20
max-wait
:
300000
#连接最大阻塞时间
max-active
:
30
min-idle
:
10
knife4j
:
basic
:
enable
:
true
#配置ApiBoot Logging 日志组件
api
:
boot
:
logging
:
show-console-log
:
true
#实现美化打印请求日志
format-console-log-json
:
true
saas
:
url
:
https://hhsaas-test.miyapay.com
hhappId
:
wx5e87437bdd346c77
appId
:
wx273772ce26499402
form
:
cocaCola
ahas
:
namespace
:
mboxdev
license
:
b64d4c6c8ee9458e916e4bd2ab6d5a4a
xxl
:
job
:
admin
:
addresses
:
http://xxljob.dev.miyahub.net
executor
:
appname
:
xxl-job-miya-draw
ip
:
port
:
6149
custom
:
flag
:
true
allow
:
origins
:
"
*"
### eureka 配置 ###
eureka
:
instance
:
#【默认为false】优先使用内网IP,避免配置本地host
prefer-ip-address
:
true
client
:
serviceUrl
:
defaultZone
:
http://120.79.123.116:8661/eureka/
#【默认为30秒】eureka客户端间隔多久去拉取服务注册信息
registry-fetch-interval-seconds
:
3
\ No newline at end of file
src/main/resources/application-prod.yml
deleted
100644 → 0
View file @
c37d9e37
spring
:
datasource
:
dynamic
:
hikari
:
connection-timeout
:
5000
idleTimeout
:
600000
maxLifetime
:
1800000
min-idle
:
10
max-pool-size
:
20
primary
:
db1
strict
:
true
datasource
:
db1
:
url
:
jdbc:mysql://rm-bp15h28bq72fbw407.mysql.rds.aliyuncs.com:3306/drawxuehuapijiu?characterEncoding=UTF-8&useSSL=true&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username
:
draw
password
:
sACSFEgGEYcWXNDeyr74
driver-class-name
:
com.mysql.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
db2
:
#十足
url
:
jdbc:mysql://202.107.222.149:6306/szapplets?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username
:
sz_root
password
:
Sz20010526
driver-class-name
:
com.mysql.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
redis
:
database
:
0
host
:
r-bp1e52ee6d76d334.redis.rds.aliyuncs.com
port
:
6379
password
:
lettuce
:
pool
:
max-idle
:
20
max-wait
:
300000
#连接最大阻塞时间
max-active
:
30
min-idle
:
10
knife4j
:
basic
:
enable
:
false
#配置ApiBoot Logging 日志组件
api
:
boot
:
logging
:
show-console-log
:
true
#实现美化打印请求日志
format-console-log-json
:
false
# 发券
saas
:
url
:
https://saas-merchant.miyapay.com
hhappId
:
wx743313e7a4740003
appId
:
wx273772ce26499402
form
:
sz
# 高防护
ahas
:
namespace
:
default
license
:
b64d4c6c8ee9458e916e4bd2ab6d5a4a
xxl
:
job
:
admin
:
addresses
:
http://172.16.115.251:6013,http://172.16.115.252:6013
executor
:
appname
:
xxl-job-miya-draw
ip
:
port
:
6149
custom
:
flag
:
true
allow
:
origins
:
"
https://hh-oss-html.miyapay.com"
### eureka 配置 ###
eureka
:
instance
:
#【默认为false】优先使用内网IP,避免配置本地host
prefer-ip-address
:
true
client
:
serviceUrl
:
defaultZone
:
http://172.16.115.216:8761/eureka/,http://172.16.115.217:8761/eureka/
#【默认为30秒】eureka客户端间隔多久去拉取服务注册信息
registry-fetch-interval-seconds
:
3
src/main/resources/bootstrap-prod.yml
0 → 100644
View file @
d604c67c
spring
:
application
:
name
:
draw
cloud
:
nacos
:
discovery
:
server-addr
:
172.16.116.74:28100,172.16.116.75:28100,172.16.116.76:28100
namespace
:
prod
config
:
server-addr
:
172.16.116.74:28100,172.16.116.75:28100,172.16.116.76:28100
namespace
:
prod
group
:
SAAS-CLOUD
prefix
:
${spring.application.name}
file-extension
:
yaml
encode
:
UTF-8
# 引入扩展配置
extension-configs
:
-
data-id
:
draw-bussiness.yaml
group
:
EXAMPLE_GROUP
refresh
:
true
server
:
port
:
6048
biz-logging
:
path
:
./logs/${spring.application.name}
\ No newline at end of file
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