package com.seer.teach.pay.app.wallet.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogOperation;
import com.seer.teach.common.enums.ModuleEnum;
import com.seer.teach.pay.app.refund.service.IAppRefundService;
import com.seer.teach.pay.app.wallet.req.AppCoinRefundReq;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
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;

@RestController
@Tag(name = "APP - 微信退款")
@Validated
@RequiredArgsConstructor
@RequestMapping("/app/wallet/refund")
@SaCheckLogin(type = StpUtil.TYPE)
@Slf4j
public class AppCoinRefundController {

    private final IAppRefundService applyRefundService;

    /**
     * 用户申请退款
     */
    @Operation(summary = "用户申请退款")
    @PostMapping("/{payOrderId}")
    @LogOperation(module = ModuleEnum.MALL_WECHAT, subModule = "用户申请退款" )
    @SaCheckPermission("app:pay:refund:apply")
    @DecryptionAnnotation
    @EncryptionAnnotation
    public ResultBean<Boolean> applyRefund(@PathVariable("payOrderId")Integer payOrderId,@RequestBody AppCoinRefundReq refundReq) {
        return ResultBean.success(applyRefundService.applyRefund(payOrderId,refundReq));
    }
}