package com.sifang.modules.customer.controller;

import com.sifang.modules.sys.util.insurance.IRet;
import com.sifang.modules.sys.util.insurance.InsuranceApiService;
import com.sifang.modules.sys.util.insurance.form.endorse.EndorseCallbackReq;
import com.sifang.modules.sys.util.insurance.form.ordersubmit.OrderCallbackReq;
import com.sifang.modules.sys.web.BaseExceptionController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 核保回调和批改回调，目前没用，因为接口都是实时返回的。
 */
@RequestMapping("${adminPath}/main/ins/callback")
@RestController
public class InsuranceCallbackController extends BaseExceptionController {

    private static final Logger log = LoggerFactory.getLogger(InsuranceCallbackController.class);

    @Autowired
    InsuranceApiService insuranceApiService;

    @RequestMapping("order")
    public IRet<Void> orderCallback(@RequestBody OrderCallbackReq req) {
        log.info("insurance order callback ret: {}", req);
        insuranceApiService.handleOrderCallback(req);
        IRet<Void> ret = new IRet<>();
        ret.setCode("000000");
        ret.setMsg("");
        return ret;
    }

    @RequestMapping("endorse")
    public IRet<Void> endorseCallback(@RequestBody EndorseCallbackReq req) {
        log.info("endorse callback ret: {}", req);
        insuranceApiService.handleEndorseCallback(req);
        IRet<Void> ret = new IRet<>();
        ret.setCode("000000");
        ret.setMsg("");
        return ret;
    }

}
