package com.ym.mec.student.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.math.BigDecimal;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.service.StudentRechargeService;
import com.ym.mec.biz.service.SysUserCashAccountService;
import com.ym.mec.common.controller.BaseController;

@RequestMapping("recharge")
@Api(tags = "账户充值")
@RestController
public class RechargeController extends BaseController {
	@Resource
	private SysUserFeignService sysUserFeignService;
	@Autowired
	private StudentRechargeService rechargeService;

	@Autowired
	private SysUserCashAccountService sysUserCashAccountService;

	@ApiOperation("充值")
	@GetMapping(value = "/recharge")
	public Object recharge(String bankCardNo, BigDecimal amount) {
		SysUser sysUser = sysUserFeignService.queryUserInfo();
		if (sysUser == null) {
			return failed("获取用户信息失败");
		}

		return succeed(rechargeService.recharge(sysUser.getId(), bankCardNo, amount));
	}
}
