public PaymentGEPPaymentProcessResultT PaymentExecuteOrder( PaymentOrderMultiParamT orderParam , PaymentOrderMultiParamEtcT orderParamEtc , PaymentInfoCheckT payMethodtInfo , List<PaymentDataOrderInfoT> paymentDataOrderInfoList , List<PaymentDataCostBasisInfoT> paymentDataCostBasisInfoList , List<PaymentOrderItemCostInfoT> paymentOrderItemCostInfoList) { PaymentGEPPaymentProcessResultT orderResult = new PaymentGEPPaymentProcessResultT(); PaymentProcessQueryBiz biz = new PaymentProcessQueryBiz(); orderResult.Result = new GEPBaseResultT(); string acntNo = string.Empty; string cashpayWay = "M"; int affectedRowCount = 0; #region 미리 처리할 것들 #endregion #region 주문 중 수량 입력 try { biz.UpdatePaymentOrderCountToOrderBufSell(orderParam.PackNo); } catch { throw new PaymentProcessBizException(-742, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 결제 수단 처리 // 현금 계좌 생성 if (orderParam.AcntType.Equals("A3", StringComparison.InvariantCultureIgnoreCase)) { if (orderParam.CardCash.Equals("CASH", StringComparison.InvariantCultureIgnoreCase)) { // 일반계좌 생성 if (string.IsNullOrEmpty(orderParam.Vaccount) || orderParam.Vaccount.Length < 3) { cashpayWay = "M"; if (orderParam.MemberWay.Equals("NON", StringComparison.InvariantCultureIgnoreCase)) { acntNo = "300792725"; } else { PaymentCashAccountInfoT customerCashAccountInfo = biz.GetCustomerCashAccountInfo(orderParam.CustNo, cashpayWay); acntNo = customerCashAccountInfo != null ? customerCashAccountInfo.AcntNo : string.Empty; } } else // 가상계좌 생성 { cashpayWay = "V"; // 잘못된 가상계좌 튕겨내기 if (!biz.GetExistAccountMCash(orderParam.CustNo, orderParam.VacntNo, cashpayWay, orderParam.Vaccount).IsExist) { throw new PaymentProcessBizException(-334, "가상계좌 정보에 이상이 있습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } acntNo = orderParam.Vaccount; } if (string.IsNullOrEmpty(acntNo)) { throw new PaymentProcessBizException(-321, "온라인 입금을 위한 계좌 정보를 찾지 못했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } } else if (orderParam.AcntType.Equals("I1", StringComparison.InvariantCultureIgnoreCase)) // Paypal 계좌 생성 { if (orderParam.CardCash.Equals("GBANK_PAYPAL", StringComparison.InvariantCultureIgnoreCase)) { cashpayWay = "P"; try { PaymentGlobalAccountInfoT customerGlobalAccountInfo = biz.GetCustomerGlobalAccountInfo(orderParam.CustNo, cashpayWay); acntNo = customerGlobalAccountInfo != null ? customerGlobalAccountInfo.AcntNo : string.Empty; if (string.IsNullOrEmpty(acntNo) || acntNo.Length < 3) { string result = biz.MakePersonalAccount(orderParam.CustNo, orderParam.AcntType, orderParam.Gbank.ToString() , string.Empty, string.Empty, string.Empty, 0, string.Empty, string.Empty , string.Empty, string.Empty, string.Empty, string.Empty, orderParam.CardCash , string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, 0, null , string.Empty, "Y", 0, string.Empty); acntNo = result; } } catch { throw new PaymentProcessBizException(-333, "외화입금 계좌 생성중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (string.IsNullOrEmpty(acntNo)) { throw new PaymentProcessBizException(-322, "온라인 입금을 위한 계좌 정보를 찾지 못했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } else if (acntNo == "-1") { throw new PaymentProcessBizException(-333, "외화입금 계좌 생성중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } } else if (orderParam.AcntType.Equals("A2", StringComparison.InvariantCultureIgnoreCase) || orderParam.AcntType.Equals("A7", StringComparison.InvariantCultureIgnoreCase)) // 카드 계좌 생성 { cashpayWay = "M"; try { decimal totalAcntMoney = paymentDataOrderInfoList.Sum(x => (decimal)(x.OrderPrice * x.OrderCnt) + x.SelItemPrice + x.DeliveryFee - x.CostPrice); string result = biz.MakePersonalAccount(orderParam.CustNo, orderParam.AcntType, payMethodtInfo.MasterCard , orderParam.CardNumber, orderParam.CardYear, orderParam.CardMonth, orderParam.Installmonth, orderParam.CardPwd, orderParam.SocialNo2 , orderParam.KVPCardCode, payMethodtInfo.SessionKey, payMethodtInfo.EncData, payMethodtInfo.AppType, string.Empty , string.Empty, string.Empty, string.Empty, string.Empty, orderParam.Eci, 0, null , orderParamEtc.OrderJaehuID, orderParamEtc.DirectYN, totalAcntMoney, orderParam.HalbuType); acntNo = result; } catch { throw new PaymentProcessBizException(-338, "카드 계좌 처리작업중 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (string.IsNullOrEmpty(acntNo) || acntNo == "-1") { throw new PaymentProcessBizException(-328, "카드 계좌 생성중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } else { throw new PaymentProcessBizException(-376, "결제 정보가 잘못 되었습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } // PayPal Express CheckOut if (orderParam.CardCash.Equals("GBANK_PAYPAL", StringComparison.InvariantCultureIgnoreCase) && orderParam.PaypalToken.Trim().Length != 0) { if (biz.GetExistPaypalPaymentInfo(orderParam.PaypalToken).IsExist) { throw new PaymentProcessBizException(-727, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } try { PaymentPaypalPaymentInfoT paypalPaymentInfo = biz.GetPaypalPaymentInfo(orderParam.PaypalToken); biz.UpdatePaypalPaymentInfo(orderParam.PackNo, orderParam.PaypalToken, paypalPaymentInfo == null || string.IsNullOrEmpty(paypalPaymentInfo.CustNo) ? orderParam.CustNo : string.Empty); } catch { throw new PaymentProcessBizException(-728, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } // 카드 정보 기록 if (orderParam.AcntType.Equals("A2", StringComparison.InvariantCultureIgnoreCase) || orderParam.AcntType.Equals("A7", StringComparison.InvariantCultureIgnoreCase)) { try { biz.InsertCardInfo(orderParam.PackNo, payMethodtInfo.SessionKey, payMethodtInfo.EncData, payMethodtInfo.AppType , orderParam.Installmonth, orderParam.CardPwd, orderParam.RemoteAddr, orderParam.Eci , (string.IsNullOrEmpty(orderParam.PaySaveCardYN) ? "N" : orderParam.PaySaveCardYN) , orderParam.SocialNo2, orderParam.HalbuType, orderParam.KVPCardCode, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-330, "주문카드 정보 기록중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 경품권 서비스 관련 if (orderParam.MemberWay.Equals("MEM", StringComparison.InvariantCultureIgnoreCase) && !orderParam.OrderWayKind.Equals("BAR", StringComparison.InvariantCultureIgnoreCase)) { try { int insertedRowCount = biz.InsertSticketAccHistory(orderParam.PackNo, orderParam.CustNo, orderParam.LoginID); if (insertedRowCount > 0) { if (biz.GetExistSticketAccount(orderParam.CustNo).IsExist) { biz.UpdateStickerAccount(orderParam.PackNo, orderParam.CustNo, orderParam.LoginID, orderParam.OrderDateTime); } else { biz.InsertStickerAccount(orderParam.PackNo, orderParam.CustNo, orderParam.LoginID); } } } catch { throw new PaymentProcessBizException(-417, "경품권 서비스 관련 오류 발생."); } } #endregion #region 세금계산서 및 현금영수증 요청 처리 if (orderParam.TaxRegNo.Length >= 9) { string cardKind = (orderParam.IsCorpCard.Equals("Y", StringComparison.InvariantCultureIgnoreCase) ? "Y" : (orderParam.IsCorpCard.Equals("N", StringComparison.InvariantCultureIgnoreCase) ? "N" : string.Empty)); try { biz.InsertRequestTaxCheck(orderParam.PackNo, orderParam.CustNo, orderParam.TaxRegNo , orderParam.TaxCompanyNm, orderParam.TaxBoss, orderParam.TaxAddress, orderParam.TaxRcvAddress , orderParam.TaxZipCode, orderParam.TaxCategory, orderParam.TaxKind, cardKind , orderParam.TaxEmail, orderParam.TaxPhone, orderParam.TaxMemo , orderParam.TaxChargeName, orderParam.TaxChargeName, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-808, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다"); } if (orderParam.CashRegNo.Length >= 9) { if (paymentDataOrderInfoList .Where(x => x.TaxIssueYn.Equals("N", StringComparison.InvariantCultureIgnoreCase) && x.CashIssueYn.Equals("Y", StringComparison.InvariantCultureIgnoreCase)) .Sum(x => (decimal)(x.OrderPrice * x.OrderCnt) + x.SelItemPrice + x.DeliveryFee - x.CostPrice) >= 10) { try { List<PaymentDataOrderInfoT> cashReceiptDataOrderList = paymentDataOrderInfoList.Where(x => x.TaxIssueYn.Equals("N", StringComparison.InvariantCultureIgnoreCase) && x.CashIssueYn.Equals("Y", StringComparison.InvariantCultureIgnoreCase)).ToList<PaymentDataOrderInfoT>(); foreach (PaymentDataOrderInfoT item in cashReceiptDataOrderList) { biz.InsertCashReceipt(orderParam.CashUseType, orderParam.CashRegNo, orderParam.CashName , item.OrderNo, item.ItemNo, orderParam.CashPhone, orderParam.CashEmail , (item.SelItemPrice + item.DeliveryFee - item.CostPrice), orderParam.CustNo , "Y", orderParam.IdFlag); } } catch { throw new PaymentProcessBizException(-809, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다"); } } } } else { if (orderParam.CashRegNo.Length >= 9) { if (paymentDataOrderInfoList .Where(x => x.CashIssueYn.Equals("Y", StringComparison.InvariantCultureIgnoreCase)) .Sum(x => (decimal)(x.OrderPrice * x.OrderCnt) + x.SelItemPrice + x.DeliveryFee - x.CostPrice) >= 10) { try { List<PaymentDataOrderInfoT> cashReceiptDataOrderList = paymentDataOrderInfoList.Where(x => x.CashIssueYn.Equals("Y", StringComparison.InvariantCultureIgnoreCase)).ToList<PaymentDataOrderInfoT>(); foreach (PaymentDataOrderInfoT item in cashReceiptDataOrderList) { biz.InsertCashReceipt(orderParam.CashUseType, orderParam.CashRegNo, orderParam.CashName , item.OrderNo, item.ItemNo, orderParam.CashPhone, orderParam.CashEmail , (item.SelItemPrice + item.DeliveryFee - item.CostPrice), orderParam.CustNo , "Y", orderParam.IdFlag); } } catch { throw new PaymentProcessBizException(-810, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다"); } } } } #endregion #region 공급원가 입력 try { biz.InsertPaymentDsorderSttlData(paymentOrderItemCostInfoList); } catch { throw new PaymentProcessBizException(-741, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 할인정보 입력 if (paymentDataCostBasisInfoList.Count > 0) { try { biz.InsertDsorderCostbasisInfo(orderParam.PackNo, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-113, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 현금성 도용 예외처리 if (biz.GetExistCashTypeGoods(orderParam.PackNo).IsExist) { if (orderParam.AcntType.Equals("AM", StringComparison.InvariantCultureIgnoreCase) || orderParam.AcntType.Equals("A8", StringComparison.InvariantCultureIgnoreCase) || (orderParam.AcntType.Equals("A3", StringComparison.InvariantCultureIgnoreCase) && cashpayWay.Equals("V", StringComparison.InvariantCultureIgnoreCase))) { throw new PaymentProcessBizException(-10, "결제가 불가능 합니다."); } } #endregion #region 사자 주문 입력 // dsorderindex 테이블에 입력하기 affectedRowCount = 0; try { affectedRowCount = biz.InsertDsorderIndex(orderParam.PackNo, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-708, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (affectedRowCount != orderParam.ItemCount) { throw new PaymentProcessBizException(-708, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } // dsorder 테이블에 입력하기 affectedRowCount = 0; try { affectedRowCount = biz.InsertDsorder(orderParam.PackNo, orderParam.CustNo, orderParam.TaxRegNo , acntNo, orderParam.ReceiverName, orderParam.ReceiverZipCode, orderParam.ReceiverAddr1, orderParam.ReceiverAddr2 , orderParam.AcntType, orderParam.ReceiverPhoneNo, orderParam.ReceiverHpNo, orderParam.BuyerEmail , orderParam.Gbank, orderParam.DepositNm, orderParam.OnCreditYN, orderParam.Vaccount , orderParam.FreeInterestNo, orderParam.HalbuType, orderParam.AddressNo, cashpayWay, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-709, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (affectedRowCount != orderParam.ItemCount) { throw new PaymentProcessBizException(-709, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } // dsorder_sub 테이블에 입력하기 try { biz.InsertDsorderSub(orderParam.PackNo); } catch { throw new PaymentProcessBizException(-720, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 필수구성/선택옵션 정보 입력 try { biz.InsertDsselorder(orderParam.BasketPID, orderParam.PackNo); } catch { throw new PaymentProcessBizException(-710, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 필수구성/선택옵션 가격 조작 방지 체크 PaymentCurrentSelPriceInfoT currentSelPriceInfo = biz.GetCurrentSelPriceInfo(orderParam.PackNo); if (currentSelPriceInfo != null) { if (currentSelPriceInfo.SelItemPriceDb != currentSelPriceInfo.SelItemPriceIn) { throw new PaymentProcessBizException(-807, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region G-Plus 카드 쿠폰 사용내용 기록 if (paymentDataCostBasisInfoList.Any(x => x.BasisKind.Equals("PCP", StringComparison.InvariantCultureIgnoreCase)) && orderParam.PaymentCode.Equals("Po_HN_G", StringComparison.InvariantCultureIgnoreCase)) { string useMonth; if (orderParam.OrderDateTime.Day < 5) { useMonth = orderParam.OrderDateTime.AddMonths(-1).Year.ToString() + orderParam.OrderDateTime.AddMonths(-1).Month.ToString().PadLeft(2, '0'); } else { useMonth = orderParam.OrderDateTime.Year.ToString() + orderParam.OrderDateTime.Month.ToString().PadLeft(2, '0'); } affectedRowCount = 0; int gplusCostBasisNo = 0; #if DEBUG || PAYMENT_DEBUG gplusCostBasisNo = 2238819; #else gplusCostBasisNo = 2238819; #endif try { affectedRowCount = biz.InsertGlusUsedCouponInfo(orderParam.PackNo, orderParam.CustNo, orderParam.PaymentCode , "SN", useMonth, gplusCostBasisNo, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-118, "배송비 할인쿠폰 적용 에러입니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (affectedRowCount > 0) { try { biz.UpdateUsedCouponSum(orderParam.CustNo, orderParam.LoginID, useMonth, affectedRowCount, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-119, "배송비 할인쿠폰 적용 에러입니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } } #endregion #region 위약금 정보 입력 if (paymentDataOrderInfoList.Any(x => x.PolicyNo != 0)) { try { biz.InsertChargeOffOrder(orderParam.PackNo, orderParam.CustNo, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-504, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 외화입금 정보 입력 if (orderParam.CardCash.Equals("GBANK_PAYPAL", StringComparison.InvariantCultureIgnoreCase)) { int gubunMethod; string paymentMthd; decimal gExchangeRate; if (orderParam.GbankGubun.Equals("citibank", StringComparison.InvariantCultureIgnoreCase)) { gubunMethod = 2000; paymentMthd = "02"; } else if (orderParam.GbankGubun.Equals("resonabank", StringComparison.InvariantCultureIgnoreCase)) { gubunMethod = 30000; paymentMthd = "03"; } else if (orderParam.GbankGubun.Equals("paypal_express", StringComparison.InvariantCultureIgnoreCase)) { gubunMethod = 110000; paymentMthd = "01"; } else { gubunMethod = 10000; paymentMthd = "01"; } try { gExchangeRate = biz.GetExchangeRate(paymentMthd, orderParam.OrderDateTime); biz.InsertDsgbankorder(orderParam.PackNo, gubunMethod, paymentMthd, gExchangeRate, orderParam.ForeignMoney, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-335, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 개인별 할인쿠폰 사용여부 변경 if (paymentDataCostBasisInfoList.Any(x => x.BasisKind.Equals("PCP", StringComparison.InvariantCultureIgnoreCase))) { // 쿠폰 사용내역 업데이트 try { biz.UpdateDcouponDetail(orderParam.PackNo, orderParam.CustNo, orderParam.LoginID, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-114, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } // 쿠폰 사용 히스토리 입력 try { biz.InsertOrderCouponHistory(orderParam.PackNo, orderParam.CustNo, orderParam.LoginID, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-115, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 복수구매 할인 정보 기록 if (paymentDataOrderInfoList.Any(x => x.BundCondNo > 0)) { try { biz.InsertBundKeysProc(orderParam.PackNo, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-116, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 세트구매 할인 정보 기록 if (paymentDataOrderInfoList.Any(x => x.SetCostNo > 0)) { try { biz.InsertDsSetCostOrder(orderParam.PackNo, orderParam.LoginID, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-129, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 묶음구매 할인 정보 기록 if (paymentDataOrderInfoList.Any(x => x.PackCostNo > 0)) { try { biz.InsertDsSetCostOrder(orderParam.PackNo, orderParam.LoginID, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-133, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 결제에 따른 코드 추가 if (!string.IsNullOrEmpty(orderParam.PaymentCode) && orderParam.PaymentCode.Length > 0) { try { biz.UpdateDscontrPolicySttlCode(orderParam.PackNo, orderParam.PaymentCode); } catch { throw new PaymentProcessBizException(-133, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 현금잔고 주문시 장바구니 번호 입력 if (orderParam.AcntType.Equals("A3", StringComparison.InvariantCultureIgnoreCase) && orderParam.CardCash.Equals("CASH", StringComparison.InvariantCultureIgnoreCase) && orderParam.Gbank == 60000) { try { biz.InsertBuySttlBalancePackNo(orderParam.PackNo); } catch { throw new PaymentProcessBizException(-744, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 해외PG 한도 제한 관련 기록 if (!string.IsNullOrEmpty(orderParam.SettleLimitKey) && orderParam.SettleLimitKey.Length > 12) { if (orderParam.AcntType.Equals("I1", StringComparison.InvariantCultureIgnoreCase)) { orderParam.AcntType = "I2"; } decimal totalOrderPeice = paymentDataOrderInfoList.Sum(x => x.OrderPrice * (decimal)x.OrderCnt); try { biz.InsertLimitOrderSettleLog(orderParam.PackNo, orderParam.CustNo, orderParam.LoginID , orderParam.SettleLimitKey, totalOrderPeice, orderParam.AcntType, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-748, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 주문 유입경로 기록 try { biz.InsertOrderFlowLog(orderParam.PackNo, orderParamEtc.PolicyOrderSrc, orderParam.PrimaryCheckValue, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-812, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 북캐시 적립 정책 기록 if (biz.GetExistBookCashInfo(orderParam.PackNo).IsExist) { try { biz.InsertDsOrderBookCash(orderParam.PackNo, orderParam.LoginID, orderParam.OrderDateTime); } catch { throw new PaymentProcessBizException(-814, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } try { PaymentBookCashPolicyT bookCashPolicy = biz.GetBookCashPolicy("A", orderParam.OrderDateTime); if (bookCashPolicy != null) { if (bookCashPolicy.BcashPNo != 0 && bookCashPolicy.BasisMoney > 0) { biz.InsertDsOrderBookCashPack(orderParam.PackNo, orderParam.LoginID, bookCashPolicy.BcashPNo, bookCashPolicy.PHistNo, bookCashPolicy.BasisMoney, orderParam.OrderDateTime); } } } catch { throw new PaymentProcessBizException(-815, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 쇼핑지원금 차감 처리 if (paymentDataCostBasisInfoList.Any(x => x.BasisKind.Equals("SSD", StringComparison.InvariantCultureIgnoreCase))) { decimal remainSSCash = biz.GetRemainShoppingSupportCash(orderParam.CustNo, orderParam.OrderDateTime); decimal deductSSCash = paymentDataCostBasisInfoList.Where(x => x.BasisKind.Equals("SSD", StringComparison.InvariantCultureIgnoreCase)).Sum(x => x.CostPrice); if (remainSSCash < deductSSCash || remainSSCash <= 0) { throw new PaymentProcessBizException(-157, "쇼핑지원금이 부족합니다."); } // 주문건별로 쇼핑지원금 차감 처리 try { var costSSInfo = (from x in paymentDataCostBasisInfoList where x.BasisKind.Equals("SSD", StringComparison.InvariantCultureIgnoreCase) group x by new { x.PackNo, x.ItemNo, x.BuyOrderNo } into g select new { PackNo = g.Key.PackNo, ItemNo = g.Key.ItemNo, OrderNo = g.Key.BuyOrderNo, ShoppingSupportCash = g.Sum(p => p.CostPrice) } ).ToList(); List<PaymentCostShoppingSupportInfoT> costSSInfoList = new List<PaymentCostShoppingSupportInfoT>(); foreach (var item in costSSInfo) { costSSInfoList.Add(new PaymentCostShoppingSupportInfoT { PackNo = item.PackNo, ItemNo = item.ItemNo, OrderNo = item.OrderNo, ShoppingSupportCash = item.ShoppingSupportCash }); } if (costSSInfoList != null && costSSInfoList.Count > 0) { if (costSSInfoList.Count == 1) { int retCode = 0; try { retCode = biz.SetShoppingSupportCash(orderParam.CustNo, "D1", costSSInfoList[0].ShoppingSupportCash, costSSInfoList[0].PackNo, costSSInfoList[0].ItemNo , costSSInfoList[0].OrderNo, null, null, 0, orderParam.LoginID, 0, "N", 0); } catch { throw new PaymentProcessBizException(-155, "쇼핑지원금 처리에 문제가 발생했습니다."); } if (retCode != 0) { throw new PaymentProcessBizException(-155, "쇼핑지원금 처리에 문제가 발생했습니다."); } } else { try { biz.SetShoppingSupportCash(costSSInfoList, orderParam.CustNo, orderParam.LoginID, "D1"); } catch (PaymentProcessBizException pEx) { throw pEx; } catch { throw new PaymentProcessBizException(-156, "쇼핑지원금 처리에 문제가 발생했습니다."); } } } } catch (PaymentProcessBizException pEx) { throw pEx; } catch { throw new PaymentProcessBizException(-817, "쇼핑지원금 회원권 처리에 문제가 발생하였습니다. 다시 주문해 주시기 바랍니다."); } } #endregion #region 주문 유입 채널 정보 기록 try { //string siteCode = string.Empty; string siteCode = "P"; switch (orderParam.PrimaryCheckValue.ToUpper()) { case "ENG": siteCode = "E"; break; case "BRA": siteCode = "B"; break; case "SOH": siteCode = "S"; break; case "GIR": siteCode = "G"; break; case "GEP": siteCode = "P"; break; } biz.InsertDsOrderChannelInfo(paymentDataOrderInfoList, siteCode, orderParamEtc.OrderJaehuID); } catch { throw new PaymentProcessBizException(-760, "채널 정보 기록 중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 외부 주문 번호 저장 try { biz.InsertOutContrList(orderParam.PackNo); } catch { throw new PaymentProcessBizException(-764, "외부 주문 정보 기록 중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region GEP의 통합주문 목록에 주문 정보 Update #if (!PAYMENT_DEBUG && !PAYMENT_RELEASE) try { List<PaymentGepOrderUpdateInfoT> gepOrderUpdateInfoList = new List<PaymentGepOrderUpdateInfoT>(); foreach (PaymentDataOrderInfoT item in paymentDataOrderInfoList) { gepOrderUpdateInfoList.Add(new PaymentGepOrderUpdateInfoT { GepOrderNo = item.GepOrderNo, ItemNo = item.ItemNo, OrderNo = (long)item.OrderNo, PackNo = item.PackNo }); } new PaymentProcessQueryBiz().UpdateGepOrderList(gepOrderUpdateInfoList, orderParam.OrderDateTime); } catch (PaymentProcessBizException pEx) { throw pEx; } catch { throw new PaymentProcessBizException(-1104, "GEP 주문 정보 기록 중 오류가 발생하였습니다"); } #endif #endregion return orderResult; }
/// <summary> /// 주문 실행 전 주문건별 Validation 및 주문정보 생성 /// </summary> /// <returns></returns> private void PaymentPrepare() { PaymentBiz paymentBiz = new PaymentBiz(); PaymentProcessQueryBiz paymentProcessQueryBiz = new PaymentProcessQueryBiz(); List<PaymentOrderItemCostInfoT> paymentOrderItemCostInfoList = new List<PaymentOrderItemCostInfoT>(); List<PaymentDataOrderInfoT> paymentDataOrderInfoList = new List<PaymentDataOrderInfoT>(); List<PaymentDataCostBasisInfoT> paymentDataCostBasisInfoList = new List<PaymentDataCostBasisInfoT>(); List<string> exItem = new List<string>(); bool isExistCartOptionInfo = false; string orderSrc = string.Empty; string deliveryHopeDay = string.Empty; string orderKind = "O"; long sellOrderNo = 0; int costBasisNo = 0; int jaehuCostPrice = 0; decimal itemDiscountPrice = 0; decimal itemDiscountLastCost = 0; decimal itemCurrentCostPrice = 0; #region 구매자 이메일 if (this._orderParam.MemberWay.Equals("MEM", StringComparison.InvariantCultureIgnoreCase) && string.IsNullOrEmpty(this._orderParam.BuyerEmail)) { PaymentCustomInfoT paymentCustomInfo = paymentBiz.GetPaymentCustomInfo(this._orderParam.CustNo); this._orderParam.BuyerEmail = paymentCustomInfo.EMail; } #endregion #region 현금 영수증 발급 자동화 if (this._orderParam.CashReceiptYN.Equals("Y", StringComparison.InvariantCultureIgnoreCase)) { try { PaymentAutoCashReceiptInfoT autoCashReceiptInfo = paymentProcessQueryBiz.GetAutoCashReceiptInfo(this._orderParam); this._orderParam.CashUseType = autoCashReceiptInfo.ReceiptType; this._orderParam.CashRegNo = autoCashReceiptInfo.IDNumber; this._orderParam.CashName = autoCashReceiptInfo.Demander; this._orderParam.CashPhone = autoCashReceiptInfo.Contact; this._orderParam.CashEmail = autoCashReceiptInfo.Email; this._orderParam.IdFlag = autoCashReceiptInfo.IDFlag; } catch { throw new PaymentProcessBizException(-418, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 주문을 위한 조건들 확인 try { PaymentInfoCheckT paymentInfoCheck = paymentProcessQueryBiz.GetPaymentInfoCheck(this._orderParam.CardCash, this._orderParam.BuyerName, this._orderParam.MemberWay , this._orderParam.AcntType, this._orderParam.VirtualCardKind, string.Empty, this._orderParam.CardNumber , this._orderParam.CardYear, this._orderParam.CardMonth, this._orderParam.CardPwd, this._orderParam.SocialNo2 , this._orderParam.Xid, this._orderParam.Cavv, this._orderParam.KVPSessionkey, this._orderParam.KVPEncdata , this._orderParam.Gbank, this._orderParam.DepositNm, this._orderParam.Eci); if (paymentInfoCheck.RetCode < 0) { throw new PaymentProcessBizException(paymentInfoCheck.RetCode, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } this._orderParam.Gbank = paymentInfoCheck.Gbank; this._orderParam.DepositNm = paymentInfoCheck.DepositName; this._paymenPayMethodtInfo = paymentInfoCheck; } catch { throw new PaymentProcessBizException(-372, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 장바구니 주문건에 필수선택/추가구성 존재여부 조회 isExistCartOptionInfo = paymentProcessQueryBiz.GetExistCartOptionInfo(this._orderParam.BasketPID).IsExist; #endregion #region 장바구니에 담긴 주문 건별로 점검 foreach (PaymentGEPItemInfoT item in this._paymentGEPItemInfoList) { #region 변수 초기화 sellOrderNo = 0; jaehuCostPrice = 0; #endregion #region 상품별 정책 조회 PaymentDscontrPolicyInfoT dscontrPolicyInfo = paymentProcessQueryBiz.GetDscontrPolicyInfo(item.ItemNo, item.OrderNo); #endregion #region 내용 보정 // 주문 수량 보전 if (item.OrderCnt <= 0) item.OrderCnt = 1; #endregion #region 판매시장 정상여부 확인 if (string.IsNullOrEmpty(dscontrPolicyInfo.TradWay)) { throw new PaymentProcessBizException(-607, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region GlinkNation 체크 // 이거 이상한 코드일세.. if (!item.GlinkNation.Equals("SG", StringComparison.InvariantCultureIgnoreCase) && !item.GlinkNation.Equals("JP", StringComparison.InvariantCultureIgnoreCase)) { item.GlinkNation = string.Empty; } if (!item.GlinkNation.Equals("SG", StringComparison.InvariantCultureIgnoreCase) && !item.GlinkNation.Equals("JP", StringComparison.InvariantCultureIgnoreCase) && !item.GlinkNation.Equals("AC", StringComparison.InvariantCultureIgnoreCase)) { item.GlinkNation = string.Empty; } #endregion #region 샵주문 정보 입력 if (!string.IsNullOrEmpty(this._orderParam.PrimaryCheckValue) && !this._orderParam.PrimaryCheckValue.Equals("KOR", StringComparison.InvariantCultureIgnoreCase)) { try { int retCode = paymentProcessQueryBiz.SetOrderSiteInfo(this._orderParam.PrimaryCheckValue , item.ItemNo, dscontrPolicyInfo.OrderNo, this._orderParam.OrderDateTime, dscontrPolicyInfo.ShopGroupCd , dscontrPolicyInfo.ShopGdlcCd, dscontrPolicyInfo.ShopGdmcCd, dscontrPolicyInfo.ShopGdscCd); if (retCode != 0) { //throw new PaymentProcessBizException(-729, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); throw new PaymentProcessBizException(-729, retCode.ToString()); } } catch (Exception ex) { //throw new PaymentProcessBizException(-729, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); throw new PaymentProcessBizException(-729, ex.Message); } } #endregion #region 공동구매 상품 존재 여부 체크 PaymentExistResultT existGroupGoods = paymentProcessQueryBiz.GetExistGroupGoods(item.ItemNo); if (existGroupGoods.IsExist) { throw new PaymentProcessBizException(-627, "공동구매 상품은 장바구니 주문을 하실 수 없습니다. 확인후 다시 주문해 주시기 바랍니다."); } if (dscontrPolicyInfo.GdShopkind == "8" || dscontrPolicyInfo.GdShopkind2 == "8" || dscontrPolicyInfo.GdShopkind3 == "8") { throw new PaymentProcessBizException(-628, "공동구매 상품은 장바구니 주문을 하실 수 없습니다. 확인후 다시 주문해 주시기 바랍니다."); } #endregion #region GMall, 공구, 오픈마켓 상품에 대해 품절 체크 if (dscontrPolicyInfo.TradWay.Equals("T1", StringComparison.InvariantCultureIgnoreCase) || dscontrPolicyInfo.TradWay.Equals("T4", StringComparison.InvariantCultureIgnoreCase) || dscontrPolicyInfo.TradWay.Equals("T6", StringComparison.InvariantCultureIgnoreCase)) { PaymentExistResultT existDsprice = paymentProcessQueryBiz.GetExistDsprice(item.ItemNo, item.OrderCnt, (decimal)item.OrderPrice); if (!existDsprice.IsExist) { paymentProcessQueryBiz.UpdateCartOrderFail(this._orderParam.BasketPID, this._orderParam.CustNo, item.ItemNo); exItem.Add(item.ItemNo); } } if (exItem.Count > 0) { throw new PaymentProcessBizException(-509, "상품의 재고가 부족합니다."); } #endregion #region 판매자 직결제 정보 조회 PaymentAccountmDirectInfoT accountmDirectInfo = paymentProcessQueryBiz.GetAccountmDirectInfo(dscontrPolicyInfo.SellCustNo); if (accountmDirectInfo == null) { accountmDirectInfo = new PaymentAccountmDirectInfoT { SCustNo = string.Empty, Seqno = 0 }; } #endregion #region 스탬프 발급 수량 조회 PaymentStickerGoodsInfoT stickerGoodsInfo = paymentProcessQueryBiz.GetStickerGoodsInfo(item.ItemNo, this._orderParam.OrderDateTime); if (stickerGoodsInfo == null) { stickerGoodsInfo = new PaymentStickerGoodsInfoT { StickerCnt = 0, WhoFee = string.Empty }; } stickerGoodsInfo.StickerCnt = stickerGoodsInfo.StickerCnt * item.OrderCnt; #endregion #region 선택정보 및 옵션상품에 대한 체크 기능 변경/옵션상품값 체크 (선택옵션의 합을 구함) PaymentCartOptionInfoSumT cartOptionInfoSum; if (isExistCartOptionInfo) { try { cartOptionInfoSum = paymentProcessQueryBiz.GetCartOptionInfoSum(this._orderParam.BasketPID, item.OrderIdx); } catch { throw new PaymentProcessBizException(-505, "옵션상품가격 처리 시 에러 발생."); } } else { cartOptionInfoSum = new PaymentCartOptionInfoSumT(); } #endregion #region 복수구매할인 주문인 경우 0원 주문 가능 if (item.BundCondNo > 0 || (dscontrPolicyInfo.GdShopkind.Equals("U", StringComparison.InvariantCultureIgnoreCase) || dscontrPolicyInfo.GdShopkind2.Equals("U", StringComparison.InvariantCultureIgnoreCase) || dscontrPolicyInfo.GdShopkind3.Equals("U", StringComparison.InvariantCultureIgnoreCase))) { if ((item.OrderPrice * item.OrderCnt) + cartOptionInfoSum.SelItemPrice - item.CostPrice < 0) { throw new PaymentProcessBizException(-608, "0원 미만 주문."); } } else { if ((item.OrderPrice * item.OrderCnt) + cartOptionInfoSum.SelItemPrice - item.CostPrice <= 0) { throw new PaymentProcessBizException(-123, "0원 이하 주문."); } } #endregion #region 제휴ID에 따른 제휴사 SET if (Validate.IsNumeric(item.Jaehuid) && item.Jaehuid.Length == 9) { if (!paymentProcessQueryBiz.GetExistBannerContract(item.Jaehuid, this._orderParam.OrderDateTime).IsExist) { orderSrc = "F"; } } orderSrc = item.Jaehuid == "200002328" ? "F" : item.Jaehuid; #endregion #region 할인금액이 넘어왔을 경우 실제로 장바구니 할인 테이블에 할인 내역 존재하는지 체크 if (item.CostPrice > 0 && !paymentProcessQueryBiz.GetExistCartCostInfo(this._orderParam.BasketPID, item.OrderIdx).IsExist) { throw new PaymentProcessBizException(-112, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (item.DealerCostPrice > 0 && item.DealerCostBasisNo <= 0) { throw new PaymentProcessBizException(-128, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 배송비에 따른 배송비 그룹 번호 확인 if (dscontrPolicyInfo.DeliveryFee != 0 && dscontrPolicyInfo.DeliveryGroupNo == 0) { throw new PaymentProcessBizException(-209, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 최소구매수량, 구매단위 확인 if (item.OrderCnt < dscontrPolicyInfo.MinBuyCnt) { throw new PaymentProcessBizException(-605, "주문 수량은 최소 구매 수량보다 많아야 합니다. 주문은 접수되지 않았습니다."); } if ((item.OrderCnt % (dscontrPolicyInfo.BuyUnitCnt > 0 ? dscontrPolicyInfo.BuyUnitCnt : 1)) != 0) { throw new PaymentProcessBizException(-606, "주문 수량은 구매단위의 배수이어야 합니다. 주문은 접수되지 않았습니다."); } #endregion #region PDF 할인 정보 조회 PaymentPdcDiscountPriceT pdcDiscountPrice = paymentProcessQueryBiz.GetPdcDiscountPrice(item.Jaehuid, item.ItemNo); if (pdcDiscountPrice == null) { pdcDiscountPrice = new PaymentPdcDiscountPriceT { PdcDiscountPrice = 0 }; } else { if (!pdcDiscountPrice.PdcDiscountPriceSpecified) pdcDiscountPrice.PdcDiscountPrice = 0; } #endregion #region 할인 정보 List<PaymentDataCostBasisInfoT> costBasisInfo = paymentProcessQueryBiz.GetCostBasisInfo(this._orderParam.PackNo, dscontrPolicyInfo.OrderNo, item.ItemNo, item.OrderCnt, item.OrderPrice, this._orderParam.BasketPID , item.OrderIdx, pdcDiscountPrice.PdcDiscountPrice, item.BundSatisCnt, item.PackSatisCnt, dscontrPolicyInfo.GdShopkind , dscontrPolicyInfo.GdShopkind2, dscontrPolicyInfo.GdShopkind3, dscontrPolicyInfo.DeliveryFee , dscontrPolicyInfo.DeliveryFeeCondition, dscontrPolicyInfo.DeliveryFeePolicy, cartOptionInfoSum.SelItemPrice, this._orderParam.OrderDateTime); if (costBasisInfo != null && costBasisInfo.Count > 0) { // 판매자 공제금 처리를 위한 제휴할인액 jaehuCostPrice = Util.GetSafeInt(costBasisInfo.Sum(x => x.JaehuCostPrice)); //복수구매할인 원단위 절삭 if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("BDC", StringComparison.InvariantCultureIgnoreCase))) { itemDiscountPrice = 0; itemDiscountLastCost = 0; itemDiscountPrice = (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("BDC", StringComparison.InvariantCultureIgnoreCase) select x).Sum(x => x.CostPrice); itemDiscountLastCost = itemDiscountPrice > 0 ? itemDiscountPrice % 10 : 0; if (itemDiscountLastCost != 0) { if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("BDC", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("GD", StringComparison.InvariantCultureIgnoreCase))) { (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("BDC", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("GD", StringComparison.InvariantCultureIgnoreCase) select x).ToList().ForEach(x=> x.CostPrice = x.CostPrice - itemDiscountLastCost); } else { (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("BDC", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("ME", StringComparison.InvariantCultureIgnoreCase) select x).ToList().ForEach(x=> x.CostPrice = x.CostPrice - itemDiscountLastCost); } } } // 세트구매할인 원단위 절삭 if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("SET", StringComparison.InvariantCultureIgnoreCase))) { itemDiscountPrice = 0; itemDiscountLastCost = 0; itemDiscountPrice = (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("SET", StringComparison.InvariantCultureIgnoreCase) select x).Sum(x => x.CostPrice); itemDiscountLastCost = itemDiscountPrice > 0 ? itemDiscountPrice % 10 : 0; if (itemDiscountLastCost != 0) { if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("SET", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("GD", StringComparison.InvariantCultureIgnoreCase))) { (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("SET", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("GD", StringComparison.InvariantCultureIgnoreCase) select x).ToList().ForEach(x=> x.CostPrice = x.CostPrice - itemDiscountLastCost); } else { (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("SET", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("ME", StringComparison.InvariantCultureIgnoreCase) select x).ToList().ForEach(x=> x.CostPrice = x.CostPrice - itemDiscountLastCost); } } } // Pack할인 원단위 절삭 if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("CBD", StringComparison.InvariantCultureIgnoreCase))) { itemDiscountPrice = 0; itemDiscountLastCost = 0; itemDiscountPrice = (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("CBD", StringComparison.InvariantCultureIgnoreCase) select x).Sum(x => x.CostPrice); itemDiscountLastCost = itemDiscountPrice > 0 ? itemDiscountPrice % 10 : 0; if (itemDiscountLastCost != 0) { if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("CBD", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("GD", StringComparison.InvariantCultureIgnoreCase))) { (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("CBD", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("GD", StringComparison.InvariantCultureIgnoreCase) select x).ToList().ForEach(x => x.CostPrice = x.CostPrice - itemDiscountLastCost); } else { (from x in costBasisInfo where x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("CBD", StringComparison.InvariantCultureIgnoreCase) && x.WhoFee.Equals("ME", StringComparison.InvariantCultureIgnoreCase) select x).ToList().ForEach(x => x.CostPrice = x.CostPrice - itemDiscountLastCost); } } } // fix : 나중에 해결하자. // 카테고리 할인 확인 if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.BasisKind.Equals("CPD", StringComparison.InvariantCultureIgnoreCase))) { } // 주문별 할인 총액 계산 itemCurrentCostPrice = 0; itemCurrentCostPrice = Util.GetSafeInt(costBasisInfo.Sum(x => x.CostPrice)); if (itemCurrentCostPrice != item.CostPrice) { if (costBasisInfo.Any(x => x.ItemNo == item.ItemNo && x.BuyOrderNo == dscontrPolicyInfo.OrderNo && x.CostBasisNo == 2238819)) { throw new PaymentProcessBizException(-124, "할인 금액 오류입니다. 주문은 접수되지 않았습니다."); } else { throw new PaymentProcessBizException(-122, "할인 금액 오류입니다. 주문은 접수되지 않았습니다."); } } costBasisNo = item.CostPrice > 0 ? -1 : 0; paymentDataCostBasisInfoList.AddRange(costBasisInfo); } #endregion #region 변수들 SET if (this._orderParam.CardCash.Equals("DIRECT", StringComparison.InvariantCultureIgnoreCase)) { orderSrc = "F"; orderKind = "D"; } #endregion #region 팔자주문 번호 처리 if (!this._orderParam.OrderWayKind.Equals("BAR", StringComparison.InvariantCultureIgnoreCase)) { try { PaymentSellOrderInfoT sellOrderInfo = paymentProcessQueryBiz.GetSellOrderInfo(this._orderParam.OrderWayKind , item.ItemNo, item.OrderPrice, item.OrderCnt, "Y"); if (sellOrderInfo == null) { sellOrderInfo = new PaymentSellOrderInfoT { ContrOrderNo = 0, ContrSellCustNo = string.Empty, SellStat = string.Empty }; } sellOrderInfo.ContrSellCustNo = string.IsNullOrEmpty(sellOrderInfo.ContrSellCustNo) ? string.Empty : sellOrderInfo.ContrSellCustNo.Trim(); if (sellOrderInfo.ContrOrderNo == 0 && string.IsNullOrEmpty(sellOrderInfo.ContrSellCustNo)) { paymentProcessQueryBiz.UpdateCartOrderFail(this._orderParam.BasketPID, this._orderParam.CustNo, item.ItemNo); throw new PaymentProcessBizException(-739, string.Format("재고 부족(상품번호 : {0})", item.ItemNo)); } if (sellOrderInfo.ContrOrderNo == -1) { throw new PaymentProcessBizException(-753, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } sellOrderNo = sellOrderInfo.ContrOrderNo; dscontrPolicyInfo.SellCustNo = sellOrderInfo.ContrSellCustNo; } catch { throw new PaymentProcessBizException(-738, "주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 공급원가 기록 if (!this._orderParam.OrderWayKind.Equals("BAR", StringComparison.InvariantCultureIgnoreCase)) { try { PaymentItemCostCalculateInfoT itemCostCalculateInfo = paymentProcessQueryBiz.GetItemCostCalculateInfo(item.ItemNo, dscontrPolicyInfo.OrderNo, dscontrPolicyInfo.SellCustNo , this._orderParam.OrderWayKind, item.OrderPrice, item.OrderCnt, orderKind, dscontrPolicyInfo.TradWay , dscontrPolicyInfo.GdShopkind, dscontrPolicyInfo.GdShopkind2, dscontrPolicyInfo.GdShopkind3 , this._orderParam.LoginID, 0, 0, 0, string.Empty, sellOrderNo); if (itemCostCalculateInfo == null) { throw new PaymentProcessBizException(-743, "주문주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (itemCostCalculateInfo.RetCode < 0) { throw new PaymentProcessBizException(itemCostCalculateInfo.RetCode, "주문주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } paymentOrderItemCostInfoList.Add(new PaymentOrderItemCostInfoT { ItemNo = item.ItemNo, OrderNo = dscontrPolicyInfo.OrderNo, SellerCustNo = dscontrPolicyInfo.SellCustNo, SellerType = itemCostCalculateInfo.SellerType, SellerCustType = itemCostCalculateInfo.SellerCustType, OrderWayKind = this._orderParam.OrderWayKind, OrderKind = orderKind, ContrWay = dscontrPolicyInfo.TradWay, GdShopKind1 = dscontrPolicyInfo.GdShopkind, GdShopKind2 = dscontrPolicyInfo.GdShopkind2, GdShopKind3 = dscontrPolicyInfo.GdShopkind3, SettleFlag = itemCostCalculateInfo.SettleFlag, WhoFee = itemCostCalculateInfo.WhoFee, HowFee = itemCostCalculateInfo.HowFee, SettleUom = itemCostCalculateInfo.SettleUom, ItemCost = itemCostCalculateInfo.ItemCost, ItemRate = itemCostCalculateInfo.ItemRate, TransPrice = itemCostCalculateInfo.TransPrice, SettleType = itemCostCalculateInfo.SettleType, RegDt = this._orderParam.OrderDateTime, RegId = this._orderParam.LoginID, ChgDt = this._orderParam.OrderDateTime, ChgId = this._orderParam.LoginID }); } catch { throw new PaymentProcessBizException(-736, "주문주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 상품에 대한 주문 정보 try { paymentDataOrderInfoList.Add(new PaymentDataOrderInfoT { PackNo = this._orderParam.PackNo, OrderNo = dscontrPolicyInfo.OrderNo, ItemNo = item.ItemNo, OrderPrice = item.OrderPrice, OrderCnt = item.OrderCnt, OrderIdx = item.OrderIdx, Interval = item.Interval, TradWay = dscontrPolicyInfo.TradWay, GdBuyerMlRate = dscontrPolicyInfo.GdBuyerMlRate, GdBuddyMlRate = dscontrPolicyInfo.GdBuddyMlRate, OrderWayKind = this._orderParam.OrderWayKind, DeliveryFee = dscontrPolicyInfo.DeliveryFee, DeliveryGroupNo = dscontrPolicyInfo.DeliveryGroupNo, CostPrice = item.CostPrice, CostBasisNo = costBasisNo, DelMemo = item.DelMemo, DealerCostPrice = item.DealerCostPrice, DealerCostBasisNo = item.DealerCostBasisNo, DntNo = dscontrPolicyInfo.DntNo, DntSaveMoney = dscontrPolicyInfo.DntSaveMoney, MinSellOrderNo = sellOrderNo, CouponNo = "0", StickerCnt = stickerGoodsInfo.StickerCnt, StickerWhofee = stickerGoodsInfo.WhoFee, OrderSrc = orderSrc, PolicyNo = item.PolicyNo, JaehuCostPrice = jaehuCostPrice, BundCondNo = item.BundCondNo, BundSatisCnt = item.BundSatisCnt, TaxIssueYn = item.TaxIssueYn, CashIssueYn = item.CashIssueYn, SCustNo = accountmDirectInfo.SCustNo, AdNo = accountmDirectInfo.Seqno, SetCostNo = item.SetCostNo, SetCondNo = item.SetCondNo, GlinkNation = item.GlinkNation, PackCostNo = item.PackCostNo, PackCondNo = item.PackCondNo, PackSatisCnt = item.PackSatisCnt, OutOrderNo = item.OutOrderNo, SelItemPrice = cartOptionInfoSum.SelItemPrice, OptSelPrice = cartOptionInfoSum.OptSelPrice, OptAddPrice = cartOptionInfoSum.OptAddPrice, GepOrderNo = Convert.ToInt64(item.OutOrderNo), }); } catch { throw new PaymentProcessBizException(-1102, "주문주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion } #endregion #region 상품수량 맞는지 확인 if (this._paymentGEPItemInfoList.Count != paymentDataOrderInfoList.Count) { throw new PaymentProcessBizException(-1103, "주문주문 접수중에 문제가 발생했습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion // fix : 아래는 주문 데이터 입력전까지 중간에 행해지는데 마땅한데가 없어서 일단 여기 넣음 #region 구매 제한 수량 초과 여부 점검 if (paymentProcessQueryBiz.GetOrderLimitItemCount(this._orderParam.CustNo, this._orderParam.PackNo, this._orderParam.OrderDateTime) > 0) { throw new PaymentProcessBizException(-609, "구매 제한 수량을 초과한 상품이 존재합니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } #endregion #region 개인별 할인쿠폰의 사용여부를 체크 if (paymentDataCostBasisInfoList.Any(x => x.PackNo == this._orderParam.PackNo && x.BasisKind.Equals("PCP", StringComparison.InvariantCultureIgnoreCase))) { var groupedCostBasisInfo = (from x in paymentDataCostBasisInfoList where x.PackNo == this._orderParam.PackNo && x.BasisKind.Equals("PCP", StringComparison.InvariantCultureIgnoreCase) group x by x.CouponNo into g select new { CouponNo = g.Key, Count = g.Count() } ); if (groupedCostBasisInfo.Max(x=>x.Count) > 1) { throw new PaymentProcessBizException(-107, "중복 할인쿠폰이 존재합니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (paymentProcessQueryBiz.GetExistUsedCoupon(this._orderParam.CustNo, this._orderParam.PackNo).IsExist) { throw new PaymentProcessBizException(-107, "이미 사용한 할인쿠폰이 존재합니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } if (paymentProcessQueryBiz.GetNotExistCoupon(this._orderParam.CustNo, this._orderParam.PackNo, this._orderParam.OrderDateTime).IsExist) { throw new PaymentProcessBizException(-120, "받으신 할인쿠폰이 존재하지 않습니다. 다시 주문해 주세요. 주문은 접수되지 않았습니다."); } } #endregion #region 주문 유입 채널정보 // 주문시 직방 체크 공통 PaymentJaehuTypeInfoT jaehuTypeCheck = paymentProcessQueryBiz.GetJaehuTypeCheck(this._orderParam.JaehuID, this._orderParam.OrderDateTime); // 주문 유입 채널정보 if (Validate.IsNumeric(this._orderParam.JaehuID) && this._orderParam.JaehuID.Length == 9) { if (this._orderParam.JaehuID == "200002328" || paymentProcessQueryBiz.GetNotExistContractInfo(this._orderParam.JaehuID, this._orderParam.OrderDateTime).IsExist) { this._orderParamEtc.OrderJaehuID = "F"; } else { this._orderParamEtc.OrderJaehuID = this._orderParam.JaehuID; } } else if (string.IsNullOrEmpty(this._orderParam.JaehuID)) { this._orderParamEtc.OrderJaehuID = "D"; } this._orderParamEtc.DirectYN = jaehuTypeCheck.DirectYN; #endregion // [끝] 아래는 주문 데이터 입력전까지 중간에 행해지는데 마땅한데가 없어서 일단 여기 넣음 this._paymentOrderItemCostInfoList = paymentOrderItemCostInfoList; this._paymentDataOrderInfoList = paymentDataOrderInfoList; this._paymentDataCostBasisInfoList = paymentDataCostBasisInfoList; }
public PaymentInfoCheckT GetPaymentInfoCheck(string cardCash, string buyerName, string memberType , string acntType, string virtualVardKind, string transBankBo, string cardNumber, string year, string month , string cardPwd, string socialNo2, string xid, string cavv, string kcpSessionKey, string kcpEncData , int gBank, string depositName, string eci) { PaymentInfoCheckT data = new PaymentInfoCheckT(); int retCode = 0; SqlParameter[] sqlParam = new SqlParameter[] { SqlParameterHelper.CreateParameter("@card_cash", cardCash, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@buyer_name", buyerName, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@member_type", memberType, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@acnt_type", acntType, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@virtual_card_kind", virtualVardKind, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@trans_bank_no", transBankBo, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@card_number", cardNumber, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@year", year, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@month", month, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@card_pwd", cardPwd, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@social_no2", socialNo2, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@xid", xid, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@cavv", cavv, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@kcp_session_key", kcpSessionKey, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@kcp_enc_data", kcpEncData, SqlDbType.VarChar), SqlParameterHelper.CreateParameter("@gbank", gBank, SqlDbType.Int, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@deposit_nm", depositName, SqlDbType.VarChar, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@isCertified", string.Empty, SqlDbType.VarChar, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@master_card", string.Empty, SqlDbType.VarChar, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@app_type", string.Empty, SqlDbType.VarChar, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@session_key", string.Empty, SqlDbType.VarChar, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@enc_data", string.Empty, SqlDbType.VarChar, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@ret_code", retCode, SqlDbType.Int, int.MaxValue, ParameterDirection.InputOutput), SqlParameterHelper.CreateParameter("@eci", eci, SqlDbType.VarChar) }; new DacHelper(DbHelper, "tiger_read").Execute( CommandType.StoredProcedure, "dbo.up_gmkt_front_order_payment_info_check", sqlParam ); data.Gbank = Convert.ToInt32(sqlParam[15].Value); data.DepositName = sqlParam[16].Value.ToString(); data.IsCertified = sqlParam[17].Value.ToString(); data.MasterCard = sqlParam[18].Value.ToString(); data.AppType = sqlParam[19].Value.ToString(); data.SessionKey = sqlParam[20].Value.ToString(); data.EncData = sqlParam[21].Value.ToString(); data.RetCode = Convert.ToInt32(sqlParam[22].Value); return data; }
/// <summary> /// 주문 실행 /// </summary> /// <param name="orderParam"></param> /// <param name="orderParamEtc"></param> /// <param name="paymenPayMethodtInfo"></param> /// <param name="paymentDataOrderInfoList"></param> /// <param name="paymentDataCostBasisInfoList"></param> /// <param name="paymentOrderItemCostInfoList"></param> /// <returns></returns> //private List<PaymentGEPOrderMultiResultT> PaymentStartOrder() private PaymentGEPPaymentProcessResultT PaymentExecuteOrder(PaymentOrderMultiParamT orderParam , PaymentOrderMultiParamEtcT orderParamEtc , PaymentInfoCheckT paymenPayMethodtInfo , List<PaymentDataOrderInfoT> paymentDataOrderInfoList , List<PaymentDataCostBasisInfoT> paymentDataCostBasisInfoList , List<PaymentOrderItemCostInfoT> paymentOrderItemCostInfoList) { PaymentGEPPaymentProcessResultT orderResult = new PaymentGEPPaymentProcessResultT(); PaymentBiz paymentBiz = new PaymentBiz(); PaymentProcessQueryBiz paymentProcessQueryBiz = new PaymentProcessQueryBiz(); orderResult.Result = new GEPBaseResultT(); #region 주문 #region 주문 실행 PaymentGEPPaymentProcessResultT paymentExecuteOrderResult = paymentProcessQueryBiz.PaymentExecuteOrder( orderParam , orderParamEtc , paymenPayMethodtInfo , paymentDataOrderInfoList , paymentDataCostBasisInfoList , paymentOrderItemCostInfoList); #endregion #region 주문 이후 처리 GEPBaseResultT followUpResult = PaymentExecuteOrderFollowUp(orderParam); if (followUpResult.RetCode != 0) { orderResult.Result = followUpResult; } #endregion #region 주문 내역 조회 List<PaymentGEPOrderMultiResultT> orderItemList = GetExecuteOrderItemList(paymentDataOrderInfoList); #endregion #region 주문 CleanUp try { PaymentExecuteOrderCleanUp(orderParam); } catch { } #endregion paymentExecuteOrderResult.OrderResultList.AddRange(orderItemList); #endregion #region 주문 결과 처리 if (paymentExecuteOrderResult.OrderResultList == null) { orderResult.Result.RetCode = -1107; orderResult.Result.RetMessage = "주문 접수중에 문제가 발생하여 결제가 이루어지지 않았습니다. 확인후 다시 주문해 주시기 바랍니다"; } else { if (paymentExecuteOrderResult.OrderResultList.Count <= 0) { orderResult.Result.RetCode = -1108; orderResult.Result.RetMessage = "주문 접수중에 문제가 발생하여 결제가 이루어지지 않았습니다. 확인후 다시 주문해 주시기 바랍니다"; } else { orderResult.Result.RetCode = paymentExecuteOrderResult.OrderResultList[0].RetCode; orderResult.Result.RetMessage = paymentExecuteOrderResult.OrderResultList[0].RetReason; orderResult.OrderResultList.AddRange(paymentExecuteOrderResult.OrderResultList); } } #endregion return orderResult; }