| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714 |
- package com.style24.admin.biz.service;
- import java.io.IOException;
- import java.text.SimpleDateFormat;
- import java.util.Collection;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.core.env.Environment;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.StringUtils;
- import com.fasterxml.jackson.core.type.TypeReference;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.style24.admin.biz.dao.TsaGoodsDao;
- import com.style24.admin.support.env.TsaConstants;
- import com.style24.admin.support.security.session.TsaSession;
- import com.style24.core.biz.thirdparty.NaverLowestPriceApi;
- import com.style24.core.biz.thirdparty.SafetyKoreaApi;
- import com.style24.core.support.message.TscMessageByLocale;
- import com.style24.persistence.domain.AdKeyword;
- import com.style24.persistence.domain.AdKeywordGoods;
- import com.style24.persistence.domain.Brand;
- import com.style24.persistence.domain.Color;
- import com.style24.persistence.domain.FreeGoods;
- import com.style24.persistence.domain.Goods;
- import com.style24.persistence.domain.GoodsCompose;
- import com.style24.persistence.domain.GoodsDesc;
- import com.style24.persistence.domain.GoodsEpSkip;
- import com.style24.persistence.domain.GoodsHst;
- import com.style24.persistence.domain.GoodsImg;
- import com.style24.persistence.domain.GoodsNaverLowestPrice;
- import com.style24.persistence.domain.GoodsNotiInfo;
- import com.style24.persistence.domain.GoodsPriceRes;
- import com.style24.persistence.domain.GoodsResSell;
- import com.style24.persistence.domain.GoodsSafeNo;
- import com.style24.persistence.domain.GoodsSearch;
- import com.style24.persistence.domain.GoodsTnmRes;
- import com.style24.persistence.domain.GoodsVideo;
- import com.style24.persistence.domain.Itemkind;
- import com.style24.persistence.domain.NaverLowestPrice;
- import com.style24.persistence.domain.NotiInfo;
- import com.style24.persistence.domain.Notice;
- import com.style24.persistence.domain.NoticeGoods;
- import com.style24.persistence.domain.Option;
- import com.style24.persistence.domain.ReinboundInform;
- import com.style24.persistence.domain.SearchData;
- import com.style24.persistence.domain.Video;
- import com.style24.persistence.domain.WmsColorMapping;
- import com.style24.persistence.domain.WmsGoods;
- import com.style24.persistence.domain.WmsSeasonMapping;
- import com.style24.persistence.domain.WmsStyleYearMapping;
- import io.netty.util.internal.StringUtil;
- import lombok.extern.slf4j.Slf4j;
- import com.gagaframework.excel.GagaExcelUtil;
- import com.gagaframework.excel.env.GagaExcelConstants;
- import com.gagaframework.web.parameter.GagaMap;
- import com.gagaframework.web.util.GagaDateUtil;
- import com.gagaframework.web.util.GagaFileUtil;
- import com.gagaframework.web.util.GagaStringUtil;
- /**
- *상품관리 Service
- *
- * @author eskim
- * @since 2020. 10. 16
- */
- @Service
- @Slf4j
- public class TsaGoodsService {
- @Autowired
- private TscMessageByLocale message;
- @Autowired
- private Environment env;
- @Autowired
- private TsaGoodsDao goodsDao;
- @Autowired
- private TsaBusinessService businessService;
- @Autowired
- private TsaCommonService commonService;
- @Autowired
- private TsaRendererService rendererService;
- @Autowired
- private TsaNoticeService noticeService;
- @Autowired
- private SafetyKoreaApi safetyKoreaApi;
- @Autowired
- private NaverLowestPriceApi naverLowestPriceApi;
- @Autowired
- private ObjectMapper mapper;
- private static final String NUMBER_PATTERN = "^[0-9]+$";
- private static final String SELF_GOOODS_AFTER = "STY";
- /**
- * 상품 할인율 계산
- *
- * @param value
- * @param len
- * @param pad
- * @return
- */
- private long getDcRate(int listPrice, int currPrice) {
- double rate = (double)(currPrice) / (double)(listPrice);
- return 100 - (long)((Math.round(rate * 100) / 100.0) * 100);
- }
- /**
- * 품목 목록
- * @param itemkind
- * @return
- * @author eskim
- * @since 2020. 10. 16
- */
- public Collection<Itemkind> getItemkindList(Itemkind itemkind) {
- return goodsDao.getItemkindList(itemkind);
- }
- /**
- * 품목 저장
- *
- * @param itemkindList - 품목 정보 목록
- * @author eskim
- * @since 2020. 10. 16
- */
- @Transactional("shopTxnManager")
- public void saveItemkindInfo(Collection<Itemkind> itemkindList) {
- for (Itemkind itemkind : itemkindList) {
- itemkind.setRegNo(TsaSession.getInfo().getUserNo());
- itemkind.setUpdNo(TsaSession.getInfo().getUserNo());
- itemkind.setItemkindNm(GagaStringUtil.replace(GagaStringUtil.replace(itemkind.getItemkindNm(), "<", "<"),">", ">"));
- //itemkind.setItemkindEnm(GagaStringUtil.replace(GagaStringUtil.replace(itemkind.getItemkindEnm(), "<", "<"),">", ">"));
- goodsDao.saveItemkindInfo(itemkind);
- }
- }
- /**
- * 품목 삭제
- *
- * @param itemkindList - 품목 정보 목록
- * @author eskim
- * @since 2020. 10. 16
- */
- @Transactional("shopTxnManager")
- public void deleteItemkindInfo(Collection<Itemkind> itemkindList) {
- for (Itemkind itemkind : itemkindList) {
- goodsDao.deleteItemkindInfo(itemkind);
- }
- }
- /**
- * 색상목록 조회
- *
- * @param color
- * @return
- * @author eskim
- * @since 2020. 10. 16
- */
- public Collection<Color> getColorList(Color color) {
- return goodsDao.getColorList(color);
- }
- /**
- * 색상 저장
- *
- * @param colorList
- * @return
- * @author eskim
- * @since 2020. 10. 16
- */
- @Transactional("shopTxnManager")
- public void saveColor(Collection<Color> colorList) {
- for (Color color : colorList) {
- color.setRegNo(TsaSession.getInfo().getUserNo());
- color.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveColor(color);
- }
- }
- /**
- * 상품정보고시 목록
- *
- * @param notiInfo
- * @return
- * @author eskim
- * @since 2010. 10. 19
- */
- public Collection<NotiInfo> getNotiInfoList(NotiInfo notiInfo) {
- return goodsDao.getNotiInfoList(notiInfo);
- }
- /**
- * 상품정보고시 항목 목록
- *
- * @param notiInfo
- * @return
- * @author eskim
- * @since 2010. 10. 19
- */
- public Collection<NotiInfo> getNotiInfoItemList(NotiInfo notiInfo) {
- return goodsDao.getNotiInfoItemList(notiInfo);
- }
- /**
- * 상품정보고시 항목 저장
- *
- * @param notiInfoList
- * @return
- * @author eskim
- * @since 2010. 10. 19
- */
- @Transactional("shopTxnManager")
- public void saveNotiInfoItem(Collection<NotiInfo> notiInfoList) {
- if (notiInfoList == null || notiInfoList.isEmpty())
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- for (NotiInfo notiInfo : notiInfoList) {
- if (!StringUtils.isEmpty(notiInfo.getNiContent())) {
- notiInfo.setNiContent(GagaStringUtil.replace(GagaStringUtil.replace(notiInfo.getNiContent(),"<", "<"),">", ">"));
- }
- notiInfo.setRegNo(TsaSession.getInfo().getUserNo());
- notiInfo.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveNotiInfo(notiInfo);
- }
- }
- /**
- * WMS 색상 매핑목록 조회
- *
- * @param color
- * @return
- * @author eskim
- * @since 2020. 10. 16
- */
- public Collection<WmsColorMapping> getWmsColorMappingList(WmsColorMapping wmsColorMapping) {
- return goodsDao.getWmsColorMappingList(wmsColorMapping);
- }
- /**
- * WMS 색상 매핑 저장
- *
- * @param colorList
- * @return
- * @author eskim
- * @since 2020. 10. 16
- */
- @Transactional("shopTxnManager")
- public void saveWmsColorMapping(Collection<WmsColorMapping> wmsColorMappingList) {
- for (WmsColorMapping wmsColorMapping : wmsColorMappingList) {
- wmsColorMapping.setRegNo(TsaSession.getInfo().getUserNo());
- wmsColorMapping.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveWmsColorMapping(wmsColorMapping);
- }
- }
- /**
- * WMS 스타일년도 매핑목록 조회
- *
- * @param wmsStyleYearMapping
- * @return
- * @author eskim
- * @since 2020. 11. 13
- */
- public Collection<WmsStyleYearMapping> getWmsStyleYearMappingList(WmsStyleYearMapping wmsStyleYearMapping) {
- return goodsDao.getWmsStyleYearMappingList(wmsStyleYearMapping);
- }
- /**
- * WMS 스타일년도 매핑 저장
- *
- * @param wmsStyleYearMappingList
- * @return
- * @author eskim
- * @since 2020. 11. 13
- */
- @Transactional("shopTxnManager")
- public void saveWmsStyleYearMapping(Collection<WmsStyleYearMapping> wmsStyleYearMappingList) {
- for (WmsStyleYearMapping wmsStyleYearMapping : wmsStyleYearMappingList) {
- wmsStyleYearMapping.setRegNo(TsaSession.getInfo().getUserNo());
- wmsStyleYearMapping.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveWmsStyleYearMapping(wmsStyleYearMapping);
- }
- }
- /**
- * WMS 시즌 매핑목록 조회
- *
- * @param wmsSeasonMapping
- * @return
- * @author eskim
- * @since 2020. 11. 13
- */
- public Collection<WmsSeasonMapping> getWmsSeasonMappingList(WmsSeasonMapping wmsSeasonMapping) {
- return goodsDao.getWmsSeasonMappingList(wmsSeasonMapping);
- }
- /**
- * WMS 시즌 매핑 저장
- *
- * @param wmsSeasonMappingList
- * @return
- * @author eskim
- * @since 2020. 11. 13
- */
- @Transactional("shopTxnManager")
- public void saveWmsSeasonMapping(Collection<WmsSeasonMapping> wmsSeasonMappingList) {
- for (WmsSeasonMapping wmsSeasonMapping : wmsSeasonMappingList) {
- wmsSeasonMapping.setRegNo(TsaSession.getInfo().getUserNo());
- wmsSeasonMapping.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveWmsSeasonMapping(wmsSeasonMapping);
- }
- }
- /**
- * 상품 목록 건수
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 10. 20
- */
- public int getGoodsListCount(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsListCount(goodsSearch);
- }
- /**
- * 상품 목록
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 10. 20
- */
- public Collection<Goods> getGoodsList(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsList(goodsSearch);
- }
- /**
- * 상품목록 - 기본정보 엑셀다운로드
- *
- * @param goodsSearch
- * @param excelFilenameWithPath - 경로를 포함한 엑셀파일명
- * @return
- * @author eskim
- * @since 2020. 10. 21
- */
- public void getGoodsInfoExcelList(GoodsSearch goodsSearch, String excelFilenameWithPath) {
- if ("Y".equals(goodsSearch.getImageViewYn())) {
- // 헤더 title 설정
- String[] listTitles = {"이미지", "상품코드", "업체명", "브랜드명", "상품명", "품목", "재고", "상품상태", "스타일년도", "시즌",
- "정상가", "판매가", "할인율", "가격변경일", "ERP재고연동여부", "정상이월구분", "반품가능 여부","승인일시"};
- // DB 처리 시 사용되는 파라미터명(셀명) 설정
- String[] cellNames = {"SYS_IMG_NM", "GOODS_CD", "SUPPLY_COMP_CD", "BRAND_GRP_NM", "GOODS_NM", "ITEMKIND_NM",
- "STOCK_QTY_SUM", "GOODS_STAT", "STYLE_YEAR", "SEASON_CD", "LIST_PRICE", "CURR_PRICE",
- "DC_RATE", "PRICE_UPD_DT", "ERP_STOCK_LINK_YN", "FORMAL_GB", "RETURNABLE_YN", "FRST_CFRM_DT"};
- String[] cellTypes = {GagaExcelConstants.CellType.IMAGE.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
- GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name()};
- String targetPath = env.getProperty("upload.goods.view");
- Collection<GagaMap> dataList = goodsDao.getGoodsInfoExcelList(goodsSearch); // map형식으로 조회
- if (dataList != null && !dataList.isEmpty()) {
- for (GagaMap gagaMap : dataList) {
- if (!StringUtils.isEmpty(gagaMap.get("SYS_IMG_NM").toString()) ) {
- gagaMap.set("SYS_IMG_NM", targetPath + '/' + gagaMap.get("SYS_IMG_NM").toString());
- }
- }
- }
- try {
- GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 정보", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- } else {
- // 헤더 title 설정
- String[] listTitles = {"상품코드", "업체명", "브랜드명", "상품명", "품목", "재고", "상품상태", "스타일년도",
- "시즌", "정상가", "판매가", "할인율", "가격변경일", "ERP재고연동여부", "정상이월구분", "반품가능 여부", "승인일시"};
- // DB 처리 시 사용되는 파라미터명(셀명) 설정
- String[] cellNames = {"GOODS_CD", "SUPPLY_COMP_CD", "BRAND_GRP_NM", "GOODS_NM", "ITEMKIND_NM", "STOCK_QTY_SUM", "GOODS_STAT", "STYLE_YEAR",
- "SEASON_CD", "LIST_PRICE", "CURR_PRICE", "DC_RATE", "PRICE_UPD_DT", "ERP_STOCK_LINK_YN", "FORMAL_GB", "RETURNABLE_YN", "FRST_CFRM_DT"};
- String[] cellTypes = {
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
- GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
- GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name()};
- Collection<GagaMap> dataList = goodsDao.getGoodsInfoExcelList(goodsSearch);
- try {
- GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 정보", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
- }
- /**
- * 상품 이미지 등록여부 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 21
- */
- public Collection<Goods> getGoodsImgsYn(Goods goods) {
- return goodsDao.getGoodsImgsYn(goods);
- }
- /**
- * 상품 상세
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 22
- */
- public Goods getGoods(Goods goods) {
- // 상품기본정보
- Goods resultGoods = goodsDao.getGoods(goods);
- // 상품 상세
- this.getGoodsDesc(resultGoods);
- return resultGoods;
- }
- /**
- * 상품 상세 조회
- *
- * @param resultGoods
- * @return
- * @author eskim
- * @since 2020. 10. 22
- */
- private Goods getGoodsDesc(Goods resultGoods) {
- GoodsDesc goods = new GoodsDesc();
- goods.setGoodsCd(resultGoods.getGoodsCd());
- // 상품 상세 타이틀
- goods.setDescGb("10");
- String goodsTitlesDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsTitlesDesc(goodsTitlesDesc);
- // 상품 상세 내용
- goods.setDescGb("20");
- String goodsContentsDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsContentsDesc(goodsContentsDesc);
- // 상품 상세 특징
- goods.setDescGb("30");
- String goodsCharacterDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsCharacterDesc(goodsCharacterDesc);
- // 상품 상세 pc 상단
- goods.setDescGb("40");
- String goodsPcTopDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsPcTopDesc(goodsPcTopDesc);
- // 상품 상세 pc 하단
- goods.setDescGb("50");
- String goodsPcDownDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsPcDownDesc(goodsPcDownDesc);
- // 상품 상세 mobile 상단
- goods.setDescGb("60");
- String goodsMobileTopDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsMobileTopDesc(goodsMobileTopDesc);
- // 상품 상세 mobile 하단
- goods.setDescGb("70");
- String goodsMobileDownDesc = this.getGoodsDescList(goods);
- resultGoods.setGoodsMobileDownDesc(goodsMobileDownDesc);
- return resultGoods;
- }
- /**
- * 상품 상세구분별 컨텐츠 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 22
- */
- private String getGoodsDescList(GoodsDesc goodsDesc) {
- Collection<GoodsDesc> goodsDescList = goodsDao.getGoodsDescList(goodsDesc);
- StringBuilder goodsDescSb = new StringBuilder();
- if (goodsDescList != null && !goodsDescList.isEmpty()) {
- for (GoodsDesc tmpGoodsDesc : goodsDescList) {
- goodsDescSb.append(tmpGoodsDesc.getGoodsDesc());
- }
- }else {
- goodsDescSb.append("");
- }
- return goodsDescSb.toString();
- }
- /**
- * 상품 정보 이력 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2019. 12. 12
- */
- public Collection<GoodsHst> getGoodsHstList(Goods goods) {
- return goodsDao.getGoodsHstList(goods);
- }
- /**
- * 상품 옵션 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 26
- */
- public Collection<Option> getGoodsSizeList(Goods goods) {
- return goodsDao.getGoodsSizeList(goods);
- }
- /**
- * 상품 색상목록 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 11. 18
- */
- public Collection<GoodsImg> getGoodsColorList(Goods goods) {
- return goodsDao.getGoodsColorList(goods);
- }
- /**
- * 상품 정보고시 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 22
- */
- public Collection<GoodsNotiInfo> getGoodsNotiInfoList(GoodsNotiInfo goodsNotiInfo) {
- return goodsDao.getGoodsNotiInfoList(goodsNotiInfo);
- }
- /**
- * 상품의 정보고시 항목 목록
- *
- * @param notiInfo
- * @return
- * @author eskim
- * @since 2020. 11. 18
- */
- public Collection<NotiInfo> getNotiGoodsInfoList(NotiInfo notiInfo) {
- return goodsDao.getNotiGoodsInfoList(notiInfo);
- }
- /**
- * 상품 구매등급 조회
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 11. 18
- */
- public Collection<Goods> getGoodsDetailOrderGradeList(Goods goods) {
- return goodsDao.getGoodsDetailOrderGradeList(goods);
- }
- /**
- * 구성상품 목록
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 27
- */
- public Collection<GoodsCompose> getGoodsDetailComposeList(Goods goods) {
- return goodsDao.getGoodsDetailComposeList(goods);
- }
- /**
- * 안전인증번호
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 12. 07
- */
- public GagaMap getGoodsDetailCertNum(String goodsCd) {
- GagaMap result = new GagaMap();
- return result;
- }
- /**
- * 안전인증번호 저장
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 12. 07
- */
- @Transactional("shopTxnManager")
- public void saveGoodsDetailCertNum(Goods goods) {
- try {
- GagaMap result = safetyKoreaApi.getKoreaCertifyDetail(goods.getCertNum());
- if (result != null || !StringUtil.isNullOrEmpty(result.get("certNum").toString())) {
- GoodsSafeNo goodsSafeNo = new GoodsSafeNo();
- goodsSafeNo.setGoodsCd(goods.getGoodsCd());
- goodsSafeNo.setCertDt(result.get("certDt").toString());
- goodsSafeNo.setCertNum(result.get("certNum").toString());
- goodsSafeNo.setCertState(result.get("certState").toString());
- goodsSafeNo.setCertDiv(result.get("certDiv").toString());
- goodsSafeNo.setRegNo(TsaSession.getInfo().getUserNo());
- goodsSafeNo.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveGoodsSafeNo(goodsSafeNo);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 상품 수정 항목 일괄변경
- *
- * @param goods
- * @author eskim
- * @since 2020. 01. 17
- */
- @Transactional("shopTxnManager")
- public void updateGoodsState(Goods goods) {
- if (goods == null || (goods.getArrGoodsCd() == null && goods.getArrGoodsCd().length <= 0)) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- if (goods.getArrGoodsCd().length > 0) {
- for (String goodsCd : goods.getArrGoodsCd()) {
- goods.setGoodsCd(goodsCd);
- // 이력생성
- goodsDao.createGoodsHst(goods);
- if ("formalGb".equals(goods.getProcJob())) {
- // 상품브랜드 조회
- Goods originGoods = goodsDao.getGoods(goods);
- // 브랜드 확인
- goods.setPntPrate(originGoods.getPntPrate()); // 포인트적립율(PC)
- goods.setPntMrate(originGoods.getPntMrate()); // 포인트적립율(MOBILE)
- Brand brand = new Brand();
- brand.setBrandCd(originGoods.getBrandCd());
- Collection<Brand> brandList = businessService.getBrandList(brand);
- if (brandList != null && !brandList.isEmpty()) {
- float pntPrate = 0;
- float pntMrate = 0;
- for (Brand tmpBrand : brandList) {
- if ("G009_10".equals(goods.getFormalGb())) {
- pntPrate = tmpBrand.getPntPrate10();
- pntMrate = tmpBrand.getPntMrate10();
- } else {
- pntPrate = tmpBrand.getPntPrate20();
- pntMrate = tmpBrand.getPntMrate20();
- }
- }
- goods.setPntPrate(pntPrate); // 포인트적립율(PC)
- goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
- }
- } else if ("goodsStat".equals(goods.getProcJob())) {
- // 상품브랜드 조회
- Goods originGoods = goodsDao.getGoods(goods);
- // 승인일
- if (!goods.getGoodsStat().equals(originGoods.getGoodsStat()) && "G008_90".equals(goods.getGoodsStat())) {
- goods.setChGoodsStatYn("Y");
- }
- }
- // 상품정보 변경
- goodsDao.updateGoodsState(goods);
- }
- } else {
- // 이력생성
- goodsDao.createGoodsHst(goods);
- if ("formalGb".equals(goods.getProcJob())) {
- // 상품브랜드 조회
- Goods originGoods = goodsDao.getGoods(goods);
- // 브랜드 확인
- goods.setPntPrate(originGoods.getPntPrate()); // 포인트적립율(PC)
- goods.setPntMrate(originGoods.getPntMrate()); // 포인트적립율(MOBILE)
- Brand brand = new Brand();
- brand.setBrandCd(originGoods.getBrandCd());
- Collection<Brand> brandList = businessService.getBrandList(brand);
- if (brandList != null && !brandList.isEmpty()) {
- float pntPrate = 0;
- float pntMrate = 0;
- for (Brand tmpBrand : brandList) {
- if ("G009_10".equals(goods.getFormalGb())) {
- pntPrate = tmpBrand.getPntPrate10();
- pntMrate = tmpBrand.getPntMrate10();
- } else {
- pntPrate = tmpBrand.getPntPrate20();
- pntMrate = tmpBrand.getPntMrate20();
- }
- }
- goods.setPntPrate(pntPrate); // 포인트적립율(PC)
- goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
- }
- }
- // 상품정보 변경
- goodsDao.updateGoodsState(goods);
- }
- }
- /**
- * 엑셀조회용 상품 저장
- *
- * @param procJob : goodsExcelUpload
- * @param goodsList
- * @return
- * @author eskim
- * @since 2020. 10. 22
- */
- @Transactional("shopTxnManager")
- public void saveExceluploadGoods(Collection<Goods> goodsList, String excelFilename) {
- String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
- if (goodsList == null || goodsList.isEmpty()) {
- this.deleteExceluploadFile(targetPath, excelFilename);
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int index = 0;
- String goodsCdFlag = "";
- String goodsNumFlag = "";
- for (Goods goods : goodsList) {
- if (!StringUtils.isEmpty(goodsCdFlag) && !StringUtils.isEmpty(goodsNumFlag)) {
- throw new IllegalStateException("상품코드와 원코드 중 한 개의 셀에만 값을 입력해서 조회하세요.");
- }
- if (!StringUtils.isEmpty(goods.getSupplyCompCd())) {
- goods.setGoodsCd(goods.getSupplyCompCd());
- }
- SearchData searchData = new SearchData();
- searchData.setRegNo(goods.getRegNo());
- searchData.setSearchCd(goods.getGoodsCd());
- if (index == 0) {
- commonService.deleteExceluploadSearCh(searchData);
- }
- commonService.createExceluploadSearch(searchData);
- index++;
- }
- }
- /**
- * 파일 삭제
- *
- * @param targetPath
- * @param excelFilename
- * @author eskim
- * @since 2020. 10. 22
- */
- private void deleteExceluploadFile(String targetPath, String excelFilename) {
- // 파일 삭제
- try {
- GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(targetPath, excelFilename));
- } catch (IOException e) {
- // Nothing Do
- }
- }
- /**
- * 상품 품목 변경 저장
- *
- * @param goodsList
- * @return
- * @author eskim
- * @since 2020. 10. 23
- */
- @Transactional("shopTxnManager")
- //@CacheEvict(value = "cate", allEntries = true)
- public void saveItemKindChange(Collection<Goods> goodsList) {
- for (Goods goods : goodsList) {
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- goods.setItemkindCd(goods.getItemkindCd().toUpperCase());
- // 품목확인
- Itemkind itemkind = new Itemkind();
- itemkind.setItemkindCd(goods.getItemkindCd());
- itemkind.setUseYn("Y");
- Collection<Itemkind> itemkindList = goodsDao.getItemkindList(itemkind);
- if (itemkindList == null || itemkindList.isEmpty()) {
- throw new IllegalStateException(goods.getGoodsCd() + " 상품의 품목코드를 확인해주세요.");
- }
- // 상품이력
- goodsDao.createGoodsHst(goods);
- // 품목변경
- goodsDao.updateGoodItemKindCd(goods);
- // 검색어 변경
- String goodsSnm = goodsDao.getGoodsSnm(goods.getGoodsCd());
- Goods tmpGoods = goodsDao.getGoods(goods);
- if (tmpGoods != null && !StringUtils.isEmpty(tmpGoods.getGoodsSnm1())) {
- String[] arrGoodsSnm = tmpGoods.getGoodsSnm1().split(";");
- StringBuilder tempGoodsSnm = new StringBuilder();
- for (String loopGoodsSnm : arrGoodsSnm) {
- if (goodsSnm.toUpperCase().indexOf(loopGoodsSnm.toUpperCase()) <= -1) {
- tempGoodsSnm.append(loopGoodsSnm).append(";");
- }
- }
- goods.setGoodsSnm(tempGoodsSnm.toString() + goodsSnm);
- } else {
- goods.setGoodsSnm(goodsSnm);
- }
- goodsDao.updateGoodsSnm(goods);
- Collection<GoodsNotiInfo> goodsNotiInfoList = goodsDao.getNewNotiInfo(goods);
- goodsDao.deleteGoodsNotiInfo(goods);
- for (GoodsNotiInfo goodsNotiInfo : goodsNotiInfoList) {
- goodsNotiInfo.setRegNo(TsaSession.getInfo().getUserNo());
- goodsNotiInfo.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsNotiInfo.setGoodsCd(goods.getGoodsCd());
- goodsDao.saveGoodsNotiInfo(goodsNotiInfo);
- }
- this.saveGoodsCategory(goods);
- }
- }
- /**
- * 상품 품목 기준 카테고리 저장
- *
- * @param goods
- * @author eskim
- * @since 2020. 4. 21.
- */
- private void saveGoodsCategory(Goods goods) {
- // GoodsCategory goodsCategory = new GoodsCategory();
- // goodsCategory.setRegNo(TsaSession.getInfo().getUserNo());
- // goodsCategory.setUpdNo(TsaSession.getInfo().getUserNo());
- // goodsCategory.setGoodsCd(goods.getGoodsCd());
- // displayService.deleteGoodsCategory(goodsCategory);
- //
- // Collection<ItemkindCategory> itemkindCategoryList = displayService.getItemkindCategoryList(goods.getItemkindCd());
- // for ItemkindCategory itemkindCategory : itemkindCategoryList) {
- // Category category = new Category();
- // category.setCateGb(itemkindCategory.getCateGb());
- // category.setCateCd(itemkindCategory.getCateCd());
- // category = displayService.getCategory4srch(category);
- //
- // CategoryGoods categoryGoods = new CategoryGoods();
- // categoryGoods.setRegNo(TsaSession.getInfo().getUserNo());
- // categoryGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- // String[] goodsCdArr = {goods.getGoodsCd()};
- // categoryGoods.setGoodsCdArr(goodsCdArr);
- // if (category.getCateGb() != null) {
- // categoryGoods.setNcateGb(String.valueOf(category.getCateGb()));
- // }
- // if (category.getCateType() != null) {
- // categoryGoods.setNcateType(String.valueOf(category.getCateType()));
- // }
- // if (category.getCateCd() != null) {
- // categoryGoods.setNcateCd(String.valueOf(category.getCateCd()));
- // }
- // if (category.getTcateCd() != null) {
- // categoryGoods.setNtcateCd(String.valueOf(category.getTcateCd()));
- // }
- // if (category.getMcateCd() != null) {
- // categoryGoods.setNmcateCd(String.valueOf(category.getMcateCd()));
- // }
- // if (category.getScateCd() != null) {
- // categoryGoods.setNscateCd(String.valueOf(category.getScateCd()));
- // }
- // if (category.getDcateCd() != null) {
- // categoryGoods.setNdcateCd(String.valueOf(category.getDcateCd()));
- // }
- // displayService.moveCategoryGoods(categoryGoods);
- // }
- }
- /**
- * 상품 저장
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 27
- */
- @Transactional("shopTxnManager")
- public void saveGoodsDetail(Goods goods) {
- // <,> replace 처리
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- goods.setGoodsPcTopDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsPcTopDesc(), "<", "<"), ">", ">"));
- goods.setGoodsMobileTopDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsMobileTopDesc(), "<", "<"), ">", ">"));
- goods.setGoodsPcDownDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsPcDownDesc(), "<", "<"), ">", ">"));
- goods.setGoodsMobileDownDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsMobileDownDesc(), "<", "<"), ">", ">"));
- goods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "<", "<"), ">", ">"));
- goods.setGoodsTnm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsTnm(), "<", "<"), ">", ">"));
- goods.setGoodsSnm1(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsSnm1(), "<", "<"), ">", ">"));
- // 딜상품의 대표상품 변경여부 확인
- if ("G056_D".equals(goods.getGoodsType())) {
- String newRepGoodsCd = "";
- int newRepGoodsPrice = 0;
- Collection<GoodsCompose> goodsExtendList = goods.getGoodsComposeListNew();
- for (GoodsCompose regGoodsExtend : goodsExtendList) {
- if ("Y".equals(regGoodsExtend.getRepYn())) {
- newRepGoodsCd = regGoodsExtend.getCompsGoodsCd();
- newRepGoodsPrice = regGoodsExtend.getCurrPrice();
- }
- }
- log.info("newRepGoodsCd = {}, newRepGoodsPrice = {}, goods.getRepGoodsCd = {}", newRepGoodsCd, newRepGoodsPrice, goods.getRepGoodsCd());
- // 1순 : 대표상품 변경, 2순 : 판매가 변경
- if (!newRepGoodsCd.equals(goods.getRepGoodsCd())) {
- goods.setCurrBprice(goods.getCurrPriceOrg());
- goods.setCurrPrice(newRepGoodsPrice);
- goods.setListPrice(newRepGoodsPrice);
- goods.setDcRate(0);
- goods.setChDataYn("Y");
- }else {
- if (goods.getCurrPrice() != goods.getCurrPriceOrg()) {
- goods.setCurrBprice(goods.getCurrPriceOrg());
- goods.setListPrice(goods.getCurrPrice());
- goods.setDcRate(0);
- }
- }
- }else {
- // 가격변경일
- if (goods.getCurrPrice() != goods.getCurrPriceOrg()) {
- goods.setCurrBprice(goods.getCurrPriceOrg());
- } else {
- goods.setCurrPrice(goods.getCurrPriceOrg());
- }
- }
- // 승인일
- if (!goods.getGoodsStat().equals(goods.getGoodsStatOrg()) && "G008_90".equals(goods.getGoodsStat())) {
- goods.setChGoodsStatYn("Y");
- }
- // 사용자 검색어를 검색어에 적용
- String goodsSnm = goodsDao.getGoodsSnm(goods.getGoodsCd());
- if (!StringUtils.isEmpty(goods.getGoodsSnm1())) {
- goods.setGoodsSnm1(GagaStringUtil.replace(goods.getGoodsSnm1(), " ", "")); // 빈값 삭제
- String[] arrGoodsSnm = goods.getGoodsSnm1().split(";");
- StringBuilder tempGoodsSnm = new StringBuilder();
- for (String loopGoodsSnm : arrGoodsSnm) {
- if (goodsSnm.toUpperCase().indexOf(loopGoodsSnm.toUpperCase()) <= -1) {
- tempGoodsSnm.append(loopGoodsSnm).append(";");
- }
- }
- goods.setGoodsSnm(tempGoodsSnm.toString() + goodsSnm);
- } else if (!goodsSnm.equals(goods.getGoodsSnm())) {
- goods.setGoodsSnm(goodsSnm);
- }
- goods.setFormalGb(goods.getFormalGb());
- // 브랜드 확인
- if (!"G056_N".equals(goods.getGoodsType())) {
- if (!goods.getFormalGb().equals(goods.getFormalGbOrg())) {
- Brand brand = new Brand();
- brand.setBrandCd(goods.getBrandCd());
- Collection<Brand> brandList = businessService.getBrandList(brand);
- if (brandList != null && !brandList.isEmpty()) {
- float pntPrate = 0.0f;
- float pntMrate = 0.0f;
- for (Brand tmpBrand : brandList) {
- if ("G009_10".equals(goods.getFormalGb())) {
- pntPrate = tmpBrand.getPntPrate10();
- pntMrate = tmpBrand.getPntMrate10();
- } else {
- pntPrate = tmpBrand.getPntPrate20();
- pntMrate = tmpBrand.getPntMrate20();
- }
- }
- goods.setPntPrate(pntPrate); // 포인트적립율(PC)
- goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
- }
- }
- }
- // 기본정보 변경
- if ("Y".equals(goods.getChDataYn())) {
- goodsDao.createGoodsHst(goods);
- goodsDao.updateGoods(goods);
- }
- // 상품상세정보 변경
- if (!"Y".equals(goods.getChkDescKeep())) {
- this.saveGoodsDetailDesc(goods);
- }
- int idx = 1;
- // 구성상품 변경
- if (!"G056_N".equals(goods.getGoodsType())) {
- Collection<GoodsCompose> goodsExtendList = goods.getGoodsComposeListNew();
- for (GoodsCompose regGoodsExtend : goodsExtendList) {
- regGoodsExtend.setDispOrd(idx);
- regGoodsExtend.setRegNo(TsaSession.getInfo().getUserNo());
- regGoodsExtend.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveGoodsCompose(regGoodsExtend); // 구성상품기본 저장
- idx++;
- }
- }
- // 옵션/재고 변경
- if (goods.getOptCd() != null && goods.getOptCd().length > 0 && "Y".equals(goods.getChStockDataYn())) {
- this.saveStock(goods);
- }
- // 상품 정보고시 변경
- this.saveGoodsNotiInfo(goods);
- // 상품 구매등급 적용
- if (goods.getGoodsOrderGrade() != null && goods.getGoodsOrderGrade().length > 0) {
- Goods goodsOrderGrade = new Goods();
- goodsOrderGrade.setGoodsCd(goods.getGoodsCd());
- goodsOrderGrade.setRegNo(TsaSession.getInfo().getUserNo());
- goodsDao.deleteGoodsCustGrade(goodsOrderGrade);
- for(String custGrade : goods.getGoodsOrderGrade()) {
- goodsOrderGrade.setCustGrade(custGrade);
- goodsDao.createGoodsCustGrade(goodsOrderGrade);
- }
- }else {
- Goods goodsOrderGrade = new Goods();
- goodsOrderGrade.setGoodsCd(goods.getGoodsCd());
- goodsOrderGrade.setRegNo(TsaSession.getInfo().getUserNo());
- goodsDao.deleteGoodsCustGrade(goodsOrderGrade);
- }
- }
- /**
- * 상품상세정보 변경 - 상품상세
- *
- * @param goods
- * @author eskim
- * @since 2020. 10. 27.
- */
- private void saveGoodsDetailDesc(Goods goods) {
- // 상품상세 구분(10:상품타이틀,20:상품타이틀내용,30:상품특징,40:상위컨텐츠,50:하위컨텐츠,60:하위컨텐츠-모바일,70:상위컨텐츠-모바일)
- GoodsDesc goodsDesc = new GoodsDesc();
- goodsDesc.setGoodsCd(goods.getGoodsCd());
- goodsDesc.setRegNo(goods.getRegNo());
- goodsDesc.setUpdNo(goods.getUpdNo());
- // AS-IS 상세 정보 이력 처리
- goodsDao.createGoodsDetailDescHst(goodsDesc);
- // 상세 타이틀
- goodsDesc.setDescGb("10");
- goodsDesc.setGoodsDesc(goods.getGoodsTitlesDesc());
- this.saveGoodsDesc(goodsDesc);
- // 상세 내용
- goodsDesc.setDescGb("20");
- goodsDesc.setGoodsDesc(goods.getGoodsContentsDesc());
- this.saveGoodsDesc(goodsDesc);
- // 상세 특징
- goodsDesc.setDescGb("30");
- goodsDesc.setGoodsDesc(goods.getGoodsCharacterDesc());
- this.saveGoodsDesc(goodsDesc);
- // PC 상단
- goodsDesc.setDescGb("40");
- goodsDesc.setGoodsDesc(goods.getGoodsPcTopDesc());
- this.saveGoodsDesc(goodsDesc);
- // PC 하단
- goodsDesc.setDescGb("50");
- goodsDesc.setGoodsDesc(goods.getGoodsPcDownDesc());
- this.saveGoodsDesc(goodsDesc);
- // MO 상단
- goodsDesc.setDescGb("60");
- goodsDesc.setGoodsDesc(goods.getGoodsMobileTopDesc());
- this.saveGoodsDesc(goodsDesc);
- // MO 하단
- goodsDesc.setDescGb("70");
- goodsDesc.setGoodsDesc(goods.getGoodsMobileDownDesc());
- this.saveGoodsDesc(goodsDesc);
- }
- /**
- * 상품 상세 저장
- *
- * @param goodsDesc
- * @return
- * @author eskim
- * @since 2020. 10. 27
- */
- private void saveGoodsDesc(GoodsDesc goodsDesc) {
- goodsDao.deleteGoodsDesc(goodsDesc);
- String[] arrProdHtml = null;
- arrProdHtml = makeArrayToString(goodsDesc.getGoodsDesc(), 3900);
- if (arrProdHtml.length > 0) {
- for (int i = 0; i < arrProdHtml.length; i++) {
- if (!arrProdHtml[i].isEmpty()) {
- goodsDesc.setSeq(i + 1);
- goodsDesc.setGoodsDesc(arrProdHtml[i]);
- goodsDao.createGoodsDesc(goodsDesc);
- }
- }
- }
- }
- /**
- * String => byte array
- *
- * @param raw
- * @param len
- * @return
- * @author eskim
- * @since 2020. 10. 27
- */
- public static String[] makeArrayToString(String raw, int len) {
- String[] ary = null;
- if (raw == null) {
- return ary;
- }
- try {
- // raw 의 byte
- byte[] rawBytes = raw.getBytes("UTF-8"); // MS949
- int rawLength = rawBytes.length;
- if (rawLength > len) {
- int aryLength = (rawLength / len) + (rawLength % len != 0 ? 1 : 0);
- ary = new String[aryLength];
- int endCharIndex = 0; // 문자열이 끝나는 위치
- String tmp;
- for (int i = 0; i < aryLength; i++) {
- if (i == (aryLength - 1)) {
- tmp = raw.substring(endCharIndex);
- } else {
- int useByteLength = 0;
- int rSize = 0;
- for (; endCharIndex < raw.length(); endCharIndex++) {
- if (raw.charAt(endCharIndex) > 0x007F) {
- useByteLength += 3;
- } else {
- useByteLength++;
- }
- if (useByteLength > len) {
- break;
- }
- rSize++;
- }
- tmp = raw.substring((endCharIndex - rSize), endCharIndex);
- }
- ary[i] = tmp;
- }
- } else {
- ary = new String[] {raw};
- }
- } catch (java.io.UnsupportedEncodingException e) {
- }
- return ary;
- }
- /**
- * 옵션/재고 변경 - 상품상세
- *
- * @param goods
- * @param index
- * @author eskim
- * @since 2020. 10. 27
- */
- private void saveStock(Goods goods) {
- int index = 0;
- Option stock = new Option();
- stock.setGoodsCd(goods.getGoodsCd());
- stock.setUpdNo(goods.getUpdNo());
- stock.setRegNo(goods.getRegNo());
- goodsDao.createStockHst(stock);
- log.info("saveStock goods={}", goods);
- for (String optCd : goods.getOptCd()) {
- log.info("saveStock index={}", index);
- log.info("saveStock optCd={}", optCd);
- Option goodsStock = new Option();
- goodsStock.setGoodsCd(goods.getCompsGoodsCd()[index]); // 구성상품 코드
- goodsStock.setOptCd(optCd);
- goodsStock.setOptCd1(goods.getOptCd1()[index]);
- goodsStock.setOptCd2(goods.getOptCd2()[index]);
- goodsStock.setBaseStockQty(Integer.parseInt(goods.getBaseStockQty()[index]));
- goodsStock.setSoldoutYn(goods.getSoldoutYn()[index]);
- goodsStock.setDispOrd(Integer.parseInt(goods.getDispOrd()[index]));
- goodsStock.setDispYn(goods.getDispYn()[index]);
- goodsStock.setRegNo(goods.getRegNo());
- goodsStock.setUpdNo(goods.getUpdNo());
- if ("N".equals(goods.getSelfGoodsYn())) {
- goodsStock.setSelfGoodsYn(goods.getSelfGoodsYn());
- goodsStock.setCurrStockQty(Integer.parseInt(goods.getEditCurrStockQty()[index]));
- }
- goodsDao.saveStock(goodsStock);
- index++;
- }
- }
- /**
- * 상품 사이즈 옵션정보 이력 생성
- *
- * @param goods
- * @author eskim
- * @since 2020. 11. 17
- */
- @Transactional("shopTxnManager")
- public void createStockHst(Option option) {
- goodsDao.createStockHst(option);
- }
- /**
- * 상품 정보고시 변경 - 상품상세
- *
- * @param goods
- * @author eskim
- * @since 2020. 10. 27
- */
- private void saveGoodsNotiInfo(Goods goods) {
- int index;
- if (goods.getNotiListNew() != null && !goods.getNotiListNew().isEmpty()) {
- index = 0;
- for (GoodsNotiInfo goodsNotiInfo : goods.getNotiListNew()) {
- if (index == 0) {
- goodsDao.deleteGoodsNotiInfo(goods);
- }
- goodsNotiInfo.setNiContent(GagaStringUtil.replace(GagaStringUtil.replace(goodsNotiInfo.getNiContent(), "<", "<"), ">", ">"));
- goodsNotiInfo.setRegNo(goods.getRegNo());
- goodsNotiInfo.setUpdNo(goods.getUpdNo());
- goodsDao.saveGoodsNotiInfo(goodsNotiInfo);
- index++;
- }
- }
- }
- /**
- * 딜상품 저장
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 30
- */
- @Transactional("shopTxnManager")
- public void saveGoodsDeal(Goods goods) {
- Goods regGoods = new Goods();
- // <,> replace 처리
- regGoods.setRegNo(TsaSession.getInfo().getUserNo());
- regGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- String goodsCd = this.getGoodsCodeSeq("D", "D");
- regGoods.setGoodsCd(goodsCd);
- regGoods.setSupplyGoodsCd(goodsCd);
- regGoods.setGoodsType("G056_D");
- regGoods.setSupplyCompCd(goods.getSupplyCompCd());
- regGoods.setBrandCd(goods.getBrandCd());
- regGoods.setItemkindCd(goods.getItemkindCd());
- regGoods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "<", "<"), ">", ">"));
- regGoods.setStyleYear(goods.getStyleYear());
- regGoods.setSeasonCd(goods.getSeasonCd());
- regGoods.setSexGb(goods.getSexGb());
- regGoods.setMainColorCd("00");
- regGoods.setOriginCd(goods.getOriginCd());
- regGoods.setMakeYmd(goods.getMakeYmd());
- regGoods.setSelfMallYn(goods.getSelfMallYn());
- regGoods.setGoodsStat("G008_20"); // 정보부족
- regGoods.setFormalGb("G009_10"); // 정상 기본값 처리
- regGoods.setGoodsGb("G073_11"); // 자사상품은 신규
- regGoods.setDistributionGb("G065_12"); // 유통구분
- regGoods.setTaxGb("10"); // 과세구분
- regGoods.setGoodsNum(goodsCd);
- regGoods.setListPrice(goods.getCurrPrice());
- regGoods.setCurrPrice(goods.getCurrPrice());
- regGoods.setDcRate((int)(this.getDcRate(goods.getCurrPrice(), goods.getCurrPrice())));
- Collection<GoodsCompose> goodsComposeList = null;
- try {
- goodsComposeList = mapper.readValue(goods.getGoodsComposeList(), new TypeReference<Collection<GoodsCompose>>() {
- });
- } catch (Exception e) {
- e.printStackTrace();
- throw new IllegalStateException(message.getMessage("딜상품 저장 중 오류로 인해 저장되지 않았습니다."));
- }
- for (GoodsCompose goodsCompose : goodsComposeList) {
- goodsCompose.setGoodsCd(regGoods.getGoodsCd());
- goodsCompose.setGoodsType(regGoods.getGoodsType());
- goodsCompose.setRegNo(TsaSession.getInfo().getUserNo());
- goodsCompose.setUpdNo(TsaSession.getInfo().getUserNo());
- Goods extendGoods = new Goods();
- extendGoods.setGoodsCd(goodsCompose.getCompsGoodsCd());
- extendGoods = goodsDao.getGoods(extendGoods);
- if (StringUtils.isEmpty(extendGoods.getBrandCd())) {
- throw new IllegalStateException(message.getMessage("구성상품 중 " + goodsCompose.getCompsGoodsCd() + " 상품 정보를 확인해 주세요."));
- }
- if ("Y".equals(goodsCompose.getBaseYn())) {
- regGoods.setBrandCd(extendGoods.getBrandCd());
- regGoods.setItemkindCd(extendGoods.getItemkindCd());
- regGoods.setSupplyCompCd(extendGoods.getSupplyCompCd());
- regGoods.setFormalGb(extendGoods.getFormalGb());
- }
- }
- this.createGoodsExtend(regGoods, goodsComposeList); // 딜상품 관련 정보 저장
- }
- /**
- * 세트상품 저장
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 11. 04
- */
- @Transactional("shopTxnManager")
- public void saveGoodsSet(Goods goods) {
- Goods regGoods = new Goods();
- // <,> replace 처리
- regGoods.setRegNo(TsaSession.getInfo().getUserNo());
- regGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- String goodsCd = this.getGoodsCodeSeq("S", "S");
- regGoods.setGoodsCd(goodsCd);
- regGoods.setSupplyGoodsCd(goodsCd);
- regGoods.setGoodsType("G056_S");
- regGoods.setSupplyCompCd(goods.getSupplyCompCd());
- regGoods.setBrandCd(goods.getBrandCd());
- regGoods.setItemkindCd(goods.getItemkindCd());
- regGoods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "<", "<"), ">", ">"));
- regGoods.setStyleYear(goods.getStyleYear());
- regGoods.setSeasonCd(goods.getSeasonCd());
- regGoods.setSexGb(goods.getSexGb());
- regGoods.setMainColorCd("00");
- regGoods.setOriginCd(goods.getOriginCd());
- regGoods.setMakeYmd(goods.getMakeYmd());
- regGoods.setSelfMallYn(goods.getSelfMallYn());
- regGoods.setGoodsStat("G008_20"); // 정보부족
- regGoods.setFormalGb("G009_10"); // 정상 기본값 처리
- regGoods.setGoodsGb("G073_11"); // 자사상품은 신규
- regGoods.setDistributionGb("G065_12"); // 유통구분
- regGoods.setTaxGb("10"); // 과세구분
- regGoods.setGoodsNum(goodsCd);
- Collection<GoodsCompose> goodsComposeList = null;
- try {
- goodsComposeList = mapper.readValue(goods.getGoodsComposeList(), new TypeReference<Collection<GoodsCompose>>() {
- });
- } catch (Exception e) {
- throw new IllegalStateException(message.getMessage("세트상품 저장 중 오류로 인해 저장되지 않았습니다."));
- }
- int listPriceSum = 0;
- int currPriceSum = 0;
- for (GoodsCompose goodsCompose : goodsComposeList) {
- goodsCompose.setGoodsCd(regGoods.getGoodsCd());
- goodsCompose.setGoodsType(regGoods.getGoodsType());
- goodsCompose.setRegNo(TsaSession.getInfo().getUserNo());
- goodsCompose.setUpdNo(TsaSession.getInfo().getUserNo());
- Goods extendGoods = new Goods();
- extendGoods.setGoodsCd(goodsCompose.getCompsGoodsCd());
- extendGoods = goodsDao.getGoods(extendGoods);
- if (StringUtils.isEmpty(extendGoods.getBrandCd())) {
- throw new IllegalStateException(message.getMessage("구성상품 중 " + goodsCompose.getCompsGoodsCd() + " 상품 정보를 확인해 주세요."));
- }
- listPriceSum += extendGoods.getListPrice() * goodsCompose.getQty() ;
- currPriceSum += goodsCompose.getCompsCurrPrice(); // 입력값
- if ("Y".equals(goodsCompose.getBaseYn())) {
- regGoods.setBrandCd(extendGoods.getBrandCd());
- regGoods.setItemkindCd(extendGoods.getItemkindCd());
- regGoods.setGoodsNum(extendGoods.getGoodsNum());
- regGoods.setSupplyCompCd(extendGoods.getSupplyCompCd());
- regGoods.setFormalGb(extendGoods.getFormalGb());
- }
- }
- regGoods.setListPrice(listPriceSum);
- regGoods.setCurrPrice(currPriceSum);
- regGoods.setCostPrice(0); // 원가 0원처리
- regGoods.setDcRate((int)(this.getDcRate(listPriceSum, currPriceSum)));
- this.createGoodsExtend(regGoods, goodsComposeList); // 세트상품 관련 정보 저장
- }
- /**
- * 세트/딜 상품 관련 저장
- *
- * @param goods
- * @return
- * @author eskim
- * @since 2020. 10. 30
- */
- private void createGoodsExtend(Goods regGoods, Collection<GoodsCompose> goodsComposeList) {
- // 브랜드 확인
- Brand brand = new Brand();
- brand.setBrandCd(regGoods.getBrandCd());
- brand.setSupplyCompCd(regGoods.getSupplyCompCd());
- Collection<Brand> brandList = businessService.getBrandList(brand);
- if (brandList == null || brandList.isEmpty()) {
- throw new IllegalStateException(message.getMessage("구성상품 중 기준 상품의 브랜드를 확인해 주세요."));
- }
- float pntPrate = 0.0f;
- float pntMrate = 0.0f;
- float sellFeeRate = 0.0f;
- String delvFeeCd = "";
- for (Brand tmpBrand : brandList) {
- if ("10".equals(regGoods.getFormalGb())) {
- pntPrate = tmpBrand.getPntPrate10();
- pntMrate = tmpBrand.getPntMrate10();
- } else {
- pntPrate = tmpBrand.getPntPrate20();
- pntMrate = tmpBrand.getPntMrate20();
- }
- sellFeeRate = tmpBrand.getSellFeeRate();
- delvFeeCd = tmpBrand.getDelvFeeCd();
- }
- regGoods.setDelvFeeCd(delvFeeCd);// 배송비전책코드
- regGoods.setPntPrate(pntPrate); // 포인트적립율(PC)
- regGoods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
- regGoods.setSellFeeRate(sellFeeRate); // 판매수수료율
- regGoods.setSelfGoodsYn("Y");
- // 스타일 연도
- regGoods.setStyleYear(regGoods.getStyleYear());
- goodsDao.createGoods(regGoods); // 상품기본 저장
- goodsDao.createGoodsSmmary(regGoods); // 상품통계 생성
- StringBuilder goodsDescSb = new StringBuilder(); // 상품상세
- int dispOrd = 1;
- for (GoodsCompose regGoodsExtend : goodsComposeList) {
- regGoodsExtend.setDispOrd(dispOrd);
- goodsDao.saveGoodsCompose(regGoodsExtend); // 구성상품기본 저장
- dispOrd++;
- }
- // 사용자 검색어를 검색어에 적용
- String goodsSnm = goodsDao.getGoodsSnm(regGoods.getGoodsCd());
- regGoods.setGoodsSnm(goodsSnm);
- goodsDao.updateGoodsSnm(regGoods);
- // 카테고리 전시
- // 추후 작업 해야함 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- //goodsDao.createCategoryGoods(regGoods);
- }
- // /**
- // * 품 이미지 경로생성
- // *
- // * @param goodsCd
- // * @param brandCd
- // * @return String
- // * @author eskim
- // * @since 2020. 10. 30
- // */
- // private String getGoodsImgPath(String goodsCd, String brandCd) {
- // return "/" + goodsCd.substring(0, 1) + "/" + goodsCd.substring(0, 3) + "/" + goodsCd + "/1000/" + goodsCd + "_";
- // }
- /**
- * 상품 코드 생성
- *
- * @param goodsType - 상품타입
- * @param goodsCdAfter - 상품시퀀스 앞에 붙는명
- * @return
- * @author eskim
- * @since 2020. 10. 30
- */
- public String getGoodsCodeSeq(String goodsType, String goodsCdAfter) {
- //상품코드 12자리
- String goodsCd = "";
- Goods goods = new Goods();
- goodsDao.createGoodsSequence(goods);
- String goodsSeq = GagaStringUtil.getLPadding(Integer.toString(goods.getGoodsSq()), 8, "0");
- if ("S".equals(goodsType) || "D".equals(goodsType)) {
- goodsCd = SELF_GOOODS_AFTER + goodsCdAfter + goodsSeq;
- } else {
- goodsCd = goodsCdAfter + goodsSeq; // 입점 : 브랜드코드
- }
- return goodsCd;
- }
- /**
- * 상품 타이틀 관리 목록 건수
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 11 .02
- */
- public int getGoodsTitleReserveCount(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsTitleReserveCount(goodsSearch);
- }
- /**
- * 상품 타이틀 관리 목록
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 11 .02
- */
- public Collection<GoodsTnmRes> getGoodsTitleReserveList(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsTitleReserveList(goodsSearch);
- }
- /**
- * 상품 타이틀 예약 등록
- *
- * @param goodsTnmRes
- * @author eskim
- * @since 2020. 11 .02
- */
- @Transactional("shopTxnManager")
- public void saveGoodsRsvtTnm(GoodsTnmRes goodsTnmRes) {
- if (goodsTnmRes.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- goodsTnmRes.setGoodsTnm(GagaStringUtil.replace(GagaStringUtil.replace(goodsTnmRes.getGoodsTnm(), "<", "<"), ">", ">"));
- for (String goodsCd : goodsTnmRes.getArrGoodsCd()) {
- goodsTnmRes.setGoodsCd(goodsCd);
- goodsTnmRes.setRegNo(TsaSession.getInfo().getUserNo());
- goodsTnmRes.setUpdNo(TsaSession.getInfo().getUserNo());
- if (goodsDao.getGoodsTnmDupChkCount(goodsTnmRes) > 0) {
- throw new IllegalStateException("이미 등록된 상품 타이틀예약이 등록하려는 예약기간내에 존재합니다. \n(상품코드 : " + goodsCd + ")");
- }
- goodsDao.createGoodTnmRes(goodsTnmRes);
- // 현재일자가 예약기간에 포함되어 있으면 바로 적용한다.
- String toDaytime = GagaDateUtil.getTodayDateTime();
- if (Long.parseLong(toDaytime) >= Long.parseLong(goodsTnmRes.getApplyStdt()) && Long.parseLong(toDaytime) <= Long.parseLong(goodsTnmRes.getApplyEddt())) {
- // 이력생성 및 상품타이틀 수정
- Goods goods = new Goods();
- goods.setGoodsCd(goodsCd);
- goods.setGoodsTnm(goodsTnmRes.getGoodsTnm());
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.createGoodsHst(goods);
- goodsDao.updateGoodTnm(goods);
- }
- }
- }
- /**
- * 상품 타이틀 예약 삭제
- *
- * @param goodsTnmRes
- * @author eskim
- * @since 2020. 11 .02
- */
- @Transactional("shopTxnManager")
- public void deleteGoodsRsvtTnm(GoodsTnmRes goodsTnmRes) {
- if (goodsTnmRes.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int idx = 0;
- for (String goodsCd : goodsTnmRes.getArrGoodsCd()) {
- // 상품 타이틀 예약 삭제
- goodsTnmRes.setGoodsTnmResSq(goodsTnmRes.getArrGoodsTnmResSq()[idx]);
- goodsDao.deleteGoodTnmRes(goodsTnmRes);
- // 상품 타이틀 예약건 초기화
- Goods goods = new Goods();
- goods.setGoodsCd(goodsCd);
- goods = goodsDao.getGoodTnmInit(goods);
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- if (!StringUtils.isEmpty(goods.getGoodsTnm()) && !goods.getGoodsTnm().equals(goods.getGoodTnmInit())) {
- // 상품이력 먼저 쌓기
- goodsDao.createGoodsHst(goods);
- // 정보수정
- goods.setGoodsTnm(goods.getGoodTnmInit());
- goodsDao.updateGoodTnm(goods);
- }
- idx++;
- }
- }
- /**
- * 네이버 EP 제외 상품 목록 건수
- *
- * @param goodsSearch
- * @return int
- * @author eskim
- * @since 2020. 11. 03
- */
- public int getGoodsEpSkipCount(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsEpSkipCount(goodsSearch);
- }
- /**
- * 네이버 EP 제외 상품 목록
- *
- * @param goodsSearch
- * @return Collection<TsaGoodsEpSkip>
- * @author eskim
- * @since 2020. 11. 03
- */
- public Collection<GoodsEpSkip> getGoodsEpSkipList(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsEpSkipList(goodsSearch);
- }
- /**
- * 네이버 EP 제외 상품 예약 등록
- *
- * @param goodsEpSkip
- * @return void
- * @author eskim
- * @since 2020. 11. 03
- */
- @Transactional("shopTxnManager")
- public void saveGoodsRsvtEpSkip(GoodsEpSkip goodsEpSkip) {
- if (goodsEpSkip.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- for (String goodsCd : goodsEpSkip.getArrGoodsCd()) {
- goodsEpSkip.setGoodsCd(goodsCd);
- goodsEpSkip.setRegNo(TsaSession.getInfo().getUserNo());
- goodsEpSkip.setUpdNo(TsaSession.getInfo().getUserNo());
- if (goodsDao.getGoodsEpSkipDupChkCount(goodsEpSkip) > 0) {
- throw new IllegalStateException("비노출예약이 중복된 상품이 존재합니다.<br/>(상품코드 : " + goodsCd + ")");
- }
- goodsDao.createGoodEpSkip(goodsEpSkip);
- }
- }
- /**
- * 네이버 EP 제외 상품 예약 삭제
- *
- * @param goodsEpSkip
- * @return void
- * @author eskim
- * @since 2020. 11. 03
- */
- @Transactional("shopTxnManager")
- public void deleteGoodsEpSkip(GoodsEpSkip goodsEpSkip) {
- if (goodsEpSkip.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int idx = 0;
- for (String goodsCd : goodsEpSkip.getArrGoodsCd()) {
- goodsEpSkip.setGoodsEpSkipSq(goodsEpSkip.getArrGoodsEpSkipSq()[idx]);
- goodsDao.deleteGoodEpSkip(goodsEpSkip);
- idx++;
- }
- }
- /**
- * 상품예약판매 목록 건수
- *
- * @param goodsSearch
- * @return Integer
- * @author eskim
- * @since 2020. 11. 12
- */
- public int getGoodsResSellCount(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsResSellCount(goodsSearch);
- }
- /**
- * 상품예약판매 목록
- *
- * @param goodsSearch
- * @return Collection<TsaGoodsResSell>
- * @author eskim
- * @since 2020. 11. 12
- */
- public Collection<GoodsResSell> getGoodsResSellList(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsResSellList(goodsSearch);
- }
- /**
- * 상품예약판매 등록
- *
- * @param goodsResSell
- * @return void
- * @author eskim
- * @since 2020. 11. 12
- */
- @Transactional("shopTxnManager")
- public void saveGoodsResSell(GoodsResSell goodsResSell) {
- if (goodsResSell.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- for (String goodsCd : goodsResSell.getArrGoodsCd()) {
- goodsResSell.setGoodsCd(goodsCd);
- goodsResSell.setRegNo(TsaSession.getInfo().getUserNo());
- goodsResSell.setUpdNo(TsaSession.getInfo().getUserNo());
- if(goodsDao.getGoodsResSellDupChkCount(goodsResSell) > 0 ) {
- throw new IllegalStateException("이미 등록된 상품예약판매가 존재합니다. \n(상품코드 : " + goodsCd + ")");
- }
- goodsDao.createGoodResSell(goodsResSell);
- Goods goods = new Goods();
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- goods.setGoodsCd(goodsResSell.getGoodsCd());
- // 재고연동 비활성화
- goodsDao.createGoodsHst(goods);
- goodsDao.updateGoodsErpStockLinkYn(goods);
- }
- }
- /**
- * 상품예약판매 삭제
- *
- * @param goodsResSell
- * @return void
- * @author eskim
- * @since 2020. 11. 12
- */
- @Transactional("shopTxnManager")
- public void deleteGoodsResSell(GoodsResSell goodsResSell) {
- if (goodsResSell.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int idx = 0;
- for (String goodsCd : goodsResSell.getArrGoodsCd()) {
- goodsResSell.setGoodsResSellSq(goodsResSell.getArrGoodsResSellSq()[idx]);
- goodsDao.deleteGoodResSell(goodsResSell);
- idx++;
- }
- }
- /**
- * 상품 상세공지 목록
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 11. 05
- */
- public Collection<Notice> getNoticeList(GoodsSearch goodsSearch) {
- return goodsDao.getNoticeList(goodsSearch);
- }
- /**
- * 상품 상세공지 상품 목록
- *
- * @param notice
- * @return
- * @author eskim
- * @since 2020. 11. 06
- */
- public Collection<NoticeGoods> getNoticeGoodsList(Notice notice) {
- return goodsDao.getNoticeGoodsList(notice);
- }
- /**
- * 공지사항 저장
- * @param notice - 공지사항 정보
- * @return
- * @author eskim
- * @since 2020. 11. 05
- */
- @Transactional("shopTxnManager")
- public void saveNotice(Notice notice) {
- notice.setRegNo(TsaSession.getInfo().getUserNo());
- notice.setUpdNo(TsaSession.getInfo().getUserNo());
- // 신규 일때
- if (notice.getNoticeSq() == null) {
- // 공지사항 저장
- noticeService.createNotice(notice);
- // 등록된 사용자번호 값 가져오기
- Integer noticeSq = notice.getNoticeSq();
- notice.setNoticeSq(noticeSq);
- } else {
- // 공지사항 수정
- noticeService.updateNotice(notice);
- }
- if (!StringUtils.isEmpty(notice.getGoodsList())) {
- Collection<NoticeGoods> noticeGoodsList = null;
- try {
- noticeGoodsList = mapper.readValue(notice.getGoodsList(), new TypeReference<Collection<NoticeGoods>>() {
- });
- } catch (Exception e) {
- e.printStackTrace();
- throw new IllegalStateException(message.getMessage("상품상세공지 저장 중 오류로 인해 저장되지 않았습니다."));
- }
- log.info("noticeGoodsList: {}", noticeGoodsList);
- for (NoticeGoods noticeGoods : noticeGoodsList) {
- noticeGoods.setNoticeSq(notice.getNoticeSq());
- noticeGoods.setRegNo(TsaSession.getInfo().getUserNo());
- noticeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveNoticeGoods(noticeGoods);
- }
- }
- }
- /**
- * 공지사항 상품 삭제
- * @param noticeGoods
- * @return
- * @author eskim
- * @since 2020. 11. 06
- */
- @Transactional("shopTxnManager")
- public void deleteNoticeGoods(NoticeGoods noticeGoods) {
- if (noticeGoods == null || (noticeGoods.getArrGoodsCd() == null && noticeGoods.getArrGoodsCd().length <= 0)) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- if (noticeGoods.getArrGoodsCd().length > 0) {
- for (String goodsCd : noticeGoods.getArrGoodsCd()) {
- noticeGoods.setGoodsCd(goodsCd);
- noticeGoods.setRegNo(TsaSession.getInfo().getUserNo());
- noticeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.deleteNoticeGoods(noticeGoods);
- }
- }
- }
- /**
- * 상품 가격예약 목록 건수
- *
- * @param goodsSearch
- * @return Integer
- * @author eskim
- * @since 2020. 11. 13
- */
- public int getGoodsPriceResCount(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsPriceResCount(goodsSearch);
- }
- /**
- * 상품 가격예약 목록
- *
- * @param goodsSearch
- * @return Collection<TsaGoodsResSell>
- * @author eskim
- * @since 2020. 11. 13
- */
- public Collection<GoodsPriceRes> getGoodsPriceResList(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsPriceResList(goodsSearch);
- }
- /**
- * 상품 가격예약 등록
- *
- * @param goodsPriceRes
- * @return void
- * @author eskim
- * @since 2020. 11. 13
- */
- @Transactional("shopTxnManager")
- public void createGoodPriceRes(GoodsPriceRes goodsPriceRes) {
- if (goodsPriceRes.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int idx = 0;
- for (String goodsCd : goodsPriceRes.getArrGoodsCd()) {
- goodsPriceRes.setGoodsCd(goodsCd);
- goodsPriceRes.setEndGoodsPrice(goodsPriceRes.getArrEndGoodsPrice()[idx]);
- goodsPriceRes.setRegNo(TsaSession.getInfo().getUserNo());
- goodsPriceRes.setUpdNo(TsaSession.getInfo().getUserNo());
- if(goodsDao.getGoodsPriceResDupChkCount(goodsPriceRes) > 0 ) {
- throw new IllegalStateException("이미 등록된 상품 가격예약이 존재합니다. \n(상품코드 : " + goodsCd + ")");
- }
- goodsDao.createGoodPriceRes(goodsPriceRes);
- Goods goods = new Goods();
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- goods.setGoodsCd(goodsPriceRes.getGoodsCd());
- idx++;
- }
- }
- /**
- * 상품 가격예약 삭제
- *
- * @param goodsPriceRes
- * @return void
- * @author eskim
- * @since 2020. 11. 13
- */
- @Transactional("shopTxnManager")
- public void deleteGoodsPriceRes(GoodsPriceRes goodsPriceRes) {
- if (goodsPriceRes.getArrGoodsCd().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int idx = 0;
- for (String goodsCd : goodsPriceRes.getArrGoodsCd()) {
- goodsPriceRes.setGoodsPriceResSq(goodsPriceRes.getArrGoodsPriceResSq()[idx]);
- goodsDao.deleteGoodPriceRes(goodsPriceRes);
- idx++;
- }
- }
- /**
- * 상품 가격예약 저장
- *
- * @param goodsPriceList
- * @return
- * @author eskim
- * @since 2020. 11. 16
- */
- @Transactional("shopTxnManager")
- public void saveGoodsPriceExcelupload(Collection<GoodsPriceRes> goodsPriceList, String excelFilename) {
- String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
- if (goodsPriceList == null || goodsPriceList.isEmpty()) {
- this.deleteExceluploadFile(targetPath, excelFilename);
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- // 입력값 확인
- String goodsPriceResvCheck = getGoodsPriceResvCheck(goodsPriceList);
- if (!"SUCC".equals(goodsPriceResvCheck)) {
- this.deleteExceluploadFile(targetPath, excelFilename);
- throw new IllegalStateException(goodsPriceResvCheck);
- }
- int index = 0;
- for (GoodsPriceRes goodsPriceRes : goodsPriceList) {
- goodsPriceRes.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsPriceRes.setRegNo(TsaSession.getInfo().getUserNo());
- //예약일시 시분 설정
- goodsPriceRes.setApplyStdt(goodsPriceRes.getApplyStdt() + "0000");
- goodsPriceRes.setApplyEddt(goodsPriceRes.getApplyEddt() + "5959");
- // 엑셀조회를 위한 SEARCH 테이블 생성
- SearchData searchData = new SearchData();
- searchData.setRegNo(goodsPriceRes.getRegNo());
- searchData.setSearchCd(goodsPriceRes.getGoodsCd());
- searchData.setDispOrd(index);
- if (index == 0) {
- commonService.deleteExceluploadSearCh(searchData);
- }
- commonService.createExceluploadSearch(searchData);
- goodsDao.createGoodPriceRes(goodsPriceRes);
- index++;
- }
- }
- /*
- * 상품 가격예약 엑셀조회용 상품 저장 - 입력값 확인
- */
- private String getGoodsPriceResvCheck(Collection<GoodsPriceRes> goodsPriceList) {
- int cnt = 0;
- for (GoodsPriceRes goodsPriceRes : goodsPriceList) {
- if (StringUtils.isEmpty(goodsPriceRes.getGoodsCd())) {
- return (cnt + 2) + "행의 상품코드를 확인해주세요";
- }
- if (StringUtils.isEmpty(goodsPriceRes.getResGoodsPrice())) {
- return (cnt + 2) + "행의 예약가격을 확인해주세요.";
- }
- if (goodsPriceRes.getResGoodsPrice() <= 0) {
- return (cnt + 2) + "행의 예약가격을 확인해주세요.";
- }
- String nowDate = GagaDateUtil.getToday(); //yyyyMMddHH
- SimpleDateFormat dateFormatParser = new SimpleDateFormat("yyyyMMddHH");
- dateFormatParser.setLenient(false);
- try {
- dateFormatParser.parse(goodsPriceRes.getApplyStdt() );
- } catch (Exception e) {
- return (cnt + 2) + "행의 예약시작일시을 확인해주세요.";
- }
- try {
- dateFormatParser.parse(goodsPriceRes.getApplyEddt() );
- } catch (Exception e) {
- return (cnt + 2) + "행의 예약종료일시을 확인해주세요.";
- }
- if (Integer.parseInt(goodsPriceRes.getApplyStdt()) > Integer.parseInt(goodsPriceRes.getApplyEddt())) {
- return (cnt + 2) + "행의 예약 시작일시은 종료일시보다 보다 클 수 없습니다.";
- }
- if (Integer.parseInt(goodsPriceRes.getApplyStdt()) <= Integer.parseInt(nowDate)) {
- return (cnt + 2) + "행의 예약 시작일자는 현재일자 보다 작거나 같을 수 없습니다.";
- }
- //정상가와 비교
- Goods searchGoods = new Goods();
- searchGoods.setGoodsCd(goodsPriceRes.getGoodsCd());
- Goods goods = goodsDao.getGoods(searchGoods);
- if (goods == null) {
- return (cnt + 2) + "행의 상품코드를 확인해주세요";
- }
- if (goods.getListPrice() < goodsPriceRes.getResGoodsPrice()) {
- return (cnt + 2) + "행의 상품 정상가보다 예약판매가가 더 큽니다.";
- }
- if (!"Y".equals(goods.getSelfGoodsYn())) {
- return (cnt + 2) + "행의 상품은 자사상품이 아닙니다.";
- }
- if(goodsDao.getGoodsPriceResDupChkCount(goodsPriceRes) > 0 ) {
- return (cnt + 2) + "행은 이미 등록된 상품 가격예약이 존재합니다. \n(상품코드 : " + goodsPriceRes.getGoodsCd() + ")";
- }
- cnt++;
- }
- return "SUCC";
- }
- /**
- * 상품 동영상 목록 조회
- *
- * @param goodsVideo
- * @return
- * @author eskim
- * @since 2020. 11. 16
- */
- public Collection<GoodsVideo> getGoodsVideoList(GoodsVideo goodsVideo) {
- return goodsDao.getGoodsVideoList(goodsVideo);
- }
- /**
- * 상품 동영상 삭제로 변경
- *
- * @param goodsVideo
- * @return
- * @author eskim
- * @since 2020. 11. 16
- */
- @Transactional("shopTxnManager")
- public void updateNotUseGoodsVideo(Collection<GoodsVideo> goodsVideos) {
- for (GoodsVideo goodsVideo : goodsVideos) {
- Video video = new Video();
- video.setUpdNo(TsaSession.getInfo().getUserNo());
- video.setVideoSq(goodsVideo.getVideoSq());
- goodsDao.updateNotUseGoodsVideo(video);
- }
- }
- /**
- * 상품동영상 수정/저장
- *
- * @param video
- * @return
- * @author eskim
- * @since 2020. 11. 16
- */
- @Transactional("shopTxnManager")
- public void saveGoodsVideo(Video video) {
- video.setRegNo(TsaSession.getInfo().getUserNo());
- video.setUpdNo(TsaSession.getInfo().getUserNo());
- if (video.getVideoSq() == null || video.getVideoSq() == 0) {
- String videoSeq = goodsDao.getVideoSeq(video);
- if (StringUtils.isEmpty(videoSeq)) {
- goodsDao.createVideo(video);
- }else {
- //video.setVideoSq(Integer.parseInt(videoSeq)); //why?
- //goodsDao.updateVideo(video);
- }
- }
- if (video.getVideoSq() == null || video.getVideoSq() == 0) {
- String videoSeq = goodsDao.getVideoSeq(video);
- if (!StringUtils.isEmpty(videoSeq)) {
- video.setVideoSq(Integer.parseInt(videoSeq));
- }
- }
- //goodsDao.delVideoDispLoc(video); why?
- String[] displocValArr = video.getDisplocValArr();
- for (String displocVal : displocValArr) {
- video.setDisplocVal(displocVal);
- goodsDao.saveVideoDispLoc(video);
- }
- }
- /**
- * 상품동영상 엑셀파일 등록
- *
- * @param dataList
- * @return
- * @author eskim
- * @since 2020. 11. 16
- */
- @Transactional("shopTxnManager")
- public int saveExcelGoodsVideo(Collection<GagaMap> dataList) {
- int cnt = 0;
- for (GagaMap map : dataList) {
- Video video = mapper.convertValue(map, Video.class);
- video.setUpdNo(TsaSession.getInfo().getUserNo());
- video.setRegNo(TsaSession.getInfo().getUserNo());
- video.setDisplocGb("G");
- video.setDispYn("Y");
- String videoVal = video.getVideoVal();
- if (videoVal.contains("http")) {
- video.setVideoGb("M");
- } else {
- video.setVideoGb("Y");
- }
- String videoSeq = goodsDao.getVideoSeq(video);
- if (StringUtils.isEmpty(videoSeq)) {
- goodsDao.createVideo(video);
- }
- videoSeq = goodsDao.getVideoSeq(video);
- if (!StringUtils.isEmpty(videoSeq)) {
- video.setVideoSq(Integer.parseInt(videoSeq));
- }
- goodsDao.saveVideoDispLoc(video);
- cnt++;
- }
- return cnt;
- }
- /**
- * 상품별 옵션 등록 여부 확인
- *
- * @param
- * @return
- * @author eskim
- * @since 2020. 11. 17
- */
- public int getGoodsOptionCount(Option option) {
- return goodsDao.getGoodsOptionCount(option);
- }
- /**
- * 상품 가격승인관리 목록 조회
- *
- * @param goodsPriceHst
- * @return
- * @author eskim
- * @since 2020. 11. 26
- */
- public Collection<GoodsPriceRes> getGoodsSupplyPriceList(GoodsPriceRes goodsPriceHst) {
- return goodsDao.getGoodsSupplyPriceList(goodsPriceHst);
- }
- /**
- * 상품 가격승인관리 승인 처리
- *
- * @param goodsPriceHstList - 상품 가격 승인 목록
- * @author eskim
- * @since 2020. 11. 26
- */
- @Transactional("shopTxnManager")
- public void saveGoodsSupplyPrice(Collection<GoodsPriceRes> goodsPriceHstList) {
- for (GoodsPriceRes goodsPriceRes : goodsPriceHstList) {
- goodsPriceRes.setRegNo(TsaSession.getInfo().getUserNo());
- goodsPriceRes.setUpdNo(TsaSession.getInfo().getUserNo());
- Goods goods = new Goods();
- goods.setRegNo(TsaSession.getInfo().getUserNo());
- goods.setUpdNo(TsaSession.getInfo().getUserNo());
- goods.setGoodsCd(goodsPriceRes.getGoodsCd());
- goodsDao.createGoodsHst(goods);
- // 판매가 변경
- if (goodsPriceRes.getResGoodsPrice() > 0) {
- log.info("goodsPriceRes.getTagPrice() ={}", goodsPriceRes.getListPrice());
- log.info("goodsPriceRes.getResGoodsPrice() ={}", goodsPriceRes.getResGoodsPrice());
- goods.setDcRate((int)(this.getDcRate(goodsPriceRes.getListPrice(), goodsPriceRes.getResGoodsPrice())));
- goods.setCurrBprice(goodsPriceRes.getCurrPrice());
- goods.setCurrPrice(goodsPriceRes.getResGoodsPrice());
- goodsDao.updateGoodsPrice(goods);
- }
- // 판매수수료율 변경
- if (goodsPriceRes.getSellFeeRate() != null) {
- goods.setSellFeeRate(goodsPriceRes.getSellFeeRate());
- goodsDao.updateSellFeeRate(goods);
- }
- goodsDao.updateGoodsSupplyPricecfrmDt(goodsPriceRes);
- }
- }
- /**
- * 상품 네이버 최저가 목록
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 12. 08
- */
- public Collection<GoodsNaverLowestPrice> getGoodsNaverPriceList(GoodsSearch goodsSearch) {
- return goodsDao.getGoodsNaverPriceList(goodsSearch);
- }
- /**
- * 상품 네이버 최저가 목록
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 12. 08
- */
- @Transactional("shopTxnManager")
- public Collection<GoodsNaverLowestPrice> saveGoodsNaverPrice(GoodsSearch goodsSearch) {
- // 1. 조회 상품 TB_SEARCH_DATA 담기
- int index = 0;
- for (String goodsCd : goodsSearch.getConditionList()) {
- SearchData searchData = new SearchData();
- searchData.setRegNo(TsaSession.getInfo().getUserNo());
- searchData.setSearchCd(goodsCd);
- if (index == 0) {
- commonService.deleteExceluploadSearCh(searchData);
- }
- commonService.createExceluploadSearch(searchData);
- index++;
- }
- // 2. 일 최초 조회이면 테이블 삭제
- String regYmd = goodsDao.getGoodsNaverLowestPriceReqYmd();
- if (!StringUtils.isEmpty(regYmd) && !regYmd.equals(GagaDateUtil.getToday())) {
- goodsDao.deleteGoodsNaverLowestPrice();
- }
- // 3. 네이버 최저가 조회 저장
- saveGoodsNaverLowestPrice(goodsSearch);
- // 4. 최저가 상품 조회
- goodsSearch.setSearchGb("EXCEL");
- goodsSearch.setRegNo(TsaSession.getInfo().getUserNo()); // 엑셀조회시 로그인 사용자의 엑셀 상품조회시 사용
- return goodsDao.getGoodsNaverPriceList(goodsSearch);
- }
- /**
- * 상품 네이버 최저가 목록
- *
- * @param goodsSearch
- * @return
- * @author eskim
- * @since 2020. 12. 08
- */
- private void saveGoodsNaverLowestPrice(GoodsSearch goodsSearch) {
- for (String goodsCd : goodsSearch.getConditionList()) {
- try {
- log.info("saveGoodsNaverLowestPrice 11 = {}", GagaDateUtil.getTodayDateTime());
- TaskSleeep();
- log.info("saveGoodsNaverLowestPrice 22 = {}", GagaDateUtil.getTodayDateTime());
- NaverLowestPrice naverLowestPrice = naverLowestPriceApi.getLowestPrice(goodsCd);
- log.info("[saveGoodsNaverLowestPrice] naverLowestPrice= {}",naverLowestPrice);
- if (naverLowestPrice != null) {
- GoodsNaverLowestPrice goodsNaverLowestPrice = new GoodsNaverLowestPrice();
- goodsNaverLowestPrice.setReqYmd(GagaDateUtil.getToday());
- goodsNaverLowestPrice.setGoodsCd(goodsCd);
- goodsNaverLowestPrice.setMallNm(naverLowestPrice.getItems().iterator().next().getMallName());
- goodsNaverLowestPrice.setMallLink(naverLowestPrice.getItems().iterator().next().getLink());
- goodsNaverLowestPrice.setLowestPrice(naverLowestPrice.getItems().iterator().next().getLprice());
- goodsNaverLowestPrice.setRegNo(TsaSession.getInfo().getUserNo());
- goodsNaverLowestPrice.setUpdNo(TsaSession.getInfo().getUserNo());
- log.info("[saveGoodsNaverLowestPrice] goodsNaverLowestPrice= {}", goodsNaverLowestPrice);
- goodsDao.saveGoodsNaverLowestPrice(goodsNaverLowestPrice);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- /**
- *
- *
- * @return
- * @author eskim
- * @since 2020. 12. 08
- */
- static void TaskSleeep() {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- /**
- * 광고 키워드 목록
- *
- * @param adKeyword
- * @return
- * @author eskim
- * @since 2020. 12. 15
- */
- public Collection<AdKeyword> getAdKeywordList(AdKeyword adKeyword) {
- return goodsDao.getAdKeywordList(adKeyword);
- }
- /**
- * 광고 키워드 상품 목록
- *
- * @param adKeyword
- * @return
- * @author eskim
- * @since 2020. 12. 15
- */
- public Collection<AdKeywordGoods> getAdKeywordGoodsList(AdKeyword adKeyword) {
- return goodsDao.getAdKeywordGoodsList(adKeyword);
- }
- /**
- * 광고 키워드 저장
- * @param adKeyword
- * @return
- * @author eskim
- * @since 2020. 12. 15
- */
- @Transactional("shopTxnManager")
- public void saveAdKeywordGoods(AdKeyword adKeyword) {
- adKeyword.setRegNo(TsaSession.getInfo().getUserNo());
- adKeyword.setUpdNo(TsaSession.getInfo().getUserNo());
- // 신규 일때
- if (adKeyword.getAdKeywordSq() == null) {
- // 공지사항 저장
- goodsDao.saveAdKeyword(adKeyword);
- // 등록된 사용자번호 값 가져오기
- Integer noticeSq = adKeyword.getAdKeywordSq();
- adKeyword.setAdKeywordSq(noticeSq);
- } else {
- // 공지사항 수정
- goodsDao.saveAdKeyword(adKeyword);
- }
- if (!StringUtils.isEmpty(adKeyword.getGoodsList())) {
- Collection<AdKeywordGoods> adKeywordGoodsList = null;
- try {
- adKeywordGoodsList = mapper.readValue(adKeyword.getGoodsList(), new TypeReference<Collection<AdKeywordGoods>>() {
- });
- } catch (Exception e) {
- e.printStackTrace();
- throw new IllegalStateException(message.getMessage("광고 키워드 저장 중 오류로 인해 저장되지 않았습니다."));
- }
- log.info("adKeywordGoodsList: {}", adKeywordGoodsList);
- int idx = 0;
- for (AdKeywordGoods adKeywordGoods : adKeywordGoodsList) {
- if (idx == 0) goodsDao.deleteAdKeywordGoods(adKeywordGoods); // 전체 상품 삭제
- adKeywordGoods.setAdKeywordSq(adKeyword.getAdKeywordSq());
- adKeywordGoods.setRegNo(TsaSession.getInfo().getUserNo());
- adKeywordGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveAdKeywordGoods(adKeywordGoods);
- idx++;
- }
- }
- }
- /**
- * 광고 키워드 상품 삭제
- * @param adKeywordGoods
- * @return
- * @author eskim
- * @since 2020. 12. 15
- */
- @Transactional("shopTxnManager")
- public void deleteAdKeywordGoods(AdKeywordGoods adKeywordGoods) {
- if (adKeywordGoods == null || (adKeywordGoods.getArrGoodsCd() == null && adKeywordGoods.getArrGoodsCd().length <= 0)) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- if (adKeywordGoods.getArrGoodsCd().length > 0) {
- goodsDao.deleteAdKeywordGoods(adKeywordGoods);
- }
- }
- /**
- * 재입고알림 목록 건수
- *
- * @param goodsSearch
- * @return Integer
- * @author eskim
- * @since 2020. 12. 16
- */
- public int getReinboundInformCount(GoodsSearch goodsSearch) {
- return goodsDao.getReinboundInformCount(goodsSearch);
- }
- /**
- * 재입고알림 목록
- *
- * @param goodsSearch
- * @return Collection<ReinboundInform>
- * @author eskim
- * @since 2020. 12. 16
- */
- public Collection<ReinboundInform> getReinboundInformList(GoodsSearch goodsSearch) {
- return goodsDao.getReinboundInformList(goodsSearch);
- }
- /**
- * 재입고알림 발송 처리
- *
- * @param params
- * @return void
- * @author daehyoung
- * @since 2020. 07 .21
- */
- @Transactional("shopTxnManager")
- public void sendReinboundInform(ReinboundInform reinboundInform) {
- if (reinboundInform.getArrRinbdInfoSq().length <= 0) {
- throw new IllegalStateException(message.getMessage("FAIL_1001"));
- }
- int idx = 0;
- for (String rinbdInfoSq : reinboundInform.getArrRinbdInfoSq()) {
- GoodsSearch goodsSearch = new GoodsSearch();
- goodsSearch.setRinbdInfoSq(Integer.parseInt(rinbdInfoSq));
- Collection<ReinboundInform> list = goodsDao.getReinboundInformList(goodsSearch);
- ReinboundInform oneParam = null;
- if (list.size() == 1) {
- oneParam = list.iterator().next();
- } else {
- continue;
- }
- // 재고체크
- if (oneParam.getCurrStockQty() < 1 || "Y".equals(oneParam.getSoldoutYn())) {
- throw new IllegalStateException(oneParam.getGoodsCd() + "상품( 사이즈 : " + oneParam.getOptCd1() + " )은 가용재고가 없습니다.");
- }
- oneParam.setRegNo(TsaSession.getInfo().getUserNo());
- oneParam.setUpdNo(TsaSession.getInfo().getUserNo());
- // **** 알림톡 발송 start ****
- try {
- log.info("[카카오 알림톡 발송 정보] - 재입고알림 발송: " + oneParam.toString());
- /////////////////////////////////////////////////////
- //kakaoService.sendGoodsRestock(oneParam); //나중에 수정해요 eskim
- /////////////////////////////////////////////////////
- } catch (Exception e) {
- e.getStackTrace();
- throw new IllegalStateException("재입고알림 알림톡 발송을 실패하였습니다.");
- }
- // **** 알림톡 발송 end ****
- // 재입고알림 발송처리
- goodsDao.updateReinboundInform(oneParam);
- idx++;
- }
- }
- /**
- * 상품이미지 목록
- *
- * @param goodsImg
- * @return Collection<GoodsImg>
- * @author eskim
- * @since 2020. 12. 18
- */
- public Collection<GoodsImg> getGoodsImgList(GoodsImg goodsImg) {
- return goodsDao.getGoodsImageList(goodsImg);
- }
- /**
- * 상품이미지 저장 처리
- * @param goodsImgList - 상품이미지 목록
- * @throws AdmBizException
- * @author eskim
- * @since 2020. 12. 21
- */
- @Transactional("shopTxnManager")
- public void saveGoodsImageList(Collection<GoodsImg> goodsImgList){
- int index = 0;
- for (GoodsImg goodsImg : goodsImgList) {
- // 상품이미지 전체 삭제
- if (index++ == 0) {
- goodsDao.deleteGoodsImageTotal(goodsImg);
- }
- if (!goodsImg.getMode().equals("D")) {
- // 상품이미지 등록
- goodsImg.setRegNo(TsaSession.getInfo().getUserNo());
- goodsDao.createGoodsImage(goodsImg);
- }
- }
- }
- /**
- * 사은품 목록
- *
- * @param goodsSearch
- * @return Collection<FreeGoods>
- * @author eskim
- * @since 2020. 12. 28
- */
- public Collection<FreeGoods> getFreeGoodsList(GoodsSearch goodsSearch) {
- return goodsDao.getFreeGoodsList(goodsSearch);
- }
- /**
- * 사은품 정보 수정
- * @param goodsImgList - 상품이미지 목록
- * @throws AdmBizException
- * @author eskim
- * @since 2020. 12. 21
- */
- @Transactional("shopTxnManager")
- public void updateFreeGoods(FreeGoods freeGoods){
- freeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- goodsDao.updateFreeGoods(freeGoods);
- }
- /**
- * WMS입고상품관리 목록 건수
- *
- * @param goodsSearch
- * @return Collection<WmsGoods>
- * @author eskim
- * @since 2021. 01. 04
- */
- public int getGoodsWmsIncomelotListCount(WmsGoods wmsGoods) {
- return goodsDao.getGoodsWmsIncomelotListCount(wmsGoods);
- }
- /**
- * WMS입고상품관리 목록 조회
- *
- * @param goodsSearch
- * @return Collection<WmsGoods>
- * @author eskim
- * @since 2021. 01. 04
- */
- public Collection<WmsGoods> getGoodsWmsIncomelotList(WmsGoods wmsGoods) {
- return goodsDao.getGoodsWmsIncomelotList(wmsGoods);
- }
- /**
- * WMS 입고상품 사은품 등록
- * @param wmsGoodsList
- * @author eskim
- * @since 2021. 01. 05
- */
- @Transactional("shopTxnManager")
- public void saveFreeGoods(Collection<WmsGoods> wmsGoodsList){
- for (WmsGoods wmsGoods: wmsGoodsList) {
- FreeGoods freeGoods = new FreeGoods();
- freeGoods.setProductNo(wmsGoods.getProductNo());
- freeGoods.setProductCode(wmsGoods.getProductCode());
- freeGoods.setGoodsNum(wmsGoods.getModelNo());
- freeGoods.setBrandCd(wmsGoods.getBrandCd());
- freeGoods.setGoodsNm(wmsGoods.getProductName());
- freeGoods.setUseYn("Y");
- freeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- freeGoods.setRegNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveFreeGoods(freeGoods);
- //WMS 상품등록구분
- wmsGoods.setGoodsRegGb("F");
- wmsGoods.setUpdNo(TsaSession.getInfo().getUserNo());
- wmsGoods.setRegNo(TsaSession.getInfo().getUserNo());
- goodsDao.saveGoodsWmsIncomelot(wmsGoods);
- }
- }
- }
|