package com.younike.admin;

import com.younike.common.core.controller.BaseController;
import com.younike.common.core.domain.AjaxResult;
import com.younike.common.core.page.TableDataInfo;
import com.younike.system.domain.UjdChangeRecord;
import com.younike.system.domain.vo.ReconciliationVo;
import com.younike.system.param.UjdChangeRedordQueryParam;
import com.younike.system.service.IMerchantOrderService;
import com.younike.system.service.IUjdChangeRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 运营管理
 * 财务对账运营
 */
@Api("财务对账运营")
@RestController
@RequestMapping("/" +
        "admin/reconciliation")
public class AdminReconciliationController extends BaseController {

    @Autowired
    private IMerchantOrderService orderService;
    @Autowired
    private IUjdChangeRecordService iUjdChangeRecordService;

    /**
     * 运营管理：财务对账：查询订单账单
     */
    @GetMapping("/orderList")
    @PreAuthorize("@ss.hasRole('operation')")
    public TableDataInfo orderList(ReconciliationVo vo) {
        startPage();
        List<ReconciliationVo> list = orderService.getReconciliationOrderList(vo);
        return getDataTable(list);
    }

    /**
     * 运营管理:统计店铺入账总金额，以及平台抽成
     */
    @ApiOperation("统计店铺入账总金额，以及平台抽成")
    @GetMapping("/orderStatistics")
    @PreAuthorize("@ss.hasRole('operation')")
    public AjaxResult getInfo(ReconciliationVo vo) {
        return AjaxResult.success(orderService.adminOrderStatistics(vo));
    }


    /**
     * 查看保证金账单运营list
     * @param ujdChangeRedordQueryParam
     * @return
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasRole('operation')")
    public TableDataInfo reconciliationlist(UjdChangeRedordQueryParam ujdChangeRedordQueryParam){
        startPage();
        List<UjdChangeRecord> reconciliationlist = orderService.reconciliationlist(ujdChangeRedordQueryParam);
        return getDataTable(reconciliationlist);
    }
}
