Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
safe-campus-bbs
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
万成波
safe-campus-bbs
Commits
3f1dfa85
Commit
3f1dfa85
authored
Nov 06, 2025
by
万成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复Bug
parent
9c15c3b7
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
244 additions
and
83 deletions
+244
-83
safe-campus-points/src/main/java/com/tangguo/controller/BbsUserPointsController.java
.../java/com/tangguo/controller/BbsUserPointsController.java
+5
-4
safe-campus-points/src/main/java/com/tangguo/controller/BbsUserPointsExchangeController.java
...m/tangguo/controller/BbsUserPointsExchangeController.java
+17
-3
safe-campus-points/src/main/java/com/tangguo/domain/bo/BatchUserPointsBO.java
...rc/main/java/com/tangguo/domain/bo/BatchUserPointsBO.java
+18
-2
safe-campus-points/src/main/java/com/tangguo/domain/bo/UserPointsExchangeBO.java
...main/java/com/tangguo/domain/bo/UserPointsExchangeBO.java
+42
-0
safe-campus-points/src/main/java/com/tangguo/mapper/BbsGradeMapper.java
...ints/src/main/java/com/tangguo/mapper/BbsGradeMapper.java
+4
-0
safe-campus-points/src/main/java/com/tangguo/service/IBbsUserPointsExchangeService.java
...va/com/tangguo/service/IBbsUserPointsExchangeService.java
+11
-1
safe-campus-points/src/main/java/com/tangguo/service/IBbsUserPointsService.java
.../main/java/com/tangguo/service/IBbsUserPointsService.java
+3
-2
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsGradeServiceImpl.java
...in/java/com/tangguo/service/impl/BbsGradeServiceImpl.java
+1
-5
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsExchangeServiceImpl.java
...angguo/service/impl/BbsUserPointsExchangeServiceImpl.java
+102
-54
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
...va/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
+27
-11
safe-campus-points/src/main/resources/mapper/BbsGradeMapper.xml
...ampus-points/src/main/resources/mapper/BbsGradeMapper.xml
+14
-1
No files found.
safe-campus-points/src/main/java/com/tangguo/controller/BbsUserPointsController.java
View file @
3f1dfa85
...
...
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户积分Controller
...
...
@@ -126,8 +127,8 @@ public class BbsUserPointsController extends BaseController {
@Log
(
title
=
"用户积分"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
(
"/batch/incr"
)
public
AjaxResult
batchIncrUserPoints
(
@RequestBody
BatchUserPointsBO
bo
)
{
this
.
bbsUserPointsService
.
batchAddUserPoints
(
bo
);
return
AjaxResult
.
success
();
List
<
Map
<
String
,
String
>>
results
=
this
.
bbsUserPointsService
.
batchAddUserPoints
(
bo
);
return
AjaxResult
.
success
(
results
);
}
...
...
@@ -140,8 +141,8 @@ public class BbsUserPointsController extends BaseController {
@Log
(
title
=
"用户积分"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
(
"/batch/decr"
)
public
AjaxResult
batchDecrUserPoints
(
@RequestBody
BatchUserPointsBO
bo
)
{
this
.
bbsUserPointsService
.
batchDeleteUserPoints
(
bo
);
return
AjaxResult
.
success
();
List
<
Map
<
String
,
String
>>
results
=
this
.
bbsUserPointsService
.
batchDeleteUserPoints
(
bo
);
return
AjaxResult
.
success
(
results
);
}
}
safe-campus-points/src/main/java/com/tangguo/controller/BbsUserPointsExchangeController.java
View file @
3f1dfa85
...
...
@@ -8,6 +8,7 @@ import com.tangguo.common.core.page.TableDataInfo;
import
com.tangguo.common.enums.BusinessType
;
import
com.tangguo.common.utils.poi.ExcelUtil
;
import
com.tangguo.domain.BbsUserPointsExchange
;
import
com.tangguo.domain.bo.UserPointsExchangeBO
;
import
com.tangguo.service.IBbsUserPointsExchangeService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户积分兑换Controller
...
...
@@ -69,10 +71,22 @@ public class BbsUserPointsExchangeController extends BaseController {
@Log
(
title
=
"用户积分兑换"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"/exchange"
)
public
AjaxResult
exchange
(
@RequestBody
BbsUserPointsExchange
exchange
)
{
synchronized
(
exchange
.
getUserName
().
intern
())
{
this
.
bbsUserPointsExchangeService
.
addUserPointsExchange
(
exchange
);
}
this
.
bbsUserPointsExchangeService
.
addUserPointsExchange
(
exchange
);
return
AjaxResult
.
success
();
}
/**
* 用户积分兑换
*/
@RepeatSubmit
(
interval
=
1000
)
@ApiOperation
(
"用户积分兑换"
)
@PreAuthorize
(
"@ss.hasPermi('points:exchange:exchange')"
)
@Log
(
title
=
"用户积分兑换"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"/batch/exchange"
)
public
AjaxResult
batchExchange
(
@RequestBody
UserPointsExchangeBO
bo
)
{
List
<
Map
<
String
,
String
>>
results
=
this
.
bbsUserPointsExchangeService
.
batchAddUserPointsExchange
(
bo
);
return
AjaxResult
.
success
(
results
);
}
}
safe-campus-points/src/main/java/com/tangguo/domain/bo/BatchUserPointsBO.java
View file @
3f1dfa85
...
...
@@ -15,9 +15,9 @@ import java.util.Set;
public
class
BatchUserPointsBO
{
/**
* 用户
名
* 用户
*/
private
Set
<
String
>
userName
s
;
private
List
<
User
>
user
s
;
/**
* 积分
...
...
@@ -29,4 +29,20 @@ public class BatchUserPointsBO {
*/
private
String
remarks
;
@Data
public
static
class
User
{
/**
* 用户姓名
*/
private
String
nickName
;
/**
* 用户名
*/
private
String
userName
;
}
}
safe-campus-points/src/main/java/com/tangguo/domain/bo/UserPointsExchangeBO.java
0 → 100644
View file @
3f1dfa85
package
com
.
tangguo
.
domain
.
bo
;
import
lombok.Data
;
import
java.util.List
;
/**
*
*
* @author 谈笑
* @createTime 2025-11-06 14:29:35 星期四
*/
@Data
public
class
UserPointsExchangeBO
{
/**
* 用户名
*/
private
List
<
User
>
users
;
/**
* 商品编码
*/
private
String
goodsCode
;
@Data
public
static
class
User
{
/**
* 用户姓名
*/
private
String
nickName
;
/**
* 用户名
*/
private
String
userName
;
}
}
safe-campus-points/src/main/java/com/tangguo/mapper/BbsGradeMapper.java
View file @
3f1dfa85
...
...
@@ -2,6 +2,7 @@ package com.tangguo.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.tangguo.domain.BbsGrade
;
import
org.apache.ibatis.annotations.Param
;
/**
* 用户等级Mapper接口
...
...
@@ -10,4 +11,7 @@ import com.tangguo.domain.BbsGrade;
* @date 2025-08-28
*/
public
interface
BbsGradeMapper
extends
BaseMapper
<
BbsGrade
>
{
BbsGrade
selectGradeByPoints
(
@Param
(
"points"
)
int
points
);
}
safe-campus-points/src/main/java/com/tangguo/service/IBbsUserPointsExchangeService.java
View file @
3f1dfa85
...
...
@@ -2,8 +2,10 @@ package com.tangguo.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.tangguo.domain.BbsUserPointsExchange
;
import
com.tangguo.domain.bo.UserPointsExchangeBO
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户积分兑换Service接口
...
...
@@ -23,10 +25,18 @@ public interface IBbsUserPointsExchangeService extends IService<BbsUserPointsExc
/**
*
添加用户积分兑换记录
*
用户积分兑换
*
* @param exchange 兑换
*/
void
addUserPointsExchange
(
BbsUserPointsExchange
exchange
);
/**
* 批量用户积分兑换
*
* @param bo 兑换
*/
List
<
Map
<
String
,
String
>>
batchAddUserPointsExchange
(
UserPointsExchangeBO
bo
);
}
safe-campus-points/src/main/java/com/tangguo/service/IBbsUserPointsService.java
View file @
3f1dfa85
...
...
@@ -6,6 +6,7 @@ import com.tangguo.domain.BbsUserPoints;
import
com.tangguo.domain.bo.BatchUserPointsBO
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户积分Service接口
...
...
@@ -72,7 +73,7 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> {
*
* @param bo 积分
*/
void
batchAddUserPoints
(
BatchUserPointsBO
bo
);
List
<
Map
<
String
,
String
>>
batchAddUserPoints
(
BatchUserPointsBO
bo
);
/**
...
...
@@ -80,7 +81,7 @@ public interface IBbsUserPointsService extends IService<BbsUserPoints> {
*
* @param bo 积分
*/
void
batchDeleteUserPoints
(
BatchUserPointsBO
bo
);
List
<
Map
<
String
,
String
>>
batchDeleteUserPoints
(
BatchUserPointsBO
bo
);
/**
...
...
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsGradeServiceImpl.java
View file @
3f1dfa85
...
...
@@ -192,11 +192,7 @@ public class BbsGradeServiceImpl extends ServiceImpl<BbsGradeMapper, BbsGrade> i
*/
@Override
public
BbsGrade
getGradeByPoints
(
int
points
)
{
return
this
.
getOne
(
Wrappers
.
lambdaQuery
(
BbsGrade
.
class
)
.
le
(
BbsGrade:
:
getMinPoints
,
points
)
.
ge
(
BbsGrade:
:
getMaxPoints
,
points
)
);
return
this
.
baseMapper
.
selectGradeByPoints
(
points
);
}
}
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsExchangeServiceImpl.java
View file @
3f1dfa85
...
...
@@ -6,16 +6,18 @@ import com.tangguo.common.exception.ServiceException;
import
com.tangguo.domain.BbsPointsGoods
;
import
com.tangguo.domain.BbsUserPoints
;
import
com.tangguo.domain.BbsUserPointsExchange
;
import
com.tangguo.domain.bo.UserPointsExchangeBO
;
import
com.tangguo.mapper.BbsUserPointsExchangeMapper
;
import
com.tangguo.service.IBbsPointsGoodsService
;
import
com.tangguo.service.IBbsUserPointsExchangeService
;
import
com.tangguo.service.IBbsUserPointsService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.support.TransactionTemplate
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.*
;
/**
* 用户积分兑换Service业务层处理
...
...
@@ -23,18 +25,19 @@ import java.util.Objects;
* @author ruoyi
* @date 2025-08-29
*/
@Slf4j
@Service
public
class
BbsUserPointsExchangeServiceImpl
extends
ServiceImpl
<
BbsUserPointsExchangeMapper
,
BbsUserPointsExchange
>
implements
IBbsUserPointsExchangeService
{
@Resource
private
BbsUserPointsExchangeMapper
bbsUserPointsExchangeMapper
;
@Resource
private
IBbsUserPointsService
userPointsService
;
@Resource
private
IBbsPointsGoodsService
pointsGoodsService
;
@Resource
private
TransactionTemplate
transactionTemplate
;
/**
* 查询用户积分兑换列表
...
...
@@ -49,60 +52,105 @@ public class BbsUserPointsExchangeServiceImpl extends ServiceImpl<BbsUserPointsE
/**
*
添加用户积分兑换记录
*
用户积分兑换
*
* @param exchange 兑换
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
addUserPointsExchange
(
BbsUserPointsExchange
exchange
)
{
// 积分商品校验
BbsPointsGoods
dbGoods
=
this
.
pointsGoodsService
.
getByGoodsCode
(
exchange
.
getGoodsCode
());
if
(
Objects
.
isNull
(
dbGoods
))
{
throw
new
ServiceException
(
"兑换失败,未查询到当前兑换的商品数据。"
);
}
if
(
dbGoods
.
getStockNum
()
<
1
)
{
throw
new
ServiceException
(
"兑换失败,当前兑换的商品库存数量不足。"
);
}
// 用户积分校验
String
userName
=
exchange
.
getUserName
();
Integer
exchangePoints
=
dbGoods
.
getExchangePoints
();
BbsUserPoints
dbUserPoints
=
this
.
userPointsService
.
getAndInitUserPoints
(
userName
);
int
currentPoints
=
dbUserPoints
.
getCurrentPoints
()
-
dbGoods
.
getExchangePoints
();
if
(
currentPoints
<
0
)
{
throw
new
ServiceException
(
"兑换失败,当前用户可用积分不足。"
);
}
// 扣减商品库存
Long
goodsId
=
dbGoods
.
getId
();
boolean
decrResult
=
this
.
pointsGoodsService
.
decrGoodsStock
(
goodsId
,
1
);
if
(!
decrResult
)
{
throw
new
ServiceException
(
"兑换失败,当前兑换的商品库存数量不足。"
);
}
// 增加商品销量
this
.
pointsGoodsService
.
incrGoodsSales
(
goodsId
,
1
);
// 扣减用户积分
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
detail
.
setDetailPoints
(
exchangePoints
);
detail
.
setDetailName
(
dbGoods
.
getName
());
detail
.
setDetailCode
(
dbGoods
.
getCode
());
detail
.
setDescription
(
String
.
format
(
"用户【%s】兑换积分商品【%s-%s】"
,
userName
,
dbGoods
.
getName
(),
dbGoods
.
getCode
()));
this
.
userPointsService
.
decrUserPoints
(
detail
);
// 添加兑换记录
BbsUserPointsExchange
addExchange
=
new
BbsUserPointsExchange
();
addExchange
.
setNickName
(
exchange
.
getNickName
());
addExchange
.
setUserName
(
dbUserPoints
.
getUserName
());
addExchange
.
setUserGradeName
(
dbUserPoints
.
getGradeName
());
addExchange
.
setGoodsName
(
dbGoods
.
getName
());
addExchange
.
setGoodsCode
(
dbGoods
.
getCode
());
addExchange
.
setGoodsExchangePoints
(
dbGoods
.
getExchangePoints
());
addExchange
.
setUserRemainingPoints
(
currentPoints
);
this
.
save
(
addExchange
);
this
.
pointsExchange
(
exchange
.
getUserName
(),
exchange
.
getNickName
(),
exchange
.
getGoodsCode
());
}
/**
* 批量用户积分兑换
*
* @param bo 兑换
*/
@Override
public
List
<
Map
<
String
,
String
>>
batchAddUserPointsExchange
(
UserPointsExchangeBO
bo
)
{
List
<
Map
<
String
,
String
>>
results
=
new
ArrayList
<>(
10
);
for
(
UserPointsExchangeBO
.
User
user
:
bo
.
getUsers
())
{
String
userName
=
user
.
getUserName
();
String
nickName
=
user
.
getNickName
();
try
{
this
.
pointsExchange
(
userName
,
nickName
,
bo
.
getGoodsCode
());
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 批量用户积分兑换失败,用户:{} 商品:{} 失败原因:"
,
userName
,
bo
.
getGoodsCode
(),
e
);
Map
<
String
,
String
>
resultItem
=
new
HashMap
<>(
2
);
resultItem
.
put
(
"nickName"
,
nickName
);
resultItem
.
put
(
"userName"
,
userName
);
resultItem
.
put
(
"errorMessage"
,
e
.
getMessage
());
results
.
add
(
resultItem
);
}
}
return
results
;
}
/**
* 积分兑换
*
* @param userName 用户名
* @param goodsCode 商品编码
*/
public
void
pointsExchange
(
String
userName
,
String
nickName
,
String
goodsCode
)
{
synchronized
(
userName
.
intern
())
{
BbsPointsGoods
dbGoods
=
this
.
pointsGoodsService
.
getByGoodsCode
(
goodsCode
);
if
(
Objects
.
isNull
(
dbGoods
))
{
throw
new
ServiceException
(
"兑换失败,未查询到当前兑换的商品数据。"
);
}
if
(
dbGoods
.
getStockNum
()
<
1
)
{
throw
new
ServiceException
(
"兑换失败,当前兑换的商品库存数量不足。"
);
}
this
.
transactionTemplate
.
executeWithoutResult
(
status
->
{
try
{
// 用户积分校验
Integer
exchangePoints
=
dbGoods
.
getExchangePoints
();
BbsUserPoints
dbUserPoints
=
this
.
userPointsService
.
getAndInitUserPoints
(
userName
);
int
currentPoints
=
dbUserPoints
.
getCurrentPoints
()
-
dbGoods
.
getExchangePoints
();
if
(
currentPoints
<
0
)
{
throw
new
ServiceException
(
"兑换失败,当前用户可用积分不足。"
);
}
// 扣减商品库存
Long
goodsId
=
dbGoods
.
getId
();
boolean
decrResult
=
this
.
pointsGoodsService
.
decrGoodsStock
(
goodsId
,
1
);
if
(!
decrResult
)
{
throw
new
ServiceException
(
"兑换失败,当前兑换的商品库存数量不足。"
);
}
// 增加商品销量
this
.
pointsGoodsService
.
incrGoodsSales
(
goodsId
,
1
);
// 扣减用户积分
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
detail
.
setDetailPoints
(
exchangePoints
);
detail
.
setDetailName
(
dbGoods
.
getName
());
detail
.
setDetailCode
(
dbGoods
.
getCode
());
detail
.
setDescription
(
String
.
format
(
"用户【%s】兑换积分商品【%s-%s】"
,
userName
,
dbGoods
.
getName
(),
dbGoods
.
getCode
()));
this
.
userPointsService
.
decrUserPoints
(
detail
);
// 添加兑换记录
BbsUserPointsExchange
addExchange
=
new
BbsUserPointsExchange
();
addExchange
.
setNickName
(
nickName
);
addExchange
.
setUserName
(
userName
);
addExchange
.
setUserGradeName
(
dbUserPoints
.
getGradeName
());
addExchange
.
setGoodsName
(
dbGoods
.
getName
());
addExchange
.
setGoodsCode
(
dbGoods
.
getCode
());
addExchange
.
setGoodsExchangePoints
(
dbGoods
.
getExchangePoints
());
addExchange
.
setUserRemainingPoints
(
currentPoints
);
this
.
save
(
addExchange
);
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 用户积分兑换失败:"
,
e
);
status
.
setRollbackOnly
();
throw
new
ServiceException
(
e
.
getMessage
());
}
});
}
}
}
safe-campus-points/src/main/java/com/tangguo/service/impl/BbsUserPointsServiceImpl.java
View file @
3f1dfa85
...
...
@@ -21,10 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.transaction.support.TransactionTemplate
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.*
;
/**
* 用户积分Service业务层处理
...
...
@@ -173,9 +170,10 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
* @param bo 积分
*/
@Override
public
void
batchAddUserPoints
(
BatchUserPointsBO
bo
)
{
Set
<
String
>
userNames
=
bo
.
getUserNames
();
for
(
String
userName
:
userNames
)
{
public
List
<
Map
<
String
,
String
>>
batchAddUserPoints
(
BatchUserPointsBO
bo
)
{
List
<
Map
<
String
,
String
>>
results
=
new
ArrayList
<>(
10
);
for
(
BatchUserPointsBO
.
User
user
:
bo
.
getUsers
())
{
String
userName
=
user
.
getUserName
();
try
{
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
...
...
@@ -187,10 +185,17 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
}
detail
.
setDescription
(
remarks
);
this
.
incrUserPoints
(
detail
);
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 用户:{} 增加积分:{} 失败:"
,
userName
,
bo
.
getPoints
(),
e
);
Map
<
String
,
String
>
resultItem
=
new
HashMap
<>(
2
);
resultItem
.
put
(
"nickName"
,
user
.
getNickName
());
resultItem
.
put
(
"userName"
,
userName
);
resultItem
.
put
(
"errorMessage"
,
e
.
getMessage
());
results
.
add
(
resultItem
);
}
}
return
results
;
}
...
...
@@ -200,9 +205,10 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
* @param bo 积分
*/
@Override
public
void
batchDeleteUserPoints
(
BatchUserPointsBO
bo
)
{
Set
<
String
>
userNames
=
bo
.
getUserNames
();
for
(
String
userName
:
userNames
)
{
public
List
<
Map
<
String
,
String
>>
batchDeleteUserPoints
(
BatchUserPointsBO
bo
)
{
List
<
Map
<
String
,
String
>>
results
=
new
ArrayList
<>(
10
);
for
(
BatchUserPointsBO
.
User
user
:
bo
.
getUsers
())
{
String
userName
=
user
.
getUserName
();
try
{
PointsDetail
detail
=
new
PointsDetail
();
detail
.
setUserName
(
userName
);
...
...
@@ -214,10 +220,17 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
}
detail
.
setDescription
(
remarks
);
this
.
decrUserPoints
(
detail
);
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 用户:{} 扣减积分:{} 失败:"
,
userName
,
bo
.
getPoints
(),
e
);
Map
<
String
,
String
>
resultItem
=
new
HashMap
<>(
2
);
resultItem
.
put
(
"nickName"
,
user
.
getNickName
());
resultItem
.
put
(
"userName"
,
userName
);
resultItem
.
put
(
"errorMessage"
,
e
.
getMessage
());
results
.
add
(
resultItem
);
}
}
return
results
;
}
...
...
@@ -257,6 +270,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
if
(
points
<
1
)
{
throw
new
ServiceException
(
"增加用户积分失败,增加的积分分值不能小于0。"
);
}
this
.
transactionTemplate
.
executeWithoutResult
(
status
->
{
try
{
// 更新用户积分
...
...
@@ -291,6 +305,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 处理增加用户积分失败:"
,
e
);
status
.
setRollbackOnly
();
throw
new
ServiceException
(
e
.
getMessage
());
}
});
}
...
...
@@ -306,6 +321,7 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
if
(
points
<
1
)
{
throw
new
ServiceException
(
"扣减用户积分失败,扣减的积分分值不能小于0。"
);
}
this
.
transactionTemplate
.
executeWithoutResult
(
status
->
{
try
{
String
userName
=
detail
.
getUserName
();
...
...
@@ -334,8 +350,8 @@ public class BbsUserPointsServiceImpl extends ServiceImpl<BbsUserPointsMapper, B
this
.
pointsDetailService
.
save
(
newDetail
);
}
catch
(
Exception
e
)
{
log
.
error
(
"=> 处理扣减用户积分失败:"
,
e
);
status
.
setRollbackOnly
();
throw
new
ServiceException
(
e
.
getMessage
());
}
});
}
...
...
safe-campus-points/src/main/resources/mapper/BbsGradeMapper.xml
View file @
3f1dfa85
...
...
@@ -3,5 +3,18 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.tangguo.mapper.BbsGradeMapper"
>
<select
id=
"selectGradeByPoints"
resultType=
"com.tangguo.domain.BbsGrade"
>
SELECT
*
FROM
bbs_grade g
WHERE
(g.min_points
<
= #{points} AND g.max_points >= #{points}) OR (#{points} > g.max_points)
ORDER BY
g.max_points DESC
LIMIT
1
</select>
</mapper>
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