package com.engine.htsc.ydbx.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.ydbx.service.PreExaminationService;
import com.engine.htsc.ydbx.service.impl.PreExaminationServiceImpl;
import weaver.general.BaseBean;
import weaver.general.Util;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

/**
 * @Author Weaver.SongYuchen
 * @Date 2022-05-27
 * @Description
 */
public class PreExaminationAction {
    private PreExaminationService getServices() {
        return ServiceUtil.getService(PreExaminationServiceImpl.class);
    }

    /**
     * 通用报销&差旅报销-发票重复性校验
     *
     * @param request
     * @return
     */
    @POST
    @Path("/checkInvoiceRepeat")
    @Produces({MediaType.APPLICATION_JSON})
    public String checkInvoiceRepeat(@Context HttpServletRequest request) {
        BaseBean bb = new BaseBean();
        bb.writeLog("=========================== 发票重复性校验 ===========================");
        String fps = Util.null2String(request.getParameter("fps"));
        String lcbh = Util.null2String(request.getParameter("lcbh"));
        bb.writeLog("发票重复性校验 -> fps: " + fps + ", lcbh: " + lcbh);
        String result = JSONObject.toJSONString(getServices().getInvoiceRepeat(fps, lcbh));
        bb.writeLog("发票重复性校验即将返回给前端的参数是：" + result);
        return result;
    }

    /**
     * 通用报销&差旅报销-银行账户信息校验
     *
     * @param request
     * @return
     */
    @POST
    @Path("/checkBankAccountInfo")
    @Produces({MediaType.APPLICATION_JSON})
    public String checkBankAccountInfo(@Context HttpServletRequest request) {
        BaseBean bb = new BaseBean();
        bb.writeLog("=========================== 银行账户信息校验 ===========================");
        String khx = Util.null2String(request.getParameter("khx"));
        String yxzfje = Util.null2String(request.getParameter("yxzfje"));
        String yxzh = Util.null2String(request.getParameter("yxzh"));
        bb.writeLog("银行账户信息校验 -> khx: " + khx + ", yxzfje: " + yxzfje + ", yxzh: " + yxzh);
        String result = JSONObject.toJSONString(getServices().getBankAccountInfo(khx, yxzfje, yxzh));
        bb.writeLog("银行账户信息校验即将返回给前端的参数是：" + result);
        return result;
    }
}
