yujian
2019-05-20 c4d752a1d340652d9c7d2abb5abff65cdee40d69
fanli/src/main/java/com/yeshi/fanli/controller/client/UserMoneyController.java
@@ -13,6 +13,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.BigDecimalUtil;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
@@ -124,7 +125,8 @@
            if (value == null) {
               return new JsonPrimitive("");
            } else {
               return new JsonPrimitive(MoneyBigDecimalUtil.getWithNoZera(value).toString());
               value = value.setScale(2);
               return new JsonPrimitive(value.toString());
            }
         }
      });
@@ -271,8 +273,21 @@
      // 全部未到账
      minDate = new Date(0);
      vo.setTotalUnRecievedMoney(hongBaoV2Service.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate));
      Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
      out.print(JsonUtil.loadTrueResult(gson.toJson(vo)));
      GsonBuilder builder = new GsonBuilder();
      builder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
         @Override
         public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
            if (value == null) {
               return new JsonPrimitive("");
            } else {
               // 保留2位小数
               value = value.setScale(2);
               return new JsonPrimitive(value.toString());
            }
         }
      });
      out.print(JsonUtil.loadTrueResult(builder.create().toJson(vo)));
   }
}