package com.iformall.controller.market;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.vo.WxProfitSharingOrderQueryVo;
import com.iformall.domain.vo.WxProfitSharingOrderVo;
import com.iformall.service.WxProfitSharingOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author gongbiao
 */
@RestController
@RequestMapping("wxProfitSharingOrder")
@Api(description = "微信分账订单接口")
public class WxProfitSharingOrderController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxProfitSharingOrderService wxProfitSharingOrderService;

    @ApiOperation("分页列表接口")
    @GetMapping("list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
    @SystemControllerLog(description = "分账订单-列表")
    public ResultData list(@ModelAttribute WxProfitSharingOrderQueryVo order, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::list");
        if (null == order) {
            order = new WxProfitSharingOrderQueryVo();
        }
        final PageInfo<WxProfitSharingOrderVo> page = wxProfitSharingOrderService.listAsPage(order, pageNum, pageSize);
        return new ResultData(page);
    }

    @ApiOperation("交易统计")
    @GetMapping("/queryOrderSummary")
    @SystemControllerLog(description = "分账订单-交易统计")
    public ResultData queryOrderSummary() {
        logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::queryOrderSummary");

        Map<String, Object> data = wxProfitSharingOrderService.queryOrderSummary(getTenantId());

        return new ResultData(data);
    }



    @ApiOperation("分账详情")
    @GetMapping("findOrderDetails")
    @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
    @SystemControllerLog(description = "分账订单-分账详情")
    public ResultData findOrderDetails(Long id) {
        logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::findOrderDetails");
        return wxProfitSharingOrderService.findOrderDetails(id);
    }


}
