package com.bonus.canteen.core.account.controller;

import com.bonus.canteen.core.account.constants.AccTradeTypeEnum;
import com.bonus.canteen.core.account.constants.AccWalletTypeEnum;
import com.bonus.canteen.core.account.domain.param.*;
import com.bonus.canteen.core.account.service.AccSubService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 账户资料Controller
 * 
 * @author xsheng
 * @date 2025-04-05
 */
@Api(tags = "账户补贴接口")
@RestController
@RequestMapping("/acc/subsidy")
public class AccSubsidyController extends BaseController {
    @Autowired
    private AccSubService accSubService;
    @ApiOperation("单人补贴")
    @PostMapping("/add")
    public AjaxResult individualAccSubsidyAdd(@RequestBody @Valid AccSubsidyAddParam param) {
        this.accSubService.individualAccSubsidyAdd(param);
        return AjaxResult.success();
    }

    @ApiOperation("补贴清空")
    @PostMapping({"/clear"})
    public AjaxResult individualAccSubsidyClear(@RequestBody @Valid AccSubsidyClearParam param) {
        this.accSubService.individualAccSubsidyClear(param);
        return AjaxResult.success();
    }

    @ApiOperation("批量补贴")
    @PostMapping("/batch/add")
    public AjaxResult batchAccSubsidyAdd(@RequestBody @Valid AccSubsidyBatchAddParam param) {
        this.accSubService.batchAccSubsidyAdd(param);
        return AjaxResult.success();
    }
    @ApiOperation("批量补贴校验")
    @PostMapping("/batch/add/check")
    public AjaxResult batchAccSubsidyAddCheck(@RequestBody @Valid AccSubsidyBatchAddParam param) {
        return AjaxResult.success(accSubService.batchOperationWalletAddCheck(param));
    }
    @ApiOperation("批量补贴清空")
    @PostMapping({"/batch/clear"})
    public AjaxResult batchAccSubsidyClear(@RequestBody @Valid AccSubsidyBatchClearParam param) {
        this.accSubService.batchAccSubsidyClear(param);
        return AjaxResult.success();
    }

    @ApiOperation("批量补贴清空校验")
    @PostMapping({"/batch/clear/check"})
    public AjaxResult batchAccSubsidyClearCheck(@RequestBody @Valid AccSubsidyBatchClearParam param) {
        return AjaxResult.success(accSubService.batchOperationWalletClearCheck(param));
    }

    @ApiOperation("补贴记录")
    @PostMapping({"/add/history"})
    public TableDataInfo queryAccSubOperationAddList(@RequestBody AccWalletOperationQueryParam request) {
        startPage();
        request.setTradeType(AccTradeTypeEnum.SUBSIDY.getKey());
        return getDataTable(accSubService.queryAccSubOperationList(request));
    }

    @ApiOperation("补贴清空记录")
    @PostMapping({"/clear/history"})
    public TableDataInfo queryAccSubOperationClearList(@RequestBody AccWalletOperationQueryParam request) {
        startPage();
        request.setTradeType(AccTradeTypeEnum.CLEAR.getKey());
        request.setWalletType(AccWalletTypeEnum.SUBSIDY.getKey());
        return getDataTable(accSubService.queryAccSubOperationList(request));
    }
}
