Browse Source

Merge branch 'develop' into bin2107

bin2107 5 năm trước cách đây
mục cha
commit
0d7ca9fa61

+ 96 - 0
src/main/java/com/style24/core/biz/service/TscKakaoPayService.java

@@ -0,0 +1,96 @@
+package com.style24.core.biz.service;
+
+import java.net.URI;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.util.GagaFileUtil;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.style24.core.biz.dao.TscPointDao;
+import com.style24.persistence.domain.Order;
+import com.style24.persistence.domain.Point;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 카카오페이 Service
+ * 
+ * @author card007
+ * @since 2020. 03. 03
+ */
+@Service
+@Slf4j
+public class TscKakaoPayService {
+
+	@Autowired
+	private Environment env;
+
+	@Autowired
+	private RestTemplate restTemplate;
+
+	public static final String PROTOCOL = "http:";
+
+	/**
+	 * 카카오페이 결제준비 처리
+	 * 
+	 * @param Order
+	 * @return GagaMap
+	 * @author card007
+	 * @since 2021. 03. 03
+	 */
+	@Transactional("shopTxnManager")
+	public GagaMap kakaoPaymentReady(Order order) {
+		GagaMap map = new GagaMap();
+		String paymentReadyUrl = env.getProperty("kakao.paymentReadyUrl");
+		try {
+			MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+			params.add("cid", env.getProperty("kakao.cid"));
+			params.add("partner_order_id", order.getOrdNo()+"");
+			params.add("partner_user_id", order.getCustNo()+"");
+			params.add("item_name", order.getGoodsNm());
+			params.add("quantity", order.getOrdQty()+"");
+			params.add("total_amount", order.getRealOrdAmt()+"");
+			params.add("tax_free_amount", "0");
+			params.add("approval_url", PROTOCOL + env.getProperty("domain.front"));
+			params.add("fail_url", PROTOCOL + env.getProperty("domain.front"));
+			params.add("cancel_url", PROTOCOL + env.getProperty("domain.front"));
+
+			// Header
+			HttpHeaders headers = new HttpHeaders();
+			headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+			headers.set("Authorization", "KakaoAK " + env.getProperty("kakao.adminKey"));
+
+			HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
+			URI url = URI.create(paymentReadyUrl);
+
+			// POST방식으로 호출
+			ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
+			log.info("responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
+
+			String jsonResult = responseEntity.getBody();
+			log.info("responseEntity.getBody(): {} ", jsonResult);
+
+			Gson gson = new GsonBuilder().create();
+			map = gson.fromJson(jsonResult, GagaMap.class); //access_token, refresh_token
+
+		} catch (Exception e) {
+			log.error(e.getMessage());
+		}
+		
+		return map;
+	}
+	
+}

+ 43 - 10
src/main/java/com/style24/core/biz/service/TscOrderService.java

@@ -844,6 +844,28 @@ public class TscOrderService {
 		return cartApplyCpnList;
 	}
 	
+	/**
+	 * 배송비쿠폰단위 상품 등록 
+	 *
+	 * @param Order
+	 * @author jsh77b
+	 * @since 2021. 02. 02
+	 */
+	public Collection<Order> getDelvCpnApplyList(Collection<Order> delvFeeCdList, Collection<Order> delvCpnAllList) {
+		
+		// 배송비가 있으면 배소업체코드, 배송비 배송비쿠폰에 설정
+		for (Order delvCpn : delvCpnAllList) {
+			for (Order delvFeeCd : delvFeeCdList) {
+				if (delvFeeCd.getDelvFee() > 0) {
+					delvCpn.setCpnDcAmt(delvFeeCd.getDelvFee());
+					delvCpn.setDelvFeeCd(delvFeeCd.getDelvFeeCd());
+				}
+			}
+		}
+		
+		return delvCpnAllList;
+	}
+	
 	// 쿠폰할인금액이 높은순으로 정렬 함수
 	private List<Order> getListSort(List<Order> goodsCpnList) {
 		int cnt 			= 0;
@@ -905,24 +927,34 @@ public class TscOrderService {
 		
 		GagaMap resultMap = new GagaMap();
 		
-		int prePntDcAmt 	= 0;
-		int goodsSumAmt 	= 0;
+		int orgGoodsSumAmt	= 0;
+		int currGoodsSumAmt	= 0;
 		int tmtbDcSumAmt 	= 0;
-		
+		int cpn1DcSumAmt	= 0;
+		int prePntDcAmt 	= 0;
+		int savePntSumAmt 	= 0;
+
 		// 상품금액, 배송비, 할인금액, 다다익선할인금액, 쿠폰할인금액, 선포인트사용, 포인트사용, 상품권사용
 		for (Order tmtbGoodsApply : tmtbGoodsApplyList) {
-			prePntDcAmt 	= prePntDcAmt + tmtbGoodsApply.getPrePntDcAmt();
-			goodsSumAmt 	= goodsSumAmt + ((tmtbGoodsApply.getCurrPrice() + tmtbGoodsApply.getOptAddPrice()) * tmtbGoodsApply.getGoodsQty());
-
+			orgGoodsSumAmt 		= orgGoodsSumAmt + ((tmtbGoodsApply.getOrgCurrPrice() + tmtbGoodsApply.getOptAddPrice()) * tmtbGoodsApply.getGoodsQty());	// 상품가
+			currGoodsSumAmt 	= currGoodsSumAmt + ((tmtbGoodsApply.getCurrPrice() + tmtbGoodsApply.getOptAddPrice()) * tmtbGoodsApply.getGoodsQty());		// 즉시할인상품가
+			cpn1DcSumAmt		= cpn1DcSumAmt + (orgGoodsSumAmt - currGoodsSumAmt);																		// 즉시할인금액
+			savePntSumAmt		= savePntSumAmt + tmtbGoodsApply.getSavePntAmt();																			// 적립에정포인트
+			
 			// 다다익선 할인금액이 있을때 적용
 			if (tmtbGoodsApply.getTmtbDcAmt() > 0) {
 				tmtbDcSumAmt = tmtbDcSumAmt + (((tmtbGoodsApply.getCurrPrice() + tmtbGoodsApply.getOptAddPrice()) * tmtbGoodsApply.getGoodsQty()) - tmtbGoodsApply.getTmtbDcAmt());
 			}
+			
+			// 선포인트 사용가능 금액
+			prePntDcAmt 		= prePntDcAmt + tmtbGoodsApply.getPrePntDcAmt();
 		}
 
-		resultMap.set("prePntDcAmt"		, prePntDcAmt);
-		resultMap.set("goodsSumAmt"		, goodsSumAmt);
-		resultMap.set("tmtbDcSumAmt"	, tmtbDcSumAmt);
+		resultMap.set("orgGoodsSumAmt"		, orgGoodsSumAmt);
+		resultMap.set("cpn1DcSumAmt"		, cpn1DcSumAmt);
+		resultMap.set("tmtbDcSumAmt"		, tmtbDcSumAmt);
+		resultMap.set("prePntDcAmt"			, prePntDcAmt);
+		resultMap.set("savePntSumAmt"		, savePntSumAmt);
 		
 		return resultMap;
 	}
@@ -1080,7 +1112,8 @@ public class TscOrderService {
 		resultMap.set("delvAllCartList"		, delvAllCartList);		// 전체배송목록 sort
 		resultMap.set("delvCartList"		, delvCartList);		// 입점업체상품목록
 		resultMap.set("sumDelvFee"			, sumDelvFee);			// 배송비합계
-				
+		resultMap.set("delvFeeCdList"		, delvFeeCdList);		// 배송업체목록
+		
 		return resultMap;
 	}
 	

+ 2 - 1
src/main/java/com/style24/persistence/mybatis/shop/TscOrder.xml

@@ -1813,7 +1813,8 @@
 		  FROM TB_CUST_POINT CP
 		 WHERE 1=1
 		   AND CP.CUST_NO = #{custNo}
-		   AND CP.EXP_BE_DT <![CDATA[>]]> NOW()
+		   AND CP.EXP_BE_DT <![CDATA[<]]> NOW()
+		   AND CP.EXP_CMP_DT <![CDATA[>=]]> NOW()
 	</select>
 	
 	<!-- 상품권정보 조회 -->