Przeglądaj źródła

이태영 - 20210423 KCP 상품권 현금영수증 취소 로직 개발 중

xodud1202 5 lat temu
rodzic
commit
cc900be036

+ 17 - 0
src/main/java/com/style24/core/biz/dao/TscOrderDao.java

@@ -5,6 +5,7 @@ import java.util.Collection;
 import org.apache.ibatis.session.ResultHandler;
 
 import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.GiftCard;
 import com.style24.persistence.domain.Order;
 import com.style24.persistence.domain.Payment;
 
@@ -751,4 +752,20 @@ public interface TscOrderDao {
 	 * @since 2021. 04. 22
 	 */
 	int updateOrderDetailItemStat(Order order);
+
+	/**
+	 * 상품권 현금영수증 API 연동 결과 등록
+	 * @param param
+	 * @author xodud1202
+	 * @since 2021.04.23
+	 */
+	void createGiftcartReceiptApi(GiftCard param);
+
+	/**
+	 * 상품권 현금영수증 금액 수정
+	 * @param param
+	 * @author xodud1202
+	 * @since 2021.04.23
+	 */
+	void updateGiftCardReceipt(GiftCard para);
 }

+ 75 - 0
src/main/java/com/style24/core/biz/service/TscKcpService.java

@@ -16,6 +16,7 @@ import com.kcp.J_PP_CLI_N;
 import com.style24.core.biz.dao.TscOrderDao;
 import com.style24.core.support.env.TscConstants;
 import com.style24.persistence.domain.CustAccount;
+import com.style24.persistence.domain.GiftCard;
 import com.style24.persistence.domain.Order;
 import com.style24.persistence.domain.Payment;
 
@@ -415,4 +416,78 @@ public class TscKcpService {
 		return result;
 	}
 
+	/**
+	 * KCP 현금영수증 취소 신청 API
+	 * param.setModType("STSQ");				// 요청 구분 (STSQ : 조회, STSC : 전체취소, STPC : 부분취소) >> 조회는 사용 안함 > result 안받음. 사용시 result 추가활것.
+	 * param.setTradeNo("20210423066396");		// 현금영수증 거래번호 (TB_GIFTCARD_RECEIPT.TRADE_NO)
+	 * param.setTradeTime("20210422200347");	// 결제시각 : YYYYMMDDHH24MISS 형식
+	 * param.setOrdNo(100);						// 주문번호
+	 *
+	 * * 부분취소시 추가 금액
+	 * param.setRmGfcdAmt(10000);		// 잔여금액 (부분취소 이전에 남은 금액)
+	 * param.setUsGfcdAmt(3000);		// 부분취소 요청 금액
+	 *
+	 * @param GiftCard
+	 * @author xodud1202
+	 * @since 2021. 04. 23
+	 */
+	@Transactional("shopTxnManager")
+	public GiftCard kcpCashReceiptCancel(GiftCard param) {
+		GiftCard result = new GiftCard();
+		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
+		String cust_ip = request.getRemoteAddr();
+		String reqTx = "mod";		// 현금영수증 취소 or 조회 요청
+		String txCd = "07030000";	// 현금영수증 조회 요청
+
+		J_PP_CLI_N c_PayPlus = new J_PP_CLI_N();
+		c_PayPlus.mf_init( "", env.getProperty("pg.kcp.gw.url"), env.getProperty("pg.kcp.gw.port"), Integer.parseInt(env.getProperty("pg.kcp.tx.mode")), env.getProperty("pg.kcp.log.dir"));
+		c_PayPlus.mf_init_set();
+
+		int     mod_data_set_no ;
+
+		mod_data_set_no = c_PayPlus.mf_add_set( "mod_data" ) ;
+
+		// 요청 구분
+		if("STSQ".equals(param.getModType())) {
+			txCd = "07030000" ;     // 조회 요청
+		} else {
+			txCd = "07020000" ;     // 취소 요청
+		}
+
+		// 부분 취소
+		if("STPC".equals(param.getModType())) {
+			c_PayPlus.mf_set_us( mod_data_set_no, "mod_mny"  , String.valueOf(param.getUsGfcdAmt()));	// 부분취소 요청 금액
+			c_PayPlus.mf_set_us( mod_data_set_no, "rem_mny"  , String.valueOf(param.getRmGfcdAmt()));	// 잔여금액 (부분취소 이전에 남은 금액)
+		}
+
+		c_PayPlus.mf_set_us( mod_data_set_no, "mod_type"  , param.getModType()) ;
+		c_PayPlus.mf_set_us( mod_data_set_no, "mod_value" , param.getTradeNo()) ;
+		c_PayPlus.mf_set_us( mod_data_set_no, "mod_gubn"  , "MG01"  ) ;
+		c_PayPlus.mf_set_us( mod_data_set_no, "trad_time" , param.getTradeTime()) ;
+
+		// 실행
+		c_PayPlus.mf_do_tx(env.getProperty("pg.kcp.site.cd"), "", txCd, cust_ip, String.valueOf(param.getOrdNo()), env.getProperty("pg.kcp.log.level"), "0");
+
+		log.info("CHECK CASH MOD RESULT ::::: {}", c_PayPlus.getRecvObj().toString());
+
+		// 결과
+		result.setResultCd(c_PayPlus.m_res_cd);
+		result.setResultMsg(c_PayPlus.m_res_msg);
+		result.setOrdNo(param.getOrdNo());
+		result.setUsGfcdAmt(-param.getUsGfcdAmt());
+		if(!"STSQ".equals(param.getModType())) {
+			if ("0000".equals(result.getResultCd())) {
+				result.setTradeNo(c_PayPlus.mf_get_res("cash_no"));
+				result.setAuthNo(c_PayPlus.mf_get_res("receipt_no"));
+
+				// 성공시 TB_GIFTCARD_RECEIPT AMT UPDATE
+				orderDao.updateGiftCardReceipt(result);
+			}
+
+			// 성공이든 실패이든 로그성 데이터 TB_GIFTCARD_RECEIPT_API INSERT
+			orderDao.createGiftcartReceiptApi(result);
+		}
+
+		return result;
+	}
 }

+ 1 - 0
src/main/java/com/style24/persistence/domain/GiftCard.java

@@ -60,4 +60,5 @@ public class GiftCard extends TscBaseDomain {
 	private String ordPhnno;		// 주문자휴대폰번호
 	private String ordNm;			// 주문자명
 	private String ordEmail;		// 주문자 E-Mail
+	private String modType;			// 요청 구분 (STSQ : 조회, STSC : 전체취소, STPC : 부분취소)
 }

+ 30 - 0
src/main/java/com/style24/persistence/mybatis/shop/TscOrder.xml

@@ -3588,6 +3588,36 @@
 		AND    ORD_DTL_NO = #{ordDtlNo}
 	</update>
 
+	<!-- 상품권 현금영수증 정보 등록 API 결과 -->
+	<insert id="createGiftcartReceiptApi" parameterType="GiftCard">
+		/* TsfOrder.createGiftcartReceiptApi : 상품권 현금영수증 정보 등록 */
+		INSERT INTO TB_GIFTCARD_RECEIPT_API (
+			  ORD_NO
+			, TRADE_NO
+			, AUTH_NO
+			, AMT
+			, RESULT_CD
+			, RESULT_MSG
+			, REG_DT
+		) VALUES (
+			  #{ordNo}
+			, #{tradeNo}
+			, #{authNo}
+			, #{usGfcdAmt}
+			, #{resultCd}
+			, #{resultMsg}
+			, NOW()
+		)
+	</insert>
+
+	<!-- 사은품 현금영수증 금액 금액 수정 -->
+	<update id="updateGiftCardReceipt" parameterType="GiftCard">
+		/* TscOrder.updateGiftCardReceipt : 사은품 현금영수증 금액 금액 수정 */
+		UPDATE TB_GIFTCARD_RECEIPT SET
+		       AMT = AMT + #{usGfcdAmt}
+		     , UPD_DT = NOW()
+		WHERE  ORD_NO = #{ordNo}
+	</update>
 </mapper>