admin
2022-05-19 a44f2c3b5db92069ea2813ecf8cb12a6ab3b2203
app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornConsumeRecordAdminController.java
@@ -7,6 +7,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yeshi.utils.BigDecimalUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.TimeUtil;
import com.google.gson.reflect.TypeToken;
@@ -14,6 +15,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
@@ -28,6 +31,13 @@
    @Resource
    private GoldCornConsumeRecordService goldCornConsumeRecordService;
    Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
        @Override
        public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
            return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm"));
        }
    }).create();
    @ResponseBody
    @RequestMapping("list")
@@ -35,15 +45,12 @@
        List<GoldCornConsumeRecord> list = goldCornConsumeRecordService.list(query, page, limit);
        long count = goldCornConsumeRecordService.count(query);
        JSONObject data = new JSONObject();
        Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
        JSONArray array = JSONArray.fromObject(gson.toJson(list));
        for (int i = 0; i < array.size(); i++) {
            array.optJSONObject(i).put("money", new BigDecimal(array.optJSONObject(i).optLong("money")).divide(new BigDecimal(100), 2, RoundingMode.FLOOR));
        }
            @Override
            public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
                return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm"));
            }
        }).create();
        data.put("list", gson.toJson(list));
        data.put("list", array);
        data.put("count", count);
        return JsonUtil.loadTrueResult(data);
@@ -57,7 +64,6 @@
        List<String> idList = new Gson().fromJson(ids, type);
        goldCornConsumeRecordService.delete(idList);
        return JsonUtil.loadTrueResult("");
    }