package com.cool.store.controller.webc;

import com.cool.store.request.OrderSummaryRequest;
import com.cool.store.request.bigdata.ProfitDataRequest;
import com.cool.store.request.huoma.ShopBasicInfoRequest;
import com.cool.store.request.oppty.*;
import com.cool.store.response.IncomeBaseResponse;
import com.cool.store.response.IncomeSummaryResponse;
import com.cool.store.response.OrderSummaryResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.bigdata.ActDataResponse;
import com.cool.store.response.bigdata.ProfitDataResponse;
import com.cool.store.response.bigdata.ProfitRateResponse;
import com.cool.store.response.huoma.ShopBaseInfoResponse;
import com.cool.store.response.oppty.CityResponse;
import com.cool.store.response.oppty.OpportunityDetailResponse;
import com.cool.store.response.oppty.OpportunityInfoPageResponse;
import com.cool.store.service.HuoMaService;
import com.cool.store.service.ThirdBigDataService;
import com.cool.store.service.ThirdOpportunityService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Author suzhuhong
 * @Date 2025/4/1 20:49
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/mini/third/api")
public class ThirdApiController {

    @Resource
    ThirdOpportunityService thirdOpportunityService;
    @Resource
    ThirdBigDataService thirdBigDataService;
    @Resource
    HuoMaService huoMaService;

    @PostMapping("/list")
    @ApiOperation("机会点列表/我的机会点")
    public ResponseResult<OpportunityInfoPageResponse> listOpportunities(@Valid @RequestBody OpportunityListRequest request) {
        return ResponseResult.success(thirdOpportunityService.listOpportunities(request));
    }


    @PostMapping("/getOpportunitiesDetail")
    @ApiOperation("机会点详情")
    public ResponseResult<OpportunityDetailResponse> getOpportunitiesDetail(@Valid @RequestBody OpportunityDetailRequest request) {
        return ResponseResult.success(thirdOpportunityService.getOpportunitiesDetail(request));
    }


    @PostMapping("/followOpportunity")
    @ApiOperation("关注/取消关注 机会点")
    public ResponseResult<String> followOpportunity(@Valid @RequestBody FollowRequest request) {
        return ResponseResult.success(thirdOpportunityService.followOpportunity(request));
    }

    @PostMapping("/inspectionOpportunity")
    @ApiOperation("考察机会点")
    public ResponseResult<String> inspectionOpportunity(@Valid @RequestBody InspectionRequest request) {
        return ResponseResult.success(thirdOpportunityService.inspectionOpportunity(request));
    }

    @PostMapping("/berthOperation")
    @ApiOperation("铺位关注机会点")
    public ResponseResult<String> berthOperation(@Valid @RequestBody BerthOperationRequest request) {
        return ResponseResult.success(thirdOpportunityService.berthOperation(request));
    }

    @PostMapping("/storeOperation")
    @ApiOperation("门店关注机会点")
    public ResponseResult<String> storeOperation(@Valid @RequestBody StoreOperationRequest request) {
        return ResponseResult.success(thirdOpportunityService.storeOperation(request));
    }

    @PostMapping("/cityList")
    @ApiOperation("省市区列表 查询省传0")
    public ResponseResult<List<CityResponse>> listOpportunities(@Valid @RequestBody CityRequest request) {
        // 调用第三方接口
        return ResponseResult.success(thirdOpportunityService.cityList(request));
    }

    @PostMapping("/getProfitData")
    @ApiOperation("昨天毛利")
    public ResponseResult<ProfitDataResponse> listOpportunities(@Valid @RequestBody ProfitDataRequest request) {
        // 调用第三方接口
        return ResponseResult.success(thirdBigDataService.getProfitData(request));
    }

    @PostMapping("/getCurMonthProfitData")
    @ApiOperation("本月毛利")
    public ResponseResult<ProfitDataResponse> getCurMonthProfitData(@Valid @RequestBody ProfitDataRequest request) {
        // 调用第三方接口
        return ResponseResult.success(thirdBigDataService.getCurMonthProfitData(request));
    }


    @PostMapping("/getPreMonthProfitData")
    @ApiOperation("上月毛利")
    public ResponseResult<ProfitDataResponse> getPreMonthProfitData(@Valid @RequestBody ProfitDataRequest request) {
        // 调用第三方接口
        return ResponseResult.success(thirdBigDataService.getPreMonthProfitData(request));
    }


    @PostMapping("/getMonthProfitTrend")
    @ApiOperation("毛利趋势")
    public ResponseResult<List<ProfitRateResponse>> getMonthProfitTrend(@Valid @RequestBody ProfitDataRequest request) {
        // 调用第三方接口
        return ResponseResult.success(thirdBigDataService.getMonthProfitTrend(request));
    }

    @PostMapping("/getActData")
    @ApiOperation("门店实收")
    public ResponseResult<ActDataResponse> getActData(@Valid @RequestBody ProfitDataRequest request) {
        // 调用第三方接口
        return ResponseResult.success(thirdBigDataService.getActData(request));
    }

    @PostMapping("/getShopInfo")
    @ApiOperation("火码 查询门店信息")
    public ResponseResult<ShopBaseInfoResponse> getShopInfo(@Valid @RequestBody ShopBasicInfoRequest request) {
        // 调用第三方接口
        return ResponseResult.success(huoMaService.getShopInfo(request));
    }

    @PostMapping("/getTodayPreIncome")
    @ApiOperation("火码 获取店铺今日预收金额")
    public ResponseResult<IncomeBaseResponse> getTodayPreIncome(@Valid @RequestBody ShopBasicInfoRequest request) {
        // 调用第三方接口
        return ResponseResult.success(huoMaService.getTodayPreIncome(request));
    }

    @PostMapping("/getYesterdayPreIncome")
    @ApiOperation("火码 获取店铺昨日预计收入")
    public ResponseResult<IncomeBaseResponse> getYesterdayPreIncome(@Valid @RequestBody ShopBasicInfoRequest request) {
        // 调用第三方接口
        return ResponseResult.success(huoMaService.getYesterdayPreIncome(request));
    }

    @PostMapping("/getMonthPreIncome")
    @ApiOperation("火码 获取店铺当月预计收入")
    public ResponseResult<IncomeBaseResponse> getMonthPreIncome(@Valid @RequestBody ShopBasicInfoRequest request) {
        // 调用第三方接口
        return ResponseResult.success(huoMaService.getMonthPreIncome(request));
    }

    @PostMapping("/getOrderSummary")
    @ApiOperation("火码 获取店铺营业概览")
    public ResponseResult<OrderSummaryResponse> getOrderSummary(@Valid @RequestBody OrderSummaryRequest request) {
        // 调用第三方接口
        return ResponseResult.success(huoMaService.getOrderSummary(request));
    }

    @PostMapping("/getIncomeSummary")
    @ApiOperation("火码 获取店铺交易分析")
    public ResponseResult<IncomeSummaryResponse> getIncomeSummary(@Valid @RequestBody OrderSummaryRequest request) {
        // 调用第三方接口
        return ResponseResult.success(huoMaService.getIncomeSummary(request));
    }


}
