|
|
@@ -12,10 +12,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.gagaframework.web.util.GagaDateUtil;
|
|
|
import com.gagaframework.web.util.GagaFileUtil;
|
|
|
+import com.style24.core.biz.dao.TscPointDao;
|
|
|
+import com.style24.core.biz.service.TscEnvsetService;
|
|
|
+import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.front.biz.dao.TsfReviewDao;
|
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
|
import com.style24.persistence.domain.Goods;
|
|
|
import com.style24.persistence.domain.Plan;
|
|
|
+import com.style24.persistence.domain.Point;
|
|
|
import com.style24.persistence.domain.Review;
|
|
|
import com.style24.persistence.domain.ReviewAttach;
|
|
|
|
|
|
@@ -34,8 +38,15 @@ public class TsfReviewService {
|
|
|
@Autowired
|
|
|
private TsfReviewDao reviewDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TscPointDao pointDao;
|
|
|
+
|
|
|
+
|
|
|
@Autowired
|
|
|
private Environment env;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TscEnvsetService envsetService;
|
|
|
|
|
|
/**
|
|
|
* 상품 리뷰 목록 건수
|
|
|
@@ -162,12 +173,19 @@ public class TsfReviewService {
|
|
|
review.setDispYn("Y");
|
|
|
review.setDelYn("N");
|
|
|
review.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
- review.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
+ review.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
+ if (review.getKufKeyArr() == null && review.getOrgFileNmArr() == null) {
|
|
|
+ review.setPntGiveStat("G043_30");
|
|
|
+ }else if(review.getKufKeyArr() == null && review.getOrgFileNmArr() != null) {
|
|
|
+ review.setPntGiveStat("G043_30");
|
|
|
+ }else {
|
|
|
+ review.setPntGiveStat("G043_10");
|
|
|
+ }
|
|
|
reviewDao.saveMypageReview(review);
|
|
|
|
|
|
//이미지등록
|
|
|
- ReviewAttach fileReview = new ReviewAttach();
|
|
|
- if(!StringUtils.isAllEmpty(review.getOrgFileNmArr())) {
|
|
|
+ if(review.getOrgFileNmArr() != null) {
|
|
|
+ ReviewAttach fileReview = new ReviewAttach();
|
|
|
fileReview.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
fileReview.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
fileReview.setReviewSq(review.getReviewSq());
|
|
|
@@ -200,6 +218,125 @@ public class TsfReviewService {
|
|
|
ind++;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(review.getKufKeyArr() != null) {
|
|
|
+ ReviewAttach fileReview = new ReviewAttach();
|
|
|
+ fileReview.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
+ fileReview.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
+ fileReview.setReviewSq(review.getReviewSq());
|
|
|
+ fileReview.setFileGb("M");
|
|
|
+ fileReview.setDelYn("N");
|
|
|
+ String[] fileItemVal1 = review.getKufKeyArr();
|
|
|
+ for (int j = 0; j < fileItemVal1.length; j++) {
|
|
|
+ fileReview.setKufKey(fileItemVal1[j]);
|
|
|
+ reviewDao.saveReviewAttach(fileReview);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = reviewDao.getReviewPointGiveCount(review);
|
|
|
+ // 포인트 지급해 준 적 없을때 만 지급
|
|
|
+ if (count == 0) {
|
|
|
+ int textReviewPnt = envsetService.getTextReviewPoint(TscConstants.Site.STYLE24.value());
|
|
|
+ int photoReviewPnt = envsetService.getPhotoReviewPoint(TscConstants.Site.STYLE24.value());
|
|
|
+
|
|
|
+ Point point = new Point();
|
|
|
+ point.setCustNo(TsfSession.getInfo().getCustNo());
|
|
|
+ point.setOccurGb(TscConstants.PointOccurGb.REVIEW_POINT.value());
|
|
|
+ point.setOccurDtlDesc("상품평포인트 지급");
|
|
|
+ point.setPntUploadStat(TscConstants.PntUploadStat.APPLY_COMPLETE.value());
|
|
|
+ point.setOrdNo(review.getOrdNo());
|
|
|
+ point.setOrdDtlNo(review.getOrdDtlNo());
|
|
|
+ if (review.getKufKeyArr() == null && review.getOrgFileNmArr() == null) {
|
|
|
+ // 상품평만 적었을 경우
|
|
|
+ point.setGvPntAmt(textReviewPnt);
|
|
|
+ point.setRmPntAmt(textReviewPnt);
|
|
|
+ reviewDao.createReviewPoint(point);
|
|
|
+ point.setPntAmt(textReviewPnt);
|
|
|
+ point.setReviewSq(review.getReviewSq());
|
|
|
+ reviewDao.createReviewPointHst(point);
|
|
|
+ }else if(review.getKufKeyArr() == null && review.getOrgFileNmArr() != null) {
|
|
|
+ // 상품평 + 사진
|
|
|
+ point.setCustNo(TsfSession.getInfo().getCustNo());
|
|
|
+ point.setGvPntAmt(photoReviewPnt);
|
|
|
+ point.setRmPntAmt(photoReviewPnt);
|
|
|
+ reviewDao.createReviewPoint(point);
|
|
|
+ point.setPntAmt(photoReviewPnt);
|
|
|
+ point.setReviewSq(review.getReviewSq());
|
|
|
+ reviewDao.createReviewPointHst(point);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 마이페이지 리뷰 업데이트
|
|
|
+ * @param review
|
|
|
+ * @return
|
|
|
+ * @author sowon
|
|
|
+ * @since 2021. 3. 25
|
|
|
+ */
|
|
|
+ public void updateMypageReview(Review review) {
|
|
|
+ review.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
+ review.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
+ reviewDao.updateMypageReview(review);
|
|
|
+ reviewDao.reviewAttachDelete(review);
|
|
|
+
|
|
|
+ //이미지등록
|
|
|
+ if(!StringUtils.isAllEmpty(review.getOrgFileNmArr())) {
|
|
|
+ ReviewAttach fileReview = new ReviewAttach();
|
|
|
+ fileReview.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
+ fileReview.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
+ fileReview.setReviewSq(review.getReviewSq());
|
|
|
+ fileReview.setFileGb("I");
|
|
|
+ fileReview.setDelYn("N");
|
|
|
+ //파일아이템 등록
|
|
|
+ String[] fileItemVal1 = review.getOrgFileNmArr();
|
|
|
+ int ind = 1;
|
|
|
+ for (int j = 0; j < fileItemVal1.length; j++) {
|
|
|
+ String imgInd = String.valueOf(ind);
|
|
|
+ if (ind < 10) {
|
|
|
+ imgInd = "0" + imgInd;
|
|
|
+ }
|
|
|
+ if (!fileItemVal1[j].contains("REVIEW_")) {
|
|
|
+ String planUploadPath = env.getProperty("upload.default.target.path");
|
|
|
+ String yearMonth = GagaDateUtil.getToday().substring(0, 6);
|
|
|
+ planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, "/review");
|
|
|
+ File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, fileItemVal1[j]));
|
|
|
+ planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
|
|
|
+ String newFilename = "REVIEW_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + org.springframework.util.StringUtils.getFilenameExtension(fileItemVal1[j]);
|
|
|
+ File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(planUploadPath, newFilename)));
|
|
|
+ // Rename a file
|
|
|
+ File path = new File(planUploadPath);
|
|
|
+ if (!path.exists()) {
|
|
|
+ path.mkdir();
|
|
|
+ }
|
|
|
+ newFile.renameTo(uniqueFile);
|
|
|
+ fileReview.setOrgFileNm("/review/" + yearMonth + "/" + newFilename);
|
|
|
+ fileReview.setSysFileNm("/review/" + yearMonth + "/" + newFilename);
|
|
|
+ reviewDao.saveReviewAttach(fileReview);
|
|
|
+ }else {
|
|
|
+ fileReview.setOrgFileNm(fileItemVal1[j]);
|
|
|
+ fileReview.setSysFileNm(fileItemVal1[j]);
|
|
|
+ reviewDao.saveReviewAttach(fileReview);
|
|
|
+ }
|
|
|
+
|
|
|
+ ind++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.isAllEmpty(review.getKufKeyArr())) {
|
|
|
+ ReviewAttach fileReview = new ReviewAttach();
|
|
|
+ fileReview.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
+ fileReview.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
+ fileReview.setReviewSq(review.getReviewSq());
|
|
|
+ fileReview.setFileGb("M");
|
|
|
+ fileReview.setDelYn("N");
|
|
|
+ String[] fileItemVal1 = review.getKufKeyArr();
|
|
|
+ for (int j = 0; j < fileItemVal1.length; j++) {
|
|
|
+ fileReview.setKufKey(fileItemVal1[j]);
|
|
|
+ reviewDao.saveReviewAttach(fileReview);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -296,6 +433,17 @@ public class TsfReviewService {
|
|
|
reviewDao.reviewCustomerConfirm(review);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 리뷰 포인트 지급 확인
|
|
|
+ * @param review
|
|
|
+ * @return
|
|
|
+ * @author sowon
|
|
|
+ * @since 2021. 4. 28
|
|
|
+ */
|
|
|
+
|
|
|
+ public int getReviewPointGiveCount(Review review) {
|
|
|
+ return reviewDao.getReviewPointGiveCount(review);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|