|
|
@@ -7,6 +7,7 @@ import java.util.List;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
|
+import com.gagaframework.web.util.GagaDateUtil;
|
|
|
import com.style24.persistence.domain.CustGrade;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -689,6 +690,8 @@ public class TsfCustomerService {
|
|
|
GagaMap resultMap = new GagaMap();
|
|
|
customer.setRegNo(customer.getCustNo());
|
|
|
customer.setUpdNo(customer.getCustNo());
|
|
|
+ customer.setHypenCellPhone();
|
|
|
+ customer.encryptData();
|
|
|
boolean isSuccess = false;
|
|
|
// CI 유효성 체크
|
|
|
Customer custInfo = getCustomerFindByCi(customer.getCi());
|
|
|
@@ -990,37 +993,58 @@ public class TsfCustomerService {
|
|
|
* 정책 등급쿠폰 발급
|
|
|
*
|
|
|
* @param custGrade - 고객번호
|
|
|
- * @return CustGrade
|
|
|
+ * @return boolean - true : 모두 다운/ false 이미 쿠폰 다운
|
|
|
* @author jsshin
|
|
|
* @since 2021. 04. 06
|
|
|
*/
|
|
|
- public GagaMap downloadCustGradeCoupon(Integer custNo) {
|
|
|
- GagaMap result = new GagaMap();
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public boolean downloadCustGradeCoupon(Integer custNo) {
|
|
|
+ // 1. 고객정보 조회
|
|
|
Customer custInfo = getCustomerFindByCustNo(custNo);
|
|
|
+
|
|
|
+ // 2. 등급쿠폰 조회
|
|
|
CustGrade params = new CustGrade();
|
|
|
params.setCustNo(custInfo.getCustNo());
|
|
|
params.setSiteCd(custInfo.getSiteCd());
|
|
|
params.setGradeCd(custInfo.getCustGrade());
|
|
|
List<CustGrade> custGradeCollection = (List<CustGrade>)customerDao.getCustGradePolicy(params);
|
|
|
- CustGrade custGrade = custGradeCollection.get(0);
|
|
|
-
|
|
|
- // WELCOME 등급 첫 번째 쿠폰은 회원가입시 쿠폰
|
|
|
- if (TscConstants.CustGrade.WELCOME.value().equals(custGrade.getGradeCd())) {
|
|
|
- custGrade.setGradeCpnId1("");
|
|
|
- // 1. 회원등급 정책 쿠폰1, 쿠폰2 발급
|
|
|
- int gradeCpn1 = couponService.saveCustGradeCoupon(custGrade.getGradeCpnId1());
|
|
|
- int gradeCpn2 = couponService.saveCustGradeCoupon(custGrade.getGradeCpnId2());
|
|
|
-
|
|
|
- // 2. 생일쿠폰 발급
|
|
|
- int birthCpn = 0;
|
|
|
- if (StringUtils.isNotBlank(custInfo.getBirthYmd()) && custInfo.getBirthYmd().length() > 7) {
|
|
|
- birthCpn = couponService.saveCustBirthDayCoupon(custGrade.getGradeCpnId3());
|
|
|
- }
|
|
|
- result.setInt("gradeCpn1", gradeCpn1);
|
|
|
- result.setInt("gradeCpn2", gradeCpn2);
|
|
|
- result.setInt("birthCpn", birthCpn);
|
|
|
+ CustGrade custGradePolicy = custGradeCollection.get(0);
|
|
|
|
|
|
+ // 3.WELCOME 등급 - 첫번째 쿠폰은 회원 가입시 지급
|
|
|
+ if (TscConstants.CustGrade.WELCOME.value().equals(custGradePolicy.getGradeCd())) {
|
|
|
+ custGradePolicy.setGradeCpnId1("0");
|
|
|
}
|
|
|
- return result;
|
|
|
+
|
|
|
+ String frontGb = TsfSession.getFrontGb();
|
|
|
+ // 4. 회원등급 정책 쿠폰1 발급
|
|
|
+ Coupon couponFirst = new Coupon();
|
|
|
+ couponFirst.setCustNo(custNo);
|
|
|
+ couponFirst.setCpnId(Integer.parseInt(custGradePolicy.getGradeCpnId1()));
|
|
|
+ couponFirst.setFrontGb(frontGb);
|
|
|
+ int custGradeCpnFirst = couponService.saveCustGradeCoupon(couponFirst);
|
|
|
+
|
|
|
+ // 5. 회원등급 정책 쿠폰2 발급
|
|
|
+ Coupon couponSecond = new Coupon();
|
|
|
+ couponSecond.setCustNo(custNo);
|
|
|
+ couponSecond.setCpnId(Integer.parseInt(custGradePolicy.getGradeCpnId2()));
|
|
|
+ couponSecond.setFrontGb(frontGb);
|
|
|
+ int custGradeCpnSecond = couponService.saveCustGradeCoupon(couponSecond);
|
|
|
+
|
|
|
+ // 6. 회원등급 정책 쿠폰3 발급(생일쿠폰)
|
|
|
+ int birthCpn = 0;
|
|
|
+ if (StringUtils.isNotBlank(custInfo.getBirthYmd()) && custInfo.getBirthYmd().length() > 7) {
|
|
|
+ String currentMonth = GagaDateUtil.getToday().substring(4, 6);
|
|
|
+ String birthMonth = custInfo.getBirthYmd().substring(4, 6);
|
|
|
+ log.info("currentMonth ===> {}, birthMonth ===> {}", currentMonth, birthMonth);
|
|
|
+ if (currentMonth.equals(birthMonth)) {
|
|
|
+ Coupon couponThird = new Coupon();
|
|
|
+ couponThird.setCustNo(custNo);
|
|
|
+ couponThird.setCpnId(Integer.parseInt(custGradePolicy.getGradeCpnId3()));
|
|
|
+ couponThird.setFrontGb(frontGb);
|
|
|
+ birthCpn = couponService.saveCustGradeCoupon(couponThird);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return custGradeCpnFirst + custGradeCpnSecond + birthCpn > 0;
|
|
|
}
|
|
|
+
|
|
|
}
|