package com.madeu.controller.web.webpayment;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.madeu.util.RequestLogUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import com.madeu.constants.Constants;
import com.madeu.init.ManagerDraftAction;
import com.madeu.service.web.webloghistory.WebLogHistoryService;
import com.madeu.service.web.webpayment.WebPaymentService;
import com.madeu.util.HttpUtil;
import com.madeu.view.web.WebPaymentView;
import com.madeu.view.web.WebUserPaymentView;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
public class WebPaymentController extends ManagerDraftAction {

    @Autowired
    private WebPaymentService webPaymentService;

    @Autowired
    private WebLogHistoryService webLogHistoryService;

    /**
     * 수납내역 리스트 화면으로 이동.
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/selectListPaymentIntro.do")
    public String  selectListPaymentIntro(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model model) {
        log.debug("WebPaymentController  selectListPaymentIntro START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        try{
            if(!webCheckLogin(session)){
                return "/web/login/logout";
            }
            else {
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.selectListPaymentIntro(paramMap);

                model.addAttribute("selectUseYn", map.get("selectUseYn"));
                model.addAttribute("insertUseYn", map.get("insertUseYn"));
                model.addAttribute("updateUseYn", map.get("updateUseYn"));
                model.addAttribute("deleteUseYn", map.get("deleteUseYn"));
                model.addAttribute("downloadUseYn", map.get("downloadUseYn"));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            return "/web/login/logout";
        }
        log.debug("WebPaymentController  selectListPaymentIntro END");
        return "/web/payment/paymentSelectList";
    }
    /**
     * 수납내역 리스트 화면으로 이동.
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/selectListPayment.do")
    public ModelAndView selectListPayment(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model model) {
        log.debug("WebPaymentController  selectListPayment START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.selectListPayment(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }
        }
        log.debug("WebMemberController selectListMemberDoctorOption END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }

    /**
     * <b>고객 신체정보 엑셀 다운로드 </b>
     * 페이지 처리 없음
     * request:
     * response : msgCode, msgDesc
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/webpayment/downloadPaymentExcel.do")
    public ModelAndView downloadPaymentExcel(HttpSession session, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "file", required = false) MultipartFile file, Model model) {
        log.debug("WebUserController downloadPaymentExcel START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        List<Map<String, Object>> selectListReport = new ArrayList<Map<String, Object>>();
        Map<String, Object> map = new HashMap<String, Object>();

        try {
            if (!webCheckLogin(session)) {
                return null;
            } else {
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                selectListReport = webPaymentService.selectPaymentListExcel(paramMap);
                map.put("selectListPayment", selectListReport);
                map.put("name", "payment");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        log.debug("WebMemberController downloadPaymentExcel END");
        return new ModelAndView(new WebPaymentView(), "map", map);
    }
    

	/**
	 * 고객 수납내역 정보 리스트 조회 (병원현황 수납 모달)
	 * 
	 * @param request
	 * @param response 
	 * @return
	 */
	@RequestMapping(value="/webpayment/selectListPaymentUser.do")
	public ModelAndView selectListPaymentUser(HttpSession session,HttpServletRequest request, HttpServletResponse response) {
		log.debug("WebPaymentController selectListPaymentUser START");
		
		HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		try{
			if(!webCheckLogin(session)){
				return null;
			}
			else{
				paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
				map = webPaymentService.selectListPaymentUser(paramMap);
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		finally {
			if(Constants.OK == map.get("msgCode")) {

			}
			else{
				map.put("msgCode", Constants.FAIL);
				map.put("success", false);
				if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
					map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
				}
			}
		}
		log.debug("WebPaymentController selectListPaymentUser END");
		return HttpUtil.makeHashToJsonModelAndView(map);
	}
	
	/**
     * 고객 - 수납내역 리스트 화면으로 이동.
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/selectListPaymentUser2Intro.do")
    public String  selectListPaymentUser2Intro(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model model) {
        log.debug("WebPaymentController  selectListPaymentUser2Intro START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        try{
            if(!webCheckLogin(session)){
                return "/web/login/logout";
            }
            else {
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.selectListPaymentUser2Intro(paramMap);

                model.addAttribute("selectUseYn", map.get("selectUseYn"));
                model.addAttribute("insertUseYn", map.get("insertUseYn"));
                model.addAttribute("updateUseYn", map.get("updateUseYn"));
                model.addAttribute("deleteUseYn", map.get("deleteUseYn"));
                model.addAttribute("downloadUseYn", map.get("downloadUseYn"));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            return "/web/login/logout";
        }
        log.debug("WebPaymentController  selectListPaymentUser2Intro END");
        return "/web/user/userPaymentSelectList";
    }
    
    /**
     * 고객 - 수납내역 리스트 조회 (List)
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/selectListPaymentUser2.do")
    public ModelAndView selectListPaymentUser2(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model model) {
        log.debug("WebPaymentController  selectListPaymentUser2 START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.selectListPaymentUser2(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }
        }
        log.debug("WebPaymentController selectListPaymentUser2 END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }
    
    /**
     * <b>고객 - 수납내역 리스트 엑셀 다운로드 (Excel)</b>
     * 페이지 처리 없음
     * request:
     * response : msgCode, msgDesc
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/webpayment/downloadUserPayment2Excel.do")
    public ModelAndView downloadUserPayment2Excel(HttpSession session, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "file", required = false) MultipartFile file, Model model) {
        log.debug("WebPaymentController downloadUserPayment2Excel START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        List<Map<String, Object>> selectListReport = new ArrayList<Map<String, Object>>();
        Map<String, Object> map = new HashMap<String, Object>();

        try {
            if (!webCheckLogin(session)) {
                return null;
            } else {
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                selectListReport = webPaymentService.selectListPaymentUser2Excel(paramMap);
                map.put("selectListPaymentUser", selectListReport);
                map.put("name", "userpayment");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        log.debug("WebPaymentController downloadUserPayment2Excel END");
        return new ModelAndView(new WebUserPaymentView(), "map", map);
    }
    /**
     * 결제 정보 등록
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/insertPayment.do")
    public ModelAndView insertPayment(HttpSession session,HttpServletRequest request, HttpServletResponse response, MultipartHttpServletRequest file) {
        log.debug("WebPaymentController insertPayment START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        StringBuffer errorMsg = new StringBuffer();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("regId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("modId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.insertPayment(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            errorMsg.append(e);
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }

            try {
                HashMap<String, Object> visitLogParamMap = RequestLogUtil.getVisitLogParameterMap(request);
                HashMap<String, Object> insertMap = new HashMap<String, Object>();

                insertMap.put("url", "/webpayment/insertPayment.do");
                insertMap.put("func", "insertPayment");
                insertMap.put("funcName", "결제 정보 등록");
                insertMap.put("service", "webPaymentService");
                insertMap.put("serviceName", "결제 정보 등록");
                insertMap.put("requestValue", String.valueOf(paramMap));
                insertMap.put("responseValue", String.valueOf(map));
                insertMap.put("tId", map.get("tId"));
                if((String.valueOf(errorMsg)).equals("") || (String.valueOf(errorMsg) == null) || String.valueOf(errorMsg).length() == 0){
                    insertMap.put("resultCode", "SUCCESS");
                }
                else{
                    insertMap.put("resultCode", "ERROR");
                }
                insertMap.put("resultMsg", String.valueOf(errorMsg));
                insertMap.put("muMemberId", paramMap.get("loginMemberId"));

                webLogHistoryService.insertLogHistory(insertMap, visitLogParamMap);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
        log.debug("WebPaymentController insertPayment END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }
    /**
     * 단말기 결제요청 정보 등록
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/insertPaymentRequestHistory.do")
    public ModelAndView insertPaymentRequestHistory(HttpSession session,HttpServletRequest request, HttpServletResponse response, MultipartHttpServletRequest file) {
        log.debug("WebPaymentController insertPaymentRequestHistory START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        StringBuffer errorMsg = new StringBuffer();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("regId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("modId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.insertPaymentRequestHistory(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            errorMsg.append(e);
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }

            try {
                HashMap<String, Object> visitLogParamMap = RequestLogUtil.getVisitLogParameterMap(request);
                HashMap<String, Object> insertMap = new HashMap<String, Object>();

                insertMap.put("url", "/webpayment/insertPaymentRequestHistory.do");
                insertMap.put("func", "insertPaymentRequestHistory");
                insertMap.put("funcName", "단말기 결제요청 정보 등록");
                insertMap.put("service", "webPaymentService");
                insertMap.put("serviceName", "단말기 결제요청 정보 등록");
                insertMap.put("requestValue", String.valueOf(paramMap));
                insertMap.put("responseValue", String.valueOf(map));
                insertMap.put("tId", map.get("tId"));
                if((String.valueOf(errorMsg)).equals("") || (String.valueOf(errorMsg) == null) || String.valueOf(errorMsg).length() == 0){
                    insertMap.put("resultCode", "SUCCESS");
                }
                else{
                    insertMap.put("resultCode", "ERROR");
                }
                insertMap.put("resultMsg", String.valueOf(errorMsg));
                insertMap.put("muMemberId", paramMap.get("loginMemberId"));

                webLogHistoryService.insertLogHistory(insertMap, visitLogParamMap);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
        log.debug("WebPaymentController insertPaymentRequestHistory END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }
    /**
     * 단말기 결제응답 정보 등록
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/insertPaymentResponseHistory.do")
    public ModelAndView insertPaymentResponseHistory(HttpSession session,HttpServletRequest request, HttpServletResponse response, MultipartHttpServletRequest file) {
        log.debug("WebPaymentController insertPaymentResponseHistory START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        StringBuffer errorMsg = new StringBuffer();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("regId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("modId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.insertPaymentResponseHistory(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            errorMsg.append(e);
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }

            try {
                HashMap<String, Object> visitLogParamMap = RequestLogUtil.getVisitLogParameterMap(request);
                HashMap<String, Object> insertMap = new HashMap<String, Object>();

                insertMap.put("url", "/webpayment/insertPaymentResponseHistory.do");
                insertMap.put("func", "insertPaymentResponseHistory");
                insertMap.put("funcName", "단말기 결제응답 정보 등록");
                insertMap.put("service", "webPaymentService");
                insertMap.put("serviceName", "단말기 결제응답 정보 등록");
                insertMap.put("requestValue", String.valueOf(paramMap));
                insertMap.put("responseValue", String.valueOf(map));
                insertMap.put("tId", map.get("tId"));
                if((String.valueOf(errorMsg)).equals("") || (String.valueOf(errorMsg) == null) || String.valueOf(errorMsg).length() == 0){
                    insertMap.put("resultCode", "SUCCESS");
                }
                else{
                    insertMap.put("resultCode", "ERROR");
                }
                insertMap.put("resultMsg", String.valueOf(errorMsg));
                insertMap.put("muMemberId", paramMap.get("loginMemberId"));

                webLogHistoryService.insertLogHistory(insertMap, visitLogParamMap);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
        log.debug("WebPaymentController insertPaymentResponseHistory END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }
    /**
     * 결제 취소 정보 등록
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/paymentCancellation.do")
    public ModelAndView paymentCancellation(HttpSession session,HttpServletRequest request, HttpServletResponse response, MultipartHttpServletRequest file) {
        log.debug("WebPaymentController paymentCancellation START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        StringBuffer errorMsg = new StringBuffer();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("regId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("modId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.paymentCancellation(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            errorMsg.append(e);
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }

            try {
                HashMap<String, Object> visitLogParamMap = RequestLogUtil.getVisitLogParameterMap(request);
                HashMap<String, Object> insertMap = new HashMap<String, Object>();

                insertMap.put("url", "/webpayment/paymentCancellation.do");
                insertMap.put("func", "insertPayment");
                insertMap.put("funcName", "결제 취소 정보 등록");
                insertMap.put("service", "webPaymentService");
                insertMap.put("serviceName", "결제 취소 정보 등록");
                insertMap.put("requestValue", String.valueOf(paramMap));
                insertMap.put("responseValue", String.valueOf(map));
                insertMap.put("tId", map.get("tId"));
                if((String.valueOf(errorMsg)).equals("") || (String.valueOf(errorMsg) == null) || String.valueOf(errorMsg).length() == 0){
                    insertMap.put("resultCode", "SUCCESS");
                }
                else{
                    insertMap.put("resultCode", "ERROR");
                }
                insertMap.put("resultMsg", String.valueOf(errorMsg));
                insertMap.put("muMemberId", paramMap.get("loginMemberId"));

                webLogHistoryService.insertLogHistory(insertMap, visitLogParamMap);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
        log.debug("WebPaymentController paymentCancellation END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }
    /**
     * 결제 취소 정보 등록 (취소 재결제)
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webpayment/paymentCancellationPay.do")
    public ModelAndView paymentCancellationPay(HttpSession session,HttpServletRequest request, HttpServletResponse response, MultipartHttpServletRequest file) {
        log.debug("WebPaymentController paymentCancellationPay START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        StringBuffer errorMsg = new StringBuffer();

        try{
            if(!webCheckLogin(session)){
                return null;
            }
            else{
                paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("muMemberId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("regId", String.valueOf(session.getAttribute("loginMemberId")));
                paramMap.put("modId", String.valueOf(session.getAttribute("loginMemberId")));
                map = webPaymentService.paymentCancellationPay(paramMap);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            errorMsg.append(e);
        }
        finally {
            if(Constants.OK == map.get("msgCode")) {

            }
            else{
                map.put("msgCode", Constants.FAIL);
                map.put("success", false);
                if(null == map.get("msgDesc") || ("").equals(map.get("msgDesc"))) {
                    map.put("msgDesc","정상적으로 수행되지 않았습니다. 관리자에게 문의하시기 바랍니다.");
                }
            }

            try {
                HashMap<String, Object> visitLogParamMap = RequestLogUtil.getVisitLogParameterMap(request);
                HashMap<String, Object> insertMap = new HashMap<String, Object>();

                insertMap.put("url", "/webpayment/paymentCancellationPay.do");
                insertMap.put("func", "paymentCancellationPay");
                insertMap.put("funcName", "결제 취소 정보 등록");
                insertMap.put("service", "webPaymentService");
                insertMap.put("serviceName", "결제 취소 정보 등록");
                insertMap.put("requestValue", String.valueOf(paramMap));
                insertMap.put("responseValue", String.valueOf(map));
                insertMap.put("tId", map.get("tId"));
                if((String.valueOf(errorMsg)).equals("") || (String.valueOf(errorMsg) == null) || String.valueOf(errorMsg).length() == 0){
                    insertMap.put("resultCode", "SUCCESS");
                }
                else{
                    insertMap.put("resultCode", "ERROR");
                }
                insertMap.put("resultMsg", String.valueOf(errorMsg));
                insertMap.put("muMemberId", paramMap.get("loginMemberId"));

                webLogHistoryService.insertLogHistory(insertMap, visitLogParamMap);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
        log.debug("WebPaymentController paymentCancellationPay END");
        return HttpUtil.makeHashToJsonModelAndView(map);
    }
}
