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
2585a8e1
Commit
2585a8e1
authored
Apr 08, 2020
by
阮思源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1002623小睿好友
parent
8d9b72d2
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
1278 additions
and
64 deletions
+1278
-64
BookBiz.java
...-book/src/main/java/com/pcloud/book/book/biz/BookBiz.java
+2
-0
BookBizImpl.java
.../main/java/com/pcloud/book/book/biz/impl/BookBizImpl.java
+19
-0
BookFacade.java
...src/main/java/com/pcloud/book/book/facade/BookFacade.java
+8
-0
BookFacadeImpl.java
...java/com/pcloud/book/book/facade/impl/BookFacadeImpl.java
+12
-0
CultivateBiz.java
...main/java/com/pcloud/book/cultivate/biz/CultivateBiz.java
+28
-0
CultivateBizImpl.java
.../com/pcloud/book/cultivate/biz/impl/CultivateBizImpl.java
+648
-35
CultivateConstant.java
...com/pcloud/book/cultivate/constant/CultivateConstant.java
+4
-0
CultivateDao.java
...main/java/com/pcloud/book/cultivate/dao/CultivateDao.java
+6
-0
CultivateHoldSeatDao.java
...a/com/pcloud/book/cultivate/dao/CultivateHoldSeatDao.java
+17
-0
CultivateRecordDao.java
...ava/com/pcloud/book/cultivate/dao/CultivateRecordDao.java
+3
-1
CultivateDaoImpl.java
.../com/pcloud/book/cultivate/dao/impl/CultivateDaoImpl.java
+25
-0
CultivateHoldSeatDaoImpl.java
...oud/book/cultivate/dao/impl/CultivateHoldSeatDaoImpl.java
+45
-0
CultivateRecordDaoImpl.java
...cloud/book/cultivate/dao/impl/CultivateRecordDaoImpl.java
+9
-0
CultivateDTO.java
...main/java/com/pcloud/book/cultivate/dto/CultivateDTO.java
+41
-0
DealHoldSeatFriendFishBallDTO.java
...oud/book/cultivate/dto/DealHoldSeatFriendFishBallDTO.java
+20
-0
FriendDTO.java
...rc/main/java/com/pcloud/book/cultivate/dto/FriendDTO.java
+22
-0
GiveEnergyDTO.java
...ain/java/com/pcloud/book/cultivate/dto/GiveEnergyDTO.java
+17
-0
HoldSeatDTO.java
.../main/java/com/pcloud/book/cultivate/dto/HoldSeatDTO.java
+16
-0
HoldTimeDTO.java
.../main/java/com/pcloud/book/cultivate/dto/HoldTimeDTO.java
+26
-0
Cultivate.java
...main/java/com/pcloud/book/cultivate/entity/Cultivate.java
+11
-2
CultivateHoldSeat.java
...a/com/pcloud/book/cultivate/entity/CultivateHoldSeat.java
+20
-0
CultivateRecord.java
...ava/com/pcloud/book/cultivate/entity/CultivateRecord.java
+7
-4
CultivateChangeTypeEnum.java
.../pcloud/book/cultivate/enums/CultivateChangeTypeEnum.java
+44
-5
FishBallChangeTypeEnum.java
...m/pcloud/book/cultivate/enums/FishBallChangeTypeEnum.java
+13
-1
CultivateFacade.java
...ava/com/pcloud/book/cultivate/facade/CultivateFacade.java
+86
-8
ThreadPoolUtils.java
...ain/java/com/pcloud/book/util/common/ThreadPoolUtils.java
+11
-0
application.yml
pcloud-service-book/src/main/resources/application.yml
+2
-2
Cultivate.xml
...ce-book/src/main/resources/mapper/cultivate/Cultivate.xml
+41
-3
CultivateHoldSeat.xml
...src/main/resources/mapper/cultivate/CultivateHoldSeat.xml
+62
-0
CultivateRecord.xml
...k/src/main/resources/mapper/cultivate/CultivateRecord.xml
+13
-3
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/BookBiz.java
View file @
2585a8e1
...
@@ -632,4 +632,6 @@ public interface BookBiz {
...
@@ -632,4 +632,6 @@ public interface BookBiz {
* 根据isbn模糊匹配,获得所有book_id
* 根据isbn模糊匹配,获得所有book_id
*/
*/
List
<
Long
>
getBookIdsByIsbn
(
String
isbn
);
List
<
Long
>
getBookIdsByIsbn
(
String
isbn
);
BookDto
getAdviserBook
(
Long
bookId
,
Long
adviserId
,
Long
channelId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/impl/BookBizImpl.java
View file @
2585a8e1
...
@@ -1985,6 +1985,25 @@ public class BookBizImpl implements BookBiz {
...
@@ -1985,6 +1985,25 @@ public class BookBizImpl implements BookBiz {
return
pageBeanNew
;
return
pageBeanNew
;
}
}
@ParamLog
(
"获取书刊"
)
@Override
public
BookDto
getAdviserBook
(
Long
bookId
,
Long
adviserId
,
Long
channelId
)
{
if
(
bookId
==
null
||
adviserId
==
null
||
channelId
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"参数有误"
);
}
Map
<
String
,
Object
>
paramMap
=
Maps
.
newHashMap
();
paramMap
.
put
(
"bookId"
,
bookId
);
paramMap
.
put
(
"adviserId"
,
adviserId
);
paramMap
.
put
(
"channelId"
,
channelId
);
BookDto
bookDto
=
bookDao
.
getById
(
paramMap
);
if
(
bookDto
==
null
)
{
return
new
BookDto
();
}
// 设置模板名字
bookSet
.
setTemplateName
(
bookDto
);
return
bookDto
;
}
@ParamLog
(
"填充书刊信息"
)
@ParamLog
(
"填充书刊信息"
)
private
void
fillBookInfo
(
List
<
BookDto
>
list
)
{
private
void
fillBookInfo
(
List
<
BookDto
>
list
)
{
if
(
ListUtils
.
isEmpty
(
list
)){
if
(
ListUtils
.
isEmpty
(
list
)){
...
...
pcloud-service-book/src/main/java/com/pcloud/book/book/facade/BookFacade.java
View file @
2585a8e1
...
@@ -712,4 +712,12 @@ public interface BookFacade {
...
@@ -712,4 +712,12 @@ public interface BookFacade {
@RequestParam
(
value
=
"startDate"
,
required
=
false
)
@ApiParam
(
"开始日期"
)
String
startDate
,
@RequestParam
(
value
=
"startDate"
,
required
=
false
)
@ApiParam
(
"开始日期"
)
String
startDate
,
@RequestParam
(
value
=
"endDate"
,
required
=
false
)
@ApiParam
(
"结束日期"
)
String
endDate
@RequestParam
(
value
=
"endDate"
,
required
=
false
)
@ApiParam
(
"结束日期"
)
String
endDate
)
throws
PermissionException
,
JsonParseException
,
BizException
;
)
throws
PermissionException
,
JsonParseException
,
BizException
;
@ApiOperation
(
"获取书刊"
)
@GetMapping
(
"getAdviserBook"
)
ResponseDto
<?>
getAdviserBook
(
@RequestParam
(
value
=
"bookId"
)
Long
bookId
,
@RequestParam
(
value
=
"adviserId"
)
Long
adviserId
,
@RequestParam
(
value
=
"channelId"
)
Long
channelId
)
throws
BizException
,
PermissionException
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/book/facade/impl/BookFacadeImpl.java
View file @
2585a8e1
...
@@ -978,4 +978,15 @@ public class BookFacadeImpl implements BookFacade {
...
@@ -978,4 +978,15 @@ public class BookFacadeImpl implements BookFacade {
PageBeanNew
<
BookDto
>
pageBean
=
bookBiz
.
getBookAndServeList4Channel
(
currentPage
,
numPerPage
,
channelId
,
name
,
isFundSupport
,
startDate
,
endDate
);
PageBeanNew
<
BookDto
>
pageBean
=
bookBiz
.
getBookAndServeList4Channel
(
currentPage
,
numPerPage
,
channelId
,
name
,
isFundSupport
,
startDate
,
endDate
);
return
new
ResponseDto
<>(
pageBean
);
return
new
ResponseDto
<>(
pageBean
);
}
}
@ApiOperation
(
"获取书刊"
)
@GetMapping
(
"getAdviserBook"
)
@Override
public
ResponseDto
<?>
getAdviserBook
(
@RequestParam
(
value
=
"bookId"
)
Long
bookId
,
@RequestParam
(
value
=
"adviserId"
)
Long
adviserId
,
@RequestParam
(
value
=
"channelId"
)
Long
channelId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
bookBiz
.
getAdviserBook
(
bookId
,
adviserId
,
channelId
));
}
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/biz/CultivateBiz.java
View file @
2585a8e1
...
@@ -2,9 +2,13 @@ package com.pcloud.book.cultivate.biz;
...
@@ -2,9 +2,13 @@ package com.pcloud.book.cultivate.biz;
import
com.pcloud.book.book.vo.SearchBookVO
;
import
com.pcloud.book.book.vo.SearchBookVO
;
import
com.pcloud.book.cultivate.dto.CreateCultivateDTO
;
import
com.pcloud.book.cultivate.dto.CreateCultivateDTO
;
import
com.pcloud.book.cultivate.dto.CultivateDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.FriendDTO
;
import
com.pcloud.book.cultivate.dto.GiveEnergyDTO
;
import
com.pcloud.book.cultivate.dto.HoldSeatDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
...
@@ -54,4 +58,28 @@ public interface CultivateBiz {
...
@@ -54,4 +58,28 @@ public interface CultivateBiz {
CultivateBookUser
getLastCultivateBookUser
(
Long
wechatUserId
);
CultivateBookUser
getLastCultivateBookUser
(
Long
wechatUserId
);
PageBeanNew
<
SearchBookVO
>
getBookSearchRecord
(
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
PageBeanNew
<
SearchBookVO
>
getBookSearchRecord
(
Long
wechatUserId
,
Integer
currentPage
,
Integer
numPerPage
);
List
<
FriendDTO
>
getFriendList
(
Long
cultivateId
);
void
giveEnergy
(
GiveEnergyDTO
giveEnergyDTO
);
//占座
void
holdSeat
(
HoldSeatDTO
holdSeatDTO
);
//踢人
void
kickPeople
(
HoldSeatDTO
holdSeatDTO
);
//退出
Integer
signOut
(
HoldSeatDTO
holdSeatDTO
);
//找回 返回好友养成id
Long
getBack
(
Long
cultivateId
);
//占座好友
List
<
FriendDTO
>
getHoldSeatFriend
(
Long
cultivateId
);
//判断占座之前是否在学习中
Boolean
beforeHoldSeat
(
Long
cultivateId
);
CultivateDTO
getCultivateBaseInfo
(
Long
cultivateId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/biz/impl/CultivateBizImpl.java
View file @
2585a8e1
...
@@ -12,11 +12,24 @@ import com.pcloud.book.cultivate.biz.CultivateBiz;
...
@@ -12,11 +12,24 @@ import com.pcloud.book.cultivate.biz.CultivateBiz;
import
com.pcloud.book.cultivate.constant.CultivateConstant
;
import
com.pcloud.book.cultivate.constant.CultivateConstant
;
import
com.pcloud.book.cultivate.dao.CultivateBookUserDao
;
import
com.pcloud.book.cultivate.dao.CultivateBookUserDao
;
import
com.pcloud.book.cultivate.dao.CultivateDao
;
import
com.pcloud.book.cultivate.dao.CultivateDao
;
import
com.pcloud.book.cultivate.dao.CultivateHoldSeatDao
;
import
com.pcloud.book.cultivate.dao.CultivateRecordDao
;
import
com.pcloud.book.cultivate.dao.CultivateRecordDao
;
import
com.pcloud.book.cultivate.dao.CultivateRobotClassifyDao
;
import
com.pcloud.book.cultivate.dao.CultivateRobotClassifyDao
;
import
com.pcloud.book.cultivate.dto.*
;
import
com.pcloud.book.cultivate.dto.CreateCultivateDTO
;
import
com.pcloud.book.cultivate.dto.CultivateDTO
;
import
com.pcloud.book.cultivate.dto.DealHoldSeatFriendFishBallDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDelayDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.FriendDTO
;
import
com.pcloud.book.cultivate.dto.GiveEnergyDTO
;
import
com.pcloud.book.cultivate.dto.HoldSeatDTO
;
import
com.pcloud.book.cultivate.dto.HoldTimeDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.Cultivate
;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
import
com.pcloud.book.cultivate.entity.CultivateHoldSeat
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.cultivate.enums.CultivateChangeTypeEnum
;
import
com.pcloud.book.cultivate.enums.CultivateChangeTypeEnum
;
...
@@ -25,18 +38,17 @@ import com.pcloud.book.cultivate.enums.FishBallChangeTypeEnum;
...
@@ -25,18 +38,17 @@ import com.pcloud.book.cultivate.enums.FishBallChangeTypeEnum;
import
com.pcloud.book.mq.delay.DelayMessageSender
;
import
com.pcloud.book.mq.delay.DelayMessageSender
;
import
com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz
;
import
com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz
;
import
com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz
;
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.biz.PersonalMedalBiz
;
import
com.pcloud.book.personal.dao.PersonalMedalDao
;
import
com.pcloud.book.personal.dao.PersonalMedalDao
;
import
com.pcloud.book.personal.dao.PersonalMedalRecordDao
;
import
com.pcloud.book.personal.dao.PersonalMedalRecordDao
;
import
com.pcloud.book.personal.dto.PersonalMedalRecordDto
;
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.PersonalMedal
;
import
com.pcloud.book.personal.entity.PersonalMedalRecord
;
import
com.pcloud.book.personal.entity.PersonalMedalRecord
;
import
com.pcloud.book.personal.entity.PersonalShareTemplate
;
import
com.pcloud.book.personal.entity.PersonalShareTemplate
;
import
com.pcloud.book.personal.mapper.PersonalShareTemplateMapper
;
import
com.pcloud.book.personal.mapper.PersonalShareTemplateMapper
;
import
com.pcloud.book.util.common.ThreadPoolUtils
;
import
com.pcloud.book.util.common.YesOrNoEnums
;
import
com.pcloud.book.util.common.YesOrNoEnums
;
import
com.pcloud.common.constant.CacheConstant
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.mq.DelayQueueDTO
;
import
com.pcloud.common.core.mq.DelayQueueDTO
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
...
@@ -45,15 +57,26 @@ import com.pcloud.common.page.PageParam;
...
@@ -45,15 +57,26 @@ import com.pcloud.common.page.PageParam;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ResponseHandleUtil
;
import
com.pcloud.common.utils.ResponseHandleUtil
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.facade.shareimage.dto.HtmlDto
;
import
com.pcloud.facade.shareimage.dto.HtmlDto
;
import
com.pcloud.facade.shareimage.facade.Htm2ImgService
;
import
com.pcloud.facade.shareimage.facade.Htm2ImgService
;
import
com.pcloud.readercenter.wechat.entity.WechatUser
;
import
com.pcloud.readercenter.wechat.entity.WechatUser
;
import
org.apache.commons.collections.MapUtils
;
import
org.springframework.beans.BeanUtils
;
import
com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto
;
import
com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -101,6 +124,10 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -101,6 +124,10 @@ public class CultivateBizImpl implements CultivateBiz {
@Autowired
private
CultivateHoldSeatDao
cultivateHoldSeatDao
;
...
@@ -236,12 +263,12 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -236,12 +263,12 @@ public class CultivateBizImpl implements CultivateBiz {
CultivateRecord
last
=
cultivateRecordDao
.
getLastEnergyConsumptionRecord
(
wechatUserId
,
cultivateId
);
CultivateRecord
last
=
cultivateRecordDao
.
getLastEnergyConsumptionRecord
(
wechatUserId
,
cultivateId
);
addDelayEnergyConsumption
(
last
.
getId
(),
wechatUserId
,
afterEnergy
);
addDelayEnergyConsumption
(
last
.
getId
(),
wechatUserId
,
afterEnergy
);
}
else
{
}
else
{
//熄灯,收取
鱼丸
//熄灯,收取
银两
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
cultivate
.
setLighten
(
false
);
cultivate
.
setLighten
(
false
);
//查询用户点灯之后收取过的
鱼丸
数量
//查询用户点灯之后收取过的
银两
数量
Integer
userGatherFishBall
=
cultivateRecordDao
.
getUserGatherFishBallCount
(
wechatUserId
,
cultivateId
);
Integer
userGatherFishBall
=
cultivateRecordDao
.
getUserGatherFishBallCount
(
wechatUserId
,
cultivateId
);
//系统收取
鱼丸
//系统收取
银两
Integer
allEnergy
=
0
;
Integer
allEnergy
=
0
;
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
wechatUserId
,
cultivateId
);
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
wechatUserId
,
cultivateId
);
if
(
lastLighten
!=
null
){
if
(
lastLighten
!=
null
){
...
@@ -253,8 +280,13 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -253,8 +280,13 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
}
}
Integer
currentAdd
=
allEnergy
-
userGatherFishBall
;
Integer
currentAdd
=
allEnergy
-
userGatherFishBall
;
//减去被占座的部分之后
DealHoldSeatFriendFishBallDTO
deal
=
getHoldSeatFriendFishBall
(
cultivateId
,
currentAdd
,
lastLighten
.
getId
());
currentAdd
=
deal
.
getOwnHasFishBall
();
//占座好友分银两
dealStayFriendFishBall
(
deal
.
getFriendFishBallMap
(),
cultivateId
);
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
currentAdd
);
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
currentAdd
);
//产生收
鱼丸
记录
//产生收
银两
记录
CultivateRecord
hasFishBall
=
new
CultivateRecord
();
CultivateRecord
hasFishBall
=
new
CultivateRecord
();
hasFishBall
.
setCultivateId
(
cultivateId
);
hasFishBall
.
setCultivateId
(
cultivateId
);
hasFishBall
.
setWechatUserId
(
wechatUserId
);
hasFishBall
.
setWechatUserId
(
wechatUserId
);
...
@@ -272,8 +304,113 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -272,8 +304,113 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
}
}
@ParamLog
(
"获取被好友占座的能量值"
)
private
DealHoldSeatFriendFishBallDTO
getHoldSeatFriendFishBall
(
Long
cultivateId
,
Integer
currentHas
,
Long
lastLightenRecordId
){
//查询上次点灯之后被占座的记录集合
List
<
CultivateRecord
>
records
=
cultivateRecordDao
.
getHoldSeatFriendList
(
cultivateId
,
lastLightenRecordId
);
//开始记录
List
<
CultivateRecord
>
startRecords
=
records
.
stream
().
filter
(
s
->
CultivateChangeTypeEnum
.
HOLD_SEAT_BY_FRIEND
.
code
.
equals
(
s
.
getChangeType
())).
collect
(
Collectors
.
toList
());
//结束记录
List
<
CultivateRecord
>
endRecords
=
records
.
stream
().
filter
(
s
->
CultivateChangeTypeEnum
.
FRIEND_EXIT_SEAT
.
code
.
equals
(
s
.
getChangeType
())
||
CultivateChangeTypeEnum
.
KICK_OUT_FRIEND_BY_SELF
.
code
.
equals
(
s
.
getChangeType
())).
collect
(
Collectors
.
toList
());
DealHoldSeatFriendFishBallDTO
deal
=
new
DealHoldSeatFriendFishBallDTO
();
deal
.
setCultivateId
(
cultivateId
);
deal
.
setOwnHasFishBall
(
currentHas
);
if
(
ListUtils
.
isEmpty
(
records
)){
return
deal
;
}
List
<
HoldTimeDTO
>
holdTimeDTOS
=
new
ArrayList
<>();
Date
now
=
new
Date
();
List
<
Long
>
go
=
new
ArrayList
<>();
for
(
CultivateRecord
start:
startRecords
){
//获取开始
HoldTimeDTO
holdTimeDTO
=
new
HoldTimeDTO
();
holdTimeDTO
.
setStartHold
(
start
.
getCreateTime
());
holdTimeDTO
.
setFriendCultivateId
(
start
.
getFriendCultivateId
());
Date
endHold
=
null
;
//循环获取结束
for
(
CultivateRecord
end:
endRecords
){
if
(
end
.
getId
()>
start
.
getId
()&&
start
.
getFriendCultivateId
().
equals
(
end
.
getFriendCultivateId
())&&!
go
.
contains
(
end
.
getId
())){
endHold
=
end
.
getCreateTime
();
go
.
add
(
end
.
getId
());
break
;
}
}
if
(
endHold
==
null
){
holdTimeDTO
.
setEndHold
(
now
);
holdTimeDTO
.
setStay
(
true
);
}
else
{
holdTimeDTO
.
setEndHold
(
endHold
);
holdTimeDTO
.
setStay
(
false
);
}
//增加一组占位开始和结束时间
holdTimeDTOS
.
add
(
holdTimeDTO
);
}
Double
allFriendFishBall
=
0
D
;
Map
<
Long
,
Double
>
friendFishBallMap
=
new
HashMap
<>();
for
(
HoldTimeDTO
holdTimeDTO:
holdTimeDTOS
){
//一共呆的分钟数
Double
oneHoldSeatFishBall
=
(
holdTimeDTO
.
getEndHold
().
getTime
()
-
holdTimeDTO
.
getStartHold
().
getTime
())/(
1000
*
60
)*
CultivateConstant
.
HOLD_SEAT_PROPORTION
;
allFriendFishBall
=
allFriendFishBall
+
oneHoldSeatFishBall
;
//判断是否还在
if
(
holdTimeDTO
.
getStay
()){
Long
friendId
=
holdTimeDTO
.
getFriendCultivateId
();
if
(
friendFishBallMap
.
get
(
friendId
)==
null
){
friendFishBallMap
.
put
(
friendId
,
oneHoldSeatFishBall
);
}
else
{
Double
en
=
friendFishBallMap
.
get
(
friendId
);
en
=
en
+
oneHoldSeatFishBall
;
friendFishBallMap
.
put
(
friendId
,
en
);
}
}
}
deal
.
setOwnHasFishBall
(
currentHas
-
allFriendFishBall
.
intValue
());
deal
.
setFriendFishBallMap
(
friendFishBallMap
);
return
deal
;
}
@ParamLog
(
"给占座没走的好友分银两"
)
private
void
dealStayFriendFishBall
(
Map
<
Long
,
Double
>
friendFishBallMap
,
Long
cultivateId
){
//给没走的人分银两
if
(
friendFishBallMap
==
null
||
MapUtils
.
isEmpty
(
friendFishBallMap
)){
return
;
}
List
<
Long
>
stayFriendIds
=
new
ArrayList
<>(
friendFishBallMap
.
keySet
());
List
<
Cultivate
>
friendCultivates
=
cultivateDao
.
getByCultivateIds
(
stayFriendIds
);
Map
<
Long
,
Cultivate
>
friendCultivateMap
=
new
HashMap
<>();
for
(
Cultivate
friend:
friendCultivates
){
friendCultivateMap
.
put
(
friend
.
getId
(),
friend
);
}
for
(
Long
statFriendId:
stayFriendIds
){
Integer
fishBall
=
friendFishBallMap
.
get
(
statFriendId
).
intValue
();
Cultivate
friend
=
friendCultivateMap
.
get
(
statFriendId
);
if
(
friend
==
null
){
continue
;
}
friend
.
setFishBall
(
friend
.
getFishBall
()+
fishBall
);
//更新银两
cultivateDao
.
update
(
friend
);
CultivateRecord
record
=
new
CultivateRecord
();
record
.
setChangeType
(
CultivateChangeTypeEnum
.
GET_FISH_BALL
.
code
);
record
.
setFishBallChangeType
(
FishBallChangeTypeEnum
.
FRIEND_LIGHTS_OUT_CHANGE
.
value
);
record
.
setFishBallChange
(
fishBall
);
record
.
setCultivateId
(
statFriendId
);
record
.
setFriendCultivateId
(
cultivateId
);
record
.
setWechatUserId
(
friend
.
getWechatUserId
());
//分银两记录
createCultivateRecord
(
record
);
//好友灯熄灭记录
CultivateRecord
recordOut
=
new
CultivateRecord
();
recordOut
.
setChangeType
(
CultivateChangeTypeEnum
.
FRIEND_LIGHTS_OUT
.
code
);
recordOut
.
setCultivateId
(
statFriendId
);
recordOut
.
setFriendCultivateId
(
cultivateId
);
recordOut
.
setWechatUserId
(
friend
.
getWechatUserId
());
createCultivateRecord
(
recordOut
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"
鱼丸
兑换"
)
@ParamLog
(
"
银两
兑换"
)
@Override
@Override
public
void
fishBallConversion
(
FishBallConversionDTO
fishBallConversionDTO
)
{
public
void
fishBallConversion
(
FishBallConversionDTO
fishBallConversionDTO
)
{
if
(
fishBallConversionDTO
==
null
){
if
(
fishBallConversionDTO
==
null
){
...
@@ -283,7 +420,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -283,7 +420,7 @@ public class CultivateBizImpl implements CultivateBiz {
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成id为空!"
);
}
}
if
(
fishBallConversionDTO
.
getFishBall
()==
null
){
if
(
fishBallConversionDTO
.
getFishBall
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
鱼丸
为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
银两
为空!"
);
}
}
if
(
fishBallConversionDTO
.
getWechatUserId
()==
null
){
if
(
fishBallConversionDTO
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
...
@@ -294,13 +431,13 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -294,13 +431,13 @@ public class CultivateBizImpl implements CultivateBiz {
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有养成!"
);
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有养成!"
);
}
}
if
(
cultivate
.
getFishBall
()<
fishBallConversionDTO
.
getFishBall
()){
if
(
cultivate
.
getFishBall
()<
fishBallConversionDTO
.
getFishBall
()){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"
鱼丸不足,当前只有"
+
cultivate
.
getFishBall
()+
"鱼丸
"
);
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"
银两不足,当前只有"
+
cultivate
.
getFishBall
()+
"银两
"
);
}
}
if
(
fishBallConversionDTO
.
getFishBall
()%
100
!=
0
){
if
(
fishBallConversionDTO
.
getFishBall
()%
100
!=
0
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"请使用100的倍数"
);
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"请使用100的倍数"
);
}
}
//插入
鱼丸
兑换记录
//插入
银两
兑换记录
CultivateRecord
convertFishBall
=
new
CultivateRecord
();
CultivateRecord
convertFishBall
=
new
CultivateRecord
();
convertFishBall
.
setWechatUserId
(
wechatUserId
);
convertFishBall
.
setWechatUserId
(
wechatUserId
);
convertFishBall
.
setChangeType
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
);
convertFishBall
.
setChangeType
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
);
...
@@ -308,7 +445,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -308,7 +445,7 @@ public class CultivateBizImpl implements CultivateBiz {
convertFishBall
.
setFishBallChange
(-
fishBallConversionDTO
.
getFishBall
());
convertFishBall
.
setFishBallChange
(-
fishBallConversionDTO
.
getFishBall
());
convertFishBall
.
setStarChange
(
fishBallConversionDTO
.
getFishBall
()/
100
);
convertFishBall
.
setStarChange
(
fishBallConversionDTO
.
getFishBall
()/
100
);
createCultivateRecord
(
convertFishBall
);
createCultivateRecord
(
convertFishBall
);
//先插入记录在更新养成表
星星
数
//先插入记录在更新养成表
书币
数
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()-
fishBallConversionDTO
.
getFishBall
());
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()-
fishBallConversionDTO
.
getFishBall
());
cultivate
.
setStar
(
cultivate
.
getStar
()+
fishBallConversionDTO
.
getFishBall
()/
100
);
cultivate
.
setStar
(
cultivate
.
getStar
()+
fishBallConversionDTO
.
getFishBall
()/
100
);
cultivateDao
.
update
(
cultivate
);
cultivateDao
.
update
(
cultivate
);
...
@@ -327,11 +464,12 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -327,11 +464,12 @@ public class CultivateBizImpl implements CultivateBiz {
if
(
cultivateRecord
.
getWechatUserId
()==
null
){
if
(
cultivateRecord
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
}
}
if
(
cultivateRecord
.
getChangeType
()==
null
){
Integer
changeType
=
cultivateRecord
.
getChangeType
();
if
(
changeType
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"动态类型为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"动态类型为空!"
);
}
}
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
GET_FISH_BALL
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
GET_FISH_BALL
.
code
)){
if
(
cultivateRecord
.
getFishBallChange
()==
null
){
if
(
cultivateRecord
.
getFishBallChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"银两数为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"银两数为空!"
);
...
@@ -342,16 +480,16 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -342,16 +480,16 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
cultivateRecord
.
setRemark
(
"获得了"
+
cultivateRecord
.
getFishBallChange
()+
"个银两"
);
cultivateRecord
.
setRemark
(
"获得了"
+
cultivateRecord
.
getFishBallChange
()+
"个银两"
);
}
}
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
LIGHTEN
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
LIGHTEN
.
code
)){
cultivateRecord
.
setRemark
(
"灯已点亮,我有吃的了!"
);
cultivateRecord
.
setRemark
(
"灯已点亮,我有吃的了!"
);
}
}
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
QUENCH
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
QUENCH
.
code
)){
cultivateRecord
.
setRemark
(
"灯已熄灭,我看不见了小主,点亮我吧!"
);
cultivateRecord
.
setRemark
(
"灯已熄灭,我看不见了小主,点亮我吧!"
);
}
}
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
USE_ENERGY
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
USE_ENERGY
.
code
)){
if
(
cultivateRecord
.
getEnergyChange
()==
null
){
if
(
cultivateRecord
.
getEnergyChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"能量值为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"能量值为空!"
);
}
}
...
@@ -364,7 +502,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -364,7 +502,7 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
}
}
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
USE_SKILL
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
USE_SKILL
.
code
)){
if
(
cultivateRecord
.
getSkillType
()==
null
){
if
(
cultivateRecord
.
getSkillType
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"技能类型为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"技能类型为空!"
);
}
}
...
@@ -373,14 +511,102 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -373,14 +511,102 @@ public class CultivateBizImpl implements CultivateBiz {
cultivateRecord
.
setRemark
(
"你使用了"
+
skill
+
"技能,请添加小睿为好友后,回复您想要定制阅读的书名吧"
);
cultivateRecord
.
setRemark
(
"你使用了"
+
skill
+
"技能,请添加小睿为好友后,回复您想要定制阅读的书名吧"
);
}
}
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
)){
if
(
cultivateRecord
.
getStarChange
()==
null
){
if
(
cultivateRecord
.
getStarChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
玉璧
数量为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
书币
数量为空!"
);
}
}
cultivateRecord
.
setRemark
(
"你已将"
+
cultivateRecord
.
getStarChange
()*
100
+
"个银两兑换了"
+
cultivateRecord
.
getStarChange
()+
"颗玉璧"
);
cultivateRecord
.
setRemark
(
"你已将"
+
cultivateRecord
.
getStarChange
()*
100
+
"个银两兑换了"
+
cultivateRecord
.
getStarChange
()+
"书币"
);
}
//赠送能量给好友
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
GIVE_ENERGY_TO_FRIEND
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
if
(
cultivateRecord
.
getEnergyChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"能量不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"赠送好友"
+
wechatUser
.
getWechatUserNickname
()+
cultivateRecord
.
getEnergyChange
()+
"个能量。"
);
}
//被好友赠送能量
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
GET_ENERGY_BY_FRIEND
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
if
(
cultivateRecord
.
getEnergyChange
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"能量不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"获得了好友"
+
wechatUser
.
getWechatUserNickname
()+
"赠送的"
+
cultivateRecord
.
getEnergyChange
()+
"个能量。"
);
}
//占好友座位
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
HOLD_FRIEND_SEAT
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"我到好友"
+
wechatUser
.
getWechatUserNickname
()+
"这里占座学习啦,主人记得收银两哦。"
);
}
//被好友占座
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
HOLD_SEAT_BY_FRIEND
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"好友"
+
wechatUser
.
getWechatUserNickname
()+
"过来抄作业了,赶紧阻止他。"
);
}
//退出好友座位
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
EXIT_FRIEND_SEAT
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"我退出了好友"
+
wechatUser
.
getWechatUserNickname
()+
"书房座位,获得了"
+
cultivateRecord
.
getFishBallChange
()+
"个银两"
);
cultivateRecord
.
setFishBallChange
(
null
);
}
//好友退出我的座位
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
FRIEND_EXIT_SEAT
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"好友"
+
wechatUser
.
getWechatUserNickname
()+
"退出了我的书房座位。"
);
}
//将好友踢出座位
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
KICK_OUT_FRIEND_BY_SELF
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"发现有人来抄作业,我将"
+
wechatUser
.
getWechatUserNickname
()+
"请出了我的书房。"
);
}
//被好友踢出座位
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
KICK_OUT_BY_FRIEND
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"占座被发现了,此处不留人,好友"
+
wechatUser
.
getWechatUserNickname
()+
"将我踢出了。"
);
}
//占座好友灯熄灭
if
(
changeType
.
equals
(
CultivateChangeTypeEnum
.
FRIEND_LIGHTS_OUT
.
code
)){
if
(
cultivateRecord
.
getFriendCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"好友养成id不能为空!"
);
}
Cultivate
friend
=
cultivateDao
.
getById
(
cultivateRecord
.
getFriendCultivateId
());
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
friend
.
getWechatUserId
());
cultivateRecord
.
setRemark
(
"好友"
+
wechatUser
.
getWechatUserNickname
()+
"灯已熄灭,主人快召回我吧。"
);
}
}
cultivateRecordDao
.
insert
(
cultivateRecord
);
cultivateRecordDao
.
insert
(
cultivateRecord
);
if
(
c
ultivateRecord
.
getChangeType
()
.
equals
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
)){
if
(
c
hangeType
.
equals
(
CultivateChangeTypeEnum
.
FISH_BALL_CONVERT_STAR
.
code
)){
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
cultivateRecord
.
getWechatUserId
());
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
cultivateRecord
.
getWechatUserId
());
Boolean
isUp
=
isUpGrade
(
cultivate
.
getStar
(),
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
());
Boolean
isUp
=
isUpGrade
(
cultivate
.
getStar
(),
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
());
Integer
newStarCount
=
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
();
Integer
newStarCount
=
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
();
...
@@ -391,9 +617,9 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -391,9 +617,9 @@ public class CultivateBizImpl implements CultivateBiz {
upGradeRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
UPGRADE
.
code
);
upGradeRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
UPGRADE
.
code
);
upGradeRecord
.
setCultivateId
(
cultivate
.
getId
());
upGradeRecord
.
setCultivateId
(
cultivate
.
getId
());
//插入领取的勋章
//插入领取的勋章
// 获取用户的
星星
数
// 获取用户的
书币
数
Integer
starCount
=
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
();
Integer
starCount
=
cultivate
.
getStar
()+
cultivateRecord
.
getStarChange
();
// 查询当前数量的
星星
可以领取的勋章(过滤掉已领取的)
// 查询当前数量的
书币
可以领取的勋章(过滤掉已领取的)
List
<
Long
>
medalIds
=
personalMedalDao
.
getReceivingMedal
(
cultivateRecord
.
getWechatUserId
(),
starCount
);
List
<
Long
>
medalIds
=
personalMedalDao
.
getReceivingMedal
(
cultivateRecord
.
getWechatUserId
(),
starCount
);
if
(!
ListUtils
.
isEmpty
(
medalIds
)){
if
(!
ListUtils
.
isEmpty
(
medalIds
)){
// 插入可以领取的记录
// 插入可以领取的记录
...
@@ -447,17 +673,17 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -447,17 +673,17 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"
鱼丸
摘取"
)
@ParamLog
(
"
银两
摘取"
)
@Override
@Override
public
void
fishBallPick
(
FishBallPickDTO
fishBallPickDTO
)
{
public
void
fishBallPick
(
FishBallPickDTO
fishBallPickDTO
)
{
if
(
fishBallPickDTO
==
null
){
if
(
fishBallPickDTO
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
鱼丸
摘取参数为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
银两
摘取参数为空!"
);
}
}
if
(
fishBallPickDTO
.
getCultivateId
()==
null
){
if
(
fishBallPickDTO
.
getCultivateId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成Id为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"养成Id为空!"
);
}
}
if
(
fishBallPickDTO
.
getFishBall
()==
null
){
if
(
fishBallPickDTO
.
getFishBall
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
鱼丸
数量为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"
银两
数量为空!"
);
}
}
if
(
fishBallPickDTO
.
getWechatUserId
()==
null
){
if
(
fishBallPickDTO
.
getWechatUserId
()==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"用户id为空!"
);
...
@@ -470,7 +696,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -470,7 +696,7 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
Integer
notPick
=
getFishBallNotPick
(
cultivateId
);
Integer
notPick
=
getFishBallNotPick
(
cultivateId
);
if
(
notPick
<=
0
){
if
(
notPick
<=
0
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有可摘取的
鱼丸
!"
);
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"没有可摘取的
银两
!"
);
}
}
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
fishBallPickDTO
.
getFishBall
());
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
fishBallPickDTO
.
getFishBall
());
cultivateDao
.
update
(
cultivate
);
cultivateDao
.
update
(
cultivate
);
...
@@ -483,7 +709,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -483,7 +709,7 @@ public class CultivateBizImpl implements CultivateBiz {
createCultivateRecord
(
cultivateRecord
);
createCultivateRecord
(
cultivateRecord
);
}
}
@ParamLog
(
"获取现有未摘取
鱼丸
"
)
@ParamLog
(
"获取现有未摘取
银两
"
)
@Override
@Override
public
Integer
getFishBallNotPick
(
Long
cultivateId
)
{
public
Integer
getFishBallNotPick
(
Long
cultivateId
)
{
if
(
cultivateId
==
null
){
if
(
cultivateId
==
null
){
...
@@ -503,11 +729,15 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -503,11 +729,15 @@ public class CultivateBizImpl implements CultivateBiz {
if
(
lastLighten
==
null
){
if
(
lastLighten
==
null
){
return
0
;
return
0
;
}
}
//一共产生的
鱼丸
//一共产生的
银两
Integer
proFishBall
=(
int
)(
new
Date
().
getTime
()-
lastLighten
.
getCreateTime
().
getTime
())/
1000
/
60
;
Integer
proFishBall
=(
int
)(
new
Date
().
getTime
()-
lastLighten
.
getCreateTime
().
getTime
())/
1000
/
60
;
//点亮期间已经摘取过的
语言
//点亮期间已经摘取过的
银两
Integer
gatherFishBallCount
=
cultivateRecordDao
.
getUserGatherFishBallCount
(
wechatUserId
,
cultivateId
);
Integer
gatherFishBallCount
=
cultivateRecordDao
.
getUserGatherFishBallCount
(
wechatUserId
,
cultivateId
);
return
proFishBall
-
gatherFishBallCount
;
//减去被占座的银两
Integer
fishBallNotPick
=
proFishBall
-
gatherFishBallCount
;
DealHoldSeatFriendFishBallDTO
fishBall
=
getHoldSeatFriendFishBall
(
cultivateId
,
fishBallNotPick
,
lastLighten
.
getId
());
fishBallNotPick
=
fishBall
.
getOwnHasFishBall
();
return
fishBallNotPick
;
}
}
@Override
@Override
...
@@ -662,6 +892,69 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -662,6 +892,69 @@ public class CultivateBizImpl implements CultivateBiz {
@ParamLog
(
"能量赠送"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
giveEnergy
(
GiveEnergyDTO
giveEnergyDTO
)
{
if
(
giveEnergyDTO
==
null
||
giveEnergyDTO
.
getCultivateId
()==
null
||
giveEnergyDTO
.
getFriendCultivateId
()==
null
||
giveEnergyDTO
.
getEnergy
()==
null
||
giveEnergyDTO
.
getEnergy
()<
0
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数错误!"
);
}
String
keyCh
;
if
(
giveEnergyDTO
.
getCultivateId
()>
giveEnergyDTO
.
getFriendCultivateId
()){
keyCh
=
giveEnergyDTO
.
getCultivateId
()+
"_"
+
giveEnergyDTO
.
getFriendCultivateId
();
}
else
{
keyCh
=
giveEnergyDTO
.
getFriendCultivateId
()+
"_"
+
giveEnergyDTO
.
getCultivateId
();
}
String
key
=
CacheConstant
.
BOOK
+
"GIVE_ENERGY"
+
keyCh
;
if
(
JedisClusterUtils
.
setnx
(
key
,
giveEnergyDTO
.
getCultivateId
().
toString
())){
JedisClusterUtils
.
expire
(
key
,
10
);
try
{
Cultivate
cultivate
=
cultivateDao
.
getById
(
giveEnergyDTO
.
getCultivateId
());
if
(
cultivate
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"账户为空!!"
);
}
if
(
cultivate
.
getEnergy
()<
giveEnergyDTO
.
getEnergy
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"能量不足!"
);
}
Cultivate
friendCultivate
=
cultivateDao
.
getById
(
giveEnergyDTO
.
getFriendCultivateId
());
if
(
friendCultivate
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"好友账户为空!!"
);
}
//自己账户减能量
cultivate
.
setEnergy
(
cultivate
.
getEnergy
()-
giveEnergyDTO
.
getEnergy
());
cultivateDao
.
update
(
cultivate
);
//插入赠送能量记录
CultivateRecord
giveRecord
=
new
CultivateRecord
();
giveRecord
.
setCultivateId
(
cultivate
.
getId
());
giveRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
GIVE_ENERGY_TO_FRIEND
.
code
);
giveRecord
.
setFriendCultivateId
(
friendCultivate
.
getId
());
giveRecord
.
setEnergyChange
(
giveEnergyDTO
.
getEnergy
());
giveRecord
.
setWechatUserId
(
cultivate
.
getWechatUserId
());
createCultivateRecord
(
giveRecord
);
//好友账户增加
friendCultivate
.
setEnergy
(
friendCultivate
.
getEnergy
()+
giveEnergyDTO
.
getEnergy
());
cultivateDao
.
update
(
friendCultivate
);
//插入被赠送能量记录
CultivateRecord
giveToRecord
=
new
CultivateRecord
();
giveToRecord
.
setCultivateId
(
friendCultivate
.
getId
());
giveToRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
GET_ENERGY_BY_FRIEND
.
code
);
giveToRecord
.
setFriendCultivateId
(
cultivate
.
getId
());
giveToRecord
.
setEnergyChange
(
giveEnergyDTO
.
getEnergy
());
giveToRecord
.
setWechatUserId
(
friendCultivate
.
getWechatUserId
());
createCultivateRecord
(
giveToRecord
);
}
catch
(
Exception
e
){
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"该账户正在转账,请稍后!!"
);
}
finally
{
if
(
giveEnergyDTO
.
getCultivateId
().
toString
().
equals
(
JedisClusterUtils
.
get
(
key
))){
JedisClusterUtils
.
del
(
key
);
}
}
}
}
@Override
@Override
@ParamLog
(
"分享"
)
@ParamLog
(
"分享"
)
public
String
shareMedal
(
Long
wechatUserId
)
{
public
String
shareMedal
(
Long
wechatUserId
)
{
...
@@ -672,7 +965,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -672,7 +965,7 @@ public class CultivateBizImpl implements CultivateBiz {
List
<
PersonalMedalRecordDto
>
personalMedalRecordDtos
=
new
ArrayList
<>();
List
<
PersonalMedalRecordDto
>
personalMedalRecordDtos
=
new
ArrayList
<>();
// TODO 换小程序二维码图片地址
// TODO 换小程序二维码图片地址
String
projectQrcodeUrl
=
"https://file.5rs.me/oss/uploadfe/jpg/5e586c6176e13b8806736581b9f641a0.jpg"
;
String
projectQrcodeUrl
=
"https://file.5rs.me/oss/uploadfe/jpg/5e586c6176e13b8806736581b9f641a0.jpg"
;
//根据
星星
数获取勋章图片信息
//根据
书币
数获取勋章图片信息
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
wechatUserId
);
Cultivate
cultivate
=
cultivateDao
.
getByWechatUserId
(
wechatUserId
);
if
(
CultivateConstant
.
FIRST_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
second_MEDAL_STAR
)
{
if
(
CultivateConstant
.
FIRST_MEDAL_STAR
<=
cultivate
.
getStar
()&&
cultivate
.
getStar
()<
CultivateConstant
.
second_MEDAL_STAR
)
{
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
PersonalMedalRecordDto
personalMedalRecordDto
=
new
PersonalMedalRecordDto
();
...
@@ -787,7 +1080,7 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -787,7 +1080,7 @@ public class CultivateBizImpl implements CultivateBiz {
return
html
;
return
html
;
}
}
@ParamLog
(
"
鱼丸
兑换后是否升级"
)
@ParamLog
(
"
银两
兑换后是否升级"
)
private
Boolean
isUpGrade
(
Integer
oldStarCounts
,
Integer
newStarCounts
){
private
Boolean
isUpGrade
(
Integer
oldStarCounts
,
Integer
newStarCounts
){
if
(
CultivateConstant
.
FIRST_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
second_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
second_MEDAL_STAR
)
{
if
(
CultivateConstant
.
FIRST_MEDAL_STAR
<=
oldStarCounts
&&
oldStarCounts
<
CultivateConstant
.
second_MEDAL_STAR
&&
newStarCounts
>=
CultivateConstant
.
second_MEDAL_STAR
)
{
return
true
;
return
true
;
...
@@ -809,4 +1102,324 @@ public class CultivateBizImpl implements CultivateBiz {
...
@@ -809,4 +1102,324 @@ public class CultivateBizImpl implements CultivateBiz {
}
}
@Override
public
List
<
FriendDTO
>
getFriendList
(
Long
cultivateId
)
{
//随机选十个好友。但是如果在其他好友占位,则占第一位
//先找被占座的好友
Long
friendCultivateId
=
cultivateHoldSeatDao
.
getFriendCultivateIdById
(
cultivateId
);
List
<
Cultivate
>
cultivates
=
new
ArrayList
<>();
if
(
null
==
friendCultivateId
){
//如果没有好友,随机选十个
cultivates
=
cultivateDao
.
getRandomUserId
(
cultivateId
,
null
);
}
else
{
//有占座,随机选九个
Cultivate
cultivate
=
cultivateDao
.
getById
(
friendCultivateId
);
cultivate
.
setSeq
(
0
);
cultivates
.
add
(
cultivate
);
List
<
Cultivate
>
randomUserId
=
cultivateDao
.
getRandomUserId
(
cultivateId
,
friendCultivateId
);
for
(
int
i
=
0
;
i
<
randomUserId
.
size
();
i
++)
{
Cultivate
cultivate1
=
randomUserId
.
get
(
i
);
cultivate1
.
setSeq
(
i
+
1
);
cultivates
.
add
(
cultivate1
);
}
cultivates
.
sort
(
Comparator
.
comparingInt
(
a
->
a
.
getSeq
()));
}
if
(
ListUtils
.
isEmpty
(
cultivates
)){
return
new
ArrayList
<>();
}
List
<
Long
>
userIds
=
cultivates
.
stream
().
map
(
a
->
a
.
getWechatUserId
()).
distinct
().
collect
(
Collectors
.
toList
());
List
<
Long
>
cultivateIds
=
cultivates
.
stream
().
map
(
a
->
a
.
getId
()).
distinct
().
collect
(
Collectors
.
toList
());
Map
<
Long
,
WechatUser
>
userMap
=
readerConsr
.
getUserList
(
userIds
);
Map
<
Long
,
Integer
>
levelMap
=
buildLevalMap
(
cultivateIds
);
List
<
FriendDTO
>
list
=
new
ArrayList
<>();
FriendDTO
friendDTO
=
null
;
for
(
Cultivate
cultivate
:
cultivates
)
{
friendDTO
=
new
FriendDTO
();
friendDTO
.
setCultivateId
(
cultivate
.
getId
());
friendDTO
.
setWechatUserId
(
cultivate
.
getWechatUserId
());
if
(
MapUtils
.
isNotEmpty
(
userMap
)
&&
userMap
.
containsKey
(
cultivate
.
getWechatUserId
())){
WechatUser
wechatUser
=
userMap
.
get
(
cultivate
.
getWechatUserId
());
friendDTO
.
setHeadPic
(
null
==
wechatUser
?
null
:
wechatUser
.
getWechatUserHeadurl
());
}
//是否在学习中
friendDTO
.
setInSeat
(
false
);
if
(
null
!=
cultivateId
){
if
(
null
!=
cultivate
&&
cultivate
.
getId
().
equals
(
friendCultivateId
))
{
friendDTO
.
setInSeat
(
true
);
}
}
friendDTO
.
setLevel
(
1
);
if
(
MapUtils
.
isNotEmpty
(
levelMap
)
&&
levelMap
.
containsKey
(
cultivate
.
getId
())){
Integer
level
=
levelMap
.
get
(
cultivate
.
getId
());
friendDTO
.
setLevel
(
level
);
}
list
.
add
(
friendDTO
);
}
return
list
;
}
private
Map
<
Long
,
Integer
>
buildLevalMap
(
List
<
Long
>
cultivateIds
){
List
<
Cultivate
>
cultivateList
=
cultivateDao
.
getByCultivateIds
(
cultivateIds
);
for
(
Cultivate
cultivate
:
cultivateList
)
{
Integer
level
=
getLevel
(
cultivate
.
getStar
());
cultivate
.
setLevel
(
level
);
}
Map
<
Long
,
Integer
>
LevelMap
=
cultivateList
.
stream
().
collect
(
Collectors
.
toMap
(
Cultivate:
:
getId
,
Cultivate:
:
getLevel
,
(
v1
,
v2
)
->
v2
));
return
LevelMap
;
}
private
Integer
getLevel
(
Integer
star
){
Integer
level
=
0
;
if
(
star
<
CultivateConstant
.
FIRST_MEDAL_STAR
)
{
level
=
0
;
}
else
if
(
star
>=
CultivateConstant
.
FIRST_MEDAL_STAR
&&
star
<
CultivateConstant
.
second_MEDAL_STAR
)
{
level
=
1
;
}
else
if
(
star
>=
CultivateConstant
.
second_MEDAL_STAR
&&
star
<
CultivateConstant
.
third_MEDAL_STAR
)
{
level
=
2
;
}
else
if
(
star
>=
CultivateConstant
.
third_MEDAL_STAR
&&
star
<
CultivateConstant
.
fourth_MEDAL_STAR
)
{
level
=
3
;
}
else
if
(
star
>=
CultivateConstant
.
fourth_MEDAL_STAR
&&
star
<
CultivateConstant
.
fifth_MEDAL_STAR
)
{
level
=
4
;
}
else
if
(
star
>=
CultivateConstant
.
fifth_MEDAL_STAR
&&
star
<
CultivateConstant
.
sixth_MEDAL_STAR
)
{
level
=
5
;
}
else
if
(
star
>=
CultivateConstant
.
sixth_MEDAL_STAR
&&
star
<
CultivateConstant
.
seventh_MEDAL_STAR
)
{
level
=
6
;
}
else
if
(
star
>=
CultivateConstant
.
seventh_MEDAL_STAR
&&
star
<
CultivateConstant
.
eighth_MEDAL_STAR
)
{
level
=
7
;
}
else
{
level
=
8
;
}
return
level
;
}
@Override
@ParamLog
(
"占座"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
holdSeat
(
HoldSeatDTO
holdSeatDTO
)
{
if
(
null
==
holdSeatDTO
||
null
==
holdSeatDTO
.
getCultivateId
()
||
null
==
holdSeatDTO
.
getFriendCultivateId
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数错误!"
);
}
//占座之前要判断被占座的用户是否开灯或者是否还有空位
Cultivate
friendCultivate
=
cultivateDao
.
getById
(
holdSeatDTO
.
getFriendCultivateId
());
if
(
null
!=
friendCultivate
&&
null
!=
friendCultivate
.
getLighten
()
&&
!
friendCultivate
.
getLighten
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"不能占位,当前好友未点亮!"
);
}
List
<
Long
>
cultivateIds
=
cultivateHoldSeatDao
.
getCultivateIdByFriendId
(
holdSeatDTO
.
getFriendCultivateId
());
if
(!
ListUtils
.
isEmpty
(
cultivateIds
)
&&
cultivateIds
.
size
()>=
2
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"不能占位,当前好友座位已被占满!"
);
}
ThreadPoolUtils
.
SIGN_OUT_THREAD_POOL
.
execute
(()->{
//占座之前如果已经在别人家学习,要先退出,再占位
Long
friendCultivateId
=
cultivateHoldSeatDao
.
getFriendCultivateIdById
(
holdSeatDTO
.
getCultivateId
());
if
(
null
!=
friendCultivateId
){
//已经在别人家学习,要先退出
HoldSeatDTO
holdSeatDTO1
=
new
HoldSeatDTO
();
holdSeatDTO1
.
setCultivateId
(
holdSeatDTO
.
getCultivateId
());
holdSeatDTO1
.
setFriendCultivateId
(
friendCultivateId
);
this
.
signOut
(
holdSeatDTO1
);
}
});
CultivateHoldSeat
holdSeat
=
new
CultivateHoldSeat
();
BeanUtils
.
copyProperties
(
holdSeatDTO
,
holdSeat
);
cultivateHoldSeatDao
.
insert
(
holdSeat
);
//加占位记录
CultivateRecord
holdSeatRecord
=
new
CultivateRecord
();
holdSeatRecord
.
setCultivateId
(
holdSeatDTO
.
getCultivateId
());
holdSeatRecord
.
setFriendCultivateId
(
holdSeat
.
getFriendCultivateId
());
holdSeatRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
HOLD_FRIEND_SEAT
.
code
);
Cultivate
cultivate
=
cultivateDao
.
getById
(
holdSeatDTO
.
getCultivateId
());
holdSeatRecord
.
setWechatUserId
(
cultivate
.
getWechatUserId
());
createCultivateRecord
(
holdSeatRecord
);
//加被占位记录
CultivateRecord
holdSeatByRecord
=
new
CultivateRecord
();
holdSeatByRecord
.
setCultivateId
(
holdSeatDTO
.
getFriendCultivateId
());
holdSeatByRecord
.
setFriendCultivateId
(
holdSeat
.
getCultivateId
());
holdSeatByRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
HOLD_SEAT_BY_FRIEND
.
code
);
Cultivate
friend
=
cultivateDao
.
getById
(
holdSeatDTO
.
getFriendCultivateId
());
holdSeatByRecord
.
setWechatUserId
(
friend
.
getWechatUserId
());
createCultivateRecord
(
holdSeatByRecord
);
//改变是否在家状态
cultivateDao
.
updateIsHome
(
0
,
holdSeatDTO
.
getCultivateId
());
}
@Override
@ParamLog
(
"踢人"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
kickPeople
(
HoldSeatDTO
holdSeatDTO
)
{
if
(
null
==
holdSeatDTO
||
null
==
holdSeatDTO
.
getCultivateId
()
||
null
==
holdSeatDTO
.
getFriendCultivateId
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数错误!"
);
}
// 1.算踢走这个人时候这个人的能量,并加上,然后主人能量获取速度变化。
//其实主人此时收能量只需要时间*3减去两个人的能量。
//注意 这里 CultivateId应该是踢人的人 FriendCultivateId是被踢的人
Cultivate
cultivate
=
cultivateDao
.
getById
(
holdSeatDTO
.
getCultivateId
());
Cultivate
friend
=
cultivateDao
.
getById
(
holdSeatDTO
.
getFriendCultivateId
());
//拿踢人的人最后一次点亮记录和被踢人占座的时间比较
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
cultivate
.
getWechatUserId
(),
holdSeatDTO
.
getCultivateId
());
CultivateHoldSeat
cultivateHoldSeat
=
cultivateHoldSeatDao
.
getById
(
holdSeatDTO
.
getFriendCultivateId
(),
holdSeatDTO
.
getCultivateId
());
Integer
proFishBall
=
0
;
Integer
minute
=
0
;
if
(
null
!=
lastLighten
&&
null
!=
cultivateHoldSeat
&&
cultivateHoldSeat
.
getCreateTime
().
after
(
lastLighten
.
getCreateTime
())){
//如果是最后一次点灯之后进来的,计算就是进来到踢走这段时间的能量
//一共产生的银两
minute
=(
int
)(
new
Date
().
getTime
()-
cultivateHoldSeat
.
getCreateTime
().
getTime
())/
1000
/
60
;
}
else
if
(
null
!=
lastLighten
&&
null
!=
cultivateHoldSeat
&&
cultivateHoldSeat
.
getCreateTime
().
before
(
lastLighten
.
getCreateTime
())){
//如果是最后一次点灯之前就在,计算就是点灯到踢走这段时间的能量
//一共产生的银两
minute
=(
int
)(
new
Date
().
getTime
()-
lastLighten
.
getCreateTime
().
getTime
())/
1000
/
60
;
}
else
{
minute
=
0
;
}
//计算银两
if
(
minute
<=
0
){
proFishBall
=
0
;
}
else
{
proFishBall
=((
Double
)(
minute
*
0.3
)).
intValue
();
}
friend
.
setFishBall
(
friend
.
getFishBall
()+
proFishBall
);
cultivateDao
.
update
(
friend
);
//加踢人的记录
CultivateRecord
kickRecord
=
new
CultivateRecord
();
kickRecord
.
setCultivateId
(
holdSeatDTO
.
getCultivateId
());
kickRecord
.
setFriendCultivateId
(
holdSeatDTO
.
getFriendCultivateId
());
kickRecord
.
setWechatUserId
(
cultivate
.
getWechatUserId
());
kickRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
KICK_OUT_FRIEND_BY_SELF
.
code
);
createCultivateRecord
(
kickRecord
);
//加被踢记录
CultivateRecord
byKickRecord
=
new
CultivateRecord
();
byKickRecord
.
setCultivateId
(
holdSeatDTO
.
getFriendCultivateId
());
byKickRecord
.
setFriendCultivateId
(
holdSeatDTO
.
getCultivateId
());
byKickRecord
.
setWechatUserId
(
friend
.
getWechatUserId
());
byKickRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
KICK_OUT_BY_FRIEND
.
code
);
createCultivateRecord
(
byKickRecord
);
//4.删除占位表数据
cultivateHoldSeatDao
.
deleteById
(
holdSeatDTO
.
getFriendCultivateId
(),
holdSeatDTO
.
getCultivateId
());
//5.回到家 改变是否在家状态
cultivateDao
.
updateIsHome
(
1
,
holdSeatDTO
.
getFriendCultivateId
());
}
@Override
@ParamLog
(
"退出"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Integer
signOut
(
HoldSeatDTO
holdSeatDTO
)
{
if
(
null
==
holdSeatDTO
||
null
==
holdSeatDTO
.
getCultivateId
()
||
null
==
holdSeatDTO
.
getFriendCultivateId
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数错误!"
);
}
// 1.算退出这个人时候这个人的能量,并加上,然后主人能量获取速度变化。
//其实主人此时收能量只需要时间*3减去两个人的能量。
//注意 这里 CultivateId应该是占座的人 FriendCultivateId是被占座的人
Cultivate
cultivate
=
cultivateDao
.
getById
(
holdSeatDTO
.
getCultivateId
());
Cultivate
friend
=
cultivateDao
.
getById
(
holdSeatDTO
.
getFriendCultivateId
());
//拿踢人的人最后一次点亮记录和被踢人占座的时间比较
CultivateRecord
lastLighten
=
cultivateRecordDao
.
getLastLighten
(
friend
.
getWechatUserId
(),
holdSeatDTO
.
getFriendCultivateId
());
CultivateHoldSeat
cultivateHoldSeat
=
cultivateHoldSeatDao
.
getById
(
holdSeatDTO
.
getCultivateId
(),
holdSeatDTO
.
getFriendCultivateId
());
Integer
proFishBall
=
0
;
Integer
minute
=
0
;
//先计算
if
(
null
!=
lastLighten
&&
null
!=
cultivateHoldSeat
&&
cultivateHoldSeat
.
getCreateTime
().
after
(
lastLighten
.
getCreateTime
())){
//如果是最后一次点灯之后进来的,计算就是进来到踢走这段时间的能量
//一共产生的银两 每分钟1个。N个人分
minute
=(
int
)(
new
Date
().
getTime
()-
cultivateHoldSeat
.
getCreateTime
().
getTime
())/
1000
/
60
;
}
else
if
(
null
!=
lastLighten
&&
null
!=
cultivateHoldSeat
&&
cultivateHoldSeat
.
getCreateTime
().
before
(
lastLighten
.
getCreateTime
())){
//如果是最后一次点灯之前就在,计算就是点灯到踢走这段时间的能量
//一共产生的银两
minute
=(
int
)(
new
Date
().
getTime
()-
lastLighten
.
getCreateTime
().
getTime
())/
1000
/
60
;
}
else
{
minute
=
0
;
}
//计算银两
if
(
minute
<=
0
){
proFishBall
=
0
;
}
else
{
proFishBall
=((
Double
)(
minute
*
0.3
)).
intValue
();
}
cultivate
.
setFishBall
(
cultivate
.
getFishBall
()+
proFishBall
);
cultivateDao
.
update
(
cultivate
);
//加退出记录
CultivateRecord
exitRecord
=
new
CultivateRecord
();
exitRecord
.
setCultivateId
(
holdSeatDTO
.
getCultivateId
());
exitRecord
.
setWechatUserId
(
cultivate
.
getWechatUserId
());
exitRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
EXIT_FRIEND_SEAT
.
code
);
exitRecord
.
setFriendCultivateId
(
holdSeatDTO
.
getFriendCultivateId
());
exitRecord
.
setFishBallChange
(
proFishBall
);
createCultivateRecord
(
exitRecord
);
//加被退出记录
CultivateRecord
byExitRecord
=
new
CultivateRecord
();
byExitRecord
.
setCultivateId
(
holdSeatDTO
.
getFriendCultivateId
());
byExitRecord
.
setWechatUserId
(
friend
.
getWechatUserId
());
byExitRecord
.
setChangeType
(
CultivateChangeTypeEnum
.
FRIEND_EXIT_SEAT
.
code
);
byExitRecord
.
setFriendCultivateId
(
holdSeatDTO
.
getCultivateId
());
createCultivateRecord
(
byExitRecord
);
//4.删除占位表数据
cultivateHoldSeatDao
.
deleteById
(
holdSeatDTO
.
getCultivateId
(),
holdSeatDTO
.
getFriendCultivateId
());
//5.回到家 改变是否在家状态
cultivateDao
.
updateIsHome
(
1
,
holdSeatDTO
.
getCultivateId
());
return
proFishBall
;
}
@Override
@ParamLog
(
"找回"
)
public
Long
getBack
(
Long
cultivateId
)
{
Long
friendCultivateId
=
cultivateHoldSeatDao
.
getFriendCultivateIdById
(
cultivateId
);
return
friendCultivateId
;
}
@Override
@ParamLog
(
"占座两个好友"
)
public
List
<
FriendDTO
>
getHoldSeatFriend
(
Long
cultivateId
)
{
List
<
Long
>
cultivateIdByFriendId
=
cultivateHoldSeatDao
.
getCultivateIdByFriendId
(
cultivateId
);
if
(
ListUtils
.
isEmpty
(
cultivateIdByFriendId
)){
return
new
ArrayList
<>();
}
Map
<
Long
,
Integer
>
levelMap
=
buildLevalMap
(
cultivateIdByFriendId
);
List
<
Cultivate
>
cultivates
=
cultivateDao
.
getByCultivateIds
(
cultivateIdByFriendId
);
List
<
Long
>
userIds
=
Optional
.
ofNullable
(
cultivates
.
stream
().
map
(
a
->
a
.
getWechatUserId
()).
collect
(
Collectors
.
toList
())).
orElse
(
new
ArrayList
<>());
Map
<
Long
,
WechatUser
>
userMap
=
readerConsr
.
getUserList
(
userIds
);
List
<
FriendDTO
>
list
=
new
ArrayList
<>();
FriendDTO
friendDTO
=
null
;
for
(
Cultivate
cultivate
:
cultivates
)
{
friendDTO
=
new
FriendDTO
();
friendDTO
.
setCultivateId
(
cultivate
.
getId
());
friendDTO
.
setWechatUserId
(
cultivate
.
getWechatUserId
());
if
(
MapUtils
.
isNotEmpty
(
userMap
)
&&
userMap
.
containsKey
(
cultivate
.
getWechatUserId
())){
WechatUser
wechatUser
=
userMap
.
get
(
cultivate
.
getWechatUserId
());
friendDTO
.
setHeadPic
(
null
==
wechatUser
?
null
:
wechatUser
.
getWechatUserHeadurl
());
}
friendDTO
.
setLevel
(
1
);
if
(
MapUtils
.
isNotEmpty
(
levelMap
)
&&
levelMap
.
containsKey
(
cultivate
.
getId
())){
Integer
level
=
levelMap
.
get
(
cultivate
.
getId
());
friendDTO
.
setLevel
(
level
);
}
list
.
add
(
friendDTO
);
}
return
list
;
}
@Override
@ParamLog
(
"是否在学习中"
)
public
Boolean
beforeHoldSeat
(
Long
cultivateId
)
{
Long
friendCultivateIdById
=
cultivateHoldSeatDao
.
getFriendCultivateIdById
(
cultivateId
);
return
null
!=
friendCultivateIdById
?
true
:
false
;
}
@Override
public
CultivateDTO
getCultivateBaseInfo
(
Long
cultivateId
)
{
if
(
cultivateId
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"cultivateId为空!"
);
}
Cultivate
cultivate
=
cultivateDao
.
getById
(
cultivateId
);
if
(
null
==
cultivate
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"未能找到当前用户!"
);
}
CultivateDTO
cultivateDTO
=
new
CultivateDTO
();
BeanUtils
.
copyProperties
(
cultivate
,
cultivateDTO
);
//TODO 计算等级勋章等,获取用户基本信息等
WechatUser
wechatUser
=
readerConsr
.
getWechatUser
(
cultivate
.
getWechatUserId
());
cultivateDTO
.
setPicUrl
(
null
!=
wechatUser
?
wechatUser
.
getWechatUserHeadurl
():
null
);
return
cultivateDTO
;
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/constant/CultivateConstant.java
View file @
2585a8e1
...
@@ -23,4 +23,8 @@ public class CultivateConstant {
...
@@ -23,4 +23,8 @@ public class CultivateConstant {
public
static
final
Integer
sixth_MEDAL_STAR
=
500
;
public
static
final
Integer
sixth_MEDAL_STAR
=
500
;
public
static
final
Integer
seventh_MEDAL_STAR
=
1000
;
public
static
final
Integer
seventh_MEDAL_STAR
=
1000
;
public
static
final
Integer
eighth_MEDAL_STAR
=
2000
;
public
static
final
Double
HOLD_SEAT_PROPORTION
=
0.3
D
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateDao.java
View file @
2585a8e1
...
@@ -9,4 +9,10 @@ public interface CultivateDao extends BaseDao<Cultivate> {
...
@@ -9,4 +9,10 @@ public interface CultivateDao extends BaseDao<Cultivate> {
Cultivate
getByWechatUserId
(
Long
wechatUserId
);
Cultivate
getByWechatUserId
(
Long
wechatUserId
);
List
<
Cultivate
>
getAllOrderByStar
();
List
<
Cultivate
>
getAllOrderByStar
();
void
updateIsHome
(
Integer
isHome
,
Long
cultivateId
);
List
<
Cultivate
>
getRandomUserId
(
Long
cultivateId
,
Long
friendCultivateId
);
List
<
Cultivate
>
getByCultivateIds
(
List
<
Long
>
cultivateIds
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateHoldSeatDao.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dao
;
import
com.pcloud.book.cultivate.entity.CultivateHoldSeat
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
CultivateHoldSeatDao
extends
BaseDao
<
CultivateHoldSeat
>
{
void
deleteById
(
Long
cultivateId
,
Long
friendCultivateId
);
List
<
Long
>
getCultivateIdByFriendId
(
Long
friendCultivateId
);
Long
getFriendCultivateIdById
(
Long
cultivateId
);
CultivateHoldSeat
getById
(
Long
cultivateId
,
Long
friendCultivateId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/CultivateRecordDao.java
View file @
2585a8e1
...
@@ -2,7 +2,6 @@ package com.pcloud.book.cultivate.dao;
...
@@ -2,7 +2,6 @@ package com.pcloud.book.cultivate.dao;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.book.cultivate.entity.CultivateRecord
;
import
com.pcloud.common.core.dao.BaseDao
;
import
com.pcloud.common.core.dao.BaseDao
;
import
com.pcloud.common.page.PageBeanNew
;
import
java.util.List
;
import
java.util.List
;
...
@@ -16,4 +15,7 @@ public interface CultivateRecordDao extends BaseDao<CultivateRecord> {
...
@@ -16,4 +15,7 @@ public interface CultivateRecordDao extends BaseDao<CultivateRecord> {
CultivateRecord
getLastLighten
(
Long
wechatUserId
,
Long
cultivateId
);
CultivateRecord
getLastLighten
(
Long
wechatUserId
,
Long
cultivateId
);
CultivateRecord
getLastEnergyConsumptionBefore
(
Long
cultivateRecordId
,
Long
wechatUserId
);
CultivateRecord
getLastEnergyConsumptionBefore
(
Long
cultivateRecordId
,
Long
wechatUserId
);
List
<
CultivateRecord
>
getHoldSeatFriendList
(
Long
cultivateId
,
Long
lastLightenRecordId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateDaoImpl.java
View file @
2585a8e1
...
@@ -5,7 +5,9 @@ import com.pcloud.book.cultivate.entity.Cultivate;
...
@@ -5,7 +5,9 @@ import com.pcloud.book.cultivate.entity.Cultivate;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@Component
(
"cultivateDao"
)
@Component
(
"cultivateDao"
)
public
class
CultivateDaoImpl
extends
BaseDaoImpl
<
Cultivate
>
implements
CultivateDao
{
public
class
CultivateDaoImpl
extends
BaseDaoImpl
<
Cultivate
>
implements
CultivateDao
{
...
@@ -18,4 +20,27 @@ public class CultivateDaoImpl extends BaseDaoImpl<Cultivate> implements Cultivat
...
@@ -18,4 +20,27 @@ public class CultivateDaoImpl extends BaseDaoImpl<Cultivate> implements Cultivat
public
List
<
Cultivate
>
getAllOrderByStar
()
{
public
List
<
Cultivate
>
getAllOrderByStar
()
{
return
getSessionTemplate
().
selectList
(
getStatement
(
"getAllOrderByStar"
));
return
getSessionTemplate
().
selectList
(
getStatement
(
"getAllOrderByStar"
));
}
}
@Override
public
void
updateIsHome
(
Integer
isHome
,
Long
cultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"isHome"
,
isHome
);
map
.
put
(
"cultivateId"
,
cultivateId
);
super
.
getSessionTemplate
().
update
(
getStatement
(
"updateIsHome"
),
map
);
}
@Override
public
List
<
Cultivate
>
getRandomUserId
(
Long
cultivateId
,
Long
friendCultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"friendCultivateId"
,
friendCultivateId
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getRandomUserId"
),
map
);
}
@Override
public
List
<
Cultivate
>
getByCultivateIds
(
List
<
Long
>
cultivateIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateIds"
,
cultivateIds
);
return
super
.
getSessionTemplate
().
selectList
(
getStatement
(
"getByCultivateIds"
),
map
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateHoldSeatDaoImpl.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dao
.
impl
;
import
com.pcloud.book.cultivate.dao.CultivateHoldSeatDao
;
import
com.pcloud.book.cultivate.entity.CultivateHoldSeat
;
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
(
"cultivateHoldSeatDao"
)
public
class
CultivateHoldSeatDaoImpl
extends
BaseDaoImpl
<
CultivateHoldSeat
>
implements
CultivateHoldSeatDao
{
@Override
public
void
deleteById
(
Long
cultivateId
,
Long
friendCultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"friendCultivateId"
,
friendCultivateId
);
super
.
getSqlSession
().
update
(
getStatement
(
"deleteById"
),
map
);
}
@Override
public
List
<
Long
>
getCultivateIdByFriendId
(
Long
friendCultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"friendCultivateId"
,
friendCultivateId
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getCultivateIdByFriendId"
),
map
);
}
@Override
public
Long
getFriendCultivateIdById
(
Long
cultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getFriendCultivateIdById"
),
map
);
}
@Override
public
CultivateHoldSeat
getById
(
Long
cultivateId
,
Long
friendCultivateId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"friendCultivateId"
,
friendCultivateId
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getById"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dao/impl/CultivateRecordDaoImpl.java
View file @
2585a8e1
...
@@ -5,6 +5,7 @@ import com.pcloud.book.cultivate.entity.CultivateRecord;
...
@@ -5,6 +5,7 @@ import com.pcloud.book.cultivate.entity.CultivateRecord;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -51,4 +52,12 @@ public class CultivateRecordDaoImpl extends BaseDaoImpl<CultivateRecord> impleme
...
@@ -51,4 +52,12 @@ public class CultivateRecordDaoImpl extends BaseDaoImpl<CultivateRecord> impleme
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getLastEnergyConsumptionBefore"
),
map
);
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getLastEnergyConsumptionBefore"
),
map
);
}
}
@Override
public
List
<
CultivateRecord
>
getHoldSeatFriendList
(
Long
cultivateId
,
Long
lastLightenRecordId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"cultivateId"
,
cultivateId
);
map
.
put
(
"lastLightenRecordId"
,
lastLightenRecordId
);
return
super
.
getSqlSession
().
selectList
(
getStatement
(
"getHoldSeatFriendList"
),
map
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/CultivateDTO.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"小睿基本信息"
)
public
class
CultivateDTO
extends
BaseEntity
{
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"能量"
)
private
Integer
energy
;
@ApiModelProperty
(
"银两"
)
private
Integer
fishBall
;
@ApiModelProperty
(
"书币"
)
private
Integer
star
;
@ApiModelProperty
(
"是否点亮"
)
private
Boolean
lighten
;
@ApiModelProperty
(
"是否在家"
)
private
Boolean
isHome
;
@ApiModelProperty
(
"等级"
)
private
Integer
level
;
@ApiModelProperty
(
"排序用"
)
private
Integer
seq
;
@ApiModelProperty
(
"用户头像"
)
private
String
picUrl
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/DealHoldSeatFriendFishBallDTO.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Map
;
@Data
public
class
DealHoldSeatFriendFishBallDTO
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"自己还剩银两"
)
private
Integer
ownHasFishBall
;
@ApiModelProperty
(
"占座好友应该分得的银两Map"
)
private
Map
<
Long
,
Double
>
friendFishBallMap
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/FriendDTO.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
FriendDTO
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"用户微信id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"用户头像"
)
private
String
headPic
;
@ApiModelProperty
(
"用户等级"
)
private
Integer
level
;
@ApiModelProperty
(
"占位"
)
private
Boolean
inSeat
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/GiveEnergyDTO.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
GiveEnergyDTO
{
@ApiModelProperty
(
"养成id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"好友养成id"
)
private
Long
friendCultivateId
;
@ApiModelProperty
(
"能量数"
)
private
Integer
energy
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/HoldSeatDTO.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
HoldSeatDTO
{
@ApiModelProperty
(
"占座人Id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"被占座人Id"
)
private
Long
friendCultivateId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/dto/HoldTimeDTO.java
0 → 100644
View file @
2585a8e1
package
com
.
pcloud
.
book
.
cultivate
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
HoldTimeDTO
{
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
"开始占座时间"
)
private
Date
startHold
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@ApiModelProperty
(
"结束占座时间"
)
private
Date
endHold
;
@ApiModelProperty
(
"好友id"
)
private
Long
friendCultivateId
;
@ApiModelProperty
(
"是否还在"
)
private
Boolean
stay
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/Cultivate.java
View file @
2585a8e1
...
@@ -17,13 +17,22 @@ public class Cultivate extends BaseEntity {
...
@@ -17,13 +17,22 @@ public class Cultivate extends BaseEntity {
@ApiModelProperty
(
"能量"
)
@ApiModelProperty
(
"能量"
)
private
Integer
energy
;
private
Integer
energy
;
@ApiModelProperty
(
"
鱼丸
"
)
@ApiModelProperty
(
"
银两
"
)
private
Integer
fishBall
;
private
Integer
fishBall
;
@ApiModelProperty
(
"
星星
"
)
@ApiModelProperty
(
"
书币
"
)
private
Integer
star
;
private
Integer
star
;
@ApiModelProperty
(
"是否点亮"
)
@ApiModelProperty
(
"是否点亮"
)
private
Boolean
lighten
;
private
Boolean
lighten
;
@ApiModelProperty
(
"是否在家"
)
private
Boolean
isHome
;
@ApiModelProperty
(
"等级"
)
private
Integer
level
;
@ApiModelProperty
(
"排序用"
)
private
Integer
seq
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateHoldSeat.java
0 → 100644
View file @
2585a8e1
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
CultivateHoldSeat
extends
BaseEntity
{
@ApiModelProperty
(
"占座人Id"
)
private
Long
cultivateId
;
@ApiModelProperty
(
"被占座人Id"
)
private
Long
friendCultivateId
;
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/entity/CultivateRecord.java
View file @
2585a8e1
...
@@ -21,7 +21,7 @@ public class CultivateRecord extends BaseEntity {
...
@@ -21,7 +21,7 @@ public class CultivateRecord extends BaseEntity {
@ApiModelProperty
(
"用户id"
)
@ApiModelProperty
(
"用户id"
)
private
Long
wechatUserId
;
private
Long
wechatUserId
;
@ApiModelProperty
(
"动态类型(1
鱼丸获取2点亮3熄灭4升级5使用能量值6使用技能7鱼丸兑换星星
)"
)
@ApiModelProperty
(
"动态类型(1
银两获取2点亮3熄灭4升级5使用能量值6使用技能7银两兑换书币
)"
)
private
Integer
changeType
;
private
Integer
changeType
;
@ApiModelProperty
(
"备注信息"
)
@ApiModelProperty
(
"备注信息"
)
...
@@ -30,13 +30,13 @@ public class CultivateRecord extends BaseEntity {
...
@@ -30,13 +30,13 @@ public class CultivateRecord extends BaseEntity {
@ApiModelProperty
(
"能量变化"
)
@ApiModelProperty
(
"能量变化"
)
private
Integer
energyChange
;
private
Integer
energyChange
;
@ApiModelProperty
(
"
鱼丸
变化"
)
@ApiModelProperty
(
"
银两
变化"
)
private
Integer
fishBallChange
;
private
Integer
fishBallChange
;
@ApiModelProperty
(
"
鱼丸
变化类型:1用户自己收,2熄灯之后系统自动收取"
)
@ApiModelProperty
(
"
银两
变化类型:1用户自己收,2熄灯之后系统自动收取"
)
private
Integer
fishBallChangeType
;
private
Integer
fishBallChangeType
;
@ApiModelProperty
(
"
星星
变化"
)
@ApiModelProperty
(
"
书币
变化"
)
private
Integer
starChange
;
private
Integer
starChange
;
@ApiModelProperty
(
"使用技能类型"
)
@ApiModelProperty
(
"使用技能类型"
)
...
@@ -48,4 +48,7 @@ public class CultivateRecord extends BaseEntity {
...
@@ -48,4 +48,7 @@ public class CultivateRecord extends BaseEntity {
)
)
@ApiModelProperty
(
"创建时间"
)
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
private
Date
createTime
;
@ApiModelProperty
(
"好友养成id"
)
private
Long
friendCultivateId
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/enums/CultivateChangeTypeEnum.java
View file @
2585a8e1
...
@@ -2,11 +2,11 @@ package com.pcloud.book.cultivate.enums;
...
@@ -2,11 +2,11 @@ package com.pcloud.book.cultivate.enums;
public
enum
CultivateChangeTypeEnum
{
public
enum
CultivateChangeTypeEnum
{
//1
鱼丸获取2点亮3熄灭4升级5使用能量值6使用技能7鱼丸兑换星星
//1
银两获取2点亮3熄灭4升级5使用能量值6使用技能7银两兑换书币,(鱼丸=银两,星星=书币)
/**
/**
*
鱼丸
获取
*
银两
获取
*/
*/
GET_FISH_BALL
(
1
,
"
鱼丸
获取"
),
GET_FISH_BALL
(
1
,
"
银两
获取"
),
/**
/**
* 点亮
* 点亮
...
@@ -29,9 +29,48 @@ public enum CultivateChangeTypeEnum {
...
@@ -29,9 +29,48 @@ public enum CultivateChangeTypeEnum {
*/
*/
USE_SKILL
(
6
,
"使用技能"
),
USE_SKILL
(
6
,
"使用技能"
),
/**
/**
*
鱼丸兑换星星
*
银两兑换书币
*/
*/
FISH_BALL_CONVERT_STAR
(
7
,
"鱼丸兑换星星"
);
FISH_BALL_CONVERT_STAR
(
7
,
"银两兑换书币"
),
/**
* 赠送能量给好友
*/
GIVE_ENERGY_TO_FRIEND
(
8
,
"赠送能量给好友"
),
/**
* 被好友赠送能量
*/
GET_ENERGY_BY_FRIEND
(
9
,
"被好友赠送能量"
),
/**
* 占好友座位
*/
HOLD_FRIEND_SEAT
(
10
,
"占好友座位"
),
/**
* 被好友占座(我)
*/
HOLD_SEAT_BY_FRIEND
(
11
,
"被好友占座"
),
/**
* 退出好友座位
*/
EXIT_FRIEND_SEAT
(
12
,
"退出好友座位"
),
/**
* 好友退出我的座位(我)
*/
FRIEND_EXIT_SEAT
(
13
,
"好友退出我的座位"
),
/**
* 将好友踢出座位(我)
*/
KICK_OUT_FRIEND_BY_SELF
(
14
,
"将好友踢出座位"
),
/**
* 被好友踢出座位
*/
KICK_OUT_BY_FRIEND
(
15
,
"被好友踢出座位"
),
/**
* 占座好友灯熄灭
*/
FRIEND_LIGHTS_OUT
(
16
,
"占座好友灯熄灭"
);
public
final
Integer
code
;
public
final
Integer
code
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/enums/FishBallChangeTypeEnum.java
View file @
2585a8e1
...
@@ -8,7 +8,19 @@ public enum FishBallChangeTypeEnum {
...
@@ -8,7 +8,19 @@ public enum FishBallChangeTypeEnum {
/**
/**
* 2熄灯之后系统自动收取
* 2熄灯之后系统自动收取
*/
*/
AUTO_CHANGE
(
2
);
AUTO_CHANGE
(
2
),
/**
* 退出好友座位获取银两
*/
EXIT_FRIEND_SEAT_CHANGE
(
3
),
/**
* 被占座好友踢走获取银两
*/
KICK_OUT_BY_FRIEND_CHANGE
(
4
),
/**
* 占座好友熄灯获取到的银两
*/
FRIEND_LIGHTS_OUT_CHANGE
(
5
);
public
final
Integer
value
;
public
final
Integer
value
;
...
...
pcloud-service-book/src/main/java/com/pcloud/book/cultivate/facade/CultivateFacade.java
View file @
2585a8e1
...
@@ -6,6 +6,8 @@ import com.pcloud.book.cultivate.dto.CreateCultivateDTO;
...
@@ -6,6 +6,8 @@ import com.pcloud.book.cultivate.dto.CreateCultivateDTO;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.EnergyConsumptionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallConversionDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.FishBallPickDTO
;
import
com.pcloud.book.cultivate.dto.GiveEnergyDTO
;
import
com.pcloud.book.cultivate.dto.HoldSeatDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.dto.SkillUseDTO
;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
import
com.pcloud.book.cultivate.entity.CultivateBookUser
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
import
com.pcloud.book.cultivate.entity.CultivateRobotClassify
;
...
@@ -13,12 +15,10 @@ import com.pcloud.common.dto.ResponseDto;
...
@@ -13,12 +15,10 @@ import com.pcloud.common.dto.ResponseDto;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.permission.PermissionException
;
import
com.pcloud.common.permission.PermissionException
;
import
com.pcloud.common.utils.NumberUtil
;
import
com.pcloud.common.utils.NumberUtil
;
import
com.pcloud.common.utils.cookie.Cookie
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -72,10 +72,10 @@ public class CultivateFacade {
...
@@ -72,10 +72,10 @@ public class CultivateFacade {
return
new
ResponseDto
<>();
return
new
ResponseDto
<>();
}
}
@ApiOperation
(
"
鱼丸
兑换"
)
@ApiOperation
(
"
银两
兑换"
)
@PostMapping
(
"/fishBallConversion"
)
@PostMapping
(
"/fishBallConversion"
)
public
ResponseDto
<?>
fishBallConversion
(
public
ResponseDto
<?>
fishBallConversion
(
@RequestBody
@ApiParam
(
"
鱼丸
兑换"
)
FishBallConversionDTO
fishBallConversionDTO
@RequestBody
@ApiParam
(
"
银两
兑换"
)
FishBallConversionDTO
fishBallConversionDTO
)
throws
BizException
,
PermissionException
{
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
fishBallConversion
(
fishBallConversionDTO
);
cultivateBiz
.
fishBallConversion
(
fishBallConversionDTO
);
return
new
ResponseDto
<>();
return
new
ResponseDto
<>();
...
@@ -84,7 +84,7 @@ public class CultivateFacade {
...
@@ -84,7 +84,7 @@ public class CultivateFacade {
@ApiOperation
(
"新增技能使用记录"
)
@ApiOperation
(
"新增技能使用记录"
)
@PostMapping
(
"/addUseSkillRecord"
)
@PostMapping
(
"/addUseSkillRecord"
)
public
ResponseDto
<?>
addUseSkillRecord
(
public
ResponseDto
<?>
addUseSkillRecord
(
@RequestBody
@ApiParam
(
"
鱼丸兑换
"
)
SkillUseDTO
skillUseDTO
@RequestBody
@ApiParam
(
"
技能使用
"
)
SkillUseDTO
skillUseDTO
)
throws
BizException
,
PermissionException
{
)
throws
BizException
,
PermissionException
{
Long
wechatUserId
=
skillUseDTO
.
getWechatUserId
();
Long
wechatUserId
=
skillUseDTO
.
getWechatUserId
();
cultivateBiz
.
addUseSkillRecord
(
wechatUserId
,
skillUseDTO
);
cultivateBiz
.
addUseSkillRecord
(
wechatUserId
,
skillUseDTO
);
...
@@ -92,16 +92,16 @@ public class CultivateFacade {
...
@@ -92,16 +92,16 @@ public class CultivateFacade {
}
}
@ApiOperation
(
"
鱼丸
摘取"
)
@ApiOperation
(
"
银两
摘取"
)
@PostMapping
(
"/fishBallPick"
)
@PostMapping
(
"/fishBallPick"
)
public
ResponseDto
<?>
fishBallPick
(
public
ResponseDto
<?>
fishBallPick
(
@RequestBody
@ApiParam
(
"
鱼丸
摘取"
)
FishBallPickDTO
fishBallPickDTO
@RequestBody
@ApiParam
(
"
银两
摘取"
)
FishBallPickDTO
fishBallPickDTO
)
throws
BizException
,
PermissionException
{
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
fishBallPick
(
fishBallPickDTO
);
cultivateBiz
.
fishBallPick
(
fishBallPickDTO
);
return
new
ResponseDto
<>();
return
new
ResponseDto
<>();
}
}
@ApiOperation
(
"待摘取
鱼丸
数量获取"
)
@ApiOperation
(
"待摘取
银两
数量获取"
)
@GetMapping
(
"/getFishBallNotPick"
)
@GetMapping
(
"/getFishBallNotPick"
)
public
ResponseDto
<?>
getFishBallNotPick
(
public
ResponseDto
<?>
getFishBallNotPick
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
...
@@ -190,5 +190,83 @@ public class CultivateFacade {
...
@@ -190,5 +190,83 @@ public class CultivateFacade {
return
new
ResponseDto
<>(
cultivateBiz
.
getBookSearchRecord
(
wechatUserId
,
currentPage
,
numPerPage
));
return
new
ResponseDto
<>(
cultivateBiz
.
getBookSearchRecord
(
wechatUserId
,
currentPage
,
numPerPage
));
}
}
@ApiOperation
(
"获取好友列表"
)
@GetMapping
(
"/getFriendList"
)
public
ResponseDto
<?>
getFriendList
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
if
(!
NumberUtil
.
isNumber
(
cultivateId
)){
throw
new
BizException
(
BizException
.
PARAM_IS_NULL
.
getCode
(),
"cultivateId 不能为空"
);
}
return
new
ResponseDto
<>(
cultivateBiz
.
getFriendList
(
cultivateId
));
}
@ApiOperation
(
"能量赠送"
)
@PostMapping
(
"/giveEnergy"
)
public
ResponseDto
<?>
giveEnergy
(
@RequestBody
@ApiParam
(
"养成id"
)
GiveEnergyDTO
giveEnergyDTO
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
giveEnergy
(
giveEnergyDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"占位之前判断是否要切换占座"
)
@GetMapping
(
"/beforeHoldSeat"
)
public
ResponseDto
<?>
beforeHoldSeat
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
beforeHoldSeat
(
cultivateId
));
}
@ApiOperation
(
"占位"
)
@PostMapping
(
"/holdSeat"
)
public
ResponseDto
<?>
holdSeat
(
@RequestBody
@ApiParam
(
"占座"
)
HoldSeatDTO
holdSeatDTO
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
holdSeat
(
holdSeatDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"踢人"
)
@PostMapping
(
"/kickPeople"
)
public
ResponseDto
<?>
kickPeople
(
@RequestBody
@ApiParam
(
"踢人"
)
HoldSeatDTO
holdSeatDTO
)
throws
BizException
,
PermissionException
{
cultivateBiz
.
kickPeople
(
holdSeatDTO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
"退出"
)
@PostMapping
(
"/signOut"
)
public
ResponseDto
<?>
signOut
(
@RequestBody
@ApiParam
(
"退出"
)
HoldSeatDTO
holdSeatDTO
)
throws
BizException
,
PermissionException
{
Integer
proFishBall
=
cultivateBiz
.
signOut
(
holdSeatDTO
);
return
new
ResponseDto
<>(
proFishBall
);
}
@ApiOperation
(
"找回"
)
@GetMapping
(
"/getBack"
)
public
ResponseDto
<?>
getBack
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
getBack
(
cultivateId
));
}
@ApiOperation
(
"占座两个好友"
)
@GetMapping
(
"/getHoldSeatFriend"
)
public
ResponseDto
<?>
getHoldSeatFriend
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
getHoldSeatFriend
(
cultivateId
));
}
@ApiOperation
(
"获取养成基本信息"
)
@GetMapping
(
"/getCultivateBaseInfo"
)
public
ResponseDto
<?>
getCultivateBaseInfo
(
@RequestParam
(
"cultivateId"
)
@ApiParam
(
"养成id"
)
Long
cultivateId
)
throws
BizException
,
PermissionException
{
return
new
ResponseDto
<>(
cultivateBiz
.
getCultivateBaseInfo
(
cultivateId
));
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/util/common/ThreadPoolUtils.java
View file @
2585a8e1
...
@@ -33,4 +33,15 @@ public class ThreadPoolUtils {
...
@@ -33,4 +33,15 @@ public class ThreadPoolUtils {
public
static
final
ExecutorService
SEND_MAOPAO_THREAD_POOL
=
new
ThreadPoolExecutor
(
1
,
1
,
0L
,
TimeUnit
.
SECONDS
,
public
static
final
ExecutorService
SEND_MAOPAO_THREAD_POOL
=
new
ThreadPoolExecutor
(
1
,
1
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"other-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"other-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
/**
* 小程序小睿蹭光退出线程池
*/
public
static
final
ExecutorService
SIGN_OUT_THREAD_POOL
=
new
ThreadPoolExecutor
(
5
,
5
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"sign-out-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
/**
* 其他线程池
*/
public
static
final
ExecutorService
OTHER_POOL
=
new
ThreadPoolExecutor
(
8
,
8
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"other-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
}
}
pcloud-service-book/src/main/resources/application.yml
View file @
2585a8e1
...
@@ -5,8 +5,8 @@ server:
...
@@ -5,8 +5,8 @@ server:
eureka
:
eureka
:
instance
:
instance
:
status-page-url-path
:
/book/v1.0/swagger-ui.html
status-page-url-path
:
/book/v1.0/swagger-ui.html
#
client:
#
client:
#
register-with-eureka: false #禁止自己当做服务注册
#
register-with-eureka: false #禁止自己当做服务注册
spring
:
spring
:
application
:
application
:
...
...
pcloud-service-book/src/main/resources/mapper/cultivate/Cultivate.xml
View file @
2585a8e1
...
@@ -8,12 +8,13 @@
...
@@ -8,12 +8,13 @@
<result
column=
"fish_ball"
property=
"fishBall"
jdbcType=
"INTEGER"
/>
<result
column=
"fish_ball"
property=
"fishBall"
jdbcType=
"INTEGER"
/>
<result
column=
"star"
property=
"star"
jdbcType=
"INTEGER"
/>
<result
column=
"star"
property=
"star"
jdbcType=
"INTEGER"
/>
<result
column=
"lighten"
property=
"lighten"
jdbcType=
"BOOLEAN"
/>
<result
column=
"lighten"
property=
"lighten"
jdbcType=
"BOOLEAN"
/>
<result
column=
"is_home"
property=
"isHome"
jdbcType=
"BOOLEAN"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, wechat_user_id, energy, fish_ball, star, lighten, create_time,update_time
id, wechat_user_id, energy, fish_ball, star, lighten, create_time,update_time
,is_home
</sql>
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.Cultivate"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.Cultivate"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
...
@@ -25,7 +26,8 @@
...
@@ -25,7 +26,8 @@
star,
star,
lighten,
lighten,
create_time,
create_time,
update_time
update_time,
is_home
)
)
values (
values (
#{wechatUserId},
#{wechatUserId},
...
@@ -34,7 +36,8 @@
...
@@ -34,7 +36,8 @@
#{star},
#{star},
#{lighten},
#{lighten},
NOW(),
NOW(),
NOW()
NOW(),
1
)
)
</insert>
</insert>
...
@@ -79,4 +82,38 @@
...
@@ -79,4 +82,38 @@
cultivate order by star desc
cultivate order by star desc
</select>
</select>
<select
id=
"updateIsHome"
parameterType=
"map"
>
update cultivate
set is_home=#{isHome}
where id=#{cultivateId}
</select>
<select
id=
"getRandomUserId"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM cultivate
WHERE id >= (SELECT floor(RAND() * (SELECT count(1) FROM cultivate)))
and id!=#{cultivateId}
<if
test=
"friendCultivateId !=null"
>
and id!=#{friendCultivateId}
ORDER BY lighten desc,id asc LIMIT 9
</if>
<if
test=
"friendCultivateId ==null"
>
ORDER BY lighten desc,id asc LIMIT 10
</if>
</select>
<select
id=
"getByCultivateIds"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
cultivate
where id IN
<foreach
collection=
"cultivateIds"
open=
"("
close=
")"
separator=
","
item=
"item"
>
#{item}
</foreach>
group by id
</select>
</mapper>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateHoldSeat.xml
0 → 100644
View file @
2585a8e1
<?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.CultivateHoldSeatDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.cultivate.entity.CultivateHoldSeat"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"cultivate_id"
property=
"cultivateId"
jdbcType=
"BIGINT"
/>
<result
column=
"friend_cultivate_id"
property=
"friendCultivateId"
jdbcType=
"BIGINT"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, cultivate_id, friend_cultivate_id, create_time,update_time
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateHoldSeat"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into cultivate_hold_seat
(
cultivate_id,
friend_cultivate_id,
create_time,
update_time
)
values (
#{cultivateId},
#{friendCultivateId},
NOW(),
NOW()
)
</insert>
<select
id=
"deleteById"
parameterType=
"map"
>
DELETE from cultivate_hold_seat
WHERE cultivate_id=#{cultivateId}
and friend_cultivate_id=#{friendCultivateId}
</select>
<select
id=
"getCultivateIdByFriendId"
parameterType=
"map"
resultType=
"long"
>
SELECT DISTINCT cultivate_id
FROM cultivate_hold_seat
where friend_cultivate_id=#{friendCultivateId}
</select>
<select
id=
"getFriendCultivateIdById"
parameterType=
"map"
resultType=
"long"
>
select friend_cultivate_id from cultivate_hold_seat
where cultivate_id=#{cultivateId}
limit 1
</select>
<select
id=
"getById"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_hold_seat
where cultivate_id=#{cultivateId}
and friend_cultivate_id=#{friendCultivateId}
limit 1
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/cultivate/CultivateRecord.xml
View file @
2585a8e1
...
@@ -13,18 +13,19 @@
...
@@ -13,18 +13,19 @@
<result
column=
"star_change"
property=
"starChange"
jdbcType=
"INTEGER"
/>
<result
column=
"star_change"
property=
"starChange"
jdbcType=
"INTEGER"
/>
<result
column=
"skill_type"
property=
"skillType"
jdbcType=
"INTEGER"
/>
<result
column=
"skill_type"
property=
"skillType"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"friend_cultivate_id"
property=
"friendCultivateId"
jdbcType=
"BIGINT"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<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
id, cultivate_id, wechat_user_id, change_type, remark, energy_change, fish_ball_change, fish_ball_change_type, star_change, skill_type, create_time
, friend_cultivate_id
</sql>
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.cultivate.entity.CultivateRecord"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
<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,
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
remark, energy_change, fish_ball_change, fish_ball_change_type,star_change, skill_type, create_time
,friend_cultivate_id
)
)
values (#{cultivateId},#{wechatUserId},#{changeType},#{remark},#{energyChange},#{fishBallChange},#{fishBallChangeType},
values (#{cultivateId},#{wechatUserId},#{changeType},#{remark},#{energyChange},#{fishBallChange},#{fishBallChangeType},
#{starChange}, #{skillType}, NOW()
#{starChange}, #{skillType}, NOW()
,#{friendCultivateId}
)
)
</insert>
</insert>
...
@@ -107,6 +108,15 @@
...
@@ -107,6 +108,15 @@
limit 1
limit 1
</select>
</select>
<select
id=
"getHoldSeatFriendList"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from cultivate_record
where cultivate_id = #{cultivateId}
and id > #{lastLightenRecordId}
and change_type in (11,13,14)
and friend_cultivate_id is not null
</select>
<select
id=
"getBookSearchRecord"
parameterType=
"map"
resultType=
"com.pcloud.book.book.vo.SearchBookVO"
>
<select
id=
"getBookSearchRecord"
parameterType=
"map"
resultType=
"com.pcloud.book.book.vo.SearchBookVO"
>
select a.id,a.content,a.book_id bookId ,b.book_name bookName,a.agent_id agentId,c.SECOND_TEMPLET_ID secondTempletId,b.publish ,c.ADVISER_ID adviserId
select a.id,a.content,a.book_id bookId ,b.book_name bookName,a.agent_id agentId,c.SECOND_TEMPLET_ID secondTempletId,b.publish ,c.ADVISER_ID adviserId
,a.create_time createTime,b.author,b.COVER_IMG coverImg
,a.create_time createTime,b.author,b.COVER_IMG coverImg
...
...
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