package com.liquidnet.service.goblin.controller;

import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.service.IGoblinSqbOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 收钱吧回调 Controller（收钱吧主动推送，无需鉴权）
 */
@Slf4j
@Api(tags = "收钱吧回调")
@RestController
public class GoblinSqbCallbackController {

    @Autowired
    private IGoblinSqbOrderService goblinSqbOrderService;

    /**
     * 支付成功回调
     * URL: https://testgoblin.zhengzai.tv/goblin/sqb/order/callback
     */
    @PostMapping("/goblin/sqb/order/callback")
    @ApiOperation("支付成功回调")
    public ResponseDto<String> payCallback(@RequestBody Map<String, Object> params) {
        log.info("[收钱吧支付回调] 收到推送");
        return goblinSqbOrderService.handlePayCallback(params);
    }

    /**
     * 退款成功回调
     * URL: https://testgoblin.zhengzai.tv/goblin/sqb/refund/callback
     */
    @PostMapping("/goblin/sqb/refund/callback")
    @ApiOperation("退款成功回调")
    public ResponseDto<String> refundCallback(@RequestBody Map<String, Object> params) {
        log.info("[收钱吧退款回调] 收到推送");
        return goblinSqbOrderService.handleRefundCallback(params);
    }

    /**
     * 券状态变更回调
     * URL: https://testgoblin.zhengzai.tv/goblin/sqb/coupon/callback
     */
    @PostMapping("/goblin/sqb/coupon/callback")
    @ApiOperation("券状态变更回调")
    public ResponseDto<String> couponCallback(@RequestBody Map<String, Object> params) {
        log.info("[收钱吧券状态回调] 收到推送");
        return goblinSqbOrderService.handleCouponCallback(params);
    }
}
