提交 4bcc6cca authored 作者: Whispa's avatar Whispa

commit commit

上级 e6d1c43b
......@@ -76,13 +76,13 @@ public class BonusController extends Controller {
int year = localDate.getYear();
Optional<TbCfUserInfo> byId = userRepository.findById(id);
if (!byId.isPresent()) return null;
Query nativeQuery = entityManager.createNativeQuery("select IFNULL(sum(b.amount),0) as data FROM bonus b where b.user_info_user_id=:user and month (b.create_date) = :month and year(b.create_date) = :year ");
Query nativeQuery = entityManager.createNativeQuery("select IFNULL(sum(b.amount),0.0) as data FROM bonus b where b.user_info_user_id=:user and month (b.create_date) = :month and year(b.create_date) = :year ");
nativeQuery.setParameter("user", id);
nativeQuery.setParameter("month", month);
nativeQuery.setParameter("year", year);
List<Bonus> bonuses = repository.findAllByUser_IdAndCreateDateMonthAndCreateDateYear(byId.get(), month, year, PageRequest.of(pageNo, pageSize)).toList();
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", nativeQuery.getSingleResult());
hashMap.put("total", BigDecimal.valueOf((double)nativeQuery.getSingleResult()).setScale(3,RoundingMode.HALF_UP));
hashMap.put("list", bonuses);
return hashMap;
}
......@@ -103,13 +103,13 @@ public class BonusController extends Controller {
int year = localDate.getYear();
Optional<TbCfUserInfo> byId = userRepository.findById(id);
if (!byId.isPresent()) return null;
Query nativeQuery = entityManager.createNativeQuery("select IFNULL(sum(b.amount),0) as data FROM bonus b where b.user_info_user_id=:user and month (b.create_date) = :month and year(b.create_date) = :year ");
Query nativeQuery = entityManager.createNativeQuery("select IFNULL(sum(b.amount),0.0) as data FROM bonus b where b.user_info_user_id=:user and month (b.create_date) = :month and year(b.create_date) = :year ");
nativeQuery.setParameter("user", id);
nativeQuery.setParameter("month", month);
nativeQuery.setParameter("year", year);
List<Bonus> bonuses = repository.findAllByUser_IdAndCreateDateMonthAndCreateDateYear(byId.get(), month, year, PageRequest.of(pageNo, pageSize)).toList();
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", nativeQuery.getSingleResult());
hashMap.put("total", BigDecimal.valueOf((double)nativeQuery.getSingleResult()).setScale(3,RoundingMode.HALF_UP));
hashMap.put("list", bonuses);
return hashMap;
}
......@@ -136,7 +136,7 @@ public class BonusController extends Controller {
nativeQuery.setParameter("year", year);
List<Bonus> bonuses = repository.findAllByUser_IdAndCreateDate(byId.get(), dayOfYear, year, PageRequest.of(pageNo, pageSize)).toList();
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", nativeQuery.getSingleResult());
hashMap.put("total", BigDecimal.valueOf((double)nativeQuery.getSingleResult()).setScale(3,RoundingMode.HALF_UP));
hashMap.put("list", bonuses);
return hashMap;
}
......
......@@ -11,6 +11,7 @@ import org.hibernate.annotations.NotFoundAction;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/**
......@@ -289,8 +290,8 @@ public class TbCfUserInfo {
@JsonProperty
public double getWallet() {
return bonus + withdraw;
public BigDecimal getWallet() {
return BigDecimal.valueOf(bonus + withdraw).setScale(3, RoundingMode.HALF_UP);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论