package com.iformall.controller.datatower;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.service.WxChartDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(description = "图表")
@RestController
@RequestMapping("chart")
public class WxChartDataController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxChartDataService wxChartDataService;

    @ApiOperation(
            "chart=45 卡营销数据:" +
            "saleHistory销售金额历史 paymentHistory核销历史 saleCardCount售出卡数量 tranCount转增数量 subsidyCount补贴金额"+
            "--------------------------------------" +
            "chart=46 卷营销数据:" +
            "orderCountList卷购买数量历史 paymentCountList卷核销数量 priceCouponSaleCountList有价卷销售数量历史 " +
            "priceCouponPaymentCountList有价卷核销数量历史 sumPriceSaleMoney有价券销售总额 sumPricePayMent有价卷核销总额 " +
            "sumSubsidyMoney商场补贴金额 priceCouponCancelCount有价卷退款数量 priceCouponSaleCountListTotal有价券售出数量"+
            "--------------------------------------" +
            "chart=47 砍价营销数据:" +
            "pressSendHistory砍价发起历史 pressSuccHistory砍价成功历史 pressPaymentHistory砍价核销历史 " +
            "pressSendHistoryTotal发起总数 pressSuccHistoryCount成功总数 pressPaymentHistoryCount核销总数 pressSuccRate成功率 sumJoin参与人数"+
            "--------------------------------------"+
            "chart=49商铺出租数据:" +
            "total商铺总数 totalShop店铺个数 totalPoint多径点位个数, rentTotal已出租总数 rentTotalShop已出租店铺 rentTotalPoint已出租点位" +
            ",notRentTotal未出租总数 notRentTotalShop未出租店铺 notRentTotalPoint未出租点位," +
                    "rentTotalRate店铺出租率 rentTotalShopRate商铺出租率 rentTotalPointRate点位出租率" +
            "，"+
            "--------------------------------------"+
            "chart=50费用收缴数据:" +
            "ysje 应收金额 ssje 实收金额 zjsjl收缴率 rent*租赁收缴率  property*物业收缴率 deposit*押金收缴率  other*其他费用收缴率" +
            "rentOwe 租赁总额  propertyOwe物业总额  otherOwe其他总额  depositOwe押金总额  totalOwe欠缴总额"+
            "--------------------------------------"+
            "chart=51首页场景发卷:" +
            "carStopHistory停车发卷 couponVerifyHistory核销发卷 orderHistory交易发卷 micropayHistory收银台发卷 merchantHistory商户发券"+
            "--------------------------------------"+
            "chart=52营销数据:" +
            "当前”券交易数据“替换为”营销数据“:cardHistory卡营销历史 pressSendHistory砍价营销历史 groupHistory拼团营销历史 couponHistory卷营销历史，" +
            "卡、卷、砍价、拼团走势以及右边的数据总览，对应原来 营销系统->卡、卷、砍价、拼团营销数据" +
            "--------------------------------------" +
                    "触达用户=数据总览的活跃用户数据" + "------------------------------" +
                    "chart=48拼团营销数据:拼团成功次数successList verifyList核销量 拼团发起次数groupCount 拼团成功successCount 参与拼团人次peopleCount" +
                    "拼团成功人次successPeopleCount 拼团转化率transferRatio 核销数verifyCount"
    )
    @GetMapping("/queryData")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "chart", value = "chart", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "startdate", value = "startdate", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "enddate", value = "enddate", dataType = "String", paramType = "query")
    })
    @SystemControllerLog(description = "报表-图表")
    public ResultData queryData(@RequestParam Map<String, String> params) {
        String chart = params.get("chart");
        logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart);
        params.put("tenantId",super.getTenantId());
        ResultData data = wxChartDataService.queryData(params);
        logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart + " end");
        return data;
    }

}
