package cn.newfeifan.mall.module.pay.controller.app.fuyouorder;

import cn.newfeifan.mall.framework.common.pojo.CommonResult;
import cn.newfeifan.mall.module.pay.fuiou.reqvo.SubmitOrderRequestVO;
import cn.newfeifan.mall.module.pay.fuiou.respVO.FuYouPaymentResponseVO;
import cn.newfeifan.mall.module.pay.service.fuyouorder.FuYouPayOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 富有支付订单")
@RestController
@RequestMapping("/fuYou/pay/order")
@Validated
@Slf4j
public class NewPayOrderController {

    @Resource
    private FuYouPayOrderService fuYouPayOrderService;

    @PostMapping("/submit")
    @Operation(summary = "向富友提交支付订单")
    public CommonResult<String> submitFuYouPayOrder(@RequestBody SubmitOrderRequestVO reqVO) {

        String respVO = fuYouPayOrderService.submitOrder(reqVO);

        return success(respVO);
    }

    @PostMapping("/notify")
    @Operation(summary = "富友支付订单回调")
    public CommonResult<String> notifyFuYouPayOrder(@RequestBody FuYouPaymentResponseVO responseVO) {


        System.out.println(responseVO.toString());
//        fiYouPayOrderService.notifyOrder(notify);

        return success("success");
    }

    @PostMapping("/afterSale")
    @Operation(summary = "向富友申请退款")
    public CommonResult<String> afterSaleFuYouPayOrder(Long afterSaleId) {

        fuYouPayOrderService.afterSale(afterSaleId);

        return success("success");
    }
}
