TsaGoodsService.java 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170
  1. package com.style24.admin.biz.service;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.text.SimpleDateFormat;
  5. import java.util.ArrayList;
  6. import java.util.Collection;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.core.env.Environment;
  10. import org.springframework.stereotype.Service;
  11. import org.springframework.transaction.annotation.Transactional;
  12. import com.fasterxml.jackson.core.type.TypeReference;
  13. import com.fasterxml.jackson.databind.ObjectMapper;
  14. import com.style24.admin.biz.dao.TsaGoodsDao;
  15. import com.style24.admin.support.env.TsaConstants;
  16. import com.style24.admin.support.security.session.TsaSession;
  17. import com.style24.core.biz.service.TscCommonService;
  18. import com.style24.core.biz.thirdparty.NaverLowestPriceApi;
  19. import com.style24.core.biz.thirdparty.SafetyKoreaApi;
  20. import com.style24.core.support.message.TscMessageByLocale;
  21. import com.style24.persistence.domain.AdKeyword;
  22. import com.style24.persistence.domain.AdKeywordGoods;
  23. import com.style24.persistence.domain.Brand;
  24. import com.style24.persistence.domain.Color;
  25. import com.style24.persistence.domain.CommonCode;
  26. import com.style24.persistence.domain.DelvFeePolicy;
  27. import com.style24.persistence.domain.FreeGoods;
  28. import com.style24.persistence.domain.Goods;
  29. import com.style24.persistence.domain.GoodsCategory;
  30. import com.style24.persistence.domain.GoodsCompose;
  31. import com.style24.persistence.domain.GoodsContents;
  32. import com.style24.persistence.domain.GoodsContentsData;
  33. import com.style24.persistence.domain.GoodsDesc;
  34. import com.style24.persistence.domain.GoodsEpSkip;
  35. import com.style24.persistence.domain.GoodsHst;
  36. import com.style24.persistence.domain.GoodsImg;
  37. import com.style24.persistence.domain.GoodsMass;
  38. import com.style24.persistence.domain.GoodsNaverLowestPrice;
  39. import com.style24.persistence.domain.GoodsNotiInfo;
  40. import com.style24.persistence.domain.GoodsPriceRes;
  41. import com.style24.persistence.domain.GoodsResSell;
  42. import com.style24.persistence.domain.GoodsSafeNo;
  43. import com.style24.persistence.domain.GoodsSearch;
  44. import com.style24.persistence.domain.GoodsSupplyPrice;
  45. import com.style24.persistence.domain.GoodsTnmRes;
  46. import com.style24.persistence.domain.GoodsVideo;
  47. import com.style24.persistence.domain.IfIncomelot;
  48. import com.style24.persistence.domain.IfProductSku;
  49. import com.style24.persistence.domain.Itemkind;
  50. import com.style24.persistence.domain.NaverLowestPrice;
  51. import com.style24.persistence.domain.NotiInfo;
  52. import com.style24.persistence.domain.Notice;
  53. import com.style24.persistence.domain.NoticeGoods;
  54. import com.style24.persistence.domain.Option;
  55. import com.style24.persistence.domain.ReinboundInform;
  56. import com.style24.persistence.domain.SearchData;
  57. import com.style24.persistence.domain.SizeInfo;
  58. import com.style24.persistence.domain.SupplyCompany;
  59. import com.style24.persistence.domain.WmsColorMapping;
  60. import com.style24.persistence.domain.WmsGoods;
  61. import com.style24.persistence.domain.WmsSeasonMapping;
  62. import com.style24.persistence.domain.WmsStyleYearMapping;
  63. import io.netty.util.internal.StringUtil;
  64. import lombok.extern.slf4j.Slf4j;
  65. import com.gagaframework.excel.GagaExcelUtil;
  66. import com.gagaframework.excel.env.GagaExcelConstants;
  67. import com.gagaframework.web.parameter.GagaMap;
  68. import com.gagaframework.web.util.GagaDateUtil;
  69. import com.gagaframework.web.util.GagaFileUtil;
  70. import com.gagaframework.web.util.GagaStringUtil;
  71. /**
  72. *상품관리 Service
  73. *
  74. * @author eskim
  75. * @since 2020. 10. 16
  76. */
  77. @Service
  78. @Slf4j
  79. public class TsaGoodsService {
  80. @Autowired
  81. private TscMessageByLocale message;
  82. @Autowired
  83. private Environment env;
  84. @Autowired
  85. private TsaGoodsDao goodsDao;
  86. @Autowired
  87. private TsaBusinessService businessService;
  88. @Autowired
  89. private TsaCommonService commonService;
  90. @Autowired
  91. private TscCommonService tscCommonService;
  92. @Autowired
  93. private TsaNoticeService noticeService;
  94. @Autowired
  95. private TsaDisplayService displayService;
  96. @Autowired
  97. private TsaRendererService rendererService;
  98. @Autowired
  99. private SafetyKoreaApi safetyKoreaApi;
  100. @Autowired
  101. private NaverLowestPriceApi naverLowestPriceApi;
  102. @Autowired
  103. private TsaWmsGoodsService wmsGoodsService;
  104. @Autowired
  105. private ObjectMapper mapper;
  106. private static final String NUMBER_PATTERN = "^[0-9]+$";
  107. private static final String UPDATE_NO_PATTERN = "X";
  108. private static final String SELF_GOOODS_AFTER = "STY";
  109. private static final int EXCEL_ROW_COUNT = 500;
  110. /**
  111. * 상품 할인율 계산
  112. *
  113. * @param value
  114. * @param len
  115. * @param pad
  116. * @return
  117. */
  118. private long getDcRate(int listPrice, int currPrice) {
  119. double rate = (double)(currPrice) / (double)(listPrice);
  120. return 100 - (long)((Math.round(rate * 100) / 100.0) * 100);
  121. }
  122. /**
  123. * 품목 목록
  124. * @param itemkind
  125. * @return
  126. * @author eskim
  127. * @since 2020. 10. 16
  128. */
  129. public Collection<Itemkind> getItemkindList(Itemkind itemkind) {
  130. return goodsDao.getItemkindList(itemkind);
  131. }
  132. /**
  133. * 품목 저장
  134. *
  135. * @param itemkindList - 품목 정보 목록
  136. * @author eskim
  137. * @since 2020. 10. 16
  138. */
  139. @Transactional("shopTxnManager")
  140. public void saveItemkindInfo(Collection<Itemkind> itemkindList) {
  141. for (Itemkind itemkind : itemkindList) {
  142. itemkind.setRegNo(TsaSession.getInfo().getUserNo());
  143. itemkind.setUpdNo(TsaSession.getInfo().getUserNo());
  144. // itemkind.setItemkindNm(GagaStringUtil.replace(GagaStringUtil.replace(itemkind.getItemkindNm(), "&lt;", "<"), "&gt;", ">"));
  145. //itemkind.setItemkindEnm(GagaStringUtil.replace(GagaStringUtil.replace(itemkind.getItemkindEnm(), "&lt;", "<"),"&gt;", ">"));
  146. goodsDao.saveItemkindInfo(itemkind);
  147. }
  148. }
  149. /**
  150. * 품목 삭제
  151. *
  152. * @param itemkindList - 품목 정보 목록
  153. * @author eskim
  154. * @since 2020. 10. 16
  155. */
  156. @Transactional("shopTxnManager")
  157. public void deleteItemkindInfo(Collection<Itemkind> itemkindList) {
  158. for (Itemkind itemkind : itemkindList) {
  159. goodsDao.deleteItemkindInfo(itemkind);
  160. }
  161. }
  162. /**
  163. * 색상목록 조회
  164. *
  165. * @param color
  166. * @return
  167. * @author eskim
  168. * @since 2020. 10. 16
  169. */
  170. public Collection<Color> getColorList(Color color) {
  171. return goodsDao.getColorList(color);
  172. }
  173. /**
  174. * 색상 저장
  175. *
  176. * @param colorList
  177. * @return
  178. * @author eskim
  179. * @since 2020. 10. 16
  180. */
  181. @Transactional("shopTxnManager")
  182. public void saveColor(Collection<Color> colorList) {
  183. for (Color color : colorList) {
  184. color.setRegNo(TsaSession.getInfo().getUserNo());
  185. color.setUpdNo(TsaSession.getInfo().getUserNo());
  186. goodsDao.saveColor(color);
  187. }
  188. }
  189. /**
  190. * 상품정보고시 목록
  191. *
  192. * @param notiInfo
  193. * @return
  194. * @author eskim
  195. * @since 2010. 10. 19
  196. */
  197. public Collection<NotiInfo> getNotiInfoList(NotiInfo notiInfo) {
  198. return goodsDao.getNotiInfoList(notiInfo);
  199. }
  200. /**
  201. * 상품정보고시 항목 목록
  202. *
  203. * @param notiInfo
  204. * @return
  205. * @author eskim
  206. * @since 2010. 10. 19
  207. */
  208. public Collection<NotiInfo> getNotiInfoItemList(NotiInfo notiInfo) {
  209. return goodsDao.getNotiInfoItemList(notiInfo);
  210. }
  211. /**
  212. * 상품정보고시 항목 저장
  213. *
  214. * @param notiInfoList
  215. * @return
  216. * @author eskim
  217. * @since 2010. 10. 19
  218. */
  219. @Transactional("shopTxnManager")
  220. public void saveNotiInfoItem(Collection<NotiInfo> notiInfoList) {
  221. if (notiInfoList == null || notiInfoList.isEmpty()) {
  222. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  223. }
  224. for (NotiInfo notiInfo : notiInfoList) {
  225. if (!StringUtils.isBlank(notiInfo.getNiContent())) {
  226. // notiInfo.setNiContent(GagaStringUtil.replace(GagaStringUtil.replace(notiInfo.getNiContent(), "&lt;", "<"), "&gt;", ">"));
  227. }
  228. notiInfo.setRegNo(TsaSession.getInfo().getUserNo());
  229. notiInfo.setUpdNo(TsaSession.getInfo().getUserNo());
  230. goodsDao.saveNotiInfo(notiInfo);
  231. }
  232. }
  233. /**
  234. * WMS 색상 매핑목록 조회
  235. *
  236. * @param color
  237. * @return
  238. * @author eskim
  239. * @since 2020. 10. 16
  240. */
  241. public Collection<WmsColorMapping> getWmsColorMappingList(WmsColorMapping wmsColorMapping) {
  242. return goodsDao.getWmsColorMappingList(wmsColorMapping);
  243. }
  244. /**
  245. * WMS 색상 매핑 저장
  246. *
  247. * @param colorList
  248. * @return
  249. * @author eskim
  250. * @since 2020. 10. 16
  251. */
  252. @Transactional("shopTxnManager")
  253. public void saveWmsColorMapping(Collection<WmsColorMapping> wmsColorMappingList) {
  254. for (WmsColorMapping wmsColorMapping : wmsColorMappingList) {
  255. wmsColorMapping.setRegNo(TsaSession.getInfo().getUserNo());
  256. wmsColorMapping.setUpdNo(TsaSession.getInfo().getUserNo());
  257. goodsDao.saveWmsColorMapping(wmsColorMapping);
  258. }
  259. }
  260. /**
  261. * WMS 스타일년도 매핑목록 조회
  262. *
  263. * @param wmsStyleYearMapping
  264. * @return
  265. * @author eskim
  266. * @since 2020. 11. 13
  267. */
  268. public Collection<WmsStyleYearMapping> getWmsStyleYearMappingList(WmsStyleYearMapping wmsStyleYearMapping) {
  269. return goodsDao.getWmsStyleYearMappingList(wmsStyleYearMapping);
  270. }
  271. /**
  272. * WMS 스타일년도 매핑 저장
  273. *
  274. * @param wmsStyleYearMappingList
  275. * @return
  276. * @author eskim
  277. * @since 2020. 11. 13
  278. */
  279. @Transactional("shopTxnManager")
  280. public void saveWmsStyleYearMapping(Collection<WmsStyleYearMapping> wmsStyleYearMappingList) {
  281. for (WmsStyleYearMapping wmsStyleYearMapping : wmsStyleYearMappingList) {
  282. wmsStyleYearMapping.setRegNo(TsaSession.getInfo().getUserNo());
  283. wmsStyleYearMapping.setUpdNo(TsaSession.getInfo().getUserNo());
  284. goodsDao.saveWmsStyleYearMapping(wmsStyleYearMapping);
  285. }
  286. }
  287. /**
  288. * WMS 시즌 매핑목록 조회
  289. *
  290. * @param wmsSeasonMapping
  291. * @return
  292. * @author eskim
  293. * @since 2020. 11. 13
  294. */
  295. public Collection<WmsSeasonMapping> getWmsSeasonMappingList(WmsSeasonMapping wmsSeasonMapping) {
  296. return goodsDao.getWmsSeasonMappingList(wmsSeasonMapping);
  297. }
  298. /**
  299. * WMS 시즌 매핑 저장
  300. *
  301. * @param wmsSeasonMappingList
  302. * @return
  303. * @author eskim
  304. * @since 2020. 11. 13
  305. */
  306. @Transactional("shopTxnManager")
  307. public void saveWmsSeasonMapping(Collection<WmsSeasonMapping> wmsSeasonMappingList) {
  308. for (WmsSeasonMapping wmsSeasonMapping : wmsSeasonMappingList) {
  309. wmsSeasonMapping.setRegNo(TsaSession.getInfo().getUserNo());
  310. wmsSeasonMapping.setUpdNo(TsaSession.getInfo().getUserNo());
  311. goodsDao.saveWmsSeasonMapping(wmsSeasonMapping);
  312. }
  313. }
  314. /**
  315. * 상품 목록 건수
  316. *
  317. * @param goodsSearch
  318. * @return
  319. * @author eskim
  320. * @since 2020. 10. 20
  321. */
  322. public int getGoodsListCount(GoodsSearch goodsSearch) {
  323. return goodsDao.getGoodsListCount(goodsSearch);
  324. }
  325. /**
  326. * 상품 목록
  327. *
  328. * @param goodsSearch
  329. * @return
  330. * @author eskim
  331. * @since 2020. 10. 20
  332. */
  333. public Collection<Goods> getGoodsList(GoodsSearch goodsSearch) {
  334. return goodsDao.getGoodsList(goodsSearch);
  335. }
  336. /**
  337. * 상품목록 - 기본정보 엑셀다운로드
  338. *
  339. * @param goodsSearch
  340. * @param excelFilenameWithPath - 경로를 포함한 엑셀파일명
  341. * @return
  342. * @author eskim
  343. * @since 2020. 10. 21
  344. */
  345. public void getGoodsInfoExcelList(GoodsSearch goodsSearch, String excelFilenameWithPath) {
  346. if ("Y".equals(goodsSearch.getImageViewYn())) {
  347. // 헤더 title 설정
  348. String[] listTitles = {"이미지", "상품코드", "업체명", "브랜드명", "상품명", "품목", "전시재고", "상품상태", "스타일년도", "시즌",
  349. "정상가", "판매가", "자사즉시할인가", "가격변경일", "ERP재고연동여부", "정상이월구분", "반품가능 여부"};
  350. // DB 처리 시 사용되는 파라미터명(셀명) 설정
  351. String[] cellNames = {"SYS_IMG_NM", "GOODS_CD", "SUPPLY_COMP_CD", "BRAND_ENM", "GOODS_NM", "ITEMKIND_NM",
  352. "STOCK_QTY_SUM", "GOODS_STAT", "STYLE_YEAR", "SEASON_CD", "LIST_PRICE", "CURR_PRICE",
  353. "BENEFIT_PRICE", "PRICE_UPD_DT", "ERP_STOCK_LINK_YN", "FORMAL_GB", "RETURNABLE_YN"};
  354. String[] cellTypes = {GagaExcelConstants.CellType.IMAGE.name(),
  355. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  356. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  357. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  358. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  359. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  360. GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  361. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  362. GagaExcelConstants.CellType.CHAR_CENTER.name(),
  363. GagaExcelConstants.CellType.CHAR_CENTER.name()};
  364. String targetPath = env.getProperty("upload.goods.view");
  365. Collection<GagaMap> dataList = goodsDao.getGoodsInfoExcelList(goodsSearch); // map형식으로 조회
  366. if (dataList != null && !dataList.isEmpty()) {
  367. for (GagaMap gagaMap : dataList) {
  368. if (!StringUtils.isBlank(gagaMap.get("SYS_IMG_NM").toString())) {
  369. gagaMap.set("SYS_IMG_NM", targetPath + '/' + gagaMap.get("SYS_IMG_NM").toString() + "?RS=60");
  370. }
  371. }
  372. }
  373. try {
  374. GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 정보", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
  375. } catch (Exception e) {
  376. throw new IllegalStateException(e);
  377. }
  378. } else {
  379. // 헤더 title 설정
  380. String[] listTitles = {"상품코드", "업체명", "브랜드명", "상품명", "품목", "전시재고", "상품상태", "스타일년도", "시즌",
  381. "정상가", "판매가", "자사즉시할인가", "가격변경일", "ERP재고연동여부", "정상이월구분", "반품가능 여부"};
  382. // DB 처리 시 사용되는 파라미터명(셀명) 설정
  383. String[] cellNames = {"GOODS_CD", "SUPPLY_COMP_CD", "BRAND_ENM", "GOODS_NM", "ITEMKIND_NM", "STOCK_QTY_SUM", "GOODS_STAT", "STYLE_YEAR",
  384. "SEASON_CD", "LIST_PRICE", "CURR_PRICE", "BENEFIT_PRICE", "PRICE_UPD_DT", "ERP_STOCK_LINK_YN", "FORMAL_GB", "RETURNABLE_YN"};
  385. String[] cellTypes = {
  386. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  387. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  388. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  389. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  390. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  391. GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  392. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  393. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name()};
  394. Collection<GagaMap> dataList = goodsDao.getGoodsInfoExcelList(goodsSearch);
  395. try {
  396. GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 정보", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
  397. } catch (Exception e) {
  398. throw new IllegalStateException(e);
  399. }
  400. }
  401. }
  402. /**
  403. * 상품 이미지 등록여부 조회
  404. *
  405. * @param goods
  406. * @return
  407. * @author eskim
  408. * @since 2020. 10. 21
  409. */
  410. public Collection<Goods> getGoodsImgsYn(Goods goods) {
  411. return goodsDao.getGoodsImgsYn(goods);
  412. }
  413. /**
  414. * 상품 상세
  415. *
  416. * @param goods
  417. * @return
  418. * @author eskim
  419. * @since 2020. 10. 22
  420. */
  421. public Goods getGoods(Goods goods) {
  422. // 상품기본정보
  423. Goods resultGoods = goodsDao.getGoods(goods);
  424. // 상품 상세
  425. this.getGoodsDesc(resultGoods);
  426. return resultGoods;
  427. }
  428. /**
  429. * 상품 상세 조회
  430. *
  431. * @param resultGoods
  432. * @return
  433. * @author eskim
  434. * @since 2020. 10. 22
  435. */
  436. private Goods getGoodsDesc(Goods resultGoods) {
  437. GoodsDesc goods = new GoodsDesc();
  438. goods.setGoodsCd(resultGoods.getGoodsCd());
  439. // 상품 상세 타이틀
  440. goods.setDescGb("10");
  441. String goodsTitlesDesc = this.getGoodsDescList(goods);
  442. resultGoods.setGoodsTitlesDesc(goodsTitlesDesc);
  443. // 상품 상세 내용
  444. goods.setDescGb("20");
  445. String goodsContentsDesc = this.getGoodsDescList(goods);
  446. resultGoods.setGoodsContentsDesc(goodsContentsDesc);
  447. // 상품 상세 특징
  448. goods.setDescGb("30");
  449. String goodsCharacterDesc = this.getGoodsDescList(goods);
  450. resultGoods.setGoodsCharacterDesc(goodsCharacterDesc);
  451. // 상품 상세 pc 상단
  452. goods.setDescGb("40");
  453. String goodsPcTopDesc = this.getGoodsDescList(goods);
  454. resultGoods.setGoodsPcTopDesc(goodsPcTopDesc);
  455. // 상품 상세 pc 하단
  456. goods.setDescGb("50");
  457. String goodsPcDownDesc = this.getGoodsDescList(goods);
  458. resultGoods.setGoodsPcDownDesc(goodsPcDownDesc);
  459. // 상품 상세 mobile 상단
  460. goods.setDescGb("60");
  461. String goodsMobileTopDesc = this.getGoodsDescList(goods);
  462. resultGoods.setGoodsMobileTopDesc(goodsMobileTopDesc);
  463. // 상품 상세 mobile 하단
  464. goods.setDescGb("70");
  465. String goodsMobileDownDesc = this.getGoodsDescList(goods);
  466. resultGoods.setGoodsMobileDownDesc(goodsMobileDownDesc);
  467. // 상품 상세 (as-is)
  468. goods.setDescGb("80");
  469. String goodsDesc = this.getGoodsDescList(goods);
  470. resultGoods.setGoodsDesc(goodsDesc);
  471. return resultGoods;
  472. }
  473. /**
  474. * 상품 상세구분별 컨텐츠 조회
  475. *
  476. * @param goods
  477. * @return
  478. * @author eskim
  479. * @since 2020. 10. 22
  480. */
  481. private String getGoodsDescList(GoodsDesc goodsDesc) {
  482. Collection<GoodsDesc> goodsDescList = goodsDao.getGoodsDescList(goodsDesc);
  483. StringBuilder goodsDescSb = new StringBuilder();
  484. if (goodsDescList != null && !goodsDescList.isEmpty()) {
  485. for (GoodsDesc tmpGoodsDesc : goodsDescList) {
  486. goodsDescSb.append(tmpGoodsDesc.getGoodsDesc());
  487. }
  488. } else {
  489. goodsDescSb.append("");
  490. }
  491. return goodsDescSb.toString();
  492. }
  493. /**
  494. * 상품 정보 이력 조회
  495. *
  496. * @param goods
  497. * @return
  498. * @author eskim
  499. * @since 2019. 12. 12
  500. */
  501. public Collection<GoodsHst> getGoodsHstList(Goods goods) {
  502. return goodsDao.getGoodsHstList(goods);
  503. }
  504. /**
  505. * 상품 옵션 조회
  506. *
  507. * @param goods
  508. * @return
  509. * @author eskim
  510. * @since 2020. 10. 26
  511. */
  512. public Collection<Option> getGoodsSizeList(Goods goods) {
  513. return goodsDao.getGoodsSizeList(goods);
  514. }
  515. /**
  516. * 상품 색상목록 조회
  517. *
  518. * @param goods
  519. * @return
  520. * @author eskim
  521. * @since 2020. 11. 18
  522. */
  523. public Collection<GoodsImg> getGoodsColorList(Goods goods) {
  524. return goodsDao.getGoodsColorList(goods);
  525. }
  526. /**
  527. * 상품 정보고시 조회
  528. *
  529. * @param goods
  530. * @return
  531. * @author eskim
  532. * @since 2020. 10. 22
  533. */
  534. public Collection<GoodsNotiInfo> getGoodsNotiInfoList(GoodsNotiInfo goodsNotiInfo) {
  535. return goodsDao.getGoodsNotiInfoList(goodsNotiInfo);
  536. }
  537. /**
  538. * 상품의 정보고시 항목 목록
  539. *
  540. * @param notiInfo
  541. * @return
  542. * @author eskim
  543. * @since 2020. 11. 18
  544. */
  545. public Collection<NotiInfo> getNotiGoodsInfoList(NotiInfo notiInfo) {
  546. return goodsDao.getNotiGoodsInfoList(notiInfo);
  547. }
  548. /**
  549. * 상품 구매등급 조회
  550. *
  551. * @param goods
  552. * @return
  553. * @author eskim
  554. * @since 2020. 11. 18
  555. */
  556. public Collection<Goods> getGoodsDetailOrderGradeList(Goods goods) {
  557. return goodsDao.getGoodsDetailOrderGradeList(goods);
  558. }
  559. /**
  560. * 상품 안전인증 조회
  561. *
  562. * @param goods
  563. * @return
  564. * @author eskim
  565. * @since 2021. 05. 10
  566. */
  567. public GoodsSafeNo getGoodsDetailSafe(Goods goods) {
  568. return goodsDao.getGoodsDetailSafe(goods);
  569. }
  570. /**
  571. * 구성상품 목록
  572. *
  573. * @param goods
  574. * @return
  575. * @author eskim
  576. * @since 2020. 10. 27
  577. */
  578. public Collection<GoodsCompose> getGoodsDetailComposeList(Goods goods) {
  579. return goodsDao.getGoodsDetailComposeList(goods);
  580. }
  581. /**
  582. * 안전인증번호
  583. *
  584. * @param goods
  585. * @return
  586. * @author eskim
  587. * @since 2020. 12. 07
  588. */
  589. public GagaMap getGoodsDetailCertNum(String goodsCd) {
  590. GagaMap result = new GagaMap();
  591. return result;
  592. }
  593. /**
  594. * 안전인증번호 저장
  595. *
  596. * @param goods
  597. * @return
  598. * @author eskim
  599. * @since 2020. 12. 07
  600. */
  601. @Transactional("shopTxnManager")
  602. public void saveGoodsDetailCertNum(GoodsSafeNo goodsSafeNo) {
  603. try {
  604. //인증대상
  605. if ("G083_1".equals(goodsSafeNo.getCertTargetGb())) {
  606. //인증형태 (방송통신, 위해) or 인증타입 - 공급자적합성
  607. if ("G084_4".equals(goodsSafeNo.getCertFormGb()) || "G084_5".equals(goodsSafeNo.getCertFormGb()) || "G081_3".equals(goodsSafeNo.getCertType())) {
  608. goodsSafeNo.setCertDt("");
  609. // goodsSafeNo.setCertNum("");
  610. goodsSafeNo.setCertState("");
  611. goodsSafeNo.setCertDiv("");
  612. goodsSafeNo.setCertOrganName("");
  613. goodsSafeNo.setRegNo(TsaSession.getInfo().getUserNo());
  614. goodsSafeNo.setUpdNo(TsaSession.getInfo().getUserNo());
  615. goodsDao.saveGoodsSafeNo(goodsSafeNo);
  616. } else {
  617. GagaMap result = safetyKoreaApi.getKoreaCertifyDetail(goodsSafeNo.getCertNum());
  618. if (result != null || !StringUtil.isNullOrEmpty(result.get("certNum").toString())) {
  619. goodsSafeNo.setCertDt(result.get("certDt").toString());
  620. goodsSafeNo.setCertState(result.get("certState").toString());
  621. goodsSafeNo.setCertDiv(result.get("certDiv").toString());
  622. goodsSafeNo.setCertOrganName(result.get("certOrganName").toString());
  623. goodsSafeNo.setRegNo(TsaSession.getInfo().getUserNo());
  624. goodsSafeNo.setUpdNo(TsaSession.getInfo().getUserNo());
  625. goodsDao.saveGoodsSafeNo(goodsSafeNo);
  626. } else {
  627. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  628. }
  629. }
  630. } else { //인증대상 그외 - 인증처리 안해도 됨
  631. goodsSafeNo.setCertDt("");
  632. // goodsSafeNo.setCertNum("");
  633. goodsSafeNo.setCertState("");
  634. goodsSafeNo.setCertDiv("");
  635. goodsSafeNo.setCertOrganName("");
  636. goodsSafeNo.setRegNo(TsaSession.getInfo().getUserNo());
  637. goodsSafeNo.setUpdNo(TsaSession.getInfo().getUserNo());
  638. goodsDao.saveGoodsSafeNo(goodsSafeNo);
  639. }
  640. } catch (Exception e) {
  641. e.printStackTrace();
  642. }
  643. }
  644. /**
  645. * 상품 수정 항목 일괄변경
  646. *
  647. * @param goods
  648. * @author eskim
  649. * @since 2020. 01. 17
  650. */
  651. @Transactional("shopTxnManager")
  652. public void updateGoodsState(Goods goods) {
  653. if (goods == null || (goods.getArrGoodsCd() == null && goods.getArrGoodsCd().length <= 0)) {
  654. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  655. }
  656. goods.setRegNo(TsaSession.getInfo().getUserNo());
  657. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  658. if (goods.getArrGoodsCd().length > 0) {
  659. for (String goodsCd : goods.getArrGoodsCd()) {
  660. goods.setGoodsCd(goodsCd);
  661. // 이력생성
  662. goodsDao.createGoodsHst(goods);
  663. if ("formalGb".equals(goods.getProcJob())) {
  664. // 상품브랜드 조회
  665. Goods originGoods = goodsDao.getGoods(goods);
  666. // 브랜드 확인
  667. goods.setPntPrate(originGoods.getPntPrate()); // 포인트적립율(PC)
  668. goods.setPntMrate(originGoods.getPntMrate()); // 포인트적립율(MOBILE)
  669. Brand brand = new Brand();
  670. brand.setBrandCd(originGoods.getBrandCd());
  671. Collection<Brand> brandList = businessService.getBrandList(brand);
  672. if (brandList != null && !brandList.isEmpty()) {
  673. float pntPrate = 0f;
  674. float pntMrate = 0f;
  675. for (Brand tmpBrand : brandList) {
  676. if ("G009_10".equals(goods.getFormalGb())) {
  677. pntPrate = tmpBrand.getPntPrate10();
  678. pntMrate = tmpBrand.getPntMrate10();
  679. } else {
  680. pntPrate = tmpBrand.getPntPrate20();
  681. pntMrate = tmpBrand.getPntMrate20();
  682. }
  683. }
  684. goods.setPntPrate(pntPrate); // 포인트적립율(PC)
  685. goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
  686. }
  687. } else if ("goodsStat".equals(goods.getProcJob())) {
  688. // 상품브랜드 조회
  689. Goods originGoods = goodsDao.getGoods(goods);
  690. // 승인일
  691. if (!goods.getGoodsStat().equals(originGoods.getGoodsStat()) && "G008_90".equals(goods.getGoodsStat())) {
  692. goods.setChGoodsStatYn("Y");
  693. }
  694. }
  695. // 상품정보 변경
  696. goodsDao.updateGoodsState(goods);
  697. }
  698. } else {
  699. // 이력생성
  700. goodsDao.createGoodsHst(goods);
  701. if ("formalGb".equals(goods.getProcJob())) {
  702. // 상품브랜드 조회
  703. Goods originGoods = goodsDao.getGoods(goods);
  704. // 브랜드 확인
  705. goods.setPntPrate(originGoods.getPntPrate()); // 포인트적립율(PC)
  706. goods.setPntMrate(originGoods.getPntMrate()); // 포인트적립율(MOBILE)
  707. Brand brand = new Brand();
  708. brand.setBrandCd(originGoods.getBrandCd());
  709. Collection<Brand> brandList = businessService.getBrandList(brand);
  710. if (brandList != null && !brandList.isEmpty()) {
  711. float pntPrate = 0f;
  712. float pntMrate = 0f;
  713. for (Brand tmpBrand : brandList) {
  714. if ("G009_10".equals(goods.getFormalGb())) {
  715. pntPrate = tmpBrand.getPntPrate10();
  716. pntMrate = tmpBrand.getPntMrate10();
  717. } else {
  718. pntPrate = tmpBrand.getPntPrate20();
  719. pntMrate = tmpBrand.getPntMrate20();
  720. }
  721. }
  722. goods.setPntPrate(pntPrate); // 포인트적립율(PC)
  723. goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
  724. }
  725. }
  726. // 상품정보 변경
  727. goodsDao.updateGoodsState(goods);
  728. }
  729. }
  730. /**
  731. * 엑셀조회용 상품 저장
  732. *
  733. * @param procJob : goodsExcelUpload
  734. * @param goodsList
  735. * @return
  736. * @author eskim
  737. * @since 2020. 10. 22
  738. */
  739. @Transactional("shopTxnManager")
  740. public void saveExceluploadGoods(Collection<Goods> goodsList, String excelFilename) {
  741. String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
  742. if (goodsList == null || goodsList.isEmpty()) {
  743. this.deleteExceluploadFile(targetPath, excelFilename);
  744. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  745. }
  746. //건수
  747. if (goodsList != null && goodsList.size() > EXCEL_ROW_COUNT) {
  748. throw new IllegalStateException("엑셀 파일의 건수를 " + EXCEL_ROW_COUNT + "건 이하로 사용하세요.");
  749. }
  750. int index = 0;
  751. String goodsCdFlag = "";
  752. String goodsNumFlag = "";
  753. for (Goods goods : goodsList) {
  754. SearchData searchData = new SearchData();
  755. searchData.setRegNo(goods.getRegNo());
  756. searchData.setSearchCd(goods.getGoodsCd());
  757. if (index == 0) {
  758. commonService.deleteExceluploadSearCh(searchData);
  759. }
  760. commonService.createExceluploadSearch(searchData);
  761. index++;
  762. }
  763. }
  764. /**
  765. * 파일 삭제
  766. *
  767. * @param targetPath
  768. * @param excelFilename
  769. * @author eskim
  770. * @since 2020. 10. 22
  771. */
  772. private void deleteExceluploadFile(String targetPath, String excelFilename) {
  773. // 파일 삭제
  774. try {
  775. GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(targetPath, excelFilename));
  776. } catch (IOException e) {
  777. // Nothing Do
  778. }
  779. }
  780. /**
  781. * 상품 품목 변경 저장
  782. *
  783. * @param goodsList
  784. * @return
  785. * @author eskim
  786. * @since 2020. 10. 23
  787. */
  788. @Transactional("shopTxnManager")
  789. //@CacheEvict(value = "cate", allEntries = true)
  790. public void saveItemKindChange(Collection<Goods> goodsList) {
  791. for (Goods goods : goodsList) {
  792. goods.setRegNo(TsaSession.getInfo().getUserNo());
  793. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  794. goods.setItemkindCd(goods.getItemkindCd().toUpperCase());
  795. // 품목확인
  796. Itemkind itemkind = new Itemkind();
  797. itemkind.setItemkindCd(goods.getItemkindCd());
  798. itemkind.setUseYn("Y");
  799. Collection<Itemkind> itemkindList = goodsDao.getItemkindList(itemkind);
  800. if (itemkindList == null || itemkindList.isEmpty()) {
  801. throw new IllegalStateException(goods.getGoodsCd() + " 상품의 품목코드를 확인해주세요.");
  802. }
  803. // 상품이력
  804. goodsDao.createGoodsHst(goods);
  805. // 품목변경
  806. goodsDao.updateGoodItemKindCd(goods);
  807. // 검색어 변경
  808. String goodsSnm = goodsDao.getGoodsSnm(goods.getGoodsCd());
  809. Goods tmpGoods = goodsDao.getGoods(goods);
  810. if (tmpGoods != null && !StringUtils.isBlank(tmpGoods.getGoodsSnm1())) {
  811. String[] arrGoodsSnm = tmpGoods.getGoodsSnm1().split("\\;");
  812. StringBuilder tempGoodsSnm = new StringBuilder();
  813. for (String loopGoodsSnm : arrGoodsSnm) {
  814. if (goodsSnm.toUpperCase().indexOf(loopGoodsSnm.toUpperCase()) <= -1) {
  815. tempGoodsSnm.append(loopGoodsSnm).append(";");
  816. }
  817. }
  818. goods.setGoodsSnm(tempGoodsSnm.toString() + goodsSnm);
  819. } else {
  820. goods.setGoodsSnm(goodsSnm);
  821. }
  822. goodsDao.updateGoodsSnm(goods);
  823. //상품 등록후에는 고시정보는 품목과 상관없이 변경처리 가능하게
  824. // Collection<GoodsNotiInfo> goodsNotiInfoList = goodsDao.getNewNotiInfo(goods);
  825. // goodsDao.deleteGoodsNotiInfo(goods);
  826. //
  827. // for (GoodsNotiInfo goodsNotiInfo : goodsNotiInfoList) {
  828. // goodsNotiInfo.setRegNo(TsaSession.getInfo().getUserNo());
  829. // goodsNotiInfo.setUpdNo(TsaSession.getInfo().getUserNo());
  830. // goodsNotiInfo.setGoodsCd(goods.getGoodsCd());
  831. // goodsDao.saveGoodsNotiInfo(goodsNotiInfo);
  832. // }
  833. // 품목변경시 카테고리 전시카테고리 변경
  834. GoodsCategory goodsCategory = new GoodsCategory();
  835. goodsCategory.setRegNo(TsaSession.getInfo().getUserNo());
  836. goodsCategory.setUpdNo(TsaSession.getInfo().getUserNo());
  837. goodsCategory.setGoodsCd(goods.getGoodsCd());
  838. goodsCategory.setCateType("G031_10"); //상품분류카테고리
  839. displayService.deleteGoodsCategory(goodsCategory);
  840. goodsDao.createCategoryGoods(goods);
  841. }
  842. }
  843. /**
  844. * 상품 저장
  845. *
  846. * @param goods
  847. * @return
  848. * @author eskim
  849. * @since 2020. 10. 27
  850. */
  851. @Transactional("shopTxnManager")
  852. public void saveGoodsDetail(Goods goods) {
  853. // <,> replace 처리
  854. goods.setRegNo(TsaSession.getInfo().getUserNo());
  855. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  856. // goods.setGoodsDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsDesc(), "&lt;", "<"), "&gt;", ">"));
  857. // goods.setGoodsPcTopDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsPcTopDesc(), "&lt;", "<"), "&gt;", ">"));
  858. // goods.setGoodsMobileTopDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsMobileTopDesc(), "&lt;", "<"), "&gt;", ">"));
  859. // goods.setGoodsPcDownDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsPcDownDesc(), "&lt;", "<"), "&gt;", ">"));
  860. // goods.setGoodsMobileDownDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsMobileDownDesc(), "&lt;", "<"), "&gt;", ">"));
  861. // goods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "&lt;", "<"), "&gt;", ">"));
  862. // goods.setGoodsTnm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsTnm(), "&lt;", "<"), "&gt;", ">"));
  863. // goods.setGoodsSnm1(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsSnm1(), "&lt;", "<"), "&gt;", ">"));
  864. // 딜상품의 대표상품 변경여부 확인
  865. if ("G056_D".equals(goods.getGoodsType())) {
  866. String newRepGoodsCd = "";
  867. int newRepGoodsPrice = 0;
  868. Collection<GoodsCompose> goodsExtendList = goods.getGoodsComposeListNew();
  869. for (GoodsCompose regGoodsExtend : goodsExtendList) {
  870. if ("Y".equals(regGoodsExtend.getRepYn())) {
  871. newRepGoodsCd = regGoodsExtend.getCompsGoodsCd();
  872. newRepGoodsPrice = regGoodsExtend.getCurrPrice();
  873. }
  874. }
  875. // 1순 : 대표상품 변경, 2순 : 판매가 변경
  876. if (!newRepGoodsCd.equals(goods.getRepGoodsCd())) {
  877. goods.setCurrBprice(goods.getCurrPriceOrg());
  878. goods.setCurrPrice(newRepGoodsPrice);
  879. goods.setListPrice(newRepGoodsPrice);
  880. goods.setDcRate(0);
  881. goods.setChDataYn("Y");
  882. } else {
  883. if (goods.getCurrPrice() != goods.getCurrPriceOrg()) {
  884. goods.setCurrBprice(goods.getCurrPriceOrg());
  885. goods.setListPrice(goods.getCurrPrice());
  886. goods.setDcRate(0);
  887. }
  888. }
  889. } else {
  890. // 가격변경일
  891. if (goods.getCurrPrice() != goods.getCurrPriceOrg()) {
  892. goods.setCurrBprice(goods.getCurrPriceOrg());
  893. } else {
  894. goods.setCurrPrice(goods.getCurrPriceOrg());
  895. }
  896. }
  897. // 승인일
  898. if (!goods.getGoodsStat().equals(goods.getGoodsStatOrg()) && "G008_90".equals(goods.getGoodsStat())) {
  899. goods.setChGoodsStatYn("Y");
  900. }
  901. // 사용자 검색어를 검색어에 적용
  902. String goodsSnm = goodsDao.getGoodsSnm(goods.getGoodsCd());
  903. if (!StringUtils.isBlank(goods.getGoodsSnm1())) {
  904. goods.setGoodsSnm1(GagaStringUtil.replace(goods.getGoodsSnm1(), " ", "")); // 빈값 삭제
  905. String[] arrGoodsSnm = goods.getGoodsSnm1().split("\\;");
  906. StringBuilder tempGoodsSnm = new StringBuilder();
  907. for (String loopGoodsSnm : arrGoodsSnm) {
  908. if (goodsSnm.toUpperCase().indexOf(loopGoodsSnm.toUpperCase()) <= -1) {
  909. tempGoodsSnm.append(loopGoodsSnm).append(";");
  910. }
  911. }
  912. goods.setGoodsSnm(tempGoodsSnm.toString() + goodsSnm);
  913. } else if (!goodsSnm.equals(goods.getGoodsSnm())) {
  914. goods.setGoodsSnm(goodsSnm);
  915. }
  916. goods.setFormalGb(goods.getFormalGb());
  917. // 브랜드 확인
  918. if (!"G056_N".equals(goods.getGoodsType())) {
  919. if (!goods.getFormalGb().equals(goods.getFormalGbOrg())) {
  920. Brand brand = new Brand();
  921. brand.setBrandCd(goods.getBrandCd());
  922. Collection<Brand> brandList = businessService.getBrandList(brand);
  923. if (brandList != null && !brandList.isEmpty()) {
  924. float pntPrate = 0f;
  925. float pntMrate = 0f;
  926. for (Brand tmpBrand : brandList) {
  927. if ("G009_10".equals(goods.getFormalGb())) {
  928. pntPrate = tmpBrand.getPntPrate10();
  929. pntMrate = tmpBrand.getPntMrate10();
  930. } else {
  931. pntPrate = tmpBrand.getPntPrate20();
  932. pntMrate = tmpBrand.getPntMrate20();
  933. }
  934. }
  935. goods.setPntPrate(pntPrate); // 포인트적립율(PC)
  936. goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
  937. }
  938. }
  939. }
  940. // 판매기간설정 eskim
  941. goods.setSellStdt(goods.getSellStYMD().replaceAll("-", "") + goods.getSellStHH() + "0000");
  942. goods.setSellEddt(goods.getSellEdYMD().replaceAll("-", "") + goods.getSellEdHH() + "5959");
  943. // 신규가입기간
  944. if (!StringUtils.isEmpty(goods.getNewCustOrdStdt())) {
  945. goods.setNewCustOrdStdt(goods.getNewCustOrdStdt().replaceAll("-", "") + "000000");
  946. goods.setNewCustOrdEddt(goods.getNewCustOrdEddt().replaceAll("-", "") + "235959");
  947. }
  948. // 기본정보 변경
  949. if ("Y".equals(goods.getChDataYn())) {
  950. goodsDao.createGoodsHst(goods);
  951. goodsDao.updateGoods(goods);
  952. }
  953. // 상품상세정보 변경
  954. if (!"Y".equals(goods.getChkDescKeep())) {
  955. this.saveGoodsDetailDesc(goods);
  956. }
  957. int idx = 1;
  958. // 구성상품 변경
  959. if (!"G056_N".equals(goods.getGoodsType())) {
  960. Collection<GoodsCompose> goodsExtendList = goods.getGoodsComposeListNew();
  961. for (GoodsCompose regGoodsExtend : goodsExtendList) {
  962. regGoodsExtend.setDispOrd(idx);
  963. regGoodsExtend.setRegNo(TsaSession.getInfo().getUserNo());
  964. regGoodsExtend.setUpdNo(TsaSession.getInfo().getUserNo());
  965. goodsDao.saveGoodsCompose(regGoodsExtend); // 구성상품기본 저장
  966. idx++;
  967. }
  968. }
  969. // 옵션/재고 변경
  970. if (goods.getOptCd() != null && goods.getOptCd().length > 0 && "Y".equals(goods.getChStockDataYn())) {
  971. this.saveStock(goods);
  972. }
  973. // 상품 정보고시 변경
  974. this.saveGoodsNotiInfo(goods);
  975. // 안전인증정보
  976. if (!StringUtils.isEmpty(goods.getCertTargetGb())) {
  977. GoodsSafeNo goodsSafeNo = new GoodsSafeNo();
  978. goodsSafeNo.setGoodsCd(goods.getGoodsCd());
  979. goodsSafeNo.setCertFormGb(goods.getCertFormGb());
  980. goodsSafeNo.setCertTargetGb(goods.getCertTargetGb());
  981. goodsSafeNo.setCertType(goods.getCertType());
  982. goodsSafeNo.setCertNum(goods.getCertNum());
  983. log.info("goodsSafeNo ==>{}", goodsSafeNo);
  984. this.saveGoodsDetailCertNum(goodsSafeNo);
  985. }
  986. // 상품 구매등급 적용
  987. if (goods.getGoodsOrderGrade() != null && goods.getGoodsOrderGrade().length > 0) {
  988. Goods goodsOrderGrade = new Goods();
  989. goodsOrderGrade.setGoodsCd(goods.getGoodsCd());
  990. goodsOrderGrade.setRegNo(TsaSession.getInfo().getUserNo());
  991. goodsDao.deleteGoodsCustGrade(goodsOrderGrade);
  992. for (String custGrade : goods.getGoodsOrderGrade()) {
  993. goodsOrderGrade.setCustGrade(custGrade);
  994. goodsDao.createGoodsCustGrade(goodsOrderGrade);
  995. }
  996. } else {
  997. Goods goodsOrderGrade = new Goods();
  998. goodsOrderGrade.setGoodsCd(goods.getGoodsCd());
  999. goodsOrderGrade.setRegNo(TsaSession.getInfo().getUserNo());
  1000. goodsDao.deleteGoodsCustGrade(goodsOrderGrade);
  1001. }
  1002. }
  1003. /**
  1004. * 상품상세정보 변경 - 상품상세
  1005. *
  1006. * @param goods
  1007. * @author eskim
  1008. * @since 2020. 10. 27.
  1009. */
  1010. private void saveGoodsDetailDesc(Goods goods) {
  1011. // 상품상세 구분(10:상품타이틀,20:상품타이틀내용,30:상품특징,40:상위컨텐츠,50:하위컨텐츠,60:하위컨텐츠-모바일,70:상위컨텐츠-모바일,80:상품상세(as-is))
  1012. GoodsDesc goodsDesc = new GoodsDesc();
  1013. goodsDesc.setGoodsCd(goods.getGoodsCd());
  1014. goodsDesc.setRegNo(goods.getRegNo());
  1015. goodsDesc.setUpdNo(goods.getUpdNo());
  1016. // AS-IS 상세 정보 이력 처리
  1017. goodsDao.createGoodsDetailDescHst(goodsDesc);
  1018. // 상세 타이틀
  1019. goodsDesc.setDescGb("10");
  1020. goodsDesc.setGoodsDesc(goods.getGoodsTitlesDesc());
  1021. this.saveGoodsDesc(goodsDesc);
  1022. // 상세 내용
  1023. goodsDesc.setDescGb("20");
  1024. goodsDesc.setGoodsDesc(goods.getGoodsContentsDesc());
  1025. this.saveGoodsDesc(goodsDesc);
  1026. // 상세 특징
  1027. goodsDesc.setDescGb("30");
  1028. goodsDesc.setGoodsDesc(goods.getGoodsCharacterDesc());
  1029. this.saveGoodsDesc(goodsDesc);
  1030. // PC 상단
  1031. goodsDesc.setDescGb("40");
  1032. goodsDesc.setGoodsDesc(goods.getGoodsPcTopDesc());
  1033. this.saveGoodsDesc(goodsDesc);
  1034. // PC 하단
  1035. goodsDesc.setDescGb("50");
  1036. goodsDesc.setGoodsDesc(goods.getGoodsPcDownDesc());
  1037. this.saveGoodsDesc(goodsDesc);
  1038. // MO 상단
  1039. goodsDesc.setDescGb("60");
  1040. goodsDesc.setGoodsDesc(goods.getGoodsMobileTopDesc());
  1041. this.saveGoodsDesc(goodsDesc);
  1042. // MO 하단
  1043. goodsDesc.setDescGb("70");
  1044. goodsDesc.setGoodsDesc(goods.getGoodsMobileDownDesc());
  1045. this.saveGoodsDesc(goodsDesc);
  1046. // 상품상세(as-is,입점
  1047. goodsDesc.setDescGb("80");
  1048. goodsDesc.setGoodsDesc(goods.getGoodsDesc());
  1049. this.saveGoodsDesc(goodsDesc);
  1050. }
  1051. /**
  1052. * 상품 상세 저장
  1053. *
  1054. * @param goodsDesc
  1055. * @return
  1056. * @author eskim
  1057. * @since 2020. 10. 27
  1058. */
  1059. private void saveGoodsDesc(GoodsDesc goodsDesc) {
  1060. goodsDao.deleteGoodsDesc(goodsDesc);
  1061. String[] arrProdHtml = null;
  1062. arrProdHtml = makeArrayToString(goodsDesc.getGoodsDesc(), 3900);
  1063. if (arrProdHtml.length > 0) {
  1064. for (int i = 0; i < arrProdHtml.length; i++) {
  1065. if (!arrProdHtml[i].isEmpty()) {
  1066. goodsDesc.setSeq(i + 1);
  1067. goodsDesc.setGoodsDesc(arrProdHtml[i]);
  1068. goodsDao.createGoodsDesc(goodsDesc);
  1069. }
  1070. }
  1071. }
  1072. }
  1073. /**
  1074. * String => byte array
  1075. *
  1076. * @param raw
  1077. * @param len
  1078. * @return
  1079. * @author eskim
  1080. * @since 2020. 10. 27
  1081. */
  1082. public static String[] makeArrayToString(String raw, int len) {
  1083. String[] ary = null;
  1084. if (raw == null) {
  1085. return ary;
  1086. }
  1087. try {
  1088. // raw 의 byte
  1089. byte[] rawBytes = raw.getBytes("UTF-8"); // MS949
  1090. int rawLength = rawBytes.length;
  1091. if (rawLength > len) {
  1092. int aryLength = (rawLength / len) + (rawLength % len != 0 ? 1 : 0);
  1093. ary = new String[aryLength];
  1094. int endCharIndex = 0; // 문자열이 끝나는 위치
  1095. String tmp;
  1096. for (int i = 0; i < aryLength; i++) {
  1097. if (i == (aryLength - 1)) {
  1098. tmp = raw.substring(endCharIndex);
  1099. } else {
  1100. int useByteLength = 0;
  1101. int rSize = 0;
  1102. for (; endCharIndex < raw.length(); endCharIndex++) {
  1103. if (raw.charAt(endCharIndex) > 0x007F) {
  1104. useByteLength += 3;
  1105. } else {
  1106. useByteLength++;
  1107. }
  1108. if (useByteLength > len) {
  1109. break;
  1110. }
  1111. rSize++;
  1112. }
  1113. tmp = raw.substring((endCharIndex - rSize), endCharIndex);
  1114. }
  1115. ary[i] = tmp;
  1116. }
  1117. } else {
  1118. ary = new String[] {raw};
  1119. }
  1120. } catch (java.io.UnsupportedEncodingException e) {
  1121. }
  1122. return ary;
  1123. }
  1124. /**
  1125. * 옵션/재고 변경 - 상품상세
  1126. *
  1127. * @param goods
  1128. * @param index
  1129. * @author eskim
  1130. * @since 2020. 10. 27
  1131. */
  1132. private void saveStock(Goods goods) {
  1133. int index = 0;
  1134. Option stock = new Option();
  1135. stock.setGoodsCd(goods.getGoodsCd());
  1136. stock.setUpdNo(goods.getUpdNo());
  1137. stock.setRegNo(goods.getRegNo());
  1138. // goodsDao.createStockHst(stock);
  1139. //log.info("saveStock goods={}", goods);
  1140. for (String optCd : goods.getOptCd()) {
  1141. //log.info("saveStock index={}", index);
  1142. //log.info("saveStock optCd={}", optCd);
  1143. Option goodsStock = new Option();
  1144. goodsStock.setGoodsCd(goods.getCompsGoodsCd()[index]); // 구성상품 코드
  1145. goodsStock.setOptCd(optCd);
  1146. goodsStock.setOptCd1(goods.getOptCd1()[index]);
  1147. goodsStock.setOptCd2(goods.getOptCd2()[index]);
  1148. goodsStock.setAddPrice(Integer.parseInt(goods.getAddPrice()[index]));
  1149. goodsStock.setBaseStockQty(Integer.parseInt(goods.getBaseStockQty()[index]));
  1150. goodsStock.setSoldoutYn(goods.getSoldoutYn()[index]);
  1151. goodsStock.setDispOrd(Integer.parseInt(goods.getDispOrd()[index]));
  1152. goodsStock.setDispYn(goods.getDispYn()[index]);
  1153. goodsStock.setRegNo(goods.getRegNo());
  1154. goodsStock.setUpdNo(goods.getUpdNo());
  1155. if ("N".equals(goods.getSelfGoodsYn())) {
  1156. goodsStock.setSelfGoodsYn(goods.getSelfGoodsYn());
  1157. goodsStock.setCurrStockQty(Integer.parseInt(goods.getEditCurrStockQty()[index]));
  1158. goodsStock.setStoreMaxQty(Integer.parseInt(goods.getEditCurrStockQty()[index]));
  1159. }
  1160. goodsDao.createStockHst(goodsStock);
  1161. goodsDao.saveStock(goodsStock);
  1162. index++;
  1163. }
  1164. }
  1165. /**
  1166. * 상품 사이즈 옵션정보 이력 생성
  1167. *
  1168. * @param goods
  1169. * @author eskim
  1170. * @since 2020. 11. 17
  1171. */
  1172. @Transactional("shopTxnManager")
  1173. public void createStockHst(Option option) {
  1174. goodsDao.createStockHst(option);
  1175. }
  1176. /**
  1177. * 상품 정보고시 변경 - 상품상세
  1178. *
  1179. * @param goods
  1180. * @author eskim
  1181. * @since 2020. 10. 27
  1182. */
  1183. private void saveGoodsNotiInfo(Goods goods) {
  1184. int index;
  1185. if (goods.getNotiListNew() != null && !goods.getNotiListNew().isEmpty()) {
  1186. index = 0;
  1187. for (GoodsNotiInfo goodsNotiInfo : goods.getNotiListNew()) {
  1188. if (index == 0) {
  1189. goodsDao.deleteGoodsNotiInfo(goods);
  1190. }
  1191. // goodsNotiInfo.setNiContent(GagaStringUtil.replace(GagaStringUtil.replace(goodsNotiInfo.getNiContent(), "&lt;", "<"), "&gt;", ">"));
  1192. goodsNotiInfo.setRegNo(goods.getRegNo());
  1193. goodsNotiInfo.setUpdNo(goods.getUpdNo());
  1194. goodsDao.saveGoodsNotiInfo(goodsNotiInfo);
  1195. index++;
  1196. }
  1197. }
  1198. }
  1199. /**
  1200. * 딜상품 저장
  1201. *
  1202. * @param goods
  1203. * @return
  1204. * @author eskim
  1205. * @since 2020. 10. 30
  1206. */
  1207. @Transactional("shopTxnManager")
  1208. public void saveGoodsDeal(Goods goods) {
  1209. Goods regGoods = new Goods();
  1210. // <,> replace 처리
  1211. regGoods.setRegNo(TsaSession.getInfo().getUserNo());
  1212. regGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  1213. String goodsCd = this.getGoodsCodeSeq("D", "D");
  1214. regGoods.setGoodsCd(goodsCd);
  1215. regGoods.setSupplyGoodsCd(goodsCd);
  1216. regGoods.setGoodsType("G056_D");
  1217. regGoods.setSupplyCompCd(goods.getSupplyCompCd());
  1218. regGoods.setBrandCd(goods.getBrandCd());
  1219. regGoods.setItemkindCd(goods.getItemkindCd());
  1220. // regGoods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "&lt;", "<"), "&gt;", ">"));
  1221. regGoods.setGoodsNm(goods.getGoodsNm());
  1222. regGoods.setStyleYear(goods.getStyleYear());
  1223. regGoods.setSeasonCd(goods.getSeasonCd());
  1224. regGoods.setSexGb(goods.getSexGb());
  1225. regGoods.setMainColorCd("XX");
  1226. regGoods.setOriginCd(goods.getOriginCd());
  1227. regGoods.setMakeYmd(goods.getMakeYmd());
  1228. regGoods.setSelfMallYn(goods.getSelfMallYn());
  1229. regGoods.setGoodsStat("G008_20"); // 정보부족
  1230. regGoods.setFormalGb("G009_10"); // 정상 기본값 처리
  1231. regGoods.setGoodsGb("G073_11"); // 자사상품은 신규
  1232. //regGoods.setDistributionGb("G065_12"); // 유통구분
  1233. regGoods.setTaxGb("10"); // 과세구분
  1234. regGoods.setTobeFormYn("Y");
  1235. regGoods.setGoodsNum(goodsCd);
  1236. Collection<GoodsCompose> goodsComposeList = null;
  1237. try {
  1238. goodsComposeList = mapper.readValue(goods.getGoodsComposeList(), new TypeReference<Collection<GoodsCompose>>() {
  1239. });
  1240. } catch (Exception e) {
  1241. e.printStackTrace();
  1242. throw new IllegalStateException(message.getMessage("딜상품 저장 중 오류로 인해 저장되지 않았습니다."));
  1243. }
  1244. for (GoodsCompose goodsCompose : goodsComposeList) {
  1245. goodsCompose.setGoodsCd(regGoods.getGoodsCd());
  1246. goodsCompose.setGoodsType(regGoods.getGoodsType());
  1247. goodsCompose.setRegNo(TsaSession.getInfo().getUserNo());
  1248. goodsCompose.setUpdNo(TsaSession.getInfo().getUserNo());
  1249. Goods extendGoods = new Goods();
  1250. extendGoods.setGoodsCd(goodsCompose.getCompsGoodsCd());
  1251. extendGoods = goodsDao.getGoods(extendGoods);
  1252. if (StringUtils.isBlank(extendGoods.getBrandCd())) {
  1253. throw new IllegalStateException(message.getMessage("구성상품 중 " + goodsCompose.getCompsGoodsCd() + " 상품 정보를 확인해 주세요."));
  1254. }
  1255. if ("Y".equals(goodsCompose.getBaseYn())) {
  1256. regGoods.setBrandCd(extendGoods.getBrandCd());
  1257. regGoods.setItemkindCd(extendGoods.getItemkindCd());
  1258. regGoods.setSupplyCompCd(extendGoods.getSupplyCompCd());
  1259. regGoods.setFormalGb(extendGoods.getFormalGb());
  1260. regGoods.setSelfGoodsYn(extendGoods.getSelfGoodsYn());
  1261. regGoods.setDelvLocCd(extendGoods.getDelvLocCd()); //출고처
  1262. }
  1263. if ("Y".equals(goodsCompose.getRepYn())) {
  1264. regGoods.setListPrice(extendGoods.getCurrPrice());
  1265. regGoods.setCurrPrice(extendGoods.getCurrPrice());
  1266. regGoods.setDcRate((int)(this.getDcRate(regGoods.getListPrice(), regGoods.getCurrPrice())));
  1267. }
  1268. }
  1269. this.createGoodsCompose(regGoods, goodsComposeList); // 딜상품 관련 정보 저장
  1270. }
  1271. /**
  1272. * 세트상품 저장
  1273. *
  1274. * @param goods
  1275. * @return
  1276. * @author eskim
  1277. * @since 2020. 11. 04
  1278. */
  1279. @Transactional("shopTxnManager")
  1280. public void saveGoodsSet(Goods goods) {
  1281. Goods regGoods = new Goods();
  1282. // <,> replace 처리
  1283. regGoods.setRegNo(TsaSession.getInfo().getUserNo());
  1284. regGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  1285. String goodsCd = this.getGoodsCodeSeq("S", "S");
  1286. regGoods.setGoodsCd(goodsCd);
  1287. regGoods.setSupplyGoodsCd(goodsCd);
  1288. regGoods.setGoodsType("G056_S");
  1289. regGoods.setSupplyCompCd(goods.getSupplyCompCd());
  1290. regGoods.setBrandCd(goods.getBrandCd());
  1291. regGoods.setItemkindCd(goods.getItemkindCd());
  1292. // regGoods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "&lt;", "<"), "&gt;", ">"));
  1293. regGoods.setGoodsNm(goods.getGoodsNm());
  1294. regGoods.setStyleYear(goods.getStyleYear());
  1295. regGoods.setSeasonCd(goods.getSeasonCd());
  1296. regGoods.setSexGb(goods.getSexGb());
  1297. regGoods.setMainColorCd("XX");
  1298. regGoods.setOriginCd(goods.getOriginCd());
  1299. regGoods.setMakeYmd(goods.getMakeYmd());
  1300. regGoods.setSelfMallYn(goods.getSelfMallYn());
  1301. regGoods.setGoodsStat("G008_20"); // 정보부족
  1302. regGoods.setFormalGb("G009_10"); // 정상 기본값 처리
  1303. regGoods.setGoodsGb("G073_11"); // 자사상품은 신규
  1304. //regGoods.setDistributionGb("G065_12"); // 유통구분
  1305. regGoods.setTaxGb("10"); // 과세구분
  1306. regGoods.setTobeFormYn("Y");
  1307. regGoods.setGoodsNum(goodsCd);
  1308. Collection<GoodsCompose> goodsComposeList = null;
  1309. try {
  1310. goodsComposeList = mapper.readValue(goods.getGoodsComposeList(), new TypeReference<Collection<GoodsCompose>>() {
  1311. });
  1312. } catch (Exception e) {
  1313. throw new IllegalStateException(message.getMessage("세트상품 저장 중 오류로 인해 저장되지 않았습니다."));
  1314. }
  1315. int listPriceSum = 0;
  1316. int currPriceSum = 0;
  1317. for (GoodsCompose goodsCompose : goodsComposeList) {
  1318. goodsCompose.setGoodsCd(regGoods.getGoodsCd());
  1319. goodsCompose.setGoodsType(regGoods.getGoodsType());
  1320. goodsCompose.setRegNo(TsaSession.getInfo().getUserNo());
  1321. goodsCompose.setUpdNo(TsaSession.getInfo().getUserNo());
  1322. Goods extendGoods = new Goods();
  1323. extendGoods.setGoodsCd(goodsCompose.getCompsGoodsCd());
  1324. extendGoods = goodsDao.getGoods(extendGoods);
  1325. if (StringUtils.isBlank(extendGoods.getBrandCd())) {
  1326. throw new IllegalStateException(message.getMessage("구성상품 중 " + goodsCompose.getCompsGoodsCd() + " 상품 정보를 확인해 주세요."));
  1327. }
  1328. listPriceSum += extendGoods.getListPrice() * goodsCompose.getQty();
  1329. currPriceSum += goodsCompose.getCompsCurrPrice(); // 입력값
  1330. if ("Y".equals(goodsCompose.getBaseYn())) {
  1331. regGoods.setBrandCd(extendGoods.getBrandCd());
  1332. regGoods.setItemkindCd(extendGoods.getItemkindCd());
  1333. regGoods.setGoodsNum(extendGoods.getGoodsNum());
  1334. regGoods.setSupplyCompCd(extendGoods.getSupplyCompCd());
  1335. regGoods.setFormalGb(extendGoods.getFormalGb());
  1336. regGoods.setSelfGoodsYn(extendGoods.getSelfGoodsYn());
  1337. regGoods.setDelvLocCd(extendGoods.getDelvLocCd()); //출고처
  1338. }
  1339. }
  1340. regGoods.setListPrice(listPriceSum);
  1341. regGoods.setCurrPrice(currPriceSum);
  1342. regGoods.setCostPrice(0); // 원가 0원처리
  1343. regGoods.setDcRate((int)(this.getDcRate(listPriceSum, currPriceSum)));
  1344. this.createGoodsCompose(regGoods, goodsComposeList); // 세트상품 관련 정보 저장
  1345. }
  1346. /**
  1347. * 세트/딜 상품 관련 저장
  1348. *
  1349. * @param goods
  1350. * @return
  1351. * @author eskim
  1352. * @since 2020. 10. 30
  1353. */
  1354. private void createGoodsCompose(Goods regGoods, Collection<GoodsCompose> goodsComposeList) {
  1355. // 브랜드 확인
  1356. Brand brand = new Brand();
  1357. brand.setBrandCd(regGoods.getBrandCd());
  1358. brand.setSupplyCompCd(regGoods.getSupplyCompCd());
  1359. Collection<Brand> brandList = businessService.getBrandList(brand);
  1360. if (brandList == null || brandList.isEmpty()) {
  1361. throw new IllegalStateException(message.getMessage("구성상품 중 기준 상품의 브랜드를 확인해 주세요."));
  1362. }
  1363. float pntPrate = 0f;
  1364. float pntMrate = 0f;
  1365. String distributionGb = "";
  1366. for (Brand tmpBrand : brandList) {
  1367. if ("G009_10".equals(regGoods.getFormalGb())) {
  1368. pntPrate = tmpBrand.getPntPrate10();
  1369. pntMrate = tmpBrand.getPntMrate10();
  1370. } else {
  1371. pntPrate = tmpBrand.getPntPrate20();
  1372. pntMrate = tmpBrand.getPntMrate20();
  1373. }
  1374. distributionGb = tmpBrand.getDistributionGb(); // 유통구분
  1375. }
  1376. regGoods.setPntPrate(pntPrate); // 포인트적립율(PC)
  1377. regGoods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
  1378. regGoods.setDistributionGb(distributionGb); // 유통구분
  1379. //regGoods.setSelfGoodsYn("Y");
  1380. SupplyCompany supplyCompany = new SupplyCompany();
  1381. supplyCompany.setSupplyCompCd(regGoods.getSupplyCompCd());
  1382. Collection<SupplyCompany> supplyCompanyList = businessService.getSupplyCompanyList(supplyCompany);
  1383. if (supplyCompanyList == null || supplyCompanyList.isEmpty()) {
  1384. throw new IllegalStateException(message.getMessage("구성상품 중 기준 상품의 업체(판매수수율를 확인해 주세요."));
  1385. }
  1386. regGoods.setSellFeeRate(supplyCompanyList.iterator().next().getSellFeeRate()); // 판매수수료율
  1387. DelvFeePolicy delvFeePolicy = new DelvFeePolicy();
  1388. delvFeePolicy.setSupplyCompCd(regGoods.getSupplyCompCd());
  1389. Collection<DelvFeePolicy> deliveryFeePolicyList = businessService.getDeliveryFeePolicyList(delvFeePolicy);
  1390. if (deliveryFeePolicyList == null || deliveryFeePolicyList.isEmpty()) {
  1391. throw new IllegalStateException(message.getMessage("구성상품 중 기준 상품의 업체(배송비정책)를 확인해 주세요."));
  1392. }
  1393. regGoods.setDelvFeeCd(deliveryFeePolicyList.iterator().next().getDelvFeeCd());// 배송비정책코드
  1394. // 스타일 연도
  1395. regGoods.setStyleYear(regGoods.getStyleYear());
  1396. // 판매기간설정
  1397. regGoods.setSellStdt(GagaDateUtil.getToday() + "000000");
  1398. regGoods.setSellEddt("30001231235959");
  1399. regGoods.setTobeFormYn("Y");
  1400. goodsDao.createGoods(regGoods); // 상품기본 저장
  1401. goodsDao.createGoodsSmmary(regGoods); // 상품통계 생성
  1402. StringBuilder goodsDescSb = new StringBuilder(); // 상품상세
  1403. int dispOrd = 1;
  1404. for (GoodsCompose regGoodsExtend : goodsComposeList) {
  1405. regGoodsExtend.setDispOrd(dispOrd);
  1406. goodsDao.saveGoodsCompose(regGoodsExtend); // 구성상품기본 저장
  1407. dispOrd++;
  1408. }
  1409. // 사용자 검색어를 검색어에 적용
  1410. String goodsSnm = goodsDao.getGoodsSnm(regGoods.getGoodsCd());
  1411. regGoods.setGoodsSnm(goodsSnm);
  1412. goodsDao.updateGoodsSnm(regGoods);
  1413. goodsDao.createCategoryGoods(regGoods);
  1414. }
  1415. // /**
  1416. // * 품 이미지 경로생성
  1417. // *
  1418. // * @param goodsCd
  1419. // * @param brandCd
  1420. // * @return String
  1421. // * @author eskim
  1422. // * @since 2020. 10. 30
  1423. // */
  1424. // private String getGoodsImgPath(String goodsCd, String brandCd) {
  1425. // return "/" + goodsCd.substring(0, 1) + "/" + goodsCd.substring(0, 3) + "/" + goodsCd + "/1000/" + goodsCd + "_";
  1426. // }
  1427. /**
  1428. * 상품 코드 생성
  1429. *
  1430. * @param goodsType - 상품타입
  1431. * @param goodsCdAfter - 상품시퀀스 앞에 붙는명
  1432. * @return
  1433. * @author eskim
  1434. * @since 2020. 10. 30
  1435. */
  1436. public String getGoodsCodeSeq(String goodsType, String goodsCdAfter) {
  1437. //상품코드 12자리
  1438. String goodsCd = "";
  1439. Goods goods = new Goods();
  1440. goodsDao.createGoodsSequence(goods);
  1441. String goodsSeq = GagaStringUtil.getLPadding(Integer.toString(goods.getGoodsSq()), 8, "0");
  1442. if ("S".equals(goodsType) || "D".equals(goodsType)) {
  1443. goodsCd = SELF_GOOODS_AFTER + goodsCdAfter + goodsSeq;
  1444. } else {
  1445. goodsCd = goodsCdAfter + goodsSeq; // 입점 : 브랜드코드
  1446. }
  1447. return goodsCd;
  1448. }
  1449. /**
  1450. * 상품 타이틀 관리 목록 건수
  1451. *
  1452. * @param goodsSearch
  1453. * @return
  1454. * @author eskim
  1455. * @since 2020. 11 .02
  1456. */
  1457. public int getGoodsTitleReserveCount(GoodsSearch goodsSearch) {
  1458. return goodsDao.getGoodsTitleReserveCount(goodsSearch);
  1459. }
  1460. /**
  1461. * 상품 타이틀 관리 목록
  1462. *
  1463. * @param goodsSearch
  1464. * @return
  1465. * @author eskim
  1466. * @since 2020. 11 .02
  1467. */
  1468. public Collection<GoodsTnmRes> getGoodsTitleReserveList(GoodsSearch goodsSearch) {
  1469. return goodsDao.getGoodsTitleReserveList(goodsSearch);
  1470. }
  1471. /**
  1472. * 상품 타이틀 예약 등록
  1473. *
  1474. * @param goodsTnmRes
  1475. * @author eskim
  1476. * @since 2020. 11 .02
  1477. */
  1478. @Transactional("shopTxnManager")
  1479. public void saveGoodsRsvtTnm(GoodsTnmRes goodsTnmRes) {
  1480. if (goodsTnmRes.getArrGoodsCd().length <= 0) {
  1481. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1482. }
  1483. // goodsTnmRes.setGoodsTnm(GagaStringUtil.replace(GagaStringUtil.replace(goodsTnmRes.getGoodsTnm(), "&lt;", "<"), "&gt;", ">"));
  1484. for (String goodsCd : goodsTnmRes.getArrGoodsCd()) {
  1485. goodsTnmRes.setGoodsCd(goodsCd);
  1486. goodsTnmRes.setRegNo(TsaSession.getInfo().getUserNo());
  1487. goodsTnmRes.setUpdNo(TsaSession.getInfo().getUserNo());
  1488. if (goodsDao.getGoodsTnmDupChkCount(goodsTnmRes) > 0) {
  1489. throw new IllegalStateException("이미 등록된 상품 타이틀예약이 등록하려는 예약기간내에 존재합니다. \n(상품코드 : " + goodsCd + ")");
  1490. }
  1491. goodsDao.createGoodTnmRes(goodsTnmRes);
  1492. // 현재일자가 예약기간에 포함되어 있으면 바로 적용한다.
  1493. String toDaytime = GagaDateUtil.getTodayDateTime();
  1494. if (Long.parseLong(toDaytime) >= Long.parseLong(goodsTnmRes.getApplyStdt()) && Long.parseLong(toDaytime) <= Long.parseLong(goodsTnmRes.getApplyEddt())) {
  1495. // 이력생성 및 상품타이틀 수정
  1496. Goods goods = new Goods();
  1497. goods.setGoodsCd(goodsCd);
  1498. goods.setGoodsTnm(goodsTnmRes.getGoodsTnm());
  1499. goods.setRegNo(TsaSession.getInfo().getUserNo());
  1500. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  1501. goodsDao.createGoodsHst(goods);
  1502. goodsDao.updateGoodTnm(goods);
  1503. }
  1504. }
  1505. }
  1506. /**
  1507. * 상품 타이틀 예약 삭제
  1508. *
  1509. * @param goodsTnmRes
  1510. * @author eskim
  1511. * @since 2020. 11 .02
  1512. */
  1513. @Transactional("shopTxnManager")
  1514. public void deleteGoodsRsvtTnm(GoodsTnmRes goodsTnmRes) {
  1515. if (goodsTnmRes.getArrGoodsCd().length <= 0) {
  1516. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1517. }
  1518. int idx = 0;
  1519. for (String goodsCd : goodsTnmRes.getArrGoodsCd()) {
  1520. // 상품 타이틀 예약 삭제
  1521. goodsTnmRes.setGoodsTnmResSq(goodsTnmRes.getArrGoodsTnmResSq()[idx]);
  1522. goodsDao.deleteGoodTnmRes(goodsTnmRes);
  1523. // 상품 타이틀 예약건 초기화
  1524. Goods goods = new Goods();
  1525. goods.setGoodsCd(goodsCd);
  1526. goods = goodsDao.getGoodTnmInit(goods);
  1527. goods.setRegNo(TsaSession.getInfo().getUserNo());
  1528. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  1529. if (!StringUtils.isBlank(goods.getGoodsTnm()) && !goods.getGoodsTnm().equals(goods.getGoodTnmInit())) {
  1530. // 상품이력 먼저 쌓기
  1531. goodsDao.createGoodsHst(goods);
  1532. // 정보수정
  1533. goods.setGoodsTnm(goods.getGoodTnmInit());
  1534. goodsDao.updateGoodTnm(goods);
  1535. }
  1536. idx++;
  1537. }
  1538. }
  1539. /**
  1540. * 네이버 EP 제외 상품 목록 건수
  1541. *
  1542. * @param goodsSearch
  1543. * @return int
  1544. * @author eskim
  1545. * @since 2020. 11. 03
  1546. */
  1547. public int getGoodsEpSkipCount(GoodsSearch goodsSearch) {
  1548. return goodsDao.getGoodsEpSkipCount(goodsSearch);
  1549. }
  1550. /**
  1551. * 네이버 EP 제외 상품 목록
  1552. *
  1553. * @param goodsSearch
  1554. * @return Collection<TsaGoodsEpSkip>
  1555. * @author eskim
  1556. * @since 2020. 11. 03
  1557. */
  1558. public Collection<GoodsEpSkip> getGoodsEpSkipList(GoodsSearch goodsSearch) {
  1559. return goodsDao.getGoodsEpSkipList(goodsSearch);
  1560. }
  1561. /**
  1562. * 네이버 EP 제외 상품 예약 등록
  1563. *
  1564. * @param goodsEpSkip
  1565. * @return void
  1566. * @author eskim
  1567. * @since 2020. 11. 03
  1568. */
  1569. @Transactional("shopTxnManager")
  1570. public void saveGoodsRsvtEpSkip(GoodsEpSkip goodsEpSkip) {
  1571. if (goodsEpSkip.getArrGoodsCd().length <= 0) {
  1572. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1573. }
  1574. for (String goodsCd : goodsEpSkip.getArrGoodsCd()) {
  1575. goodsEpSkip.setGoodsCd(goodsCd);
  1576. goodsEpSkip.setRegNo(TsaSession.getInfo().getUserNo());
  1577. goodsEpSkip.setUpdNo(TsaSession.getInfo().getUserNo());
  1578. if (goodsDao.getGoodsEpSkipDupChkCount(goodsEpSkip) > 0) {
  1579. throw new IllegalStateException("비노출예약이 중복된 상품이 존재합니다.<br/>(상품코드 : " + goodsCd + ")");
  1580. }
  1581. goodsDao.createGoodEpSkip(goodsEpSkip);
  1582. }
  1583. }
  1584. /**
  1585. * 네이버 EP 제외 상품 예약 삭제
  1586. *
  1587. * @param goodsEpSkip
  1588. * @return void
  1589. * @author eskim
  1590. * @since 2020. 11. 03
  1591. */
  1592. @Transactional("shopTxnManager")
  1593. public void deleteGoodsEpSkip(GoodsEpSkip goodsEpSkip) {
  1594. if (goodsEpSkip.getArrGoodsCd().length <= 0) {
  1595. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1596. }
  1597. int idx = 0;
  1598. for (String goodsCd : goodsEpSkip.getArrGoodsCd()) {
  1599. goodsEpSkip.setGoodsEpSkipSq(goodsEpSkip.getArrGoodsEpSkipSq()[idx]);
  1600. goodsDao.deleteGoodEpSkip(goodsEpSkip);
  1601. idx++;
  1602. }
  1603. }
  1604. /**
  1605. * 상품예약판매 목록 건수
  1606. *
  1607. * @param goodsSearch
  1608. * @return Integer
  1609. * @author eskim
  1610. * @since 2020. 11. 12
  1611. */
  1612. public int getGoodsResSellCount(GoodsSearch goodsSearch) {
  1613. return goodsDao.getGoodsResSellCount(goodsSearch);
  1614. }
  1615. /**
  1616. * 상품예약판매 목록
  1617. *
  1618. * @param goodsSearch
  1619. * @return Collection<TsaGoodsResSell>
  1620. * @author eskim
  1621. * @since 2020. 11. 12
  1622. */
  1623. public Collection<GoodsResSell> getGoodsResSellList(GoodsSearch goodsSearch) {
  1624. return goodsDao.getGoodsResSellList(goodsSearch);
  1625. }
  1626. /**
  1627. * 상품예약판매 등록
  1628. *
  1629. * @param goodsResSell
  1630. * @return void
  1631. * @author eskim
  1632. * @since 2020. 11. 12
  1633. */
  1634. @Transactional("shopTxnManager")
  1635. public void saveGoodsResSell(GoodsResSell goodsResSell) {
  1636. if (goodsResSell.getArrGoodsCd().length <= 0) {
  1637. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1638. }
  1639. for (String goodsCd : goodsResSell.getArrGoodsCd()) {
  1640. goodsResSell.setGoodsCd(goodsCd);
  1641. goodsResSell.setRegNo(TsaSession.getInfo().getUserNo());
  1642. goodsResSell.setUpdNo(TsaSession.getInfo().getUserNo());
  1643. if (goodsDao.getGoodsResSellDupChkCount(goodsResSell) > 0) {
  1644. throw new IllegalStateException("이미 등록된 상품예약판매가 존재합니다. \n(상품코드 : " + goodsCd + ")");
  1645. }
  1646. goodsDao.createGoodResSell(goodsResSell);
  1647. Goods goods = new Goods();
  1648. goods.setRegNo(TsaSession.getInfo().getUserNo());
  1649. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  1650. goods.setGoodsCd(goodsResSell.getGoodsCd());
  1651. // 재고연동 비활성화
  1652. goodsDao.createGoodsHst(goods);
  1653. goodsDao.updateGoodsErpStockLinkYn(goods);
  1654. }
  1655. }
  1656. /**
  1657. * 상품예약판매 삭제
  1658. *
  1659. * @param goodsResSell
  1660. * @return void
  1661. * @author eskim
  1662. * @since 2020. 11. 12
  1663. */
  1664. @Transactional("shopTxnManager")
  1665. public void deleteGoodsResSell(GoodsResSell goodsResSell) {
  1666. if (goodsResSell.getArrGoodsCd().length <= 0) {
  1667. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1668. }
  1669. int idx = 0;
  1670. for (String goodsCd : goodsResSell.getArrGoodsCd()) {
  1671. goodsResSell.setGoodsResSellSq(goodsResSell.getArrGoodsResSellSq()[idx]);
  1672. goodsDao.deleteGoodResSell(goodsResSell);
  1673. idx++;
  1674. }
  1675. }
  1676. /**
  1677. * 상품 상세공지 목록
  1678. *
  1679. * @param goodsSearch
  1680. * @return
  1681. * @author eskim
  1682. * @since 2020. 11. 05
  1683. */
  1684. public Collection<Notice> getNoticeList(GoodsSearch goodsSearch) {
  1685. return goodsDao.getNoticeList(goodsSearch);
  1686. }
  1687. /**
  1688. * 상품 상세공지 상품 목록
  1689. *
  1690. * @param notice
  1691. * @return
  1692. * @author eskim
  1693. * @since 2020. 11. 06
  1694. */
  1695. public Collection<NoticeGoods> getNoticeGoodsList(Notice notice) {
  1696. return goodsDao.getNoticeGoodsList(notice);
  1697. }
  1698. /**
  1699. * 공지사항 저장
  1700. * @param notice - 공지사항 정보
  1701. * @return
  1702. * @author eskim
  1703. * @since 2020. 11. 05
  1704. */
  1705. @Transactional("shopTxnManager")
  1706. public void saveNotice(Notice notice) {
  1707. notice.setRegNo(TsaSession.getInfo().getUserNo());
  1708. notice.setUpdNo(TsaSession.getInfo().getUserNo());
  1709. // 신규 일때
  1710. if (notice.getNoticeSq() == null) {
  1711. // 공지사항 저장
  1712. noticeService.createNotice(notice);
  1713. // 등록된 사용자번호 값 가져오기
  1714. Integer noticeSq = notice.getNoticeSq();
  1715. notice.setNoticeSq(noticeSq);
  1716. } else {
  1717. // 공지사항 수정
  1718. noticeService.updateNotice(notice);
  1719. }
  1720. if (!StringUtils.isBlank(notice.getGoodsList())) {
  1721. Collection<NoticeGoods> noticeGoodsList = null;
  1722. try {
  1723. noticeGoodsList = mapper.readValue(notice.getGoodsList(), new TypeReference<Collection<NoticeGoods>>() {
  1724. });
  1725. } catch (Exception e) {
  1726. e.printStackTrace();
  1727. throw new IllegalStateException(message.getMessage("상품상세공지 저장 중 오류로 인해 저장되지 않았습니다."));
  1728. }
  1729. //log.info("noticeGoodsList: {}", noticeGoodsList);
  1730. for (NoticeGoods noticeGoods : noticeGoodsList) {
  1731. noticeGoods.setNoticeSq(notice.getNoticeSq());
  1732. noticeGoods.setRegNo(TsaSession.getInfo().getUserNo());
  1733. noticeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  1734. goodsDao.saveNoticeGoods(noticeGoods);
  1735. }
  1736. }
  1737. }
  1738. /**
  1739. * 공지사항 상품 삭제
  1740. * @param noticeGoods
  1741. * @return
  1742. * @author eskim
  1743. * @since 2020. 11. 06
  1744. */
  1745. @Transactional("shopTxnManager")
  1746. public void deleteNoticeGoods(NoticeGoods noticeGoods) {
  1747. if (noticeGoods == null || (noticeGoods.getArrGoodsCd() == null && noticeGoods.getArrGoodsCd().length <= 0)) {
  1748. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1749. }
  1750. if (noticeGoods.getArrGoodsCd().length > 0) {
  1751. for (String goodsCd : noticeGoods.getArrGoodsCd()) {
  1752. noticeGoods.setGoodsCd(goodsCd);
  1753. noticeGoods.setRegNo(TsaSession.getInfo().getUserNo());
  1754. noticeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  1755. goodsDao.deleteNoticeGoods(noticeGoods);
  1756. }
  1757. }
  1758. }
  1759. /**
  1760. * 상품 가격예약 목록 건수
  1761. *
  1762. * @param goodsSearch
  1763. * @return Integer
  1764. * @author eskim
  1765. * @since 2020. 11. 13
  1766. */
  1767. public int getGoodsPriceResCount(GoodsSearch goodsSearch) {
  1768. return goodsDao.getGoodsPriceResCount(goodsSearch);
  1769. }
  1770. /**
  1771. * 상품 가격예약 목록
  1772. *
  1773. * @param goodsSearch
  1774. * @return Collection<TsaGoodsResSell>
  1775. * @author eskim
  1776. * @since 2020. 11. 13
  1777. */
  1778. public Collection<GoodsPriceRes> getGoodsPriceResList(GoodsSearch goodsSearch) {
  1779. return goodsDao.getGoodsPriceResList(goodsSearch);
  1780. }
  1781. /**
  1782. * 상품 가격예약 등록
  1783. *
  1784. * @param goodsPriceRes
  1785. * @return void
  1786. * @author eskim
  1787. * @since 2020. 11. 13
  1788. */
  1789. @Transactional("shopTxnManager")
  1790. public void createGoodPriceRes(GoodsPriceRes goodsPriceRes) {
  1791. if (goodsPriceRes.getArrGoodsCd().length <= 0) {
  1792. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1793. }
  1794. int idx = 0;
  1795. for (String goodsCd : goodsPriceRes.getArrGoodsCd()) {
  1796. goodsPriceRes.setGoodsCd(goodsCd);
  1797. goodsPriceRes.setEndGoodsPrice(goodsPriceRes.getArrEndGoodsPrice()[idx]);
  1798. goodsPriceRes.setRegNo(TsaSession.getInfo().getUserNo());
  1799. goodsPriceRes.setUpdNo(TsaSession.getInfo().getUserNo());
  1800. if (goodsDao.getGoodsPriceResDupChkCount(goodsPriceRes) > 0) {
  1801. throw new IllegalStateException("이미 등록된 상품 가격예약이 존재합니다. \n(상품코드 : " + goodsCd + ")");
  1802. }
  1803. goodsDao.createGoodPriceRes(goodsPriceRes);
  1804. Goods goods = new Goods();
  1805. goods.setRegNo(TsaSession.getInfo().getUserNo());
  1806. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  1807. goods.setGoodsCd(goodsPriceRes.getGoodsCd());
  1808. idx++;
  1809. }
  1810. }
  1811. /**
  1812. * 상품 가격예약 삭제
  1813. *
  1814. * @param goodsPriceRes
  1815. * @return void
  1816. * @author eskim
  1817. * @since 2020. 11. 13
  1818. */
  1819. @Transactional("shopTxnManager")
  1820. public void deleteGoodsPriceRes(GoodsPriceRes goodsPriceRes) {
  1821. if (goodsPriceRes.getArrGoodsCd().length <= 0) {
  1822. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1823. }
  1824. int idx = 0;
  1825. for (String goodsCd : goodsPriceRes.getArrGoodsCd()) {
  1826. goodsPriceRes.setGoodsPriceResSq(goodsPriceRes.getArrGoodsPriceResSq()[idx]);
  1827. goodsDao.deleteGoodPriceRes(goodsPriceRes);
  1828. idx++;
  1829. }
  1830. }
  1831. /**
  1832. * 상품 가격예약 저장
  1833. *
  1834. * @param goodsPriceList
  1835. * @return
  1836. * @author eskim
  1837. * @since 2020. 11. 16
  1838. */
  1839. @Transactional("shopTxnManager")
  1840. public void saveGoodsPriceExcelupload(Collection<GoodsPriceRes> goodsPriceList, String excelFilename) {
  1841. String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
  1842. if (goodsPriceList == null || goodsPriceList.isEmpty()) {
  1843. this.deleteExceluploadFile(targetPath, excelFilename);
  1844. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  1845. }
  1846. //건수
  1847. if (goodsPriceList != null && goodsPriceList.size() > EXCEL_ROW_COUNT) {
  1848. throw new IllegalStateException("엑셀 파일의 건수를 " + EXCEL_ROW_COUNT + "건 이하로 사용하세요.");
  1849. }
  1850. // 입력값 확인
  1851. String goodsPriceResvCheck = getGoodsPriceResvCheck(goodsPriceList);
  1852. if (!"SUCC".equals(goodsPriceResvCheck)) {
  1853. this.deleteExceluploadFile(targetPath, excelFilename);
  1854. throw new IllegalStateException(goodsPriceResvCheck);
  1855. }
  1856. int index = 0;
  1857. for (GoodsPriceRes goodsPriceRes : goodsPriceList) {
  1858. goodsPriceRes.setUpdNo(TsaSession.getInfo().getUserNo());
  1859. goodsPriceRes.setRegNo(TsaSession.getInfo().getUserNo());
  1860. // //예약일시 시분 설정
  1861. // goodsPriceRes.setApplyStdt(goodsPriceRes.getApplyStdt() + "0000");
  1862. // goodsPriceRes.setApplyEddt(goodsPriceRes.getApplyEddt() + "5959");
  1863. // 엑셀조회를 위한 SEARCH 테이블 생성
  1864. SearchData searchData = new SearchData();
  1865. searchData.setRegNo(goodsPriceRes.getRegNo());
  1866. searchData.setSearchCd(goodsPriceRes.getGoodsCd());
  1867. searchData.setDispOrd(index);
  1868. if (index == 0) {
  1869. commonService.deleteExceluploadSearCh(searchData);
  1870. }
  1871. commonService.createExceluploadSearch(searchData);
  1872. goodsDao.createGoodPriceRes(goodsPriceRes);
  1873. index++;
  1874. }
  1875. }
  1876. /*
  1877. * 상품 가격예약 엑셀조회용 상품 저장 - 입력값 확인
  1878. */
  1879. private String getGoodsPriceResvCheck(Collection<GoodsPriceRes> goodsPriceList) {
  1880. int cnt = 0;
  1881. for (GoodsPriceRes goodsPriceRes : goodsPriceList) {
  1882. if (StringUtils.isBlank(goodsPriceRes.getGoodsCd())) {
  1883. return (cnt + 2) + "행의 상품코드를 확인해주세요";
  1884. }
  1885. if (StringUtils.isBlank(Integer.toString(goodsPriceRes.getResGoodsPrice()))) {
  1886. return (cnt + 2) + "행의 예약가격을 확인해주세요.";
  1887. }
  1888. if (goodsPriceRes.getResGoodsPrice() <= 0) {
  1889. return (cnt + 2) + "행의 예약가격을 확인해주세요.";
  1890. }
  1891. String nowDate = GagaDateUtil.getToday("yyyyMMddHH"); //yyyyMMddHH
  1892. SimpleDateFormat dateFormatParser = new SimpleDateFormat("yyyyMMddHH");
  1893. dateFormatParser.setLenient(false);
  1894. try {
  1895. dateFormatParser.parse(goodsPriceRes.getApplyStdt());
  1896. } catch (Exception e) {
  1897. return (cnt + 2) + "행의 예약시작일시을 확인해주세요.";
  1898. }
  1899. try {
  1900. dateFormatParser.parse(goodsPriceRes.getApplyEddt());
  1901. } catch (Exception e) {
  1902. return (cnt + 2) + "행의 예약종료일시을 확인해주세요.";
  1903. }
  1904. if (Integer.parseInt(goodsPriceRes.getApplyStdt()) > Integer.parseInt(goodsPriceRes.getApplyEddt())) {
  1905. return (cnt + 2) + "행의 예약 시작일시은 종료일시보다 보다 클 수 없습니다.";
  1906. }
  1907. if (Integer.parseInt(goodsPriceRes.getApplyStdt()) <= Integer.parseInt(nowDate)) {
  1908. return (cnt + 2) + "행의 예약 시작일시는 현재일시 보다 작거나 같을 수 없습니다.";
  1909. }
  1910. //정상가와 비교
  1911. Goods searchGoods = new Goods();
  1912. searchGoods.setGoodsCd(goodsPriceRes.getGoodsCd());
  1913. Goods goods = goodsDao.getGoods(searchGoods);
  1914. if (goods == null) {
  1915. return (cnt + 2) + "행의 상품코드를 확인해주세요";
  1916. }
  1917. if (goods.getListPrice() < goodsPriceRes.getResGoodsPrice()) {
  1918. return (cnt + 2) + "행의 상품 정상가보다 예약판매가가 더 큽니다.";
  1919. }
  1920. // if (!"Y".equals(goods.getSelfGoodsYn())) {
  1921. // return (cnt + 2) + "행의 상품은 자사상품이 아닙니다.";
  1922. // }
  1923. goodsPriceRes.setApplyStdt(goodsPriceRes.getApplyStdt() + "0000");
  1924. goodsPriceRes.setApplyEddt(goodsPriceRes.getApplyEddt() + "5959");
  1925. if (goodsDao.getGoodsPriceResDupChkCount(goodsPriceRes) > 0) {
  1926. return (cnt + 2) + "행의 상품 " + goodsPriceRes.getGoodsCd() + "은 이미 등록된 상품 가격예약이 존재합니다.";
  1927. }
  1928. goodsPriceRes.setEndGoodsPrice(goods.getCurrPrice());
  1929. cnt++;
  1930. }
  1931. return "SUCC";
  1932. }
  1933. /**
  1934. * 상품 동영상 목록 조회
  1935. *
  1936. * @param goodsVideo
  1937. * @return
  1938. * @author eskim
  1939. * @since 2020. 11. 16
  1940. */
  1941. public Collection<GoodsVideo> getGoodsVideoList(GoodsVideo goodsVideo) {
  1942. return goodsDao.getGoodsVideoList(goodsVideo);
  1943. }
  1944. /**
  1945. * 상품 동영상 삭제로 변경
  1946. *
  1947. * @param goodsVideo
  1948. * @return
  1949. * @author eskim
  1950. * @since 2020. 11. 16
  1951. */
  1952. @Transactional("shopTxnManager")
  1953. public void updateNotUseGoodsVideo(Collection<GoodsVideo> goodsVideos) {
  1954. for (GoodsVideo goodsVideo : goodsVideos) {
  1955. goodsVideo.setUpdNo(TsaSession.getInfo().getUserNo());
  1956. goodsDao.updateNotUseGoodsVideo(goodsVideo);
  1957. }
  1958. }
  1959. /**
  1960. * 상품동영상 수정/저장
  1961. *
  1962. * @param video
  1963. * @return
  1964. * @author eskim
  1965. * @since 2020. 11. 16
  1966. */
  1967. @Transactional("shopTxnManager")
  1968. public void saveGoodsVideo(GoodsVideo goodsVideo) {
  1969. GoodsSearch goodsSearch = new GoodsSearch();
  1970. goodsSearch.setGoodsCd(goodsVideo.getGoodsCd());
  1971. int goodsCnt = goodsDao.getGoodsListCount(goodsSearch);
  1972. if (goodsCnt <= 0) {
  1973. throw new IllegalStateException(goodsVideo.getGoodsCd() + "의 상품코드를 확인해 주세요.");
  1974. }
  1975. goodsVideo.setRegNo(TsaSession.getInfo().getUserNo());
  1976. goodsVideo.setUpdNo(TsaSession.getInfo().getUserNo());
  1977. if (goodsVideo.getVideoSq() == null || goodsVideo.getVideoSq() == 0) {
  1978. if ("Y".equals(goodsVideo.getVideoGb())) {
  1979. Collection<GoodsVideo> goodsVideoList = goodsDao.getGoodsVideoList(goodsVideo);
  1980. if (goodsVideoList != null && goodsVideoList.size() > 0) {
  1981. GoodsVideo orgingGoodsVideo = goodsVideoList.iterator().next();
  1982. goodsVideo.setVideoSq(orgingGoodsVideo.getVideoSq());
  1983. }
  1984. }
  1985. goodsDao.createGoodsVideo(goodsVideo);
  1986. } else {
  1987. goodsDao.updateGoodsVideo(goodsVideo);
  1988. }
  1989. }
  1990. /**
  1991. * 상품동영상 엑셀파일 등록
  1992. *
  1993. * @param dataList
  1994. * @return
  1995. * @author eskim
  1996. * @since 2020. 11. 16
  1997. */
  1998. @Transactional("shopTxnManager")
  1999. public int saveExcelGoodsVideo(Collection<GagaMap> dataList) {
  2000. int cnt = 0;
  2001. for (GagaMap map : dataList) {
  2002. GoodsVideo goodsVideo = mapper.convertValue(map, GoodsVideo.class);
  2003. GoodsSearch goodsSearch = new GoodsSearch();
  2004. goodsSearch.setGoodsCd(goodsVideo.getGoodsCd());
  2005. int goodsCnt = goodsDao.getGoodsListCount(goodsSearch);
  2006. if (goodsCnt <= 0) {
  2007. throw new IllegalStateException(goodsVideo.getGoodsCd() + "의 상품코드를 확인해 주세요.");
  2008. }
  2009. Collection<GoodsVideo> goodsVideoList = goodsDao.getGoodsVideoList(goodsVideo);
  2010. if (goodsVideoList != null && goodsVideoList.size() > 0) {
  2011. GoodsVideo orgingGoodsVideo = goodsVideoList.iterator().next();
  2012. goodsVideo.setUpdNo(TsaSession.getInfo().getUserNo());
  2013. goodsVideo.setVideoGb("Y");
  2014. goodsVideo.setDispYn(orgingGoodsVideo.getDispYn());
  2015. goodsDao.updateGoodsVideo(goodsVideo);
  2016. } else {
  2017. goodsVideo.setUpdNo(TsaSession.getInfo().getUserNo());
  2018. goodsVideo.setRegNo(TsaSession.getInfo().getUserNo());
  2019. goodsVideo.setDispYn("Y");
  2020. goodsVideo.setVideoGb("Y");
  2021. goodsDao.createGoodsVideo(goodsVideo);
  2022. }
  2023. cnt++;
  2024. }
  2025. return cnt;
  2026. }
  2027. /**
  2028. * 상품별 옵션 등록 여부 확인
  2029. *
  2030. * @param
  2031. * @return
  2032. * @author eskim
  2033. * @since 2020. 11. 17
  2034. */
  2035. public int getGoodsOptionCount(Option option) {
  2036. return goodsDao.getGoodsOptionCount(option);
  2037. }
  2038. /**
  2039. * 상품 가격승인관리 목록 조회
  2040. *
  2041. * @param goodsSupplyPrice
  2042. * @return
  2043. * @author eskim
  2044. * @since 2020. 11. 26
  2045. */
  2046. public Collection<GoodsSupplyPrice> getGoodsSupplyPriceList(GoodsSupplyPrice goodsSupplyPrice) {
  2047. return goodsDao.getGoodsSupplyPriceList(goodsSupplyPrice);
  2048. }
  2049. /**
  2050. * 상품 가격승인관리 승인 처리
  2051. *
  2052. * @param goodsPriceHstList - 상품 가격 승인 목록
  2053. * @author eskim
  2054. * @since 2020. 11. 26
  2055. */
  2056. @Transactional("shopTxnManager")
  2057. public void saveGoodsSupplyPrice(Collection<GoodsSupplyPrice> goodsSupplyPriceList) {
  2058. for (GoodsSupplyPrice goodsSupplyPrice : goodsSupplyPriceList) {
  2059. goodsSupplyPrice.setRegNo(TsaSession.getInfo().getUserNo());
  2060. goodsSupplyPrice.setUpdNo(TsaSession.getInfo().getUserNo());
  2061. Goods goods = new Goods();
  2062. goods.setRegNo(TsaSession.getInfo().getUserNo());
  2063. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  2064. goods.setGoodsCd(goodsSupplyPrice.getGoodsCd());
  2065. goodsDao.createGoodsHst(goods);
  2066. // 판매가 변경
  2067. if (goodsSupplyPrice.getSupplyGoodsPrice() > 0) {
  2068. goods.setDcRate((int)(this.getDcRate(goodsSupplyPrice.getListPrice(), goodsSupplyPrice.getSupplyGoodsPrice())));
  2069. goods.setCurrBprice(goodsSupplyPrice.getCurrPrice());
  2070. goods.setCurrPrice(goodsSupplyPrice.getSupplyGoodsPrice());
  2071. goodsDao.updateGoodsPrice(goods);
  2072. }
  2073. // 판매수수료율 변경
  2074. if (Float.compare(goodsSupplyPrice.getSupplySellFeeRate(), 0) > 0) {
  2075. goods.setSellFeeRate(goodsSupplyPrice.getSupplySellFeeRate());
  2076. goodsDao.updateSellFeeRate(goods);
  2077. }
  2078. goodsDao.updateGoodsSupplyPricecfrmDt(goodsSupplyPrice);
  2079. }
  2080. }
  2081. /**
  2082. * 상품 네이버 최저가 목록
  2083. *
  2084. * @param goodsSearch
  2085. * @return
  2086. * @author eskim
  2087. * @since 2020. 12. 08
  2088. */
  2089. public Collection<GoodsNaverLowestPrice> getGoodsNaverPriceList(GoodsSearch goodsSearch) {
  2090. return goodsDao.getGoodsNaverPriceList(goodsSearch);
  2091. }
  2092. /**
  2093. * 상품 네이버 최저가 엑셀다운로드
  2094. *
  2095. * @param goodsSearch
  2096. * @param excelFilenameWithPath - 경로를 포함한 엑셀파일명
  2097. * @return
  2098. * @author eskim
  2099. * @since 2021. 07. 09
  2100. */
  2101. public void getGoodsNaverExcelList(GoodsSearch goodsSearch, String excelFilenameWithPath) {
  2102. // 헤더 title 설정
  2103. String[] listTitles = {"상품코드", "브랜드명", "상품명", "정상가", "판매가", "자사즉시할인가", "네이버최저가", "차액",
  2104. "최저가몰명", "최저가몰링크"};
  2105. // DB 처리 시 사용되는 파라미터명(셀명) 설정
  2106. String[] cellNames = {"GOODS_CD", "BRAND_ENM", "GOODS_NM", "LIST_PRICE", "CURR_PRICE", "BENEFIT_PRICE", "LOWEST_PRICE", "PRICE",
  2107. "MALL_NM", "MALL_LINK"};
  2108. String[] cellTypes = {
  2109. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
  2110. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  2111. GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  2112. GagaExcelConstants.CellType.CHAR_RIGHT.name(), GagaExcelConstants.CellType.CHAR_RIGHT.name(),
  2113. GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name()};
  2114. Collection<GagaMap> dataList = goodsDao.getGoodsNaverExcelList(goodsSearch);
  2115. try {
  2116. GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "상품 네이버 가격", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
  2117. } catch (Exception e) {
  2118. throw new IllegalStateException(e);
  2119. }
  2120. }
  2121. /**
  2122. * 상품 네이버 최저가 목록
  2123. *
  2124. * @param goodsSearch
  2125. * @return
  2126. * @author eskim
  2127. * @since 2020. 12. 08
  2128. */
  2129. @Transactional("shopTxnManager")
  2130. public Collection<GoodsNaverLowestPrice> saveGoodsNaverPrice(GoodsSearch goodsSearch) {
  2131. // 1. 조회 상품 TB_SEARCH_DATA 담기
  2132. int index = 0;
  2133. for (String goodsCd : goodsSearch.getConditionList()) {
  2134. SearchData searchData = new SearchData();
  2135. searchData.setRegNo(TsaSession.getInfo().getUserNo());
  2136. searchData.setSearchCd(goodsCd);
  2137. if (index == 0) {
  2138. commonService.deleteExceluploadSearCh(searchData);
  2139. }
  2140. commonService.createExceluploadSearch(searchData);
  2141. index++;
  2142. }
  2143. // 2. 일 최초 조회이면 테이블 삭제
  2144. String regYmd = goodsDao.getGoodsNaverLowestPriceReqYmd();
  2145. if (!StringUtils.isBlank(regYmd) && !regYmd.equals(GagaDateUtil.getToday())) {
  2146. goodsDao.deleteGoodsNaverLowestPrice();
  2147. }
  2148. // 3. 네이버 최저가 조회 저장
  2149. saveGoodsNaverLowestPrice(goodsSearch);
  2150. // 4. 최저가 상품 조회
  2151. goodsSearch.setSearchGb("EXCEL");
  2152. goodsSearch.setRegNo(TsaSession.getInfo().getUserNo()); // 엑셀조회시 로그인 사용자의 엑셀 상품조회시 사용
  2153. return goodsDao.getGoodsNaverPriceList(goodsSearch);
  2154. }
  2155. /**
  2156. * 상품 네이버 최저가 목록
  2157. *
  2158. * @param goodsSearch
  2159. * @return
  2160. * @author eskim
  2161. * @since 2020. 12. 08
  2162. */
  2163. private void saveGoodsNaverLowestPrice(GoodsSearch goodsSearch) {
  2164. for (String goodsCd : goodsSearch.getConditionList()) {
  2165. try {
  2166. //log.info("saveGoodsNaverLowestPrice 11 = {}", GagaDateUtil.getTodayDateTime());
  2167. TaskSleeep();
  2168. //log.info("saveGoodsNaverLowestPrice 22 = {}", GagaDateUtil.getTodayDateTime());
  2169. NaverLowestPrice naverLowestPrice = naverLowestPriceApi.getLowestPrice(goodsCd);
  2170. //log.info("[saveGoodsNaverLowestPrice] naverLowestPrice= {}", naverLowestPrice);
  2171. if (naverLowestPrice != null && naverLowestPrice.getTotal() > 0) {
  2172. GoodsNaverLowestPrice goodsNaverLowestPrice = new GoodsNaverLowestPrice();
  2173. goodsNaverLowestPrice.setReqYmd(GagaDateUtil.getToday());
  2174. goodsNaverLowestPrice.setGoodsCd(goodsCd);
  2175. goodsNaverLowestPrice.setMallNm(naverLowestPrice.getItems().iterator().next().getMallName());
  2176. goodsNaverLowestPrice.setMallLink(naverLowestPrice.getItems().iterator().next().getLink());
  2177. goodsNaverLowestPrice.setLowestPrice(Integer.parseInt(naverLowestPrice.getItems().iterator().next().getLprice().toString()));
  2178. goodsNaverLowestPrice.setRegNo(TsaSession.getInfo().getUserNo());
  2179. goodsNaverLowestPrice.setUpdNo(TsaSession.getInfo().getUserNo());
  2180. //log.info("[saveGoodsNaverLowestPrice] goodsNaverLowestPrice= {}", goodsNaverLowestPrice);
  2181. goodsDao.saveGoodsNaverLowestPrice(goodsNaverLowestPrice);
  2182. }
  2183. } catch (Exception e) {
  2184. e.printStackTrace();
  2185. }
  2186. }
  2187. }
  2188. /**
  2189. *
  2190. *
  2191. * @return
  2192. * @author eskim
  2193. * @since 2020. 12. 08
  2194. */
  2195. static void TaskSleeep() {
  2196. try {
  2197. Thread.sleep(100);
  2198. } catch (InterruptedException e) {
  2199. // TODO Auto-generated catch block
  2200. e.printStackTrace();
  2201. }
  2202. }
  2203. /**
  2204. * 광고 키워드 목록
  2205. *
  2206. * @param adKeyword
  2207. * @return
  2208. * @author eskim
  2209. * @since 2020. 12. 15
  2210. */
  2211. public Collection<AdKeyword> getAdKeywordList(AdKeyword adKeyword) {
  2212. return goodsDao.getAdKeywordList(adKeyword);
  2213. }
  2214. /**
  2215. * 광고 키워드 상품 목록
  2216. *
  2217. * @param adKeyword
  2218. * @return
  2219. * @author eskim
  2220. * @since 2020. 12. 15
  2221. */
  2222. public Collection<AdKeywordGoods> getAdKeywordGoodsList(AdKeyword adKeyword) {
  2223. return goodsDao.getAdKeywordGoodsList(adKeyword);
  2224. }
  2225. /**
  2226. * 광고 키워드 저장
  2227. * @param adKeyword
  2228. * @return
  2229. * @author eskim
  2230. * @since 2020. 12. 15
  2231. */
  2232. @Transactional("shopTxnManager")
  2233. public void saveAdKeywordGoods(AdKeyword adKeyword) {
  2234. adKeyword.setRegNo(TsaSession.getInfo().getUserNo());
  2235. adKeyword.setUpdNo(TsaSession.getInfo().getUserNo());
  2236. // 신규 일때
  2237. if (adKeyword.getAdKeywordSq() == null) {
  2238. // 공지사항 저장
  2239. goodsDao.saveAdKeyword(adKeyword);
  2240. // 등록된 사용자번호 값 가져오기
  2241. Integer noticeSq = adKeyword.getAdKeywordSq();
  2242. adKeyword.setAdKeywordSq(noticeSq);
  2243. } else {
  2244. // 공지사항 수정
  2245. goodsDao.saveAdKeyword(adKeyword);
  2246. }
  2247. if (!StringUtils.isBlank(adKeyword.getGoodsList())) {
  2248. Collection<AdKeywordGoods> adKeywordGoodsList = null;
  2249. try {
  2250. adKeywordGoodsList = mapper.readValue(adKeyword.getGoodsList(), new TypeReference<Collection<AdKeywordGoods>>() {
  2251. });
  2252. } catch (Exception e) {
  2253. e.printStackTrace();
  2254. throw new IllegalStateException(message.getMessage("광고 키워드 저장 중 오류로 인해 저장되지 않았습니다."));
  2255. }
  2256. //log.info("adKeywordGoodsList: {}", adKeywordGoodsList);
  2257. int idx = 0;
  2258. for (AdKeywordGoods adKeywordGoods : adKeywordGoodsList) {
  2259. if (idx == 0) {
  2260. goodsDao.deleteAdKeywordGoods(adKeywordGoods); // 전체 상품 삭제
  2261. }
  2262. adKeywordGoods.setAdKeywordSq(adKeyword.getAdKeywordSq());
  2263. adKeywordGoods.setRegNo(TsaSession.getInfo().getUserNo());
  2264. adKeywordGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  2265. goodsDao.saveAdKeywordGoods(adKeywordGoods);
  2266. idx++;
  2267. }
  2268. }
  2269. }
  2270. /**
  2271. * 광고 키워드 상품 삭제
  2272. * @param adKeywordGoods
  2273. * @return
  2274. * @author eskim
  2275. * @since 2020. 12. 15
  2276. */
  2277. @Transactional("shopTxnManager")
  2278. public void deleteAdKeywordGoods(AdKeywordGoods adKeywordGoods) {
  2279. if (adKeywordGoods == null || (adKeywordGoods.getArrGoodsCd() == null && adKeywordGoods.getArrGoodsCd().length <= 0)) {
  2280. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  2281. }
  2282. if (adKeywordGoods.getArrGoodsCd().length > 0) {
  2283. goodsDao.deleteAdKeywordGoods(adKeywordGoods);
  2284. }
  2285. }
  2286. /**
  2287. * 재입고알림 목록 건수
  2288. *
  2289. * @param goodsSearch
  2290. * @return Integer
  2291. * @author eskim
  2292. * @since 2020. 12. 16
  2293. */
  2294. public int getReinboundInformCount(GoodsSearch goodsSearch) {
  2295. return goodsDao.getReinboundInformCount(goodsSearch);
  2296. }
  2297. /**
  2298. * 재입고알림 목록
  2299. *
  2300. * @param goodsSearch
  2301. * @return Collection<ReinboundInform>
  2302. * @author eskim
  2303. * @since 2020. 12. 16
  2304. */
  2305. public Collection<ReinboundInform> getReinboundInformList(GoodsSearch goodsSearch) {
  2306. return goodsDao.getReinboundInformList(goodsSearch);
  2307. }
  2308. /**
  2309. * 재입고알림 발송 처리
  2310. *
  2311. * @param params
  2312. * @return void
  2313. * @author daehyoung
  2314. * @since 2020. 07 .21
  2315. */
  2316. @Transactional("shopTxnManager")
  2317. public void sendReinboundInform(ReinboundInform reinboundInform) {
  2318. goodsDao.updateReinboundInform(reinboundInform);
  2319. }
  2320. /**
  2321. * 상품이미지 목록
  2322. *
  2323. * @param goodsImg
  2324. * @return Collection<GoodsImg>
  2325. * @author eskim
  2326. * @since 2020. 12. 18
  2327. */
  2328. public Collection<GoodsImg> getGoodsImgList(GoodsImg goodsImg) {
  2329. return goodsDao.getGoodsImageList(goodsImg);
  2330. }
  2331. /**
  2332. * 상품이미지 저장 처리
  2333. * @param goodsImgList - 상품이미지 목록
  2334. * @throws AdmBizException
  2335. * @author eskim
  2336. * @since 2020. 12. 21
  2337. */
  2338. @Transactional("shopTxnManager")
  2339. public void saveGoodsImageList(Collection<GoodsImg> goodsImgList) {
  2340. int index = 0;
  2341. for (GoodsImg goodsImg : goodsImgList) {
  2342. // 상품이미지 전체 삭제
  2343. if (index++ == 0) {
  2344. goodsDao.deleteGoodsImageTotal(goodsImg);
  2345. }
  2346. if (!goodsImg.getMode().equals("D")) {
  2347. // 상품이미지 등록
  2348. goodsImg.setRegNo(TsaSession.getInfo().getUserNo());
  2349. goodsDao.createGoodsImage(goodsImg);
  2350. }
  2351. }
  2352. }
  2353. /**
  2354. * 사은품 목록
  2355. *
  2356. * @param goodsSearch
  2357. * @return Collection<FreeGoods>
  2358. * @author eskim
  2359. * @since 2020. 12. 28
  2360. */
  2361. public Collection<FreeGoods> getFreeGoodsList(GoodsSearch goodsSearch) {
  2362. return goodsDao.getFreeGoodsList(goodsSearch);
  2363. }
  2364. /**
  2365. * 사은품 정보 수정
  2366. * @param goodsImgList - 상품이미지 목록
  2367. * @throws AdmBizException
  2368. * @author eskim
  2369. * @since 2020. 12. 21
  2370. */
  2371. @Transactional("shopTxnManager")
  2372. public void updateFreeGoods(FreeGoods freeGoods) {
  2373. freeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  2374. goodsDao.updateFreeGoods(freeGoods);
  2375. }
  2376. /**
  2377. * WMS입고상품관리 목록 건수
  2378. *
  2379. * @param goodsSearch
  2380. * @return Collection<WmsGoods>
  2381. * @author eskim
  2382. * @since 2021. 01. 04
  2383. */
  2384. public int getGoodsWmsIncomelotListCount(WmsGoods wmsGoods) {
  2385. return goodsDao.getGoodsWmsIncomelotListCount(wmsGoods);
  2386. }
  2387. /**
  2388. * WMS입고상품관리 목록 조회
  2389. *
  2390. * @param goodsSearch
  2391. * @return Collection<WmsGoods>
  2392. * @author eskim
  2393. * @since 2021. 01. 04
  2394. */
  2395. public Collection<WmsGoods> getGoodsWmsIncomelotList(WmsGoods wmsGoods) {
  2396. return goodsDao.getGoodsWmsIncomelotList(wmsGoods);
  2397. }
  2398. /**
  2399. * WMS 입고상품 사은품 등록
  2400. * @param wmsGoodsList
  2401. * @author eskim
  2402. * @since 2021. 01. 05
  2403. */
  2404. @Transactional("shopTxnManager")
  2405. public void saveFreeGoods(Collection<IfIncomelot> wmsGoodsList) {
  2406. for (IfIncomelot wmsGoods : wmsGoodsList) {
  2407. FreeGoods freeGoods = new FreeGoods();
  2408. freeGoods.setProductNo(Integer.parseInt(wmsGoods.getProductno()));
  2409. freeGoods.setProductCode(wmsGoods.getProductcode());
  2410. freeGoods.setGoodsNm(wmsGoods.getProductname());
  2411. freeGoods.setBrandCd(wmsGoods.getBrandCd());
  2412. freeGoods.setUseYn("Y");
  2413. freeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  2414. freeGoods.setRegNo(TsaSession.getInfo().getUserNo());
  2415. goodsDao.saveFreeGoods(freeGoods);
  2416. }
  2417. }
  2418. /**
  2419. * 고시분류별 상품고시정보 목록
  2420. * @param goodsNotiInfo - 상품고시정보
  2421. * @return
  2422. * @author gagamel
  2423. * @since 2021. 1. 21
  2424. */
  2425. public Collection<GoodsNotiInfo> getGoodsNotiInfoListByNotiClsf(GoodsNotiInfo goodsNotiInfo) {
  2426. return goodsDao.getGoodsNotiInfoListByNotiClsf(goodsNotiInfo);
  2427. }
  2428. /**
  2429. * 고시분류 칼럼 정보
  2430. * @param niClsfCd - 고시분류코드
  2431. * @return
  2432. * @author gagamel
  2433. * @since 2021. 1. 21
  2434. */
  2435. public GoodsNotiInfo getNotiClsfColumnInfo(String niClsfCd) {
  2436. return goodsDao.getNotiClsfColumnInfo(niClsfCd);
  2437. }
  2438. /**
  2439. * 상품대량수정 엑셀 저장
  2440. *
  2441. * @param ecxelGoodsList, procJob(updateGoods)
  2442. * @return
  2443. * @author eskim
  2444. * @since 2021. 01. 25
  2445. */
  2446. @Transactional("shopTxnManager")
  2447. public String updateMassExceluploadGoods(GagaMap gagaMap, String procJob) {
  2448. GoodsMass goodsMass = mapper.convertValue(gagaMap, GoodsMass.class);
  2449. if (StringUtils.isBlank(goodsMass.getGoodsCd())) {
  2450. throw new IllegalStateException("상품코드는 필수입니다.");
  2451. }
  2452. // 상품기본정보
  2453. Goods goodsData = new Goods();
  2454. goodsData.setGoodsCd(goodsMass.getGoodsCd().trim().toUpperCase());
  2455. Goods goodsOrigin = goodsDao.getGoods(goodsData);
  2456. if (goodsOrigin == null) {
  2457. goodsData.setGoodsRegMsg("미등록 상품코드");
  2458. goodsData.setGoodsStat("10");
  2459. this.setGoodsRegResult(goodsData, goodsMass, procJob);
  2460. return goodsData.getGoodsStat();
  2461. }
  2462. Goods goods = this.updateMassGoodsInfo(goodsMass, procJob, goodsOrigin);
  2463. if ("10".equals(goods.getGoodsStat())) { // 정보 오류
  2464. this.setGoodsRegResult(goods, goodsMass, procJob);
  2465. return goods.getGoodsStat();
  2466. }
  2467. // 옵션
  2468. if (!UPDATE_NO_PATTERN.equals(goodsMass.getOptStr().trim())) {
  2469. goods.setGoodsRegMsg("옵션은 변경할 수 없습니다.");
  2470. goods.setGoodsStat("10");
  2471. this.setGoodsRegResult(goods, goodsMass, procJob);
  2472. return goods.getGoodsStat();
  2473. }
  2474. // 상품 고시
  2475. Collection<GoodsNotiInfo> newGoodsNotiList = new ArrayList<>(); //적용할 고시 정보
  2476. goods = this.getUpdateMassGoodsNotiCheck(goods, gagaMap, goodsOrigin, newGoodsNotiList);
  2477. if ("10".equals(goods.getGoodsStat())) { // 정보 오류
  2478. this.setGoodsRegResult(goods, goodsMass, procJob);
  2479. return goods.getGoodsStat();
  2480. }
  2481. // 상품상세 (html, as-is/입점) - 일반상품만 적용
  2482. if (!UPDATE_NO_PATTERN.equals(goodsMass.getGoodsContent().trim()) && "G056_N".equals(goodsOrigin.getGoodsType())) {
  2483. if (goodsMass.getGoodsContent().toLowerCase().indexOf("script") >= 0) {
  2484. goods.setGoodsRegMsg("상품상세 html script 선언 오류");
  2485. goods.setGoodsStat("10");
  2486. this.setGoodsRegResult(goods, goodsMass, procJob);
  2487. return goods.getGoodsStat();
  2488. }
  2489. goods.setChkDescKeep("Y");
  2490. }
  2491. if ("N".equals(goods.getChDataYn()) && "N".equals(goods.getChkDescKeep()) && "N".equals(goods.getChNotiYn())) {
  2492. goods.setGoodsRegMsg("변경정보 없음");
  2493. goods.setGoodsStat("10");
  2494. this.setGoodsRegResult(goods, goodsMass, procJob);
  2495. return goods.getGoodsStat();
  2496. }
  2497. //상품 기본정보 변경여부 와 촬영업체가 아닌경우
  2498. if ("Y".equals(goods.getChDataYn()) && !"G001_E000".equals(TsaSession.getInfo().getRoleCd())) {
  2499. goodsDao.createGoodsHst(goods); // 이력생성
  2500. goodsDao.updateGoodsMass(goods); // 상품기본 저장
  2501. if (!StringUtils.isBlank(goods.getGoodsSnm1()) && !UPDATE_NO_PATTERN.equals(goods.getGoodsSnm1())) {
  2502. // 사용자 검색어를 검색어에 적용
  2503. String goodsSnm = goodsDao.getGoodsSnm(goods.getGoodsCd());
  2504. String[] arrGoodsSnm = goods.getGoodsSnm1().split("\\;");
  2505. StringBuilder tempGoodsSnm = new StringBuilder();
  2506. for (String loopGoodsSnm : arrGoodsSnm) {
  2507. if (goodsSnm.toUpperCase().indexOf(loopGoodsSnm.toUpperCase()) <= -1) {
  2508. tempGoodsSnm.append(loopGoodsSnm).append(";");
  2509. }
  2510. }
  2511. goods.setGoodsSnm(tempGoodsSnm.toString() + goodsSnm);
  2512. goodsDao.updateGoodsSnm(goods);
  2513. }
  2514. }
  2515. //상품 상세 변경여부 와 촬영업체가 아닌경우
  2516. if ("Y".equals(goods.getChkDescKeep()) && !"G001_E000".equals(TsaSession.getInfo().getRoleCd()) && "G056_N".equals(goodsOrigin.getGoodsType())) {
  2517. GoodsDesc goodsDesc = new GoodsDesc();
  2518. goodsDesc.setGoodsCd(goods.getGoodsCd());
  2519. goodsDesc.setRegNo(goods.getRegNo());
  2520. goodsDesc.setUpdNo(goods.getUpdNo());
  2521. goodsDesc.setDescGb("80");
  2522. goodsDesc.setGoodsDesc(goodsMass.getGoodsContent().trim());
  2523. this.saveGoodsDesc(goodsDesc);
  2524. }
  2525. // 상품고시정보 적용
  2526. if ("Y".equals(goods.getChNotiYn()) && newGoodsNotiList != null && !newGoodsNotiList.isEmpty()) {
  2527. int index = 0;
  2528. for (GoodsNotiInfo goodsNotiInfo : newGoodsNotiList) {
  2529. if (index == 0) {
  2530. goodsDao.deleteGoodsNotiInfo(goods);
  2531. }
  2532. goodsDao.saveGoodsNotiInfo(goodsNotiInfo);
  2533. index++;
  2534. }
  2535. }
  2536. // 품목변경시 카테고리 자동 전시
  2537. if (!UPDATE_NO_PATTERN.equals(goods.getItemkindCd().trim())) {
  2538. GoodsCategory goodsCategory = new GoodsCategory();
  2539. goodsCategory.setRegNo(TsaSession.getInfo().getUserNo());
  2540. goodsCategory.setUpdNo(TsaSession.getInfo().getUserNo());
  2541. goodsCategory.setGoodsCd(goods.getGoodsCd());
  2542. goodsCategory.setCateType("G031_10"); //상품분류카테고리
  2543. displayService.deleteGoodsCategory(goodsCategory);
  2544. goodsDao.createCategoryGoods(goods);
  2545. }
  2546. this.setGoodsRegResult(goods, goodsMass, procJob);
  2547. return goods.getGoodsStat();
  2548. }
  2549. /**
  2550. * 상품 대량 등록 결과 정보
  2551. *
  2552. * @param goods
  2553. * @author eskim
  2554. * @since 2021. 01. 25
  2555. */
  2556. private void setGoodsRegResult(Goods goods, GoodsMass goodsMass, String procJob) {
  2557. // 결과 저장
  2558. goodsMass.setBrandCd(goods.getBrandCd());
  2559. goodsMass.setGoodsStat(goods.getGoodsStat());
  2560. goodsMass.setRegSuccYn("Y");
  2561. goodsMass.setRegFailRsn(goods.getGoodsRegMsg());
  2562. goodsMass.setRegNo(TsaSession.getInfo().getUserNo());
  2563. //model은 string 테이블은 number 형이라 ,,,
  2564. // if (StringUtils.isBlank(goodsMass.getListPrice())) {
  2565. // goodsMass.setListPrice("0");
  2566. // }
  2567. // if (UPDATE_NO_PATTERN.equals(goodsMass.getCurrPrice()) || StringUtils.isBlank(goodsMass.getCurrPrice())) {
  2568. // goodsMass.setCurrPrice("0");
  2569. // }
  2570. // if (StringUtils.isBlank(goodsMass.getCostPrice())) {
  2571. // goodsMass.setCostPrice("0");
  2572. // }
  2573. // if ("10".equals(goods.getGoodsStat())) {
  2574. // goodsMass.setRegSuccYn("N");
  2575. // }
  2576. goodsMass.setProcGb("C");
  2577. if ("updateGoods".equals(procJob)) {
  2578. goodsMass.setProcGb("U");
  2579. }
  2580. goodsDao.createGoodsRegLog(goodsMass);
  2581. }
  2582. /**
  2583. * 상품대량수정 - 상품기본정보
  2584. *
  2585. * @param goodsMass
  2586. * @param excelFilename
  2587. * @author eskim
  2588. * @since 2021. 1. 20
  2589. */
  2590. private Goods updateMassGoodsInfo(GoodsMass goodsMass, String procJob, Goods goodsOrigin) {
  2591. Goods goods = new Goods();
  2592. goods.setChDataYn("N"); // 데이터 변경여부
  2593. goods.setGoodsRegMsg("상품정보 변경");
  2594. goods.setRegNo(TsaSession.getInfo().getUserNo());
  2595. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  2596. goods.setGoodsCd(goodsMass.getGoodsCd().toUpperCase().trim().toUpperCase()); // 상품코드
  2597. if (StringUtils.isBlank(goodsMass.getGoodsNm())) {
  2598. goods.setGoodsRegMsg("상품명 오류");
  2599. goods.setGoodsStat("10");
  2600. return goods;
  2601. }
  2602. goods.setGoodsNm(goodsMass.getGoodsNm().trim()); // 상품명
  2603. if (!UPDATE_NO_PATTERN.equals(goods.getGoodsNm())) {
  2604. goods.setGoodsNm(goods.getGoodsNm().replaceAll("(\\r\\n|\\r|\\n|\\n\\r)", "")); // 상품명
  2605. goods.setChDataYn("Y");
  2606. }
  2607. goods.setGoodsTnm(goodsMass.getGoodsTnm().trim()); // 상품 타이틀
  2608. if (!UPDATE_NO_PATTERN.equals(goods.getGoodsTnm())) {
  2609. goods.setChDataYn("Y");
  2610. if (!StringUtils.isBlank(goods.getGoodsTnm())) {
  2611. goods.setGoodsTnm(goods.getGoodsTnm().replaceAll("(\\r\\n|\\r|\\n|\\n\\r)", "")); // 상품 타이틀
  2612. }
  2613. }
  2614. goods.setGoodsSnm1(goodsMass.getGoodsSnm1().trim()); // 상품 사용자 검색어
  2615. if (!UPDATE_NO_PATTERN.equals(goods.getGoodsSnm1())) {
  2616. goods.setChDataYn("Y");
  2617. if (!StringUtils.isBlank(goods.getGoodsSnm1())) {
  2618. goods.setGoodsSnm1(goods.getGoodsSnm1().replaceAll("(\\r\\n|\\r|\\n|\\n\\r|\\s)", "")); // 상품 사용자 검색어
  2619. }
  2620. }
  2621. // 품목확인
  2622. if (StringUtils.isBlank(goodsMass.getItemkindCd())) {
  2623. goods.setGoodsRegMsg("품목코드 오류");
  2624. goods.setGoodsStat("10");
  2625. return goods;
  2626. }
  2627. goods.setItemkindCd(goodsMass.getItemkindCd().trim().toUpperCase()); // 품목
  2628. if (!UPDATE_NO_PATTERN.equals(goods.getItemkindCd())) {
  2629. Itemkind itemkind = new Itemkind();
  2630. itemkind.setItemkindCd(goods.getItemkindCd());
  2631. itemkind.setUseYn("Y");
  2632. Collection<Itemkind> itemkindList = goodsDao.getItemkindList(itemkind);
  2633. if (itemkindList == null || itemkindList.isEmpty()) {
  2634. goods.setGoodsRegMsg("품목 오류");
  2635. goods.setGoodsStat("10");
  2636. return goods;
  2637. }
  2638. goods.setChDataYn("Y");
  2639. }
  2640. CommonCode commonCode = new CommonCode();
  2641. commonCode.setUseYn("Y");
  2642. // 시즌코드
  2643. if (StringUtils.isBlank(goodsMass.getSeasonCd())) {
  2644. goods.setGoodsRegMsg("시즌코드 오류");
  2645. goods.setGoodsStat("10");
  2646. return goods;
  2647. }
  2648. goods.setSeasonCd(goodsMass.getSeasonCd().trim().toUpperCase());
  2649. if (!UPDATE_NO_PATTERN.equals(goods.getSeasonCd())) {
  2650. commonCode.setCdGb("G006"); // 시즌
  2651. commonCode.setCd(goods.getSeasonCd());
  2652. Collection<CommonCode> seassonList = rendererService.getCommonCodeList(commonCode);
  2653. if (seassonList == null || seassonList.isEmpty()) {
  2654. goods.setGoodsRegMsg("시즌 오류");
  2655. goods.setGoodsStat("10");
  2656. return goods;
  2657. }
  2658. goods.setChDataYn("Y");
  2659. }
  2660. // 성별
  2661. if (StringUtils.isBlank(goodsMass.getSexGb())) {
  2662. goods.setGoodsRegMsg("성별코드 오류");
  2663. goods.setGoodsStat("10");
  2664. return goods;
  2665. }
  2666. goods.setSexGb(goodsMass.getSexGb().trim().toUpperCase());
  2667. // 성별
  2668. if (!UPDATE_NO_PATTERN.equals(goods.getSexGb())) {
  2669. commonCode.setCdGb("G007"); // 성별
  2670. commonCode.setCd(goods.getSexGb());
  2671. Collection<CommonCode> genderList = rendererService.getCommonCodeList(commonCode);
  2672. if (genderList == null || genderList.isEmpty()) {
  2673. goods.setGoodsRegMsg("성별 오류");
  2674. goods.setGoodsStat("10");
  2675. return goods;
  2676. }
  2677. goods.setChDataYn("Y");
  2678. }
  2679. //판매가
  2680. if (StringUtils.isBlank(goodsMass.getCurrPrice())) {
  2681. goods.setGoodsRegMsg("판매가 오류");
  2682. goods.setGoodsStat("10");
  2683. return goods;
  2684. }
  2685. if (UPDATE_NO_PATTERN.equals(goodsMass.getCurrPrice().trim())) {
  2686. goods.setCurrPrice(0);
  2687. } else {
  2688. if (!GagaStringUtil.replace(goodsMass.getCurrPrice().trim(), ",", "").matches(NUMBER_PATTERN)) {
  2689. goods.setGoodsRegMsg("판매가 오류");
  2690. goods.setGoodsStat("10");
  2691. return goods;
  2692. }
  2693. if (Integer.parseInt(goodsMass.getCurrPrice().trim()) == 0) {
  2694. goods.setGoodsRegMsg("판매가 오류");
  2695. goods.setGoodsStat("10");
  2696. return goods;
  2697. }
  2698. }
  2699. //판매수수료율
  2700. if (StringUtils.isBlank(goodsMass.getSellFeeRate())) {
  2701. goods.setGoodsRegMsg("판매수수료율 오류");
  2702. goods.setGoodsStat("10");
  2703. return goods;
  2704. }
  2705. float sellFeeRate = 0f;
  2706. if (UPDATE_NO_PATTERN.equals(goodsMass.getSellFeeRate().trim())) {
  2707. goods.setSellFeeRate(0);
  2708. } else {
  2709. try {
  2710. sellFeeRate = Float.valueOf(goodsMass.getSellFeeRate().trim());
  2711. //goods.setSellFeeRate(sellFeeRate);
  2712. } catch (Exception e) {
  2713. goods.setGoodsRegMsg("판매수수료율 오류");
  2714. goods.setGoodsStat("10");
  2715. return goods;
  2716. }
  2717. //비교값 크면 1, 같으면 0, 작은면 -1 리턴
  2718. if (Float.compare(sellFeeRate, 0) == 0) {
  2719. goods.setGoodsRegMsg("판매수수료율 오류");
  2720. goods.setGoodsStat("10");
  2721. return goods;
  2722. }
  2723. if (Float.compare(sellFeeRate, 100) >= 0) {
  2724. goods.setGoodsRegMsg("판매수수료율 오류");
  2725. goods.setGoodsStat("10");
  2726. return goods;
  2727. }
  2728. }
  2729. //판매가나 판매수수료율이 변경되었을 때
  2730. if (!UPDATE_NO_PATTERN.equals(goodsMass.getCurrPrice().trim()) || !UPDATE_NO_PATTERN.equals(goodsMass.getSellFeeRate().trim())) {
  2731. //자사
  2732. if ("Y".equals(goodsOrigin.getSelfGoodsYn())) {
  2733. //판매가 변경시
  2734. if (!UPDATE_NO_PATTERN.equals(goodsMass.getCurrPrice().trim())) {
  2735. goods.setCurrPrice(Integer.parseInt(GagaStringUtil.replace(goodsMass.getCurrPrice().trim(), ",", ""))); // 판매가
  2736. goods.setCurrBprice(goodsOrigin.getCurrPrice());
  2737. goods.setDcRate((int)(this.getDcRate(goodsOrigin.getListPrice(), goods.getCurrPrice())));
  2738. goods.setChDataYn("Y");
  2739. }
  2740. //판매수수료율 변경시
  2741. if (!UPDATE_NO_PATTERN.equals(goodsMass.getSellFeeRate().trim())) {
  2742. goods.setSellFeeRate(sellFeeRate); // 판매수수료율
  2743. goods.setChDataYn("Y");
  2744. }
  2745. } else {
  2746. //입점
  2747. GoodsPriceRes goodsPriceRes = new GoodsPriceRes();
  2748. goodsPriceRes.setGoodsCd(goods.getGoodsCd());
  2749. if (goods.getCurrPrice() != goodsOrigin.getCurrPrice()) {
  2750. goodsPriceRes.setResGoodsPrice(goods.getCurrPrice());
  2751. goodsPriceRes.setEndGoodsPrice(goods.getCurrPrice());
  2752. }
  2753. if (goods.getSellFeeRate() != goodsOrigin.getSellFeeRate()) {
  2754. goodsPriceRes.setSellFeeRate(sellFeeRate);
  2755. }
  2756. goodsPriceRes.setApplyStdt(GagaDateUtil.getTodayDateTime()); //yyyymmddhhmiss
  2757. int toYear = Integer.parseInt(GagaDateUtil.getToday("yyyy")) + 4;
  2758. goodsPriceRes.setApplyEddt(Integer.toString(toYear) + "1231235959"); //yyyymmddhhmiss
  2759. goodsPriceRes.setCfrmYn("N");
  2760. goodsPriceRes.setApplyYn("N");
  2761. goodsPriceRes.setRegNo(goods.getRegNo());
  2762. goodsPriceRes.setUpdNo(goods.getUpdNo());
  2763. goodsDao.createGoodPriceRes(goodsPriceRes);
  2764. // 상품테이블에 바로 변경하지 않고 입점상품가격관리에서 승인해야함
  2765. goods.setCurrPrice(goodsOrigin.getCurrPrice());
  2766. goods.setSellFeeRate(goodsOrigin.getSellFeeRate());
  2767. }
  2768. }
  2769. // 상품구분
  2770. if (StringUtils.isBlank(goodsMass.getGoodsGb())) {
  2771. goods.setGoodsRegMsg("상품구분 오류");
  2772. goods.setGoodsStat("10");
  2773. return goods;
  2774. }
  2775. goods.setGoodsGb(goodsMass.getGoodsGb().trim().toUpperCase());
  2776. // 상품구분
  2777. if (!UPDATE_NO_PATTERN.equals(goods.getGoodsGb())) {
  2778. commonCode.setCdGb("G073"); // 상품구분
  2779. commonCode.setCd(goods.getGoodsGb());
  2780. Collection<CommonCode> goodsGbList = rendererService.getCommonCodeList(commonCode);
  2781. if (goodsGbList == null || goodsGbList.isEmpty()) {
  2782. goods.setGoodsRegMsg("상품구분 오류");
  2783. goods.setGoodsStat("10");
  2784. return goods;
  2785. }
  2786. goods.setChDataYn("Y");
  2787. }
  2788. //정상이월구분
  2789. if (StringUtils.isBlank(goodsMass.getFormalGb())) {
  2790. goods.setGoodsRegMsg("정상이월구분 오류");
  2791. goods.setGoodsStat("10");
  2792. return goods;
  2793. }
  2794. goods.setFormalGb(goodsMass.getFormalGb().trim().toUpperCase()); // 정상이월
  2795. if (!UPDATE_NO_PATTERN.equals(goods.getFormalGb())
  2796. && !"G009_10".equals(goods.getFormalGb())
  2797. && !"G009_20".equals(goods.getFormalGb())) {
  2798. goods.setGoodsRegMsg("정상이월구분 오류");
  2799. goods.setGoodsStat("10");
  2800. return goods;
  2801. }
  2802. if (!UPDATE_NO_PATTERN.equals(goods.getFormalGb())) {
  2803. goods.setPntPrate(goodsOrigin.getPntPrate()); // 포인트적립율(PC)
  2804. goods.setPntMrate(goodsOrigin.getPntMrate()); // 포인트적립율(MOBILE)
  2805. Brand brand = new Brand();
  2806. brand.setBrandCd(goodsOrigin.getBrandCd());
  2807. Collection<Brand> brandList = businessService.getBrandList(brand);
  2808. if (brandList != null && !brandList.isEmpty()) {
  2809. // 브랜드 확인
  2810. float pntPrate = 0f;
  2811. float pntMrate = 0f;
  2812. for (Brand tmpBrand : brandList) {
  2813. if ("G009_10".equals(goods.getFormalGb())) {
  2814. pntPrate = tmpBrand.getPntPrate10();
  2815. pntMrate = tmpBrand.getPntMrate10();
  2816. } else {
  2817. pntPrate = tmpBrand.getPntPrate20();
  2818. pntMrate = tmpBrand.getPntMrate20();
  2819. }
  2820. }
  2821. goods.setPntPrate(pntPrate); // 포인트적립율(PC)
  2822. goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
  2823. }
  2824. goods.setChDataYn("Y");
  2825. }
  2826. //최소주문수량
  2827. if (UPDATE_NO_PATTERN.equals(goodsMass.getMinOrdQty().trim())) {
  2828. goods.setMinOrdQty(0);
  2829. } else {
  2830. if (!goodsMass.getMinOrdQty().trim().matches(NUMBER_PATTERN) || Integer.parseInt(goodsMass.getMinOrdQty().trim()) == 0) {
  2831. goods.setGoodsRegMsg("최소주문수량 오류");
  2832. goods.setGoodsStat("10");
  2833. return goods;
  2834. }
  2835. goods.setMinOrdQty(Integer.parseInt(goodsMass.getMinOrdQty().trim()));
  2836. goods.setChDataYn("Y");
  2837. }
  2838. //최대주문수량
  2839. if (UPDATE_NO_PATTERN.equals(goodsMass.getMaxOrdQty().trim())) {
  2840. goods.setMaxOrdQty(0);
  2841. } else {
  2842. if (!goodsMass.getMaxOrdQty().trim().matches(NUMBER_PATTERN) || Integer.parseInt(goodsMass.getMaxOrdQty().trim()) == 0) {
  2843. goods.setGoodsRegMsg("최대주문수량 오류");
  2844. goods.setGoodsStat("10");
  2845. return goods;
  2846. }
  2847. goods.setMaxOrdQty(Integer.parseInt(goodsMass.getMaxOrdQty().trim()));
  2848. goods.setChDataYn("Y");
  2849. }
  2850. //ID당1일최대주문수량
  2851. if (UPDATE_NO_PATTERN.equals(goodsMass.getDayMaxOrdQty().trim())) {
  2852. goods.setMaxOrdQty(0);
  2853. } else {
  2854. if (!goodsMass.getDayMaxOrdQty().trim().matches(NUMBER_PATTERN) || Integer.parseInt(goodsMass.getDayMaxOrdQty().trim()) == 0) {
  2855. goods.setGoodsRegMsg("ID당1일최대주문수량 오류");
  2856. goods.setGoodsStat("10");
  2857. return goods;
  2858. }
  2859. goods.setDayMaxOrdQty(Integer.parseInt(goodsMass.getDayMaxOrdQty().trim()));
  2860. goods.setChDataYn("Y");
  2861. }
  2862. if (goods.getMinOrdQty() > goods.getMaxOrdQty()) {
  2863. goods.setGoodsRegMsg("최소주문수량 오류(최대주문수량보다 클 수 없음)");
  2864. goods.setGoodsStat("10");
  2865. return goods;
  2866. }
  2867. if (goods.getMaxOrdQty() > goods.getDayMaxOrdQty()) {
  2868. goods.setGoodsRegMsg("최대주문수량 오류(ID당1일최대구매수량보다 클 수 없음)");
  2869. goods.setGoodsStat("10");
  2870. return goods;
  2871. }
  2872. //선물주문가능여부
  2873. if (StringUtils.isBlank(goodsMass.getGiftPackYn())) {
  2874. goods.setGoodsRegMsg("선물주문가능여부 오류");
  2875. goods.setGoodsStat("10");
  2876. return goods;
  2877. }
  2878. if ("Y".equals(goodsOrigin.getSelfGoodsYn())) {
  2879. if (!UPDATE_NO_PATTERN.equals(goodsMass.getGiftPackYn().trim().toUpperCase())) {
  2880. goods.setGiftPackYn(goodsMass.getGiftPackYn().trim().toUpperCase());
  2881. if (!"Y".equals(goods.getGiftPackYn()) && !"N".equals(goods.getGiftPackYn())) {
  2882. goods.setGoodsRegMsg("선물주문가능여부 오류");
  2883. goods.setGoodsStat("10");
  2884. return goods;
  2885. }
  2886. goods.setChDataYn("Y");
  2887. }
  2888. } else {
  2889. goods.setGiftPackYn(goodsOrigin.getGiftPackYn().trim().toUpperCase());
  2890. }
  2891. //신규가입구매가능여부
  2892. if (StringUtils.isBlank(goodsMass.getNewCustOrdYn())) {
  2893. goods.setGoodsRegMsg("신규가입구매가능여부 오류");
  2894. goods.setGoodsStat("10");
  2895. return goods;
  2896. }
  2897. if ("Y".equals(goodsOrigin.getSelfGoodsYn())) {
  2898. if (!UPDATE_NO_PATTERN.equals(goodsMass.getNewCustOrdYn().trim().toUpperCase())) {
  2899. goods.setNewCustOrdYn(goodsMass.getNewCustOrdYn().trim().toUpperCase());
  2900. if (!"Y".equals(goods.getNewCustOrdYn()) && !"N".equals(goods.getNewCustOrdYn())) {
  2901. goods.setGoodsRegMsg("신규가입구매가능여부 오류");
  2902. goods.setGoodsStat("10");
  2903. return goods;
  2904. }
  2905. goods.setChDataYn("Y");
  2906. }
  2907. } else {
  2908. goods.setNewCustOrdYn(goodsOrigin.getNewCustOrdYn().toUpperCase());
  2909. }
  2910. //반품여부
  2911. if (StringUtils.isBlank(goodsMass.getReturnableYn())) {
  2912. goods.setGoodsRegMsg("반품여부 오류");
  2913. goods.setGoodsStat("10");
  2914. return goods;
  2915. }
  2916. goods.setReturnableYn(goodsMass.getReturnableYn().trim().toUpperCase());
  2917. if (!UPDATE_NO_PATTERN.equals(goodsMass.getReturnableYn().trim())) {
  2918. if (!"Y".equals(goods.getReturnableYn()) && !"N".equals(goods.getReturnableYn())) {
  2919. goods.setGoodsRegMsg("반품여부 오류");
  2920. goods.setGoodsStat("10");
  2921. return goods;
  2922. }
  2923. goods.setChDataYn("Y");
  2924. }
  2925. //교환여부
  2926. if (StringUtils.isBlank(goodsMass.getChangeableYn())) {
  2927. goods.setGoodsRegMsg("교환여부 오류");
  2928. goods.setGoodsStat("10");
  2929. return goods;
  2930. }
  2931. goods.setChangeableYn(goodsMass.getChangeableYn().trim().toUpperCase());
  2932. if (!UPDATE_NO_PATTERN.equals(goodsMass.getChangeableYn().trim())) {
  2933. if (!"Y".equals(goods.getChangeableYn()) && !"N".equals(goods.getChangeableYn())) {
  2934. goods.setGoodsRegMsg("교환여부 오류");
  2935. goods.setGoodsStat("10");
  2936. return goods;
  2937. }
  2938. goods.setChDataYn("Y");
  2939. }
  2940. //과세구분
  2941. if (StringUtils.isBlank(goodsMass.getTaxGb())) {
  2942. goods.setGoodsRegMsg("과세구분 오류");
  2943. goods.setGoodsStat("10");
  2944. return goods;
  2945. }
  2946. goods.setTaxGb(goodsMass.getTaxGb().trim().toUpperCase());
  2947. if (!UPDATE_NO_PATTERN.equals(goodsMass.getTaxGb().trim())) {
  2948. if (!"10".equals(goods.getTaxGb()) && !"20".equals(goods.getTaxGb()) && !"30".equals(goods.getTaxGb())) {
  2949. goods.setGoodsRegMsg("과세구분 오류");
  2950. goods.setGoodsStat("10");
  2951. return goods;
  2952. }
  2953. goods.setChDataYn("Y");
  2954. }
  2955. //상품연령
  2956. if (StringUtils.isBlank(goodsMass.getAgeGrpCd())) {
  2957. goods.setGoodsRegMsg("상품연령 오류");
  2958. goods.setGoodsStat("10");
  2959. return goods;
  2960. }
  2961. goods.setAgeGrpCd(goodsMass.getAgeGrpCd().trim().toUpperCase());
  2962. if (!UPDATE_NO_PATTERN.equals(goods.getAgeGrpCd())) {
  2963. commonCode.setCdGb("G023");
  2964. commonCode.setCd(goods.getAgeGrpCd());
  2965. Collection<CommonCode> ageGrpCdList = rendererService.getCommonCodeList(commonCode);
  2966. if (ageGrpCdList == null || ageGrpCdList.isEmpty()) {
  2967. goods.setGoodsRegMsg("상품연령 오류");
  2968. goods.setGoodsStat("10");
  2969. return goods;
  2970. }
  2971. goods.setChDataYn("Y");
  2972. }
  2973. //성인용품여부
  2974. if (StringUtils.isBlank(goodsMass.getAdultYn())) {
  2975. goods.setGoodsRegMsg("성인용품여부 오류");
  2976. goods.setGoodsStat("10");
  2977. return goods;
  2978. }
  2979. goods.setAdultYn(goodsMass.getAdultYn().trim().toUpperCase());
  2980. if (!UPDATE_NO_PATTERN.equals(goods.getAdultYn())) {
  2981. if (!"Y".equals(goods.getAdultYn()) && !"N".equals(goods.getAdultYn())) {
  2982. goods.setGoodsRegMsg("성인용품여부 오류");
  2983. goods.setGoodsStat("10");
  2984. return goods;
  2985. }
  2986. goods.setChDataYn("Y");
  2987. }
  2988. //PC포인트적립율
  2989. if (StringUtils.isBlank(goodsMass.getPntPrate())) {
  2990. goods.setGoodsRegMsg("PC포인트적립율 오류");
  2991. goods.setGoodsStat("10");
  2992. return goods;
  2993. }
  2994. if (!UPDATE_NO_PATTERN.equals(goodsMass.getPntPrate().trim())) {
  2995. try {
  2996. float pntPrate = Float.valueOf(goodsMass.getPntPrate().trim());
  2997. goods.setPntPrate(pntPrate);
  2998. } catch (Exception e) {
  2999. goods.setGoodsRegMsg("PC포인트적립율 오류");
  3000. goods.setGoodsStat("10");
  3001. return goods;
  3002. }
  3003. goods.setChDataYn("Y");
  3004. }
  3005. if (StringUtils.isBlank(goodsMass.getPrePpntUsableYn())) {
  3006. goods.setGoodsRegMsg("PC선포인트 사용여부 오류");
  3007. goods.setGoodsStat("10");
  3008. return goods;
  3009. }
  3010. if (!UPDATE_NO_PATTERN.equals(goodsMass.getPrePpntUsableYn().trim())) {
  3011. if ("Y".equals(goodsMass.getPrePpntUsableYn().trim()) || "N".equals(goodsMass.getPrePpntUsableYn().trim())) {
  3012. goods.setPrePpntUsableYn(goodsMass.getPrePpntUsableYn().trim());
  3013. goods.setChDataYn("Y");
  3014. } else {
  3015. goods.setGoodsRegMsg("PC선포인트 사용여부 오류");
  3016. goods.setGoodsStat("10");
  3017. return goods;
  3018. }
  3019. }
  3020. if (StringUtils.isBlank(goodsMass.getPntMrate())) {
  3021. goods.setGoodsRegMsg("모바일포인트적립율 오류");
  3022. goods.setGoodsStat("10");
  3023. return goods;
  3024. }
  3025. if (!UPDATE_NO_PATTERN.equals(goodsMass.getPntMrate().trim())) {
  3026. try {
  3027. int pntMrate = Integer.parseInt(goodsMass.getPntMrate().trim());
  3028. goods.setPntMrate(pntMrate);
  3029. } catch (Exception e) {
  3030. goods.setGoodsRegMsg("모바일포인트적립율 오류");
  3031. goods.setGoodsStat("10");
  3032. return goods;
  3033. }
  3034. goods.setChDataYn("Y");
  3035. }
  3036. if (StringUtils.isBlank(goodsMass.getPreMpntUsableYn())) {
  3037. goods.setGoodsRegMsg("모바일선포인트 사용여부 오류");
  3038. goods.setGoodsStat("10");
  3039. return goods;
  3040. }
  3041. if (!UPDATE_NO_PATTERN.equals(goodsMass.getPreMpntUsableYn().trim())) {
  3042. if ("Y".equals(goodsMass.getPreMpntUsableYn().trim()) || "N".equals(goodsMass.getPreMpntUsableYn().trim())) {
  3043. goods.setPreMpntUsableYn(goodsMass.getPreMpntUsableYn().trim());
  3044. goods.setChDataYn("Y");
  3045. } else {
  3046. goods.setGoodsRegMsg("모바일선포인트 사용여부 오류");
  3047. goods.setGoodsStat("10");
  3048. return goods;
  3049. }
  3050. }
  3051. // 배송비 정책 확인
  3052. if (StringUtils.isBlank(goodsMass.getDelvFeeCd())) {
  3053. goods.setGoodsRegMsg("배송비정책코드 오류");
  3054. goods.setGoodsStat("10");
  3055. return goods;
  3056. }
  3057. goods.setDelvFeeCd(goodsMass.getDelvFeeCd().trim().toUpperCase());
  3058. if (!UPDATE_NO_PATTERN.equals(goods.getDelvFeeCd())) {
  3059. DelvFeePolicy delvFeePolicy = new DelvFeePolicy();
  3060. delvFeePolicy.setSupplyCompCd(goods.getSupplyCompCd());
  3061. delvFeePolicy.setDelvFeeCd(goods.getDelvFeeCd());
  3062. delvFeePolicy.setUseYn("Y");
  3063. Collection<DelvFeePolicy> deliveryFeePolicyList = businessService.getDeliveryFeePolicyList(delvFeePolicy);
  3064. if (deliveryFeePolicyList != null && !deliveryFeePolicyList.isEmpty()) {
  3065. goods.setGoodsRegMsg("배송비정책코드 오류");
  3066. goods.setGoodsStat("10");
  3067. return goods;
  3068. }
  3069. }
  3070. return goods;
  3071. }
  3072. /**
  3073. * 상품대량수정 - 상품고시정보 check
  3074. *
  3075. * @param goods
  3076. * @param excelMap
  3077. * @param goodsOrigin
  3078. * @param newGoodsNotiList
  3079. * @return Goods
  3080. * @author eskim
  3081. * @since 2021. 01. 25
  3082. */
  3083. private Goods getUpdateMassGoodsNotiCheck(Goods goods, GagaMap excelMap, Goods goodsOrigin, Collection<GoodsNotiInfo> newGoodsNotiList) {
  3084. goods.setChNotiYn("N");
  3085. String oldNiClsfCd = "";
  3086. String newNiClsfCd = "";
  3087. newNiClsfCd = excelMap.getString("niClsfCd").trim();
  3088. for (int i = 0; i < 28; i++) {
  3089. if (StringUtils.isBlank(excelMap.getString("niContent" + (i + 1)))) {
  3090. goods.setGoodsRegMsg("고시항목정보 없음 (" + (i + 1) + "번째 항목)");
  3091. goods.setGoodsStat("10");
  3092. return goods;
  3093. }
  3094. if (!UPDATE_NO_PATTERN.equals(excelMap.getString("niContent" + (i + 1)).trim())) {
  3095. goods.setChNotiYn("Y");
  3096. }
  3097. }
  3098. // 변경사항이 있는지 확인
  3099. if (UPDATE_NO_PATTERN.equals(newNiClsfCd) && "N".equals(goods.getChNotiYn())) {
  3100. return goods;
  3101. }
  3102. Collection<GoodsNotiInfo> goodsNotiList = new ArrayList<>();
  3103. //고시분류 코드의 고시항목 조회
  3104. NotiInfo notiInfo = new NotiInfo();
  3105. notiInfo.setSupplyCompCd(goodsOrigin.getSupplyCompCd());
  3106. if (!UPDATE_NO_PATTERN.equals(newNiClsfCd)) {
  3107. notiInfo.setNiClsfCd(newNiClsfCd);
  3108. } else {
  3109. GoodsNotiInfo goodsNotiInfo = new GoodsNotiInfo();
  3110. goodsNotiInfo.setGoodsCd(goods.getGoodsCd());
  3111. goodsNotiList = goodsDao.getGoodsNotiInfoList(goodsNotiInfo);
  3112. if (goodsNotiList != null && !goodsNotiList.isEmpty()) {
  3113. oldNiClsfCd = goodsNotiList.iterator().next().getNiClsfCd();
  3114. }
  3115. notiInfo.setNiClsfCd(oldNiClsfCd);
  3116. newNiClsfCd = oldNiClsfCd;
  3117. }
  3118. Collection<NotiInfo> notiInfolist = goodsDao.getNotiInfoItemList(notiInfo); // 항목별 기본값 조회
  3119. // 상품의 고시 분류코드 조회
  3120. if (notiInfolist == null || notiInfolist.isEmpty()) {
  3121. goods.setGoodsRegMsg("고시분류정보 없음");
  3122. goods.setGoodsStat("10");
  3123. return goods;
  3124. }
  3125. int index = 0;
  3126. // 같은 고시분류 일경우 기존 고시항목 정보 적용
  3127. if (oldNiClsfCd.equals(newNiClsfCd)) {
  3128. for (NotiInfo notiInfoData : notiInfolist) {
  3129. for (GoodsNotiInfo goodsNotiInfoTemp : goodsNotiList) {
  3130. if (notiInfoData.getNiItemCd().equals(goodsNotiInfoTemp.getNiItemCd())) {
  3131. notiInfoData.setNiContent(goodsNotiInfoTemp.getNiContent());
  3132. break;
  3133. }
  3134. }
  3135. index++;
  3136. }
  3137. }
  3138. index = 0;
  3139. for (NotiInfo notiInfoTmp : notiInfolist) {
  3140. GoodsNotiInfo goodsNotiInfoTmp = new GoodsNotiInfo();
  3141. goodsNotiInfoTmp.setGoodsCd(goods.getGoodsCd());
  3142. goodsNotiInfoTmp.setNiClsfCd(notiInfoTmp.getNiClsfCd());
  3143. goodsNotiInfoTmp.setNiItemCd(notiInfoTmp.getNiItemCd());
  3144. goodsNotiInfoTmp.setDispOrd(index + 1);
  3145. goodsNotiInfoTmp.setRegNo(TsaSession.getInfo().getUserNo());
  3146. goodsNotiInfoTmp.setUpdNo(TsaSession.getInfo().getUserNo());
  3147. if (UPDATE_NO_PATTERN.equals(excelMap.getString("niContent" + (index + 1)))) {
  3148. goodsNotiInfoTmp.setNiContent(notiInfoTmp.getNiContent());
  3149. } else {
  3150. goodsNotiInfoTmp.setNiContent(excelMap.getString("niContent" + (index + 1)));
  3151. }
  3152. newGoodsNotiList.add(goodsNotiInfoTmp);
  3153. index++;
  3154. }
  3155. return goods;
  3156. }
  3157. /**
  3158. * 상품등록로그 목록
  3159. *
  3160. * @param goodsSearch
  3161. * @return
  3162. * @author eskim
  3163. * @since 2020. 01. 25
  3164. */
  3165. public Collection<GoodsMass> getGoodsRegLogList(GoodsSearch goodsSearch) {
  3166. // 입점업체담당자는 업체코드 설정
  3167. if ("G001_B000".equals(TsaSession.getInfo().getRoleCd()) || "G001_E000".equals(TsaSession.getInfo().getRoleCd())) {
  3168. goodsSearch.setSupplyCompCd(TsaSession.getInfo().getSupplyCompCd());
  3169. goodsSearch.setRegNo(TsaSession.getInfo().getUserNo());
  3170. }
  3171. return goodsDao.getGoodsRegLogList(goodsSearch);
  3172. }
  3173. /**
  3174. * 사이즈 정보 목록
  3175. *
  3176. * @param sizeInfo
  3177. * @return
  3178. * @author eskim
  3179. * @since 2021. 01. 26
  3180. */
  3181. public Collection<SizeInfo> getSizeInfoList(SizeInfo sizeInfo) {
  3182. return goodsDao.getSizeInfoList(sizeInfo);
  3183. }
  3184. /**
  3185. * 사이즈 정보 저장
  3186. *
  3187. * @param sizeInfo
  3188. * @return
  3189. * @author eskim
  3190. * @since 2021. 01. 27
  3191. */
  3192. public void saveSizeInfo(SizeInfo sizeInfo) {
  3193. //log.info("[saveSizeInfo] sizeInfo {}", sizeInfo);
  3194. String sizeCate1Cd = "";
  3195. String sizeCate2Cd = "";
  3196. if ("1".equals(sizeInfo.getSizeGb())) {
  3197. if (StringUtils.isBlank(sizeInfo.getSizeCate1Cd())) {
  3198. sizeCate1Cd = "00";
  3199. if ("Y".equals(sizeInfo.getSelfYn())) {
  3200. sizeCate1Cd = sizeInfo.getBrandCd();
  3201. }
  3202. sizeInfo.setSizeCate1Cd(sizeCate1Cd);
  3203. }
  3204. if (StringUtils.isBlank(sizeInfo.getSizeCate2Cd())) {
  3205. sizeCate2Cd = tscCommonService.getNextSequence("SEQ_CATE").toString();
  3206. sizeInfo.setSizeCate2Cd(sizeCate2Cd);
  3207. }
  3208. } else {
  3209. if (StringUtils.isBlank(sizeInfo.getSizeCate1Cd())) {
  3210. sizeCate1Cd = tscCommonService.getNextSequence("SEQ_CATE").toString();
  3211. sizeInfo.setSizeCate1Cd(sizeCate1Cd);
  3212. sizeInfo.setSizeCate2Cd(sizeCate1Cd);
  3213. }
  3214. }
  3215. sizeInfo.setRegNo(TsaSession.getInfo().getUserNo());
  3216. sizeInfo.setUpdNo(TsaSession.getInfo().getUserNo());
  3217. goodsDao.saveSizeInfo(sizeInfo);
  3218. }
  3219. /**
  3220. * 총알배송 제외 상품 건수
  3221. *
  3222. * @param goodsSearch
  3223. * @return
  3224. * @author eskim
  3225. * @since 2021. 02. 25
  3226. */
  3227. public int getGoodsQuikDeleverySkipCount(GoodsSearch goodsSearch) {
  3228. return goodsDao.getGoodsQuikDeleverySkipCount(goodsSearch);
  3229. }
  3230. /**
  3231. * 총알배송 제외 상품 목록
  3232. *
  3233. * @param goodsSearch
  3234. * @return
  3235. * @author eskim
  3236. * @since 2021. 02. 25
  3237. */
  3238. public Collection<Goods> getGoodsQuikDeleverySkipList(GoodsSearch goodsSearch) {
  3239. return goodsDao.getGoodsQuikDeleverySkipList(goodsSearch);
  3240. }
  3241. /**
  3242. * 총알배송 제외 상품 저장
  3243. *
  3244. * @param goods
  3245. * @author eskim
  3246. * @since 2021. 02. 25
  3247. */
  3248. @Transactional("shopTxnManager")
  3249. public void createGoodsQuikDeleverySkip(Goods goods) {
  3250. if (goods.getArrGoodsCd().length <= 0) {
  3251. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  3252. }
  3253. GoodsSearch search = new GoodsSearch();
  3254. search.setConditionList(goods.getArrGoodsCd());
  3255. search.setSearch("searchGoodsCd");
  3256. int cnt = getGoodsListCount(search);
  3257. if (cnt < goods.getArrGoodsCd().length) {
  3258. throw new IllegalStateException("상품코드를 확인해주세요.");
  3259. }
  3260. goods.setRegNo(TsaSession.getInfo().getUserNo());
  3261. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  3262. for (String goodsCd : goods.getArrGoodsCd()) {
  3263. goods.setGoodsCd(goodsCd);
  3264. goodsDao.createGoodsQuikDeleverySkip(goods);
  3265. }
  3266. }
  3267. /**
  3268. * 총알배송 제외 상품 삭제
  3269. *
  3270. * @param goods
  3271. * @author eskim
  3272. * @since 2021. 02. 25
  3273. */
  3274. @Transactional("shopTxnManager")
  3275. public void deleteGoodsQuikDeleverySkip(Goods goods) {
  3276. if (goods.getArrGoodsCd().length <= 0) {
  3277. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  3278. }
  3279. goodsDao.deleteGoodsQuikDeleverySkip(goods);
  3280. }
  3281. /**
  3282. * 상품 입출고 엑셀조회용 상품 저장
  3283. *
  3284. * @param procJob : goodsExcelUpload
  3285. * @param goodsSizeList
  3286. * @return
  3287. * @author eskim
  3288. * @since 2020. 02. 13
  3289. */
  3290. @Transactional("shopTxnManager")
  3291. public void saveGoodsSizeSoldoutExcelupload(Collection<Goods> goodsList, String excelFilename) {
  3292. String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
  3293. if (goodsList == null || goodsList.isEmpty()) {
  3294. this.deleteExceluploadFile(targetPath, excelFilename);
  3295. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  3296. }
  3297. //건수
  3298. if (goodsList != null && goodsList.size() > EXCEL_ROW_COUNT) {
  3299. throw new IllegalStateException("엑셀 파일의 건수를 " + EXCEL_ROW_COUNT + "건 이하로 사용하세요.");
  3300. }
  3301. // 검증
  3302. GoodsSearch search = new GoodsSearch();
  3303. search.setSearch("searchGoodsCd");
  3304. int index = 0;
  3305. for (Goods goods : goodsList) {
  3306. search.setGoodsCd(goods.getGoodsCd());
  3307. int cnt = getGoodsListCount(search);
  3308. if (cnt == 0) {
  3309. throw new IllegalStateException("상품코드를 확인해주세요.");
  3310. }
  3311. goods.setRegNo(TsaSession.getInfo().getUserNo());
  3312. // 엑셀조회를 위한 SEARCH 테이블 생성
  3313. SearchData searchData = new SearchData();
  3314. searchData.setRegNo(goods.getRegNo());
  3315. searchData.setSearchCd(goods.getGoodsCd());
  3316. searchData.setDispOrd(index);
  3317. if (index == 0) {
  3318. commonService.deleteExceluploadSearCh(searchData);
  3319. }
  3320. commonService.createExceluploadSearch(searchData);
  3321. goodsDao.createGoodsQuikDeleverySkip(goods);
  3322. index++;
  3323. }
  3324. }
  3325. /**
  3326. * 상품 모델 정보
  3327. *
  3328. * @param goodsImg
  3329. * @return
  3330. * @author eskim
  3331. * @since 2021. 04. 27
  3332. */
  3333. public GoodsImg getGoodsModelInfo(GoodsImg goodsImg) {
  3334. return goodsDao.getGoodsModelInfo(goodsImg);
  3335. }
  3336. /**
  3337. * 상품 모델 정보 저장
  3338. *
  3339. * @param goodsImg
  3340. * @return
  3341. * @author eskim
  3342. * @since 2020.04. 27
  3343. */
  3344. @Transactional("shopTxnManager")
  3345. public void saveGoodsModelInfo(GoodsImg goodsImg) {
  3346. goodsDao.saveGoodsModelInfo(goodsImg);
  3347. }
  3348. /**
  3349. * WMS입고단품목록 건수
  3350. *
  3351. * @param goodsSearch
  3352. * @return Collection<WmsGoods>
  3353. * @author eskim
  3354. * @since 2021. 06. 28
  3355. */
  3356. public int getGoodsWmsIncomelotSkuListCount(IfIncomelot iIfIncomelot) {
  3357. return goodsDao.getGoodsWmsIncomelotSkuListCount(iIfIncomelot);
  3358. }
  3359. /**
  3360. * WMS입고단품목록 조회
  3361. *
  3362. * @param goodsSearch
  3363. * @return Collection<WmsGoods>
  3364. * @author eskim
  3365. * @since 2021. 06. 28
  3366. */
  3367. public Collection<WmsGoods> getGoodsWmsIncomelotSkuList(IfIncomelot ifIncomelot) {
  3368. return goodsDao.getGoodsWmsIncomelotSkuList(ifIncomelot);
  3369. }
  3370. /**
  3371. * 자사 상품 등록
  3372. *
  3373. * @param goods
  3374. * @return
  3375. * @author eskim
  3376. * @since 2021. 07. 04
  3377. */
  3378. @Transactional("shopTxnManager")
  3379. public void createSalfGoodsDetail(Goods goods) {
  3380. // 중복여부 확인
  3381. Goods goodsDup = goodsDao.getGoods(goods);
  3382. if (goodsDup != null) {
  3383. throw new IllegalStateException("자사상품코드 중복요청입니다.");
  3384. }
  3385. // 입고여부확인
  3386. WmsGoods WmsGoods = goodsDao.getWmsGoodsInfo(goods);
  3387. if (WmsGoods == null) {
  3388. throw new IllegalStateException("미입고 상품코드입니다.");
  3389. }
  3390. Brand brand = new Brand();
  3391. brand.setSupplyCompCd(goods.getSupplyCompCd());
  3392. brand.setBrandCd(goods.getBrandCd());
  3393. int brandCount = goodsDao.getBrandSupplyCount(brand);
  3394. if (brandCount != 1) {
  3395. throw new IllegalStateException("미입고 상품의 업체/브랜드코드와 상품의 업체/브랜드코드가 상이합니다.");
  3396. }
  3397. goods.setErpStockLinkYn("Y");
  3398. goods.setGoodsStat("G008_20");
  3399. goods.setNewCustOrdYn("N");
  3400. goods.setSelfGoodsYn("Y");
  3401. goods.setGoodsType("G056_N");
  3402. goods.setTobeFormYn("Y");
  3403. // <,> replace 처리
  3404. goods.setRegNo(TsaSession.getInfo().getUserNo());
  3405. goods.setUpdNo(TsaSession.getInfo().getUserNo());
  3406. // goods.setGoodsDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsDesc(), "&lt;", "<"), "&gt;", ">"));
  3407. // goods.setGoodsPcTopDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsPcTopDesc(), "&lt;", "<"), "&gt;", ">"));
  3408. // goods.setGoodsMobileTopDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsMobileTopDesc(), "&lt;", "<"), "&gt;", ">"));
  3409. // goods.setGoodsPcDownDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsPcDownDesc(), "&lt;", "<"), "&gt;", ">"));
  3410. // goods.setGoodsMobileDownDesc(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsMobileDownDesc(), "&lt;", "<"), "&gt;", ">"));
  3411. //
  3412. // goods.setGoodsNm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsNm(), "&lt;", "<"), "&gt;", ">"));
  3413. // goods.setGoodsTnm(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsTnm(), "&lt;", "<"), "&gt;", ">"));
  3414. // goods.setGoodsSnm1(GagaStringUtil.replace(GagaStringUtil.replace(goods.getGoodsSnm1(), "&lt;", "<"), "&gt;", ">"));
  3415. // 판매기간설정 eskim
  3416. goods.setSellStdt(goods.getSellStYMD().replaceAll("-", "") + goods.getSellStHH() + "0000");
  3417. goods.setSellEddt(goods.getSellEdYMD().replaceAll("-", "") + goods.getSellEdHH() + "5959");
  3418. // 품번코드
  3419. goods.setGoodsNum(goods.getGoodsCd());
  3420. // 입점상품코드
  3421. goods.setSupplyGoodsCd(goods.getGoodsCd());
  3422. if (goods.getListPrice() < goods.getCurrPrice()) {
  3423. throw new IllegalStateException("판매가를 올바르게 입력해주세요.");
  3424. }
  3425. // 판매수수료율
  3426. SupplyCompany supplyCompany = new SupplyCompany();
  3427. supplyCompany.setSupplyCompCd(goods.getSupplyCompCd());
  3428. Collection<SupplyCompany> supplyCompanyList = businessService.getSupplyCompanyList(supplyCompany);
  3429. if (supplyCompanyList == null || supplyCompanyList.isEmpty()) {
  3430. throw new IllegalStateException("업체정보를 확인해 주세요.");
  3431. }
  3432. goods.setSellFeeRate(supplyCompanyList.iterator().next().getSellFeeRate()); // 판매수수료율
  3433. // 적립포인트 관련 브랜드 확인
  3434. // Brand brand = new Brand();
  3435. brand.setBrandCd(goods.getBrandCd());
  3436. Collection<Brand> brandList = businessService.getBrandList(brand);
  3437. if (brandList == null || brandList.isEmpty()) {
  3438. throw new IllegalStateException("상품브랜드를 확인해 주세요.");
  3439. }
  3440. float pntPrate = 0f;
  3441. float pntMrate = 0f;
  3442. String distributionGb = "G065_12";
  3443. for (Brand tmpBrand : brandList) {
  3444. if ("G009_10".equals(goods.getFormalGb())) {
  3445. pntPrate = tmpBrand.getPntPrate10();
  3446. pntMrate = tmpBrand.getPntMrate10();
  3447. } else {
  3448. pntPrate = tmpBrand.getPntPrate20();
  3449. pntMrate = tmpBrand.getPntMrate20();
  3450. }
  3451. distributionGb = tmpBrand.getDistributionGb(); //유통구분
  3452. }
  3453. goods.setPntPrate(pntPrate); // 포인트적립율(PC)
  3454. goods.setPntMrate(pntMrate); // 포인트적립율(MOBILE)
  3455. goods.setPrePpntUsableYn("N");
  3456. goods.setPreMpntUsableYn("N");
  3457. goods.setDistributionGb(distributionGb);
  3458. //출고처 코드
  3459. goods.setDelvLocCd("DL001"); // 자사상품 출고처 코드 고정
  3460. // 기본정보 생성
  3461. goodsDao.createGoods(goods); // 상품기본 저장
  3462. goodsDao.createGoodsSmmary(goods); // 상품통계 생성
  3463. WmsGoods wmsGoods = new WmsGoods();
  3464. wmsGoods.setUpdNo(TsaSession.getInfo().getUserNo());
  3465. wmsGoods.setGoodsRegGb("G"); // G: 상품, F: 사은품
  3466. wmsGoods.setModelNo(goods.getGoodsCd());
  3467. goodsDao.saveGoodsWmsIncomelotByModelNo(wmsGoods); // wms 상품 상품등록일 변경
  3468. // 사용자 검색어를 검색어에 적용
  3469. String goodsSnm = goodsDao.getGoodsSnm(goods.getGoodsCd());
  3470. if (!StringUtils.isBlank(goods.getGoodsSnm1())) {
  3471. String[] arrGoodsSnm = goods.getGoodsSnm1().split("\\;");
  3472. StringBuilder tempGoodsSnm = new StringBuilder();
  3473. for (String loopGoodsSnm : arrGoodsSnm) {
  3474. if (goodsSnm.toUpperCase().indexOf(loopGoodsSnm.toUpperCase()) <= -1) {
  3475. tempGoodsSnm.append(loopGoodsSnm).append(";");
  3476. }
  3477. }
  3478. goods.setGoodsSnm(tempGoodsSnm.toString() + goodsSnm);
  3479. } else if (!goodsSnm.equals(goods.getGoodsSnm())) {
  3480. goods.setGoodsSnm(goodsSnm);
  3481. }
  3482. // 상품타이틀 수정
  3483. goodsDao.updateGoodsSnm(goods);
  3484. // 상품사이즈 정보
  3485. Collection<IfProductSku> goodsWmsSizeList = wmsGoodsService.getGoodsWmsSizeList(goods.getGoodsCd());
  3486. if (goodsWmsSizeList == null || goodsWmsSizeList.isEmpty()) {
  3487. throw new IllegalStateException("WMS의 TB_IF_PRODUCTSKU 에 " + goods.getGoodsCd() + " 상품이 존재하지 않습니다.");
  3488. } else {
  3489. int index = 1;
  3490. for (IfProductSku ifProductSku : goodsWmsSizeList) {
  3491. Option wmsOption = goodsDao.getWmsColorStock(ifProductSku);
  3492. if (wmsOption == null) {
  3493. throw new IllegalStateException(goods.getGoodsCd() + " 의 WMS의 색상 " + ifProductSku.getWmsColorCd() + "이(가) WMS색상관리에 없습니다.");
  3494. }
  3495. Option goodsStock = new Option();
  3496. goodsStock.setGoodsCd(goods.getGoodsCd());
  3497. goodsStock.setOptCd(ifProductSku.getSkucode());
  3498. goodsStock.setOptCd1(wmsOption.getOptCd1());
  3499. goodsStock.setOptCd2(ifProductSku.getOption2());
  3500. goodsStock.setSkuModelNo(ifProductSku.getSkumodelno());
  3501. goodsStock.setProductNo(ifProductSku.getProductno());
  3502. goodsStock.setProductCode(ifProductSku.getProductcode());
  3503. goodsStock.setBaseStockQty(0);
  3504. goodsStock.setCurrStockQty(wmsOption.getCurrStockQty());
  3505. goodsStock.setStoreStockQty(0);
  3506. goodsStock.setStoreMaxQty(wmsOption.getCurrStockQty());
  3507. goodsStock.setAddPrice(0);
  3508. goodsStock.setSoldoutYn("N");
  3509. goodsStock.setDispOrd(index);
  3510. goodsStock.setDispYn("Y");
  3511. goodsStock.setRegNo(TsaSession.getInfo().getUserNo());
  3512. goodsStock.setUpdNo(TsaSession.getInfo().getUserNo());
  3513. goodsDao.saveStock(goodsStock);
  3514. index++;
  3515. }
  3516. }
  3517. // 상품 색상 , 사이즈 옵션 정보 조회
  3518. Goods goodsColorSize = goodsDao.getGoodsColorSize(goods);
  3519. if (goodsColorSize != null && !StringUtils.isBlank(goodsColorSize.getMainColorCd())) {
  3520. goodsColorSize.setUpdNo(TsaSession.getInfo().getUserNo());
  3521. goodsDao.updateGoodsMainColorCd(goodsColorSize); // 대표색상 설정
  3522. }
  3523. // 상품상세정보 저장
  3524. this.saveGoodsDetailDesc(goods);
  3525. // 상품 정보고시 변경
  3526. this.saveGoodsNotiInfo(goods);
  3527. // 전시카테고리 작업
  3528. goodsDao.createCategoryGoods(goods);
  3529. log.info("goods = {}", goods);
  3530. // 안전안증작업
  3531. if (!StringUtils.isEmpty(goods.getCertTargetGb())) {
  3532. GoodsSafeNo goodsSafeNo = new GoodsSafeNo();
  3533. goodsSafeNo.setGoodsCd(goods.getGoodsCd());
  3534. goodsSafeNo.setCertTargetGb(goods.getCertTargetGb());
  3535. goodsSafeNo.setCertFormGb(goods.getCertFormGb());
  3536. goodsSafeNo.setCertType(goods.getCertType());
  3537. goodsSafeNo.setCertNum(goods.getCertNum());
  3538. saveGoodsDetailCertNum(goodsSafeNo);
  3539. }
  3540. }
  3541. /**
  3542. * 상품 상세 컨텐츠 목록
  3543. *
  3544. * @param goodsSearch
  3545. * @return
  3546. * @author eskim
  3547. * @since 2021. 07. 14
  3548. */
  3549. public Collection<GoodsContents> getGoodsContentsList(GoodsSearch goodsSearch) {
  3550. return goodsDao.getGoodsContentsList(goodsSearch);
  3551. }
  3552. /**
  3553. * 상품 상세 컨텐츠 상품 목록
  3554. *
  3555. * @param notice
  3556. * @return
  3557. * @author eskim
  3558. * @since 2021. 07. 14
  3559. */
  3560. public Collection<GoodsContentsData> getGoodsContentsDataList(GoodsContents goodsContents) {
  3561. return goodsDao.getGoodsContentsDataList(goodsContents);
  3562. }
  3563. /**
  3564. * 상품 상세 컨텐츠 저장
  3565. * @param notice - 공지사항 정보
  3566. * @return
  3567. * @author eskim
  3568. * @since 2021. 07. 14
  3569. */
  3570. @Transactional("shopTxnManager")
  3571. public void saveGoodsContent(GoodsContents goodsContents) {
  3572. goodsContents.setRegNo(TsaSession.getInfo().getUserNo());
  3573. goodsContents.setUpdNo(TsaSession.getInfo().getUserNo());
  3574. //신규이미지가 있을 경우
  3575. if(!StringUtils.isEmpty(goodsContents.getNewImgPath())){
  3576. String displayUploadPath = env.getProperty("upload.default.target.path");
  3577. displayUploadPath = GagaFileUtil.getConcatenationPath(displayUploadPath, "goodscontents");
  3578. File file = new File(GagaFileUtil.getConcatenationPath(displayUploadPath, goodsContents.getNewImgPath()));
  3579. String yearMonth = GagaDateUtil.getToday().substring(0, 6);
  3580. displayUploadPath = GagaFileUtil.getConcatenationPath(displayUploadPath, yearMonth);
  3581. log.info("displayUploadPath {}", displayUploadPath);
  3582. File contentsPath = new File(displayUploadPath);
  3583. if (!contentsPath.exists()) {
  3584. contentsPath.mkdir();
  3585. }
  3586. String newFilename = "GOODSCONTENTS_" + GagaDateUtil.getTodayDateTime() + "." + org.springframework.util.StringUtils.getFilenameExtension(goodsContents.getNewImgPath());
  3587. File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(displayUploadPath, newFilename)));
  3588. // 기존이미지 삭제
  3589. try{
  3590. GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(displayUploadPath, goodsContents.getImgPath()));
  3591. }catch (IOException e){
  3592. // nothing
  3593. log.info("[saveGoodsContent 기존 이미지 삭제중 error]");
  3594. //e.printStackTrace();
  3595. }
  3596. // Rename a file
  3597. file.renameTo(uniqueFile);
  3598. goodsContents.setImgPath("/goodscontents/"+ yearMonth +'/'+ newFilename);
  3599. }
  3600. log.info("saveGoodsContent =={}", goodsContents);
  3601. // 신규 일때
  3602. if (goodsContents.getGoodsContentsSq() == null) {
  3603. // 저장
  3604. goodsDao.createGoodsContents(goodsContents);
  3605. // 등록된 값 가져오기
  3606. Integer goodsContentsSq = goodsContents.getGoodsContentsSq();
  3607. goodsContents.setGoodsContentsSq(goodsContentsSq);
  3608. } else {
  3609. // 수정
  3610. goodsDao.updateGoodsContents(goodsContents);
  3611. }
  3612. if (!StringUtils.isBlank(goodsContents.getGoodsList())) {
  3613. Collection<GoodsContentsData> noticeGoodsList = null;
  3614. try {
  3615. noticeGoodsList = mapper.readValue(goodsContents.getGoodsList(), new TypeReference<Collection<GoodsContentsData>>() {
  3616. });
  3617. } catch (Exception e) {
  3618. e.printStackTrace();
  3619. throw new IllegalStateException(message.getMessage("상품상세컨텐츠 상품 저장 중 오류로 인해 저장되지 않았습니다."));
  3620. }
  3621. //log.info("noticeGoodsList: {}", noticeGoodsList);
  3622. for (GoodsContentsData goodsContentsData : noticeGoodsList) {
  3623. goodsContentsData.setGoodsContentsSq(goodsContents.getGoodsContentsSq());
  3624. goodsContentsData.setRegNo(TsaSession.getInfo().getUserNo());
  3625. goodsContentsData.setUpdNo(TsaSession.getInfo().getUserNo());
  3626. goodsDao.saveGoodsContent(goodsContentsData);
  3627. }
  3628. }
  3629. }
  3630. /**
  3631. * 상품 상세 컨텐츠 상품 삭제
  3632. * @param noticeGoods
  3633. * @return
  3634. * @author eskim
  3635. * @since 2021. 07. 14
  3636. */
  3637. @Transactional("shopTxnManager")
  3638. public void deleteGoodsContentGoods(GoodsContentsData goodsContentsData) {
  3639. if (goodsContentsData == null || (goodsContentsData.getArrGoodsCd() == null && goodsContentsData.getArrGoodsCd().length <= 0)) {
  3640. throw new IllegalStateException(message.getMessage("FAIL_1001"));
  3641. }
  3642. if (goodsContentsData.getArrGoodsCd().length > 0) {
  3643. for (String goodsCd : goodsContentsData.getArrGoodsCd()) {
  3644. goodsContentsData.setGoodsCd(goodsCd);
  3645. goodsContentsData.setRegNo(TsaSession.getInfo().getUserNo());
  3646. goodsContentsData.setUpdNo(TsaSession.getInfo().getUserNo());
  3647. goodsDao.deleteGoodsContentGoods(goodsContentsData);
  3648. }
  3649. }
  3650. }
  3651. }