package com.jeequan.jeepay.mch.ctrl.route;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.entity.PayOrderCount;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.db.entity.PayOrder;
import com.jeequan.jeepay.db.entity.Route;
import com.jeequan.jeepay.db.entity.RouteRecord;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.PayOrderService;
import com.jeequan.jeepay.service.impl.RouteRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 路由运行策略
 * @date 2021-06-16 09:15
 */
@RestController
@RequestMapping("/api/routeData")
public class RouteDataController extends CommonCtrl {

    @Autowired
    private PayOrderService payOrderService;

    /**
     * @Description: 分页查询
     * @since 2024/04/19
     */
    @GetMapping
    public ApiRes list() {
        PayOrderCount entity = getObject(PayOrderCount.class).setMchNo(getCurrentMchNo());
        IPage<PayOrderCount> pages = payOrderService.routePageList(getIPage(true), entity);
        return ApiRes.page(pages);
    }

    /**
     * 统计
     * @return
     */
    @GetMapping("/count")
    public ApiRes count() {
        PayOrderCount entity = getObject(PayOrderCount.class).setMchNo(getCurrentMchNo());
        PayOrderCount orderCount = payOrderService.routeCount(entity);
        return ApiRes.ok(orderCount);
    }
}
