TssPlanService.java 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. package com.style24.scm.biz.service;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.util.ArrayList;
  5. import java.util.Collection;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.core.env.Environment;
  8. import org.springframework.stereotype.Service;
  9. import org.springframework.transaction.annotation.Transactional;
  10. import org.springframework.util.StringUtils;
  11. import com.fasterxml.jackson.databind.ObjectMapper;
  12. import com.gagaframework.web.parameter.GagaMap;
  13. import com.gagaframework.web.util.GagaDateUtil;
  14. import com.gagaframework.web.util.GagaFileUtil;
  15. import com.gagaframework.web.util.GagaStringUtil;
  16. import com.style24.persistence.domain.Plan;
  17. import com.style24.scm.biz.dao.TssPlanDao;
  18. import com.style24.scm.support.security.session.TssSession;
  19. import lombok.extern.slf4j.Slf4j;
  20. /**
  21. * 기획전 Service
  22. *
  23. * @author sowon
  24. * @since 2021. 02. 04
  25. */
  26. @Service
  27. @Slf4j
  28. public class TssPlanService {
  29. @Autowired
  30. private TssPlanDao planDao;
  31. @Autowired
  32. private Environment env;
  33. @Autowired
  34. private ObjectMapper mapper;
  35. /**
  36. * 기획전 목록
  37. *
  38. * @param
  39. * @return
  40. * @author sowon
  41. * @since 2021. 2. 5
  42. */
  43. public Collection<Plan> getPlanList(Plan param) {
  44. return planDao.getPlanList(param);
  45. }
  46. /**
  47. * 기획전 목록 카운트 조회
  48. * @param param
  49. * @return int
  50. * @author sowon
  51. * @since 2021. 2. 5
  52. */
  53. public int getPlanListCount(Plan param) {
  54. return planDao.getPlanListCount(param);
  55. }
  56. /**
  57. * 기획전 카테고리 목록
  58. *
  59. * @param plan
  60. * @return
  61. * @author sowon
  62. * @since 2021. 05. 05
  63. */
  64. public Collection<Plan> getPlanningCategoryList(Plan param){
  65. return planDao.getPlanningCategoryList(param);
  66. }
  67. /**
  68. * 기획전 웹 등록
  69. *
  70. * @param
  71. * @return
  72. * @author sowon
  73. * @since 2021. 5. 5
  74. */
  75. @Transactional("shopTxnManager")
  76. public void createPlanInfo(Plan param) {
  77. Plan plan = new Plan();
  78. // 입점업체담당자는 업체코드 설정
  79. if ("G001_B000".equals(TssSession.getInfo().getRoleCd())) {
  80. param.setRegNo(TssSession.getInfo().getUserNo());
  81. param.setUpdNo(TssSession.getInfo().getUserNo());
  82. }
  83. int ind = 1;
  84. if(param.getMainPimg() != null && !"".equals(param.getMainPimg())){
  85. String imgInd = String.valueOf(ind);
  86. if (ind < 10) {
  87. imgInd = "0" + imgInd;
  88. }
  89. String planUploadPath = env.getProperty("upload.default.target.path");
  90. String yearMonth = GagaDateUtil.getToday().substring(0, 6);
  91. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, "/planning");
  92. File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainPimg()));
  93. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
  94. String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainPimg());
  95. File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(planUploadPath, newFilename)));
  96. // Rename a file
  97. File path = new File(planUploadPath);
  98. if (!path.exists()) {
  99. path.mkdir();
  100. }
  101. newFile.renameTo(uniqueFile);
  102. param.setMainPimg("/planning/" + yearMonth + "/" + newFilename);
  103. param.setMainMimg("/planning/" + yearMonth + "/" + newFilename);
  104. }
  105. planDao.createPlanInfo(param);
  106. String[] brand = param.getMultiBrand();
  107. // 기획전 브랜드 insert
  108. for (int j = 0; j < brand.length; j++) {
  109. plan.setBrandGroupNo(brand[j]);
  110. plan.setPlanSq(param.getPlanSq());
  111. plan.setRegNo(TssSession.getInfo().getUserNo());
  112. plan.setUpdNo(TssSession.getInfo().getUserNo());
  113. planDao.createPlanBrand(plan);
  114. }
  115. String[] cate = param.getMultiCate();
  116. // 기획전 카테고리insert
  117. for (int j = 0; j < cate.length; j++) {
  118. plan.setCateNo(cate[j]);
  119. plan.setPlanSq(param.getPlanSq());
  120. plan.setRegNo(TssSession.getInfo().getUserNo());
  121. plan.setUpdNo(TssSession.getInfo().getUserNo());
  122. planDao.createPlanCate(plan);
  123. }
  124. // 기획전 회원구분 insert
  125. String[] custGb = param.getUsableCustGbArr();
  126. for (int j = 0; j < custGb.length; j++) {
  127. plan.setCustGb(custGb[j]);
  128. plan.setPlanSq(param.getPlanSq());
  129. plan.setRegNo(TssSession.getInfo().getUserNo());
  130. planDao.createPlanCustGb(plan);
  131. }
  132. // 기획전 회원등급 insert
  133. String[] custGrade = param.getUsableCustGradeArr();
  134. for (int j = 0; j < custGrade.length; j++) {
  135. plan.setCustGrade(custGrade[j]);
  136. plan.setPlanSq(param.getPlanSq());
  137. plan.setRegNo(TssSession.getInfo().getUserNo());
  138. planDao.createPlanCustGrade(plan);
  139. }
  140. }
  141. /**
  142. * 기획전 상세 정보
  143. *
  144. * @param
  145. * @return
  146. * @author sowon
  147. * @since 2021. 5. 5
  148. */
  149. public Plan getPlanDetailInfo(Plan param) {
  150. Collection<Plan> planList = planDao.getPlanList(param);
  151. Plan planInfo = new Plan();
  152. if (!planList.isEmpty()) {
  153. for (Plan plan : planList) {
  154. planInfo = plan;
  155. }
  156. }
  157. // 날짜 설정
  158. String[] stDate = planInfo.getDispStdt().split(" ");
  159. planInfo.setStartSearchDate(stDate[0]);
  160. planInfo.setStartSearchTime(GagaStringUtil.replace(stDate[1], ":", "").substring(0, 6));
  161. String[] edDate = planInfo.getDispEddt().split(" ");
  162. planInfo.setEndSearchDate(edDate[0]);
  163. planInfo.setEndSearchTime(GagaStringUtil.replace(edDate[1], ":", "").substring(0, 6));
  164. return planInfo;
  165. }
  166. /**
  167. * 기획전 브랜드 목록
  168. *
  169. * @param
  170. * @return
  171. * @author sowon
  172. * @since 2021. 5. 5
  173. */
  174. public Collection<Plan> getPlanBrandList(Plan param){
  175. return planDao.getPlanBrandList(param);
  176. }
  177. /**
  178. * 기획전 카테고리 목록
  179. *
  180. * @param
  181. * @return
  182. * @author sowon
  183. * @since 2021. 5. 5
  184. */
  185. public Collection<Plan> getPlanCateList(Plan param){
  186. return planDao.getPlanCateList(param);
  187. }
  188. /**
  189. * 기획전 웹 수정
  190. *
  191. * @param
  192. * @return
  193. * @author sowon
  194. * @since 2021. 2. 8
  195. */
  196. @Transactional("shopTxnManager")
  197. public void updatePlanInfo(Plan param) {
  198. Plan plan = new Plan();
  199. log.debug("param {}", param);
  200. String targetPath = env.getProperty("upload.default.target.path") + "/planning";
  201. param.setRegNo(TssSession.getInfo().getUserNo());
  202. param.setUpdNo(TssSession.getInfo().getUserNo());
  203. // 이미지 삭제 여부에 따른 이미지 삭제 처리
  204. if (("Y").equals(param.getOrgMainPimgDelYn())) {
  205. deleteFile(targetPath, param.getOrgMainPimg());
  206. }
  207. if (("Y").equals(param.getOrgMainMimgDelYn())) {
  208. deleteFile(targetPath, param.getOrgMainMimg());
  209. }
  210. if (("Y").equals(param.getOrgDtlPimgDelYn())) {
  211. deleteFile(targetPath, param.getOrgDtlPimg());
  212. }
  213. if (("Y").equals(param.getOrgDtlMimgDelYn())) {
  214. deleteFile(targetPath, param.getOrgDtlMimg());
  215. }
  216. if (("Y").equals(param.getOrgReplyImgDelYn())) {
  217. //param.setReplyImg(null);
  218. deleteFile(targetPath, param.getOrgReplyImg());
  219. }
  220. // 기존 기획전 카테고리 삭제
  221. planDao.deletePlanCate(param);
  222. String[] cate = param.getMultiCate();
  223. // 기획전 카테고리insert
  224. for (int j = 0; j < cate.length; j++) {
  225. plan.setCateNo(cate[j]);
  226. plan.setPlanSq(param.getPlanSq());
  227. plan.setRegNo(TssSession.getInfo().getUserNo());
  228. plan.setUpdNo(TssSession.getInfo().getUserNo());
  229. planDao.createPlanCate(plan);
  230. }
  231. // 기존 기획전 브랜드 삭제
  232. planDao.deletePlanBrand(param);;
  233. String[] brand = param.getMultiBrand();
  234. // 기획전 브랜드 insert
  235. for (int j = 0; j < brand.length; j++) {
  236. plan.setBrandGroupNo(brand[j]);
  237. plan.setPlanSq(param.getPlanSq());
  238. plan.setRegNo(TssSession.getInfo().getUserNo());
  239. plan.setUpdNo(TssSession.getInfo().getUserNo());
  240. planDao.createPlanBrand(plan);
  241. }
  242. //기존 회원구분 삭제
  243. planDao.deletePlanCustGb(param);
  244. // 기획전 회원구분 insert
  245. String[] custGb = param.getUsableCustGbArr();
  246. for (int j = 0; j < custGb.length; j++) {
  247. plan.setCustGb(custGb[j]);
  248. plan.setPlanSq(param.getPlanSq());
  249. plan.setRegNo(TssSession.getInfo().getUserNo());
  250. planDao.createPlanCustGb(plan);
  251. }
  252. //기존 회원등급 삭제
  253. planDao.deletePlanCustGrade(param);
  254. // 기획전 회원등급 insert
  255. String[] custGrade = param.getUsableCustGradeArr();
  256. for (int j = 0; j < custGrade.length; j++) {
  257. plan.setCustGrade(custGrade[j]);
  258. plan.setPlanSq(param.getPlanSq());
  259. plan.setRegNo(TssSession.getInfo().getUserNo());
  260. planDao.createPlanCustGrade(plan);
  261. }
  262. int ind = 1;
  263. param.setMainMimg(param.getMainPimg());
  264. if(param.getMainPimg() != null && !"".equals(param.getMainPimg())){
  265. String imgInd = String.valueOf(ind);
  266. if (ind < 10) {
  267. imgInd = "0" + imgInd;
  268. }
  269. if (!param.getMainPimg().contains("planning")) {
  270. String planUploadPath = env.getProperty("upload.default.target.path");
  271. String yearMonth = GagaDateUtil.getToday().substring(0, 6);
  272. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, "/planning");
  273. File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainPimg()));
  274. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
  275. String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainPimg());
  276. File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(planUploadPath, newFilename)));
  277. // Rename a file
  278. File path = new File(planUploadPath);
  279. if (!path.exists()) {
  280. path.mkdir();
  281. }
  282. newFile.renameTo(uniqueFile);
  283. param.setMainPimg("/planning/" + yearMonth + "/" + newFilename);
  284. }
  285. }
  286. if(param.getMainMimg() != null && !"".equals(param.getMainMimg())){
  287. String imgInd = String.valueOf(ind);
  288. if (ind < 10) {
  289. imgInd = "0" + imgInd;
  290. }
  291. if(!param.getMainMimg().contains("planning")) {
  292. String planUploadPath = env.getProperty("upload.default.target.path");
  293. String yearMonth = GagaDateUtil.getToday().substring(0, 6);
  294. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, "/planning");
  295. File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainMimg()));
  296. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
  297. String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainMimg());
  298. File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(planUploadPath, newFilename)));
  299. // Rename a file
  300. File path = new File(planUploadPath);
  301. if (!path.exists()) {
  302. path.mkdir();
  303. }
  304. newFile.renameTo(uniqueFile);
  305. param.setMainMimg("/planning/" + yearMonth + "/" + newFilename);
  306. }
  307. }
  308. // 최종업데이트
  309. planDao.updatePlanInfo(param);
  310. //기획전 응모이벤트
  311. // if (StringUtils.isNotBlank(param.getPrivacyPolicy())) {
  312. // int i = 0;
  313. // for (String planQtitle : param.getPlanQtitle()) {
  314. // PlanQuestAnswer planQuestAnswer = new TsaPlanQuestAnswer();
  315. // planQuestAnswer.setPlanSq(param.getPlanSq());
  316. // planQuestAnswer.setPlanQtitle(planQtitle);
  317. // planQuestAnswer.setAttachYn(param.getAttachYn()[i]);
  318. // planQuestAnswer.setQuestNo(i);
  319. // planQuestAnswer.setRegNo(param.getRegNo());
  320. // planQuestAnswer.setUpdNo(param.getUpdNo());
  321. // planDao.savePlanQuestion(planQuestAnswer);
  322. // i++;
  323. // }
  324. // }
  325. }
  326. /**
  327. * 기획전 코너 목록 조회
  328. *
  329. * @param
  330. * @return
  331. * @author sowon
  332. * @since 2021. 05. 06
  333. */
  334. public Collection<Plan> getPlanCornerList(Plan param) {
  335. Collection<Plan> cornerList = planDao.getPlanCornerList(param);
  336. for (Plan corner : cornerList) {
  337. // 날짜 설정
  338. String[] stDate = corner.getDispStdt().split(" ");
  339. corner.setStartSearchDate(stDate[0]);
  340. corner.setStartSearchTime(stDate[1].substring(0, 8));
  341. String[] edDate = corner.getDispEddt().split(" ");
  342. corner.setEndSearchDate(edDate[0]);
  343. corner.setEndSearchTime(edDate[1].substring(0, 8));
  344. }
  345. return cornerList;
  346. }
  347. /**
  348. * 기획전 코너 저장
  349. *
  350. * @param
  351. * @return
  352. * @author sowon
  353. * @since 2021. 05. 06
  354. */
  355. @Transactional("shopTxnManager")
  356. public void savePlanCornerInfo(Collection<Plan> paramList) {
  357. for (Plan cornerInfo : paramList) {
  358. cornerInfo.setRegNo(TssSession.getInfo().getUserNo());
  359. cornerInfo.setUpdNo(TssSession.getInfo().getUserNo());
  360. planDao.savePlanCornerInfo(cornerInfo);
  361. }
  362. }
  363. /**
  364. * 기획전 코너 상품 조회 건수
  365. *
  366. * @param
  367. * @return
  368. * @author sowon
  369. * @since 2021. 05. 06
  370. */
  371. public int getPlanGoodsListCount(Plan param) {
  372. return planDao.getPlanGoodsListCount(param);
  373. }
  374. /**
  375. * 기획전 코너 상품 조회
  376. *
  377. * @param
  378. * @return
  379. * @author sowon
  380. * @since 2021. 05. 06
  381. */
  382. public Collection<Plan> getPlanGoodsList(Plan param) {
  383. return planDao.getPlanGoodsList(param);
  384. }
  385. /**
  386. * 파일 삭제
  387. *
  388. * @param targetPath
  389. * @param excelFilename
  390. * @author sowon
  391. * @since 2021. 5. 6
  392. */
  393. private void deleteFile(String targetPath, String excelFilename) {
  394. // 파일 삭제
  395. try {
  396. GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(targetPath, excelFilename));
  397. } catch (IOException e) {
  398. // Nothing Do
  399. }
  400. }
  401. /**
  402. * 기획전 코너 상품 엑셀 저장
  403. *
  404. * @param
  405. * @return
  406. * @author sowon
  407. * @since 2021. 5. 6
  408. */
  409. @Transactional("shopTxnManager")
  410. public void createExceluploadGoods(Collection<GagaMap> ecxelGoodsList, Plan param) {
  411. String targetPath = env.getProperty("upload.excel.target.path");
  412. if ((ecxelGoodsList == null || ecxelGoodsList.isEmpty())) {
  413. deleteFile(targetPath, param.getExcelFileNm());
  414. throw new IllegalStateException("저장 할 데이터가 없습니다.");
  415. }
  416. Collection<Plan> dtlPlan = new ArrayList<>();
  417. Collection<Plan> goodsList = new ArrayList<>();
  418. long tempPlanDtlSq = 0;
  419. for (GagaMap gagaMap : ecxelGoodsList) {
  420. Plan planGoods = mapper.convertValue(gagaMap, Plan.class);
  421. planGoods.setPlanSq(param.getPlanSq());
  422. String planDtlSq = String.valueOf(planGoods.getPlanDtlSq());
  423. if (org.apache.commons.lang3.StringUtils.isBlank(planDtlSq)) {
  424. throw new IllegalStateException("상품코드 : " + planGoods.getGoodsCd() + " 기획전 코너 번호가 없습니다.");
  425. }
  426. if (org.apache.commons.lang3.StringUtils.isBlank(planGoods.getGoodsCd())) {
  427. throw new IllegalStateException("비어 있는 상품코드가 존재합니다.");
  428. }
  429. // 중복 확인 위한 데이터 적제
  430. if (tempPlanDtlSq != planGoods.getPlanDtlSq()) {
  431. dtlPlan.add(planGoods);
  432. }
  433. // 상품 데이터 적제
  434. goodsList.add(planGoods);
  435. }
  436. // 기획전 유효성 체크
  437. for (Plan plan : dtlPlan) {
  438. Plan searchCorner = new Plan();
  439. searchCorner.setPlanSq(plan.getPlanSq());
  440. searchCorner.setPlanDtlSq(plan.getPlanDtlSq());
  441. Collection<Plan> cornerList = planDao.getPlanCornerList(searchCorner);
  442. if (cornerList == null || cornerList.isEmpty()) {
  443. throw new IllegalStateException("상품코드 : " + plan.getGoodsCd() + "의 " + plan.getPlanDtlSq() + " 기획전 코너가 존재 하지 않습니다.");
  444. }
  445. }
  446. // 기획전 상품 저장
  447. for (Plan goods : goodsList) {
  448. savePlanCornerGoods(goods);
  449. }
  450. }
  451. /**
  452. * 기획전 코너 상품 저장
  453. *
  454. * @param
  455. * @return
  456. * @author sowon
  457. * @since 2021. 05. 06
  458. */
  459. @Transactional("shopTxnManager")
  460. public void savePlanCornerGoods(Plan param) {
  461. Plan plan = new Plan();
  462. plan.setRegNo(TssSession.getInfo().getUserNo());
  463. plan.setUpdNo(TssSession.getInfo().getUserNo());
  464. plan.setGoodsCd(param.getGoodsCd());
  465. plan.setPlanDtlSq(param.getPlanDtlSq());
  466. planDao.savePlanCornerGoods(plan);
  467. }
  468. /**
  469. * 기획전 코너 상품 추가
  470. *
  471. * @param
  472. * @return
  473. * @author sowon
  474. * @since 2021. 05. 06
  475. */
  476. @Transactional("shopTxnManager")
  477. public void savePlanGoods(Collection<Plan> paramList) {
  478. for (Plan param : paramList) {
  479. savePlanCornerGoods(param);
  480. }
  481. }
  482. /**
  483. * 기획전 코너 삭제 처리
  484. *
  485. * @param
  486. * @return
  487. * @author sowon
  488. * @since 2021. 05. 06
  489. */
  490. @Transactional("shopTxnManager")
  491. public void deletePlanCornerInfo(Collection<Plan> paramList) {
  492. for (Plan cornerInfo : paramList) {
  493. planDao.deletePlanCornerInfo(cornerInfo);
  494. planDao.deletePlanCornerGoods(cornerInfo);
  495. }
  496. }
  497. /**
  498. * 기획전 코너 상품 삭제 처리
  499. *
  500. * @param
  501. * @return
  502. * @author sowon
  503. * @since 2021. 05. 06
  504. */
  505. @Transactional("shopTxnManager")
  506. public void deletePlanCornerGoods(Collection<Plan> paramList) {
  507. for (Plan cornerInfo : paramList) {
  508. planDao.deletePlanCornerGoods(cornerInfo);
  509. }
  510. }
  511. /**
  512. * 기획전 템플릿 목록 카운트 조회
  513. * @param param
  514. * @return int
  515. * @author sowon
  516. * @since 2021. 05. 06
  517. */
  518. public int getPlanContentsCount(Plan param) {
  519. return planDao.getPlanContentsCount(param);
  520. }
  521. /**
  522. * 기획전 템플릿 상세조회 - 리뷰
  523. *
  524. * @param
  525. * @return
  526. * @author sowon
  527. * @since 2021. 05. 06
  528. */
  529. public Collection<Plan> getPlanContentReviewList(Plan param){
  530. return planDao.getPlanContentReviewList(param);
  531. }
  532. /**
  533. * 기획전 템플릿 상세조회 - 쿠폰
  534. *
  535. * @param
  536. * @return
  537. * @author sowon
  538. * @since 2021. 05. 06
  539. */
  540. public Collection<Plan> getPlanContentCouponList(Plan param){
  541. return planDao.getPlanContentCouponList(param);
  542. }
  543. /**
  544. * 기획전 템플릿 상세조회 - 쿠폰유의사항
  545. *
  546. * @param
  547. * @return
  548. * @author sowon
  549. * @since 2021. 5 .26
  550. */
  551. public Plan getPlanContentCouponNotice(Plan param){
  552. return planDao.getPlanContentCouponNotice(param);
  553. }
  554. /**
  555. * 기획전 템플릿 상세조회 - 파일
  556. *
  557. * @param
  558. * @return
  559. * @author sowon
  560. * @since 2021. 05. 06
  561. */
  562. public Collection<Plan> getPlanContentFileList(Plan param){
  563. return planDao.getPlanContentFileList(param);
  564. }
  565. /**
  566. * 기획전 템플릿 상세조회 - 유의사항
  567. *
  568. * @param
  569. * @return
  570. * @author sowon
  571. * @since 2021. 5 .28
  572. */
  573. public Collection<Plan> getPlanContentNoticeList(Plan param){
  574. return planDao.getPlanContentNoticeList(param);
  575. }
  576. /**
  577. * 기획전 템플릿 상세조회 - html
  578. *
  579. * @param
  580. * @return
  581. * @author sowon
  582. * @since 2021. 05. 06
  583. */
  584. public Collection<Plan> getPlanContentFsrcList(Plan param){
  585. return planDao.getPlanContentFsrcList(param);
  586. }
  587. /**
  588. * 기획전 템플릿 상세조회 - goods
  589. *
  590. * @param
  591. * @return
  592. * @author sowon
  593. * @since 2021. 05. 06
  594. */
  595. public Collection<Plan> getPlanContentGoodsList(Plan param){
  596. return planDao.getPlanContentGoodsList(param);
  597. }
  598. /**
  599. * 기획전 템플릿 상세조회 - goods 목록조회
  600. *
  601. * @param
  602. * @return
  603. * @author sowon
  604. * @since 2021. 05. 06
  605. */
  606. public Collection<Plan> getPlanContentGoodsDetailList(Plan param){
  607. return planDao.getPlanContentGoodsDetailList(param);
  608. }
  609. /**
  610. * 기획전 템플릿 상품목록 삭제
  611. * @param
  612. * @return
  613. * @author sowon
  614. * @since 2021. 05. 06
  615. */
  616. @Transactional("shopTxnManager")
  617. public void deletePlanContentItemGoods(Integer planContSq) {
  618. planDao.deletePlanContentItemGoods(planContSq);
  619. }
  620. /**
  621. * 기획전 템플릿 컨텐츠 삭제
  622. * @param
  623. * @return
  624. * @author sowon
  625. * @since 2021. 05. 06
  626. */
  627. @Transactional("shopTxnManager")
  628. public void deletePlanContentItem(Integer planContSq) {
  629. planDao.deletePlanContentItem(planContSq);
  630. }
  631. /**
  632. * 기획전 템플릿 등록
  633. *
  634. * @param
  635. * @return
  636. * @author sowon
  637. * @since 2021. 2. 25
  638. */
  639. public void createPlanContents(Plan param) {
  640. Integer regNo = TssSession.getInfo().getUserNo();
  641. param.setRegNo(regNo);
  642. // 리뷰 등록
  643. Plan rePlan = new Plan();
  644. //리뷰 등록 - tb_plan_contents
  645. if(param.getReTitle() != "" || !org.apache.commons.lang3.StringUtils.isAllEmpty(param.getMultiPlanReview())) {
  646. rePlan.setRegNo(regNo);
  647. rePlan.setUpdNo(regNo);
  648. rePlan.setTmplType("G082_10");
  649. rePlan.setPlanSq(param.getPlanSq());
  650. rePlan.setTitle(param.getReTitle());
  651. rePlan.setDispYn(param.getReDispYn());
  652. rePlan.setDispOrd(param.getReDispOrd());
  653. rePlan.setPlanContSq(param.getRePlanContSq());
  654. planDao.createPlanContents(rePlan);
  655. // 기존 리뷰아이템 삭제
  656. planDao.deletePlanContentItem(param.getRePlanContSq());
  657. //리뷰 아이템 등록
  658. if(param.getMultiPlanReview().length>0) {
  659. String[] reItemVal = param.getMultiPlanReview();
  660. String[] startDate = param.getMultiPlanReviewStartD();
  661. String[] startTime = param.getMultiPlanReviewStartT();
  662. String[] endDate = param.getMultiPlanReviewEndD();
  663. String[] endTime = param.getMultiPlanReviewEndT();
  664. // 기획전 브랜드 insert
  665. for (int j = 0; j < reItemVal.length; j++) {
  666. rePlan.setItemVal(reItemVal[j]);
  667. rePlan.setReviewDispStdt(startDate[j] + ' ' +startTime[j]);
  668. rePlan.setReviewDispEddt(endDate[j] + ' ' +endTime[j]);
  669. planDao.createPlanContentsItem(rePlan);
  670. }
  671. }
  672. }
  673. // 쿠폰등록
  674. Plan cuPlan = new Plan();
  675. //쿠폰 등록 - tb_plan_contents
  676. if(param.getCuTitle() != "" || param.getMultiPlanCoupon().length>0) {
  677. cuPlan.setRegNo(regNo);
  678. cuPlan.setUpdNo(regNo);
  679. cuPlan.setTmplType("G082_20");
  680. cuPlan.setPlanSq(param.getPlanSq());
  681. cuPlan.setTitle(param.getCuTitle());
  682. cuPlan.setDispYn(param.getCuDispYn());
  683. cuPlan.setDispOrd(param.getCuDispOrd());
  684. cuPlan.setPlanContSq(param.getCuPlanContSq());
  685. String[] cpnNote = param.getMultiPlanCouponNotice();
  686. for (int i = 0; i < cpnNote.length; i++) {
  687. if(i==0)
  688. cuPlan.setCpnNote0(cpnNote[i]);
  689. else if(i==1)
  690. cuPlan.setCpnNote1(cpnNote[i]);
  691. else if(i==2)
  692. cuPlan.setCpnNote2(cpnNote[i]);
  693. else if(i==3)
  694. cuPlan.setCpnNote3(cpnNote[i]);
  695. else if(i==4)
  696. cuPlan.setCpnNote4(cpnNote[i]);
  697. else if(i==5)
  698. cuPlan.setCpnNote5(cpnNote[i]);
  699. else if(i==6)
  700. cuPlan.setCpnNote6(cpnNote[i]);
  701. else if(i==7)
  702. cuPlan.setCpnNote7(cpnNote[i]);
  703. else if(i==8)
  704. cuPlan.setCpnNote8(cpnNote[i]);
  705. else if(i==9)
  706. cuPlan.setCpnNote9(cpnNote[i]);
  707. }
  708. planDao.createPlanContents(cuPlan);
  709. // 기존 쿠폰아이템 삭제
  710. planDao.deletePlanContentItem(param.getCuPlanContSq());
  711. //쿠폰아이템 등록
  712. if(param.getMultiPlanCoupon().length>0) {
  713. String[] cuItemVal = param.getMultiPlanCoupon();
  714. // 기획전 브랜드 insert
  715. for (int j = 0; j < cuItemVal.length; j++) {
  716. cuPlan.setItemVal(cuItemVal[j]);
  717. planDao.createPlanContentsItem(cuPlan);
  718. }
  719. }
  720. }
  721. //이미지등록
  722. Plan filePlan = new Plan();
  723. if(!org.apache.commons.lang3.StringUtils.isAllEmpty(param.getMultiPlanFile()) || param.getFileDispOrd() >=0) {
  724. filePlan.setRegNo(regNo);
  725. filePlan.setUpdNo(regNo);
  726. filePlan.setTmplType("G082_30");
  727. filePlan.setPlanSq(param.getPlanSq());
  728. filePlan.setDispYn(param.getFileDispYn());
  729. filePlan.setDispOrd(param.getFileDispOrd());
  730. filePlan.setPlanContSq(param.getFilePlanContSq());
  731. planDao.createPlanContents(filePlan);
  732. // 기존 파일 삭제
  733. planDao.deletePlanContentItem(param.getFilePlanContSq());
  734. //파일아이템 등록
  735. String[] fileItemVal = param.getMultiPlanFile();
  736. String[] fileItemVal2 = param.getMultiPlanFile2();
  737. String[] fileItemVal3 = param.getMultiPlanFile3();
  738. int ind = 1;
  739. for (int j = 0; j < fileItemVal.length; j++) {
  740. String imgInd = String.valueOf(ind);
  741. if (ind < 10) {
  742. imgInd = "0" + imgInd;
  743. }
  744. String planUploadPath = env.getProperty("upload.default.target.path");
  745. String yearMonth = GagaDateUtil.getToday().substring(0, 6);
  746. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, "/planning");
  747. File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, fileItemVal[j]));
  748. planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
  749. String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(fileItemVal[j]);
  750. File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(planUploadPath, newFilename)));
  751. // Rename a file
  752. File path = new File(planUploadPath);
  753. if (!path.exists()) {
  754. path.mkdir();
  755. }
  756. newFile.renameTo(uniqueFile);
  757. if (fileItemVal[j].contains("/planning")) {
  758. filePlan.setItemVal(fileItemVal[j]);
  759. }else {
  760. filePlan.setItemVal("/planning/" + yearMonth + "/" + newFilename);
  761. }
  762. filePlan.setItemVal("/planning/" + yearMonth + "/" + newFilename);
  763. filePlan.setLinkUrl(fileItemVal2[j]);
  764. filePlan.setLinkOpenGb((fileItemVal3[j]));
  765. planDao.createPlanContentsItem(filePlan);
  766. ind++;
  767. }
  768. }
  769. // 유의사항등록
  770. Plan noticePlan = new Plan();
  771. //유의사항 등록 - tb_plan_contents
  772. if(!org.apache.commons.lang3.StringUtils.isAllEmpty(param.getMultiPlanNotice()) || param.getNoticeDispOrd() >=0) {
  773. noticePlan.setRegNo(regNo);
  774. noticePlan.setUpdNo(regNo);
  775. noticePlan.setTmplType("G082_60");
  776. noticePlan.setPlanSq(param.getPlanSq());
  777. noticePlan.setDispYn(param.getNoticeDispYn());
  778. noticePlan.setDispOrd(param.getNoticeDispOrd());
  779. noticePlan.setPlanContSq(param.getNoticePlanContSq());
  780. planDao.createPlanContents(noticePlan);
  781. // 기존 유의사항삭제
  782. planDao.deletePlanContentItem(param.getNoticePlanContSq());
  783. //유의사항아이템 등록
  784. if(param.getMultiPlanNotice().length>0) {
  785. String[] noticeItemVal = param.getMultiPlanNotice();
  786. // 유의사항 insert
  787. for (int j = 0; j < noticeItemVal.length; j++) {
  788. noticePlan.setItemVal(noticeItemVal[j]);
  789. planDao.createPlanContentsItem(noticePlan);
  790. }
  791. }
  792. }
  793. //HTML[PC] 상단 하단 등록
  794. if(param.getFsrcMobileTop() != "" || param.getFsrcPcTop() != "") {
  795. // 웹용 상단PC 등록
  796. if (org.apache.commons.lang3.StringUtils.isNotBlank(param.getFsrcPcTop())) {
  797. createPlanFsrcPcTop(param);
  798. }
  799. }
  800. //HTML[하단] 등록
  801. if(param.getFsrcMobileBtm() != "" || param.getFsrcPcBtm() != "") {
  802. // 웹용 상단PC 등록
  803. if (org.apache.commons.lang3.StringUtils.isNotBlank(param.getFsrcPcBtm())) {
  804. createPlanFsrcPcBtm(param);
  805. }
  806. }
  807. //상품 등록 -- 1
  808. for (Plan multiPlanGoodsContent1 : param.getMultiPlanGoodsContent1()) {
  809. if (!StringUtils.isEmpty(multiPlanGoodsContent1.getGoodsType())) {
  810. String goodsTitle = multiPlanGoodsContent1.getGoodsTitle();
  811. String goodsUrl = multiPlanGoodsContent1.getGoodsUrl();
  812. String goodsType = multiPlanGoodsContent1.getGoodsType();
  813. long goodsDispOrd = multiPlanGoodsContent1.getGoodsDispOrd();
  814. String goodsDispYn = multiPlanGoodsContent1.getGoodsDispYn();
  815. Integer goodsPlanContSq = multiPlanGoodsContent1.getGoodsPlanContSq();
  816. String linkOpenGb = multiPlanGoodsContent1.getGoodsLinkOpenGb();
  817. Plan goods1 = new Plan();
  818. goods1.setRegNo(regNo);
  819. goods1.setUpdNo(regNo);
  820. goods1.setTitle(goodsTitle);
  821. goods1.setDispOrd(goodsDispOrd);
  822. goods1.setPlanSq(param.getPlanSq());
  823. goods1.setDispYn(goodsDispYn);
  824. goods1.setTmplType(goodsType);
  825. goods1.setLinkOpenGb(linkOpenGb);
  826. goods1.setLinkUrl(goodsUrl);
  827. goods1.setPlanContSq(goodsPlanContSq);
  828. planDao.createPlanContents(goods1);
  829. // 기존 상품1 삭제
  830. planDao.deletePlanContentItem(goodsPlanContSq);
  831. for (Plan multiPlanGoodsContentVal1 : param.getMultiPlanGoodsContentVal1()) {
  832. if(param.getMultiPlanGoodsContentVal1().size()>0) {
  833. goods1.setItemVal(multiPlanGoodsContentVal1.getGoodsItemVal());
  834. planDao.createPlanContentsItem(goods1);
  835. }
  836. }
  837. }
  838. }
  839. //상품 등록 -- 2
  840. for (Plan multiPlanGoodsContent2 : param.getMultiPlanGoodsContent2()) {
  841. if (!StringUtils.isEmpty(multiPlanGoodsContent2.getGoodsType())) {
  842. String goodsTitle = multiPlanGoodsContent2.getGoodsTitle();
  843. String goodsUrl = multiPlanGoodsContent2.getGoodsUrl();
  844. String goodsType = multiPlanGoodsContent2.getGoodsType();
  845. long goodsDispOrd = multiPlanGoodsContent2.getGoodsDispOrd();
  846. String goodsDispYn = multiPlanGoodsContent2.getGoodsDispYn();
  847. Integer goodsPlanContSq = multiPlanGoodsContent2.getGoodsPlanContSq();
  848. String linkOpenGb = multiPlanGoodsContent2.getGoodsLinkOpenGb();
  849. Plan goods2 = new Plan();
  850. goods2.setRegNo(regNo);
  851. goods2.setUpdNo(regNo);
  852. goods2.setTitle(goodsTitle);
  853. goods2.setDispOrd(goodsDispOrd);
  854. goods2.setPlanSq(param.getPlanSq());
  855. goods2.setDispYn(goodsDispYn);
  856. goods2.setTmplType(goodsType);
  857. goods2.setLinkUrl(goodsUrl);
  858. goods2.setLinkOpenGb(linkOpenGb);
  859. goods2.setPlanContSq(goodsPlanContSq);
  860. planDao.createPlanContents(goods2);
  861. // 기존 상품2 삭제
  862. planDao.deletePlanContentItem(goodsPlanContSq);
  863. for (Plan multiPlanGoodsContentVal2 : param.getMultiPlanGoodsContentVal2()) {
  864. if(param.getMultiPlanGoodsContentVal2().size()>0) {
  865. goods2.setItemVal(multiPlanGoodsContentVal2.getGoodsItemVal());
  866. planDao.createPlanContentsItem(goods2);
  867. }
  868. }
  869. }
  870. }
  871. //상품 등록 -- 3
  872. for (Plan multiPlanGoodsContent3 : param.getMultiPlanGoodsContent3()) {
  873. if (!StringUtils.isEmpty(multiPlanGoodsContent3.getGoodsType())) {
  874. String goodsTitle = multiPlanGoodsContent3.getGoodsTitle();
  875. String goodsUrl = multiPlanGoodsContent3.getGoodsUrl();
  876. String goodsType = multiPlanGoodsContent3.getGoodsType();
  877. long goodsDispOrd = multiPlanGoodsContent3.getGoodsDispOrd();
  878. String goodsDispYn = multiPlanGoodsContent3.getGoodsDispYn();
  879. Integer goodsPlanContSq = multiPlanGoodsContent3.getGoodsPlanContSq();
  880. String linkOpenGb = multiPlanGoodsContent3.getGoodsLinkOpenGb();
  881. Plan goods3 = new Plan();
  882. goods3.setRegNo(regNo);
  883. goods3.setUpdNo(regNo);
  884. goods3.setTitle(goodsTitle);
  885. goods3.setDispOrd(goodsDispOrd);
  886. goods3.setPlanSq(param.getPlanSq());
  887. goods3.setDispYn(goodsDispYn);
  888. goods3.setTmplType(goodsType);
  889. goods3.setLinkUrl(goodsUrl);
  890. goods3.setLinkOpenGb(linkOpenGb);
  891. goods3.setPlanContSq(goodsPlanContSq);
  892. planDao.createPlanContents(goods3);
  893. // 기존 상품3 삭제
  894. planDao.deletePlanContentItem(goodsPlanContSq);
  895. for (Plan multiPlanGoodsContentVal3 : param.getMultiPlanGoodsContentVal3()) {
  896. if(param.getMultiPlanGoodsContentVal3().size()>0) {
  897. goods3.setItemVal(multiPlanGoodsContentVal3.getGoodsItemVal());
  898. planDao.createPlanContentsItem(goods3);
  899. }
  900. }
  901. }
  902. }
  903. //상품 등록 -- 4
  904. for (Plan multiPlanGoodsContent4 : param.getMultiPlanGoodsContent4()) {
  905. if (!StringUtils.isEmpty(multiPlanGoodsContent4.getGoodsType())) {
  906. String goodsTitle = multiPlanGoodsContent4.getGoodsTitle();
  907. String goodsUrl = multiPlanGoodsContent4.getGoodsUrl();
  908. String goodsType = multiPlanGoodsContent4.getGoodsType();
  909. long goodsDispOrd = multiPlanGoodsContent4.getGoodsDispOrd();
  910. String goodsDispYn = multiPlanGoodsContent4.getGoodsDispYn();
  911. Integer goodsPlanContSq = multiPlanGoodsContent4.getGoodsPlanContSq();
  912. String linkOpenGb = multiPlanGoodsContent4.getGoodsLinkOpenGb();
  913. Plan goods4 = new Plan();
  914. goods4.setRegNo(regNo);
  915. goods4.setUpdNo(regNo);
  916. goods4.setTitle(goodsTitle);
  917. goods4.setDispOrd(goodsDispOrd);
  918. goods4.setPlanSq(param.getPlanSq());
  919. goods4.setDispYn(goodsDispYn);
  920. goods4.setTmplType(goodsType);
  921. goods4.setLinkUrl(goodsUrl);
  922. goods4.setPlanContSq(goodsPlanContSq);
  923. goods4.setLinkOpenGb(linkOpenGb);
  924. planDao.createPlanContents(goods4);
  925. // 기존 상품4 삭제
  926. planDao.deletePlanContentItem(goodsPlanContSq);
  927. for (Plan multiPlanGoodsContentVal4 : param.getMultiPlanGoodsContentVal4()) {
  928. if(param.getMultiPlanGoodsContentVal4().size()>0) {
  929. goods4.setItemVal(multiPlanGoodsContentVal4.getGoodsItemVal());
  930. planDao.createPlanContentsItem(goods4);
  931. }
  932. }
  933. }
  934. }
  935. //상품 등록 -- 5
  936. for (Plan multiPlanGoodsContent5 : param.getMultiPlanGoodsContent5()) {
  937. if (!StringUtils.isEmpty(multiPlanGoodsContent5.getGoodsType())) {
  938. String goodsTitle = multiPlanGoodsContent5.getGoodsTitle();
  939. String goodsUrl = multiPlanGoodsContent5.getGoodsUrl();
  940. String goodsType = multiPlanGoodsContent5.getGoodsType();
  941. long goodsDispOrd = multiPlanGoodsContent5.getGoodsDispOrd();
  942. String goodsDispYn = multiPlanGoodsContent5.getGoodsDispYn();
  943. Integer goodsPlanContSq = multiPlanGoodsContent5.getGoodsPlanContSq();
  944. String linkOpenGb = multiPlanGoodsContent5.getGoodsLinkOpenGb();
  945. Plan goods5 = new Plan();
  946. goods5.setRegNo(regNo);
  947. goods5.setUpdNo(regNo);
  948. goods5.setTitle(goodsTitle);
  949. goods5.setDispOrd(goodsDispOrd);
  950. goods5.setPlanSq(param.getPlanSq());
  951. goods5.setDispYn(goodsDispYn);
  952. goods5.setTmplType(goodsType);
  953. goods5.setLinkUrl(goodsUrl);
  954. goods5.setPlanContSq(goodsPlanContSq);
  955. goods5.setLinkOpenGb(linkOpenGb);
  956. planDao.createPlanContents(goods5);
  957. // 기존 상품5 삭제
  958. planDao.deletePlanContentItem(goodsPlanContSq);
  959. for (Plan multiPlanGoodsContentVal5 : param.getMultiPlanGoodsContentVal5()) {
  960. if(param.getMultiPlanGoodsContentVal5().size()>0) {
  961. goods5.setItemVal(multiPlanGoodsContentVal5.getGoodsItemVal());
  962. planDao.createPlanContentsItem(goods5);
  963. }
  964. }
  965. }
  966. }
  967. //상품 등록 -- 6
  968. for (Plan multiPlanGoodsContent6 : param.getMultiPlanGoodsContent6()) {
  969. if (!StringUtils.isEmpty(multiPlanGoodsContent6.getGoodsType())) {
  970. String goodsTitle = multiPlanGoodsContent6.getGoodsTitle();
  971. String goodsUrl = multiPlanGoodsContent6.getGoodsUrl();
  972. String goodsType = multiPlanGoodsContent6.getGoodsType();
  973. long goodsDispOrd = multiPlanGoodsContent6.getGoodsDispOrd();
  974. String goodsDispYn = multiPlanGoodsContent6.getGoodsDispYn();
  975. Integer goodsPlanContSq = multiPlanGoodsContent6.getGoodsPlanContSq();
  976. String linkOpenGb = multiPlanGoodsContent6.getGoodsLinkOpenGb();
  977. Plan goods6 = new Plan();
  978. goods6.setRegNo(regNo);
  979. goods6.setUpdNo(regNo);
  980. goods6.setTitle(goodsTitle);
  981. goods6.setDispOrd(goodsDispOrd);
  982. goods6.setPlanSq(param.getPlanSq());
  983. goods6.setDispYn(goodsDispYn);
  984. goods6.setTmplType(goodsType);
  985. goods6.setLinkUrl(goodsUrl);
  986. goods6.setPlanContSq(goodsPlanContSq);
  987. goods6.setLinkOpenGb(linkOpenGb);
  988. planDao.createPlanContents(goods6);
  989. // 기존 상품6 삭제
  990. planDao.deletePlanContentItem(goodsPlanContSq);
  991. for (Plan multiPlanGoodsContentVal6 : param.getMultiPlanGoodsContentVal6()) {
  992. if(param.getMultiPlanGoodsContentVal6().size()>0) {
  993. goods6.setItemVal(multiPlanGoodsContentVal6.getGoodsItemVal());
  994. planDao.createPlanContentsItem(goods6);
  995. }
  996. }
  997. }
  998. }
  999. //상품 등록 -- 7
  1000. for (Plan multiPlanGoodsContent7 : param.getMultiPlanGoodsContent7()) {
  1001. if (!StringUtils.isEmpty(multiPlanGoodsContent7.getGoodsType())) {
  1002. String goodsTitle = multiPlanGoodsContent7.getGoodsTitle();
  1003. String goodsUrl = multiPlanGoodsContent7.getGoodsUrl();
  1004. String goodsType = multiPlanGoodsContent7.getGoodsType();
  1005. long goodsDispOrd = multiPlanGoodsContent7.getGoodsDispOrd();
  1006. String goodsDispYn = multiPlanGoodsContent7.getGoodsDispYn();
  1007. Integer goodsPlanContSq = multiPlanGoodsContent7.getGoodsPlanContSq();
  1008. String linkOpenGb = multiPlanGoodsContent7.getGoodsLinkOpenGb();
  1009. Plan goods7 = new Plan();
  1010. goods7.setRegNo(regNo);
  1011. goods7.setUpdNo(regNo);
  1012. goods7.setTitle(goodsTitle);
  1013. goods7.setDispOrd(goodsDispOrd);
  1014. goods7.setPlanSq(param.getPlanSq());
  1015. goods7.setDispYn(goodsDispYn);
  1016. goods7.setTmplType(goodsType);
  1017. goods7.setLinkUrl(goodsUrl);
  1018. goods7.setPlanContSq(goodsPlanContSq);
  1019. goods7.setLinkOpenGb(linkOpenGb);
  1020. planDao.createPlanContents(goods7);
  1021. // 기존 상품7 삭제
  1022. planDao.deletePlanContentItem(goodsPlanContSq);
  1023. for (Plan multiPlanGoodsContentVal7 : param.getMultiPlanGoodsContentVal7()) {
  1024. if(param.getMultiPlanGoodsContentVal7().size()>0) {
  1025. goods7.setItemVal(multiPlanGoodsContentVal7.getGoodsItemVal());
  1026. planDao.createPlanContentsItem(goods7);
  1027. }
  1028. }
  1029. }
  1030. }
  1031. //상품 등록 -- 8
  1032. for (Plan multiPlanGoodsContent8 : param.getMultiPlanGoodsContent8()) {
  1033. if (!StringUtils.isEmpty(multiPlanGoodsContent8.getGoodsType())) {
  1034. String goodsTitle = multiPlanGoodsContent8.getGoodsTitle();
  1035. String goodsUrl = multiPlanGoodsContent8.getGoodsUrl();
  1036. String goodsType = multiPlanGoodsContent8.getGoodsType();
  1037. long goodsDispOrd = multiPlanGoodsContent8.getGoodsDispOrd();
  1038. String goodsDispYn = multiPlanGoodsContent8.getGoodsDispYn();
  1039. Integer goodsPlanContSq = multiPlanGoodsContent8.getGoodsPlanContSq();
  1040. String linkOpenGb = multiPlanGoodsContent8.getGoodsLinkOpenGb();
  1041. Plan goods8 = new Plan();
  1042. goods8.setRegNo(regNo);
  1043. goods8.setUpdNo(regNo);
  1044. goods8.setTitle(goodsTitle);
  1045. goods8.setDispOrd(goodsDispOrd);
  1046. goods8.setPlanSq(param.getPlanSq());
  1047. goods8.setDispYn(goodsDispYn);
  1048. goods8.setTmplType(goodsType);
  1049. goods8.setLinkUrl(goodsUrl);
  1050. goods8.setPlanContSq(goodsPlanContSq);
  1051. goods8.setLinkOpenGb(linkOpenGb);
  1052. planDao.createPlanContents(goods8);
  1053. // 기존 상품8 삭제
  1054. planDao.deletePlanContentItem(goodsPlanContSq);
  1055. for (Plan multiPlanGoodsContentVal8 : param.getMultiPlanGoodsContentVal8()) {
  1056. if(param.getMultiPlanGoodsContentVal8().size()>0) {
  1057. goods8.setItemVal(multiPlanGoodsContentVal8.getGoodsItemVal());
  1058. planDao.createPlanContentsItem(goods8);
  1059. }
  1060. }
  1061. }
  1062. }
  1063. //상품 등록 -- 9
  1064. for (Plan multiPlanGoodsContent9 : param.getMultiPlanGoodsContent9()) {
  1065. if (!StringUtils.isEmpty(multiPlanGoodsContent9.getGoodsType())) {
  1066. String goodsTitle = multiPlanGoodsContent9.getGoodsTitle();
  1067. String goodsUrl = multiPlanGoodsContent9.getGoodsUrl();
  1068. String goodsType = multiPlanGoodsContent9.getGoodsType();
  1069. long goodsDispOrd = multiPlanGoodsContent9.getGoodsDispOrd();
  1070. String goodsDispYn = multiPlanGoodsContent9.getGoodsDispYn();
  1071. Integer goodsPlanContSq = multiPlanGoodsContent9.getGoodsPlanContSq();
  1072. String linkOpenGb = multiPlanGoodsContent9.getGoodsLinkOpenGb();
  1073. Plan goods9 = new Plan();
  1074. goods9.setRegNo(regNo);
  1075. goods9.setUpdNo(regNo);
  1076. goods9.setTitle(goodsTitle);
  1077. goods9.setDispOrd(goodsDispOrd);
  1078. goods9.setPlanSq(param.getPlanSq());
  1079. goods9.setDispYn(goodsDispYn);
  1080. goods9.setTmplType(goodsType);
  1081. goods9.setLinkUrl(goodsUrl);
  1082. goods9.setPlanContSq(goodsPlanContSq);
  1083. goods9.setLinkOpenGb(linkOpenGb);
  1084. planDao.createPlanContents(goods9);
  1085. // 기존 상품9 삭제
  1086. planDao.deletePlanContentItem(goodsPlanContSq);
  1087. for (Plan multiPlanGoodsContentVal9 : param.getMultiPlanGoodsContentVal9()) {
  1088. if(param.getMultiPlanGoodsContentVal9().size()>0) {
  1089. goods9.setItemVal(multiPlanGoodsContentVal9.getGoodsItemVal());
  1090. planDao.createPlanContentsItem(goods9);
  1091. }
  1092. }
  1093. }
  1094. }
  1095. //상품 등록 -- 10
  1096. for (Plan multiPlanGoodsContent10 : param.getMultiPlanGoodsContent10()) {
  1097. if (!StringUtils.isEmpty(multiPlanGoodsContent10.getGoodsType())) {
  1098. String goodsTitle = multiPlanGoodsContent10.getGoodsTitle();
  1099. String goodsUrl = multiPlanGoodsContent10.getGoodsUrl();
  1100. String goodsType = multiPlanGoodsContent10.getGoodsType();
  1101. long goodsDispOrd = multiPlanGoodsContent10.getGoodsDispOrd();
  1102. String goodsDispYn = multiPlanGoodsContent10.getGoodsDispYn();
  1103. Integer goodsPlanContSq = multiPlanGoodsContent10.getGoodsPlanContSq();
  1104. String linkOpenGb = multiPlanGoodsContent10.getGoodsLinkOpenGb();
  1105. Plan goods10 = new Plan();
  1106. goods10.setRegNo(regNo);
  1107. goods10.setUpdNo(regNo);
  1108. goods10.setTitle(goodsTitle);
  1109. goods10.setDispOrd(goodsDispOrd);
  1110. goods10.setPlanSq(param.getPlanSq());
  1111. goods10.setDispYn(goodsDispYn);
  1112. goods10.setTmplType(goodsType);
  1113. goods10.setLinkUrl(goodsUrl);
  1114. goods10.setPlanContSq(goodsPlanContSq);
  1115. goods10.setLinkOpenGb(linkOpenGb);
  1116. planDao.createPlanContents(goods10);
  1117. // 기존 상품10 삭제
  1118. planDao.deletePlanContentItem(goodsPlanContSq);
  1119. for (Plan multiPlanGoodsContentVal10 : param.getMultiPlanGoodsContentVal10()) {
  1120. if(param.getMultiPlanGoodsContentVal10().size()>0) {
  1121. goods10.setItemVal(multiPlanGoodsContentVal10.getGoodsItemVal());
  1122. planDao.createPlanContentsItem(goods10);
  1123. }
  1124. }
  1125. }
  1126. }
  1127. }
  1128. /**
  1129. * 기획전 복사
  1130. *
  1131. * @param 복사대상 기획전 번호
  1132. * @return 복사된 기획전 번호
  1133. * @author sowon
  1134. * @since 2021. 02. 09
  1135. */
  1136. @Transactional("shopTxnManager")
  1137. public Plan copyPlan(Plan param) {
  1138. Plan plan = new Plan();
  1139. int userNo = TssSession.getInfo().getUserNo();
  1140. // 01. 기획전 복사
  1141. param.setRegNo(userNo);
  1142. param.setUpdNo(userNo);
  1143. planDao.createPlanCopy(param);
  1144. plan.setRegNo(userNo);
  1145. plan.setUpdNo(userNo);
  1146. // 02. 기획전 브랜드 복사
  1147. plan.setPlanSq(param.getCopyPlanSq());
  1148. Collection <Plan> brandList = planDao.getPlanBrandList(plan);
  1149. for(Plan brandCd : brandList){
  1150. plan.setPlanSq(param.getPlanSq());
  1151. plan.setBrandGroupNo(brandCd.getBrandGroupNo());
  1152. plan.setCopyPlanSq(param.getCopyPlanSq());
  1153. planDao.createPlanBrandCopy(plan);
  1154. }
  1155. // 02. 기획전 카테고리 복사
  1156. plan.setPlanSq(param.getCopyPlanSq());
  1157. Collection <Plan> cateList = planDao.getPlanCateList(plan);
  1158. for(Plan cateNo : cateList){
  1159. plan.setPlanSq(param.getPlanSq());
  1160. plan.setCateNo(cateNo.getCateNo());
  1161. plan.setCopyPlanSq(param.getCopyPlanSq());
  1162. planDao.createPlanCateCopy(plan);
  1163. }
  1164. // 04.고객 유형복사
  1165. plan.setPlanSq(param.getCopyPlanSq());
  1166. Collection <Plan> custGbList = planDao.getPlanCustGbList(plan);
  1167. for(Plan custGb : custGbList){
  1168. plan.setPlanSq(param.getPlanSq());
  1169. plan.setCustGb(custGb.getCustGb());
  1170. plan.setCopyPlanSq(param.getCopyPlanSq());
  1171. planDao.createPlanCustGbCopy(plan);
  1172. }
  1173. // 05.고객 등급 복사
  1174. // plan.setPlanSq(param.getCopyPlanSq());
  1175. // Collection <Plan> custGradeList = planDao.getPlanCustGradeList(plan);
  1176. //
  1177. // for(Plan custGrade : custGradeList){
  1178. // plan.setPlanSq(param.getPlanSq());
  1179. // plan.setCustGrade(custGrade.getCustGrade());
  1180. // plan.setCopyPlanSq(param.getCopyPlanSq());
  1181. // planDao.createPlanCustGradeCopy(plan);
  1182. // }
  1183. return plan;
  1184. }
  1185. /**
  1186. * 기획전 삭제 처리
  1187. *
  1188. * @param
  1189. * @return
  1190. * @author rladbwnd5
  1191. * @since 2021. 05. 06
  1192. */
  1193. @Transactional("shopTxnManager")
  1194. public void deletePlan(Collection<Plan> paramList) {
  1195. for (Plan plan : paramList) {
  1196. plan.setUpdNo(TssSession.getInfo().getUserNo());
  1197. planDao.deletePlan(plan);
  1198. }
  1199. }
  1200. /**
  1201. * 기획전 템플릿 이미지 첨부파일 삭제
  1202. * @param
  1203. * @return
  1204. * @author sowon
  1205. * @since 2021. 05. 06
  1206. */
  1207. @Transactional("shopTxnManager")
  1208. public void deletePlanTemplateFile(Plan plan) {
  1209. planDao.deletePlanTemplateFile(plan);
  1210. }
  1211. /*
  1212. * 기획전 템플릿 HTML[상단] PC 모바일 소스 등록
  1213. */
  1214. @Transactional("shopTxnManager")
  1215. public Plan createPlanFsrcPcTop(Plan param) {
  1216. Plan fsrcTop = new Plan();
  1217. // int fsrcPcTotalCnt = param.getFsrcPcTop().toCharArray().length;
  1218. // int fsrcMobileTotalCnt = param.getFsrcMobileTop().toCharArray().length;
  1219. // int byteCnt = 1500;
  1220. fsrcTop.setFrontGb("T");
  1221. fsrcTop.setRegNo(param.getRegNo());
  1222. fsrcTop.setPlanSq(param.getPlanSq());
  1223. fsrcTop.setDispYn(param.getTopFsrcDispYn());
  1224. fsrcTop.setFsrcPc(param.getFsrcPcTop());
  1225. fsrcTop.setFsrcMob(param.getFsrcMobileTop());
  1226. planDao.savePlanFsrcInfo(fsrcTop);
  1227. return param;
  1228. }
  1229. /*
  1230. * 기획전 템플릿 HTML[하단] PC 모바일 소스 등록
  1231. */
  1232. @Transactional("shopTxnManager")
  1233. public Plan createPlanFsrcPcBtm(Plan param) {
  1234. Plan fsrcBtm = new Plan();
  1235. // int fsrcPcTotalCnt = param.getFsrcPcBtm().toCharArray().length;
  1236. // int fsrcMobileTotalCnt = param.getFsrcMobileBtm().toCharArray().length;
  1237. // int byteCnt = 1500;
  1238. //
  1239. fsrcBtm.setFrontGb("B");
  1240. fsrcBtm.setRegNo(param.getRegNo());
  1241. fsrcBtm.setPlanSq(param.getPlanSq());
  1242. fsrcBtm.setDispYn(param.getBtmFsrcDispYn());
  1243. fsrcBtm.setFsrcPc(param.getFsrcPcBtm());
  1244. fsrcBtm.setFsrcMob(param.getFsrcMobileBtm());
  1245. planDao.savePlanFsrcInfo(fsrcBtm);
  1246. return param;
  1247. }
  1248. }