Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
7f8997b0
Commit
7f8997b0
authored
Mar 14, 2020
by
阮思源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1002495小睿小程序
parent
00862ee1
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
1631 additions
and
2 deletions
+1631
-2
CultivateBiz.java
...main/java/com/pcloud/book/cultivate/biz/CultivateBiz.java
+49
-0
CultivateBizImpl.java
.../com/pcloud/book/cultivate/biz/impl/CultivateBizImpl.java
+690
-0
CultivateConstant.java
...com/pcloud/book/cultivate/constant/CultivateConstant.java
+24
-0
CultivateDao.java
...main/java/com/pcloud/book/cultivate/dao/CultivateDao.java
+12
-0
CultivateRecordDao.java
...ava/com/pcloud/book/cultivate/dao/CultivateRecordDao.java
+19
-0
CultivateRobotClassifyDao.java
.../pcloud/book/cultivate/dao/CultivateRobotClassifyDao.java
+8
-0
CultivateDaoImpl.java
.../com/pcloud/book/cultivate/dao/impl/CultivateDaoImpl.java
+21
-0
CultivateRecordDaoImpl.java
...cloud/book/cultivate/dao/impl/CultivateRecordDaoImpl.java
+54
-0
CultivateRobotClassifyDaoImpl.java
...ook/cultivate/dao/impl/CultivateRobotClassifyDaoImpl.java
+21
-0
CreateCultivateDTO.java
...ava/com/pcloud/book/cultivate/dto/CreateCultivateDTO.java
+10
-0
EnergyConsumptionDTO.java
...a/com/pcloud/book/cultivate/dto/EnergyConsumptionDTO.java
+18
-0
EnergyConsumptionDelayDTO.java
.../pcloud/book/cultivate/dto/EnergyConsumptionDelayDTO.java
+17
-0
FishBallConversionDTO.java
.../com/pcloud/book/cultivate/dto/FishBallConversionDTO.java
+18
-0
FishBallPickDTO.java
...n/java/com/pcloud/book/cultivate/dto/FishBallPickDTO.java
+19
-0
SkillUseDTO.java
.../main/java/com/pcloud/book/cultivate/dto/SkillUseDTO.java
+18
-0
Cultivate.java
...main/java/com/pcloud/book/cultivate/entity/Cultivate.java
+29
-0
CultivateRecord.java
...ava/com/pcloud/book/cultivate/entity/CultivateRecord.java
+51
-0
CultivateRobotClassify.java
.../pcloud/book/cultivate/entity/CultivateRobotClassify.java
+23
-0
CultivateChangeTypeEnum.java
.../pcloud/book/cultivate/enums/CultivateChangeTypeEnum.java
+61
-0
CultivateSkillTypeEnum.java
...m/pcloud/book/cultivate/enums/CultivateSkillTypeEnum.java
+42
-0
FishBallChangeTypeEnum.java
...m/pcloud/book/cultivate/enums/FishBallChangeTypeEnum.java
+18
-0
CultivateFacade.java
...ava/com/pcloud/book/cultivate/facade/CultivateFacade.java
+160
-0
DelayReceiver.java
...src/main/java/com/pcloud/book/mq/delay/DelayReceiver.java
+6
-0
PersonalMedalFacade.java
.../com/pcloud/book/personal/facade/PersonalMedalFacade.java
+1
-2
Cultivate.xml
...ce-book/src/main/resources/mapper/cultivate/Cultivate.xml
+83
-0
CultivateRecord.xml
...k/src/main/resources/mapper/cultivate/CultivateRecord.xml
+111
-0
CultivateRobotClassify.xml
...ain/resources/mapper/cultivate/CultivateRobotClassify.xml
+48
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/biz/CultivateBiz.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
biz
;
import
com.pcloud.book.cultivate.dto.CreateCultivateDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.personal.dto.PersonalMedalRecordDto
;
import
com.pcloud.common.core.mq.DelayQueueDTO
;
import
com.pcloud.common.page.PageBeanNew
;
import
java.util.List
;
public
interface
CultivateBiz
{
Long
createCultivate
(
CreateCultivateDTO
createCultivateDTO
);
Cultivate
getCultivate
(
Long
wechatUserId
);
void
createCultivateRobotClassify
(
CultivateRobotClassify
cultivateRobotClassify
);
void
energyConsumption
(
EnergyConsumptionDTO
energyConsumptionDTO
);
void
dealDelayEnergyConsumption
(
DelayQueueDTO
delayQueueDTO
);
void
fishBallConversion
(
FishBallConversionDTO
fishBallConversionDTO
);
Long
createCultivateRecord
(
CultivateRecord
cultivateRecord
);
void
addUseSkillRecord
(
Long
wechatUserId
,
SkillUseDTO
skillUseDTO
);
void
fishBallPick
(
FishBallPickDTO
fishBallPickDTO
);
Integer
getFishBallNotPick
(
Long
cultivateId
);
PageBeanNew
<
CultivateRecord
>
getCultivateRecordList
(
Long
cultivateId
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
Long
getLoginDays
(
Long
wechatUserId
);
Integer
getRanking
(
Long
wechatUserId
);
String
shareMedal
(
Long
wechatUserId
);
List
<
PersonalMedalRecordDto
>
getUserMedalList
(
Long
wechatUserId
);
Integer
getResidueLightTime
(
Long
cultivateId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/biz/impl/CultivateBizImpl.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
biz
.
impl
;
import
com.google.common.collect.Lists
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.consumer.reader.ReaderConsr
;
import
com.pcloud.book.cultivate.biz.CultivateBiz
;
import
com.pcloud.book.cultivate.constant.CultivateConstant
;
import
com.pcloud.book.cultivate.dao.CultivateDao
;
import
com.pcloud.book.cultivate.dao.CultivateRecordDao
;
import
com.pcloud.book.cultivate.dao.CultivateRobotClassifyDao
;
import
com.pcloud.book.cultivate.dto.*
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.cultivate.enums.CultivateChangeTypeEnum
;
import
com.pcloud.book.cultivate.enums.CultivateSkillTypeEnum
;
import
com.pcloud.book.cultivate.enums.FishBallChangeTypeEnum
;
import
com.pcloud.book.mq.delay.DelayMessageSender
;
import
com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz
;
import
com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz
;
import
com.pcloud.book.pcloudkeyword.entity.PcloudRobot
;
import
com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify
;
import
com.pcloud.book.personal.biz.PersonalMedalBiz
;
import
com.pcloud.book.personal.dao.PersonalMedalDao
;
import
com.pcloud.book.personal.dao.PersonalMedalRecordDao
;
import
com.pcloud.book.personal.dto.PersonalMedalRecordDto
;
import
com.pcloud.book.personal.dto.PersonalStarReceiveDto
;
import
com.pcloud.book.personal.entity.PersonalMedal
;
import
com.pcloud.book.personal.entity.PersonalMedalRecord
;
import
com.pcloud.book.personal.entity.PersonalShareTemplate
;
import
com.pcloud.book.personal.mapper.PersonalShareTemplateMapper
;
import
com.pcloud.book.util.common.YesOrNoEnums
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.mq.DelayQueueDTO
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ResponseHandleUtil
;
import
com.pcloud.facade.shareimage.dto.HtmlDto
;
import
com.pcloud.facade.shareimage.facade.Htm2ImgService
;
import
com.pcloud.readercenter.wechat.entity.WechatUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
@Component
(
"cultivateBiz"
)
public
class
CultivateBizImpl
implements
CultivateBiz
{
@Autowired
private
CultivateDao
cultivateDao
;
@Autowired
private
CultivateRobotClassifyDao
cultivateRobotClassifyDao
;
@Autowired
private
DelayMessageSender
delayMessageSender
;
@Autowired
private
CultivateRecordDao
cultivateRecordDao
;
@Autowired
private
ReaderConsr
readerConsr
;
@Autowired
private
PcloudRobotBiz
pcloudRobotBiz
;
@Autowired
private
Htm2ImgService
htm2ImgService
;
@Autowired
private
PcloudRobotClassifyBiz
pcloudRobotClassifyBiz
;
@Autowired
private
PersonalShareTemplateMapper
personalShareTemplateMapper
;
@Autowired
private
PersonalMedalDao
personalMedalDao
;
@Autowired
private
PersonalMedalRecordDao
personalMedalRecordDao
;
@Autowired
private
PersonalMedalBiz
personalMedalBiz
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增养成"
)
@Override
public
Long
createCultivate
(
CreateCultivateDTO
createCultivateDTO
)
{
if
(
createCultivateDTO
==
null
||
createCultivateDTO
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"wechatUserId为空!"
);
}
Long
wechatUserId
=
createCultivateDTO
.
getWechatUserId
();
Cultivate
old
=
cultivateDao
.
getByWechatUserId
(
wechatUserId
);
if
(
old
!=
null
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"已有养成!"
);
}
Cultivate
cultivate
=
new
Cultivate
();
cultivate
.
setEnergy
(
CultivateConstant
.
INITIAL_ENERGY
);
cultivate
.
setStar
(
CultivateConstant
.
INITIAL_STAR
);
cultivate
.
setWechatUserId
(
wechatUserId
);
cultivate
.
setLighten
(
false
);
cultivate
.
setFishBall
(
0
);
cultivateDao
.
insert
(
cultivate
);
return
cultivate
.
getId
();
}
@ParamLog
(
"获取养成"
)
@Override
public
Cultivate
getCultivate
(
Long
wechatUserId
)
{
if
(
wechatUserId
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"wechatUserId为空!"
);
}
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
wechatUserId
);
//TODO 计算等级勋章等,获取用户基本信息等
return
cultivate
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"新增养成分类关联"
)
@Override
public
void
createCultivateRobotClassify
(
CultivateRobotClassify
cultivateRobotClassify
)
{
if
(
cultivateRobotClassify
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"cultivateRobotClassify为空!"
);
}
if
(
cultivateRobotClassify
.
getCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"cultivateId为空!"
);
}
if
(
cultivateRobotClassify
.
getRobotClassifyId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"robotClassifyId为空!"
);
}
if
(
cultivateRobotClassify
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
}
//查询之前是否有
CultivateRobotClassify
byCondition
=
cultivateRobotClassifyDao
.
getByCondition
(
cultivateRobotClassify
.
getWechatUserId
(),
cultivateRobotClassify
.
getCultivateId
(),
cultivateRobotClassify
.
getRobotClassifyId
());
if
(
byCondition
!=
null
){
return
;
}
cultivateRobotClassifyDao
.
insert
(
cultivateRobotClassify
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"能量消耗"
)
@Override
public
void
energyConsumption
(
EnergyConsumptionDTO
energyConsumptionDTO
)
{
if
(
energyConsumptionDTO
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"energyConsumptionDTO为空!"
);
}
if
(
energyConsumptionDTO
.
getCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id为空!"
);
}
if
(
energyConsumptionDTO
.
getEnergy
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"能量为空!"
);
}
if
(
energyConsumptionDTO
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
}
Long
wechatUserId
=
energyConsumptionDTO
.
getWechatUserId
();
Long
cultivateId
=
energyConsumptionDTO
.
getCultivateId
();
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
if
(
cultivate
==
null
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有养成!"
);
}
if
(
cultivate
.
getEnergy
()<
energyConsumptionDTO
.
getEnergy
()){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"能量不足,当前只有"
+
cultivate
.
getEnergy
()+
"能量"
);
}
cultivate
.
setEnergy
(
cultivate
.
getEnergy
()-
energyConsumptionDTO
.
getEnergy
());
//新增能量消耗记录
CultivateRecord
addEnergyRecord
=
new
CultivateRecord
();
addEnergyRecord
.
setEnergyChange
(-
energyConsumptionDTO
.
getEnergy
());
addEnergyRecord
.
setCultivateId
(
cultivateId
);
addEnergyRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
USE_ENERGY
.
code
);
addEnergyRecord
.
setWechatUserId
(
wechatUserId
);
Long
recordId
=
createCultivateRecord
(
addEnergyRecord
);
if
(!
cultivate
.
getLighten
()){
//熄灭状态
cultivate
.
setLighten
(
true
);
//加延时队列,到点熄灯,新增点亮记录
addDelayEnergyConsumption
(
recordId
,
wechatUserId
,
energyConsumptionDTO
.
getEnergy
());
//新增点亮记录
CultivateRecord
liRecord
=
new
CultivateRecord
();
liRecord
.
setWechatUserId
(
wechatUserId
);
liRecord
.
setCultivateId
(
cultivateId
);
liRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
LIGHTEN
.
code
);
liRecord
.
setWechatUserId
(
wechatUserId
);
createCultivateRecord
(
liRecord
);
}
cultivateDao
.
update
(
cultivate
);
}
private
void
addDelayEnergyConsumption
(
Long
cultivateRecordId
,
Long
wechatUserId
,
Integer
energy
){
EnergyConsumptionDelayDTO
energyConsumptionDelayDTO
=
new
EnergyConsumptionDelayDTO
();
energyConsumptionDelayDTO
.
setCultivateRecordId
(
cultivateRecordId
);
energyConsumptionDelayDTO
.
setEnergy
(
energy
);
DelayQueueDTO
delayQueueDTONew
=
DelayQueueDTO
.
builder
().
key
(
wechatUserId
.
toString
()).
type
(
CultivateConstant
.
ENERGY_CONSUMPTION_DELAY
).
msg
(
energyConsumptionDelayDTO
).
timeout
(
energy
*
60
*
1000
).
build
();
delayMessageSender
.
send
(
delayQueueDTONew
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"能量消耗延时处理"
)
@Override
public
void
dealDelayEnergyConsumption
(
DelayQueueDTO
delayQueueDTO
)
{
Long
wechatUserId
=
new
Long
(
delayQueueDTO
.
getKey
());
EnergyConsumptionDelayDTO
consumptionDelayDTO
=
(
EnergyConsumptionDelayDTO
)
delayQueueDTO
.
getMsg
();
Long
recordId
=
consumptionDelayDTO
.
getCultivateRecordId
();
CultivateRecord
cultivateRecord
=
cultivateRecordDao
.
getById
(
recordId
);
//判断该记录之前还有没有能量消耗,如果有继续点亮,如果没有,熄灯
Integer
afterEnergy
=
cultivateRecordDao
.
getEnergyConsumptionAfter
(
cultivateRecord
.
getId
(),
wechatUserId
);
Long
cultivateId
=
cultivateRecord
.
getCultivateId
();
if
(
afterEnergy
>
0
){
//继续点亮,重新加延时队列
CultivateRecord
last
=
cultivateRecordDao
.
getLastEnergyConsumptionRecord
(
wechatUserId
,
cultivateId
);
addDelayEnergyConsumption
(
last
.
getId
(),
wechatUserId
,
afterEnergy
);
}
else
{
//熄灯,收取鱼丸
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
cultivate
.
setLighten
(
false
);
//查询用户点灯之后收取过的鱼丸数量
Integer
userGatherFishBall
=
cultivateRecordDao
.
getUserGatherFishBallCount
(
wechatUserId
,
cultivateId
);
//系统收取鱼丸
Integer
allEnergy
=
0
;
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
wechatUserId
,
cultivateId
);
if
(
lastLighten
!=
null
){
//获取点灯之前的最后一次消耗能量记录
CultivateRecord
consumptionBefore
=
cultivateRecordDao
.
getLastEnergyConsumptionBefore
(
lastLighten
.
getId
(),
wechatUserId
);
if
(
consumptionBefore
!=
null
){
Integer
consumptionAfter
=
cultivateRecordDao
.
getEnergyConsumptionAfter
(
lastLighten
.
getId
(),
wechatUserId
);
allEnergy
=-
consumptionBefore
.
getEnergyChange
()+
consumptionAfter
;
}
}
Integer
currentAdd
=
allEnergy
-
userGatherFishBall
;
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
currentAdd
);
//产生收鱼丸记录
CultivateRecord
hasFishBall
=
new
CultivateRecord
();
hasFishBall
.
setCultivateId
(
cultivateId
);
hasFishBall
.
setWechatUserId
(
wechatUserId
);
hasFishBall
.
setChangeType
(
CultivateChangeTypeEnum
.
GET_FISH_BALL
.
code
);
hasFishBall
.
setFishBallChangeType
(
FishBallChangeTypeEnum
.
AUTO_CHANGE
.
value
);
hasFishBall
.
setFishBallChange
(
currentAdd
);
createCultivateRecord
(
hasFishBall
);
//熄灯,产生一条熄灯记录
CultivateRecord
quench
=
new
CultivateRecord
();
quench
.
setWechatUserId
(
wechatUserId
);
quench
.
setCultivateId
(
cultivateId
);
quench
.
setChangeType
(
CultivateChangeTypeEnum
.
QUENCH
.
code
);
createCultivateRecord
(
quench
);
cultivateDao
.
update
(
cultivate
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"鱼丸兑换"
)
@Override
public
void
fishBallConversion
(
FishBallConversionDTO
fishBallConversionDTO
)
{
if
(
fishBallConversionDTO
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"fishBallConversionDTO为空!"
);
}
if
(
fishBallConversionDTO
.
getCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id为空!"
);
}
if
(
fishBallConversionDTO
.
getFishBall
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"鱼丸为空!"
);
}
if
(
fishBallConversionDTO
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
}
Long
wechatUserId
=
fishBallConversionDTO
.
getWechatUserId
();
Cultivate
cultivate
=
cultivateDao
.
getById
(
fishBallConversionDTO
.
getCultivateId
());
if
(
cultivate
==
null
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有养成!"
);
}
if
(
cultivate
.
getFishBall
()<
fishBallConversionDTO
.
getFishBall
()){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"鱼丸不足,当前只有"
+
cultivate
.
getFishBall
()+
"鱼丸"
);
}
if
(
fishBallConversionDTO
.
getFishBall
()%
100
!=
0
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"请使用100的倍数"
);
}
//插入鱼丸兑换记录
CultivateRecord
convertFishBall
=
new
CultivateRecord
();
convertFishBall
.
setWechatUserId
(
wechatUserId
);
convertFishBall
.
setChangeType
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
);
convertFishBall
.
setCultivateId
(
fishBallConversionDTO
.
getCultivateId
());
convertFishBall
.
setFishBallChange
(-
fishBallConversionDTO
.
getFishBall
());
convertFishBall
.
setStarChange
(
fishBallConversionDTO
.
getFishBall
()/
100
);
createCultivateRecord
(
convertFishBall
);
//先插入记录在更新养成表星星数
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()-
fishBallConversionDTO
.
getFishBall
());
cultivate
.
setStar
(
cultivate
.
getStar
()+
fishBallConversionDTO
.
getFishBall
()/
100
);
cultivateDao
.
update
(
cultivate
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"插入成长动态记录"
)
@Override
public
Long
createCultivateRecord
(
CultivateRecord
cultivateRecord
)
{
if
(
cultivateRecord
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"cultivateRecord为空!"
);
}
if
(
cultivateRecord
.
getCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id为空!"
);
}
if
(
cultivateRecord
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
}
if
(
cultivateRecord
.
getChangeType
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"动态类型为空!"
);
}
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
GET_FISH_BALL
.
code
)){
if
(
cultivateRecord
.
getFishBallChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"鱼丸数为空!"
);
}
if
(
cultivateRecord
.
getFishBallChangeType
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"鱼丸变化类型为空!"
);
}
cultivateRecord
.
setRemark
(
"获得了"
+
cultivateRecord
.
getFishBallChange
()+
"个鱼丸"
);
}
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
LIGHTEN
.
code
)){
cultivateRecord
.
setRemark
(
"灯已点亮,我有吃的了!"
);
}
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
QUENCH
.
code
)){
cultivateRecord
.
setRemark
(
"灯已熄灭,我看不见了小主,点亮我吧!"
);
}
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
USE_ENERGY
.
code
)){
if
(
cultivateRecord
.
getEnergyChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"能量值为空!"
);
}
Integer
hour
=(-
cultivateRecord
.
getEnergyChange
())/
60
;
Integer
min
=(-
cultivateRecord
.
getEnergyChange
())%
60
;
if
(
hour
>
0
)
{
cultivateRecord
.
setRemark
(
"你已使用"
+
(-
cultivateRecord
.
getEnergyChange
())
+
"能量值点亮"
+
hour
+
"小时"
+
min
+
"分钟"
);
}
else
{
cultivateRecord
.
setRemark
(
"你已使用"
+
(-
cultivateRecord
.
getEnergyChange
())
+
"能量值点亮"
+
min
+
"分钟"
);
}
}
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
USE_SKILL
.
code
)){
if
(
cultivateRecord
.
getSkillType
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"技能类型为空!"
);
}
String
skill
=
CultivateSkillTypeEnum
.
getNameByCode
(
cultivateRecord
.
getSkillType
());
cultivateRecord
.
setRemark
(
"你使用了"
+
skill
+
"技能,请添加小睿为好友后,回复您想"
);
}
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
)){
if
(
cultivateRecord
.
getStarChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"星星数量为空!"
);
}
cultivateRecord
.
setRemark
(
"你已将"
+
cultivateRecord
.
getStarChange
()*
100
+
"个鱼丸兑换了"
+
cultivateRecord
.
getStarChange
()+
"颗星"
);
}
cultivateRecordDao
.
insert
(
cultivateRecord
);
if
(
cultivateRecord
.
getChangeType
().
equals
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
)){
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
cultivateRecord
.
getWechatUserId
());
Boolean
isUp
=
isUpGrade
(
cultivate
.
getStar
(),
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
());
Integer
newStarCount
=
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
();
if
(
isUp
){
//插入升级记录
CultivateRecord
upGradeRecord
=
new
CultivateRecord
();
upGradeRecord
.
setWechatUserId
(
cultivateRecord
.
getWechatUserId
());
upGradeRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
UPGRADE
.
code
);
upGradeRecord
.
setCultivateId
(
cultivate
.
getId
());
//插入领取的勋章
// 获取用户的星星数
Integer
starCount
=
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
();
// 查询当前数量的星星可以领取的勋章(过滤掉已领取的)
List
<
Long
>
medalIds
=
personalMedalDao
.
getReceivingMedal
(
cultivateRecord
.
getWechatUserId
(),
starCount
);
if
(!
ListUtils
.
isEmpty
(
medalIds
)){
// 插入可以领取的记录
PersonalMedalRecord
medalRecord
;
for
(
Long
medalId
:
medalIds
){
medalRecord
=
new
PersonalMedalRecord
();
medalRecord
.
setMedalId
(
medalId
);
medalRecord
.
setWechatUserId
(
cultivateRecord
.
getWechatUserId
());
medalRecord
.
setHasShow
(
YesOrNoEnums
.
YES
.
getValue
());
// 插入领取记录
personalMedalRecordDao
.
insert
(
medalRecord
);
}
}
if
(
CultivateConstant
.
second_MEDAL_STAR
<=
newStarCount
&&
newStarCount
<
CultivateConstant
.
third_MEDAL_STAR
)
{
upGradeRecord
.
setRemark
(
"已成功升级LV2学有小成"
);
}
if
(
CultivateConstant
.
third_MEDAL_STAR
<=
newStarCount
&&
newStarCount
<
CultivateConstant
.
fourth_MEDAL_STAR
)
{
upGradeRecord
.
setRemark
(
"已成功升级LV3渐入佳境"
);
}
if
(
CultivateConstant
.
fourth_MEDAL_STAR
<=
newStarCount
&&
newStarCount
<
CultivateConstant
.
fifth_MEDAL_STAR
)
{
upGradeRecord
.
setRemark
(
"已成功升级LV4炉火纯青"
);
}
if
(
CultivateConstant
.
fifth_MEDAL_STAR
<=
newStarCount
&&
newStarCount
<
CultivateConstant
.
sixth_MEDAL_STAR
)
{
upGradeRecord
.
setRemark
(
"已成功升级LV5学识渊博"
);
}
if
(
CultivateConstant
.
sixth_MEDAL_STAR
<=
newStarCount
)
{
upGradeRecord
.
setRemark
(
"已成功升级LV6学亘古今"
);
}
cultivateRecordDao
.
insert
(
upGradeRecord
);
}
}
return
cultivateRecord
.
getId
();
}
@Override
public
void
addUseSkillRecord
(
Long
wechatUserId
,
SkillUseDTO
skillUseDTO
)
{
CultivateRecord
cultivateRecord
=
new
CultivateRecord
();
cultivateRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
USE_SKILL
.
code
);
cultivateRecord
.
setCultivateId
(
skillUseDTO
.
getCultivateId
());
cultivateRecord
.
setSkillType
(
skillUseDTO
.
getSkillType
());
cultivateRecord
.
setWechatUserId
(
wechatUserId
);
createCultivateRecord
(
cultivateRecord
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"鱼丸摘取"
)
@Override
public
void
fishBallPick
(
FishBallPickDTO
fishBallPickDTO
)
{
if
(
fishBallPickDTO
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"鱼丸摘取参数为空!"
);
}
if
(
fishBallPickDTO
.
getCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成Id为空!"
);
}
if
(
fishBallPickDTO
.
getFishBall
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"鱼丸数量为空!"
);
}
if
(
fishBallPickDTO
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
}
Long
wechatUserId
=
fishBallPickDTO
.
getWechatUserId
();
Long
cultivateId
=
fishBallPickDTO
.
getCultivateId
();
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
if
(
cultivate
==
null
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有该养成!"
);
}
Integer
notPick
=
getFishBallNotPick
(
cultivateId
);
if
(
notPick
<=
0
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有可摘取的鱼丸!"
);
}
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
fishBallPickDTO
.
getFishBall
());
cultivateDao
.
update
(
cultivate
);
CultivateRecord
cultivateRecord
=
new
CultivateRecord
();
cultivateRecord
.
setWechatUserId
(
wechatUserId
);
cultivateRecord
.
setCultivateId
(
cultivateId
);
cultivateRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
GET_FISH_BALL
.
code
);
cultivateRecord
.
setFishBallChangeType
(
FishBallChangeTypeEnum
.
USER_CHANGE
.
value
);
cultivateRecord
.
setFishBallChange
(
fishBallPickDTO
.
getFishBall
());
createCultivateRecord
(
cultivateRecord
);
}
@ParamLog
(
"获取现有未摘取鱼丸"
)
@Override
public
Integer
getFishBallNotPick
(
Long
cultivateId
)
{
if
(
cultivateId
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id为空!"
);
}
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
Long
wechatUserId
=
cultivate
.
getWechatUserId
();
if
(
cultivate
==
null
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有该养成!"
);
}
//熄灭状态
if
(!
cultivate
.
getLighten
()){
return
0
;
}
//查询上次点亮之后到现在的时间
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
wechatUserId
,
cultivateId
);
if
(
lastLighten
==
null
){
return
0
;
}
//一共产生的鱼丸
Integer
proFishBall
=(
int
)(
new
Date
().
getTime
()-
lastLighten
.
getCreateTime
().
getTime
())/
1000
/
60
;
//点亮期间已经摘取过的语言
Integer
gatherFishBallCount
=
cultivateRecordDao
.
getUserGatherFishBallCount
(
wechatUserId
,
cultivateId
);
return
proFishBall
-
gatherFishBallCount
;
}
@Override
public
PageBeanNew
<
CultivateRecord
>
getCultivateRecordList
(
Long
cultivateId
,
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cultivateId"
,
cultivateId
);
paramMap
.
put
(
"wechatUserId"
,
wechatUserId
);
PageBeanNew
<
CultivateRecord
>
pageBeanNew
=
cultivateRecordDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
paramMap
,
"getCultivateRecordList"
);
if
(
pageBeanNew
==
null
||
ListUtils
.
isEmpty
(
pageBeanNew
.
getRecordList
()))
{
return
new
PageBeanNew
<>(
currentPage
,
numPerPage
,
new
ArrayList
<>());
}
return
pageBeanNew
;
}
@Override
public
Long
getLoginDays
(
Long
wechatUserId
)
{
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
wechatUserId
);
Long
dateDiff
=
DateUtils
.
getDateDiff
(
wechatUser
.
getCreatedDate
(),
new
Date
());
return
dateDiff
;
}
@Override
public
Integer
getRanking
(
Long
wechatUserId
)
{
Integer
ranking
=
0
;
List
<
Cultivate
>
list
=
cultivateDao
.
getAllOrderByStar
();
if
(
list
==
null
||
list
.
size
()==
0
){
return
ranking
;
}
for
(
int
i
=
0
;
i
<=
list
.
size
()-
1
;
i
++){
Cultivate
cultivate
=
list
.
get
(
i
);
if
(
cultivate
.
getWechatUserId
().
equals
(
wechatUserId
)){
ranking
=
i
+
1
;
return
ranking
;
}
}
return
ranking
;
}
@Override
@ParamLog
(
"获取用户已获得勋章数据"
)
public
List
<
PersonalMedalRecordDto
>
getUserMedalList
(
Long
wechatUserId
)
{
List
<
PersonalMedalRecordDto
>
userMedalList
=
personalMedalRecordDao
.
getUserMedalList
(
wechatUserId
);
if
(
ListUtils
.
isEmpty
(
userMedalList
)){
return
Lists
.
newArrayList
();
}
return
userMedalList
;
}
@ParamLog
(
"获取剩余亮灯时间"
)
@Override
public
Integer
getResidueLightTime
(
Long
cultivateId
)
{
if
(
cultivateId
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id不能为空!"
);
}
//查询上次亮灯时间和亮灯之后的兑换的能量
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
if
(
cultivate
==
null
||!
cultivate
.
getLighten
()){
return
0
;
}
Long
wechatUserId
=
cultivate
.
getWechatUserId
();
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
wechatUserId
,
cultivateId
);
if
(
lastLighten
==
null
){
return
0
;
}
//获取点灯之前的最后一次消耗能量记录
CultivateRecord
consumptionBefore
=
cultivateRecordDao
.
getLastEnergyConsumptionBefore
(
lastLighten
.
getId
(),
wechatUserId
);
if
(
consumptionBefore
==
null
){
return
0
;
}
Integer
consumptionAfter
=
cultivateRecordDao
.
getEnergyConsumptionAfter
(
lastLighten
.
getId
(),
wechatUserId
);
Integer
allEnergy
=-
consumptionBefore
.
getEnergyChange
()+
consumptionAfter
;
Integer
time
=
allEnergy
*
60
-(
int
)(
new
Date
().
getTime
()-
lastLighten
.
getCreateTime
().
getTime
())/
1000
;
if
(
time
<=
0
){
return
0
;
}
return
time
;
}
@Override
@ParamLog
(
"分享"
)
public
String
shareMedal
(
Long
wechatUserId
)
{
// 获取用户基本信息
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
wechatUserId
);
Long
loginDays
=
getLoginDays
(
wechatUserId
);
List
<
PersonalMedal
>
baseMedalList
=
personalMedalBiz
.
getBaseMedalList
();
List
<
PersonalMedalRecordDto
>
personalMedalRecordDtos
=
new
ArrayList
<>();
// TODO 换小程序二维码图片地址
String
projectQrcodeUrl
=
"https://file.5rs.me/oss/uploadfe/jpg/5e586c6176e13b8806736581b9f641a0.jpg"
;
//根据星星数获取勋章图片信息
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
wechatUserId
);
if
(
CultivateConstant
.
FIRST_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
second_MEDAL_STAR
)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
personalMedalRecordDto
.
setBigImgUrl
(
baseMedalList
.
get
(
0
).
getBigImgUrl
());
personalMedalRecordDtos
.
add
(
personalMedalRecordDto
);
}
if
(
CultivateConstant
.
second_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
third_MEDAL_STAR
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
personalMedalRecordDto
.
setLightImgUrl
(
baseMedalList
.
get
(
i
).
getLightImgUrl
());
personalMedalRecordDtos
.
add
(
personalMedalRecordDto
);
}
}
if
(
CultivateConstant
.
third_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
fourth_MEDAL_STAR
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
personalMedalRecordDto
.
setLightImgUrl
(
baseMedalList
.
get
(
i
).
getLightImgUrl
());
personalMedalRecordDtos
.
add
(
personalMedalRecordDto
);
}
}
if
(
CultivateConstant
.
fourth_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
fifth_MEDAL_STAR
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
personalMedalRecordDto
.
setLightImgUrl
(
baseMedalList
.
get
(
i
).
getLightImgUrl
());
personalMedalRecordDtos
.
add
(
personalMedalRecordDto
);
}
}
if
(
CultivateConstant
.
fifth_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
sixth_MEDAL_STAR
)
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
personalMedalRecordDto
.
setLightImgUrl
(
baseMedalList
.
get
(
i
).
getLightImgUrl
());
personalMedalRecordDtos
.
add
(
personalMedalRecordDto
);
}
}
if
(
CultivateConstant
.
fifth_MEDAL_STAR
<=
cultivate
.
getStar
())
{
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
personalMedalRecordDto
.
setLightImgUrl
(
baseMedalList
.
get
(
i
).
getLightImgUrl
());
personalMedalRecordDtos
.
add
(
personalMedalRecordDto
);
}
}
if
(
wechatUser
==
null
){
throw
new
BizException
(
BizException
.
DB_DML_FAIL
.
getCode
(),
"未找到用户信息"
);
}
String
html
=
null
;
if
(
personalMedalRecordDtos
.
size
()
==
1
){
//只生成大图
html
=
buildMedalHtml4Big
(
personalMedalRecordDtos
.
get
(
0
),
wechatUser
,
projectQrcodeUrl
,
loginDays
);
}
else
{
//多个小图
html
=
buildMedalHtml4Little
(
personalMedalRecordDtos
,
wechatUser
,
projectQrcodeUrl
,
loginDays
);
}
HtmlDto
htmlDto
=
new
HtmlDto
();
htmlDto
.
setHeight
(
1206
);
htmlDto
.
setWidth
(
750
);
htmlDto
.
setHtmlCode
(
html
);
htmlDto
.
setSnapshot
(
new
Long
(
System
.
currentTimeMillis
()).
toString
());
return
ResponseHandleUtil
.
parseResponse
(
htm2ImgService
.
toJPGByChrome
(
htmlDto
),
String
.
class
);
}
private
String
buildMedalHtml4Little
(
List
<
PersonalMedalRecordDto
>
personalMedalRecordDtos
,
WechatUser
wechatUser
,
String
projectQrcodeUrl
,
Long
loginDays
)
{
PersonalShareTemplate
personalShareTemplate
=
personalShareTemplateMapper
.
selectByPrimaryKey
(
2
);
String
html
=
personalShareTemplate
.
getContent
();
html
=
html
.
replace
(
"${headUrl}"
,
wechatUser
.
getWechatUserHeadurl
());
html
=
html
.
replace
(
"${nickName}"
,
wechatUser
.
getWechatUserNickname
());
html
=
html
.
replace
(
"${loginDays}"
,
loginDays
.
toString
());
html
=
html
.
replace
(
"${classifyQrcode}"
,
projectQrcodeUrl
);
html
=
html
.
replace
(
"${medalCount}"
,
personalMedalRecordDtos
.
size
()+
""
);
String
medalImg
=
""
;
for
(
PersonalMedalRecordDto
personalMedalRecordDto
:
personalMedalRecordDtos
){
medalImg
+=
"<img src='"
+
personalMedalRecordDto
.
getLightImgUrl
()+
"'class=\"medal\" />"
;
}
html
=
html
.
replace
(
"${medalImgs}"
,
medalImg
);
return
html
;
}
private
String
buildMedalHtml4Big
(
PersonalMedalRecordDto
personalMedalRecordDto
,
WechatUser
wechatUser
,
String
projectQrcodeUrl
,
Long
loginDays
)
{
PersonalShareTemplate
personalShareTemplate
=
personalShareTemplateMapper
.
selectByPrimaryKey
(
1
);
String
html
=
personalShareTemplate
.
getContent
();
html
=
html
.
replace
(
"${headUrl}"
,
wechatUser
.
getWechatUserHeadurl
());
html
=
html
.
replace
(
"${nickName}"
,
wechatUser
.
getWechatUserNickname
());
html
=
html
.
replace
(
"${loginDays}"
,
loginDays
.
toString
());
html
=
html
.
replace
(
"${classifyQrcode}"
,
projectQrcodeUrl
);
return
html
;
}
@ParamLog
(
"鱼丸兑换后是否升级"
)
private
Boolean
isUpGrade
(
Integer
oldStarCounts
,
Integer
newStarCounts
){
if
(
CultivateConstant
.
FIRST_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
second_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
second_MEDAL_STAR
)
{
return
true
;
}
if
(
CultivateConstant
.
second_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
third_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
third_MEDAL_STAR
)
{
return
true
;
}
if
(
CultivateConstant
.
third_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
fourth_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
fourth_MEDAL_STAR
)
{
return
true
;
}
if
(
CultivateConstant
.
fourth_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
fifth_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
fifth_MEDAL_STAR
)
{
return
true
;
}
if
(
CultivateConstant
.
fifth_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
sixth_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
sixth_MEDAL_STAR
)
{
return
true
;
}
return
false
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/constant/CultivateConstant.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
constant
;
public
class
CultivateConstant
{
public
static
final
Integer
INITIAL_ENERGY
=
800
;
public
static
final
Integer
INITIAL_STAR
=
30
;
public
static
final
String
ENERGY_CONSUMPTION_DELAY
=
"ENERGY_CONSUMPTION_DELAY"
;
public
static
final
String
USE_SKILL_PRE
=
"使用技能"
;
public
static
final
Integer
FIRST_MEDAL_STAR
=
30
;
public
static
final
Integer
second_MEDAL_STAR
=
90
;
public
static
final
Integer
third_MEDAL_STAR
=
180
;
public
static
final
Integer
fourth_MEDAL_STAR
=
360
;
public
static
final
Integer
fifth_MEDAL_STAR
=
500
;
public
static
final
Integer
sixth_MEDAL_STAR
=
1000
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateDao.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
CultivateDao
extends
BaseDao
<
Cultivate
>
{
Cultivate
getByWechatUserId
(
Long
wechatUserId
);
List
<
Cultivate
>
getAllOrderByStar
();
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateRecordDao.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.common.core.dao.BaseDao
;
import
com.pcloud.common.page.PageBeanNew
;
import
java.util.List
;
public
interface
CultivateRecordDao
extends
BaseDao
<
CultivateRecord
>
{
Integer
getEnergyConsumptionAfter
(
Long
cultivateRecordId
,
Long
wechatUserId
);
CultivateRecord
getLastEnergyConsumptionRecord
(
Long
wechatUserId
,
Long
cultivateId
);
Integer
getUserGatherFishBallCount
(
Long
wechatUserId
,
Long
cultivateId
);
CultivateRecord
getLastLighten
(
Long
wechatUserId
,
Long
cultivateId
);
CultivateRecord
getLastEnergyConsumptionBefore
(
Long
cultivateRecordId
,
Long
wechatUserId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateRobotClassifyDao.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.common.core.dao.BaseDao
;
public
interface
CultivateRobotClassifyDao
extends
BaseDao
<
CultivateRobotClassify
>
{
CultivateRobotClassify
getByCondition
(
Long
wechatUserId
,
Long
cultivateId
,
Long
robotClassifyId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateDaoImpl.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateDao
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
(
"cultivateDao"
)
public
class
CultivateDaoImpl
extends
BaseDaoImpl
<
Cultivate
>
implements
CultivateDao
{
@Override
public
Cultivate
getByWechatUserId
(
Long
wechatUserId
)
{
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getByWechatUserId"
),
wechatUserId
);
}
@Override
public
List
<
Cultivate
>
getAllOrderByStar
()
{
return
getSessionTemplate
().
selectList
(
getStatement
(
"getAllOrderByStar"
));
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateRecordDaoImpl.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateRecordDao
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
(
"cultivateRecordDao"
)
public
class
CultivateRecordDaoImpl
extends
BaseDaoImpl
<
CultivateRecord
>
implements
CultivateRecordDao
{
@Override
public
Integer
getEnergyConsumptionAfter
(
Long
cultivateRecordId
,
Long
wechatUserId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateRecordId"
,
cultivateRecordId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getEnergyConsumptionAfter"
),
map
);
}
@Override
public
CultivateRecord
getLastEnergyConsumptionRecord
(
Long
wechatUserId
,
Long
cultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getLastEnergyConsumptionRecord"
),
map
);
}
@Override
public
Integer
getUserGatherFishBallCount
(
Long
wechatUserId
,
Long
cultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getUserGatherFishBallCount"
),
map
);
}
@Override
public
CultivateRecord
getLastLighten
(
Long
wechatUserId
,
Long
cultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getLastLighten"
),
map
);
}
@Override
public
CultivateRecord
getLastEnergyConsumptionBefore
(
Long
cultivateRecordId
,
Long
wechatUserId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateRecordId"
,
cultivateRecordId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getLastEnergyConsumptionBefore"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateRobotClassifyDaoImpl.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateRobotClassifyDao
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
@Component
(
"cultivateRobotClassifyDao"
)
public
class
CultivateRobotClassifyDaoImpl
extends
BaseDaoImpl
<
CultivateRobotClassify
>
implements
CultivateRobotClassifyDao
{
@Override
public
CultivateRobotClassify
getByCondition
(
Long
wechatUserId
,
Long
cultivateId
,
Long
robotClassifyId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"robotClassifyId"
,
robotClassifyId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getByCondition"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/CreateCultivateDTO.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
CreateCultivateDTO
{
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/EnergyConsumptionDTO.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
EnergyConsumptionDTO
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"消耗的能量数"
)
private
Integer
energy
;
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/EnergyConsumptionDelayDTO.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
EnergyConsumptionDelayDTO
implements
Serializable
{
@ApiModelProperty
(
"养成记录id"
)
private
Long
cultivateRecordId
;
@ApiModelProperty
(
"此次延时能量"
)
private
Integer
energy
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/FishBallConversionDTO.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
FishBallConversionDTO
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"消耗的鱼丸数"
)
private
Integer
fishBall
;
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/FishBallPickDTO.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
FishBallPickDTO
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"摘取的鱼丸数"
)
private
Integer
fishBall
;
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/SkillUseDTO.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
SkillUseDTO
{
@ApiModelProperty
(
"用户微信id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"使用技能"
)
private
Integer
skillType
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/Cultivate.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"小睿养成"
)
public
class
Cultivate
extends
BaseEntity
{
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"能量"
)
private
Integer
energy
;
@ApiModelProperty
(
"鱼丸"
)
private
Integer
fishBall
;
@ApiModelProperty
(
"星星"
)
private
Integer
star
;
@ApiModelProperty
(
"是否点亮"
)
private
Boolean
lighten
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateRecord.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 小睿养成记录
*/
@Data
@ApiModel
(
"小睿养成记录"
)
public
class
CultivateRecord
extends
BaseEntity
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"动态类型(1鱼丸获取2点亮3熄灭4升级5使用能量值6使用技能7鱼丸兑换星星)"
)
private
Integer
changeType
;
@ApiModelProperty
(
"备注信息"
)
private
String
remark
;
@ApiModelProperty
(
"能量变化"
)
private
Integer
energyChange
;
@ApiModelProperty
(
"鱼丸变化"
)
private
Integer
fishBallChange
;
@ApiModelProperty
(
"鱼丸变化类型:1用户自己收,2熄灯之后系统自动收取"
)
private
Integer
fishBallChangeType
;
@ApiModelProperty
(
"星星变化"
)
private
Integer
starChange
;
@ApiModelProperty
(
"使用技能类型"
)
private
Integer
skillType
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateRobotClassify.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"小睿养成"
)
public
class
CultivateRobotClassify
extends
BaseEntity
{
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"机器人分类id"
)
private
Long
robotClassifyId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/enums/CultivateChangeTypeEnum.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
enums
;
public
enum
CultivateChangeTypeEnum
{
//1鱼丸获取2点亮3熄灭4升级5使用能量值6使用技能7鱼丸兑换星星
/**
* 鱼丸获取
*/
GET_FISH_BALL
(
1
,
"鱼丸获取"
),
/**
* 点亮
*/
LIGHTEN
(
2
,
"点亮"
),
/**
* 熄灭
*/
QUENCH
(
3
,
"熄灭"
),
/**
* 升级
*/
UPGRADE
(
4
,
"升级"
),
/**
* 使用能量值
*/
USE_ENERGY
(
5
,
"使用能量值"
),
/**
* 使用技能
*/
USE_SKILL
(
6
,
"使用技能"
),
/**
* 鱼丸兑换星星
*/
FISH_BALL_CONVERT_STAR
(
7
,
"鱼丸兑换星星"
);
public
final
Integer
code
;
public
final
String
name
;
CultivateChangeTypeEnum
(
Integer
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
static
String
getNameByCode
(
Integer
code
)
{
if
(
code
==
null
)
{
return
null
;
}
CultivateChangeTypeEnum
[]
all
=
values
();
int
length
=
all
.
length
;
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
CultivateChangeTypeEnum
cultivateChangeTypeEnum
=
all
[
i
];
if
(
cultivateChangeTypeEnum
.
code
.
equals
(
code
))
{
return
cultivateChangeTypeEnum
.
name
;
}
}
return
null
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/enums/CultivateSkillTypeEnum.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
enums
;
public
enum
CultivateSkillTypeEnum
{
/**
* 打招呼
*/
SAY_HI
(
1
,
"打招呼"
),
/**
* 唱歌
*/
SING
(
2
,
"唱歌"
),
/**
* 爱读书
*/
READ
(
3
,
"爱读书"
);
public
final
Integer
code
;
public
final
String
name
;
CultivateSkillTypeEnum
(
Integer
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
static
String
getNameByCode
(
Integer
code
)
{
if
(
code
==
null
)
{
return
null
;
}
CultivateSkillTypeEnum
[]
all
=
values
();
int
length
=
all
.
length
;
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
CultivateSkillTypeEnum
cultivateSkillTypeEnum
=
all
[
i
];
if
(
cultivateSkillTypeEnum
.
code
.
equals
(
code
))
{
return
cultivateSkillTypeEnum
.
name
;
}
}
return
null
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/enums/FishBallChangeTypeEnum.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
enums
;
public
enum
FishBallChangeTypeEnum
{
/**
* 1用户自己收
*/
USER_CHANGE
(
1
),
/**
* 2熄灯之后系统自动收取
*/
AUTO_CHANGE
(
2
);
public
final
Integer
value
;
FishBallChangeTypeEnum
(
Integer
value
)
{
this
.
value
=
value
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/facade/CultivateFacade.java
0 → 100644
View file @
7f8997b0
package
com
.
pcloud
.
book
.
cultivate
.
facade
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.cultivate.biz.CultivateBiz
;
import
com.pcloud.book.cultivate.dto.CreateCultivateDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.permission.PermissionException
;
import
com.pcloud.common.utils.NumberUtil
;
import
com.pcloud.common.utils.cookie.Cookie
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@Api
(
"养成"
)
@RestController
(
"cultivateFacade"
)
@RequestMapping
(
"cultivate"
)
public
class
CultivateFacade
{
@Autowired
private
CultivateBiz
cultivateBiz
;
@ApiOperation
(
"新增养成"
)
@PostMapping
(
"/createCultivate"
)
public
ResponseDto
<?>
createCultivate
(
@RequestBody
CreateCultivateDTO
createCultivateDTO
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
createCultivate
(
createCultivateDTO
));
}
@ApiOperation
(
"获取养成"
)
@GetMapping
(
"/getCultivate"
)
public
ResponseDto
<?>
getCultivate
(
@RequestParam
(
"wechatUserId"
)
@ApiParam
(
"用户id"
)
Long
wechatUserId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
getCultivate
(
wechatUserId
));
}
@ApiOperation
(
"新增养成分类关联"
)
@PostMapping
(
"/createCultivateRobotClassify"
)
public
ResponseDto
<?>
createCultivateRobotClassify
(
@RequestBody
@ApiParam
(
"养成分类关联"
)
CultivateRobotClassify
cultivateRobotClassify
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
createCultivateRobotClassify
(
cultivateRobotClassify
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"能量消耗"
)
@PostMapping
(
"/energyConsumption"
)
public
ResponseDto
<?>
getCultivate
(
@RequestBody
@ApiParam
(
"养成分类关联"
)
EnergyConsumptionDTO
energyConsumptionDTO
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
energyConsumption
(
energyConsumptionDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"鱼丸兑换"
)
@PostMapping
(
"/fishBallConversion"
)
public
ResponseDto
<?>
fishBallConversion
(
@RequestBody
@ApiParam
(
"鱼丸兑换"
)
FishBallConversionDTO
fishBallConversionDTO
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
fishBallConversion
(
fishBallConversionDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"新增技能使用记录"
)
@PostMapping
(
"/addUseSkillRecord"
)
public
ResponseDto
<?>
addUseSkillRecord
(
@RequestBody
@ApiParam
(
"鱼丸兑换"
)
SkillUseDTO
skillUseDTO
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
skillUseDTO
.
getWechatUserId
();
cultivateBiz
.
addUseSkillRecord
(
wechatUserId
,
skillUseDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"鱼丸摘取"
)
@PostMapping
(
"/fishBallPick"
)
public
ResponseDto
<?>
fishBallPick
(
@RequestBody
@ApiParam
(
"鱼丸摘取"
)
FishBallPickDTO
fishBallPickDTO
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
fishBallPick
(
fishBallPickDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"待摘取鱼丸数量获取"
)
@GetMapping
(
"/getFishBallNotPick"
)
public
ResponseDto
<?>
getFishBallNotPick
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
getFishBallNotPick
(
cultivateId
));
}
@ApiOperation
(
"获取动态记录列表"
)
@GetMapping
(
"/getCultivateRecordList"
)
public
ResponseDto
<?>
getCultivateRecordList
(
@RequestParam
Long
wechatUserId
,
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
,
@RequestParam
(
value
=
"currentPage"
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
"numPerPage"
,
required
=
false
)
Integer
numPerPage
)
throws
BizException
,
PermissionException
{
if
(
currentPage
==
null
||
numPerPage
==
null
||
currentPage
<
0
||
numPerPage
<
0
)
{
throw
BookBizException
.
PAGE_PARAM_DELETION
;
}
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateBiz
.
getCultivateRecordList
(
cultivateId
,
wechatUserId
,
currentPage
,
numPerPage
));
}
@ApiOperation
(
"获取陪伴天数"
)
@GetMapping
(
"/getLoginDays"
)
public
ResponseDto
<?>
getLoginDays
(
@RequestParam
Long
wechatUserId
){
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateBiz
.
getLoginDays
(
wechatUserId
));
}
@ApiOperation
(
"获取排名"
)
@GetMapping
(
"/getRanking"
)
public
ResponseDto
<?>
getRanking
(
@RequestParam
Long
wechatUserId
){
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateBiz
.
getRanking
(
wechatUserId
));
}
@ApiOperation
(
"分享"
)
@GetMapping
(
"shareMedal"
)
public
ResponseDto
<?>
shareMedal
(
@RequestParam
Long
wechatUserId
){
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateBiz
.
shareMedal
(
wechatUserId
));
}
@ApiOperation
(
"获取剩余亮灯时间"
)
@GetMapping
(
"/getResidueLightTime"
)
public
ResponseDto
<?>
getResidueLightTime
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
getResidueLightTime
(
cultivateId
));
}
}
pcloud-service-book/src/main/java/com/pcloud/book/mq/delay/DelayReceiver.java
View file @
7f8997b0
...
...
@@ -2,6 +2,8 @@ package com.pcloud.book.mq.delay;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pcloud.book.cultivate.biz.CultivateBiz
;
import
com.pcloud.book.cultivate.constant.CultivateConstant
;
import
com.pcloud.book.personalstage.biz.PersonalStageBiz
;
import
com.pcloud.book.personalstage.biz.PersonalStageJumpBiz
;
import
com.pcloud.book.personalstage.constant.PersonalStageConstant
;
...
...
@@ -29,6 +31,8 @@ public class DelayReceiver {
private
PersonalStageBiz
personalStageBiz
;
@Autowired
private
PersonalStageJumpBiz
personalStageJumpBiz
;
@Autowired
private
CultivateBiz
cultivateBiz
;
@RabbitHandler
public
void
onMessage
(
DelayQueueDTO
dto
)
{
...
...
@@ -48,6 +52,8 @@ public class DelayReceiver {
personalStageJumpBiz
.
delayProgress
(
dto
);
}
else
if
(
PersonalStageConstant
.
PERSONALSTAGE_DELAY_PAPER
.
equalsIgnoreCase
(
dto
.
getType
()))
{
personalStageJumpBiz
.
delayPaper
(
dto
);
}
else
if
(
CultivateConstant
.
ENERGY_CONSUMPTION_DELAY
.
equals
(
dto
.
getType
()))
{
cultivateBiz
.
dealDelayEnergyConsumption
(
dto
);
}
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/personal/facade/PersonalMedalFacade.java
View file @
7f8997b0
...
...
@@ -42,8 +42,7 @@ public class PersonalMedalFacade {
@ApiOperation
(
"获取用户已获得的勋章"
)
@GetMapping
(
"getUserMedalListCount"
)
public
ResponseDto
<?>
getUserMedalListCount
(
@CookieValue
(
"userInfo"
)
String
userInfo
)
throws
PermissionException
{
Long
wechatUserId
=
Cookie
.
getId
(
userInfo
,
Cookie
.
_WECHAT_USER_ID
);
public
ResponseDto
<?>
getUserMedalListCount
(
@RequestParam
Long
wechatUserId
)
throws
PermissionException
{
if
(!
NumberUtil
.
isNumber
(
wechatUserId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"wechatUserId 不能为空"
);
}
...
...
pcloud-service-book/src/main/resources/mapper/cultivate/Cultivate.xml
0 → 100644
View file @
7f8997b0
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.cultivate.dao.impl.CultivateDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.Cultivate"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"wechat_user_id"
property=
"wechatUserId"
jdbcType=
"BIGINT"
/>
<result
column=
"energy"
property=
"energy"
jdbcType=
"INTEGER"
/>
<result
column=
"fish_ball"
property=
"fishBall"
jdbcType=
"INTEGER"
/>
<result
column=
"star"
property=
"star"
jdbcType=
"INTEGER"
/>
<result
column=
"lighten"
property=
"lighten"
jdbcType=
"BOOLEAN"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, wechat_user_id, energy, fish_ball, star, lighten, create_time,update_time
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.Cultivate"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into cultivate
(
wechat_user_id,
energy,
fish_ball,
star,
lighten,
create_time,
update_time
)
values (
#{wechatUserId},
#{energy},
#{fishBall},
#{star},
#{lighten},
NOW(),
NOW()
)
</insert>
<update
id=
"update"
parameterType=
"com.pcloud.book.cultivate.entity.Cultivate"
>
update cultivate
<set>
<if
test=
"wechatUserId != null"
>
wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
</if>
<if
test=
"energy != null"
>
energy = #{energy,jdbcType=INTEGER},
</if>
<if
test=
"fishBall != null"
>
fish_ball = #{fishBall,jdbcType=INTEGER},
</if>
<if
test=
"star != null"
>
star = #{star,jdbcType=INTEGER},
</if>
<if
test=
"lighten != null"
>
lighten = #{lighten,jdbcType=BOOLEAN},
</if>
update_time=NOW()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"getById"
parameterType=
"long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
cultivate
where id=#{id}
</select>
<select
id=
"getByWechatUserId"
parameterType=
"long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
cultivate
where wechat_user_id=#{wechatUserId}
limit 1
</select>
<select
id=
"getAllOrderByStar"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
cultivate order by star desc
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateRecord.xml
0 → 100644
View file @
7f8997b0
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.cultivate.dao.impl.CultivateRecordDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.CultivateRecord"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"cultivate_id"
property=
"cultivateId"
jdbcType=
"BIGINT"
/>
<result
column=
"wechat_user_id"
property=
"wechatUserId"
jdbcType=
"BIGINT"
/>
<result
column=
"change_type"
property=
"changeType"
jdbcType=
"INTEGER"
/>
<result
column=
"remark"
property=
"remark"
jdbcType=
"VARCHAR"
/>
<result
column=
"energy_change"
property=
"energyChange"
jdbcType=
"INTEGER"
/>
<result
column=
"fish_ball_change"
property=
"fishBallChange"
jdbcType=
"INTEGER"
/>
<result
column=
"fish_ball_change_type"
property=
"fishBallChangeType"
jdbcType=
"INTEGER"
/>
<result
column=
"star_change"
property=
"starChange"
jdbcType=
"INTEGER"
/>
<result
column=
"skill_type"
property=
"skillType"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, cultivate_id, wechat_user_id, change_type, remark, energy_change, fish_ball_change, fish_ball_change_type, star_change, skill_type, create_time
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateRecord"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into cultivate_record (cultivate_id, wechat_user_id, change_type,
remark, energy_change, fish_ball_change, fish_ball_change_type,star_change, skill_type, create_time
)
values (#{cultivateId},#{wechatUserId},#{changeType},#{remark},#{energyChange},#{fishBallChange},#{fishBallChangeType},
#{starChange}, #{skillType}, NOW()
)
</insert>
<select
id=
"getById"
parameterType=
"long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
cultivate_record
where id=#{id}
</select>
<select
id=
"getEnergyConsumptionAfter"
parameterType=
"map"
resultType=
"integer"
>
select -ifnull(sum(energy_change),0) from
cultivate_record
where id>#{cultivateRecordId}
and wechat_user_id=#{wechatUserId}
and change_type=5
</select>
<select
id=
"getLastEnergyConsumptionRecord"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_record
where cultivate_id=#{cultivateId}
and wechat_user_id=#{wechatUserId}
order by create_time desc
limit 1
</select>
<select
id=
"getUserGatherFishBallCount"
parameterType=
"map"
resultType=
"integer"
>
SELECT
IFNULL(SUM(t2.fish_ball_change), 0)
FROM
cultivate_record t2
WHERE
t2.id > (
SELECT
t.id
FROM
cultivate_record t
WHERE
t.change_type = 2
AND t.wechat_user_id = #{wechatUserId}
AND t.cultivate_id = #{cultivateId}
ORDER BY
create_time DESC
LIMIT 1
)
AND t2.change_type = 1
AND t2.wechat_user_id = #{wechatUserId}
AND t2.cultivate_id = #{cultivateId}
</select>
<select
id=
"getCultivateRecordList"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_record
where cultivate_id=#{cultivateId}
and wechat_user_id=#{wechatUserId}
order by create_time desc,id desc
</select>
<select
id=
"getLastLighten"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM
cultivate_record t
WHERE
t.change_type = 2
AND t.wechat_user_id = #{wechatUserId}
AND t.cultivate_id = #{cultivateId}
ORDER BY
create_time DESC
LIMIT 1
</select>
<select
id=
"getLastEnergyConsumptionBefore"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_record
where wechat_user_id=#{wechatUserId}
and id
<
#{cultivateRecordId}
and change_type=5
order by create_time desc
limit 1
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateRobotClassify.xml
0 → 100644
View file @
7f8997b0
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pcloud.book.cultivate.dao.impl.CultivateRobotClassifyDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.CultivateRobotClassify"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"wechat_user_id"
property=
"wechatUserId"
jdbcType=
"BIGINT"
/>
<result
column=
"cultivate_id"
property=
"cultivateId"
jdbcType=
"BIGINT"
/>
<result
column=
"robot_classify_id"
property=
"robotClassifyId"
jdbcType=
"BIGINT"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, wechat_user_id, cultivate_id, robot_classify_id, create_time
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateRobotClassify"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into cultivate_robot_classify
(
wechat_user_id,
cultivate_id,
robot_classify_id,
create_time
)
values (
#{wechatUserId},
#{cultivateId},
#{robotClassifyId},
NOW()
)
</insert>
<select
id=
"getByCondition"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_robot_classify
where 1=1
<if
test=
"wechatUserId!=null"
>
and wechat_user_id=#{wechatUserId}
</if>
<if
test=
"cultivateId!=null"
>
and cultivate_id=#{cultivateId}
</if>
<if
test=
"robotClassifyId!=null"
>
and robot_classify_id=#{robotClassifyId}
</if>
</select>
</mapper>
\ 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