package com.yida.data.school.transaction.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.FebsResponse;
import com.yida.data.school.transaction.service.EduProductOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "交易-订单(不鉴权)")
@AllArgsConstructor
@RestController
@RequestMapping("/in/transaction/order")
public class InEduProductOrderController {

    private final EduProductOrderService eduProductOrderService;

    @ApiOperation("微信通知结果回调")
    @PostMapping("/wxCall")
    public FebsResponse wxCall(@RequestBody Map<String, Object> res) {
        eduProductOrderService.wxCall(res);
        //不可更改
        return new FebsResponse().put("code", "SUCCESS");
    }

    @ApiOperation("更新订单状态")
    @GetMapping("/updateOrderStatus")
    public ResultBean updateOrderStatus() {
        eduProductOrderService.updateOrderStatus();
        return ResultBean.buildSuccess();
    }

    /**
     * 更新退款订单状态
     */
    @ApiOperation("更新退款订单状态")
    @GetMapping("/updateRefundStatus")
    public ResultBean updateRefundStatus() {
        eduProductOrderService.updateRefundStatus();
        return ResultBean.buildSuccess();
    }
}
