package cn.pluss.platform.controller.merchant;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
import cn.pluss.platform.vo.ChannelStatusVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author djh
 */
@RestController
@RequestMapping("/channelStatus")
public class MerchantChannelStatusController {

    @Autowired
    private MerchantChannelStatusService channelStatusService;

    @GetMapping("/quickCash")
    public Result<ChannelStatusVO> entity() {
        ChannelStatusVO csVO = channelStatusService.appQuickCash();
        return ResultGenerator.genSuccessResult(csVO);
    }

    @GetMapping("/current")
    public Result<ChannelStatusVO> current() {
        ChannelStatusVO csVO = channelStatusService.appCurrent();
        return ResultGenerator.genSuccessResult(csVO);
    }

    /**
     * 快速到账通道和常规通道切换
     * @param params 通道标识，目前是0：常规通道， 1： 快速到账通道
     * @return  切换后的通道记录
     */
    @PostMapping("/channelSwitch")
    public Result<ChannelStatusVO> switchChannel(@RequestBody Map<String, Object> params) {
        String flag = (String) params.get("flag");
        ChannelStatusVO channelStatusVO = channelStatusService.appSwitchChannel(Integer.parseInt(flag));
        return ResultGenerator.genSuccessResult(channelStatusVO);
    }
}
