/*
 *    Copyright (c) 2018-2025, hnqz All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: hnqz
 */

package com.qunzhixinxi.hnqz.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qunzhixinxi.hnqz.admin.entity.WmTaskSettleNote;
import com.qunzhixinxi.hnqz.admin.entity.output.WmTaskSettleNoteOutput;
import com.qunzhixinxi.hnqz.admin.service.WmTaskSettleNoteService;
import com.qunzhixinxi.hnqz.common.core.util.R;
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 弃用
 * @Modify: start
 * @Version: v2021.4.16
 * @Author: ryz
 * @Date: 2021/4/26
*/
/**
 *
 *
 * @author winter
 * @date 2021-03-03 18:15:22
 */
@RestController
@AllArgsConstructor
@RequestMapping("/taskSettle" )
@Api(value = "taskSettle", tags = "结算包结算明细管理")
public class WmTaskSettleNoteController {

    private final  WmTaskSettleNoteService wmTaskSettleNoteService;

	/**
	 * 分页查询任务+结算信息
	 * @param page 分页对象
	 * @param wmTaskSettleNote
	 * @return
	 */
	@ApiOperation(value = "分页查询任务+结算信息", notes = "分页查询任务+结算信息")
	@GetMapping("/info/page" )
	public R getWmTaskSettleInfoPage(Page page, WmTaskSettleNote wmTaskSettleNote) {
		if(StringUtils.isEmpty(wmTaskSettleNote.getPackageId()) || StringUtils.isEmpty(wmTaskSettleNote.getUserId())){

			return R.failed("参数异常");
		}

		return R.ok(wmTaskSettleNoteService.getWmTaskSettleInfoPage(page, wmTaskSettleNote));
	}

	/**
	 * 分页查询任务+结算信息
	 * @param page 分页对象
	 * @param wmTaskSettleNote
	 * @return
	 */
	@ApiOperation(value = "分页查询任务+结算信息", notes = "分页查询任务+结算信息")
	@GetMapping("/settle/page" )
	public R getWmTaskForSettlePage(Page page, WmTaskSettleNote wmTaskSettleNote) {
		if(StringUtils.isEmpty(wmTaskSettleNote.getPackageId())){
			return R.failed("参数异常");
		}

		return R.ok(wmTaskSettleNoteService.getWmTaskForSettlePage(page, wmTaskSettleNote));
	}

    /**
     * 分页查询
     * @param page 分页对象
     * @param wmTaskSettleNote
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getWmTaskSettleNotePage(Page page, WmTaskSettleNote wmTaskSettleNote) {
        return R.ok(wmTaskSettleNoteService.page(page, Wrappers.query(wmTaskSettleNote)));
    }

	/**
	 * 查询生成结算信息
	 * @param wmTaskSettleNote
	 * @return R
	 */
	@ApiOperation(value = "查询生成结算信息", notes = "查询生成结算信息")
	@PostMapping("/getSettleInfo" )
	public R getSettleInfo(@RequestBody WmTaskSettleNote wmTaskSettleNote) {
		return wmTaskSettleNoteService.getSettleInfo(wmTaskSettleNote);
	}

	/**
	 * 保存
	 * @param note
	 * @return R
	 */
	@ApiOperation(value = "保存", notes = "保存")
	@PostMapping("/saveSettleInfo" )
	public R saveSettleInfo(@RequestBody WmTaskSettleNote note) {
//		if(null == note.getId()){
//			return R.failed("参数异常");
//		}
		return wmTaskSettleNoteService.saveSettleInfo(note);
	}

	/**
	 * 提交结算申请
	 * @param note
	 * @return R
	 */
	@ApiOperation(value = "提交结算申请", notes = "提交结算申请")
	@PostMapping("/subSettleInfo" )
	public R subSettleInfo(@RequestBody WmTaskSettleNote note) {
//		if(null == note.getId()){
//			return R.failed("参数异常");
//		}
		return wmTaskSettleNoteService.subSettleInfo(note);
	}

	/**
	 * 撤销结算申请
	 * @param note
	 * @return R
	 */
	@ApiOperation(value = "撤销结算申请", notes = "撤销结算申请")
	@PostMapping("/revokeSettle" )
	public R revokeSettle(@RequestBody WmTaskSettleNote note) {
//		if(null == note.getId()){
//			return R.failed("参数异常");
//		}
		return wmTaskSettleNoteService.revokeSettle(note);
	}

	/**
	 * 提交结算申请
	 * @param note
	 * @return R
	 */
	@ApiOperation(value = "提交结算申请", notes = "提交结算申请")
	@PostMapping("/singletSettle" )
	public R singletSettle(@RequestBody WmTaskSettleNote note) {
		if(null == note.getId()){
			return R.failed("参数异常");
		}
		return wmTaskSettleNoteService.singletSettle(note);
	}

	/**
	 * 提交结算申请
	 * @param note
	 * @return R
	 */
	@ApiOperation(value = "提交结算申请", notes = "提交结算申请")
	@PostMapping("/batchSettle" )
	public R batchSettle(@RequestBody WmTaskSettleNote note) {
		if(StringUtils.isEmpty(note.getIdStr())){
			return R.failed("参数异常");
		}
		return wmTaskSettleNoteService.batchSettle(note);
	}


    /**
     * 通过id查询
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(wmTaskSettleNoteService.getById(id));
    }

    /**
     * 新增
     * @param wmTaskSettleNote
     * @return R
     */
    @ApiOperation(value = "新增", notes = "新增")
    @SysLog("新增" )
    @PostMapping
    public R save(@RequestBody WmTaskSettleNote wmTaskSettleNote) {
        return R.ok(wmTaskSettleNoteService.save(wmTaskSettleNote));
    }

    /**
     * 修改
     * @param wmTaskSettleNote
     * @return R
     */
    @ApiOperation(value = "修改", notes = "修改")
    @SysLog("修改" )
    @PutMapping
    public R updateById(@RequestBody WmTaskSettleNote wmTaskSettleNote) {
        return R.ok(wmTaskSettleNoteService.updateById(wmTaskSettleNote));
    }

    /**
     * 通过id删除
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除", notes = "通过id删除")
    @SysLog("通过id删除" )
    @DeleteMapping("/{id}" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(wmTaskSettleNoteService.removeById(id));
    }

}
