package com.sonic.lion.controller.web;

import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Result;
import com.sonic.lion.domain.input.SubChargeProductListInput;
import com.sonic.lion.domain.output.ChargeProductConfigOutput;
import com.sonic.lion.domain.output.EnabledPayChannelOutput;
import com.sonic.lion.domain.output.SubProductListOutput;
import com.sonic.lion.service.ChargeProductConfigService;
import com.sonic.lion.service.PayChargeService;
import com.sonic.lion.service.PayConfigService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 支付相关配置
 * @author: code
 * @date: 2025/06/22
 * @Description:
 * @version: 1.0.0
 */
@RestController
public class PayConfigController {

    @Autowired
    private PayChargeService payChargeService;
    @Autowired
    private PayConfigService payConfigService;
    @Autowired
    private ChargeProductConfigService chargeProductConfigService;

    @ApiOperation(value = "充值可用的支付渠道列表", tags = "支付相关配置")
    @PostMapping("/web/pay/config/enabled-pay-channel")
    public Result<EnabledPayChannelOutput> enabledPayChannel(@ApiParam(hidden = true) Session session) {
        return Result.success(payConfigService.enabledPayChannel(session.getUserId()));
    }

    @ApiOperation(value = "充值档位列表", tags = "支付相关配置")
    @PostMapping("/web/pay/config/charge-product-list")
    public Result<ChargeProductConfigOutput> chargeList(@RequestBody @Validated SubChargeProductListInput input, @ApiParam(hidden = true) Session session) {
        ChargeProductConfigOutput output = chargeProductConfigService.getRechargeLevelConfig(session.getUserId(), input.getPlatform(), input.getVersion());
        return Result.success(output);
    }

    @ApiOperation(value = "订阅档位列表", tags = "支付相关配置")
    @PostMapping("/web/pay/config/sub-product-list")
    public Result<List<SubProductListOutput>> subProductList(@RequestBody @Validated SubChargeProductListInput input) {
        return Result.success(payChargeService.subProductList(input));
    }

}
