コード例 #1
0
        public PaymentSellOrderInfoT GetSellOrderInfo(string orderWayKind, string itemNo, decimal orderPrice, int orderCnt, string costCheckYN)
        {
            PaymentSellOrderInfoT data = new PaymentSellOrderInfoT();

            SqlParameter[] sqlParam = new SqlParameter[]
            {
                SqlParameterHelper.CreateParameter("@order_way_kind", orderWayKind, SqlDbType.VarChar),
                SqlParameterHelper.CreateParameter("@sp_gd_no", itemNo, SqlDbType.VarChar),
                SqlParameterHelper.CreateParameter("@sp_order_price", orderPrice, SqlDbType.Money),
                SqlParameterHelper.CreateParameter("@sp_remain", orderCnt, SqlDbType.Int),
                SqlParameterHelper.CreateParameter("@contr_order_no", SqlDbType.BigInt, int.MaxValue,  ParameterDirection.Output),
                SqlParameterHelper.CreateParameter("@contr_sell_cust_no", SqlDbType.VarChar, int.MaxValue, ParameterDirection.Output),
                SqlParameterHelper.CreateParameter("@cost_check_yn", costCheckYN, SqlDbType.VarChar),
                SqlParameterHelper.CreateParameter("@sell_stat", SqlDbType.VarChar, int.MaxValue, ParameterDirection.Output)
            };

            new DacHelper(DbHelper, "tiger_read").Execute(
                CommandType.StoredProcedure,
                "dbo.up_gmkt_front_get_sell_order",
                sqlParam
                );

            data.ContrOrderNo = Convert.ToInt64(sqlParam[4].Value);
            data.ContrSellCustNo = sqlParam[5].Value.ToString();
            data.SellStat = sqlParam[7].Value.ToString();

            return data;
        }
コード例 #2
0
        /// <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;
        }