package com.brilliance.isc.common.api.fee.controller;

import com.brilliance.isc.common.api.fee.service.FeeDetailApiService;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.fecism.vo.CalcFeeVo;
import com.brilliance.isc.common.setfeg.vo.SetfelVo;
import com.brilliance.isc.vo.ResponseSet;
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;

@RestController
@RequestMapping("/calc")
public class CalcFeeAmtController {

    @Autowired
    private SettleContext settleContext;

    @Autowired
    private FeeDetailApiService feeDetailService;

    @PostMapping("/feeamt")
    public ResponseSet calcFeeAmt(@RequestBody SetfelVo setfelVo) {
        try {
            settleContext.simpleLoadSettleSession();
            return ResponseSet.simpleSuccess(feeDetailService.calcFeeamt(setfelVo));
        } catch (Exception e) {
            throw e;
        } finally {
            SettleContext.removeUserSession();
        }
    }

    @PostMapping("/tool/feeamt")
    public ResponseSet calcFeeAmt(@RequestBody CalcFeeVo calcFeeVo) {
        try {
            settleContext.simpleLoadSettleSession();
            return ResponseSet.simpleSuccess(feeDetailService.calcFeeamt(calcFeeVo));
        } catch (Exception e) {
            throw e;
        } finally {
            SettleContext.removeUserSession();
        }
    }

    @PostMapping("/feeamtByDctrat")
    public ResponseSet calcFeeAmtByDctrat(@RequestBody CalcFeeVo calcFeeVo) {
        try {
            return ResponseSet.simpleSuccess(feeDetailService.calcFeeamtByDctrat(calcFeeVo));
        } catch (Exception e) {
            throw e;
        } finally {
            SettleContext.removeUserSession();
        }
    }

    @PostMapping("/dctratByFeeamt")
    public ResponseSet calcDctratByFeeamt(@RequestBody CalcFeeVo calcFeeVo) {
        try {
            return ResponseSet.simpleSuccess(feeDetailService.calcDctratByFeeamt(calcFeeVo));
        } catch (Exception e) {
            throw e;
        } finally {
            SettleContext.removeUserSession();
        }
    }
}
