package com.ruoyi.api;

import com.ruoyi.ai.domain.AiRebateRecord;
import com.ruoyi.ai.service.IAiRebateRecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
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.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 返佣记录Controller
 * 
 * @author shi
 * @date 2025-11-13
 */
@Api(tags = "ai-返佣记录")
@RestController
@RequestMapping("/api/rebate-record")
public class AiRebateRecordApiController extends BaseController
{
    @Autowired
    private IAiRebateRecordService aiRebateRecordService;

    /**
     * 查询返佣记录列表
     */
    @ApiOperation("查询返佣记录列表")
    @GetMapping("/getAiRebateRecordList")
    public TableDataInfo getAiRebateRecordList(AiRebateRecord aiRebateRecord)
    {
        aiRebateRecord.setSuperiorId(SecurityUtils.getAiUserId());
        startPage();
        List<AiRebateRecord> list = aiRebateRecordService.getAiRebateRecordList(aiRebateRecord);
        BigDecimal totalAmount = aiRebateRecordService.getTotalAmount(aiRebateRecord);
        TableDataInfo dataTable = getDataTable(list);
        Map<String, Object> map = new HashMap<>();
        map.put("totalAmount", totalAmount);
        dataTable.setParam(map);
        return dataTable;
    }

}
