package com.jeequan.jeepay.pay.ctrl.openapi;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.model.openapi.AccessReq;
import com.jeequan.jeepay.core.model.openapi.AccessResp;
import com.jeequan.jeepay.core.service.IOpenApiService;
import com.jeequan.jeepay.core.utils.JeepayKit;
import com.jeequan.jeepay.core.utils.SeqKit;
import com.jeequan.jeepay.pay.anno.OpenLabel;
import com.jeequan.jeepay.pay.ctrl.OpenApiController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * TODO
 * 交易Api控制器
 * @author crystal
 * @date 2024/4/7 15:03
 */
@Slf4j
@RestController
@RequestMapping("/api/open")
public class QueryOpenApiController extends OpenApiController {

    @Autowired
    @Qualifier("queryTradeOpenApiService")
    private IOpenApiService queryTradeService;

    @Autowired
    @Qualifier("queryRefundOpenApiService")
    private IOpenApiService queryRefundService;

    /**
     * 交易订单查询
     * @return
     */
    @OpenLabel
    @RequestMapping(value = "/query/trade")
    public AccessResp tradeQuery(){
        return queryTradeService.execute(getRQ());
    }


    /**
     * 退款订单查询
     * @return
     */
    @OpenLabel
    @RequestMapping(value = "/query/refund")
    public AccessResp refundQuery(){
        return queryRefundService.execute(getRQ());
    }

}
