package com.madeu.service.web.webuser.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import com.madeu.api.InBodyApiProvider;
import com.madeu.constants.Constants;
import com.madeu.dao.web.webauthmenurelation.WebAuthMenuRelationSqlMapDAO;
import com.madeu.dao.web.webmember.WebMemberSqlMapDAO;
import com.madeu.dao.web.webuser.WebUserSqlMapDAO;
import com.madeu.service.common.file.FileService;
import com.madeu.service.web.webuser.WebUserService;
import com.madeu.util.ValidationCheckUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("WebUserService")
public class WebUserServiceImpl implements WebUserService {

    @Autowired
    private WebUserSqlMapDAO webUserSqlMapDAO;

    @Autowired
    private WebMemberSqlMapDAO webMemberSqlMapDAO;

    @Autowired
    private WebAuthMenuRelationSqlMapDAO webAuthMenuRelationSqlMapDAO;

	
	@Autowired 
	private FileService fileService;
	
	@Autowired 
	private InBodyApiProvider inBodyApiProvider;
	
    /**
     * 고객 리스트 화면으로 이동.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUserIntro(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserIntro START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
        log.debug("menuClass           :"+paramMap.get("menuClass"));

        try{
            boolean check  = true;

            String menuClass    = String.valueOf(paramMap.get("menuClass"));

            if(true != ValidationCheckUtil.emptyCheck(menuClass)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","메뉴 정보가 없습니다.");
            }

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){
                    map.put("msgCode", Constants.OK);
                    map.put("success","true");

                    map.put("selectUseYn", authMenuRelationlistMap.get(0).get("selectUseYn"));
                    map.put("insertUseYn", authMenuRelationlistMap.get(0).get("insertUseYn"));
                    map.put("updateUseYn", authMenuRelationlistMap.get(0).get("updateUseYn"));
                    map.put("deleteUseYn", authMenuRelationlistMap.get(0).get("deleteUseYn"));
                    map.put("downloadUseYn", authMenuRelationlistMap.get(0).get("downloadUseYn"));
                }
                else {
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserIntro END");
        return map;
    }

    /**
     * 고객 리스트 조회.(List)
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUser(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUser START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("userSearchKeywordParam   :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userTypeCode             :"+paramMap.get("userTypeCode"));
        log.debug("membershipYn             :"+paramMap.get("membershipYn"));
        log.debug("nationalityCode          :"+paramMap.get("nationalityCode"));
        log.debug("loginMemberId            :"+paramMap.get("loginMemberId"));
        log.debug("userSort                 :"+paramMap.get("userSort"));
        log.debug("userStart                :"+paramMap.get("userStart"));
        log.debug("nationality              :"+paramMap.get("nationality"));
        log.debug("menuClass                :"+paramMap.get("menuClass"));
        log.debug("userType                 :"+paramMap.get("userType"));
        log.debug("userLimit                :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
            if(true == check){
                // 정렬
                if(null==paramMap.get("userDir")||("").equals(paramMap.get("userDir"))){

                }
                else{
                    String dir = String.valueOf(paramMap.get("userDir"));
                    if(("A").equals(dir)){
                        paramMap.put("userDir", "DESC");
                    }
                    else if(("B").equals(dir)){
                        paramMap.put("userDir", "ASC");
                    }
                    else {
                        paramMap.put("userDir", "DESC");
                    }
                }

                paramMap.put("useYn", "Y");

                int totalCount = webUserSqlMapDAO.selectTotalUserCount(paramMap);
                if(0<totalCount){
                    listMap = webUserSqlMapDAO.selectListUser(paramMap);
                }

                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("totalCount", totalCount);
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUser END");
        return map;
    }

    /**
     * 고객 리스트 조회.(List,Option)
     * 예약팝업에서 고객 조회
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUserOption(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserOption START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("userSearchKeywordParam   :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userTypeCode             :"+paramMap.get("userTypeCode"));
        log.debug("membershipYn             :"+paramMap.get("membershipYn"));
        log.debug("nationalityCode          :"+paramMap.get("nationalityCode"));
        log.debug("loginMemberId            :"+paramMap.get("loginMemberId"));
        log.debug("userSort                 :"+paramMap.get("userSort"));
        log.debug("userStart                :"+paramMap.get("userStart"));
        log.debug("nationality              :"+paramMap.get("nationality"));
        log.debug("menuClass                :"+paramMap.get("menuClass"));
        log.debug("userType                 :"+paramMap.get("userType"));
        log.debug("userLimit                :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 정렬
                if(null==paramMap.get("userDir")||("").equals(paramMap.get("userDir"))){

                }
                else{
                    String dir = String.valueOf(paramMap.get("userDir"));
                    if(("A").equals(dir)){
                        paramMap.put("userDir", "DESC");
                    }
                    else if(("B").equals(dir)){
                        paramMap.put("userDir", "ASC");
                    }
                    else {
                        paramMap.put("userDir", "DESC");
                    }
                }

                paramMap.put("useYn", "Y");

                int totalCount = webUserSqlMapDAO.selectTotalUserCount(paramMap);
                if(0<totalCount){
                    listMap = webUserSqlMapDAO.selectListUser(paramMap);
                }

                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("totalCount", totalCount);
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserOption END");
        return map;
    }

    /**
     * 마케팅 - 고객 리스트 조회.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUserMarketing(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserMarketing START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("userSearchKeywordParam   :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userTypeCode             :"+paramMap.get("userTypeCode"));
        log.debug("membershipYn             :"+paramMap.get("membershipYn"));
        log.debug("nationalityCode          :"+paramMap.get("nationalityCode"));
        log.debug("loginMemberId            :"+paramMap.get("loginMemberId"));
        log.debug("userSort                 :"+paramMap.get("userSort"));
        log.debug("userStart                :"+paramMap.get("userStart"));
        log.debug("nationality              :"+paramMap.get("nationality"));
        log.debug("menuClass                :"+paramMap.get("menuClass"));
        log.debug("userType                 :"+paramMap.get("userType"));
        log.debug("userLimit                :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
            if(true == check){
                // 정렬
                if(null==paramMap.get("userDir")||("").equals(paramMap.get("userDir"))){

                }
                else{
                    String dir = String.valueOf(paramMap.get("userDir"));
                    if(("A").equals(dir)){
                        paramMap.put("userDir", "DESC");
                    }
                    else if(("B").equals(dir)){
                        paramMap.put("userDir", "ASC");
                    }
                    else {
                        paramMap.put("userDir", "DESC");
                    }
                }

                paramMap.put("useYn", "Y");

                int totalCount = webUserSqlMapDAO.selectTotalUserMarketingCount(paramMap);
                if(0<totalCount){
                    listMap = webUserSqlMapDAO.selectListUserMarketing(paramMap);
                }

                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("totalCount", totalCount);
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserMarketing END");
        return map;
    }

    /**
     * 마케팅 - 고객 리스트 조회.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUserMarketingPush(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserMarketingPush START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("userSearchKeywordParam   :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userTypeCode             :"+paramMap.get("userTypeCode"));
        log.debug("membershipYn             :"+paramMap.get("membershipYn"));
        log.debug("nationalityCode          :"+paramMap.get("nationalityCode"));
        log.debug("loginMemberId            :"+paramMap.get("loginMemberId"));
        log.debug("userSort                 :"+paramMap.get("userSort"));
        log.debug("userStart                :"+paramMap.get("userStart"));
        log.debug("nationality              :"+paramMap.get("nationality"));
        log.debug("menuClass                :"+paramMap.get("menuClass"));
        log.debug("userType                 :"+paramMap.get("userType"));
        log.debug("userLimit                :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
            if(true == check){
                // 정렬
                if(null==paramMap.get("userDir")||("").equals(paramMap.get("userDir"))){

                }
                else{
                    String dir = String.valueOf(paramMap.get("userDir"));
                    if(("A").equals(dir)){
                        paramMap.put("userDir", "DESC");
                    }
                    else if(("B").equals(dir)){
                        paramMap.put("userDir", "ASC");
                    }
                    else {
                        paramMap.put("userDir", "DESC");
                    }
                }

                paramMap.put("useYn", "Y");

                int totalCount = webUserSqlMapDAO.selectTotalUserMarketingPushCount(paramMap);
                if(0<totalCount){
                    listMap = webUserSqlMapDAO.selectListUserMarketingPush(paramMap);
                }

                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("totalCount", totalCount);
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserMarketingPush END");
        return map;
    }

    /**
     * 고객 리스트 조회 (List, Excel)
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public List<Map<String, Object>> selectListUserExcel(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserExcel START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = null;

        log.debug("userSearchKeywordParam   :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userTypeCode             :"+paramMap.get("userTypeCode"));
        log.debug("membershipYn             :"+paramMap.get("membershipYn"));
        log.debug("nationalityCode          :"+paramMap.get("nationalityCode"));
        log.debug("loginMemberId            :"+paramMap.get("loginMemberId"));
        log.debug("userSort                 :"+paramMap.get("userSort"));
        log.debug("userStart                :"+paramMap.get("userStart"));
        log.debug("nationality              :"+paramMap.get("nationality"));
        log.debug("menuClass                :"+paramMap.get("menuClass"));
        log.debug("userType                 :"+paramMap.get("userType"));
        log.debug("userLimit                :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("downloadUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "내려받기 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                listMap = webUserSqlMapDAO.selectListUserExcel(paramMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserExcel END");
        return listMap;
    }
    /**
     * 고객 수정 화면으로 이동.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> updateUserIntro(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl updateUserIntro START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));

        log.debug("menuClass           :"+paramMap.get("menuClass"));

        log.debug("muUserId          :"+paramMap.get("muUserId"));

        try{
            boolean check  = true;

            String menuClass    = String.valueOf(paramMap.get("menuClass"));

            // 정렬
            if(true != ValidationCheckUtil.emptyCheck(menuClass)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","메뉴 정보가 없습니다.");
            }

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){
                    map.put("msgCode", Constants.OK);
                    map.put("success","true");

                    map.put("selectUseYn", authMenuRelationlistMap.get(0).get("selectUseYn"));
                    map.put("insertUseYn", authMenuRelationlistMap.get(0).get("insertUseYn"));
                    map.put("updateUseYn", authMenuRelationlistMap.get(0).get("updateUseYn"));
                    map.put("deleteUseYn", authMenuRelationlistMap.get(0).get("deleteUseYn"));
                    map.put("downloadUseYn", authMenuRelationlistMap.get(0).get("downloadUseYn"));
                }
                else {
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl updateUserIntro END");
        return map;
    }

    /**
     * 고객 정보 수정
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
    public HashMap<String, Object> updateUser(
            HashMap<String, Object> paramMap) throws Exception{
        log.debug("WebUserServiceImpl updateUser START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("muUserId          : " + paramMap.get("muUserId"));

        log.debug("nationality       : " + paramMap.get("nationality"));
        log.debug("nationalityCode   : " + paramMap.get("nationalityCode"));
        log.debug("localYn           : " + paramMap.get("localYn"));
        log.debug("userName          : " + paramMap.get("userName"));
        log.debug("userRrn1          : " + paramMap.get("userRrn1"));
        log.debug("userRrn2          : " + paramMap.get("userRrn2"));
        log.debug("userPno           : " + paramMap.get("userPno"));
        log.debug("userArc1          : " + paramMap.get("userArc1"));
        log.debug("userArc2          : " + paramMap.get("userArc2"));
        log.debug("phoneNumber       : " + paramMap.get("phoneNumber"));
        log.debug("phoneNumber2      : " + paramMap.get("phoneNumber2"));
//        log.debug("email             : " + paramMap.get("email"));
//        log.debug("address           : " + paramMap.get("address"));
//        log.debug("addressDetails    : " + paramMap.get("addressDetails"));
//        log.debug("zipCode           : " + paramMap.get("zipCode"));
        log.debug("gender            : " + paramMap.get("gender"));
        log.debug("channel           : " + paramMap.get("channel"));
        log.debug("channelCode       : " + paramMap.get("channelCode"));
        log.debug("muGroupId         : " + paramMap.get("muGroupId"));
        log.debug("memo              : " + paramMap.get("memo"));
        log.debug("etc               : " + paramMap.get("etc"));
        log.debug("birthday          : " + paramMap.get("birthday"));
        log.debug("userTypeCode      : " + paramMap.get("userTypeCode"));
        log.debug("userType          : " + paramMap.get("userType"));
        log.debug("refusePhotoYn     : " + paramMap.get("refusePhotoYn"));
        log.debug("smsYn             : " + paramMap.get("smsYn"));
//        log.debug("emailYn           : " + paramMap.get("emailYn"));
        log.debug("identification    : " + paramMap.get("identification"));
        log.debug("introUserId       : " + paramMap.get("introUserId"));
        log.debug("muMemberId        : " + paramMap.get("muMemberId"));
        log.debug("modId             : " + paramMap.get("modId"));
        log.debug("regId             : " + paramMap.get("regId"));

        try{
            boolean check  = true;
            String tId = String.valueOf(System.currentTimeMillis());

            // 주민등록번호, 여권번호, 외국인 등록번호 정규식 패턴
            Pattern regRrn = Pattern.compile("^[0-9]{6}-[1-4][0-9]{6}$"); // 주민등록번호 형식
//            Pattern regPassport = Pattern.compile("^[A-PR-WYa-pr-wy][1-9]\\d\\s?\\d{4}[1-9]$"); // 대략적인 여권번호 형식
            Pattern regForeigner = Pattern.compile("^[0-9]{6}-[5-8][0-9]{6}$"); // 외국인 등록번호 형식

            String nationality = String.valueOf(paramMap.get("nationality"));
            boolean localYn = Boolean.parseBoolean((String) paramMap.get("localYn"));
            String userName = String.valueOf(paramMap.get("userName"));
            String userRrn1 = String.valueOf(paramMap.get("userRrn1"));
            String userRrn2 = String.valueOf(paramMap.get("userRrn2"));
            String userPno = String.valueOf(paramMap.get("userPno"));
            String userArc1 = String.valueOf(paramMap.get("userArc1"));
            String userArc2 = String.valueOf(paramMap.get("userArc2"));
            String birthday = String.valueOf(paramMap.get("birthday"));
            String gender = String.valueOf(paramMap.get("gender"));
            String userType = String.valueOf(paramMap.get("userType"));
            String phoneNumber = String.valueOf(paramMap.get("phoneNumber"));
            String phoneNumber2 = String.valueOf(paramMap.get("phoneNumber2"));
//            String email = String.valueOf(paramMap.get("email"));
            String identificationType = String.valueOf(paramMap.get("identification"));

            if(true != ValidationCheckUtil.emptyCheck(nationality)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","국적 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(userName)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객 성함 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(birthday)){
                paramMap.put("birthday", null);
                /*check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","생년월일 정보가 없습니다.");*/
            }
            /*if(true != ValidationCheckUtil.emptyCheck(gender)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","성별 정보가 없습니다.");
            }*/
            if (localYn) {
                /*if(true != ValidationCheckUtil.emptyCheck(userRrn1)){
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","주민번호 앞자리가 없습니다.");
                }
                if(true != ValidationCheckUtil.emptyCheck(userRrn2)){
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","주민번호 뒷자리가 없습니다.");
                }

                if (!ValidationCheckUtil.numberCheck(userRrn1 + userRrn2) || !regRrn.matcher(userRrn1 + "-" + userRrn2).matches()) {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","유효하지 않은 주민등록번호입니다.");
                }*/
            } else {
                /*String identificationNumber = "pno".equals(identificationType) ? userPno : userArc1 + "-" + userArc2;
//                Pattern regIdentification = "pno".equals(identificationType) ? regPassport : regForeigner;
                if("pno".equals(identificationType)){
                    if(true != ValidationCheckUtil.emptyCheck(userPno)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","여권번호가 없습니다.");
                    }
                }else{
                    if(true != ValidationCheckUtil.emptyCheck(userArc1)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","외국인 등록번호 앞자리가 없습니다.");
                    }
                    if(true != ValidationCheckUtil.emptyCheck(userArc2)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","외국인 등록번호 뒷자리가 없습니다.");
                    }
                }
//                if (!regIdentification.matcher(identificationNumber).matches()) {
//                    check = false;
//                    map.put("msgCode", Constants.FAIL);
//                    map.put("msgDesc","유효하지 않은 (외국인)식별번호입니다.");
//                }*/
            }

            if (!ValidationCheckUtil.emptyCheck(userName) || !ValidationCheckUtil.nickNameCheck(userName)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 이름 형식입니다.");
            }

            // 전화번호 형식 검증
            if (!ValidationCheckUtil.emptyCheck(phoneNumber) || !ValidationCheckUtil.phoneNumberCheck(phoneNumber)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 전화번호 형식입니다.");
            }

            // 보조 전화번호 형식 검증 (있을 경우만 검증)
            if (ValidationCheckUtil.emptyCheck(phoneNumber2) && !ValidationCheckUtil.phoneNumberCheck(phoneNumber2)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 보조 전화번호 형식입니다.");
            }

            // 이메일 형식 검증
//            if (ValidationCheckUtil.emptyCheck(email) && !ValidationCheckUtil.emailCheck(email)) {
//                check = false;
//                map.put("msgCode", Constants.FAIL);
//                map.put("msgDesc","유효하지 않은 이메일 형식입니다.");
//            }


            if(check == true){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(userListMapSize==1){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(check == true){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("updateUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "수정 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                //상단에 선언
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Calendar c1 = Calendar.getInstance();
                String tDate = sdf.format(c1.getTime());
                paramMap.put("tId", tId);
                paramMap.put("tDate", tDate);

                webUserSqlMapDAO.updateUser(paramMap);

                map.put("msgCode", Constants.OK);
                map.put("msgDesc", "수정되었습니다.");

            }
        }
		catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl updateUser END");
        return map;
    }

    /**
     * 고객 정보 수정 2 (간편예약고객 -> 신환등록)
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
    public HashMap<String, Object> updateUser2(
            HashMap<String, Object> paramMap) throws Exception{
        log.debug("WebUserServiceImpl updateUser2 START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("muUserId          : " + paramMap.get("muUserId"));

        log.debug("nationality       : " + paramMap.get("nationality"));
        log.debug("nationalityCode   : " + paramMap.get("nationalityCode"));
        log.debug("localYn           : " + paramMap.get("localYn"));
        log.debug("userName          : " + paramMap.get("userName"));
        log.debug("userRrn1          : " + paramMap.get("userRrn1"));
        log.debug("userRrn2          : " + paramMap.get("userRrn2"));
        log.debug("userPno           : " + paramMap.get("userPno"));
        log.debug("userArc1          : " + paramMap.get("userArc1"));
        log.debug("userArc2          : " + paramMap.get("userArc2"));
        log.debug("phoneNumber       : " + paramMap.get("phoneNumber"));
        log.debug("phoneNumber2      : " + paramMap.get("phoneNumber2"));
//        log.debug("email             : " + paramMap.get("email"));
//        log.debug("address           : " + paramMap.get("address"));
//        log.debug("addressDetails    : " + paramMap.get("addressDetails"));
//        log.debug("zipCode           : " + paramMap.get("zipCode"));
        log.debug("gender            : " + paramMap.get("gender"));
        log.debug("channel           : " + paramMap.get("channel"));
        log.debug("channelCode       : " + paramMap.get("channelCode"));
        log.debug("muGroupId         : " + paramMap.get("muGroupId"));
        log.debug("memo              : " + paramMap.get("memo"));
        log.debug("etc               : " + paramMap.get("etc"));
        log.debug("birthday          : " + paramMap.get("birthday"));
        log.debug("userTypeCode      : " + paramMap.get("userTypeCode"));
        log.debug("userType          : " + paramMap.get("userType"));
        log.debug("refusePhotoYn     : " + paramMap.get("refusePhotoYn"));
        log.debug("smsYn             : " + paramMap.get("smsYn"));
//        log.debug("emailYn           : " + paramMap.get("emailYn"));
        log.debug("identification    : " + paramMap.get("identification"));
        log.debug("introUserId       : " + paramMap.get("introUserId"));
        log.debug("muMemberId        : " + paramMap.get("muMemberId"));
        log.debug("modId             : " + paramMap.get("modId"));
        log.debug("regId             : " + paramMap.get("regId"));

        try{
            boolean check  = true;
            String tId = String.valueOf(System.currentTimeMillis());

            // 주민등록번호, 여권번호, 외국인 등록번호 정규식 패턴
            Pattern regRrn = Pattern.compile("^[0-9]{6}-[1-4][0-9]{6}$"); // 주민등록번호 형식
//            Pattern regPassport = Pattern.compile("^[A-PR-WYa-pr-wy][1-9]\\d\\s?\\d{4}[1-9]$"); // 대략적인 여권번호 형식
            Pattern regForeigner = Pattern.compile("^[0-9]{6}-[5-8][0-9]{6}$"); // 외국인 등록번호 형식

            String nationality = String.valueOf(paramMap.get("nationality"));
            boolean localYn = Boolean.parseBoolean((String) paramMap.get("localYn"));
            String muUserId = String.valueOf(paramMap.get("muUserId"));
            String userName = String.valueOf(paramMap.get("userName"));
            String userRrn1 = String.valueOf(paramMap.get("userRrn1"));
            String userRrn2 = String.valueOf(paramMap.get("userRrn2"));
            String userPno = String.valueOf(paramMap.get("userPno"));
            String userArc1 = String.valueOf(paramMap.get("userArc1"));
            String userArc2 = String.valueOf(paramMap.get("userArc2"));
            String birthday = String.valueOf(paramMap.get("birthday"));
            String gender = String.valueOf(paramMap.get("gender"));
            String userType = String.valueOf(paramMap.get("userType"));
            String phoneNumber = String.valueOf(paramMap.get("phoneNumber"));
            String phoneNumber2 = String.valueOf(paramMap.get("phoneNumber2"));
//            String email = String.valueOf(paramMap.get("email"));
            String identificationType = String.valueOf(paramMap.get("identification"));
            
            if(true != ValidationCheckUtil.emptyCheck(muUserId)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(nationality)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","국적 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(userName)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객 성함 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(birthday)){
                paramMap.put("birthday", null);
                /*check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","생년월일 정보가 없습니다.");*/
            }
            /*if(true != ValidationCheckUtil.emptyCheck(gender)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","성별 정보가 없습니다.");
            }*/
            if (localYn) {
                /*if(true != ValidationCheckUtil.emptyCheck(userRrn1)){
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","주민번호 앞자리가 없습니다.");
                }
                if(true != ValidationCheckUtil.emptyCheck(userRrn2)){
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","주민번호 뒷자리가 없습니다.");
                }

                if (!ValidationCheckUtil.numberCheck(userRrn1 + userRrn2) || !regRrn.matcher(userRrn1 + "-" + userRrn2).matches()) {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","유효하지 않은 주민등록번호입니다.");
                }*/
            } else {
                /*String identificationNumber = "pno".equals(identificationType) ? userPno : userArc1 + "-" + userArc2;
//                Pattern regIdentification = "pno".equals(identificationType) ? regPassport : regForeigner;
                if("pno".equals(identificationType)){
                    if(true != ValidationCheckUtil.emptyCheck(userPno)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","여권번호가 없습니다.");
                    }
                }else{
                    if(true != ValidationCheckUtil.emptyCheck(userArc1)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","외국인 등록번호 앞자리가 없습니다.");
                    }
                    if(true != ValidationCheckUtil.emptyCheck(userArc2)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","외국인 등록번호 뒷자리가 없습니다.");
                    }
                }
//                if (!regIdentification.matcher(identificationNumber).matches()) {
//                    check = false;
//                    map.put("msgCode", Constants.FAIL);
//                    map.put("msgDesc","유효하지 않은 (외국인)식별번호입니다.");
//                }*/
            }

            if (!ValidationCheckUtil.emptyCheck(userName) || !ValidationCheckUtil.nickNameCheck(userName)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 이름 형식입니다.");
            }

            // 전화번호 형식 검증
            if (!ValidationCheckUtil.emptyCheck(phoneNumber) || !ValidationCheckUtil.phoneNumberCheck(phoneNumber)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 전화번호 형식입니다.");
            }

            // 보조 전화번호 형식 검증 (있을 경우만 검증)
            if (ValidationCheckUtil.emptyCheck(phoneNumber2) && !ValidationCheckUtil.phoneNumberCheck(phoneNumber2)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 보조 전화번호 형식입니다.");
            }

            // 이메일 형식 검증
//            if (ValidationCheckUtil.emptyCheck(email) && !ValidationCheckUtil.emailCheck(email)) {
//                check = false;
//                map.put("msgCode", Constants.FAIL);
//                map.put("msgDesc","유효하지 않은 이메일 형식입니다.");
//            }


            if(check == true){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(userListMapSize==1){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(check == true){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("updateUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "수정 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                //상단에 선언
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Calendar c1 = Calendar.getInstance();
                String tDate = sdf.format(c1.getTime());
                paramMap.put("tId", tId);
                
                paramMap.put("tDate", tDate);

                webUserSqlMapDAO.updateUser(paramMap);

                map.put("msgCode", Constants.OK);
                map.put("msgDesc", "등록되었습니다.");

            }
        }
		catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl updateUser2 END");
        return map;
    }

    /**
     * 고객 정보 상세 조회
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectUser(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUser START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));

        log.debug("muMemberId          :"+paramMap.get("muMemberId"));

        log.debug("menuClass           :"+paramMap.get("menuClass"));

        log.debug("muUserId            :"+paramMap.get("muUserId"));

        try{
            boolean check  = true;
            String muUserId    = String.valueOf(paramMap.get("muUserId"));

            if(true != ValidationCheckUtil.emptyCheck(muUserId)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객 정보가 없습니다.");
            }

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }
            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
                int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

                if(1==authMenuRelationlistMapSize){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "조회 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
            if(true == check){
                List<Map<String, Object>> userDetail = webUserSqlMapDAO.selectUser(paramMap);
                String introUserId = (String)userDetail.get(0).get("introUserId");
                Map<String, Object> physical = new HashMap<>();
                if(null!=introUserId){
                    userDetail.add(webUserSqlMapDAO.checkUser(introUserId));
                }
                if(!userDetail.isEmpty()){
                    physical = webUserSqlMapDAO.selectUserPhysical(paramMap);

                    if(null!=physical){
                        map.put("userPhysical",physical);
                    }
                }
                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("userDetail",userDetail);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUser END");
        return map;
    }
    /**
     * 고객 등록
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
    public HashMap<String, Object> insertUser(
            HashMap<String, Object> paramMap) throws Exception{

        log.debug("WebUserServiceImpl insertUser START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("nationality       : " + paramMap.get("nationality"));
        log.debug("nationalityCode   : " + paramMap.get("nationalityCode"));
        log.debug("localYn           : " + paramMap.get("localYn"));
        log.debug("userName          : " + paramMap.get("userName"));
        log.debug("userRrn1          : " + paramMap.get("userRrn1"));
        log.debug("userRrn2          : " + paramMap.get("userRrn2"));
        log.debug("userPno           : " + paramMap.get("userPno"));
        log.debug("userArc1          : " + paramMap.get("userArc1"));
        log.debug("userArc2          : " + paramMap.get("userArc2"));
        log.debug("phoneNumber       : " + paramMap.get("phoneNumber"));
        log.debug("phoneNumber2      : " + paramMap.get("phoneNumber2"));
//        log.debug("email             : " + paramMap.get("email"));
//        log.debug("address           : " + paramMap.get("address"));
//        log.debug("addressDetails    : " + paramMap.get("addressDetails"));
//        log.debug("zipCode           : " + paramMap.get("zipCode"));
        log.debug("gender            : " + paramMap.get("gender"));
        log.debug("channel           : " + paramMap.get("channel"));
        log.debug("channelCode       : " + paramMap.get("channelCode"));
        log.debug("muGroupId         : " + paramMap.get("muGroupId"));
        log.debug("memo              : " + paramMap.get("memo"));
        log.debug("etc               : " + paramMap.get("etc"));
        log.debug("birthday          : " + paramMap.get("birthday"));
        log.debug("userTypeCode      : " + paramMap.get("userTypeCode"));
        log.debug("userType          : " + paramMap.get("userType"));
        log.debug("refusePhotoYn     : " + paramMap.get("refusePhotoYn"));
        log.debug("smsYn             : " + paramMap.get("smsYn"));
//        log.debug("emailYn           : " + paramMap.get("emailYn"));
        log.debug("identification    : " + paramMap.get("identification"));
        log.debug("introUserId       : " + paramMap.get("introUserId"));
        log.debug("muMemberId        : " + paramMap.get("muMemberId"));
        log.debug("modId             : " + paramMap.get("modId"));
        log.debug("regId             : " + paramMap.get("regId"));

        try{
            boolean check  = true;
            String tId = String.valueOf(System.currentTimeMillis());

            // 주민등록번호, 여권번호, 외국인 등록번호 정규식 패턴
            Pattern regRrn = Pattern.compile("^[0-9]{6}-[1-4][0-9]{6}$"); // 주민등록번호 형식
//            Pattern regPassport = Pattern.compile("^[A-PR-WYa-pr-wy][1-9]\\d\\s?\\d{4}[1-9]$"); // 대략적인 여권번호 형식
            Pattern regForeigner = Pattern.compile("^[0-9]{6}-[5-8][0-9]{6}$"); // 외국인 등록번호 형식

            String nationality = String.valueOf(paramMap.get("nationality"));
            boolean localYn = Boolean.parseBoolean((String) paramMap.get("localYn"));
            String userName = String.valueOf(paramMap.get("userName"));
            String userRrn1 = String.valueOf(paramMap.get("userRrn1"));
            String userRrn2 = String.valueOf(paramMap.get("userRrn2"));
            String userPno = String.valueOf(paramMap.get("userPno"));
            String userArc1 = String.valueOf(paramMap.get("userArc1"));
            String userArc2 = String.valueOf(paramMap.get("userArc2"));
            String birthday = String.valueOf(paramMap.get("birthday"));
            String gender = String.valueOf(paramMap.get("gender"));
            String userType = String.valueOf(paramMap.get("userType"));
            String phoneNumber = String.valueOf(paramMap.get("phoneNumber"));
            String phoneNumber2 = String.valueOf(paramMap.get("phoneNumber2"));
//            String email = String.valueOf(paramMap.get("email"));
            String identificationType = String.valueOf(paramMap.get("identification"));

            if(true != ValidationCheckUtil.emptyCheck(nationality)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","국적 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(userName)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객 성함 정보가 없습니다.");
            }
            if(true != ValidationCheckUtil.emptyCheck(birthday)){
                paramMap.put("birthday", null);
                /*check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","생년월일 정보가 없습니다.");*/
            }
            /*if(true != ValidationCheckUtil.emptyCheck(gender)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","성별 정보가 없습니다.");
            }*/
            /*if(true != ValidationCheckUtil.emptyCheck(userType)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객구분 정보가 없습니다.");
            }*/

            if (localYn) {
                /*if(true != ValidationCheckUtil.emptyCheck(userRrn1)){
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","주민번호 앞자리가 없습니다.");
                }
                if(true != ValidationCheckUtil.emptyCheck(userRrn2)){
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","주민번호 뒷자리가 없습니다.");
                }

                if (!ValidationCheckUtil.numberCheck(userRrn1 + userRrn2) || !regRrn.matcher(userRrn1 + "-" + userRrn2).matches()) {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc","유효하지 않은 주민등록번호입니다.");
                }*/
            } else {
                /*String identificationNumber = "pno".equals(identificationType) ? userPno : userArc1 + "-" + userArc2;
//                Pattern regIdentification = "pno".equals(identificationType) ? regPassport : regForeigner;
                if("pno".equals(identificationType)){
                    if(true != ValidationCheckUtil.emptyCheck(userPno)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","여권번호가 없습니다.");
                    }
                }else{
                    if(true != ValidationCheckUtil.emptyCheck(userArc1)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","외국인 등록번호 앞자리가 없습니다.");
                    }
                    if(true != ValidationCheckUtil.emptyCheck(userArc2)){
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","외국인 등록번호 뒷자리가 없습니다.");
                    }
                }
//                if (!regIdentification.matcher(identificationNumber).matches()) {
//                    check = false;
//                    map.put("msgCode", Constants.FAIL);
//                    map.put("msgDesc","유효하지 않은 (외국인)식별번호입니다.");
//                }*/
            }

            if (!ValidationCheckUtil.emptyCheck(userName) || !ValidationCheckUtil.nickNameCheck(userName)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 이름 형식입니다.");
            }

            // 전화번호 형식 검증
            if (!ValidationCheckUtil.emptyCheck(phoneNumber) || !ValidationCheckUtil.phoneNumberCheck(phoneNumber)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 전화번호 형식입니다.");
            }

            // 보조 전화번호 형식 검증 (있을 경우만 검증)
            if (ValidationCheckUtil.emptyCheck(phoneNumber2) && !ValidationCheckUtil.phoneNumberCheck(phoneNumber2)) {
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","유효하지 않은 보조 전화번호 형식입니다.");
            }

            // 이메일 형식 검증
//            if (ValidationCheckUtil.emptyCheck(email) && !ValidationCheckUtil.emailCheck(email)) {
//                check = false;
//                map.put("msgCode", Constants.FAIL);
//                map.put("msgDesc","유효하지 않은 이메일 형식입니다.");
//            }

            if(check == true){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(userListMapSize==1){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(check == true){
                String muUserId = ("U").concat(String.valueOf(System.currentTimeMillis()));
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Calendar c1 = Calendar.getInstance();
                String tDate = sdf.format(c1.getTime());
                paramMap.put("muUserId", muUserId);
                paramMap.put("tId", tId);
                paramMap.put("tDate", tDate);
                webUserSqlMapDAO.insertUser(paramMap);

                map.put("msgCode", Constants.OK);
                map.put("msgDesc", "등록되었습니다.");
            }
        }catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl insertUser END");
        return map;
    }
    
    /**
     * 고객 검색 조회 (상단 검색)
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectUserSearch(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUserSearch START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));

        log.debug("muMemberId          :"+paramMap.get("muMemberId"));

        log.debug("menuClass           :"+paramMap.get("menuClass"));

        log.debug("searchKeyword       :"+paramMap.get("searchKeyword"));

        try{
            boolean check  = true;
            String searchKeyword    = String.valueOf(paramMap.get("searchKeyword"));

            if(true != ValidationCheckUtil.emptyCheck(searchKeyword)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","검색어 정보가 없습니다.");
            }

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                List<Map<String, Object>> listMap = webUserSqlMapDAO.selectUserSearch(paramMap);
                
                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUserSearch END");
        return map;
    }
    
    /**
     * 고객 신체정보 등록
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
    public HashMap<String, Object> insertPhysical(
            HashMap<String, Object> paramMap) throws Exception{
        log.debug("WebUserServiceImpl insertPhysical START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("muMemberId         :"+paramMap.get("muMemberId"));
        log.debug("regId              :"+paramMap.get("regId"));
        log.debug("modId              :"+paramMap.get("modId"));
        log.debug("muUserId           :"+paramMap.get("muUserId"));
        log.debug("fatMass            :"+paramMap.get("fatMass"));
        log.debug("fatPercent         :"+paramMap.get("fatPercent"));
        log.debug("weight             :"+paramMap.get("weight"));
        log.debug("muscleMass         :"+paramMap.get("muscleMass"));
        log.debug("height             :"+paramMap.get("height"));
        log.debug("bmi                :"+paramMap.get("bmi"));
        log.debug("memo               :"+paramMap.get("memo"));

        try{
            boolean check  = true;
            String tId = String.valueOf(System.currentTimeMillis());
            String muMemberId      = String.valueOf(paramMap.get("muMemberId"));
            String muUserId        = String.valueOf(paramMap.get("muUserId"));
            String fatMass         = String.valueOf(paramMap.get("fatMass"));
            String fatPercent      = String.valueOf(paramMap.get("fatPercent"));
            String weight          = String.valueOf(paramMap.get("weight"));
            String muscleMass      = String.valueOf(paramMap.get("muscleMass"));
            String height          = String.valueOf(paramMap.get("height"));
            String bmi             = String.valueOf(paramMap.get("bmi"));
            String memo            = String.valueOf(paramMap.get("memo"));

            Pattern regHeight = Pattern.compile("^\\d{1,3}(\\.\\d)?$");
            Pattern regWeight = Pattern.compile("^\\d{1,3}(\\.\\d)?$");
            Pattern regMuscleMass = Pattern.compile("^\\d{1,3}(\\.\\d)?$");
            Pattern regFatMass = Pattern.compile("^\\d{1,3}(\\.\\d)?$");
            Pattern regFatPercent = Pattern.compile("^\\d{1,2}(\\.\\d)?$");
            Pattern regBmi = Pattern.compile("^\\d{1,2}(\\.\\d)?$");

            /*if(true != ValidationCheckUtil.emptyCheck(height)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","키 정보가 없습니다.");
            }else if(!regHeight.matcher(height).matches()){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","키는 최대 3자리 숫자여야 합니다.");
            }

            if(true != ValidationCheckUtil.emptyCheck(weight)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","몸무게 정보가 없습니다");
            }else if(!regWeight.matcher(weight).matches()){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","몸무게는 최대 3자리 숫자여야 합니다.");
            }

            if(true != ValidationCheckUtil.emptyCheck(muscleMass)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","골격근량 정보가 없습니다");
            }else if(!regMuscleMass.matcher(muscleMass).matches()){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","골격근량은 최대 3자리 숫자여야 합니다.");
            }

            if(true != ValidationCheckUtil.emptyCheck(fatMass)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","체지방량 정보가 없습니다");
            }else if(!regFatMass.matcher(fatMass).matches()){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","체지방량은  최대 3자리 숫자여야 합니다.");
            }

            if(true != ValidationCheckUtil.emptyCheck(fatPercent)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","체지방률 정보가 없습니다");
            }else if(!regFatPercent.matcher(fatPercent).matches()){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","체지방률은  최대 2자리 숫자여야 합니다.");
            }

            if(true != ValidationCheckUtil.emptyCheck(bmi)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","BMI 정보가 없습니다");
            }else if(!regBmi.matcher(bmi).matches()){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","BMI는  최대 2자리 숫자여야 합니다.");
            }*/

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("insertUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "등록 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                try {
//                    paramMap.put("password", SecurityUtil.encryptSHA256((String) paramMap.get("password")));
                }
                catch (Exception e) {
                    throw new Exception(e.getMessage());
                }
                String muUserPhysicalId = ("U").concat(String.valueOf(System.currentTimeMillis()));
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Calendar c1 = Calendar.getInstance();
                String tDate = sdf.format(c1.getTime());
                paramMap.put("muUserPhysicalId", muUserPhysicalId);
                paramMap.put("tId", tId);
                paramMap.put("tDate", tDate);
                webUserSqlMapDAO.insertPhysical(paramMap);
                log.debug("muMemberId :"+paramMap.get("id"));
                paramMap.put("muMemberId", paramMap.get("id"));
                map.put("muMemberId", paramMap.get("muMemberId"));

                map.put("msgCode", Constants.OK);
                map.put("msgDesc", "등록되었습니다.");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl insertPhysical END");
        return map;
    }

    /**
     * 신체정보 리스트 조회.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectUserPhysicalList(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUserPhysicalList START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("loginMemberId                :"+paramMap.get("loginMemberId"));
        log.debug("muMemberId                :"+paramMap.get("muMemberId"));
        log.debug("muUserId                    :"+paramMap.get("muUserId"));
        log.debug("menuClass                 :"+paramMap.get("menuClass"));
        log.debug("userStart                    :"+paramMap.get("userStart"));
        log.debug("userLimit                    :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "조회 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                int TotalPhysicalCount = webUserSqlMapDAO.selectTotalPhysicalCount(paramMap);
                map.put("recentData",webUserSqlMapDAO.selectUserPhysical(paramMap));
                if(0<TotalPhysicalCount){
                    listMap = webUserSqlMapDAO.selectUserPhysicalList(paramMap);
                }


                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("rows",listMap);
                map.put("totalCount",TotalPhysicalCount);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUserPhysicalList END");
        return map;
    }

    /**
     * 고객 신체기록 리스트 화면으로 이동.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUserPhysicalIntro(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserPhysicalIntro START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
        log.debug("menuClass           :"+paramMap.get("menuClass"));

        try{
            boolean check  = true;

            String menuClass    = String.valueOf(paramMap.get("menuClass"));

            if(true != ValidationCheckUtil.emptyCheck(menuClass)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","메뉴 정보가 없습니다.");
            }

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){
                    map.put("msgCode", Constants.OK);
                    map.put("success","true");

                    map.put("selectUseYn", authMenuRelationlistMap.get(0).get("selectUseYn"));
                    map.put("insertUseYn", authMenuRelationlistMap.get(0).get("insertUseYn"));
                    map.put("updateUseYn", authMenuRelationlistMap.get(0).get("updateUseYn"));
                    map.put("deleteUseYn", authMenuRelationlistMap.get(0).get("deleteUseYn"));
                    map.put("downloadUseYn", authMenuRelationlistMap.get(0).get("downloadUseYn"));
                }
                else {
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserPhysicalIntro END");
        return map;
    }
    /**
     * 고객 신체기록 리스트 조회 (List, Excel)
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public List<Map<String, Object>> selectUserPhysicalListExcel(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUserPhysicalListExcel START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = null;

        log.debug("loginMemberId                :"+paramMap.get("loginMemberId"));
        log.debug("muMemberId                   :"+paramMap.get("muMemberId"));
        log.debug("muUserId                     :"+paramMap.get("muUserId"));
        log.debug("userSort                     :"+paramMap.get("userSort"));
        log.debug("userStart                    :"+paramMap.get("userStart"));
        log.debug("muMenuClass                  :"+paramMap.get("muMenuClass"));
        log.debug("userLimit                    :"+paramMap.get("userLimit"));
        log.debug("userStart                    :"+paramMap.get("userStart"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("downloadUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "내려받기 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                listMap = webUserSqlMapDAO.selectUserPhysicalListExcel(paramMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUserPhysicalListExcel END");
        return listMap;
    }

	/**
	 * 고객 신체정보 상세 조회.
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectUserPhysical(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebUserServiceImpl selectUserPhysical START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserPhysicalId    :"+paramMap.get("muUserPhysicalId"));
		
		try{
			boolean check  = true;
			String muUserPhysicalId    = String.valueOf(paramMap.get("muUserPhysicalId"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserPhysicalId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 신체기록 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
                int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

                if(1==authMenuRelationlistMapSize){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "조회 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
			if(true == check){
				List<Map<String, Object>> listMap = webUserSqlMapDAO.selectUserPhysical2(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebUserServiceImpl selectUserPhysical END");
		return map;
	}
	
	/**
	 * 고객 신체정보 수정 (담당자)
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateUserPhysical(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebUserServiceImpl updateUserPhysical START");
	
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserPhysicalId    :"+paramMap.get("muUserPhysicalId"));
		log.debug("muMemberId          :"+paramMap.get("muMemberId"));
	
		try{
			boolean check  = true;
			
			String muUserPhysicalId      = String.valueOf(paramMap.get("muUserPhysicalId"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserPhysicalId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 신체기록 정보가 없습니다.");
			}
	
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
	
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				
				if(1==authMenuRelationlistMap.size()){
					if(("Y").equals(authMenuRelationlistMap.get(0).get("updateUseYn"))) {
					
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "수정 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "수정 정보가 없습니다.");
				}
			}
	
			if(true == check){
				webUserSqlMapDAO.updateUserPhysical(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "저장되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	
		log.debug("WebUserServiceImpl updateUserPhysical END");
		return map;
	}
	

    /**
     * 고객 신체정보 불러오기 (인바디 정보 불러오기, api 연동)
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
    public HashMap<String, Object> insertUserPhysicalInbodyApi(
            HashMap<String, Object> paramMap) throws Exception{
        log.debug("WebUserServiceImpl insertUserPhysicalInbodyApi START");

        HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserId            :"+paramMap.get("muUserId"));

        try{
        	boolean check  = true;
			String tId = String.valueOf(System.currentTimeMillis());
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar c1 = Calendar.getInstance();
			String tDate = sdf.format(c1.getTime());
			
            String muUserId        = String.valueOf(paramMap.get("muUserId"));

            if(true != ValidationCheckUtil.emptyCheck(muUserId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 정보가 없습니다.");
			}
			
            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("insertUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "등록 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
            
            if(true == check){
				// 고객정보 확인
				List<Map<String, Object>> userList = webUserSqlMapDAO.selectUser(paramMap);
				
				if(1==userList.size()) {
					paramMap.put("phoneNumber", userList.get(0).get("phoneNumber"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "고객 정보가 없습니다.");
				}
			}
            
            if(true == check){
            	
            	// 고객 전화번호
    			String usertoken = String.valueOf(paramMap.get("phoneNumber"));
    			
    			// Inbody 날짜 정보 조회
    			String inbodyTimeInfo = inBodyApiProvider.getDateTimes(usertoken);
    			
    			int insertCount = 0;
    			if(null!=inbodyTimeInfo && !("").equals(inbodyTimeInfo)) {
	    			// Inbody 정보 조회
	    			JSONParser parser = new JSONParser();
	    			Object inbodyTimeObj = parser.parse( inbodyTimeInfo );
	    			
	    			JSONArray inbodyTimeInfoObj = (JSONArray) inbodyTimeObj;
	    			
	    			for (int i = 0; i < inbodyTimeInfoObj.size(); i++) {
	    				String dataTimes = String.valueOf(inbodyTimeInfoObj.get(i));
	    				log.debug("dataTimes ["+i+"] :" + dataTimes);
	    				
	    				if(null!=dataTimes && !("").equals(dataTimes)) {
	    					String inbodyInfo = inBodyApiProvider.getFullInBodyData(usertoken, dataTimes);
	    					log.debug("inbodyInfo :" + inbodyInfo);
	    					
	    					JSONParser parser3 = new JSONParser();
	    					Object inbodyObj = parser3.parse( inbodyInfo );
	    					
	    					JSONObject inbodyInfoObj = (JSONObject) inbodyObj;
	    					
	    					String birthDay     = (String)inbodyInfoObj.get("birthday");
	    					String userName     = (String)inbodyInfoObj.get("name");
	    					String mobileNumber = (String)inbodyInfoObj.get("MobileNumber");
	    					String dateTime     = (String)inbodyInfoObj.get("TestDate/Time");
	    					String height       = (String)inbodyInfoObj.get("Height");
	    					String weight       = (String)inbodyInfoObj.get("Weight");
	    					String bfm          = (String)inbodyInfoObj.get("BFM(BodyFatMass)");
	    					String bmi          = (String)inbodyInfoObj.get("BMI(BodyMassIndex)");
	    					String smm          = (String)inbodyInfoObj.get("SMM(SkeletalMuscleMass)");
	    					String pbf          = (String)inbodyInfoObj.get("PBF(PercentBodyFat)");
	
	    					log.debug("birthDay          :"+birthDay);
	    					log.debug("userName          :"+userName);
	    					log.debug("mobileNumber      :"+mobileNumber);
	    					log.debug("dateTime          :"+dateTime);
	    					log.debug("height            :"+height);
	    					log.debug("weight            :"+weight);
	    					log.debug("bfm               :"+bfm);
	    					log.debug("bmi               :"+bmi);
	    					log.debug("smm               :"+smm);
	    					log.debug("pbf               :"+pbf);
	    					
	
	    					
	    					HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
	    					selectParamMap.put("muUserId", paramMap.get("muUserId"));
	    					selectParamMap.put("inbodyDateTimes", dataTimes);
	    					List<Map<String, Object>> userPhysicalInbodyList = webUserSqlMapDAO.selectUserPhysicalInbodyDateTimes(selectParamMap);
	    					int userPhysicalInbodyListSize = Integer.parseInt(String.valueOf(userPhysicalInbodyList.get(0).get("totalCount")));
	    					
	    					if(0 == userPhysicalInbodyListSize) {
	    						HashMap<String, Object> insertParamMap = new HashMap<String, Object>();
	        					String muUserPhysicalId = ("UP").concat(String.valueOf(System.currentTimeMillis()));
	        					insertParamMap.put("muUserPhysicalId", muUserPhysicalId);
	        					insertParamMap.put("muUserId", paramMap.get("muUserId"));
	        					insertParamMap.put("height", height);
	        					insertParamMap.put("weight", weight);
	        					insertParamMap.put("muscleMass", smm);    // 골격근량
	        					insertParamMap.put("fatMass", bfm);       // 체지방량
	        					insertParamMap.put("fatPercent", pbf);    // 체지방률
	        					insertParamMap.put("bmi", bmi);           // bmi
	        					insertParamMap.put("muMemberId", paramMap.get("loginMemberId"));
	        					insertParamMap.put("inbodyDateTimes", dataTimes);
	        					insertParamMap.put("tId", tId);
	        					insertParamMap.put("tDate", tDate);
	        					insertParamMap.put("regId", paramMap.get("regId"));
	        					insertParamMap.put("modId", paramMap.get("modId"));
	        	                webUserSqlMapDAO.insertPhysical(insertParamMap);
	        	                
	        	                insertCount++;
	    					}
	    					
	    				}
	    			}
    			}
	    			
                map.put("msgCode", Constants.OK);
                map.put("msgDesc", insertCount + "건 등록되었습니다.");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl insertUserPhysicalInbodyApi END");
        return map;
    }

    /**
     * 고객 동의서 리스트 화면으로 이동.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectListUserAgreementIntro(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectListUserAgreementIntro START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
        log.debug("menuClass           :"+paramMap.get("menuClass"));

        try{
            boolean check  = true;

            String menuClass    = String.valueOf(paramMap.get("menuClass"));

            if(true != ValidationCheckUtil.emptyCheck(menuClass)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","메뉴 정보가 없습니다.");
            }

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);

                if(1==userListMap.size()){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){
                    map.put("msgCode", Constants.OK);
                    map.put("success","true");

                    map.put("selectUseYn", authMenuRelationlistMap.get(0).get("selectUseYn"));
                    map.put("insertUseYn", authMenuRelationlistMap.get(0).get("insertUseYn"));
                    map.put("updateUseYn", authMenuRelationlistMap.get(0).get("updateUseYn"));
                    map.put("deleteUseYn", authMenuRelationlistMap.get(0).get("deleteUseYn"));
                    map.put("downloadUseYn", authMenuRelationlistMap.get(0).get("downloadUseYn"));
                }
                else {
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectListUserAgreementIntro END");
        return map;
    }

    /**
     * 고객 동의서 등록
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
    public HashMap<String, Object> insertUserAgreement(
            HashMap<String, Object> paramMap, MultipartFile file) throws Exception{
        log.debug("WebUserServiceImpl insertUserAgreement START");

        HashMap<String, Object> map = new HashMap<String, Object>();

        log.debug("muUserId              :"+paramMap.get("muUserId"));

        log.debug("menuClass             :"+paramMap.get("menuClass"));

        log.debug("writeDate             :"+paramMap.get("writeDate"));
        log.debug("type                  :"+paramMap.get("type"));
        log.debug("renewalCycle          :"+paramMap.get("renewalCycle"));
        log.debug("expirationDate        :"+paramMap.get("expirationDate"));

        log.debug("userName              :"+paramMap.get("userName"));
        
        // 이용약관동의서(한국, 일본, 중국) - 동의여부 (Y, N) 항목
        log.debug("agree3Yn              :"+paramMap.get("agree3Yn"));
        
        // 미성년자 시술 동의서 항목
        log.debug("ptUserName            :"+paramMap.get("ptUserName"));    // 공통
        log.debug("ptBirthday            :"+paramMap.get("ptBirthday"));
        log.debug("ptPhoneNumber         :"+paramMap.get("ptPhoneNumber")); // 공통
        log.debug("nokUserName           :"+paramMap.get("nokUserName"));
        log.debug("nokBirthday           :"+paramMap.get("nokBirthday"));
        log.debug("nokRelationship       :"+paramMap.get("nokRelationship"));
        log.debug("nokPhoneNumber        :"+paramMap.get("nokPhoneNumber"));
        log.debug("nokAddress            :"+paramMap.get("nokAddress"));
        
        // 인플루언서동의서(일본) 항목, N번 일반체험단동의서 (일본) 항목
        log.debug("snsItem1              :"+paramMap.get("snsItem1"));
        log.debug("snsItem2              :"+paramMap.get("snsItem2"));
        log.debug("ptPno                 :"+paramMap.get("ptPno"));
        log.debug("ptAddress             :"+paramMap.get("ptAddress"));
        log.debug("ptPhoneNumber         :"+paramMap.get("ptPhoneNumber"));  // 공통
        log.debug("ptEmail               :"+paramMap.get("ptEmail"));       
        
        // 메이드유 문진 동의서 항목, 문진동의서(일본), 문진동의서(중국)
        log.debug("ptUserName               :"+paramMap.get("ptUserName"));  // 공통
        log.debug("ptUserRrn                :"+paramMap.get("ptUserRrn"));
        log.debug("introUserName            :"+paramMap.get("introUserName"));
        log.debug("questionnaireItem1       :"+paramMap.get("questionnaireItem1"));
        log.debug("questionnaireItem1Etc    :"+paramMap.get("questionnaireItem1Etc"));
        log.debug("questionnaireItem1Detail :"+paramMap.get("questionnaireItem1Detail"));  
        log.debug("questionnaireItem2       :"+paramMap.get("questionnaireItem2"));
        log.debug("questionnaireItem2Etc    :"+paramMap.get("questionnaireItem2Etc"));
        log.debug("questionnaireItem3       :"+paramMap.get("questionnaireItem3"));
        log.debug("questionnaireItem3Etc    :"+paramMap.get("questionnaireItem3Etc"));
        log.debug("questionnaireItem4       :"+paramMap.get("questionnaireItem4"));
        log.debug("questionnaireItem4Etc    :"+paramMap.get("questionnaireItem4Etc")); 
        
        // 진료비 환불 확인서(동의서)
        log.debug("muReserveId              :"+paramMap.get("muReserveId"));
        log.debug("ptUserName               :"+paramMap.get("ptUserName"));  // 공통
        log.debug("returnAmount             :"+paramMap.get("returnAmount"));
        log.debug("returnMethodPayment      :"+paramMap.get("returnMethodPayment"));
        log.debug("returnReason             :"+paramMap.get("returnReason"));
        log.debug("returnBank               :"+paramMap.get("returnBank"));  
        log.debug("returnAccount            :"+paramMap.get("returnAccount"));
        log.debug("address2                 :"+paramMap.get("address2"));
        log.debug("userRrn2                 :"+paramMap.get("userRrn2"));
        log.debug("userName2                :"+paramMap.get("userName2"));
        log.debug("relationship             :"+paramMap.get("relationship"));
        log.debug("phoneNumber2             :"+paramMap.get("phoneNumber2"));   

        try{
            boolean check  = true;
            String tId = String.valueOf(System.currentTimeMillis());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Calendar c1 = Calendar.getInstance();
            String tDate = sdf.format(c1.getTime());
            
            String type            = String.valueOf(paramMap.get("type"));
            String renewalCycle    = String.valueOf(paramMap.get("renewalCycle"));
            String expirationDate  = String.valueOf(paramMap.get("expirationDate"));
            
            String userName        = String.valueOf(paramMap.get("userName"));
            
            String agree3Yn                 = String.valueOf(paramMap.get("agree3Yn"));
            
            String ptUserName               = String.valueOf(paramMap.get("ptUserName"));
            String ptBirthday               = String.valueOf(paramMap.get("ptBirthday"));
            String ptPhoneNumber            = String.valueOf(paramMap.get("ptPhoneNumber")); // 인플루언서동의서(일본) 항목, , 일반체험단동의서 (일본)
            String nokUserName              = String.valueOf(paramMap.get("nokUserName"));
            String nokBirthday              = String.valueOf(paramMap.get("nokBirthday"));
            String nokRelationship          = String.valueOf(paramMap.get("nokRelationship"));
            String nokPhoneNumber           = String.valueOf(paramMap.get("nokPhoneNumber"));
            String nokAddress               = String.valueOf(paramMap.get("nokAddress"));
            

            String snsItem1                 = String.valueOf(paramMap.get("snsItem1"));
            String snsItem2                 = String.valueOf(paramMap.get("snsItem2"));
            String ptPno                    = String.valueOf(paramMap.get("ptPno"));
            String ptAddress                = String.valueOf(paramMap.get("ptAddress"));
            String ptEmail                  = String.valueOf(paramMap.get("ptEmail"));
            

            String ptUserRrn                = String.valueOf(paramMap.get("ptUserRrn"));
            String introUserName            = String.valueOf(paramMap.get("introUserName"));
            String questionnaireItem1       = String.valueOf(paramMap.get("questionnaireItem1"));
            String questionnaireItem1Etc    = String.valueOf(paramMap.get("questionnaireItem1Etc"));
            String questionnaireItem1Detail = String.valueOf(paramMap.get("questionnaireItem1Detail"));
            String questionnaireItem2       = String.valueOf(paramMap.get("questionnaireItem2"));
            String questionnaireItem2Etc    = String.valueOf(paramMap.get("questionnaireItem2Etc"));
            String questionnaireItem3       = String.valueOf(paramMap.get("questionnaireItem3"));
            String questionnaireItem3Etc    = String.valueOf(paramMap.get("questionnaireItem3Etc"));
            String questionnaireItem4       = String.valueOf(paramMap.get("questionnaireItem4"));
            String questionnaireItem4Etc    = String.valueOf(paramMap.get("questionnaireItem4Etc"));
            
            String muReserveId              = String.valueOf(paramMap.get("muReserveId"));
            String returnAmount             = String.valueOf(paramMap.get("returnAmount"));
            String returnMethodPayment      = String.valueOf(paramMap.get("returnMethodPayment"));
            String returnReason             = String.valueOf(paramMap.get("returnReason"));
            String returnBank               = String.valueOf(paramMap.get("returnBank"));
            String returnAccount            = String.valueOf(paramMap.get("returnAccount"));
            String address2                 = String.valueOf(paramMap.get("address2"));
            String userRrn2                 = String.valueOf(paramMap.get("userRrn2"));
            String userName2                = String.valueOf(paramMap.get("userName2"));
            String relationship             = String.valueOf(paramMap.get("relationship"));
            String phoneNumber2             = String.valueOf(paramMap.get("phoneNumber2"));
            
            if(true != ValidationCheckUtil.emptyCheck(userName)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","고객명 정보가 없습니다.");
            }
            
            if(true != ValidationCheckUtil.emptyCheck(type)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","동의서를 선택하세요");
            }
            else {
            	if(("C").equals(type)) {
            		if(("Y").equals(agree3Yn)) {
                		
                	}
            		else {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[3가지 모두 동의함]에 동의하셔야 합니다.");
            		}
            	}
            	else if(("K").equals(type)) {
            		// K번 이용약관동의서(일본)
            		if(("Y").equals(agree3Yn)) {
                		
                	}
            		else {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[三つとも同意]에 동의하셔야 합니다.");
            		}
            	}
            	else if(("Q").equals(type)) {
            		// Q번 이용약관동의서 (중국)
            		if(("Y").equals(agree3Yn)) {
                		
                	}
            		else {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[3个选项都同意]에 동의하셔야 합니다.");
            		}
            	}
            	else if(("F").equals(type)) {
            		// F번 미성년자 시술 동의서
            		if(true != ValidationCheckUtil.emptyCheck(ptUserName)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환자 성함 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(ptBirthday)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환자 생년월일 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(ptPhoneNumber)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환자 연락처 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(nokUserName)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","법정대리인 성함 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(nokBirthday)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","법정대리인 생년월일 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(nokRelationship)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","법정대리인 관계 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(nokPhoneNumber)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","법정대리인 연락처 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(nokAddress)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","법정대리인 주소 정보가 없습니다.");
            		}
            	}
            	else if(("M").equals(type) || ("N").equals(type)) {
            		// M번 일플루언서 동의서(일본), N번 일반체험단동의서 (일본)
            		if(true != ValidationCheckUtil.emptyCheck(snsItem1)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[レビュー予定のSNS媒体] 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(snsItem2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[SNSアカウント名] 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(ptPno)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[パスポート番号] 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(ptAddress)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[住所] 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(ptPhoneNumber)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[電話番号] 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(ptEmail)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[メールアドレス] 정보가 없습니다.");
            		}
            	}
            	else if(("E").equals(type)) {
            		// E번 메이드유 문진 동의서
            		if(true != ValidationCheckUtil.emptyCheck(ptUserName)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","성함 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(ptUserRrn)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","주민번호 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem1)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","현재질환 유무 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem1)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem1Etc)
            						&& true!= ValidationCheckUtil.emptyCheck(questionnaireItem1Detail)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","현재질환 '유'일 경우 상세 선택 및 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","현재질환 유무 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem2)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem2Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","현재복용약 '유'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem3)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","임신가능성 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem3)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem3Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","임신가능성 '유'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem4)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","수술여부 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem4)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem4Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","수술여부 '유'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            	}
            	else if(("L").equals(type)) {
            		// L번 문진 동의서(일본)
            		if(true != ValidationCheckUtil.emptyCheck(ptUserName)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[お名前] 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(ptUserRrn)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[住民番号(生年月日)] 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem1)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[現在の疾患 有/無] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem1)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem1Etc)
            						&& true!= ValidationCheckUtil.emptyCheck(questionnaireItem1Detail)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[現在の疾患] '有'일 경우 상세 선택 및 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[現在服用薬] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem2)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem2Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[現在服用薬] '有'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem3)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[妊娠可能性] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem3)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem3Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[妊娠可能性] '有'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem4)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[手術経験] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem4)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem4Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[手術経験] '有'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            	}
            	else if(("R").equals(type)) {
            		// R번 문진 동의서(중국)
            		if(true != ValidationCheckUtil.emptyCheck(ptUserName)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[姓名] 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(ptUserRrn)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[身份证号] 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem1)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[当前疾病 有/无] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem1)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem1Etc)
            						&& true!= ValidationCheckUtil.emptyCheck(questionnaireItem1Detail)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[当前疾病] '有'일 경우 상세 선택 및 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[现服药物] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem2)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem2Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[现服药物] '有'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem3)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[怀孕可能] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem3)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem3Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[怀孕可能] '有'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(questionnaireItem4)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","[手术与否] 정보가 없습니다.");
            		}
            		else {
            			if(("Y").equals(questionnaireItem4)) {
            				if(true != ValidationCheckUtil.emptyCheck(questionnaireItem4Etc)) {
                    			check = false;
                                map.put("msgCode", Constants.FAIL);
                                map.put("msgDesc","[手术与否] '有'일 경우 괄호 안 상세내용을 입력하셔야 합니다.");
                    		}
            			}
            		}
            	}
            	else if(("H").equals(type)) {
            		// H번 진료비 환불 확인서(동의서)
            		if(true != ValidationCheckUtil.emptyCheck(muReserveId)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","진료내역 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(ptUserName)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환자명 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(returnAmount)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환불금액 정보가 없습니다.");
            		}

            		if(true != ValidationCheckUtil.emptyCheck(returnMethodPayment)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환불결제방법 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(returnReason)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환불사유 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(returnBank)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환불은행 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(returnAccount)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환불계좌 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(address2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","주소 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(userRrn2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","주민등록번호 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(userName2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","성명 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(relationship)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","환자와의관계 정보가 없습니다.");
            		}
            		
            		if(true != ValidationCheckUtil.emptyCheck(phoneNumber2)) {
            			check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc","연락처 정보가 없습니다.");
            		}
            	}
            }
            
            if(true != ValidationCheckUtil.emptyCheck(renewalCycle)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","갱신주기를 입력하세요.");
            }

            if(true != ValidationCheckUtil.emptyCheck(expirationDate)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","만료일자 정보가 없습니다.");
            }
            
            if(null!=file&&0==file.getSize()) {
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","서명 정보가 없습니다.");
			}

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);

                if(1==userListMap.size()){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("insertUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "등록 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
            	// file
				HashMap<String, Object> uploadFileMap = new HashMap<String, Object>();
				uploadFileMap.put("type", "UA");
				uploadFileMap.put("fileType", "I");
				uploadFileMap.put("fileName", file.getOriginalFilename());
				HashMap<String, Object> fileMap = fileService.uploadFile(uploadFileMap, file);
				String cdnUrl       = String.valueOf(fileMap.get("cdnUrl"));
				String filePath     = String.valueOf(fileMap.get("fileUrl"));
				String fileName     = String.valueOf(fileMap.get("fileName"));
				String chgFileNmae  = fileName;
				
				// 동의서 등록
                paramMap.put("tId", tId);
                paramMap.put("tDate", tDate);
                
                String muUserAgreementId = ("UA").concat(String.valueOf(System.currentTimeMillis()));
                paramMap.put("muUserAgreementId",muUserAgreementId);
                paramMap.put("status", "Y");
                paramMap.put("cdnUrl", cdnUrl);
				paramMap.put("filePath", filePath);
				paramMap.put("fileName", fileName);
				paramMap.put("originalFileName", chgFileNmae);
                webUserSqlMapDAO.insertUserAgreement(paramMap);

                map.put("msgCode", Constants.OK);
                map.put("msgDesc", "등록되었습니다.");
            }
        }
		catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl insertUserAgreement END");
        return map;
    }

    /**
     * 고객 동의서 리스트 조회.
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectUserAgreementList(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUserAgreementList START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("loginMemberId                :"+paramMap.get("loginMemberId"));
        log.debug("membershipYn                 :"+paramMap.get("membershipYn"));
        log.debug("userSort                     :"+paramMap.get("userSort"));
        log.debug("userStart                    :"+paramMap.get("userStart"));
        log.debug("nationality                  :"+paramMap.get("nationality"));
        log.debug("userSearchKeywordParam       :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userType                     :"+paramMap.get("userType"));
        log.debug("userLimit                    :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){
                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "조회 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                    listMap = webUserSqlMapDAO.selectUserAgreementList(paramMap);


                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUserAgreementList END");
        return map;
    }


    /**
     * 고객 동의서 리스트 조회 (List, Excel)
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public List<Map<String, Object>> selectUserAgreementListExcel(
            HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUserAgreementListExcel START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = null;

        log.debug("loginMemberId                :"+paramMap.get("loginMemberId"));
        log.debug("membershipYn                 :"+paramMap.get("membershipYn"));
        log.debug("userSort                     :"+paramMap.get("userSort"));
        log.debug("userStart                    :"+paramMap.get("userStart"));
        log.debug("nationality                  :"+paramMap.get("nationality"));
        log.debug("userSearchKeywordParam       :"+paramMap.get("userSearchKeywordParam"));
        log.debug("userType                     :"+paramMap.get("userType"));
        log.debug("userLimit                    :"+paramMap.get("userLimit"));

        try{
            boolean check  = true;

            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }

            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);

                if(1==authMenuRelationlistMap.size()){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("downloadUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "내려받기 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }

            if(true == check){
                listMap = webUserSqlMapDAO.selectUserAgreementListExcel(paramMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUserAgreementListExcel END");
        return listMap;
    }

    /**
     * 고객 동의서 상세 조회. (one)
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> selectUserAgreement(HashMap<String, Object> paramMap) throws Exception {
        log.debug("WebUserServiceImpl selectUserAgreement START");

        HashMap<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> listMap = new ArrayList<>();
        log.debug("loginMemberId                :"+paramMap.get("loginMemberId"));

        log.debug("muUserAgreementId            :"+paramMap.get("muUserAgreementId"));
        
        try{
            boolean check  = true;
            String muUserAgreementId    = String.valueOf(paramMap.get("muUserAgreementId"));
            
            if(true != ValidationCheckUtil.emptyCheck(muUserAgreementId)){
                check = false;
                map.put("msgCode", Constants.FAIL);
                map.put("msgDesc","동의서 정보가 없습니다.");
            }
            
            if(true == check){
                // 사용자 확인
                List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();

                if(1==userListMapSize){
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
                }
            }
            if(true == check){
                // 권한 조회
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
                int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

                if(1==authMenuRelationlistMapSize){

                    if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

                    }
                    else {
                        check = false;
                        map.put("msgCode", Constants.FAIL);
                        map.put("msgDesc", "조회 권한 정보가 없습니다.");
                    }
                }
                else {
                    check = false;
                    map.put("msgCode", Constants.FAIL);
                    map.put("msgDesc", "권한 정보가 없습니다.");
                }
            }
            if(true == check){
                listMap = webUserSqlMapDAO.selectUserAgreement(paramMap);
                
                map.put("msgCode", Constants.OK);
                map.put("success","true");
                map.put("rows",listMap);
            }

        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }

        log.debug("WebUserServiceImpl selectUserAgreement END");
        return map;
    }
}
