package com.ruoyi.web.controller.buyerapi;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.ruoyi.buyerapi.domain.BuyerBill;
import com.ruoyi.buyerapi.domain.BuyerCompanyInfo;
import com.ruoyi.buyerapi.domain.BuyerOrderRecord;
import com.ruoyi.buyerapi.service.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.parameters.P;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;

/**
 * 工作台Controller
 *
 * @author ruoyi
 * @date 2022-09-19
 */
@Api(tags = "工作台")
@RestController
@RequestMapping("/buyer/workbench")
public class BuyerWorkbenchController extends BaseController {
    @Autowired
    private IBuyerCompanyInfoService buyerCompanyInfoService;

    @Autowired
    private IBuyerBillService buyerBillService;

    @Autowired
    private IBuyerOrderRecordService buyerOrderRecordService;

    @Autowired
    private IBuyerGoodsService buyerGoodsService;

    @Autowired
    private ISysLogininforService sysLogininforService;

    /**
     * 统计工作台实时概况模块
     */
    @ApiOperation(value = "实时概况")
    @GetMapping("/situation")
    public Map situation() {
        Map map = new HashMap<String, Object>();
        // 统计销售额
        BigDecimal saleTotal = buyerGoodsService.selectMoneyBuyerGoods();
        // 统计订单数
        BuyerOrderRecord buyerOrderRecord = new BuyerOrderRecord();
        buyerOrderRecord.setOrderStatus("1");
        int orderTotal = buyerOrderRecordService.selectCountBuyerOrderRecord(buyerOrderRecord);
        // 统计访问人数
        List<SysLogininfor> list = sysLogininforService.selectLogininforList(new SysLogininfor());
        int visitTotal = list.size();
        // 统计消费人数
        int consumeTotal = buyerOrderRecordService.selectDistinctCountBuyerOrderRecord();
        map.put("saleTotal", saleTotal);
        map.put("orderTotal", orderTotal);
        map.put("visitTotal", visitTotal);
        map.put("consumeTotal", consumeTotal);
        return map;
    }

    /**
     * 统计工作台待处理模块
     */
    @ApiOperation(value = "待处理")
    @GetMapping("/pending")
    public Map pending() {
        Map map = new HashMap<String, Object>();
        // 统计企业审核认证数量
        BuyerCompanyInfo buyerCompanyInfo = new BuyerCompanyInfo();
        buyerCompanyInfo.setAuthStatus("1");
        int companyCheckTotal = buyerCompanyInfoService.selectCountBuyerCompanyInfo(buyerCompanyInfo);
        // 发票数量数量
        int billApplyTotal = buyerBillService.selectCountBuyerBillApply();
        // 发票总数量
        int total = companyCheckTotal + billApplyTotal;
        map.put("total", total);
        map.put("companyCheckTotal", companyCheckTotal);
        map.put("billApplyTotal", billApplyTotal);
        return map;
    }

    /**
     * 统计工作台会员统计模块
     */
    @ApiOperation(value = "会员统计")
    @GetMapping("/company")
    public Map company() {
        Map map = new HashMap<String, Object>();
        // 统计注册用户数量
        BuyerCompanyInfo buyerCompanyInfo = new BuyerCompanyInfo();
        int registerTotal = buyerCompanyInfoService.selectCountBuyerCompanyInfo(buyerCompanyInfo);
        // 统计会员数量
        buyerCompanyInfo = new BuyerCompanyInfo();
        buyerCompanyInfo.setType("0");
        int companyTotal = buyerCompanyInfoService.selectCountBuyerCompanyInfo(buyerCompanyInfo);
        // 统计非会员数量
        buyerCompanyInfo = new BuyerCompanyInfo();
        buyerCompanyInfo.setType("1");
        int noCompanyTotal = buyerCompanyInfoService.selectCountBuyerCompanyInfo(buyerCompanyInfo);
        // 统计认证企业数量
        buyerCompanyInfo = new BuyerCompanyInfo();
        buyerCompanyInfo.setAuthStatus("2");
        int authenticTotal = buyerCompanyInfoService.selectCountBuyerCompanyInfo(buyerCompanyInfo);
        map.put("registerTotal", registerTotal);
        map.put("companyTotal", companyTotal + "人" + " " + "占比" + (int) ((new BigDecimal((float) companyTotal / registerTotal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%");
        map.put("noCompanyTotal", noCompanyTotal + "人" + " " + "占比" + (int) ((new BigDecimal((float) noCompanyTotal / registerTotal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%");
        map.put("authenticTotal", authenticTotal + "人" + " " + "占比" + (int) ((new BigDecimal((float) authenticTotal / registerTotal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%");
        return map;
    }

    /**
     * 统计工作台订单统计模块
     */
    @ApiOperation(value = "订单统计")
    @GetMapping("/order")
    public Map order() {
        Map map = new HashMap<String, Object>();
        BuyerOrderRecord buyerOrderRecord = new BuyerOrderRecord();
        // 统计待付款订单数量
        buyerOrderRecord.setOrderStatus("0");
        int payTotal = buyerOrderRecordService.selectCountBuyerOrderRecord(buyerOrderRecord);
        // 统计已完成订单数量
        buyerOrderRecord.setOrderStatus("1");
        int finishTotal = buyerOrderRecordService.selectCountBuyerOrderRecord(buyerOrderRecord);
        // 统计已关闭订单数量
        buyerOrderRecord.setOrderStatus("2");
        int closeTotal = buyerOrderRecordService.selectCountBuyerOrderRecord(buyerOrderRecord);
        // 统计全部订单数量
        int Total = payTotal + finishTotal + closeTotal;
        map.put("Total", Total);
        map.put("payTotal", payTotal);
        map.put("finishTotal", finishTotal);
        map.put("closeTotal", closeTotal);
        return map;
    }

    /**
     * 统计工作台会员趋势模块
     */
    @ApiOperation(value = "会员趋势")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "choice", value = "昨日传yesterday，本周传week，本月传month", required = true, paramType = "query")
    })
    @GetMapping("/companyTrend")
    public Map companyTrend(BuyerCompanyInfo buyerCompanyInfo) {
        Map map = new HashMap<String, Object>();
        Date now = null;
        if(buyerCompanyInfo.getChoice().contains("-")){
            now = DateUtil.endOfMonth(DateUtil.parse(buyerCompanyInfo.getChoice(), DateUtils.YYYY_MM));
            buyerCompanyInfo.setChoice("month");
        }else{
            // 获取当前日期
            now = DateUtil.date();
        }
        switch (buyerCompanyInfo.getChoice()) {
            case "yesterday":
                // 获取昨天日期
                String yesterday = DateUtil.yesterday().toString("yyyy-MM-dd");
                Map dayDataMap = new LinkedHashMap();
                for (int i = 0; i < 24; i++) {
                    String hour = "";
                    // 获取24小时
                    if (i < 10) {
                        hour = "0" + hour + i;
                    } else {
                        hour = "" + i;
                    }
                    // 昨天日期和小时拼接
                    String yesterdayEveryHour = yesterday + " " + hour;
                    buyerCompanyInfo.setHour(yesterdayEveryHour);
                    dayDataMap.put(hour, buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                }
                map.put("list", dayDataMap);
                break;
            case "week":
                // 获取当前日期
                Date nowDate = DateUtil.date();
                // 获取本周的开始日期
                Date nowWeekStartDate = DateUtil.beginOfWeek(nowDate);
                // 获取本周的日期段
                List<DateTime> nowWeekDateList = DateUtil.rangeToList(nowWeekStartDate, nowDate, DateField.DAY_OF_MONTH);
                int i = 1;
                Map weekDataMap = new LinkedHashMap();
                for (DateTime dateTime : nowWeekDateList) {
                    // 获取当前周的每一天
                    String day = dateTime.toString("yyyy-MM-dd");
                    buyerCompanyInfo.setDay(day);
                    switch (i) {
                        case 1:
                            weekDataMap.put("Monday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                        case 2:
                            weekDataMap.put("Tuesday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                        case 3:
                            weekDataMap.put("Wednesday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                        case 4:
                            weekDataMap.put("Thursday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                        case 5:
                            weekDataMap.put("Friday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                        case 6:
                            weekDataMap.put("Saturday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                        case 7:
                            weekDataMap.put("Sunday", buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                            break;
                    }
                    i++;
                }
                map.put("list", weekDataMap);
                // 本周新增会员数
                buyerCompanyInfo = new BuyerCompanyInfo();
                buyerCompanyInfo.setStartDate(nowWeekStartDate);
                buyerCompanyInfo.setEndDate(nowDate);
                int nowWeekAmount = buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo);
                // 上周会员数量
                buyerCompanyInfo = new BuyerCompanyInfo();
                // 当前日期的上周
                Date lastWeekDate = DateUtil.lastWeek();
                // 上周的开始时间
                Date lastWeekStartDate = DateUtil.beginOfWeek(lastWeekDate);
                // 上周的结束时间
                Date lastWeekEndDate = DateUtil.endOfWeek(lastWeekDate);
                buyerCompanyInfo.setStartDate(lastWeekStartDate);
                buyerCompanyInfo.setEndDate(lastWeekEndDate);
                int lastWeenAmount = buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo);
                // 统计上周到这周的涨跌信息
                String weekTrend = "";
                if (nowWeekAmount >= lastWeenAmount) {
                    int addValue = nowWeekAmount - lastWeenAmount;
                    try {
                        weekTrend = "上涨" + (int) ((new BigDecimal((float) addValue / lastWeenAmount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%";
                    } catch (Exception e) {
                        weekTrend = "涨跌未知";
                    }
                } else {
                    int reducceValue = lastWeenAmount - nowWeekAmount;
                    try {
                        weekTrend = "下跌" + (int) ((new BigDecimal((float) reducceValue / lastWeenAmount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%";
                    } catch (Exception e) {
                        weekTrend = "涨跌未知";
                    }
                }
                Map weekDataMapInfo = new LinkedHashMap();
                weekDataMapInfo.put("amount", nowWeekAmount);
                weekDataMapInfo.put("trend", weekTrend);
                map.put("info", weekDataMapInfo);
                break;
            case "month":
                // 获取本月的开始日期
                Date nowMonthStart = DateUtil.beginOfMonth(now);
                // 获取本周的日期段
                List<DateTime> noMonthDateList = DateUtil.rangeToList(nowMonthStart, now, DateField.DAY_OF_MONTH);
                Map monthDataMap = new LinkedHashMap();
                for (DateTime dateTime : noMonthDateList) {
                    // 获取当前月的每一天
                    String day = dateTime.toString("yyyy-MM-dd");
                    buyerCompanyInfo.setDay(day);
                    monthDataMap.put(day, buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo));
                }
                map.put("list", monthDataMap);
                // 本月新增会员数
                buyerCompanyInfo = new BuyerCompanyInfo();
                buyerCompanyInfo.setStartDate(nowMonthStart);
                buyerCompanyInfo.setEndDate(now);
                int nowMonthAmount = buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo);
                // 上月会员数量
                buyerCompanyInfo = new BuyerCompanyInfo();
                // 当前日期的上月
                Date lastMonthDate = DateUtil.lastMonth();
                // 上月的开始时间
                Date lastMonthStartDate = DateUtil.beginOfMonth(lastMonthDate);
                // 上月的结束时间
                Date lastMonthEndDate = DateUtil.endOfMonth(lastMonthDate);
                buyerCompanyInfo.setStartDate(lastMonthStartDate);
                buyerCompanyInfo.setEndDate(lastMonthEndDate);
                int lastMonthAmount = buyerCompanyInfoService.selectTrendBuyerCompanyInfo(buyerCompanyInfo);
                // 统计上月到这月的涨跌信息
                String monthTrend = "";
                if (nowMonthAmount >= lastMonthAmount) {
                    int addValue = nowMonthAmount - lastMonthAmount;
                    try {
                        monthTrend = "上涨" + (int) ((new BigDecimal((float) addValue / lastMonthAmount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%";
                    } catch (Exception e) {
                        monthTrend = "涨跌未知";
                    }
                } else {
                    int reducceValue = lastMonthAmount - nowMonthAmount;
                    try {
                        monthTrend = "下跌" + (int) ((new BigDecimal((float) reducceValue / lastMonthAmount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100) + "%";
                    } catch (Exception e) {
                        monthTrend = "涨跌未知";
                    }
                }
                Map monthDataMapInfo = new LinkedHashMap();
                monthDataMapInfo.put("amount", nowMonthAmount);
                monthDataMapInfo.put("trend", monthTrend);
                map.put("info", monthDataMapInfo);
                break;
        }
        return map;
    }

    /**
     * 统计工作台销售趋势模块
     */
    @ApiOperation(value = "销售趋势")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "choice", value = "昨日传yesterday，本周传week，本月传month", required = true, paramType = "query")
    })
    @GetMapping("/saleTrend")
    public Map saleTrend(BuyerOrderRecord buyerOrderRecord) {
        Map map = new HashMap<String, Object>();
        Date now = null;
        if(buyerOrderRecord.getChoice().contains("-")){
            now = DateUtil.endOfMonth(DateUtil.parse(buyerOrderRecord.getChoice(), DateUtils.YYYY_MM));
            buyerOrderRecord.setChoice("month");
        }else{
            // 获取当前日期
            now = DateUtil.date();
        }
        switch (buyerOrderRecord.getChoice()) {
            case "yesterday":
                // 获取昨天日期
                String yesterday = DateUtil.yesterday().toString("yyyy-MM-dd");
                Map dayDataMap = new LinkedHashMap();
                for (int i = 0; i < 24; i++) {
                    // 获取24小时
                    String hour = "";
                    if (i < 10) {
                        hour = "0" + hour + i;
                    } else {
                        hour = "" + i;
                    }
                    // 昨天日期和小时拼接
                    String yesterdayEveryHour = yesterday + " " + hour;
                    buyerOrderRecord.setHour(yesterdayEveryHour);
                    dayDataMap.put(hour, buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                }
                map.put("list", dayDataMap);
                break;
            case "week":
                // 获取当前日期
                Date nowDate = DateUtil.date();
                // 获取本周的开始日期
                Date nowWeekStartDate = DateUtil.beginOfWeek(nowDate);
                // 获取本周的日期段
                List<DateTime> nowWeekDateList = DateUtil.rangeToList(nowWeekStartDate, nowDate, DateField.DAY_OF_MONTH);
                int i = 1;
                Map weekDataMap = new LinkedHashMap();
                for (DateTime dateTime : nowWeekDateList) {
                    // 获取当前周的每一天
                    String day = dateTime.toString("yyyy-MM-dd");
                    buyerOrderRecord.setDay(day);
                    switch (i) {
                        case 1:
                            weekDataMap.put("Monday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                            break;
                        case 2:
                            weekDataMap.put("Tuesday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                            break;
                        case 3:
                            weekDataMap.put("Wednesday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                            break;
                        case 4:
                            weekDataMap.put("Thursday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                            break;
                        case 5:
                            weekDataMap.put("Friday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                            break;
                        case 6:
                            weekDataMap.put("Saturday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                        case 7:
                            weekDataMap.put("Sunday", buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                            break;
                    }
                    i++;
                }
                map.put("list", weekDataMap);
                // 本周销售额
                buyerOrderRecord = new BuyerOrderRecord();
                buyerOrderRecord.setStartDate(nowWeekStartDate);
                buyerOrderRecord.setEndDate(nowDate);
                BigDecimal nowWeekAmount = buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : new BigDecimal(0);
                // 上周销售额
                buyerOrderRecord = new BuyerOrderRecord();
                // 当前日期的上周
                Date lastWeekDate = DateUtil.lastWeek();
                // 上周的开始时间
                Date lastWeekStartDate = DateUtil.beginOfWeek(lastWeekDate);
                // 上周的结束时间
                Date lastWeekEndDate = DateUtil.endOfWeek(lastWeekDate);
                buyerOrderRecord.setStartDate(lastWeekStartDate);
                buyerOrderRecord.setEndDate(lastWeekEndDate);
                BigDecimal lastWeenAmount = buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : new BigDecimal(0);
                // 统计上周到这周的涨跌信息
                String weekTrend = "";
                if (nowWeekAmount.compareTo(lastWeenAmount) > 0) {
                    BigDecimal addValue = nowWeekAmount.subtract(lastWeenAmount);
                    try {
                        weekTrend = "上涨" + addValue.divide(lastWeenAmount, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)) + "%";
                    } catch (Exception e) {
                        weekTrend = "涨跌未知";
                    }
                } else {
                    BigDecimal reducceValue = lastWeenAmount.subtract(nowWeekAmount);
                    try {
                        weekTrend = "下跌" + reducceValue.divide(lastWeenAmount, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)) + "%";
                    } catch (Exception e) {
                        weekTrend = "涨跌未知";
                    }
                }
                Map weekDataMapInfo = new LinkedHashMap();
                weekDataMapInfo.put("amount", nowWeekAmount);
                weekDataMapInfo.put("trend", weekTrend);
                map.put("info", weekDataMapInfo);
                break;
            case "month":
                // 获取本月的开始日期
                Date nowMonthStart = DateUtil.beginOfMonth(now);
                // 获取本周的日期段
                List<DateTime> noMonthDateList = DateUtil.rangeToList(nowMonthStart, now, DateField.DAY_OF_MONTH);
                Map monthDataMap = new LinkedHashMap();
                for (DateTime dateTime : noMonthDateList) {
                    // 获取当前月的每一天
                    String day = dateTime.toString("yyyy-MM-dd");
                    buyerOrderRecord.setDay(day);
                    monthDataMap.put(day, buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : 0);
                }
                map.put("list", monthDataMap);
                // 本月销售额
                buyerOrderRecord = new BuyerOrderRecord();
                buyerOrderRecord.setStartDate(nowMonthStart);
                buyerOrderRecord.setEndDate(now);
                BigDecimal nowMonthAmount = buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : new BigDecimal(0);
                // 上月销售额
                buyerOrderRecord = new BuyerOrderRecord();
                // 当前日期的上月
                Date lastMonthDate = DateUtil.lastMonth();
                // 上月的开始时间
                Date lastMonthStartDate = DateUtil.beginOfMonth(lastMonthDate);
                // 上月的结束时间
                Date lastMonthEndDate = DateUtil.endOfMonth(lastMonthDate);
                buyerOrderRecord.setStartDate(lastMonthStartDate);
                buyerOrderRecord.setEndDate(lastMonthEndDate);
                BigDecimal lastMonthAmount = buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) != null ? buyerOrderRecordService.selectTrendBuyerOrderRecord(buyerOrderRecord) : new BigDecimal(0);
                // 统计上月到这月的涨跌信息
                String monthTrend = "";
                if (nowMonthAmount.compareTo(lastMonthAmount) > 0) {
                    BigDecimal addValue = nowMonthAmount.subtract(lastMonthAmount);
                    try {
                        monthTrend = "上涨" + addValue.divide(lastMonthAmount, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)) + "%";
                    } catch (Exception e) {
                        monthTrend = "涨跌未知";
                    }
                } else {
                    BigDecimal reducceValue = lastMonthAmount.subtract(nowMonthAmount);
                    try {
                        monthTrend = "下跌" + reducceValue.divide(lastMonthAmount, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)) + "%";
                    } catch (Exception e) {
                        monthTrend = "涨跌未知";
                    }
                }
                Map monthDataMapInfo = new LinkedHashMap();
                monthDataMapInfo.put("amount", nowMonthAmount);
                monthDataMapInfo.put("trend", monthTrend);
                map.put("info", monthDataMapInfo);
                break;
        }
        return map;
    }
}
