package com.gree.mall.miniapp.controller.pay;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.gree.mall.miniapp.bean.order.SettlementOrderDetail;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.order.PayOrderLogic;
import com.gree.mall.miniapp.plus.entity.SettlementOrder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;

@Slf4j
@RestController
@Api(value = "结算单", tags = {"结算单"})
@RequestMapping(value = "/settlementOrder", produces = "application/json; charset=utf-8")
public class SettlementOrderController {

    @Resource
    PayOrderLogic payOrderLogic;


    @PostMapping("/list/pageV2")
    @ApiOperation(value = "结算单列表")
    public ResponseHelper<IPage<SettlementOrder>> pageV2(
            @ApiParam(required = false, value = "结算状态: WAIT = 待结算 WAIT_ING 可提现 ING=提现中   OVER=已到账  ") @RequestParam(required = false) List<String> status,
            @ApiParam(required = false, value = "开始时间") @RequestParam(required = false) String startTime,
            @ApiParam(required = false, value = "结束时间") @RequestParam(required = false) String endTime,
            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
    ) {
        IPage<SettlementOrder> page = payOrderLogic.pageSettlementV2(status,startTime,endTime,pageNum,pageSize);
        return ResponseHelper.success(page);
    }



    @PostMapping("/detail")
    @ApiOperation("结算详情")
    public ResponseHelper<SettlementOrderDetail> detail(
            @ApiParam(value = "结算id" , required = true) @RequestParam(required = true) String id,

            HttpServletRequest request
    ) throws ParseException {
        SettlementOrderDetail  settlementOrderDetail = payOrderLogic.detail(id);
        return ResponseHelper.success(settlementOrderDetail);
    }

}
