package com.gic.haoban.manage.web.controller.moment;

import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.web.qo.moment.MomentDataQO;
import com.gic.haoban.manage.web.vo.moment.MomentDataClickVO;
import com.gic.haoban.manage.web.vo.moment.MomentDataMemberVO;
import com.gic.haoban.manage.web.vo.moment.MomentDataOrderVO;
import com.gic.haoban.manage.web.vo.moment.MomentDataVO;
import com.gic.web.common.utils.DataApiUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 企微朋友圈-数据
 */
@RestController
@RequestMapping("/qw-moment")
public class QwMomentDataController {

    private static Logger logger = LogManager.getLogger(QwMomentDataController.class);

    /**
     * 概览
     */
    @RequestMapping("data_qw_moment_plan_overview")
    public RestResponse<MomentDataVO> data(@RequestBody MomentDataQO qo) {
        WebLoginDTO user = AuthWebRequestUtil.getLoginUser();
        String enterpriseId = user.getEnterpriseId();
        JSONObject json = new JSONObject();
        json.put("planId", qo.getPlanId()) ;
        json.put("enterpriseId",enterpriseId) ;
        Map<String, Object> res = DataApiUtils.http(json.toJSONString(), "data_qw_moment_plan_overview");
        JSONObject data = DataApiUtils.getPageOne(res);
        MomentDataVO vo = new MomentDataVO();
        if(null != data) {
            vo.setMatlClickCnt(data.getInteger("matlClickCnt"));
            vo.setMatlClickMbrNum(data.getInteger("matlClickMbrNum"));
            vo.setMatlConvsAmt(data.getDoubleValue("matlConvsAmt"));
            vo.setMatlConvsMbrNum(data.getInteger("matlConvsMbrNum"));
        }
        return RestResponse.successResult(vo);
    }

    /**
     * 转化会员
     */
    @RequestMapping("data_qw_moment_mbr_detail")
    public RestResponse<Page<MomentDataMemberVO>> memberData(@RequestBody MomentDataQO qo) {
        return RestResponse.successResult(null);
    }

    /**
     * 转化会员导出
     */
    @RequestMapping("data_qw_moment_mbr_detail_excel")
    public RestResponse<String> memberDataExcel(@RequestBody MomentDataQO qo) {
        return RestResponse.successResult(null);
    }

    /**
     * 转化订单
     */
    @RequestMapping("data_qw_moment_order_detail")
    public RestResponse<Page<MomentDataOrderVO>> orderData(@RequestBody MomentDataQO qo) {
        return RestResponse.successResult(null);
    }

    /**
     * 转化订单导出
     */
    @RequestMapping("data_qw_moment_order_detail_excel")
    public RestResponse<String> orderDataExcel(@RequestBody MomentDataQO qo) {
        return RestResponse.successResult(null);
    }

    /**
     * 点击数据
     */
    @RequestMapping("data_qw_moment_mbr_click_detail")
    public RestResponse<Page<MomentDataClickVO>> clerkData(@RequestBody MomentDataQO qo) {
        return RestResponse.successResult(null);
    }

    /**
     * 点击导出
     */
    @RequestMapping("data_qw_moment_mbr_click_detail_excel")
    public RestResponse<String> clerkDataExcel(@RequestBody MomentDataQO qo) {
        return RestResponse.successResult(null);
    }
}
