TsfPlanningController.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. package com.style24.front.biz.web;
  2. import java.text.DateFormat;
  3. import java.text.DecimalFormat;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Calendar;
  6. import java.util.Collection;
  7. import java.util.Date;
  8. import com.style24.persistence.domain.CustGrade;
  9. import org.apache.commons.lang3.StringUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.mobile.device.Device;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RequestParam;
  19. import org.springframework.web.bind.annotation.ResponseBody;
  20. import org.springframework.web.servlet.ModelAndView;
  21. import com.gagaframework.web.parameter.GagaMap;
  22. import com.gagaframework.web.rest.server.GagaResponseStatus;
  23. import com.style24.core.biz.service.TscCouponService;
  24. import com.style24.core.biz.service.TscCustomerService;
  25. import com.style24.core.biz.service.TscPointService;
  26. import com.style24.core.support.env.TscConstants;
  27. import com.style24.core.support.message.TscMessageByLocale;
  28. import com.style24.front.biz.service.TsfCouponService;
  29. import com.style24.front.biz.service.TsfCustomerService;
  30. import com.style24.front.biz.service.TsfDisplayService;
  31. import com.style24.front.biz.service.TsfPlanningService;
  32. import com.style24.front.support.controller.TsfBaseController;
  33. import com.style24.front.support.security.session.TsfSession;
  34. import com.style24.persistence.TscPageRequest;
  35. import com.style24.persistence.domain.Coupon;
  36. import com.style24.persistence.domain.CustCoupon;
  37. import com.style24.persistence.domain.CustDeliveryAddr;
  38. import com.style24.persistence.domain.Customer;
  39. import com.style24.persistence.domain.Plan;
  40. import com.style24.persistence.domain.Point;
  41. import com.style24.persistence.domain.Poll;
  42. import com.style24.persistence.domain.Review;
  43. import lombok.extern.slf4j.Slf4j;
  44. /**
  45. * 기획전 Controller
  46. *
  47. * @author gagamel
  48. * @since 2020. 12. 29
  49. */
  50. @Controller
  51. @RequestMapping("/planning")
  52. @Slf4j
  53. public class TsfPlanningController extends TsfBaseController {
  54. @Autowired
  55. private TscMessageByLocale message;
  56. @Autowired
  57. private TsfPlanningService planningService;
  58. @Autowired
  59. private TscCustomerService coreCustomerService;
  60. @Autowired
  61. private TsfCouponService couponService;
  62. @Autowired
  63. private TscCouponService coreCouponService;
  64. @Autowired
  65. private TsfCustomerService customerService;
  66. @Autowired
  67. private TsfDisplayService displayService;
  68. @Autowired
  69. private TscPointService corePointService;
  70. /**
  71. * 기획전 메인 화면
  72. * @param cateNo - 카테고리번호
  73. * @return
  74. * @author sowon
  75. * @since 2021. 3. 5
  76. */
  77. @GetMapping("/main/form")
  78. public ModelAndView planningMainForm(@RequestParam(value = "cateNo", required = false) Integer cateNo, @RequestParam(value = "brandGroupNo", required = false) Integer brandGroupNo) {
  79. ModelAndView mav = new ModelAndView(super.getDeviceViewName("planning/PlanningMainForm"));
  80. Plan plan = new Plan();
  81. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  82. plan.setFrontGb(TsfSession.getFrontGb());
  83. // 기획전 카테고리 목록
  84. mav.addObject("cateList", planningService.getPlanningCategoryList(plan));
  85. mav.addObject("cateNo", cateNo);
  86. mav.addObject("brandGroupNo", brandGroupNo);
  87. return mav;
  88. }
  89. /**
  90. * 기획전 메인 목록
  91. * @param plan - 기획전 정보
  92. * @param device - 디바이스 정보
  93. * @return
  94. * @author gagamel
  95. * @since 2021. 3. 29
  96. */
  97. @GetMapping("/main/list")
  98. @ResponseBody
  99. public Collection<Plan> getPlanningMainList(Plan plan, Device device) {
  100. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  101. plan.setFrontGb(TsfSession.getFrontGb());
  102. plan.setCustGb(TsfSession.getCustGb());
  103. plan.setCustNo(TsfSession.isLogin() ? TsfSession.getInfo().getCustNo() : 0);
  104. if (device.isNormal()) {
  105. plan.setMaxRow(2); // PC웹은 2개
  106. } else {
  107. plan.setMaxRow(3); // 모바일은 3개
  108. }
  109. return planningService.getPlanningMainList(plan);
  110. }
  111. /**
  112. * 기획전 / 이벤트 상세화면
  113. *
  114. * @return
  115. * @author sowon
  116. * @since 2021. 3. 9
  117. */
  118. @GetMapping("/detail/form")
  119. public ModelAndView PlanningDetailForm(Plan plan) {
  120. ModelAndView mav = new ModelAndView();
  121. // 접근 불가능한 기획전 메시지 조회
  122. String inaccessibleMsg = planningService.getInaccessiblePlanningMessage(plan.getPlanSq());
  123. if (StringUtils.isNotBlank(inaccessibleMsg)) {
  124. if (!TsfSession.isLogin()) {
  125. mav.addObject("loginYn", "N");
  126. }else {
  127. mav.addObject("loginYn", "Y");
  128. }
  129. mav.addObject("inaccessibleMsg", inaccessibleMsg);
  130. mav.setViewName(super.getDeviceViewName("error/Inaccess"));
  131. return mav;
  132. }
  133. Review review = new Review();
  134. Coupon coupon = new Coupon();
  135. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  136. plan.setFrontGb(TsfSession.getFrontGb());
  137. plan.setCustGb(TsfSession.getCustGb());
  138. review.setFrontGb(TsfSession.getFrontGb());
  139. review.setCustGb(TsfSession.getCustGb());
  140. if (TsfSession.isLogin()) {
  141. plan.setCustNo(TsfSession.getInfo().getCustNo());
  142. }
  143. // 기본 set
  144. plan.setExceptPlanSq(plan.getPlanSq());
  145. plan.setPlanSq(plan.getPlanSq());
  146. review.setPlanSq(plan.getPlanSq());
  147. coupon.setPlanSq(plan.getPlanSq());
  148. coupon.setSiteCd(TscConstants.Site.STYLE24.value());
  149. coupon.setFrontGb(TsfSession.getFrontGb());
  150. plan.setFrontGb(TsfSession.getFrontGb());
  151. Plan planInfo = planningService.getPlanDetailInfo(plan);
  152. String planGb = planInfo.getPlanGb();
  153. mav.addObject("planInfo", planInfo);
  154. mav.addObject("planCount", planningService.getPlanAllCount(plan));
  155. // 템플릿 순서
  156. mav.addObject("templateOrd", planningService.templateDispOrdInfo(plan));
  157. // 상단소스
  158. plan.setFrontGb("T");
  159. mav.addObject("fsrcInfoTop", planningService.getPlanFsrcInfo(plan));
  160. // 하단소스
  161. plan.setFrontGb("B");
  162. mav.addObject("fsrcInfoBtm", planningService.getPlanFsrcInfo(plan));
  163. // 리뷰
  164. mav.addObject("reviewInfo", planningService.getPlanReviewInfo(review));
  165. // 쿠폰
  166. mav.addObject("couponInfo", planningService.getPlanCouponInfo(coupon));
  167. // 이미지
  168. mav.addObject("imageInfo", planningService.getPlanImageInfo(plan));
  169. plan.setFrontGb(TsfSession.getFrontGb());
  170. // 상품1열 전시
  171. plan.setTmplType("G082_50");
  172. mav.addObject("goods1Info", planningService.getPlanGoodsDisplayList(plan));
  173. // 상품2열 전시
  174. plan.setTmplType("G082_51");
  175. /*
  176. * if (TsfSession.getFrontGb().equals("M")) { TscPageRequest pageable = new
  177. * TscPageRequest((plan.getPageNo2() > 0 ? plan.getPageNo2() - 1 : 0),
  178. * plan.getPageSize2(), plan.getPageUnit2()); int totalCnt =
  179. * planningService.getPlanGoodsDisplayList(plan).size();
  180. * pageable.setTotalCount(totalCnt); plan.setPageable2(pageable); }
  181. */
  182. mav.addObject("goods2Info", planningService.getPlanGoodsDisplayList(plan));
  183. // 상품4열 전시
  184. plan.setTmplType("G082_52");
  185. mav.addObject("goods4Info", planningService.getPlanGoodsDisplayList(plan));
  186. // 코너 목록
  187. mav.addObject("planCornerList", planningService.getPlanCornerList(plan));
  188. // 코너 상품
  189. mav.addObject("planCornerGoodsList", planningService.getPlanningCornerGoodsList(plan));
  190. // Popup Parameter
  191. mav.addObject("preview", plan.getPreview());
  192. mav.addObject("viewDt", plan.getViewDt());
  193. mav.addObject("viewPage", "G037_40");
  194. mav.addObject("popupPlanSq", plan.getPlanSq());
  195. if (planGb.equals("P")) {
  196. // 다른기획전 보기
  197. mav.addObject("planList", planningService.getPlanningList(plan));
  198. mav.addObject("listSize", planningService.getPlanningList(plan).size());
  199. }
  200. else if(planGb.equals("E")){
  201. // 다른이벤트 보기
  202. mav.addObject("planList", planningService.getPlanEventList(plan));
  203. mav.addObject("listSize", planningService.getPlanEventList(plan).size());
  204. }else if(planGb.equals("C")) {
  205. // 출석체크
  206. mav.addObject("planList", planningService.getPlanEventList(plan));
  207. mav.addObject("listSize", planningService.getPlanEventList(plan).size());
  208. mav.addObject("month", planningService.getAttendMonth(planInfo));
  209. mav.addObject("benefitList", planningService.getAttendBenefitList(plan));
  210. if (TsfSession.isLogin()) {
  211. mav.addObject("custAttendList",planningService.getCustAttendEntryList(plan));
  212. }
  213. mav.setViewName(super.getDeviceViewName("planning/PlanningEventAttendForm"));
  214. return mav;
  215. }
  216. // 브랜드그룹 정보 : 브랜드메인 링크에 설정된 기획전으로 들어올때 GNB 변경때문에 사용
  217. mav.addObject("brandGroupInfo", displayService.getGnbBrandGroup(plan.getBrandGroupNo()));
  218. mav.setViewName(super.getDeviceViewName("planning/PlanningDetailForm"));
  219. return mav;
  220. }
  221. /**
  222. * 모바일 상품 2열 전시 더보기
  223. * @param plan
  224. * @return
  225. * @author sowon
  226. * @since 2021. 05. 14
  227. */
  228. @PostMapping("/goods/list")
  229. @ResponseBody
  230. public GagaMap getPlanningGoodsList(@RequestBody Plan plan) {
  231. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  232. if (TsfSession.isLogin()) {
  233. plan.setCustNo(TsfSession.getInfo().getCustNo());
  234. }
  235. plan.setFrontGb(TsfSession.getFrontGb());
  236. GagaMap result = new GagaMap();
  237. plan.setTmplType("G082_51");
  238. plan.setPlanStat("Y");
  239. result.set("planGoods2List", planningService.getPlanGoodsDisplayList(plan).size());
  240. TscPageRequest pageable = new TscPageRequest((plan.getPageNo2() > 0 ? plan.getPageNo2() - 1 : 0), plan.getPageSize2(), plan.getPageUnit2());
  241. int totalCnt = planningService.getPlanGoodsDisplayList(plan).size();
  242. pageable.setTotalCount(totalCnt);
  243. plan.setPageable2(pageable);
  244. result.set("paging1", plan);
  245. result.set("totalCnt", totalCnt);
  246. result.set("endRow", pageable.getEndRow());
  247. result.set("dataList", planningService.getPlanGoodsDisplayList(plan));
  248. return result;
  249. }
  250. /**
  251. * 기획전 쿠폰 상세보기 팝업
  252. *
  253. * @return
  254. * @author sowon
  255. * @since 2021. 04. 14
  256. */
  257. @PostMapping(value = "/coupon/detailpop")
  258. public ModelAndView planningCouponDetailPop(@RequestBody Coupon coupon) {
  259. ModelAndView mav = new ModelAndView();
  260. // 쿠폰 - 기본정보
  261. mav.addObject("couponDetailInfo", couponService.getPlanCouponDetailInfo(coupon));
  262. mav.setViewName(super.getDeviceViewName("planning/PlanningCouponDetailForm"));
  263. return mav;
  264. }
  265. /**
  266. * 기획전/이벤트 댓글 리스트
  267. *
  268. * @return
  269. * @author sowon
  270. * @since 2021. 04. 08
  271. */
  272. @PostMapping("/reply/list")
  273. @ResponseBody
  274. public GagaMap getReplyList(@RequestBody Plan plan) {
  275. GagaMap result = new GagaMap();
  276. if (TsfSession.isLogin()) {
  277. result.set("custNo",TsfSession.getInfo().getCustNo());
  278. }
  279. TscPageRequest pageable = new TscPageRequest((plan.getPageNo() > 0 ? plan.getPageNo() - 1 : 0), plan.getPageSize(), plan.getPageUnit());
  280. pageable.setTotalCount(planningService.getEntryReplyCount(plan));
  281. plan.setPageable(pageable);
  282. log.info("pageable: {}", pageable);
  283. log.info("totalCount {}", pageable.getTotalCount());
  284. result.set("paging", plan);
  285. result.set("replyList",planningService.getReplyList(plan));
  286. result.set("replyCount",planningService.getEntryReplyCount(plan));
  287. result.set("replyAttachList",planningService.getEntryReplyAttachList(plan));
  288. return result;
  289. }
  290. /**
  291. * 기획전/이벤트 댓글 저장
  292. *
  293. * @return
  294. * @author sowon
  295. * @since 2021. 04. 13
  296. */
  297. @PostMapping("/reply/save")
  298. @ResponseBody
  299. public GagaMap saveEntryReply(@RequestBody Plan plan) {
  300. GagaMap result = new GagaMap();
  301. planningService.saveEntryReply(plan);
  302. return result;
  303. }
  304. /**
  305. * 기획전/이벤트 댓글 삭제
  306. *
  307. * @return
  308. * @author sowon
  309. * @since 2021. 04. 13
  310. */
  311. @PostMapping("/reply/delete")
  312. @ResponseBody
  313. public GagaMap deleteEntryReply(@RequestBody Plan plan) {
  314. GagaMap result = new GagaMap();
  315. planningService.deleteEntryReply(plan);
  316. return result;
  317. }
  318. /**
  319. * 기획전 쿠폰 상세보기 모달
  320. *
  321. * @return
  322. * @author sowon
  323. * @since 2021. 04. 01
  324. */
  325. @GetMapping(value = "/coupon/detail")
  326. public ModelAndView mypageCouponDetailPop(@RequestBody Coupon coupon) {
  327. ModelAndView mav = new ModelAndView();
  328. // 쿠폰 - 기본정보
  329. coupon.setPlanCouponStat("Y");
  330. mav.addObject("couponDetailInfo", couponService.getCouponDetailInfo(coupon));
  331. mav.setViewName(super.getDeviceViewName("planning/PlanningCouponDetailForm"));
  332. return mav;
  333. }
  334. /**
  335. * 기획전 쿠폰 다운로드. 고객이 상품쿠폰 다운로드 시 발급됨.
  336. *
  337. * @param params
  338. * @return
  339. * @throws Exception
  340. * @author sowon
  341. * @since 2021. 3. 24.
  342. */
  343. @PostMapping(value = "/coupon/download")
  344. @ResponseBody
  345. public GagaMap createPlanCoupon(@RequestBody Coupon coupon) throws Exception {
  346. GagaMap result = new GagaMap();
  347. // 고객정보 조회
  348. Customer customer = new Customer();
  349. customer.setSiteCd(TscConstants.Site.STYLE24.value());
  350. customer.setCustNo(TsfSession.getInfo().getCustNo());
  351. customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
  352. customer = coreCustomerService.getCustomerInfo(customer);
  353. // 고객정보 설정
  354. coupon.setCustGb(customer.getCustGb());
  355. coupon.setCustGrade(customer.getCustGrade());
  356. coupon.setCustNo(customer.getCustNo());
  357. // 등급쿠폰 다운 처리
  358. String couponResult = planningService.getPlanCouponDownInfo(coupon);
  359. result.set("status", GagaResponseStatus.SUCCESS.getCode());
  360. if ("ERROR_10".equals(couponResult)) {
  361. result.set("message", "발급가능 쿠폰이 없습니다.");
  362. }else if("ERROR_20".equals(couponResult)){
  363. result.set("message", "죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.");
  364. }else if("ERROR_30".equals(couponResult)){
  365. result.set("message", "죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.");
  366. }else {
  367. result.set("message", "쿠폰이 발급되었습니다.");
  368. }
  369. result.set("couponList", planningService.getPlanCouponInfo(coupon));
  370. return result;
  371. }
  372. /**
  373. * 이벤트 메인 화면
  374. *
  375. * @return
  376. * @author sowon
  377. * @since 2021. 3. 8
  378. */
  379. @GetMapping("/event/main/form")
  380. public ModelAndView PlanningEventMainForm(Plan plan) throws Exception {
  381. ModelAndView mav = new ModelAndView();
  382. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  383. plan.setFrontGb(TsfSession.getFrontGb());
  384. mav.setViewName(super.getDeviceViewName("planning/PlanningEventMainForm"));
  385. return mav;
  386. }
  387. /**
  388. * 이벤트 메인 목록
  389. * @param plan - 이벤트 정보
  390. * @return
  391. * @author sowon
  392. * @since 2021. 3. 29
  393. */
  394. @GetMapping("/event/main/list")
  395. @ResponseBody
  396. public Collection<Plan> getPlanningEventMainList(Plan plan, Device device) {
  397. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  398. plan.setFrontGb(TsfSession.getFrontGb());
  399. plan.setCustGb(TsfSession.getCustGb());
  400. plan.setCustNo(TsfSession.isLogin() ? TsfSession.getInfo().getCustNo() : 0);
  401. return planningService.getPlanEventList(plan);
  402. }
  403. /**
  404. * 이벤트 설문조사 화면
  405. * @param
  406. * @return
  407. * @author sowon
  408. * @since 2021. 4. 2
  409. */
  410. @GetMapping("/event/poll/form")
  411. public ModelAndView planningEventPollSave(Plan plan) {
  412. ModelAndView mav = new ModelAndView();
  413. // 로그인 안 한 경우
  414. if (!TsfSession.isLogin()) {
  415. mav.addObject("inaccessibleMsg", "로그인 후 참여 가능합니다.");
  416. mav.setViewName(super.getDeviceViewName("error/Inaccess"));
  417. return mav;
  418. }
  419. Poll poll = new Poll();
  420. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  421. plan.setCustNo(TsfSession.getInfo().getCustNo());
  422. plan.setFrontGb(TsfSession.getFrontGb());
  423. poll = planningService.getPollQuestionInfo(plan);
  424. String partYn = poll.getDupPartiYn();
  425. String comYn = poll.getFstComYn();
  426. int partiCnt = poll.getPartiCnt();
  427. // 중복참여가 아닌경우
  428. if(partYn.equals("N")) {
  429. int count = planningService.getCustAnswerCount(plan);
  430. if (count>0) {
  431. mav.addObject("inaccessibleMsg", "이미 응모하셨습니다.");
  432. mav.setViewName(super.getDeviceViewName("error/Inaccess"));
  433. return mav;
  434. }
  435. }
  436. if (comYn.equals("Y")) {
  437. int count = planningService.getCustAnswerPartiCount(poll);
  438. if (count>=partiCnt) {
  439. mav.addObject("inaccessibleMsg", "선착순 응모가 마감되었습니다.");
  440. mav.setViewName(super.getDeviceViewName("error/Inaccess"));
  441. return mav;
  442. }
  443. }
  444. mav.addObject("pollInfo", planningService.getPollQuestionInfo(plan));
  445. mav.addObject("pollList", planningService.getPollQuestionList(plan));
  446. mav.setViewName(super.getDeviceViewName("planning/PlanningEventPollForm"));
  447. return mav;
  448. }
  449. /**
  450. * 이벤트 설문조사 저장
  451. * @param
  452. * @return
  453. * @author sowon
  454. * @since 2021. 4. 2
  455. */
  456. @PostMapping("/event/poll/save")
  457. @ResponseBody
  458. public GagaMap planningEventPollForm(@RequestBody Poll poll) {
  459. GagaMap result = new GagaMap();
  460. planningService.savePollCustAnswer(poll);
  461. return result;
  462. }
  463. /**
  464. * 총알배송 메인 화면
  465. *
  466. * @return
  467. * @author sowon
  468. * @since 2021. 3. 30
  469. */
  470. @GetMapping("/shot/delivery/guide/form")
  471. public ModelAndView planningShotDeliveryForm(@RequestParam(value="planGb",required = true)String planGb ,Plan plan) throws Exception {
  472. ModelAndView mav = new ModelAndView();
  473. Integer planSq = planningService.getShotPlanSq(plan);
  474. plan.setPlanSq(planSq);
  475. CustDeliveryAddr addr = new CustDeliveryAddr();
  476. Integer custNo = null;
  477. if (TsfSession.isLogin()) {
  478. custNo = TsfSession.getInfo().getCustNo();
  479. plan.setCustNo(custNo);
  480. // 고객정보 조회
  481. Customer customer = new Customer();
  482. customer.setSiteCd(TscConstants.Site.STYLE24.value());
  483. customer.setCustNo(custNo);
  484. customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
  485. customer = coreCustomerService.getCustomerInfo(customer);
  486. mav.addObject("customerInfo", customer);
  487. }
  488. plan.setFrontGb(TsfSession.getFrontGb());
  489. plan.setSiteCd(TscConstants.Site.STYLE24.value());
  490. plan.setCustGb(TsfSession.getCustGb());
  491. // 코너 목록
  492. mav.addObject("planCornerList", planningService.getPlanCornerList(plan));
  493. // 코너 상품
  494. mav.addObject("planCornerGoodsList", planningService.getPlanningCornerGoodsList(plan));
  495. addr.setCustNo(custNo);
  496. mav.addObject("custAddr", planningService.getCustAddrInfo(addr));
  497. mav.addObject("shotHtmlTop", planningService.getShotDeliveryHtmlTop(plan));
  498. mav.addObject("shotHtmlBtm", planningService.getShotDeliveryHtmlBtm(plan));
  499. mav.setViewName(super.getDeviceViewName("planning/PlanningShotGuideForm"));
  500. return mav;
  501. }
  502. /**
  503. * 총알배송 / 일반배송 확인
  504. *
  505. * @return
  506. * @author sowon
  507. * @since 2021. 4. 5
  508. */
  509. @GetMapping("shot/delivery/confirm")
  510. @ResponseBody
  511. public GagaMap planningShotDeliveryConfirm(@RequestParam(value="recipZipcode") String recipZipcode) throws Exception {
  512. GagaMap result = new GagaMap();
  513. result.set("shotYn", planningService.getCustAddrShotConfirm(recipZipcode));
  514. return result;
  515. }
  516. /**
  517. * 회원등급 혜택
  518. *
  519. * @return ModelAndView
  520. * @author jsshin
  521. * @since 2021. 04. 06
  522. */
  523. @GetMapping("/event/custgrade/benefit/form")
  524. public ModelAndView getCustGradeBenefitForm() {
  525. ModelAndView mav = new ModelAndView();
  526. boolean isLogin = TsfSession.isLogin();
  527. mav.addObject("isLogin", isLogin);
  528. if (isLogin) {
  529. Customer customer = new Customer();
  530. customer.setSiteCd(TscConstants.Site.STYLE24.value());
  531. customer.setCustNo(TsfSession.getInfo().getCustNo());
  532. customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
  533. mav.addObject("exptCustGradeMap", customerService.getExpectedCustGrde(customer));
  534. mav.addObject("customerInfo", coreCustomerService.getCustomerInfo(customer));
  535. }
  536. mav.setViewName(super.getDeviceViewName("planning/PlanningCustGradeBenefitForm"));
  537. return mav;
  538. }
  539. @GetMapping("/next/custgrade/info/{nextGradeCd}")
  540. @ResponseBody
  541. public GagaMap getNextCustGradeInfo(@PathVariable String nextGradeCd) {
  542. boolean isLogin = TsfSession.isLogin();
  543. if (!isLogin) {
  544. throw new IllegalStateException("로그인 하시기 바랍니다.");
  545. }
  546. CustGrade custGrade = new CustGrade();
  547. custGrade.setSiteCd(TscConstants.Site.STYLE24.value());
  548. custGrade.setCustNo(TsfSession.getInfo().getCustNo());
  549. custGrade.setGradeCd(nextGradeCd);
  550. return customerService.getNextCustGradeInfo(custGrade);
  551. }
  552. /**
  553. * 회원등급 쿠폰 다운로드
  554. *
  555. * @return GagaMap
  556. * @author jsshin
  557. * @since 2021. 04. 08
  558. */
  559. @PostMapping("/event/custgrade/coupon/down")
  560. @ResponseBody
  561. public GagaMap downCustGradeCoupon() {
  562. GagaMap result = new GagaMap();
  563. int downloadCnt = couponService.downloadCustGradeCoupon(TsfSession.getInfo().getCustNo());
  564. boolean isDownload = downloadCnt > 0;
  565. result.setBoolean("isDownload", isDownload);
  566. result.setInt("downloadCnt", downloadCnt);
  567. return result;
  568. }
  569. /**
  570. * 출석체크
  571. *
  572. * @return
  573. * @author sowon
  574. * @since 2021. 4. 7
  575. */
  576. @PostMapping("/event/attend/entry")
  577. @ResponseBody
  578. public GagaMap planningAttendEntry(@RequestBody Plan plan) throws Exception {
  579. GagaMap result = new GagaMap();
  580. plan.setEntryAllYn("N");
  581. int count = planningService.getAttendEntryCount(plan);
  582. if (count > 0) {
  583. result.set("msg", "이미 출석체크 되었습니다.");
  584. }else {
  585. planningService.saveAttendEntry(plan);
  586. // 총 출석일 수 구해보장..
  587. Collection<Plan> benefitList = planningService.getAttendBenefitList(plan);
  588. plan.setEntryAllYn("Y");
  589. count = planningService.getAttendEntryCount(plan);
  590. for (Plan tPlan : benefitList) {
  591. if (tPlan.getBasDays() == count) {
  592. // 지급 방식이 포인트일 경우
  593. if (tPlan.getBenefitGb().equals("P")) {
  594. Point point = new Point();
  595. int pointAmt = tPlan.getPntAmt();
  596. point.setRegNo(TsfSession.getInfo().getCustNo());
  597. point.setUpdNo(TsfSession.getInfo().getCustNo());
  598. point.setCustNo(TsfSession.getInfo().getCustNo());
  599. point.setPntUploadStat(TscConstants.PntUploadStat.APPLY_COMPLETE.value());
  600. point.setGvPntAmt(pointAmt);
  601. point.setRmPntAmt(pointAmt);
  602. point.setPntAmt(pointAmt);
  603. point.setOccurDtlDesc("출석체크이벤트");
  604. point.setOccurGb("G069_37"); //출석체크 이벤트
  605. Calendar cal = Calendar.getInstance();
  606. cal.setTime(new Date());
  607. DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
  608. int usableDay = tPlan.getPntUsableDay();
  609. cal.add(Calendar.DATE, +usableDay);
  610. point.setExpBeDt(df.format(cal.getTime()));
  611. corePointService.saveCustomerPoint(point);
  612. String msg = "축하합니다. " + toNumFormat(pointAmt) + " 포인트가 지급 되었습니다!";
  613. result.set("msg", msg);
  614. break;
  615. }
  616. else if(tPlan.getBenefitGb().equals("C")) {
  617. CustCoupon coupon = new CustCoupon();
  618. coupon.setCpnId(tPlan.getCpnId());
  619. coupon = couponService.getAttendCouponInfo(coupon);
  620. coupon.setCustNo(TsfSession.getInfo().getCustNo());
  621. coupon.setRegNo(TsfSession.getInfo().getCustNo());
  622. coupon.setUpdNo(TsfSession.getInfo().getCustNo());
  623. // 이거 공통코드 변경예정.. 밑에
  624. coupon.setPubReason("G068_60");
  625. coupon.setPubReasonDtl("이벤트출석체크");
  626. coupon.setEndAlimSendYn("N");
  627. coreCouponService.saveCouponIssue(coupon);
  628. String msg = "축하합니다. " + toNumFormat(coupon.getDcVal()) +coupon.getDcWay() + " 할인쿠폰이 지급 되었습니다!";
  629. result.set("msg", msg);
  630. break;
  631. }
  632. else if(tPlan.getBenefitGb().equals("A")) {
  633. Point point = new Point();
  634. int pointAmt = tPlan.getPntAmt();
  635. point.setRegNo(TsfSession.getInfo().getCustNo());
  636. point.setUpdNo(TsfSession.getInfo().getCustNo());
  637. point.setCustNo(TsfSession.getInfo().getCustNo());
  638. point.setPntUploadStat(TscConstants.PntUploadStat.APPLY_COMPLETE.value());
  639. point.setGvPntAmt(pointAmt);
  640. point.setRmPntAmt(pointAmt);
  641. point.setPntAmt(pointAmt);
  642. point.setOccurDtlDesc("출석체크이벤트");
  643. point.setOccurGb("G069_37"); //출석체크 이벤트
  644. Calendar cal = Calendar.getInstance();
  645. cal.setTime(new Date());
  646. DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
  647. int usableDay = tPlan.getPntUsableDay();
  648. cal.add(Calendar.DATE, +usableDay);
  649. point.setExpBeDt(df.format(cal.getTime()));
  650. corePointService.saveCustomerPoint(point);
  651. CustCoupon coupon = new CustCoupon();
  652. coupon.setCpnId(tPlan.getCpnId());
  653. coupon = couponService.getAttendCouponInfo(coupon);
  654. coupon.setCustNo(TsfSession.getInfo().getCustNo());
  655. coupon.setRegNo(TsfSession.getInfo().getCustNo());
  656. coupon.setUpdNo(TsfSession.getInfo().getCustNo());
  657. // 이거 공통코드 변경예정.. 밑에
  658. coupon.setPubReason("G068_91");
  659. coupon.setPubReasonDtl("출석체크");
  660. coupon.setEndAlimSendYn("N");
  661. coreCouponService.saveCouponIssue(coupon);
  662. String msg = "축하합니다. " + toNumFormat(pointAmt) + " 포인트와 " + toNumFormat(coupon.getDcVal()) +coupon.getDcWay() + " 할인쿠폰이 지급 되었습니다!";
  663. result.set("msg", msg);
  664. }
  665. }else {
  666. result.set("msg", "출석체크 되었습니다.");
  667. break;
  668. }
  669. }
  670. }
  671. result.set("custAttendList",planningService.getCustAttendEntryList(plan));
  672. return result;
  673. }
  674. // 컴마
  675. public static String toNumFormat(int num) {
  676. DecimalFormat df = new DecimalFormat("#,###");
  677. return df.format(num);
  678. }
  679. }