package com.ycwl.basic.integration.profitshare.client;

import com.ycwl.basic.integration.common.response.CommonResponse;
import com.ycwl.basic.integration.common.response.PageResponse;
import com.ycwl.basic.integration.profitshare.dto.CalculateResultVO;
import com.ycwl.basic.integration.profitshare.dto.CalculateShareRequest;
import com.ycwl.basic.integration.profitshare.dto.ManualShareRequest;
import com.ycwl.basic.integration.profitshare.dto.TypesVO;
import com.ycwl.basic.integration.profitshare.dto.record.RecordDetailVO;
import com.ycwl.basic.integration.profitshare.dto.record.RecordVO;
import com.ycwl.basic.integration.profitshare.dto.rule.CreateRuleRequest;
import com.ycwl.basic.integration.profitshare.dto.rule.RuleVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 分账服务Feign客户端
 *
 * @author Claude Code
 * @date 2025-01-11
 */
@FeignClient(name = "zt-profitshare", contextId = "profit-share-v2", path = "/api/profit-share/v2")
public interface ProfitShareClient {

    /**
     * 创建分账规则
     */
    @PostMapping("/rules")
    CommonResponse<RuleVO> createRule(@RequestBody CreateRuleRequest request);

    /**
     * 查询分账规则列表
     */
    @GetMapping("/rules")
    CommonResponse<PageResponse<RuleVO>> listRules(@RequestParam(value = "scenic_id", required = false) Long scenicId,
                                                    @RequestParam(value = "status", required = false) String status,
                                                    @RequestParam(value = "rule_type", required = false) String ruleType,
                                                    @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                    @RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);

    /**
     * 获取分账规则详情
     */
    @GetMapping("/rules/{id}")
    CommonResponse<RuleVO> getRule(@PathVariable("id") Long ruleId);

    /**
     * 更新分账规则
     */
    @PutMapping("/rules/{id}")
    CommonResponse<RuleVO> updateRule(@PathVariable("id") Long ruleId,
                                      @RequestBody CreateRuleRequest request);

    /**
     * 删除分账规则
     */
    @DeleteMapping("/rules/{id}")
    CommonResponse<Void> deleteRule(@PathVariable("id") Long ruleId);

    /**
     * 启用规则
     */
    @PutMapping("/rules/{id}/enable")
    CommonResponse<Void> enableRule(@PathVariable("id") Long ruleId);

    /**
     * 禁用规则
     */
    @PutMapping("/rules/{id}/disable")
    CommonResponse<Void> disableRule(@PathVariable("id") Long ruleId);

    /**
     * 查询景区分账记录
     */
    @GetMapping("/records/scenic/{scenic_id}")
    CommonResponse<PageResponse<RecordVO>> getRecordsByScenic(@PathVariable("scenic_id") Long scenicId,
                                                               @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                               @RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);

    /**
     * 查询分账记录详情
     */
    @GetMapping("/records/{id}")
    CommonResponse<RecordDetailVO> getRecordById(@PathVariable("id") Long recordId);

    /**
     * 按订单ID查询分账记录
     */
    @GetMapping("/records/order/{order_id}")
    CommonResponse<RecordDetailVO> getRecordByOrderId(@PathVariable("order_id") String orderId);

    /**
     * 手动触发分账
     */
    @PostMapping("/manual")
    CommonResponse<Void> manualShare(@RequestBody ManualShareRequest request);

    /**
     * 计算分账金额（不执行）
     */
    @PostMapping("/calculate")
    CommonResponse<CalculateResultVO> calculateShare(@RequestBody CalculateShareRequest request);

    /**
     * 获取支持的类型
     */
    @GetMapping("/types")
    CommonResponse<TypesVO> getSupportedTypes();
}
