package com.ruoyi.xq.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.xq.domain.AuthOrder;
import com.ruoyi.xq.dto.app.pay.OrderCreateVo;
import com.ruoyi.xq.service.AuthOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/auth")
@Tag(name = "实名认证订单相关")
public class AuthOrderAppController {

    @Autowired
    private AuthOrderService authOrderService;

    @PostMapping("/order/create")
    @Operation(summary = "生成VIP订单")
    @Log(title = "生成VIP订单", businessType = BusinessType.OTHER, isSaveDb = true)
    public R<OrderCreateVo> createAuthOrder(){
        Long userId = LoginHelper.getUserId();
        AuthOrder authOrder = authOrderService.createVipOrder(userId);
        OrderCreateVo result = new OrderCreateVo();
        result.setPrice(authOrder.getPrice());
        result.setOrderNo(authOrder.getOrderNo());
        result.setOrderName(authOrder.getOrderName());
        return R.ok(result);
    }
}
