package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.dto.WithdrawDto;
import com.ym.mec.biz.dal.enums.DealStatusEnum;
import com.ym.mec.biz.dal.enums.TransTypeEnum;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.biz.service.StudentWithdrawService;
import com.ym.mec.common.controller.BaseController;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("studentWithdraw")
@Api(tags = "提现服务")
@RestController
public class StudentWithdrawController extends BaseController {

	@Autowired
	private StudentWithdrawService studentWithdrawService;
	@Autowired
	private OrganizationService organizationService;

	@PostMapping("confirm")
	@ApiOperation(value = "确认提现")
	@PreAuthorize("@pcs.hasPermissions('studentWithdraw/confirm')")
	public Object confirmWithdraw(Integer id, DealStatusEnum status, String memo, String transNo, TransTypeEnum transType, String platformAccountNo) {
		studentWithdrawService.confirmWithdraw(id, status, memo, transNo, transType, platformAccountNo);
		return succeed();
	}

	@ApiOperation(value = "分页查询")
	@GetMapping("/queryPage")
	@PreAuthorize("@pcs.hasPermissions('studentWithdraw/queryPage')")
	public Object queryPage(WithdrawDto queryInfo) {
		queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
		return succeed(studentWithdrawService.queryPage(queryInfo));
	}
}
