package co.yixiang.yshop.module.distributor.controller.app.distributororder;

import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.security.core.annotations.PreAuthenticated;
import co.yixiang.yshop.module.distributor.controller.app.distributor.vo.AppDistributorOrderPageReqVO;
import co.yixiang.yshop.module.distributor.controller.app.distributororder.vo.AppDistributorOrderWagesRespVO;
import co.yixiang.yshop.module.distributor.dal.dataobject.distributororder.DistributorOrderDO;
import co.yixiang.yshop.module.distributor.service.distributororder.DistributorOrderFacade;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import java.time.LocalDateTime;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

@Slf4j
@RestController
@Tag(name = "APP - 分销商订单模块")
@RequestMapping("/app/distributor/order")
public class AppDistributorOrderController {

    @Resource
    private DistributorOrderFacade distributorOrderFacade;

    // 分销订单收益
    @PreAuthenticated
    @GetMapping("/wages")
    @Operation(summary = "分销收益")
    public CommonResult<AppDistributorOrderWagesRespVO> getAppWages(LocalDateTime[] createTime) {
        return success(distributorOrderFacade.getAppWages(createTime));
    }

    // 分销订单
    @PreAuthenticated
    @GetMapping("/page")
    @Operation(summary = "分销订单分页")
    public CommonResult<PageResult<DistributorOrderDO>> getAppPage(AppDistributorOrderPageReqVO reqVO) {
        return success(distributorOrderFacade.getAppPage(reqVO));
    }

}
