Browse Source

상품권 대량 업로드 작업 중

jsshin 5 năm trước cách đây
mục cha
commit
8ef61503ad

+ 0 - 3
pom.xml

@@ -146,9 +146,6 @@
 									</includes>
 								</resource>
 							</resources>
-							<overwrite>
-								true
-							</overwrite>
 							<outputDirectory>
 								${basedir}/target/classes
 							</outputDirectory>

+ 17 - 0
src/main/java/com/style24/admin/biz/service/TsaCustomerService.java

@@ -453,4 +453,21 @@ public class TsaCustomerService {
 		customer.setUpdNo(userNo);
 		return coreCustomerService.saveDormantCustomerRelease(customer);
 	}
+
+	/**
+	 * 회원 정보 조회
+	 * @param custId - 고객 아이디
+	 * @return Customer
+	 * @author jsshin
+	 * @since 2021. 05. 13
+	 */
+	public Customer getCustomerInfoByCustId(String custId) {
+		Customer customer = new Customer();
+		customer.setSiteCd(TscConstants.Site.STYLE24.value());
+		customer.setCustId(custId);
+		customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
+		return coreCustomerService.getCustomerInfo(customer);
+	}
+
+
 }

+ 76 - 49
src/main/java/com/style24/admin/biz/service/TsaGiftCardService.java

@@ -1,10 +1,13 @@
 package com.style24.admin.biz.service;
 
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.gagaframework.web.parameter.GagaMap;
 import com.style24.admin.biz.dao.TsaGiftCardDao;
 import com.style24.admin.support.security.session.TsaSession;
 import com.style24.core.biz.thirdparty.Yes24Giftcard;
 import com.style24.core.support.env.TscConstants;
+import com.style24.persistence.domain.Customer;
 import com.style24.persistence.domain.GiftCard;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,9 +29,15 @@ public class TsaGiftCardService {
 	@Autowired
 	private TsaGiftCardDao giftCardDao;
 
+	@Autowired
+	private TsaCustomerService customerService;
+
 	@Autowired
 	private Yes24Giftcard yes24Giftcard;
 
+	@Autowired
+	private ObjectMapper objectMapper;
+
 
 	/**
 	 * 상품권 대량 등록수
@@ -55,66 +64,84 @@ public class TsaGiftCardService {
 	/**
 	 * 상품권 저장
 	 *
-	 * @param giftCard - 상품권, 고객 정보
+	 * @param gagaMap - 상품권, 고객 정보
 	 * @author jsshin
 	 * @throws Exception
 	 * @since 2021. 5. 12
 	 */
 	@Transactional("shopTxnManager")
-	public void saveGiftcardUseConfirm(GiftCard giftCard) throws Exception {
-		// 고객번호 설정
+	public void saveGiftcardUseConfirm(GagaMap gagaMap) throws Exception {
 		Integer userNo = TsaSession.getInfo().getUserNo();
 		String ip = TsaSession.getIpAddress();
-		giftCard.setRegNo(userNo);
-		giftCard.setUpdNo(userNo);
-		giftCard.setIpAddr(ip);  // 아이피주소
-
-		Integer custNo = giftCard.getCustNo();
-		String pubNo = giftCard.getGfcdNo().trim();
-		String result = yes24Giftcard.soapDataTransfer(pubNo, ip, custNo);
-
 		String resultMsg;
-		if ("01".equals(result)) {
-			giftCard.setResultVal(result);  // 승인 결과 insert
-			resultMsg = "존재하지 않는 상품권";
-		} else if ("02".equals(result)) {
-			giftCard.setResultVal(result);
-			resultMsg = "이미 등록된 상품권";
-		} else if ("03".equals(result)) {
-			giftCard.setResultVal(result);
-			resultMsg = "삭제된 상품권";
-		} else if ("04".equals(result)) {
-			giftCard.setResultVal(result);
-			resultMsg = "기간이 만료된 상품권";
-		} else if ("99".equals(result)) {
-			giftCard.setResultVal(result);
-			resultMsg = "시스템 오류";
+		GiftCard giftCard = objectMapper.convertValue(gagaMap, GiftCard.class);
+
+		// 1. 엑셀 내용 데이터 생성
+		giftCardDao.createGfcdBulkReg(giftCard);
+
+		// 2. 활동회원 확인
+		Customer customer = customerService.getCustomerInfoByCustId(giftCard.getCustId().trim());
+
+		// 3. 유효한 회원이면
+		if (customer != null) {
+			Integer custNo = customer.getCustNo();
+			String pubNo = giftCard.getGfcdNo().trim();
+			// 상품권 API 호출
+			String result = yes24Giftcard.soapDataTransfer(pubNo, ip, custNo);
+
+			giftCard.setCustNo(custNo);
+			giftCard.setRegNo(userNo);
+			giftCard.setUpdNo(userNo);
+			giftCard.setIpAddr(ip);
+
+			if ("01".equals(result)) {
+				giftCard.setResultVal(result);
+				resultMsg = "존재하지 않는 상품권";
+			} else if ("02".equals(result)) {
+				giftCard.setResultVal(result);
+				resultMsg = "이미 등록된 상품권";
+			} else if ("03".equals(result)) {
+				giftCard.setResultVal(result);
+				resultMsg = "삭제된 상품권";
+			} else if ("04".equals(result)) {
+				giftCard.setResultVal(result);
+				resultMsg = "기간이 만료된 상품권";
+			} else if ("99".equals(result)) {
+				giftCard.setResultVal(result);
+				resultMsg = "시스템 오류";
+			} else {
+				giftCard.setResultVal("00");
+				resultMsg = "상품권등록 성공";
+			}
+			// 상품권 API 이력 저장
+			giftCardDao.createGiftcardApi(giftCard);
+
+			// 성공일 경우
+			if ("00".equals(giftCard.getResultVal())) {
+				String[] param = result.split("[|]");
+				// [2021-04-01, 오전, 12:00:00]
+				String[] param2 = param[2].split(" ");
+				String[] param3 = param[3].split(" ");
+
+				// 고객 상품권 등록
+				giftCard.setGfcdNm("YES24상품권");
+				giftCard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
+				giftCard.setRmGfcdAmt(Integer.parseInt(param[1])); // 승인금액
+				giftCard.setUseStDate(param2[0]);
+				giftCard.setUseExpDate(param3[0]);
+				giftCardDao.createGiftcardUseConfirm(giftCard);
+
+				// 고객 상품권 이력 등록
+				giftCard.setOccurGb(TscConstants.GiftCardOccurGb.REGISTER_GIFTCARD.value());
+				giftCard.setOccurDtlDesc("상품권등록");
+				giftCard.setGfcdAmt(Integer.parseInt(param[1]));
+				giftCardDao.createCustGiftcardHistory(giftCard);
+			}
 		} else {
-			giftCard.setResultVal("00");
-			resultMsg = "상품권등록 성공";
-		}
-		giftCard.setResultMsg(resultMsg);
-		giftCardDao.createGiftcardApi(giftCard);
-
-		// 성공일 경우
-		if ("00".equals(giftCard.getResultVal())) {
-			String[] param = result.split("[|]");
-			// [2021-04-01, 오전, 12:00:00]
-			String[] param2 = param[2].split(" ");
-			String[] param3 = param[3].split(" ");
-
-			giftCard.setGfcdNm("YES24상품권");
-			giftCard.setChgGfcdAmt(Integer.parseInt(param[1])); // 승인금액
-			giftCard.setRmGfcdAmt(Integer.parseInt(param[1])); // 승인금액
-			giftCard.setUseStDate(param2[0]);
-			giftCard.setUseExpDate(param3[0]);
-			giftCardDao.createGiftcardUseConfirm(giftCard);
-			giftCard.setOccurGb(TscConstants.GiftCardOccurGb.REGISTER_GIFTCARD.value());
-			giftCard.setOccurDtlDesc("상품권등록");
-			giftCard.setGfcdAmt(Integer.parseInt(param[1]));
-			giftCardDao.createCustGiftcardHistory(giftCard);
+			resultMsg = "존재하지 않는 회원";
 		}
 
+		giftCard.setResultMsg(resultMsg);
 		giftCardDao.updateGfcdBulkReg(giftCard);
 
 	}

+ 22 - 1
src/main/java/com/style24/admin/biz/web/TsaMarketingController.java

@@ -8,12 +8,14 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.style24.admin.biz.dao.TsaGiftCardDao;
 import com.style24.admin.biz.service.TsaGiftCardService;
 import com.style24.core.support.session.TscSession;
 import com.style24.core.support.util.CryptoUtils;
 import com.style24.persistence.domain.CustomerSearch;
 import com.style24.persistence.domain.GiftCard;
+import com.style24.persistence.domain.GoodsMass;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -136,7 +138,6 @@ public class TsaMarketingController extends TsaBaseController {
 	@Autowired
 	private TsaGiftCardService giftCardService;
 
-
 	@Value("${upload.default.target.path}")
 	private String uploadTargetPath;
 
@@ -2521,4 +2522,24 @@ public class TsaMarketingController extends TsaBaseController {
 		return result;
 	}
 
+	/**
+	 * 상품권대량 업로드 엑셀 저장
+	 *
+	 * @param giftCard - 검색조건
+	 * @return
+	 * @author jsshin
+	 * @since 2021. 01. 12
+	 */
+	@PostMapping("/upload/giftcard/bulk/reg")
+	@ResponseBody
+	public GagaResponse uploadGiftCardBulkReg(@RequestBody GiftCard giftCard) throws Exception {
+		String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
+		String[] giftGardNames = {"custId", "gfcdNo"};
+		Collection<GagaMap> excelGiftCardList = GagaExcelUtil.getList(GagaFileUtil.getConcatenationPath(targetPath, giftCard.getExcelFileNm()), 0, giftGardNames, 0);
+		for (GagaMap gagaMap : excelGiftCardList) {
+			giftCardService.saveGiftcardUseConfirm(gagaMap);
+		}
+		return super.ok(message.getMessage("SUCC_0001"));
+	}
+
 }

+ 29 - 13
src/main/webapp/WEB-INF/views/marketing/GiftCardListForm.html

@@ -31,23 +31,21 @@
 		<div class="panelStyle">
 				<table class="frmStyle" aria-describedby="검색조건">
 					<colgroup>
-						<col style="width:20%;"/>
-						<col style="width:80%;"/>
+						<col style="width:10%;"/>
+						<col style="width:40%;"/>
+						<col style="width:10%;"/>
 						<col/>
 					</colgroup>
 					<tbody>
 					<tr>
-						<th class="dashR">사이트</th>
+						<th class="dashR">아이디</th>
 						<td class="dashR">
-							<select name="siteCd">
-								<option value="">전체</option>
-								<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
-							</select>
+							<input type="text" class="w200" name="custId" id="custId"/>
 						</td>
 					</tr>
 					<tr>
-						<th class="dashR">조회일자</th>
-						<td class="dashR" >
+						<th class="dashR">등록일자</th>
+						<td class="dashR">
 							<span id="terms"></span>
 						</td>
 					</tr>
@@ -66,6 +64,10 @@
 		<!-- 리스트 영역 -->
 		<div class="panelStyle">
 			<ul class="panelBar">
+				<li>
+					<button type="button" class="btn btn-default btn-lg" onclick="cfnDownloadSampleFile('SF021');">상품권대량업로드 양식 다운로드</button>
+					<button type="button" class="btn btn-primary btn-lg" id="btnGiftCardReg">상품권대량업로드</button>
+				</li>
 				<li class="right">
 					검색결과 : <strong><span id="gridRowTotalCount">0</span> 건</strong>&nbsp;
 					쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
@@ -95,10 +97,6 @@
 
 	// specify the columns
 	const columnDefs = [
-		{
-			headerName: "사이트", field:'siteCd', width:100, cellClass: 'text-center',
-			valueGetter: function (params) { return gagaAgGrid.lookupValue(siteList, params.data.siteCd); }
-		},
 		{
 			headerName: "회원ID", field:'maskingCustId', width:120, cellClass: 'text-left',
 			valueGetter: function (params) {
@@ -144,6 +142,24 @@
 		gagaPaging.createPagination(result.pageing.pageable);
 	};
 
+	// 상품대량수정 클릭시
+	$('#btnGiftCardReg').on('click', function() {
+		cfnExcelUploadPopup('giftCardReg', 'fnSaveGiftCardExcel');
+	});
+
+	var fnSaveGiftCardExcel = function(result){
+		var data = {
+			         procJob : result.procJob
+					,excelFileNm : result.excelFileNm
+					};
+		var jsonData = JSON.stringify(data);
+		gagajf.ajaxJsonSubmit('/marketing/upload/giftcard/bulk/reg', jsonData, fnGiftCardBulkExcelUpload);
+	}
+
+	var fnGiftCardBulkExcelUpload = function(){
+		fnSearch();
+	}
+
 	$(document).ready(function() {
 		// 공통 달력 생성
 		cfnCreateCalendar('#terms', 'stDate', 'edDate', true);