TsaWithdrawService.java 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. package com.style24.admin.biz.service;
  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. import java.util.List;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import org.springframework.transaction.annotation.Transactional;
  8. import lombok.extern.slf4j.Slf4j;
  9. import com.style24.admin.biz.dao.TsaDeliveryDao;
  10. import com.style24.admin.biz.dao.TsaWithdrawDao;
  11. import com.style24.admin.support.security.session.TsaSession;
  12. import com.style24.persistence.domain.OrderChange;
  13. import com.style24.persistence.domain.Withdraw;
  14. import com.style24.persistence.domain.WithdrawExc;
  15. import com.style24.persistence.domain.WmsWithdraw;
  16. import com.style24.core.support.env.TscConstants.OrderChangeStat;
  17. import com.style24.core.biz.dao.TscOrderChangeDao;
  18. import com.style24.core.support.env.TscConstants.OrderChangeGb;
  19. import com.style24.core.support.message.TscMessageByLocale;
  20. /**
  21. * 회수관리 Service
  22. *
  23. * @author moon
  24. * @since 2020. 11. 16
  25. */
  26. @Service
  27. @Slf4j
  28. public class TsaWithdrawService {
  29. @Autowired
  30. private TscMessageByLocale message;
  31. @Autowired
  32. private TsaWithdrawDao withdrawDao;
  33. @Autowired
  34. private TsaDeliveryDao deliveryDao;
  35. @Autowired
  36. private TscOrderChangeDao orderChangeDao;
  37. //@Autowired
  38. //private TsaOrderDao orderDao;
  39. //@Autowired
  40. //private TsaOrderService orderService;
  41. //@Autowired
  42. //private TsaWmsWithdrawDao wmsWithdrawDao;
  43. //@Autowired
  44. //private TsaKakaoService kakaoService;
  45. /**
  46. * 환불관리 목록 건수
  47. *
  48. * @param Delivery
  49. * @return
  50. * @author moon
  51. * @since 2021. 05. 03
  52. */
  53. public int getRefundListCount(Withdraw withdraw) {
  54. return withdrawDao.getRefundListCount(withdraw);
  55. }
  56. /**
  57. * 환불관리 목록
  58. *
  59. * @param withdraw
  60. * @return Collection<Withdraw>
  61. * @author moon
  62. * @since 2020. 11. 16
  63. */
  64. public Collection<Withdraw> getRefundList(Withdraw withdraw) {
  65. return withdrawDao.getRefundList(withdraw);
  66. }
  67. /**
  68. * 회수예외 목록 건수
  69. *
  70. * @param Delivery
  71. * @return
  72. * @author moon
  73. * @since 2021. 03. 04
  74. */
  75. public int getWithdrawExceptionListCount(WithdrawExc withdrawExc) {
  76. return withdrawDao.getWithdrawExceptionListCount(withdrawExc);
  77. }
  78. /**
  79. * 회수예외 목록
  80. *
  81. * @param Delivery
  82. * @return
  83. * @author moon
  84. * @since 2021. 03. 04
  85. */
  86. public Collection<WithdrawExc> getWithdrawExceptionList(WithdrawExc withdrawExc) {
  87. return withdrawDao.getWithdrawExceptionList(withdrawExc);
  88. }
  89. /**
  90. * 회수예외 완료처리
  91. *
  92. * @param Delivery
  93. * @return
  94. * @author moon
  95. * @since 2021. 03. 04
  96. */
  97. @Transactional("shopTxnManager")
  98. public void createWithdrawInfo(WithdrawExc withdrawExc) {
  99. withdrawExc.setRecallStat("S");
  100. withdrawDao.updateWithdrawException(withdrawExc);
  101. }
  102. /**
  103. * 회수예외 목록
  104. *
  105. * @param Delivery
  106. * @return
  107. * @author moon
  108. * @since 2021. 03. 04
  109. */
  110. public Collection<WmsWithdraw> getOptionInfo(Collection<WmsWithdraw> wmsWithdrawList) {
  111. for(WmsWithdraw data : wmsWithdrawList) {
  112. WmsWithdraw optionInfo = withdrawDao.getOptionInfo(data);
  113. data.setGoodsCd(optionInfo.getGoodsCd());
  114. }
  115. return wmsWithdrawList;
  116. }
  117. /**
  118. * 회수지시목록 건수
  119. *
  120. * @param Withdraw
  121. * @return
  122. * @author moon
  123. * @since 2021. 05. 10
  124. */
  125. public int getWithdrawDirectiveListCount(Withdraw withdraw) {
  126. return withdrawDao.getWithdrawDirectiveListCount(withdraw);
  127. }
  128. /**
  129. * 회수지시 목록
  130. *
  131. * @param Withdraw
  132. * @return
  133. * @author moon
  134. * @since 2021. 05. 10
  135. */
  136. public Collection<Withdraw> getWithdrawDirectiveList(Withdraw withdraw) {
  137. return withdrawDao.getWithdrawDirectiveList(withdraw);
  138. }
  139. /**
  140. * 재회수지시
  141. *
  142. * @param Withdraw
  143. * @return void
  144. * @author moon
  145. * @since 2021. 05. 11
  146. */
  147. @Transactional("shopTxnManager")
  148. public void reRecallOrder(Withdraw withdraw) {
  149. Integer userNo = TsaSession.getInfo().getUserNo();
  150. withdraw.setUpdNo(userNo);
  151. if(OrderChangeGb.RETURN.value().equals(withdraw.getChgGb())) { // 반품요청
  152. withdraw.setChgStat(OrderChangeStat.RETURN.value()); // 반품접수
  153. } else { //교환요청
  154. withdraw.setChgStat(OrderChangeStat.EXCHANGE.value()); // 교환접수
  155. }
  156. withdrawDao.updateReRecallOrder(withdraw);
  157. // 주문상세변경 이력
  158. OrderChange ordChg = new OrderChange();
  159. ordChg.setRegNo(userNo);
  160. ordChg.setUpdNo(userNo);
  161. ordChg.setOrdChgSq(withdraw.getOrdChgSq());
  162. ordChg.setOrdDtlNo(withdraw.getOrdDtlNo());
  163. ordChg.setChgStat(withdraw.getChgStat());
  164. orderChangeDao.createOrderChangeDetailHst(ordChg);
  165. }
  166. /**
  167. * 회수등록 - 조회(송장번호용)
  168. *
  169. * @param withdraw
  170. * @return Collection<Withdraw>
  171. * @author rladbwnd5
  172. * @since 2020. 02. 11
  173. */
  174. // public Collection<Withdraw> getWithdrawRegisterInvoiceList(Withdraw withdraw) {
  175. // Collection<Withdraw> dataList = withdrawDao.getWithdrawRegisterInvoiceList(withdraw);
  176. // return dataList;
  177. // }
  178. /**
  179. * 회수등록 - 조회(상품코드용)
  180. *
  181. * @param withdraw
  182. * @return Withdraw List
  183. * @author rladbwnd5
  184. * @since 2020. 02. 12
  185. */
  186. // public Collection<Withdraw> getWithdrawRegisterGoodsList(Withdraw withdraw) {
  187. // return withdrawDao.getWithdrawRegisterGoodsList(withdraw);
  188. // }
  189. /**
  190. * 회수등록 - 등록처리
  191. *
  192. * @param withdrawList
  193. * @return Withdraw List
  194. * @author rladbwnd5
  195. * @since 2020. 02. 12
  196. */
  197. // @Transactional("shopTxnManager")
  198. // public void createWithdrawInfo(Collection<Withdraw> withdrawList) {
  199. // String uesrId = TsaSession.getInfo().getUserId();
  200. //
  201. // // 회수 마스터 등록 정보
  202. // Withdraw withdrawInfo = withdrawList.iterator().next();
  203. //
  204. // // 주문변경번호
  205. // Long ordChgSq = withdrawInfo.getOrdChgSq();
  206. //
  207. // // 기존 회수 수량
  208. // int wdQty = withdrawInfo.getSumWdQty();
  209. //
  210. // // 1. 회수 상세 등록 (동일 여부 판단 위해 상세 먼저 등록)
  211. // for (Withdraw withdrawDetailInfo : withdrawList) {
  212. // if (ordChgSq > 0) {
  213. // wdQty += withdrawDetailInfo.getWdQty(); // 기존 회수 수량 + 회수 수량
  214. //
  215. // // 회수 완료 확인
  216. // if (withdrawInfo.getSumChgQty() == wdQty) {
  217. // withdrawInfo.setSameYn("Y");
  218. // }
  219. // } else {
  220. // withdrawInfo.setSameYn("N");
  221. // }
  222. //
  223. // withdrawDetailInfo.setRegId(uesrId);
  224. // withdrawDetailInfo.setUpdId(uesrId);
  225. // withdrawDao.createWithdrawDetailInfo(withdrawDetailInfo);
  226. // }
  227. //
  228. // // 2. 회수 마스터 등록 처리
  229. // withdrawInfo.setRegId(uesrId);
  230. // withdrawInfo.setUpdId(uesrId);
  231. // withdrawDao.saveWithdrawInfo(withdrawInfo);
  232. // }
  233. /**
  234. * 회수송장번호 변경
  235. *
  236. * @param
  237. * @return
  238. * @author rladbwnd5
  239. * @since 2020. 02. 27
  240. */
  241. // @Transactional("shopTxnManager")
  242. // public void updateRegisterWdInvoiceNo(Withdraw withdraw) {
  243. // withdraw.setUpdId(TsaSession.getInfo().getUserId());
  244. // withdrawDao.updateRegisterWdInvoiceNo(withdraw);
  245. // }
  246. /**
  247. * 회수송장번호 조회
  248. *
  249. * @param
  250. * @return
  251. * @author yujung
  252. * @since 2020. 05. 31
  253. */
  254. // public Collection<Withdraw> getWdInvoiceNo(Withdraw withdraw) {
  255. // return withdrawDao.getWdInvoiceNo(withdraw);
  256. // }
  257. /**
  258. * 환불관리 회수데이터 삭제처리
  259. *
  260. * @param
  261. * @return
  262. * @author moon
  263. * @since 2020. 11. 16
  264. */
  265. @Transactional("shopTxnManager")
  266. public void deleteWithdrawInfo(Withdraw withdraw) {
  267. Withdraw search = new Withdraw();
  268. search.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  269. Collection<Withdraw> withdrawList = withdrawDao.getRefundList(search);
  270. // 마지막 회수 리스트 일 때 마스터 정보 삭제
  271. if (withdrawList.size() == 1) {
  272. withdrawDao.deleteWithdraw(withdraw);
  273. }
  274. withdrawDao.deleteWithdrawDetail(withdraw);
  275. }
  276. /**
  277. * 회수마스터 삭제처리
  278. *
  279. * @param
  280. * @return
  281. * @author yujung
  282. * @since 2020. 06. 01
  283. */
  284. // @Transactional("shopTxnManager")
  285. // public void deleteWithdraw(Withdraw withdraw) {
  286. // withdrawDao.deleteWithdraw(withdraw);
  287. // }
  288. /**
  289. * 회수상세 삭제처리
  290. *
  291. * @param
  292. * @return
  293. * @author yujung
  294. * @since 2020. 06. 01
  295. */
  296. // @Transactional("shopTxnManager")
  297. // public void deleteWithdrawDetail(Withdraw withdraw) {
  298. // withdrawDao.deleteWithdrawDetail(withdraw);
  299. // }
  300. /**
  301. * 회수등록 팝업 목록
  302. *
  303. * @param
  304. * @return
  305. * @author rladbwnd5
  306. * @since 2020. 03. 03
  307. */
  308. // public Collection<Withdraw> getWithdrawRegisterPopupList(Withdraw withdraw) {
  309. // return withdrawDao.getWithdrawRegisterPopupList(withdraw);
  310. // }
  311. /**
  312. * 회수등록팝업 주문매핑(송장번호 수정)
  313. *
  314. * @param
  315. * @return
  316. * @author yujung
  317. * @since 2020. 03. 25
  318. */
  319. // @Transactional("shopTxnManager")
  320. // public void updateOrderChangeWdInvoiceNo(Withdraw withdraw) {
  321. // String userId = TsaSession.getInfo().getUserId();
  322. //
  323. // // 주문변경 회수송장번호 변경
  324. // Withdraw orderChangeParam = new Withdraw();
  325. // orderChangeParam.setOrdChgSq(withdraw.getOrdChgSq());
  326. // orderChangeParam.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  327. // orderChangeParam.setUpdId(userId);
  328. // withdrawDao.updateRegisterWdInvoiceNo(orderChangeParam);
  329. //
  330. // // 회수상세 변경
  331. // Withdraw withdrawDetailInfo = new Withdraw();
  332. // withdrawDetailInfo.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  333. // withdrawDetailInfo.setGoodsCd(withdraw.getGoodsCd());
  334. // withdrawDetailInfo.setSizeCd(withdraw.getSizeCd());
  335. // withdrawDetailInfo.setOrdDtlNo(withdraw.getOrdDtlNo());
  336. // withdrawDetailInfo.setUpdId(userId);
  337. // withdrawDao.updateWithdrawDetailInfo(withdrawDetailInfo);
  338. //
  339. // // 회수송장번호 등록
  340. // Withdraw wdInvoiceInfo = new Withdraw();
  341. // wdInvoiceInfo.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  342. // wdInvoiceInfo.setOrdChgSq(withdraw.getOrdChgSq());
  343. // wdInvoiceInfo.setUpdId(userId);
  344. // withdrawDao.updateWithdrawOrderChange(wdInvoiceInfo);
  345. // }
  346. /**
  347. * 회수등록팝업 주문매핑(주문상세일련번호 수정)
  348. *
  349. * @param
  350. * @return
  351. * @author yujung
  352. * @since 2020. 03. 25
  353. */
  354. // @Transactional("shopTxnManager")
  355. // public void updateWithdrawOrdDtlNo(Withdraw withdraw) {
  356. // // 아웃바운드 정보 업데이트
  357. // Withdraw outboundInfo = new Withdraw();
  358. // outboundInfo.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  359. // outboundInfo.setCsObYn("Y");
  360. // outboundInfo.setCsObId(TsaSession.getInfo().getUserId());
  361. // withdrawDao.updateWithdrawOutbound(outboundInfo);
  362. //
  363. // // 회수상세 변경
  364. // Withdraw withdrawDetailInfo = new Withdraw();
  365. // withdrawDetailInfo.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  366. // withdrawDetailInfo.setGoodsCd(withdraw.getGoodsCd());
  367. // withdrawDetailInfo.setSizeCd(withdraw.getSizeCd());
  368. // withdrawDetailInfo.setOrdDtlNo(withdraw.getOrdDtlNo());
  369. // withdrawDetailInfo.setUpdId(TsaSession.getInfo().getUserId());
  370. // withdrawDao.updateWithdrawDetailInfo(withdrawDetailInfo);
  371. //
  372. // // 회수관리 주문상세번호 및 상품 정보 변경
  373. // Withdraw withdrawInfo = new Withdraw();
  374. // withdrawInfo.setOrgOrdDtlNo(withdraw.getOrgOrdDtlNo()); // 원주문상세번호
  375. // withdrawInfo.setGoodsCd(withdraw.getGoodsCd());
  376. // withdrawInfo.setSizeCd(withdraw.getSizeCd());
  377. // withdrawInfo.setOrdDtlNo(withdraw.getOrdDtlNo()); // 변경 될 주문번호
  378. // withdrawInfo.setWdInvoiceNo(withdraw.getWdInvoiceNo());
  379. // withdrawInfo.setUpdId(TsaSession.getInfo().getUserId());
  380. // withdrawDao.updateWithdrawDetailGoodsInfo(withdrawInfo);
  381. //
  382. // // withdrawDao.updateWithdrawOrdDtlNo(withdraw);
  383. // // return super.ok(message.getMessage("SUCC_0002"));
  384. // }
  385. /**
  386. * 환불관리 상세정보
  387. *
  388. * @param withdraw - 변경주문번호
  389. * @return
  390. * @author moon
  391. * @since 2020. 11. 16
  392. */
  393. public Collection<Withdraw> getRefundDetailList(Withdraw withdraw) {
  394. return withdrawDao.getRefundDetailList(withdraw);
  395. }
  396. /**
  397. * 환불관리 남은상품정보
  398. *
  399. * @param withdraw - 변경주문번호, 주문번호
  400. * @return
  401. * @author moon
  402. * @since 2020. 11. 16
  403. */
  404. public Withdraw getRemainGoodsInfo(Withdraw withdraw) {
  405. return withdrawDao.getRemainGoodsInfo(withdraw);
  406. }
  407. /**
  408. * 환불관리 남은상품리스트
  409. *
  410. * @param withdraw - 변경주문번호, 주문번호
  411. * @return
  412. * @author moon
  413. * @since 2020. 11. 16
  414. */
  415. public Collection<Withdraw> getWithdrawRemainOrderDetailList(Withdraw withdraw) {
  416. return withdrawDao.getWithdrawRemainOrderDetailList(withdraw);
  417. }
  418. /**
  419. * 회수관리 쿠폰정보
  420. *
  421. * @param withdraw - 변경주문번호, 주문번호
  422. * @return
  423. * @author moon
  424. * @since 2020. 11. 15
  425. */
  426. public Withdraw getCouponInfo(Withdraw withdraw) {
  427. return withdrawDao.getCouponInfo(withdraw);
  428. }
  429. /**
  430. * 회수관리 - 회수처리
  431. *
  432. * @param params
  433. * @return
  434. * @author moon
  435. * @since 2020. 11. 16
  436. */
  437. @Transactional("shopTxnManager")
  438. public void refundDetailConfirm(Withdraw params) {
  439. // // 기본값 설정
  440. // String userId = TsaSession.getInfo().getUserId();
  441. // int custNo = params.getCustNo(); // 회원번호
  442. // Long ordNo = params.getOrdNo(); // 주문번호
  443. // Long ordDtlNo = params.getOrdDtlNo(); // 주문상세번호
  444. // Long ordChgSq = params.getOrdChgSq(); // 주문변경번호
  445. // int cnclRtnQty = params.getCnclRtnQty(); // 취소반품 수량
  446. // int custShipAmt = params.getCustShipAmt(); // 고객부담배송비
  447. // String chgGb = params.getChgGb(); // 변경요청구분
  448. // String supplyCompCd = params.getSupplyCompCd();
  449. // String pgStat = params.getPgStats();
  450. // String mallGb = params.getMallGb();
  451. // String chgReason = params.getChgReason();
  452. // String orgChgReason = params.getOrgChgReason();
  453. // int orgEncloseFee = params.getOrgEncloseFee();
  454. // int encloseFee = params.getEncloseFee();
  455. // String delvLocCd = params.getDelvLocCd(); // 반품처코드
  456. //
  457. // if (!chgReason.equals(orgChgReason)) {
  458. // Withdraw chgParams = new Withdraw();
  459. // chgParams.setUpdId(userId);
  460. // chgParams.setChgReason(chgReason);
  461. // chgParams.setOrdChgSq(ordChgSq);
  462. // withdrawDao.updateWithdrawOrderChange(chgParams);
  463. // }
  464. //
  465. // if (encloseFee != orgEncloseFee) {
  466. // Withdraw withdrawParams = new Withdraw();
  467. // withdrawParams.setEncloseFee(encloseFee);
  468. // withdrawParams.setUpdId(userId);
  469. // withdrawParams.setWdInvoiceNo(params.getWdInvoiceNo());
  470. // withdrawDao.updateWithdrawEncloseFee(withdrawParams);
  471. // }
  472. //
  473. // Withdraw ordChgDtlParams = new Withdraw();
  474. // ordChgDtlParams.setOrdChgSq(ordChgSq);
  475. // ordChgDtlParams.setOrdDtlNo(ordDtlNo);
  476. // if (TsaConstants.OrderChangeGb.EXCHANGE.value().equals(params.getChgGb())) { // 교환인 경우
  477. // ordChgDtlParams.setChgStat(TsaConstants.OrderChangeStat.EXCHANGE_COMPLETE.value());
  478. // } else {
  479. // ordChgDtlParams.setChgStat(TsaConstants.OrderChangeStat.RETURN_COMPLETE.value());
  480. // }
  481. // ordChgDtlParams.setUpdId(userId);
  482. // withdrawDao.updateWithdrawOrderChangeDetailInfo(ordChgDtlParams);
  483. //
  484. // int remainCount = withdrawDao.getRemainWithdrawCount(ordChgSq); // 회수컨펌 남은 개수
  485. //
  486. // if (remainCount == 0) {
  487. // // 주문 변경 회수 종료 일시 업데이트
  488. // Withdraw orderChangeInfo = new Withdraw();
  489. // orderChangeInfo.setOrdChgSq(ordChgSq);
  490. // orderChangeInfo.setUpdId(userId);
  491. // withdrawDao.updateOrderChangeInfo(orderChangeInfo);
  492. //
  493. // int orgDelvFee = 0; // 원주문배송비
  494. // int refundAmt = 0; // 환불금액
  495. // int refundPntAmt = 0;
  496. // int refundPrePntAmt = 0;
  497. // int refundGoodsCpnAmt = 0;
  498. // int refundCartCpnAmt = 0;
  499. // int refundCancelCartCpnAmt = 0;
  500. // int refundPlusCpnAmt = 0;
  501. // int refundSavePntAmt = 0;
  502. // Long usedCartCpnSq = null;
  503. //
  504. // Collection<TsaPoint> pointList = new ArrayList<TsaPoint>();
  505. // Collection<TsaPoint> prePointList = new ArrayList<TsaPoint>();
  506. // Collection<TsaPoint> savePointList = new ArrayList<TsaPoint>();
  507. //
  508. // // ORD_CHG_SQ 별 ITEM_CD 단위의 리스트
  509. // Collection<Withdraw> withdrawList = withdrawDao.getWithdrawDetailList(params);
  510. //
  511. // // 쿠폰정보
  512. // String couponCartCpnSq = withdrawList.iterator().next().getCartCpnSq();
  513. // Withdraw couponInfo = null;
  514. // if (StringUtils.isNotBlank(couponCartCpnSq)) {
  515. // Withdraw searchCoupon = new Withdraw();
  516. // searchCoupon.setCartCpnSq(couponCartCpnSq);
  517. // searchCoupon.setCustNo(custNo);
  518. // couponInfo = withdrawDao.getCouponInfo(searchCoupon);
  519. // }
  520. //
  521. // List<Withdraw> ifOnilneSales = new ArrayList();
  522. // GagaMap setOrdDtlNos = new GagaMap();
  523. // int cancelRequestAmt = 0; // 취소요청금액 cancelRequestAmt
  524. //
  525. // for (Withdraw withdraw : withdrawList) {
  526. // // 세트상품인 경우 회수컨펌 처리건이 있으면 스킵
  527. // if ("S".equals(withdraw.getGoodsType()) && setOrdDtlNos.getInt(withdraw.getOrdDtlNo()) > 1) {
  528. // continue;
  529. // }
  530. // orgDelvFee = withdraw.getOrgDelvFee();
  531. // String goodsCpnSq = withdraw.getGoodsCpnSq();
  532. // String cartCpnSq = withdraw.getCartCpnSq();
  533. // int cnclReturnRealOrdAmt = 0;
  534. // int orgOrdAmt = withdraw.getOrdAmt();
  535. // int orgCurrPrice = withdraw.getCurrPrice();
  536. // int orgRealOrdAmt = withdraw.getRealOrdAmt();
  537. // int ordQty = withdraw.getOrdQty();
  538. // int orgCnclRtnQty = withdraw.getCnclRtnQty();
  539. // int wdQty = withdraw.getWdQty();
  540. // int realOrdQty = ordQty - orgCnclRtnQty;
  541. // int orgCnclRtnAmt = withdraw.getCnclRtnAmt();
  542. // int orgGoodsCpnDcAmt = withdraw.getGoodsCpnDcAmt();
  543. // int orgCartCpnDcAmt = withdraw.getCartCpnDcAmt();
  544. // int orgPntDcAmt = withdraw.getPntDcAmt();
  545. // int orgPrePntDcAmt = withdraw.getPrePntDcAmt();
  546. // int orgSavePntAmt = withdraw.getSavePntAmt();
  547. // String plusCpnSq = withdraw.getPlusCpnSq();
  548. // int orgPlusCpnDcAmt = withdraw.getPlusCpnDcAmt();
  549. //
  550. // /* 정산,환불 처리용 */
  551. // int rfPntAmt = (int)((double)orgPntDcAmt / realOrdQty * wdQty); // 환원 포인트
  552. // int rfPrePntAmt = (int)((double)orgPrePntDcAmt / realOrdQty * wdQty); // 취소 선포인트
  553. // int rfGoodsCpnAmt = (int)((double)orgGoodsCpnDcAmt / realOrdQty * wdQty); // 취소 상품쿠폰금액
  554. // int rfCartCpnAmt = (int)((double)orgCartCpnDcAmt / realOrdQty * wdQty); // 취소 장바구니쿠폰금액
  555. // int rfPlusCpnAmt = (int)((double)orgPlusCpnDcAmt / realOrdQty * wdQty); // 취소 플러스쿠폰금액
  556. // int rfSavePntAmt = (int)((double)orgSavePntAmt / realOrdQty * wdQty);
  557. //
  558. // refundPntAmt += rfPntAmt;
  559. // refundPrePntAmt += rfPrePntAmt;
  560. // refundGoodsCpnAmt += rfGoodsCpnAmt;
  561. // refundCartCpnAmt += rfCartCpnAmt;
  562. // refundPlusCpnAmt += rfPlusCpnAmt;
  563. // refundSavePntAmt += rfSavePntAmt;
  564. //
  565. // int cnclRtnAmt = 0;
  566. // int erpCnclRtnAmt = 0;
  567. // int goodsCpnDcAmt = orgGoodsCpnDcAmt - rfGoodsCpnAmt;
  568. // int cartCpnDcAmt = orgCartCpnDcAmt - rfCartCpnAmt;
  569. // int plusCpnDcAmt = orgPlusCpnDcAmt - rfPlusCpnAmt;
  570. // int pntDcAmt = orgPntDcAmt - rfPntAmt;
  571. // int prePntDcAmt = orgPrePntDcAmt - rfPrePntAmt;
  572. // int savePntAmt = orgSavePntAmt - (orgSavePntAmt / realOrdQty * wdQty);
  573. // cnclRtnQty = orgCnclRtnQty + wdQty;
  574. //
  575. // log.info("orgRealOrdAmt = " + orgRealOrdAmt);
  576. // log.info("wdQty = " + wdQty);
  577. // log.info("cnclRtnAmt = " + cnclRtnAmt);
  578. //
  579. // cnclRtnAmt += orgCnclRtnAmt + (orgCurrPrice * wdQty);
  580. // erpCnclRtnAmt = (orgCurrPrice * wdQty);
  581. // cnclReturnRealOrdAmt = (orgCurrPrice * wdQty) - rfPntAmt - rfPrePntAmt - rfGoodsCpnAmt - rfCartCpnAmt - rfPlusCpnAmt;
  582. //
  583. // log.info("orgCnclRtnAmt = " + orgCnclRtnAmt);
  584. // log.info("orgRealOrdAmt = " + orgRealOrdAmt);
  585. // log.info("orgOrdAmt = " + orgOrdAmt);
  586. // log.info("ordQty = " + ordQty);
  587. // log.info("orgCnclRtnQty = " + orgCnclRtnQty);
  588. // log.info("(orgOrdAmt / (ordQty - orgCnclRtnQty)) = " + (orgOrdAmt / (ordQty - orgCnclRtnQty)));
  589. // log.info("refundPntAmt = " + refundPntAmt);
  590. // log.info("refundPrePntAmt = " + refundPrePntAmt);
  591. // log.info("refundGoodsCpnAmt = " + refundGoodsCpnAmt);
  592. // log.info("refundCartCpnAmt = " + refundCartCpnAmt);
  593. // log.info("refundPlusCpnAmt = " + refundPlusCpnAmt);
  594. // log.info("cnclReturnRealOrdAmt = " + cnclReturnRealOrdAmt);
  595. //
  596. // int realOrdAmt = orgRealOrdAmt - cnclReturnRealOrdAmt;
  597. // refundAmt += cnclReturnRealOrdAmt;
  598. //
  599. // log.info("realOrdAmt = " + realOrdAmt);
  600. // log.info("cnclRtnQty = " + cnclRtnQty);
  601. // log.info("cnclRtnAmt = " + cnclRtnAmt);
  602. // log.info("goodsCpnDcAmt = " + goodsCpnDcAmt);
  603. // log.info("goodsCpnSq = " + goodsCpnSq);
  604. // log.info("cartCpnDcAmt = " + cartCpnDcAmt);
  605. // log.info("cartCpnSq = " + cartCpnSq);
  606. // log.info("pntDcAmt = " + pntDcAmt);
  607. // log.info("prePntDcAmt = " + prePntDcAmt);
  608. // log.info("savePntAmt = " + savePntAmt);
  609. // log.info("plusCpnDcAmt = " + plusCpnDcAmt);
  610. // log.info("plusCpnSq = " + plusCpnSq);
  611. //
  612. // // 주문상세 업데이트
  613. // log.info("============== 주문상세 업데이트 ==============");
  614. //
  615. // Withdraw updParams = new Withdraw();
  616. // updParams.setUpdId(userId);
  617. // updParams.setOrdDtlNo(withdraw.getOrdDtlNo());
  618. // if (cnclRtnQty == ordQty) {
  619. // updParams.setOrdDtlStat(OrderDetailStat.PAYMENT_AFTER_CANCEL.value());
  620. // }
  621. // updParams.setRealOrdAmt(realOrdAmt);
  622. // updParams.setCnclRtnQty(cnclRtnQty);
  623. // updParams.setCnclRtnAmt(cnclRtnAmt);
  624. // updParams.setGoodsCpnDcAmt(goodsCpnDcAmt);
  625. // updParams.setGoodsCpnSq(goodsCpnSq);
  626. // updParams.setCartCpnDcAmt(cartCpnDcAmt);
  627. // updParams.setCartCpnSq(cartCpnSq);
  628. // updParams.setPlusCpnDcAmt(plusCpnDcAmt);
  629. // updParams.setPlusCpnSq(plusCpnSq);
  630. // updParams.setPntDcAmt(pntDcAmt);
  631. // updParams.setPrePntDcAmt(prePntDcAmt);
  632. // updParams.setSavePntAmt(savePntAmt);
  633. // updParams.setRegId(userId);
  634. // withdrawDao.updateWithdrawOrderDetailInfo(updParams);
  635. // withdrawDao.createWithdrawOrderDetailHstInfo(updParams);
  636. //
  637. // // 주문상세 업데이트
  638. // log.info("============== 매출반영 ==============");
  639. //
  640. // Withdraw ifData = new Withdraw();
  641. // ifData.setOrdDtlNo(withdraw.getOrdDtlNo());
  642. // ifData.setOrdNo(ordNo);
  643. // ifData.setWdQty(wdQty);
  644. // ifData.setCnclRtnAmt(cnclRtnAmt);
  645. // ifData.setGoodsCd(withdraw.getGoodsCd());
  646. // ifData.setRealOrdAmt(cnclReturnRealOrdAmt);
  647. // ifData.setRealOrdQty(realOrdQty);
  648. // ifData.setRfGoodsCpnAmt(rfGoodsCpnAmt);
  649. // ifData.setRfCartCpnAmt(rfCartCpnAmt);
  650. // ifData.setRfPlusCpnAmt(rfPlusCpnAmt);
  651. // ifData.setRfPntAmt(rfPntAmt);
  652. // ifData.setRfPrePntAmt(rfPrePntAmt);
  653. // ifData.setRfSavePntAmt(rfSavePntAmt);
  654. // ifData.setGoodsType(withdraw.getGoodsType());
  655. // ifData.setOrdAmt(erpCnclRtnAmt);
  656. // ifData.setCartCpnSq(cartCpnSq);
  657. // ifData.setGoodsCpnSq(goodsCpnSq);
  658. // ifData.setPlusCpnSq(plusCpnSq);
  659. // ifData.setOrderNm(withdraw.getOrderNm());
  660. // ifData.setOrderPhnno(withdraw.getOrderPhnno());
  661. // ifOnilneSales.add(ifData);
  662. //
  663. // // 자사몰이면서 반품이면 포인트,쿠폰 반환
  664. // if (TsaConstants.MallGb.SELFMALL.value().equals(mallGb) && TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) {
  665. //
  666. // if (rfPntAmt > 0) {
  667. // TsaPoint point = new TsaPoint();
  668. // point.setPntAmt(rfPntAmt);
  669. // point.setOrdNo((int)(long)ordNo);
  670. // point.setOrdDtlNo((int)(long)ordDtlNo);
  671. // pointList.add(point);
  672. // }
  673. //
  674. // if (rfPrePntAmt > 0) {
  675. // TsaPoint point = new TsaPoint();
  676. // point.setPntAmt(rfPrePntAmt);
  677. // point.setOrdNo((int)(long)ordNo);
  678. // point.setOrdDtlNo((int)(long)ordDtlNo);
  679. // prePointList.add(point);
  680. // }
  681. //
  682. // if (savePntAmt > 0) {
  683. // TsaPoint point = new TsaPoint();
  684. // point.setPntAmt(-rfSavePntAmt);
  685. // point.setOrdNo((int)(long)ordNo);
  686. // point.setOrdDtlNo((int)(long)ordDtlNo);
  687. // savePointList.add(point);
  688. // }
  689. //
  690. // if (StringUtils.isNotBlank(withdraw.getGoodsCpnSq())) {
  691. // TsaOrder goodsCpnParam = new TsaOrder();
  692. // goodsCpnParam.setCustCpnSq(Long.parseLong(withdraw.getGoodsCpnSq()));
  693. // goodsCpnParam.setUpdId(userId);
  694. //
  695. // TsaCoupon goodsCpnInfo = orderDao.getCustCouponInfo(goodsCpnParam.getCustCpnSq());
  696. // if (goodsCpnInfo != null) {
  697. // goodsCpnInfo = orderDao.getCouponInfo(goodsCpnInfo.getCpnId());
  698. //
  699. // if (goodsCpnInfo != null && ("10".equals(goodsCpnInfo.getReissuance()) || "30".equals(goodsCpnInfo.getReissuance()))) {
  700. // orderDao.updateCustCouponCancel(goodsCpnParam);
  701. // }
  702. // }
  703. // }
  704. //
  705. // if (StringUtils.isNotBlank(withdraw.getPlusCpnSq())) {
  706. // TsaOrder plusCpnParam = new TsaOrder();
  707. // plusCpnParam.setCustCpnSq(Long.parseLong(withdraw.getPlusCpnSq()));
  708. // plusCpnParam.setUpdId(userId);
  709. //
  710. // TsaCoupon plusCpnInfo = orderDao.getCustCouponInfo(plusCpnParam.getCustCpnSq());
  711. // if (plusCpnInfo != null) {
  712. // plusCpnInfo = orderDao.getCouponInfo(plusCpnInfo.getCpnId());
  713. //
  714. // if (plusCpnInfo != null && ("10".equals(plusCpnInfo.getReissuance()) || "30".equals(plusCpnInfo.getReissuance()))) {
  715. // orderDao.updateCustCouponCancel(plusCpnParam);
  716. // }
  717. // }
  718. // }
  719. //
  720. // if (StringUtils.isNotBlank(withdraw.getCartCpnSq())) {
  721. // usedCartCpnSq = Long.parseLong(withdraw.getCartCpnSq());
  722. // }
  723. // }
  724. //
  725. // // 반품요청에 대한 컨펌시 환입 정산정보 생성
  726. // if (TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) {
  727. // Withdraw paramUsac = new Withdraw();
  728. // paramUsac.setUsacGb(UsacGb.PURCHASE_RETURN.value());
  729. // paramUsac.setPrtnGb(PurchaseReturnGb.RETURN.value());
  730. // paramUsac.setOrdDtlNo(withdraw.getOrdDtlNo());
  731. // paramUsac.setOrgUsacGb(UsacGb.SELL.value());
  732. // paramUsac.setUsacQty(wdQty);
  733. // paramUsac.setGoodsCpnDcAmt(rfGoodsCpnAmt);
  734. // paramUsac.setCartCpnDcAmt(rfCartCpnAmt);
  735. // paramUsac.setPlusCpnDcAmt(rfPlusCpnAmt);
  736. // paramUsac.setPntDcAmt(rfPntAmt);
  737. // paramUsac.setPrePntDcAmt(rfPrePntAmt);
  738. // paramUsac.setRegId(userId);
  739. // withdrawDao.createWithdrawUsac(paramUsac);
  740. // }
  741. //
  742. // // 세트상품인 경우 상세번호를 저장
  743. // if ("S".equals(withdraw.getGoodsType())) {
  744. // setOrdDtlNos.setInt(withdraw.getOrdDtlNo(), setOrdDtlNos.getInt(withdraw.getOrdDtlNo()) < 1 ? 1 : setOrdDtlNos.getInt(withdraw.getOrdDtlNo()) + 1);
  745. // }
  746. // }
  747. //
  748. // // 쿠폰 처리
  749. // String chgReasonCds = "10,11,12,13,15,21,30"; // 고객 귀책
  750. // if (chgReasonCds.contains(chgReason) && TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) {
  751. // if (couponInfo != null) {
  752. // if (StringUtils.isNotBlank(couponCartCpnSq) && couponInfo.getBuyLimitAmt() > 0) {
  753. // refundCancelCartCpnAmt += orderDetailCouponCancel(ordNo, ordChgSq, couponInfo.getBuyLimitAmt());
  754. // }
  755. // }
  756. // }
  757. //
  758. // Withdraw orderDetailSumAmtInfo = withdrawDao.getOrderDetailSumAmt(ordNo.toString());
  759. //
  760. // // 마지막에 처리 할 것. 장바구니 쿠폰 사용 여부 처리( 추후 구매제한에 대한 것도 처리 필요)
  761. // if (StringUtils.isNotBlank(couponCartCpnSq) && orderDetailSumAmtInfo.getTotCartCpnDcAmt() == 0 && TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) {
  762. // TsaCoupon cartCpnInfo = new TsaCoupon();
  763. // if (usedCartCpnSq != null) {
  764. // cartCpnInfo = orderDao.getCustCouponInfo(usedCartCpnSq);
  765. // }
  766. // if (cartCpnInfo != null) {
  767. // cartCpnInfo = orderDao.getCouponInfo(cartCpnInfo.getCpnId());
  768. //
  769. // if (cartCpnInfo != null && ("10".equals(cartCpnInfo.getReissuance()) || "30".equals(cartCpnInfo.getReissuance()))) {
  770. // TsaOrder paramCpn = new TsaOrder();
  771. // paramCpn.setUpdId(userId);
  772. // paramCpn.setCustCpnSq(Long.parseLong(couponCartCpnSq));
  773. // orderDao.updateCustCouponCancel(paramCpn);
  774. // }
  775. // }
  776. // }
  777. //
  778. // int remainOrdCnt = withdrawDao.getOrderNotCancelCnt(ordNo);
  779. //
  780. // TsaDelivery paramOrder = new TsaDelivery();
  781. // paramOrder.setOrdNo(ordNo);
  782. //
  783. // if (remainOrdCnt == 0 && TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) {
  784. // paramOrder.setUpdId(userId);
  785. // paramOrder.setOrdStat(OrderStat.PAYMENT_AFTER_CANCEL.value());
  786. // deliveryDao.updateOrder(paramOrder);
  787. // }
  788. //
  789. // /* 포인트 처리 */
  790. // TsaOrder ordPnt = new TsaOrder();
  791. // ordPnt.setOrdNo(Long.toString(ordNo));
  792. // ordPnt.setCustNo(Integer.toString(custNo));
  793. // ordPnt.setOccurGb(TsaConstants.PointOccurGb.USE_POINT.value());
  794. // int ordUsedCustPointHstSq = orderDao.getOrderCustPointHstSq(ordPnt); // 사용한 포인트 정보
  795. //
  796. // if (ordUsedCustPointHstSq > 0 && TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) {
  797. //
  798. // // 환불 포인트 만료일
  799. // String expireDt = orderDao.getOrderAccountExpireDt(ordUsedCustPointHstSq);
  800. // String toDay = GagaDateUtil.getToday();
  801. //
  802. // if (StringUtils.isNotBlank(expireDt)) {
  803. //
  804. // // 만료일이 지났으면 오늘 + 7일로 셋팅
  805. // long longSwitchDueDt = Long.parseLong(expireDt);
  806. // long longToDay = Long.parseLong(toDay);
  807. //
  808. // if (longSwitchDueDt < longToDay) {
  809. // expireDt = GagaDateUtil.getOffsetDate(toDay, 7, "yyyyMMdd");
  810. // }
  811. //
  812. // // 사용 포인트 반환
  813. // if (refundPntAmt > 0) {
  814. // TsaPoint point = new TsaPoint();
  815. // point.setCustNo(Integer.toString(custNo));
  816. // point.setOccurGb(TsaConstants.PointOccurGb.USE_POINT_CANCEL.value());
  817. // point.setGivenPntAmt(refundPntAmt);
  818. // point.setAvailPntAmt(refundPntAmt);
  819. // point.setUsePntAmt(0);
  820. // point.setExpireDt(expireDt);
  821. // point.setOrdNo(Integer.parseInt(Long.toString(ordNo)));
  822. // point.setSwitchDueDt(GagaDateUtil.getTodayDateTime());
  823. // point.setPntUploadStat(TsaConstants.PointOccurStat.APPLY_COMPLETE.value());
  824. // point.setPntUploadDt(point.getSwitchDueDt());
  825. // point.setRegId(userId);
  826. // point.setUpdId(userId);
  827. // orderDao.createPointAccount(point);
  828. //
  829. // point.setPntAmt(point.getGivenPntAmt());
  830. // orderDao.createCustPointHst(point);
  831. //
  832. // orderDao.createPointDetail(point);
  833. //
  834. // for (TsaPoint paramPnt : pointList) {
  835. // paramPnt.setCustPointHstSq(point.getCustPointHstSq());
  836. // paramPnt.setRegId(userId);
  837. // orderDao.createOrderPoint(paramPnt);
  838. // }
  839. // }
  840. //
  841. // // 적립 예정 포인트 취소
  842. // if (refundSavePntAmt > 0) {
  843. // TsaPoint point = new TsaPoint();
  844. //
  845. // point.setOrdNo(Integer.parseInt(Long.toString(ordNo)));
  846. // point.setOccurGb(TsaConstants.PointOccurGb.EXPECT_POINT.value());
  847. // String switchDueDt = orderDao.getPointAccountSwitchDueDt(point);
  848. // expireDt = orderDao.getPointAccountExpireDt(point);
  849. // String pntUploadStat = orderDao.getPointAccountPntUploadStat(point);
  850. //
  851. // int availPntAmt = 0;
  852. // String uploadDt = "";
  853. // String uploadStat = TsaConstants.PointOccurStat.APPLY_EXPECT.value();
  854. // String toDayTime = GagaDateUtil.getTodayDateTime();
  855. //
  856. // // 예정일이 지났으면 오늘로 셋팅
  857. // if (TsaConstants.PointOccurStat.APPLY_COMPLETE.value().equals(pntUploadStat)) {
  858. // availPntAmt = -refundSavePntAmt;
  859. // switchDueDt = toDayTime;
  860. // uploadDt = switchDueDt;
  861. // uploadStat = TsaConstants.PointOccurStat.APPLY_COMPLETE.value();
  862. // }
  863. //
  864. // point.setCustNo(Integer.toString(custNo));
  865. // point.setOccurGb(TsaConstants.PointOccurGb.EXPECT_POINT_CANCEL.value());
  866. // point.setGivenPntAmt(-refundSavePntAmt);
  867. // point.setAvailPntAmt(availPntAmt);
  868. // point.setUsePntAmt(0);
  869. // point.setExpireDt(expireDt);
  870. // point.setSwitchDueDt(GagaDateUtil.getTodayDateTime());
  871. // point.setPntUploadStat(uploadStat);
  872. // point.setPntUploadDt(uploadDt);
  873. // point.setRegId(userId);
  874. // point.setUpdId(userId);
  875. // orderDao.createPointAccount(point);
  876. //
  877. // point.setPntAmt(point.getGivenPntAmt());
  878. // orderDao.createCustPointHst(point);
  879. //
  880. // orderDao.createPointDetail(point);
  881. //
  882. // for (TsaPoint paramPnt : savePointList) {
  883. // paramPnt.setCustPointHstSq(point.getCustPointHstSq());
  884. // paramPnt.setRegId(userId);
  885. // orderDao.createOrderPoint(paramPnt);
  886. // }
  887. // }
  888. // }
  889. // }
  890. //
  891. // if (TsaConstants.OrderChangeGb.RETURN.value().equals(chgGb)) { // 반품인경우
  892. // // 결제 정보
  893. // TsaOrder paramPay = new TsaOrder();
  894. // paramPay.setOrdNo(ordNo.toString());
  895. // paramPay.setPayStat(PaymentStat.PAYMENT_COMPLETE.value());
  896. // paramPay.setDelvPayGb("O");
  897. // TsaOrder pay = orderDao.getPayment(paramPay);
  898. //
  899. // pay.setOrgPayStat(PaymentStat.PAYMENT_COMPLETE.value());
  900. //
  901. // int orgPaySq = pay.getPaySq();
  902. // int paySq = orgPaySq + 1;
  903. // int orgPayAmt = pay.getPayAmt();
  904. // int devlFeePaySq = orgPaySq;
  905. //
  906. // // 원 결제 정보 업데이트
  907. // pay.setOrdNo(ordNo.toString());
  908. // pay.setPayStat(PaymentStat.PAYMENT_CANCEL.value());
  909. // pay.setUpdId(userId);
  910. //
  911. // /* 9.배송비 등록 */
  912. // GagaMap delvMap = deliveryFeeProcess(params, orgPaySq, chgReasonCds);
  913. // int totRfDelvFee = delvMap.getInt("totDelvFee"); // 총환불배송비
  914. // int rfDelvCpnAmt = delvMap.getInt("rfDelvCpnAmt");
  915. //
  916. // // 환불금액
  917. // log.info("============== 환불 금액 ==============");
  918. //
  919. // if (TsaConstants.MallGb.SELFMALL.value().equals(mallGb)) { // 자사몰인경우
  920. // refundAmt = refundAmt + totRfDelvFee - refundCancelCartCpnAmt;
  921. // }
  922. //
  923. // log.info("refundAmt = " + refundAmt);
  924. // log.info("custShipAmt = " + custShipAmt);
  925. // log.info("orgDelvFee = " + orgDelvFee);
  926. // log.info("refundGoodsCpnAmt = " + refundGoodsCpnAmt);
  927. // log.info("refundCartCpnAmt = " + (refundCartCpnAmt + refundCancelCartCpnAmt));
  928. // log.info("refundPntAmt = " + refundPntAmt);
  929. // log.info("refundPrePntAmt = " + refundPrePntAmt);
  930. // log.info("refundCancelCartCpnAmt = " + refundCancelCartCpnAmt);
  931. // log.info("refundPlusCpnAmt = " + refundPlusCpnAmt);
  932. // log.info("totRfDelvFee = " + totRfDelvFee);
  933. // log.info("rfDelvCpnAmt = " + rfDelvCpnAmt);
  934. //
  935. // // 환불정보
  936. // if (TsaConstants.MallGb.SELFMALL.value().equals(mallGb)) { // 자사몰만 환불정보 등록
  937. // if (PayMeans.ACCOUNT_DEPOSIT.value().equals(pay.getPayMeans())) {
  938. // pay.setOrdChgSq(ordChgSq);
  939. // TsaOrder paramRefund = orderDao.getRefundAccount(pay);
  940. //
  941. // if (paramRefund != null) {
  942. // pay.setRaBnk(paramRefund.getRaBnk());
  943. // pay.setRaNm(paramRefund.getRaNm());
  944. // pay.setRaNo(paramRefund.getRaNo());
  945. // } else {
  946. // paramRefund = orderDao.getCustomerDefaultAccount(Integer.toString(custNo));
  947. // if (paramRefund != null) {
  948. // pay.setRaNo(paramRefund.getRaNo());
  949. // pay.setRaNm(paramRefund.getRaNm());
  950. // pay.setRaBnk(paramRefund.getRaBnk());
  951. // }
  952. // }
  953. // if (paramRefund == null) {
  954. // throw new IllegalStateException("환불계좌정보가 없습니다.");
  955. // }
  956. // paramRefund.setOrdNo(Long.toString(ordNo));
  957. // paramRefund.setPaySq(pay.getPaySq());
  958. // paramRefund.setOrdChgSq(ordChgSq);
  959. // paramRefund.setRefundAmt(refundAmt);
  960. // paramRefund.setRfGoodsCpnAmt(refundGoodsCpnAmt + refundPlusCpnAmt + rfDelvCpnAmt);
  961. // paramRefund.setRfCartCpnAmt(refundCartCpnAmt + refundCancelCartCpnAmt);
  962. // paramRefund.setRfPntAmt(refundPntAmt);
  963. // paramRefund.setRfPrePntAmt(refundPrePntAmt);
  964. // paramRefund.setRegId(userId);
  965. // orderDao.createRefund(paramRefund);
  966. // } else {
  967. // TsaOrder paramRefund = new TsaOrder();
  968. // paramRefund.setOrdNo(Long.toString(ordNo));
  969. // paramRefund.setPaySq(pay.getPaySq());
  970. // paramRefund.setOrdChgSq(ordChgSq);
  971. // paramRefund.setRefundAmt(refundAmt);
  972. // paramRefund.setRfGoodsCpnAmt(refundGoodsCpnAmt + refundPlusCpnAmt + rfDelvCpnAmt);
  973. // paramRefund.setRfCartCpnAmt(refundCartCpnAmt + refundCancelCartCpnAmt);
  974. // paramRefund.setRfPntAmt(refundPntAmt);
  975. // paramRefund.setRfPrePntAmt(refundPrePntAmt);
  976. // paramRefund.setRegId(userId);
  977. // orderDao.createRefund(paramRefund);
  978. // }
  979. // }
  980. //
  981. // int payAmt = orgPayAmt - refundAmt;
  982. //
  983. // String partCancelYn = "N";
  984. //
  985. // if (orgPaySq > 1) {
  986. // partCancelYn = "Y";
  987. // }
  988. //
  989. // if (payAmt > 0) {
  990. // paramPay.setPaySq(paySq);
  991. // paramPay.setPayAmt(payAmt);
  992. // paramPay.setPayStat(PaymentStat.PAYMENT_COMPLETE.value());
  993. // paramPay.setRegId(userId);
  994. // paramPay.setUpdId(userId);
  995. // paramPay.setOrgPaySq(pay.getPaySq());
  996. // orderDao.createPayment(paramPay);
  997. //
  998. // partCancelYn = "Y";
  999. // devlFeePaySq = paySq;
  1000. // }
  1001. //
  1002. // // 매출반영
  1003. // // ERP 판매반영 생성
  1004. // for (Withdraw withdraw : ifOnilneSales) {
  1005. // withdraw.setPayAmt(payAmt);
  1006. // withdraw.setRefundAmt(refundAmt);
  1007. // withdraw.setRegId(userId);
  1008. // createIfEcpTbSalesReturn(withdraw);
  1009. // }
  1010. //
  1011. // boolean checkPay = orgPayAmt - payAmt < 0 ? true : false;
  1012. // if (checkPay) {
  1013. // throw new IllegalStateException("결제금액과 환불정보가 맞지 않습니다.");
  1014. // }
  1015. //
  1016. // /* PG결제취소 */
  1017. //
  1018. // TsaPayGate paramPg = new TsaPayGate();
  1019. // paramPg.setPgShopId(pay.getPgShopId()); // 상점아이디
  1020. // paramPg.setPgGb(pay.getPgGb()); // pg구분
  1021. // paramPg.setTid(pay.getPgTid()); // 거래번호
  1022. // paramPg.setCancelAmt(refundAmt); // 취소금액
  1023. // paramPg.setPartCancelYn(partCancelYn); // 부분취소여부
  1024. //
  1025. // if (TsaConstants.PayMeans.ACCOUNT_DEPOSIT.value().equals(pay.getPayMeans())) { // 무통입금일때
  1026. // paramPg.setRefundYn("Y");
  1027. // paramPg.setRefundBankCd(pay.getRaBnk()); // 환불은행코드
  1028. // paramPg.setRefundAcctNo(pay.getRaNo()); // 환불계좌번호
  1029. // paramPg.setRefundAcctNm(pay.getRaNm()); // 환불계좌주명
  1030. // }
  1031. //
  1032. // // 자사몰이고 결제완료이고 PG점프가 아닌경우 PG와 통신한다.
  1033. // if (TsaConstants.MallGb.SELFMALL.value().equals(mallGb)
  1034. // && TsaConstants.PaymentStat.PAYMENT_COMPLETE.value().equals(pay.getOrgPayStat()) && "N".equals(pgStat)) {
  1035. //
  1036. // GagaMap result = orderService.cancelPgPayment(paramPg);
  1037. //
  1038. // if (result.getBoolean("success")) { // 00:취소성공
  1039. // result.put("resultCd", "00");
  1040. // result.put("resultMsg", "결제취소가 완료되었습니다.");
  1041. // pay.setPgCnclTid(result.getString("TID"));
  1042. // } else {
  1043. // throw new IllegalStateException(result.getString("ResultMsg")); // PG처리 실패시 전체 ROLLBACK 처리함.
  1044. // }
  1045. //
  1046. // }
  1047. //
  1048. // if (payAmt == 0) {
  1049. // paySq = orgPaySq;
  1050. // pay.setPayStat(TsaConstants.PaymentStat.PAYMENT_CANCEL.value());
  1051. // }
  1052. //
  1053. // orderDao.updatePayment(pay);
  1054. //
  1055. // // 카카오 알림톡 전송
  1056. // try {
  1057. // if (TsaConstants.MallGb.SELFMALL.value().equals(mallGb)) {
  1058. // kakaoService.sendReturnComplete(params, withdrawList);
  1059. // }
  1060. // } catch (Exception e) {
  1061. // e.fillInStackTrace();
  1062. // }
  1063. //
  1064. // } else {// 교환인 경우
  1065. //
  1066. // // 교환출고처 지정대기(26) 상태인 놈을 출고처 예정(34) 으로 업데이트
  1067. // for (Withdraw withdraw : ifOnilneSales) {
  1068. // withdrawDao.updateExchangeLocAssignStatus(withdraw);
  1069. // withdraw.setUpdId(userId);
  1070. // withdraw.setRegId(userId);
  1071. // withdrawDao.createWithdrawOrderDetailHstInfo(withdraw); // 원주문상세번호에 대한 이력
  1072. // withdrawDao.createWithdrawOrderDetailHstInfo2(withdraw); // 교환 주문상세번호에 대한 이력
  1073. // }
  1074. //
  1075. // // 매출반영 환입 ERP 판매반영 생성
  1076. // for (Withdraw withdraw : ifOnilneSales) {
  1077. // withdraw.setRegId(userId);
  1078. // createIfEcpTbSalesReturn(withdraw);
  1079. // }
  1080. // // 카카오 알림톡 전송
  1081. // try {
  1082. // if (TsaConstants.MallGb.SELFMALL.value().equals(mallGb)) {
  1083. // kakaoService.sendWithdrawConfirm(params, withdrawList);
  1084. // }
  1085. // } catch (Exception e) {
  1086. // e.fillInStackTrace();
  1087. // }
  1088. // }
  1089. //
  1090. // }
  1091. //
  1092. }
  1093. /**
  1094. * ERP 환입반영처리
  1095. *
  1096. * @param withdraw - 주문 정보
  1097. * @return
  1098. * @author yh98kim
  1099. * @since 2020. 05. 13
  1100. */
  1101. // @Transactional("shopTxnManager")
  1102. // public void createIfEcpTbSalesReturn(Withdraw withdraw) {
  1103. // if ("S".equals(withdraw.getGoodsType())) {
  1104. // // 세트의 단품별 비중을 구한다.
  1105. // Collection<Withdraw> withdrawList = withdrawDao.getWithdrawDetailList2(withdraw);
  1106. // int totCnt = withdrawList.size();
  1107. // int cnt = 0;
  1108. //
  1109. // int sumDivRfPntAmt = 0;
  1110. // int sumDivRfPrePntAmt = 0;
  1111. // int sumDivRfGoodsCpnAmt = 0;
  1112. // int sumDivRfCartCpnAmt = 0;
  1113. // int sumDivRfPlusCpnAmt = 0;
  1114. // int sumDivRfSavePntAmt = 0;
  1115. //
  1116. // int rfPntAmt = withdraw.getRfPntAmt();
  1117. // int rfPrePntAmt = withdraw.getRfPrePntAmt();
  1118. // int rfGoodsCpnAmt = withdraw.getRfGoodsCpnAmt();
  1119. // int rfCartCpnAmt = withdraw.getRfCartCpnAmt();
  1120. // int rfPlusCpnAmt = withdraw.getRfPlusCpnAmt();
  1121. // int rfSavePntAmt = withdraw.getSavePntAmt();
  1122. //
  1123. // int wdQty = withdraw.getWdQty(); // 회수수량
  1124. // int realOrdAmt = withdraw.getRealOrdAmt(); // 실주문금액
  1125. //
  1126. // GagaMap gMap = new GagaMap();
  1127. //
  1128. // for (Withdraw wd : withdrawList) {
  1129. // int divRfPntAmt = 0;
  1130. // int divRfPrePntAmt = 0;
  1131. // int divRfGoodsCpnAmt = 0;
  1132. // int divRfCartCpnAmt = 0;
  1133. // int divRfPlusCpnAmt = 0;
  1134. // int divRfSavePntAmt = 0;
  1135. //
  1136. // // item 별 비중: 회수수량 * itemQty * itemPrice / realOrdAmt
  1137. // // 소수점 2째짜리까지 비중을 구한다.
  1138. // Double rate = Math.round(wdQty * wd.getItemQty() * wd.getItemPrice() / realOrdAmt * 100) / 100.0;
  1139. //
  1140. // if (totCnt > 1 && cnt == totCnt - 1) { // 마지막 건인 경우 쿠폰 포인트는 총계에서 나머지 합계를 빼서 구한다.
  1141. // divRfPntAmt = rfPntAmt - sumDivRfPntAmt;
  1142. // divRfPrePntAmt = rfPrePntAmt - sumDivRfPrePntAmt;
  1143. // divRfGoodsCpnAmt = rfGoodsCpnAmt - sumDivRfPrePntAmt;
  1144. // divRfCartCpnAmt = rfCartCpnAmt - sumDivRfGoodsCpnAmt;
  1145. // divRfPlusCpnAmt = rfPlusCpnAmt - sumDivRfPlusCpnAmt;
  1146. // divRfSavePntAmt = rfSavePntAmt - sumDivRfSavePntAmt;
  1147. // } else {
  1148. // divRfPntAmt = (int)Math.round(rfPntAmt * rate);
  1149. // divRfPrePntAmt = (int)Math.round(rfPrePntAmt * rate);
  1150. // divRfGoodsCpnAmt = (int)Math.round(rfGoodsCpnAmt * rate);
  1151. // divRfCartCpnAmt = (int)Math.round(rfCartCpnAmt * rate);
  1152. // divRfPlusCpnAmt = (int)Math.round(rfPlusCpnAmt * rate);
  1153. // divRfSavePntAmt = (int)Math.round(rfSavePntAmt * rate);
  1154. //
  1155. // sumDivRfPntAmt += divRfPntAmt;
  1156. // sumDivRfPrePntAmt += divRfPrePntAmt;
  1157. // sumDivRfGoodsCpnAmt += divRfGoodsCpnAmt;
  1158. // sumDivRfCartCpnAmt += divRfCartCpnAmt;
  1159. // sumDivRfPlusCpnAmt += divRfPlusCpnAmt;
  1160. // sumDivRfSavePntAmt += divRfSavePntAmt;
  1161. // }
  1162. // wd.setRfPntAmt(divRfPntAmt);
  1163. // wd.setRfPrePntAmt(divRfPrePntAmt);
  1164. // wd.setRfGoodsCpnAmt(divRfGoodsCpnAmt);
  1165. // wd.setRfCartCpnAmt(divRfCartCpnAmt);
  1166. // wd.setRfPlusCpnAmt(divRfPlusCpnAmt);
  1167. // wd.setRfSavePntAmt(divRfSavePntAmt);
  1168. // wd.setOrdAmt(wdQty * wd.getItemQty() * wd.getItemPrice());
  1169. // int tmpRealOrdAmt = wdQty * wd.getItemQty() * wd.getItemPrice() - (divRfPntAmt - divRfPrePntAmt - divRfGoodsCpnAmt - divRfCartCpnAmt - divRfPlusCpnAmt);
  1170. // wd.setRealOrdAmt(tmpRealOrdAmt);
  1171. //
  1172. // withdrawDao.createIfEcpTbSalesReturn(withdraw);
  1173. //
  1174. // cnt++;
  1175. // }
  1176. // } else {
  1177. // withdrawDao.createIfEcpTbSalesReturn(withdraw);
  1178. // }
  1179. // }
  1180. /**
  1181. * 배송비 처리
  1182. *
  1183. * @param params - 주문 정보
  1184. * @return
  1185. * @author yh98kim
  1186. * @since 2020. 05. 13
  1187. */
  1188. // @Transactional("shopTxnManager")
  1189. // public GagaMap deliveryFeeProcess(Withdraw params, int paySq, String chgReasonCds) {
  1190. // GagaMap resultMap = new GagaMap();
  1191. // TsaOrder order = new TsaOrder();
  1192. // order.setOrdNo(Long.toString(params.getOrdNo()));
  1193. // Collection<TsaOrder> delvFeeList = orderDao.getSupplyCompDelvFeeList(order);
  1194. // String regId = TsaSession.getInfo().getUserId();
  1195. // String ordNo = order.getOrdNo();
  1196. // String chgReasonDesc = order.getChgReasonDesc();
  1197. // int totDelvFee = 0; // 환불할 총배송비
  1198. // int selfYCnt = 0; // 자사상품 카운트
  1199. // String selfYSupplyCompCd = ""; // 자사상품 대표업체코드
  1200. // int selfYDelvFee = 0; // 자사상품 결제한배송비
  1201. // int selfYAddDelvFee = 0;
  1202. // int selfYMinOrdAmt = 9999999; // 자사상품 무료배송 최소주문금액
  1203. // int selfYSumRealOrdAmt = 0; // 자사상품 총결제금액
  1204. // Long selfYdelvCpnSq = null; // 배송비쿠폰
  1205. // int selfYDelvCpnAmt = 0;
  1206. // int rfDelvCpnAmt = 0;
  1207. //
  1208. // TsaOrder setParams = new TsaOrder();
  1209. // setParams.setOrdNo(ordNo);
  1210. // setParams.setPaySq(paySq);
  1211. // setParams.setOrdChgSq(params.getOrdChgSq());
  1212. //
  1213. // // 교환배송비 부과여부
  1214. // boolean bExchDelvFee = false; // true: 교환배송비 부과, false: 교환배송비 부과안함
  1215. //
  1216. // String delvFeeGb = TsaConstants.DeliveryFeeGb.RETURN_DELIVERY_FEE.value();
  1217. // if (TsaConstants.OrderChangeGb.EXCHANGE.value().equals(params.getChgGb())) {
  1218. // delvFeeGb = TsaConstants.DeliveryFeeGb.EXCHANGE_DELIVERY_FEE.value(); // 교환
  1219. // if (chgReasonCds.contains(params.getChgReason())) { // 고객귀책인 경우
  1220. // bExchDelvFee = true;
  1221. // }
  1222. // }
  1223. // setParams.setDelvFeeGb(delvFeeGb);
  1224. // setParams.setDelvUsacYn("N");
  1225. // setParams.setRegId(regId);
  1226. // setParams.setUpdId(regId);
  1227. //
  1228. // // 회수비(반품배송비) 부과여부
  1229. // boolean bRtnDelvFee = true; // true: 회수비 부과, false: 회수비 부과안함
  1230. // // 주문당 변경건수
  1231. // int chgCnt = deliveryDao.getOrdReturnChgCnt(params.getOrdNo());
  1232. // // 회원이고 고객귀책인 경우에 주문당 1회만 회수비 무료
  1233. // if (params.getCustNo() != 0 && chgReasonCds.contains(params.getChgReason())) { // 고객귀책
  1234. // if (chgCnt == 1) {
  1235. // bRtnDelvFee = false;
  1236. // }
  1237. // }
  1238. //
  1239. // for (TsaOrder oneData : delvFeeList) {
  1240. //
  1241. // String selfYn = oneData.getSelfYn();
  1242. // String supplyCompCd = oneData.getSupplyCompCd();
  1243. //
  1244. // int payDelvFee = oneData.getPayDelvFee();
  1245. // int delvFee = oneData.getDelvFee();
  1246. // int sumRealOrdAmt = oneData.getSumRealOrdAmt();
  1247. // int sumCnclRtnAmt = oneData.getSumCnclRtnAmt();
  1248. // int minOrdAmt = oneData.getMinOrdAmt();
  1249. // int delvCpnAmt = oneData.getDelvCpnAmt();
  1250. // Long delvCpnSq = oneData.getDelvCpnSq();
  1251. //
  1252. // log.debug("################# sumRealOrdAmt : {}", sumRealOrdAmt);
  1253. // log.debug("################# sumCnclRtnAmt : {}", sumCnclRtnAmt);
  1254. //
  1255. // if (selfYn.equals("Y")) { // 자사
  1256. // if (selfYCnt == 0) { // 자사 대표업체코드 : 업체코드로 DESC 해서 가져옴 - 파스텔(W), 플라인타이거(F)
  1257. // selfYSupplyCompCd = supplyCompCd;
  1258. // selfYDelvFee = payDelvFee;
  1259. // selfYAddDelvFee = delvFee;
  1260. // }
  1261. // if (minOrdAmt < selfYMinOrdAmt) {
  1262. // selfYMinOrdAmt = minOrdAmt;
  1263. // }
  1264. //
  1265. // if (selfYDelvCpnAmt == 0) {
  1266. // selfYDelvCpnAmt = delvCpnAmt;
  1267. // selfYdelvCpnSq = delvCpnSq;
  1268. // }
  1269. //
  1270. // selfYSumRealOrdAmt += sumRealOrdAmt;
  1271. // selfYCnt++;
  1272. // } else { // 입점업체
  1273. //
  1274. // if (TsaConstants.OrderChangeGb.EXCHANGE.value().equals(params.getChgGb())) { // 교환인 경우
  1275. // if (bExchDelvFee) { // 교환배송비 부과
  1276. // setParams.setDelvFee(delvFee * 2 - params.getEncloseFee());
  1277. // totDelvFee += delvFee * 2 - params.getEncloseFee();
  1278. // // TB_DELIVERY_FEE 에서 ORD_NO, ORD_CHG_SQ 조건으로 Update
  1279. // setParams.setSupplyCompCd(supplyCompCd);
  1280. // withdrawDao.mergeDeliveryFee(setParams);
  1281. // }
  1282. // } else { // 반품인 경우
  1283. // if (payDelvFee > 0) { // 결제한배송비가 있을경우
  1284. //
  1285. // if (sumRealOrdAmt == 0) { // 전체취소한경우 배송비 환불
  1286. //
  1287. // // 귀책사유에 따라 배송비 환불
  1288. // if (!chgReasonCds.contains(params.getChgReason())) { // 회사귀책
  1289. // setParams.setDelvFee(-payDelvFee - params.getEncloseFee());
  1290. // totDelvFee += payDelvFee - delvCpnAmt + params.getEncloseFee();
  1291. // } else { // 고객귀책
  1292. // if (bRtnDelvFee) { // 회수비 부과
  1293. // setParams.setDelvFee(delvFee - params.getEncloseFee()); // 회수배송비(delvFee) - 동봉비
  1294. // // 총환불배송비 = 동봉비 - 배송쿠폰금액 - 고객부담배송비
  1295. // totDelvFee += params.getEncloseFee() - delvCpnAmt - delvFee;
  1296. // } else {
  1297. // setParams.setDelvFee(0 - params.getEncloseFee()); // 회수배송비(delvFee) - 동봉비
  1298. // // 총환불배송비 = 동봉비 - 배송쿠폰금액 - 고객부담배송비(0)
  1299. // totDelvFee += params.getEncloseFee() - delvCpnAmt;
  1300. // }
  1301. // }
  1302. //
  1303. // setParams.setSupplyCompCd(supplyCompCd);
  1304. // orderDao.createDeliveryFee(setParams);
  1305. //
  1306. // if (delvCpnSq != null && delvCpnSq > 0L) {
  1307. // TsaCoupon delvCpnInfo = orderDao.getCustCouponInfo(delvCpnSq);
  1308. // delvCpnInfo = orderDao.getCouponInfo(delvCpnInfo.getCpnId());
  1309. //
  1310. // if ("10".equals(delvCpnInfo.getReissuance()) || "30".equals(delvCpnInfo.getReissuance())) {
  1311. // TsaOrder delvCpnParam = new TsaOrder();
  1312. // delvCpnParam.setUpdId(regId);
  1313. // delvCpnParam.setCustCpnSq(delvCpnSq);
  1314. // orderDao.updateCustCouponCancel(delvCpnParam);
  1315. // }
  1316. // rfDelvCpnAmt += delvCpnAmt;
  1317. // }
  1318. // }
  1319. // } else {
  1320. // if (delvCpnAmt == 0) { // 결제한배송비가 없었을경우(배송비 쿠폰 사용시 계산 필요없음)
  1321. // if (chgReasonCds.contains(params.getChgReason())) { // 고객귀책
  1322. // if (sumRealOrdAmt < minOrdAmt) { // 무료배송최소주문금액보다 작을경우 배송비 발생
  1323. // if (bRtnDelvFee) { // 회수비 부과
  1324. // setParams.setDelvFee(delvFee * 2); // 회수배송비+원주문배송비
  1325. // totDelvFee -= delvFee * 2;
  1326. // } else {
  1327. // setParams.setDelvFee(0);
  1328. // }
  1329. // } else {
  1330. // if (bRtnDelvFee) { // 회수비 부과
  1331. // setParams.setDelvFee(delvFee); // 회수배송비
  1332. // totDelvFee -= delvFee;
  1333. // } else {
  1334. // setParams.setDelvFee(0); // 회수배송비
  1335. // }
  1336. // }
  1337. // setParams.setSupplyCompCd(supplyCompCd);
  1338. // orderDao.createDeliveryFee(setParams);
  1339. // }
  1340. // }
  1341. // }
  1342. // }
  1343. // }
  1344. //
  1345. // } /* ~for */
  1346. //
  1347. // /* 자사상품 배송비 등록 */
  1348. // if (selfYCnt > 0) {
  1349. //
  1350. // if (TsaConstants.OrderChangeGb.EXCHANGE.value().equals(params.getChgGb())) { // 교환인 경우
  1351. // if (bExchDelvFee) { // 교환배송비 부과
  1352. // setParams.setDelvFee(selfYAddDelvFee * 2 - params.getEncloseFee());
  1353. // totDelvFee += selfYAddDelvFee * 2 - params.getEncloseFee();
  1354. // // TB_DELIVERY_FEE 에서 ORD_NO, ORD_CHG_SQ 조건으로 Update
  1355. // setParams.setSupplyCompCd(selfYSupplyCompCd);
  1356. // withdrawDao.mergeDeliveryFee(setParams);
  1357. // }
  1358. //
  1359. // } else {
  1360. //
  1361. // if (selfYDelvFee > 0) { // 결제한배송비가 있을경우
  1362. //
  1363. // if (selfYSumRealOrdAmt == 0) { // 전체취소한경우 배송비 환불
  1364. // // 귀책사유에 따라 배송비 환불
  1365. // if (!chgReasonCds.contains(params.getChgReason())) { // 회사귀책
  1366. // setParams.setDelvFee(selfYDelvFee * -1 - params.getEncloseFee());
  1367. // totDelvFee += selfYDelvFee - selfYDelvCpnAmt + params.getEncloseFee();
  1368. // } else {
  1369. // if (bRtnDelvFee) { // 회수비 부과
  1370. // setParams.setDelvFee(selfYDelvFee * -1 - params.getEncloseFee());
  1371. // totDelvFee += params.getEncloseFee() - selfYDelvCpnAmt - selfYDelvFee;
  1372. // } else {
  1373. // setParams.setDelvFee(-params.getEncloseFee());
  1374. // totDelvFee += params.getEncloseFee() - selfYDelvCpnAmt;
  1375. // }
  1376. // }
  1377. // setParams.setSupplyCompCd(selfYSupplyCompCd);
  1378. // orderDao.createDeliveryFee(setParams);
  1379. //
  1380. // if (selfYdelvCpnSq != null && selfYdelvCpnSq > 0L) {
  1381. // TsaCoupon delvCpnInfo = orderDao.getCustCouponInfo(selfYdelvCpnSq);
  1382. // delvCpnInfo = orderDao.getCouponInfo(delvCpnInfo.getCpnId());
  1383. //
  1384. // if ("10".equals(delvCpnInfo.getReissuance()) || "30".equals(delvCpnInfo.getReissuance())) {
  1385. // TsaOrder delvCpnParam = new TsaOrder();
  1386. // delvCpnParam.setUpdId(regId);
  1387. // delvCpnParam.setCustCpnSq(selfYdelvCpnSq);
  1388. // orderDao.updateCustCouponCancel(delvCpnParam);
  1389. // }
  1390. //
  1391. // rfDelvCpnAmt += selfYDelvCpnAmt;
  1392. // }
  1393. //
  1394. // } else {
  1395. // if (bRtnDelvFee) { // 회수비 부과
  1396. // setParams.setDelvFee(-selfYDelvFee);
  1397. // } else {
  1398. // setParams.setDelvFee(0);
  1399. // }
  1400. // setParams.setSupplyCompCd(selfYSupplyCompCd);
  1401. // orderDao.createDeliveryFee(setParams);
  1402. // totDelvFee -= selfYDelvCpnAmt;
  1403. // }
  1404. //
  1405. // } else {
  1406. // if (selfYDelvCpnAmt == 0) { // 결제한배송비가 없었을경우(배송비 쿠폰 사용시 계산 필요없음)
  1407. // if (chgReasonCds.contains(params.getChgReason())) { // 고객귀책
  1408. // if (selfYSumRealOrdAmt < selfYMinOrdAmt) { // 무료배송최소주문금액보다 작을경우 배송비 발생
  1409. // if (bRtnDelvFee) { // 회수비 부과
  1410. // setParams.setDelvFee(selfYAddDelvFee * 2);
  1411. // totDelvFee -= selfYAddDelvFee * 2;
  1412. // } else {
  1413. // setParams.setDelvFee(0);
  1414. // totDelvFee -= 0;
  1415. // }
  1416. // setParams.setSupplyCompCd(selfYSupplyCompCd);
  1417. // orderDao.createDeliveryFee(setParams);
  1418. // } else { // 무료배송금액보다 큰 경우에는 회수비만 부과
  1419. // if (bRtnDelvFee) { // 회수비 부과
  1420. // setParams.setDelvFee(selfYAddDelvFee);
  1421. // totDelvFee -= selfYAddDelvFee;
  1422. // setParams.setSupplyCompCd(selfYSupplyCompCd);
  1423. // orderDao.createDeliveryFee(setParams);
  1424. // }
  1425. // }
  1426. // }
  1427. // }
  1428. // }
  1429. // }
  1430. // }
  1431. //
  1432. // resultMap.setInt("totDelvFee", totDelvFee);
  1433. // resultMap.setInt("rfDelvCpnAmt", rfDelvCpnAmt);
  1434. //
  1435. // return resultMap;
  1436. // }
  1437. /**
  1438. * 회수관리 - 주문상세 남은상품에 대한 장바구니쿠폰 처리
  1439. *
  1440. * @param ordNo
  1441. * @param ordChgSq
  1442. * @param buyLimitAmt
  1443. * @return int
  1444. * @author rladbwnd5
  1445. * @since 2020. 02. 17
  1446. */
  1447. // @Transactional("shopTxnManager")
  1448. // private int orderDetailCouponCancel(Long ordNo, Long ordChgSq, int buyLimitAmt) {
  1449. // int refundCancelCartCpnAmt = 0;
  1450. // String userId = TsaSession.getInfo().getUserId();
  1451. //
  1452. // Withdraw searchParam = new Withdraw();
  1453. // searchParam.setOrdNo(ordNo);
  1454. // searchParam.setOrdChgSq(ordChgSq);
  1455. // Withdraw remianGoodsInfo = withdrawDao.getRemainGoodsInfo(searchParam);
  1456. //
  1457. // if (remianGoodsInfo.getRealOrdAmt() < buyLimitAmt) {
  1458. // Collection<Withdraw> remainOrderDetailList = withdrawDao.getWithdrawRemainOrderDetailList(searchParam);
  1459. //
  1460. // for (Withdraw orderDetail : remainOrderDetailList) {
  1461. // // 기존 정산 취소
  1462. // Withdraw paramCancelUsac = new Withdraw();
  1463. // paramCancelUsac.setUsacGb(UsacGb.PURCHASE_RETURN.value());
  1464. // paramCancelUsac.setPrtnGb("40"); // 해택할인취소 PurchaseReturnGb.CANCEL.value() 명칭 필요할 듯
  1465. // paramCancelUsac.setOrdDtlNo(orderDetail.getOrdDtlNo());
  1466. // paramCancelUsac.setOrgUsacGb(UsacGb.SELL.value());
  1467. // paramCancelUsac.setUsacQty(orderDetail.getOrdQty());
  1468. // paramCancelUsac.setGoodsCpnDcAmt(orderDetail.getGoodsCpnDcAmt());
  1469. // paramCancelUsac.setCartCpnDcAmt(orderDetail.getCartCpnDcAmt());
  1470. // paramCancelUsac.setPlusCpnDcAmt(orderDetail.getPlusCpnDcAmt());
  1471. // paramCancelUsac.setPntDcAmt(orderDetail.getPntDcAmt());
  1472. // paramCancelUsac.setPrePntDcAmt(orderDetail.getPrePntDcAmt());
  1473. // paramCancelUsac.setRegId(userId);
  1474. // paramCancelUsac.setPlusCpnDcAmt(orderDetail.getPlusCpnDcAmt());
  1475. // withdrawDao.createWithdrawUsac(paramCancelUsac);
  1476. //
  1477. // refundCancelCartCpnAmt += orderDetail.getCartCpnDcAmt();
  1478. // orderDetail.setRealOrdAmt(orderDetail.getRealOrdAmt() + orderDetail.getCartCpnDcAmt());
  1479. // orderDetail.setCartCpnDcAmt(0);
  1480. // orderDetail.setCartCpnSq(null);
  1481. // orderDetail.setUpdId(userId);
  1482. // orderDetail.setRegId(userId);
  1483. // withdrawDao.updateWithdrawOrderDetailInfo(orderDetail);
  1484. // withdrawDao.createWithdrawOrderDetailHstInfo(orderDetail);
  1485. //
  1486. // // 재정산
  1487. // Withdraw paramUsac = new Withdraw();
  1488. // paramUsac.setUsacGb(UsacGb.SELL.value());
  1489. // paramUsac.setPrtnGb(null);
  1490. // paramUsac.setOrdDtlNo(orderDetail.getOrdDtlNo());
  1491. // paramUsac.setOrgUsacGb(UsacGb.SELL.value());
  1492. // paramUsac.setUsacQty(orderDetail.getOrdQty());
  1493. // paramUsac.setGoodsCpnDcAmt(orderDetail.getGoodsCpnDcAmt());
  1494. // paramUsac.setCartCpnDcAmt(orderDetail.getCartCpnDcAmt());
  1495. // paramUsac.setPlusCpnDcAmt(orderDetail.getPlusCpnDcAmt());
  1496. // paramUsac.setPntDcAmt(orderDetail.getPntDcAmt());
  1497. // paramUsac.setPrePntDcAmt(orderDetail.getPrePntDcAmt());
  1498. // paramUsac.setPlusCpnDcAmt(orderDetail.getPlusCpnDcAmt());
  1499. // paramUsac.setRegId(userId);
  1500. // withdrawDao.createWithdrawUsac(paramUsac);
  1501. // }
  1502. // }
  1503. //
  1504. // return refundCancelCartCpnAmt;
  1505. // }
  1506. /**
  1507. * 환불관리 - 주문번호 전체 금액
  1508. *
  1509. * @param ordNo
  1510. * @return
  1511. * @author moon
  1512. * @since 2020. 11. 16
  1513. */
  1514. public Withdraw getOrderDetailSumAmt(String ordNo) {
  1515. return withdrawDao.getOrderDetailSumAmt(ordNo);
  1516. }
  1517. /**
  1518. * 환불목록
  1519. *
  1520. * @param withdraw
  1521. * @return Withdraw List
  1522. * @author yujung
  1523. * @since 2020. 05. 29
  1524. */
  1525. // public Collection<Withdraw> getRefundCompleteList(Withdraw withdraw) {
  1526. // return withdrawDao.getRefundCompleteList(withdraw);
  1527. // }
  1528. /**
  1529. * 반품신청, 회수수량 비교 데이터
  1530. *
  1531. * @param withdraw
  1532. * @return Withdraw
  1533. * @author moon
  1534. * @since 2020. 11. 16
  1535. */
  1536. public Withdraw getSumChgQtyWdQty(Withdraw withdraw) {
  1537. return withdrawDao.getSumChgQtyWdQty(withdraw);
  1538. }
  1539. /**
  1540. * wms 회수요청
  1541. *
  1542. * @param
  1543. * @return
  1544. * @author cjs
  1545. * @since 2020. 07. 14
  1546. */
  1547. // @Transactional("wmsTxnManager")
  1548. // public void saveWmsWithdrawRequest(TsaOrder order) {
  1549. //
  1550. // String userId = TsaSession.getInfo().getUserId();
  1551. //
  1552. // String reqSn = wmsWithdrawDao.getRequestSn();
  1553. // order.setSeq(reqSn);
  1554. //
  1555. // order.setInvoiceNo("123412341");
  1556. // order.setOrdChgSq(3);
  1557. // order.setRecipNm("반품자");
  1558. // order.setRecipTelno("010-111-1111");
  1559. // order.setRecipPhnno("010-2222-2222");
  1560. // order.setRecipPostNo("12345");
  1561. // order.setRecipBaseAddr("서울시 강남구 논현로 323");
  1562. // order.setRecipDtlAddr("MTU 빌딩 6층 전산실");
  1563. // order.setChgMemo("사이즈가 작아요");
  1564. // order.setChgerRtnMemo("물류메모");
  1565. // order.setChgGb("40");
  1566. // order.setChgReason("13");
  1567. // order.setRegDt("20200505121212");
  1568. // order.setChgQty(1);
  1569. // order.setChgRegDt("20200505121212");
  1570. // order.setChgerNm("변경자");
  1571. // if (order.getSellStoreCd() == null || order.getSellStoreCd().isEmpty()) {
  1572. // order.setSellStoreCd("PASTEL");
  1573. // }
  1574. // order.setOrdDtlNos(order.getOrdDtlNo());
  1575. // order.setChgQtys(Integer.toString(order.getChgQty()));
  1576. //
  1577. // /* 1.회수요청 Header 등록 */
  1578. // wmsWithdrawDao.createWithdrawHeader(order);
  1579. //
  1580. // /* 2.회수요청 Detail 등록 */
  1581. // int cnt = 0;
  1582. // order.setChgStat(TsaConstants.OrderChangeStat.RETURN.value());
  1583. // String[] ordDtlNoArr = order.getOrdDtlNos().split(",");
  1584. // String[] chgQtyArr = order.getChgQtys().split(",");
  1585. //
  1586. // for (String ordDtlNo : ordDtlNoArr) {
  1587. // if (!StringUtils.isBlank(ordDtlNo)) {
  1588. // order.setOrdDtlNo(ordDtlNo);
  1589. // order.setChgQty(Integer.parseInt(chgQtyArr[cnt]));
  1590. // wmsWithdrawDao.createWithdrawDetail(order);
  1591. // }
  1592. // cnt++;
  1593. // }
  1594. // }
  1595. }