|
@@ -43,7 +43,7 @@ public class RiceService {
|
|
|
private RiceOperationRecordRepo riceOperationRecordRepo;
|
|
private RiceOperationRecordRepo riceOperationRecordRepo;
|
|
|
private UserRepo userRepo;
|
|
private UserRepo userRepo;
|
|
|
private SysConfigService sysConfigService;
|
|
private SysConfigService sysConfigService;
|
|
|
- private RiceInviteRepo riceInviteRepo;
|
|
|
|
|
|
|
+ private RiceInviteRepo riceInviteRepo;
|
|
|
|
|
|
|
|
public Page<Rice> all(PageQuery pageQuery) {
|
|
public Page<Rice> all(PageQuery pageQuery) {
|
|
|
return riceRepo.findAll(JpaUtils.toSpecification(pageQuery, Rice.class), JpaUtils.toPageRequest(pageQuery));
|
|
return riceRepo.findAll(JpaUtils.toSpecification(pageQuery, Rice.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -60,7 +60,7 @@ public class RiceService {
|
|
|
User user = byId.get();
|
|
User user = byId.get();
|
|
|
nickname = user.getNickname();
|
|
nickname = user.getNickname();
|
|
|
avatar = user.getAvatar();
|
|
avatar = user.getAvatar();
|
|
|
- phone= user.getPhone();
|
|
|
|
|
|
|
+ phone = user.getPhone();
|
|
|
} else {
|
|
} else {
|
|
|
throw new BusinessException("用户不存在");
|
|
throw new BusinessException("用户不存在");
|
|
|
}
|
|
}
|
|
@@ -78,7 +78,6 @@ public class RiceService {
|
|
|
rice.setNickname(nickname);
|
|
rice.setNickname(nickname);
|
|
|
rice.setPhone(phone);
|
|
rice.setPhone(phone);
|
|
|
rice.setLevel(0L);
|
|
rice.setLevel(0L);
|
|
|
- rice.setWaterDropCount(0L);
|
|
|
|
|
rice.setSignCount(0L);
|
|
rice.setSignCount(0L);
|
|
|
rice.setSelfScore(0L);
|
|
rice.setSelfScore(0L);
|
|
|
rice.setSelfActivityScore(0L);
|
|
rice.setSelfActivityScore(0L);
|
|
@@ -113,8 +112,6 @@ public class RiceService {
|
|
|
Optional<Rice> byUserId = riceRepo.findByUserId(authId);
|
|
Optional<Rice> byUserId = riceRepo.findByUserId(authId);
|
|
|
if (byUserId.isPresent()) {
|
|
if (byUserId.isPresent()) {
|
|
|
Rice rice = byUserId.get();
|
|
Rice rice = byUserId.get();
|
|
|
- empiricalValue = rice.getEmpiricalValue();
|
|
|
|
|
-
|
|
|
|
|
JsonReader jsonReader = Json.createReader(new StringReader(jsonString));
|
|
JsonReader jsonReader = Json.createReader(new StringReader(jsonString));
|
|
|
JsonArray jsonArray = jsonReader.readArray();
|
|
JsonArray jsonArray = jsonReader.readArray();
|
|
|
|
|
|
|
@@ -171,6 +168,7 @@ public class RiceService {
|
|
|
if (byUserId.isPresent()) {
|
|
if (byUserId.isPresent()) {
|
|
|
Rice rice = byUserId.get();
|
|
Rice rice = byUserId.get();
|
|
|
int i = riceInviteRepo.countRiceInviteBy(rice.getUserId(), getTodayStartTime(), getTodayEndTime());
|
|
int i = riceInviteRepo.countRiceInviteBy(rice.getUserId(), getTodayStartTime(), getTodayEndTime());
|
|
|
|
|
+ int InviteHelpOthersCounts = riceInviteRepo.countRiceInviteByHelperId(authId, getTodayStartTime(), getTodayEndTime());
|
|
|
|
|
|
|
|
Long lastSignInTime = rice.getLastSignInTime();
|
|
Long lastSignInTime = rice.getLastSignInTime();
|
|
|
Long currentTime = System.currentTimeMillis();
|
|
Long currentTime = System.currentTimeMillis();
|
|
@@ -179,16 +177,16 @@ public class RiceService {
|
|
|
Boolean isInvited;
|
|
Boolean isInvited;
|
|
|
Boolean isCanExchangeScore;
|
|
Boolean isCanExchangeScore;
|
|
|
|
|
|
|
|
- if(rice.getSelfActivityScore()<10&&rice.getSelfScore()>=2){
|
|
|
|
|
- isCanExchangeScore=true;
|
|
|
|
|
- }else {
|
|
|
|
|
- isCanExchangeScore=false;
|
|
|
|
|
|
|
+ if (rice.getSelfActivityScore() < 10 && rice.getSelfScore() >= 2) {
|
|
|
|
|
+ isCanExchangeScore = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ isCanExchangeScore = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(i==0){
|
|
|
|
|
|
|
+ if (i == 0) {
|
|
|
isInvited = false;
|
|
isInvited = false;
|
|
|
|
|
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
isInvited = true;
|
|
isInvited = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -204,8 +202,9 @@ public class RiceService {
|
|
|
.add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
|
|
.add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
|
|
|
.add("waterDropCount", rice.getWaterDropCount())
|
|
.add("waterDropCount", rice.getWaterDropCount())
|
|
|
.add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
|
|
.add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
|
|
|
- .add("isInvited",isInvited)
|
|
|
|
|
- .add("isCanExchangeScore",isCanExchangeScore);
|
|
|
|
|
|
|
+ .add("isInvited", isInvited)
|
|
|
|
|
+ .add("isCanExchangeScore", isCanExchangeScore)
|
|
|
|
|
+ .add("InviteHelpOthersCounts", InviteHelpOthersCounts);
|
|
|
}
|
|
}
|
|
|
// 判断今天是否已经签到过
|
|
// 判断今天是否已经签到过
|
|
|
if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(currentTime))) {
|
|
if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(currentTime))) {
|
|
@@ -213,15 +212,17 @@ public class RiceService {
|
|
|
.add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
|
|
.add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
|
|
|
.add("waterDropCount", rice.getWaterDropCount())
|
|
.add("waterDropCount", rice.getWaterDropCount())
|
|
|
.add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
|
|
.add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
|
|
|
- .add("isInvited",isInvited)
|
|
|
|
|
- .add("isCanExchangeScore",isCanExchangeScore);
|
|
|
|
|
|
|
+ .add("isInvited", isInvited)
|
|
|
|
|
+ .add("isCanExchangeScore", isCanExchangeScore)
|
|
|
|
|
+ .add("InviteHelpOthersCounts", InviteHelpOthersCounts);
|
|
|
} else {
|
|
} else {
|
|
|
return R.success("未签到").add("isSignedIn", false)
|
|
return R.success("未签到").add("isSignedIn", false)
|
|
|
.add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
|
|
.add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
|
|
|
.add("waterDropCount", rice.getWaterDropCount())
|
|
.add("waterDropCount", rice.getWaterDropCount())
|
|
|
.add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
|
|
.add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
|
|
|
- .add("isInvited",isInvited)
|
|
|
|
|
- .add("isCanExchangeScore",isCanExchangeScore);
|
|
|
|
|
|
|
+ .add("isInvited", isInvited)
|
|
|
|
|
+ .add("isCanExchangeScore", isCanExchangeScore)
|
|
|
|
|
+ .add("InviteHelpOthersCounts", InviteHelpOthersCounts);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return R.error("查询失败");
|
|
return R.error("查询失败");
|
|
@@ -232,15 +233,9 @@ public class RiceService {
|
|
|
* 获取当前用户积分
|
|
* 获取当前用户积分
|
|
|
*/
|
|
*/
|
|
|
public R<String> getCurrentScore() {
|
|
public R<String> getCurrentScore() {
|
|
|
- User authenticatedUser = SecurityUtils.getAuthenticatedUser();
|
|
|
|
|
- Long authId = authenticatedUser.getId();
|
|
|
|
|
- Optional<Rice> byUserId = riceRepo.findByUserId(authId);
|
|
|
|
|
- if (byUserId.isPresent()) {
|
|
|
|
|
- Rice rice = byUserId.get();
|
|
|
|
|
- Long selfScore = rice.getSelfScore();
|
|
|
|
|
- return R.success("获取到当前用户积分").add("selfScore", selfScore);
|
|
|
|
|
- }
|
|
|
|
|
- return R.error("获取失败");
|
|
|
|
|
|
|
+ Rice rice = riceRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()).orElseThrow(new BusinessException("用户不存在"));
|
|
|
|
|
+ Long selfScore = rice.getSelfScore();
|
|
|
|
|
+ return R.success("获取到当前用户积分").add("selfScore", selfScore);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -256,6 +251,7 @@ public class RiceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ //一个获取积分排行榜的接口
|
|
|
public List<RiceDTO> getTop100(Long userId) {
|
|
public List<RiceDTO> getTop100(Long userId) {
|
|
|
List<Rice> top100Rices = riceRepo.findTop100OrderByEmpiricalValueDesc();
|
|
List<Rice> top100Rices = riceRepo.findTop100OrderByEmpiricalValueDesc();
|
|
|
List<RiceDTO> result = new ArrayList<>();
|
|
List<RiceDTO> result = new ArrayList<>();
|
|
@@ -354,8 +350,7 @@ public class RiceService {
|
|
|
//浇水
|
|
//浇水
|
|
|
public R<? extends Object> watering() {
|
|
public R<? extends Object> watering() {
|
|
|
// 获取当前用户 ID,
|
|
// 获取当前用户 ID,
|
|
|
- User authenticatedUser = SecurityUtils.getAuthenticatedUser();
|
|
|
|
|
- Long authId = authenticatedUser.getId();
|
|
|
|
|
|
|
+ Long authId = SecurityUtils.getAuthenticatedUser().getId();
|
|
|
Optional<Rice> byUserId = riceRepo.findByUserId(authId);
|
|
Optional<Rice> byUserId = riceRepo.findByUserId(authId);
|
|
|
if (byUserId.isPresent()) {
|
|
if (byUserId.isPresent()) {
|
|
|
Rice rice = byUserId.get();
|
|
Rice rice = byUserId.get();
|
|
@@ -368,7 +363,7 @@ public class RiceService {
|
|
|
}
|
|
}
|
|
|
// 浇水成功,更新水滴次数,经验值加2
|
|
// 浇水成功,更新水滴次数,经验值加2
|
|
|
rice.setWaterDropCount(waterDropCount - 1);
|
|
rice.setWaterDropCount(waterDropCount - 1);
|
|
|
- rice.setEmpiricalValue(rice.getEmpiricalValue() + 2);
|
|
|
|
|
|
|
+ rice.setEmpiricalValue(rice.getEmpiricalValue() + 10);
|
|
|
riceRepo.save(rice);
|
|
riceRepo.save(rice);
|
|
|
createRiceOperationRecord(authId, RiceOperationType.WATER_DROP, 1L, beforeWaterDropCount, rice
|
|
createRiceOperationRecord(authId, RiceOperationType.WATER_DROP, 1L, beforeWaterDropCount, rice
|
|
|
.getWaterDropCount());
|
|
.getWaterDropCount());
|
|
@@ -390,8 +385,8 @@ public class RiceService {
|
|
|
public Long getTodayWateringCount(Long userId) {
|
|
public Long getTodayWateringCount(Long userId) {
|
|
|
List<RiceUserWaterDropRecord> records = riceUserWaterDropRecordRepo.findByUserId(userId);
|
|
List<RiceUserWaterDropRecord> records = riceUserWaterDropRecordRepo.findByUserId(userId);
|
|
|
Long count = records.stream()
|
|
Long count = records.stream()
|
|
|
- .filter(RiceUserWaterDropRecord::isToday)
|
|
|
|
|
- .count();
|
|
|
|
|
|
|
+ .filter(RiceUserWaterDropRecord::isToday)
|
|
|
|
|
+ .count();
|
|
|
return count;
|
|
return count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -417,7 +412,7 @@ public class RiceService {
|
|
|
}
|
|
}
|
|
|
if (currentEmpiricalValue >= start && currentEmpiricalValue < nextStart) {
|
|
if (currentEmpiricalValue >= start && currentEmpiricalValue < nextStart) {
|
|
|
Long levelUpEmpiricalValue = nextStart - currentEmpiricalValue;
|
|
Long levelUpEmpiricalValue = nextStart - currentEmpiricalValue;
|
|
|
- Long waterDropNeededForLevelUp = levelUpEmpiricalValue / 2;
|
|
|
|
|
|
|
+ Long waterDropNeededForLevelUp = levelUpEmpiricalValue / 10;
|
|
|
return waterDropNeededForLevelUp;
|
|
return waterDropNeededForLevelUp;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -427,86 +422,75 @@ public class RiceService {
|
|
|
|
|
|
|
|
//签到
|
|
//签到
|
|
|
public R<?> signIn(Long userId) {
|
|
public R<?> signIn(Long userId) {
|
|
|
- Optional<Rice> byUserId = riceRepo.findByUserId(userId);
|
|
|
|
|
- if (byUserId.isPresent()) {
|
|
|
|
|
- Rice rice = byUserId.get();
|
|
|
|
|
- Long lastSignInTime = rice.getLastSignInTime();
|
|
|
|
|
- Long currentTime = System.currentTimeMillis();
|
|
|
|
|
- Long beforeWaterDropCount = rice.getWaterDropCount();
|
|
|
|
|
- Long beforeEmpiricalValue = rice.getEmpiricalValue();
|
|
|
|
|
- // 判断上次签到时间是否为空,如果为空,则默认为从未签到过
|
|
|
|
|
- if (lastSignInTime == null) {
|
|
|
|
|
- rice.setWaterDropCount(rice.getWaterDropCount() + 1);
|
|
|
|
|
- rice.setSignCount(rice.getSignCount() + 1);
|
|
|
|
|
- rice.setLastSignInTime(currentTime);
|
|
|
|
|
- riceRepo.save(rice);
|
|
|
|
|
- createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
|
|
|
|
|
- .getWaterDropCount());
|
|
|
|
|
- return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
- }
|
|
|
|
|
- // 判断今天是否已经签到过
|
|
|
|
|
- if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(currentTime))) {
|
|
|
|
|
- return R.error("今天已经签到过了").add("can", false);
|
|
|
|
|
- }
|
|
|
|
|
- // 签到成功,水滴数加1,签到次数加1,更新签到时间
|
|
|
|
|
|
|
+ Rice rice = riceRepo.findByUserId(userId).orElseThrow(new BusinessException("没找到用户"));
|
|
|
|
|
+ Long lastSignInTime = rice.getLastSignInTime();
|
|
|
|
|
+ Long beforeWaterDropCount = rice.getWaterDropCount();
|
|
|
|
|
+ // 判断上次签到时间是否为空,如果为空,则默认为从未签到过
|
|
|
|
|
+ if (lastSignInTime == null) {
|
|
|
rice.setWaterDropCount(rice.getWaterDropCount() + 1);
|
|
rice.setWaterDropCount(rice.getWaterDropCount() + 1);
|
|
|
rice.setSignCount(rice.getSignCount() + 1);
|
|
rice.setSignCount(rice.getSignCount() + 1);
|
|
|
- rice.setLastSignInTime(currentTime);
|
|
|
|
|
|
|
+ rice.setLastSignInTime(System.currentTimeMillis());
|
|
|
|
|
+ rice.setNumberOfSingnIn(rice.getNumberOfSingnIn() + 1);
|
|
|
riceRepo.save(rice);
|
|
riceRepo.save(rice);
|
|
|
createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
|
|
createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
|
|
|
.getWaterDropCount());
|
|
.getWaterDropCount());
|
|
|
return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
|
|
return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
|
|
|
}
|
|
}
|
|
|
- return R.error("签到失败").add("can", false);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 判断今天是否已经签到过
|
|
|
|
|
+ if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(System.currentTimeMillis()))) {
|
|
|
|
|
+ return R.error("今天已经签到过了").add("can", false);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 签到成功,水滴数加1,签到次数加1,更新签到时间
|
|
|
|
|
+ rice.setWaterDropCount(rice.getWaterDropCount() + 1);
|
|
|
|
|
+ rice.setSignCount(rice.getSignCount() + 1);
|
|
|
|
|
+ rice.setLastSignInTime(System.currentTimeMillis());
|
|
|
|
|
+ riceRepo.save(rice);
|
|
|
|
|
|
|
|
- //积分兑换水滴
|
|
|
|
|
- public R<?> exchangeScoreForWaterDrop(User authenticatedUser) {
|
|
|
|
|
- Long authId = authenticatedUser.getId();
|
|
|
|
|
- Optional<Rice> byUserId = riceRepo.findByUserId(authId);
|
|
|
|
|
- if (byUserId.isPresent()) {
|
|
|
|
|
- Rice rice = byUserId.get();
|
|
|
|
|
- Long selfScore = rice.getSelfScore();
|
|
|
|
|
- Long beforeSelfScore = rice.getSelfScore();
|
|
|
|
|
- Integer waterDropCount = Math.toIntExact(rice.getWaterDropCount());
|
|
|
|
|
- Long beforeWaterDropCount = rice.getWaterDropCount();
|
|
|
|
|
|
|
+ createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
|
|
|
|
|
+ .getWaterDropCount());
|
|
|
|
|
+ return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
|
|
|
- // 每次兑换需要消耗的积分和最大兑换次数
|
|
|
|
|
- int exchangeScore = 2;
|
|
|
|
|
- int maxExchangeCount = 10;
|
|
|
|
|
|
|
|
|
|
- // 计算当前可兑换的次数和消耗的积分
|
|
|
|
|
-// if (rice.getExchangeCount() == null) {
|
|
|
|
|
-// rice.setExchangeCount(0);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (rice.getExchangeCount() == 10) {
|
|
|
|
|
- return R.error("您今天已经兑换十次了.").add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
- }
|
|
|
|
|
- int exchangeCount = Math.min((int) (selfScore / exchangeScore), maxExchangeCount - rice.getExchangeCount());
|
|
|
|
|
- int totalScore = exchangeCount * exchangeScore;
|
|
|
|
|
|
|
|
|
|
- if (exchangeCount > 0) {
|
|
|
|
|
- rice.setSelfScore(selfScore - totalScore);
|
|
|
|
|
- rice.setWaterDropCount((long) (waterDropCount + exchangeCount));
|
|
|
|
|
- rice.setExchangeCount(rice.getExchangeCount()+exchangeCount);
|
|
|
|
|
- riceRepo.save(rice);
|
|
|
|
|
- createRiceOperationRecord(authId, RiceOperationType.WATER_DROP, (long) exchangeCount, beforeWaterDropCount, rice
|
|
|
|
|
- .getWaterDropCount());
|
|
|
|
|
|
|
+ //积分兑换水滴
|
|
|
|
|
+ public R<?> exchangeScoreForWaterDrop(User authenticatedUser) {
|
|
|
|
|
+ Rice rice = riceRepo.findByUserId(authenticatedUser.getId()).orElseThrow(new BusinessException("没找到用户"));
|
|
|
|
|
+ //获取当前的积分
|
|
|
|
|
+ Long selfScore = rice.getSelfScore();
|
|
|
|
|
+ Long beforeSelfScore = rice.getSelfScore();
|
|
|
|
|
+ Integer waterDropCount = Math.toIntExact(rice.getWaterDropCount());
|
|
|
|
|
+ Long beforeWaterDropCount = rice.getWaterDropCount();
|
|
|
|
|
+ // 每次兑换需要消耗的积分和最大兑换次数
|
|
|
|
|
+ int exchangeScore = 10;
|
|
|
|
|
+ int maxExchangeCount = 10;
|
|
|
|
|
+ if (rice.getExchangeCount() == 10) {
|
|
|
|
|
+ return R.error("您今天已经兑换十次了.").add("waterDropCount", rice.getWaterDropCount()).add("exchangeCount", rice.getExchangeCount());
|
|
|
|
|
+ }
|
|
|
|
|
+ int exchangeCount = Math.min((int) (selfScore / exchangeScore), maxExchangeCount - rice.getExchangeCount());
|
|
|
|
|
+ int totalScore = exchangeCount * exchangeScore;
|
|
|
|
|
+
|
|
|
|
|
+ if (exchangeCount > 0) {
|
|
|
|
|
+ rice.setSelfScore(selfScore - totalScore);
|
|
|
|
|
+ rice.setWaterDropCount((long) (waterDropCount + exchangeCount));
|
|
|
|
|
+ rice.setNumberOfScoreExchanged(rice.getNumberOfScoreExchanged()+exchangeCount);
|
|
|
|
|
+ rice.setExchangeCount(rice.getExchangeCount() + exchangeCount);
|
|
|
|
|
+ riceRepo.save(rice);
|
|
|
|
|
+ createRiceOperationRecord(authenticatedUser.getId(), RiceOperationType.WATER_DROP, (long) exchangeCount, beforeWaterDropCount, rice
|
|
|
|
|
+ .getWaterDropCount());
|
|
|
|
|
|
|
|
- createRiceOperationRecord(authId, RiceOperationType.SELF_SCORE, (long) totalScore, beforeSelfScore, rice
|
|
|
|
|
- .getSelfScore());
|
|
|
|
|
- return R.success("兑换成功").add("exchangeCount", exchangeCount)
|
|
|
|
|
- .add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
- } else if (exchangeCount == 0) {
|
|
|
|
|
- return R.error("兑换失败,当前积分不足").add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
|
|
+ createRiceOperationRecord(authenticatedUser.getId(), RiceOperationType.SELF_SCORE, (long) totalScore, beforeSelfScore, rice
|
|
|
|
|
+ .getSelfScore());
|
|
|
|
|
+ return R.success("兑换成功").add("exchangeCount", exchangeCount)
|
|
|
|
|
+ .add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
+ } else if (exchangeCount == 0) {
|
|
|
|
|
+ return R.error("兑换失败,当前积分不足").add("waterDropCount", rice.getWaterDropCount()).add("exchangeCount", rice.getExchangeCount());
|
|
|
|
|
|
|
|
- } else {
|
|
|
|
|
- return R.error("兑换失败,当前积分不足").add("exchangeCount", rice.getExchangeCount()).add("waterDropCount", rice.getWaterDropCount());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return R.error("兑换失败,当前积分不足").add("exchangeCount", rice.getExchangeCount()).add("waterDropCount", rice.getWaterDropCount());
|
|
|
}
|
|
}
|
|
|
- return R.error("兑换失败,用户不存在");
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -550,7 +534,7 @@ public class RiceService {
|
|
|
.getId(), RiceOperationType.WATER_DROP, exchangedWaterDropCount, beforeWaterDropCount, rice
|
|
.getId(), RiceOperationType.WATER_DROP, exchangedWaterDropCount, beforeWaterDropCount, rice
|
|
|
.getWaterDropCount());
|
|
.getWaterDropCount());
|
|
|
createRiceOperationRecord(authenticatedUser
|
|
createRiceOperationRecord(authenticatedUser
|
|
|
- .getId(), RiceOperationType.SELF_ACTIVITY_SCORE, (Long) exchangedWaterDropCount * 2, currentActivityPoints, rice
|
|
|
|
|
|
|
+ .getId(), RiceOperationType.SELF_ACTIVITY_SCORE, exchangedWaterDropCount * 2, currentActivityPoints, rice
|
|
|
.getSelfActivityScore());
|
|
.getSelfActivityScore());
|
|
|
|
|
|
|
|
return R.success("兑换成功").add("counts", exchangedWaterDropCount);
|
|
return R.success("兑换成功").add("counts", exchangedWaterDropCount);
|