|
|
@@ -11,6 +11,8 @@ import com.style24.persistence.domain.Point;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 포인트 Service
|
|
|
@@ -32,15 +34,45 @@ public class TscPointService {
|
|
|
private TscOrderService orderService;
|
|
|
|
|
|
/**
|
|
|
- * 포인트 적립
|
|
|
+ * 포인트 적립 / 차감
|
|
|
* @param point - 포인트 정보
|
|
|
* @author jsshin
|
|
|
* @since 2021. 01. 27
|
|
|
*/
|
|
|
@Transactional("shopTxnManager")
|
|
|
public void saveCustomerPoint(Point point) {
|
|
|
- pointDao.createCustomerPoint(point);
|
|
|
- pointDao.createCustomerPointHst(point);
|
|
|
+ if ("+".equals(point.getSignGb())) {
|
|
|
+ pointDao.createCustomerPoint(point);
|
|
|
+ pointDao.createCustomerPointHst(point);
|
|
|
+ } else {
|
|
|
+ int sumRmPntAmt = pointDao.getCustomerSumRmPntAmt(point.getCustNo());
|
|
|
+ sumRmPntAmt += point.getRmPntAmt();
|
|
|
+ if (sumRmPntAmt < 0 ) {
|
|
|
+ throw new IllegalStateException("보유 포인트 금액이 차감 포인트 금액 보다 작습니다.");
|
|
|
+ }
|
|
|
+ Collection<Point> rmPntAmtList = pointDao.getCustomerRmPntAmtList(point.getCustNo());
|
|
|
+ int rmPntAmt = point.getRmPntAmt() * -1; // 차감금액 : -1000 * -1
|
|
|
+ for (Point rmPntAmtInfo: rmPntAmtList) {
|
|
|
+ if (rmPntAmt > 0 ) {
|
|
|
+ if (rmPntAmt < rmPntAmtInfo.getRmPntAmt()) {
|
|
|
+ rmPntAmtInfo.setPntAmt(rmPntAmt * -1);
|
|
|
+ rmPntAmt -= rmPntAmt;
|
|
|
+ } else {
|
|
|
+ rmPntAmtInfo.setPntAmt(rmPntAmtInfo.getRmPntAmt() * -1);
|
|
|
+ rmPntAmt -= rmPntAmtInfo.getRmPntAmt();
|
|
|
+ }
|
|
|
+ rmPntAmtInfo.setCustNo(point.getCustNo());
|
|
|
+ rmPntAmtInfo.setOccurGb(point.getOccurGb());
|
|
|
+ rmPntAmtInfo.setPntUploadStat(point.getPntUploadStat());
|
|
|
+ rmPntAmtInfo.setOccurDtlDesc(point.getOccurDtlDesc());
|
|
|
+ rmPntAmtInfo.setRegNo(point.getRegNo());
|
|
|
+ rmPntAmtInfo.setUpdNo(point.getUpdNo());
|
|
|
+ pointDao.createCustomerPointHst(rmPntAmtInfo);
|
|
|
+ pointDao.updatePointDeduction(rmPntAmtInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -106,4 +138,15 @@ public class TscPointService {
|
|
|
return pointDao.getOrderDecisionPointHstCount(point);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 가용 포인트
|
|
|
+ * @param custNo - 고객번호
|
|
|
+ * @return int - 가용포인트 합
|
|
|
+ * @author jsshin
|
|
|
+ * @since 2021. 06. 14
|
|
|
+ */
|
|
|
+ public int getCustomerSumRmPntAmt(Integer custNo) {
|
|
|
+ return pointDao.getCustomerSumRmPntAmt(custNo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|