Ver código fonte

Merge branch 'stage_tsit' of https://style24@dev.azure.com/style24/style24/_git/style24.admin into stage_tsit

smlee@yes24.com 4 anos atrás
pai
commit
f744567f52

+ 55 - 0
src/main/java/com/style24/admin/biz/dao/TsaSettleDao.java

@@ -1,6 +1,7 @@
 package com.style24.admin.biz.dao;
 
 import java.util.Collection;
+import java.util.Map;
 
 import com.style24.core.support.annotation.ShopDs;
 import com.style24.persistence.domain.AflinkFee;
@@ -10,6 +11,8 @@ import com.style24.persistence.domain.GiftcardSettle;
 import com.style24.persistence.domain.GoodsSettle;
 import com.style24.persistence.domain.SettleConfirm;
 
+import com.gagaframework.web.parameter.GagaMap;
+
 /**
  * 정산 Dao
  *
@@ -140,4 +143,56 @@ public interface TsaSettleDao {
 	 */
 	void saveHansaeStyleMapping(Erp erp);
 
+	/**
+	 * 매출반영 실패건 ERP 정보로 Update
+	 * @param erp - 한세ERP 정보
+	 * @return 처리건수
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	int updateFailedSalesUploadListToErpInfo(Erp erp);
+
+	/**
+	 * 매출반영 실패한 브랜드 목록
+	 * @param erp - 한세ERP 정보
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	Collection<String> getFailedSalesUploadBrandList(Erp erp);
+
+	/**
+	 * 매출반영 실패한 목록
+	 * @param erp - 한세ERP 정보
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	Collection<GagaMap> getFailedSalesUploadList(Erp erp);
+
+	/**
+	 * 매출반영I/F번호 조회
+	 * @param erpGb - ERP구분(hsmk:한세MK, hsdr:한세드림)
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	String getSalesUploadInterfaceNo(String erpGb);
+
+	/**
+	 * 매출반영목록 I/F번호 Update
+	 * @param paramMap - ERP 정보
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	void updateSalesUploadListInterfaceNo(GagaMap paramMap);
+
+	/**
+	 * 매출반영결과 처리
+	 * @param paramMap - 매출결과 정보
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	void updateSalesUploadResult(Map<String, Object> paramMap);
+
 }

+ 92 - 0
src/main/java/com/style24/admin/biz/service/TsaSettleService.java

@@ -1,6 +1,9 @@
 package com.style24.admin.biz.service;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -232,4 +235,93 @@ public class TsaSettleService {
 		settleDao.saveHansaeStyleMapping(erp);
 	}
 
+	/**
+	 * 매출반영 실패건 ERP 정보로 Update
+	 * @param erp - 한세ERP 정보
+	 * @return 처리건수
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	@Transactional("shopTxnManager")
+	public int updateFailedSalesUploadListToErpInfo(Erp erp) {
+		return settleDao.updateFailedSalesUploadListToErpInfo(erp);
+	}
+
+	/**
+	 * 매출반영 실패한 브랜드 목록
+	 * @param erp - 한세ERP 정보
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	public Collection<String> getFailedSalesUploadBrandList(Erp erp) {
+		return settleDao.getFailedSalesUploadBrandList(erp);
+	}
+
+	/**
+	 * 매출반영 실패한 목록
+	 * @param erp - 한세ERP 정보
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	public Collection<GagaMap> getFailedSalesUploadList(Erp erp) {
+		return settleDao.getFailedSalesUploadList(erp);
+	}
+
+	/**
+	 * 매출반영I/F번호 조회
+	 * @param erpGb - ERP구분(hsmk:한세MK, hsdr:한세드림)
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	public String getSalesUploadInterfaceNo(String erpGb) {
+		return settleDao.getSalesUploadInterfaceNo(erpGb);
+	}
+
+	/**
+	 * 매출반영목록 I/F번호 Update
+	 * @param paramMap - ERP 정보
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	@Transactional("shopTxnManager")
+	public void updateSalesUploadListInterfaceNo(GagaMap paramMap) {
+		settleDao.updateSalesUploadListInterfaceNo(paramMap);
+	}
+
+	/**
+	 * 매출반영결과 처리
+	 * @param erpGb - ERP구분(hsmk:한세MK, hsdr:한세드림)
+	 * @param paramMap - 결과 정보
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	@SuppressWarnings("unchecked")
+	@Transactional("shopTxnManager")
+	public void updateSalesUploadResult(String erpGb, GagaMap salesMap) {
+		if (salesMap.get("succList") != null) {
+			// 성공건 처리
+			List<Map<String, Object>> succList = (ArrayList<Map<String, Object>>)salesMap.get("succList");
+			if (succList != null && !succList.isEmpty()) {
+				for (Map<String, Object> dataMap : succList) {
+					dataMap.put("ERP_GB", erpGb);
+					settleDao.updateSalesUploadResult(dataMap);
+				}
+			}
+		}
+
+		if (salesMap.get("failList") != null) {
+			// 실패건 처리
+			List<Map<String, Object>> failList = (ArrayList<Map<String, Object>>)salesMap.get("failList");
+			if (failList != null && !failList.isEmpty()) {
+				for (Map<String, Object> dataMap : failList) {
+					dataMap.put("ERP_GB", erpGb);
+					settleDao.updateSalesUploadResult(dataMap);
+				}
+			}
+		}
+	}
+
 }

+ 68 - 0
src/main/java/com/style24/admin/biz/web/TsaSettleController.java

@@ -24,6 +24,7 @@ import com.style24.admin.biz.service.TsaRendererService;
 import com.style24.admin.biz.service.TsaSettleService;
 import com.style24.admin.support.controller.TsaBaseController;
 import com.style24.admin.support.security.session.TsaSession;
+import com.style24.core.biz.thirdparty.HansaeErp;
 import com.style24.core.support.message.TscMessageByLocale;
 import com.style24.persistence.domain.AflinkFee;
 import com.style24.persistence.domain.DelvFeeSettle;
@@ -66,6 +67,9 @@ public class TsaSettleController extends TsaBaseController {
 	@Autowired
 	private Environment env;
 
+	@Autowired
+	private HansaeErp hansaeErp;
+
 	/**
 	 * 상품정산 화면
 	 * @return
@@ -499,4 +503,68 @@ public class TsaSettleController extends TsaBaseController {
 		return super.ok(message.getMessage("SUCC_0001"));
 	}
 
+	/**
+	 * 한세ERP 매출실패건 업로드 처리
+	 * @param erp - 한세ERP 정보
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 11. 1
+	 */
+	@PostMapping("/hansae/failedSales/upload")
+	@ResponseBody
+	public GagaResponse uploadHansaeFailedSales(@RequestBody Erp erp) {
+		log.info("{}", erp);
+
+		// 매출반영 실패한 브랜드 목록 (브랜드 단위로 처리를 위해)
+		Collection<String> brandList = settleService.getFailedSalesUploadBrandList(erp);
+		if (brandList == null || brandList.isEmpty()) {
+			throw new IllegalStateException((HansaeErp.ErpGb.HANSAE_MK.value().equals(erp.getErpGb()) ? "한세MK" : "한세드림")
+				+ "의 판매기간(" + erp.getStartDt() + "~" + erp.getEndDt() + ") 내에 매출반영 실패건이 없습니다.");
+		}
+
+		// 매출반영 실패건 ERP 옵션 정보로 Update
+		int updCnt = settleService.updateFailedSalesUploadListToErpInfo(erp);
+//		if (updCnt == 0) {
+//			throw new IllegalStateException("매출반영 실패건 중 ERP 옵션 정보가 변경된 건이 없습니다.");
+//		}
+
+		for (String brandCd : brandList) {
+			erp.setBrandCd(brandCd);
+
+			// 매출반영 실패한 목록 (브랜드 단위로 조회)
+			Collection<GagaMap> uploadList = settleService.getFailedSalesUploadList(erp);
+
+			if (uploadList == null || uploadList.isEmpty()) {
+				log.error("{}-{} 브랜드의 매출반영 실패한 데이터가 없습니다.", erp.getErpGb(), brandCd);
+				continue;
+			}
+
+			// 매출반영I/F번호 조회
+			String noIf = settleService.getSalesUploadInterfaceNo(erp.getErpGb());
+			log.info("매출반영I/F번호: {}", noIf);
+
+			for (GagaMap dataMap : uploadList) {
+				// 매출반영목록 I/F번호 Update
+				dataMap.setString("ERP_GB", erp.getErpGb());
+				dataMap.setString("NO_IF", noIf);
+				settleService.updateSalesUploadListInterfaceNo(dataMap);
+			}
+
+//			// 매출업로드
+//			GagaMap salesMap = hansaeErp.uploadErpSales(erp.getErpGb(), uploadList);
+//
+//			if (salesMap == null || salesMap.isEmpty()) {
+//				log.error("{}-{} 브랜드의 매출반영결과 데이터가 없습니다. 한세 ERP 시스템담당자에게 문의해 주세요.", erp.getErpGb(), brandCd);
+//				continue;
+//			}
+//
+//			// 매출반영결과 처리
+//			settleService.updateSalesUploadResult(erp.getErpGb(), salesMap);
+
+			log.info("{}-{} 브랜드의 매출반영 업로드 성공", erp.getErpGb(), brandCd);
+		}
+
+		return super.ok(message.getMessage("SUCC_0001"));
+	}
+
 }

+ 4 - 4
src/main/java/com/style24/admin/support/controller/TsaErrorController.java

@@ -6,12 +6,12 @@ import javax.servlet.http.HttpServletRequest;
 import org.springframework.boot.web.servlet.error.ErrorController;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
-import org.springframework.web.bind.annotation.GetMapping;
-
-import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
 
 import com.gagaframework.web.rest.server.GagaResponseStatus;
 
+import lombok.extern.slf4j.Slf4j;
+
 /**
  * Error Controller
  * 		Disabling the Whitelabel Error Page
@@ -38,7 +38,7 @@ public class TsaErrorController implements ErrorController {
 	/**
 	 * Error
 	 */
-	@GetMapping("/error")
+	@RequestMapping("/error")
 	public String error(HttpServletRequest request) throws HttpRequestMethodNotSupportedException {
 		Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
 

+ 111 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsaSettle.xml

@@ -833,6 +833,7 @@
 		AND    CD_SALEBILL IS NULL
 		AND    DS_ERROR IS NOT NULL
 		</if>
+		ORDER  BY ERP_GB, DT_SALE, BRAND_CD, CD_STYLE, CD_COLOR, CD_SIZE
 	</select>
 	
 	<!-- 한세스타일매핑 정보 -->
@@ -888,5 +889,115 @@
 		     , UPD_NO = #{updNo}
 		     , UPD_DT = NOW()
 	</update>
+	
+	<!-- 매출반영 실패건 ERP 정보로 Update -->
+	<update id="updateFailedSalesUploadListToErpInfo" parameterType="Erp">
+		/* TsaSettle.updateFailedSalesUploadListToErpInfo */
+		UPDATE TB_HANSAE_SALES HS
+		SET    CD_STYLE = IFNULL((SELECT ERP_CD_STYLE
+		                          FROM   TB_HANSAE_STYLE
+		                          WHERE  ERP_GB = HS.ERP_GB
+		                          AND    CD_STYLE = HS.CD_STYLE
+		                          AND    CD_COLOR = HS.CD_COLOR
+		                          AND    CD_SIZE = HS.CD_SIZE
+		                         ),CD_STYLE)
+		     , CD_COLOR = IFNULL((SELECT ERP_CD_COLOR
+		                          FROM   TB_HANSAE_STYLE
+		                          WHERE  ERP_GB = HS.ERP_GB
+		                          AND    CD_STYLE = HS.CD_STYLE
+		                          AND    CD_COLOR = HS.CD_COLOR
+		                          AND    CD_SIZE = HS.CD_SIZE
+		                         ),CD_COLOR)
+		     , CD_SIZE = IFNULL((SELECT ERP_CD_SIZE
+		                         FROM   TB_HANSAE_STYLE
+		                         WHERE  ERP_GB = HS.ERP_GB
+		                         AND    CD_STYLE = HS.CD_STYLE
+		                         AND    CD_COLOR = HS.CD_COLOR
+		                         AND    CD_SIZE = HS.CD_SIZE
+		                        ),CD_SIZE)
+		WHERE  ERP_GB = #{erpGb}
+		AND    DT_SALE BETWEEN REPLACE(#{startDt},'-','') AND REPLACE(#{endDt},'-','')
+		AND    CD_SALEBILL IS NULL /*매출반영후실패한넘*/
+		AND    DS_ERROR IS NOT NULL /*매출반영후실패한넘*/
+		AND    EXISTS (SELECT 1
+		               FROM   TB_HANSAE_STYLE
+		               WHERE  ERP_GB = HS.ERP_GB
+		               AND    CD_STYLE = HS.CD_STYLE
+		               AND    CD_COLOR = HS.CD_COLOR
+		               AND    CD_SIZE = HS.CD_SIZE
+		              )
+	</update>
+	
+	<!-- 매출반영 실패한 브랜드 목록 -->
+	<select id="getFailedSalesUploadBrandList" parameterType="Erp" resultType="String">
+		/* TsaSettle.getFailedSalesUploadBrandList */
+		SELECT DISTINCT BRAND_CD
+		FROM   TB_HANSAE_SALES
+		WHERE  ERP_GB = #{erpGb}
+		AND    DT_SALE BETWEEN REPLACE(#{startDt},'-','') AND REPLACE(#{endDt},'-','')
+		AND    CD_SALEBILL IS NULL /*매출반영후실패한넘*/
+		AND    DS_ERROR IS NOT NULL /*매출반영후실패한넘*/
+		ORDER  BY BRAND_CD
+	</select>
+	
+	<!-- 매출반영 실패한 목록 -->
+	<select id="getFailedSalesUploadList" parameterType="Erp" resultType="paramMap">
+		/* TsaSettle.getFailedSalesUploadList */
+		SELECT DT_SALE
+		     , TP_SALE
+		     , CD_STYLE
+		     , CD_COLOR
+		     , CD_SIZE
+		     , QT_SALE
+		     , AM_ACSALE
+		     , DS_REMARK
+		FROM   TB_HANSAE_SALES
+		WHERE  ERP_GB = #{erpGb}
+		AND    DT_SALE BETWEEN REPLACE(#{startDt},'-','') AND REPLACE(#{endDt},'-','')
+		AND    BRAND_CD = #{brandCd}
+		AND    CD_SALEBILL IS NULL /*매출반영후실패한넘*/
+		AND    DS_ERROR IS NOT NULL /*매출반영후실패한넘*/
+		ORDER  BY DT_SALE, TP_SALE, CD_STYLE, CD_COLOR, CD_SIZE
+	</select>
+	
+	<!-- 매출반영I/F번호 조회 -->
+	<select id="getSalesUploadInterfaceNo" parameterType="String" resultType="String">
+		/* TsaSettle.getSalesUploadInterfaceNo */
+		SELECT CONCAT(DATE_FORMAT(NOW(),'%Y%m%d%H%i%S')
+		             ,LPAD(IFNULL((SELECT CAST(MAX(SUBSTRING(NO_IF,15)) AS UNSIGNED)
+		                           FROM   TB_HANSAE_SALES
+		                           WHERE  ERP_GB = #{erpGb}
+		                           AND    NO_IF LIKE CONCAT(DATE_FORMAT(NOW(),'%Y%m%d'),'%')
+		                          ),0) + 1,4,'0')) AS NO_IF
+		FROM   DUAL
+	</select>
+	
+	<!-- 매출반영목록 I/F번호 Update -->
+	<update id="updateSalesUploadListInterfaceNo" parameterType="paramMap">
+		/* TsaSettle.updateSalesUploadListInterfaceNo */
+		UPDATE TB_HANSAE_SALES
+		SET    NO_IF = #{NO_IF}
+		WHERE  ERP_GB = #{ERP_GB}
+		AND    DT_SALE = #{DT_SALE}
+		AND    TP_SALE = #{TP_SALE}
+		AND    CD_STYLE = #{CD_STYLE}
+		AND    CD_COLOR = #{CD_COLOR}
+		AND    CD_SIZE = #{CD_SIZE}
+	</update>
+	
+	<!-- 매출반영결과 처리 -->
+	<update id="updateSalesUploadResult" parameterType="paramMap">
+		/* TsaSettle.updateSalesUploadResult */
+		UPDATE TB_HANSAE_SALES
+		SET    CD_SALEBILL = #{CD_SALEBILL}
+		     , DS_ERROR = #{DS_ERROR}
+		     , NO_IF = CASE WHEN LENGTH(#{DS_ERROR}) > 0 THEN NULL ELSE #{NO_IF} END
+		     , UPD_DT = NOW()
+		WHERE  ERP_GB = #{ERP_GB}
+		AND    NO_IF = #{NO_IF}
+		AND    CD_STYLE = #{CD_STYLE}
+		AND    CD_COLOR = #{CD_COLOR}
+		AND    CD_SIZE = #{CD_SIZE}
+	</update>
 
 </mapper>

+ 90 - 9
src/main/webapp/WEB-INF/views/settle/HansaeSalesUploadForm.html

@@ -45,6 +45,20 @@
 						</td>
 						<th>판매기간<i class="required" title="필수" aria-hidden="true"></i></th>
 						<td id="terms">
+							<span class="nowrap">
+								<input name="startDt" id="startDt" type="text" class="w80 schDate" maxlength="8" required="required" data-valid-name="판매시작일"/>
+								~
+								<input name="endDt" id="endDt" type="text" class="w80 schDate" maxlength="8" required="required" data-valid-name="판매종료일"/>
+							</span>
+							<button type="button" class="btn btn-default btn-sm btnToday" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', 't');">오늘</button>
+							<button type="button" class="btn btn-default btn-sm btnYesterday" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', 'y');">어제</button>
+							<button type="button" class="btn btn-default btn-sm" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', '7d');">최근한주</button>
+							<button type="button" class="btn btn-default btn-sm" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', 'tw');">이번주</button>
+							<button type="button" class="btn btn-default btn-sm" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', 'pw');">지난주</button>
+							<button type="button" class="btn btn-default btn-sm" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', '1m');">최근한달</button>
+							<button type="button" class="btn btn-default btn-sm" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', 'tm');">이번달</button>
+							<button type="button" class="btn btn-default btn-sm" onclick="gagajf.setDate('#terms', 'startDt', 'endDt', 'pm');">지난달</button>
+							<span class="infoTxt cRed"><i class="fa fa-info-circle" aria-hidden="true"></i>(한달 한도)</span>
 						</td>
 					</tr>
 					<tr>
@@ -95,10 +109,10 @@
 <script th:inline="javascript">
 /*<![CDATA[*/
 	let columnDefs = [
-		{
-			width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false,
-			checkboxSelection: function (params) { return !gagajf.isNull(params.data.dsError) ? true : false; }
-		},
+// 		{
+// 			width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false,
+// 			checkboxSelection: function (params) { return !gagajf.isNull(params.data.dsError) ? true : false; }
+// 		},
 		{
 			headerName: "ERP구분", field: "erpGb", width: 80, cellClass: 'text-center',
 			cellRenderer: function(params) { return params.value == 'hsmk' ? '한세MK' : '한세드림'; }
@@ -109,8 +123,8 @@
 			cellRenderer: function(params) { return params.value == '1' ? '판매' : '환불'; }
 		},
 		{ headerName: "스타일코드", field: "cdStyle", width: 120, cellClass: 'text-center' },
-		{ headerName: "색상코드", field: "cdColor", width: 100, cellClass: 'text-center' },
-		{ headerName: "사이즈코드", field: "cdSize", width: 100, cellClass: 'text-center' },
+		{ headerName: "색상코드", field: "cdColor", width: 80, cellClass: 'text-center' },
+		{ headerName: "사이즈코드", field: "cdSize", width: 90, cellClass: 'text-center' },
 		{
 			headerName: "판매수량", field: "qtSale", width: 100, cellClass: 'text-center',
 			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
@@ -121,7 +135,7 @@
 			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
 			cellStyle : function(params) { if (Number(params.value) < 0) return { 'color' : 'red' } }
 		},
-		{ headerName: "I/F번호", field: "ifNo", width: 200, cellClass: 'text-center' },
+		{ headerName: "I/F번호", field: "noIf", width: 150, cellClass: 'text-center' },
 		{ headerName: "판매전표번호", field: "cdSalebill", width: 150, cellClass: 'text-center' },
 		{ 
 			headerName: "실패메시지", field: "dsError", width: 300,
@@ -162,6 +176,21 @@
 		if (!gagajf.validation('#searchForm'))
 			return false;
 		
+		let fromDate = $('#searchForm input[name=startDt]').val().toDate('YYYY-MM-DD');
+		let toDate = $('#searchForm input[name=endDt]').val().toDate('YYYY-MM-DD');
+		
+		if (fromDate > toDate) {
+			mcxDialog.alert("시작일자는 종료일자 보다 클 수 없습니다.");
+			$('#searchForm input[name=endDt]').focus();
+			return false;
+		}
+		
+		var iDays = Math.ceil((toDate - fromDate) / (60 * 60 * 24 * 1000));
+		if (iDays >= 31) {
+			mcxDialog.alert("최대 31일까지 조회할 수 있습니다.");
+			return;
+		}
+		
 		gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm');
 	});
 	
@@ -172,7 +201,60 @@
 	
 	// 실패건업로드
 	$('#btnResendFailSales').on('click', function() {
+		let allData = gagaAgGrid.getAllRowData(gridOptions);
 		
+		let isFailData = false;
+		allData.forEach(function(item, idx) {
+			if (!gagajf.isNull(item.dsError)) {
+				isFailData = true;
+				return false;
+			}
+		});
+		
+		if (!isFailData) {
+			mcxDialog.alert("매출반영할 실패건이 없습니다.");
+			return false;
+		}
+		
+		if (gagajf.isNull($('#startDt').val())) {
+			mcxDialog.alertC('판매시작일자를 입력해 주세요.', {
+				sureBtnText: "확인",
+				sureBtnClick: function() {
+					$('#startDt').focus();
+				}
+			});
+			return;
+		}
+		
+		if (gagajf.isNull($('#endDt').val())) {
+			mcxDialog.alertC('판매종료일자를 입력해 주세요.', {
+				sureBtnText: "확인",
+				sureBtnClick: function() {
+					$('#endDt').focus();
+				}
+			});
+			return;
+		}
+		
+		let msg =  ($('#searchForm select[name=erpGb]').val() == 'hsmk' ? '한세MK' : '한세드림') + '의'
+				+ ' 판매기간 ' + $('#startDt').val().toDate('YYYY-MM-DD').format('YYYY-MM-DD') + '~' + $('#endDt').val().toDate('YYYY-MM-DD').format('YYYY-MM-DD') + ' 동안의 매출반영 실패건을 업로드합니다.<br/>'
+				+ '매출반영은 몇 분이 소요될 수 있습니다. 계속 진행하시겠습니까?';
+		
+		mcxDialog.confirm(msg, {
+			cancelBtnText: "취소",
+			sureBtnText: "확인",
+			sureBtnClick: function() {
+				let jsonData = JSON.stringify({
+					erpGb : $('#searchForm select[name=erpGb]').val(),
+					startDt : $('#startDt').val(),
+					endDt : $('#endDt').val()
+				});
+				
+				gagajf.ajaxJsonSubmit('/settle/hansae/failedSales/upload', jsonData, function() {
+					$('#btnSearch').trigger('click');
+				});
+			}
+		});
 	});
 	
 	// 엑셀다운로드
@@ -186,8 +268,7 @@
 	});
 	
 	$(document).ready(function() {
-		cfnCreateCalendar('#terms', 'startDt', 'endDt', true, '판매');
-		$('.btnToday').trigger('click');
+		gagajf.setDate('#terms', 'startDt', 'endDt', 't');
 		
 		// Create a agGrid
 		gagaAgGrid.createGrid('gridList', gridOptions);