//장바구니 주문 변수 만들기 public BasketOrderParamT MakeBasketOrderParam(BasketParamT basketParam) { List<SelectOptionInfoT> lstSelOptInfo = new List<SelectOptionInfoT>(); SelectOptionStatusT selOptStatus = new SelectOptionStatusT(); SelectOptionSetResultT selOptSetResult = new SelectOptionSetResultT(); SelectOptionInfoResultT selOptResult = new SelectOptionInfoResultT(); selOptResult.Result = new GEPBaseResultT(); BasketItemAddInfoT basketItemAddInfo = new BasketItemAddInfoT(); string[] arrPluralKey, arrEachPluralKey, arrCouponNo; string strPluralCouponDetail, strPluralCostBasisNo; string strPluralKeyEnc, strPluralKeyDec; selOptStatus = GetSelectOptionStatus(basketParam.GoodsCode); BasketOrderParamT basketOrderParam = new BasketOrderParamT(); if (selOptStatus == null) { basketParam.SellingStat = -1; basketParam.OptSelYn = "N"; basketParam.OptAddYn = "N"; basketParam.OptSelInventoryYn = "N"; basketParam.OptAddInventoryYn = "N "; basketParam.OptSelSortCondition = string.Empty; basketParam.OptAddSortCondition = string.Empty; } else { basketParam.SellingStat = selOptStatus.SellingStat; basketParam.OptSelYn = selOptStatus.OptSelYn; basketParam.OptAddYn = selOptStatus.OptAddYn; basketParam.OptSelInventoryYn = selOptStatus.OptSelInventoryYn; basketParam.OptAddInventoryYn = selOptStatus.OptAddInventoryYn; basketParam.OptSelSortCondition = selOptStatus.OptSelSortCondition; basketParam.OptAddSortCondition = selOptStatus.OptAddSortCondition; } if (basketParam.PluralKey != null) { if (string.IsNullOrEmpty(basketParam.SingleOrderCnt) && basketParam.OrderCnt != "0") { arrEachPluralKey = basketParam.PluralKey.Split(PaymentConstant.CommaSeperator); strPluralCostBasisNo = string.Empty; strPluralCouponDetail = string.Empty; for (int i = 0, eachPluralKeyLength = arrEachPluralKey.Length; i < eachPluralKeyLength; i++) { strPluralKeyEnc = arrEachPluralKey[i]; strPluralKeyDec = FrontEncryption.TQDecode(strPluralKeyEnc); if (!string.IsNullOrEmpty(strPluralKeyDec)) { arrPluralKey = strPluralKeyDec.Split(PaymentConstant.MainDelimiter.ToCharArray()); strPluralCostBasisNo = strPluralCostBasisNo + arrPluralKey[2].Replace(PaymentConstant.ThirdDelimiter, PaymentConstant.MainDelimiter); strPluralCouponDetail = strPluralCouponDetail + arrPluralKey[3].Replace(PaymentConstant.ThirdDelimiter, PaymentConstant.MainDelimiter); if (arrPluralKey[2].Replace(PaymentConstant.ThirdDelimiter, PaymentConstant.MainDelimiter).IndexOf(PaymentConstant.MainDelimiter) < 0) { strPluralCostBasisNo = strPluralCostBasisNo + PaymentConstant.MainDelimiter; } else { strPluralCostBasisNo = strPluralCostBasisNo + "0"; } if (i != (eachPluralKeyLength - 1)) { strPluralCostBasisNo = strPluralCostBasisNo + ","; strPluralCouponDetail = strPluralCouponDetail + ","; } } } basketParam.CostBasisNo = strPluralCostBasisNo; basketParam.CouponNo = strPluralCouponDetail; } } if (!string.IsNullOrEmpty(basketParam.CouponNo) && !string.IsNullOrEmpty(basketParam.CouponNo.Replace(PaymentConstant.MainDelimiter, string.Empty).Trim())) { arrCouponNo = basketParam.CouponNo.Split(PaymentConstant.MainDelimiter.ToCharArray()); //[skip] 개인별 할인쿠폰의 존재여부와 사용여부를 체크 line.392~421 } //[skip] 선택정보가 있는 상품인지 확인 line.425~497 //변수에 상품정보를 넣어주는 부분(원래는 '상품에 대한 쿠키를 무조건 생성한다.'부분 501~) if (!string.IsNullOrEmpty(basketParam.GoodsCode)) { if (string.IsNullOrEmpty(basketParam.PosShopCd)) basketParam.PosShopCd = "XX"; if (string.IsNullOrEmpty(basketParam.PosClassCd)) basketParam.PosClassCd = "111111111"; if (string.IsNullOrEmpty(basketParam.PosClassKind)) basketParam.PosClassKind = "T"; //[skip] 이 장바구니는 상품 정보가 하나씩 들어오도록 설계되어 이어붙이기는 생략 line.518~741 if (string.IsNullOrEmpty(basketParam.CostBasisNo)) basketParam.CostBasisNo = "0"; if (basketParam.IsExistSelInfoCheckStr == "N") { if (string.IsNullOrEmpty(basketParam.OrderCnt)) { basketParam.OrderCnt = "1"; } } if (string.IsNullOrEmpty(basketParam.FreeInterestExistYN)) basketParam.FreeInterestExistYN = "N"; if (string.IsNullOrEmpty(basketParam.OverSeaNationList)) basketParam.OverSeaNationList = "해외배송불가"; if (string.IsNullOrEmpty(basketParam.CouponEID)) basketParam.CouponEID = "0"; if (string.IsNullOrEmpty(basketParam.MinSellOrderNo)) basketParam.MinSellOrderNo = "0"; if (string.IsNullOrEmpty(basketParam.CouponNo)) basketParam.CouponNo = PaymentConstant.MainDelimiter; if (string.IsNullOrEmpty(basketParam.DeliveryGroupNo)) basketParam.DeliveryGroupNo = string.Empty; if (string.IsNullOrEmpty(basketParam.OkCashBagPoint)) basketParam.OkCashBagPoint = string.Empty; if (string.IsNullOrEmpty(basketParam.SpecTransFee)) basketParam.SpecTransFee = "0"; if (string.IsNullOrEmpty(basketParam.SpecTransDay)) basketParam.SpecTransDay = "0"; if (string.IsNullOrEmpty(basketParam.BuyUnitCnt)) basketParam.BuyUnitCnt = "1"; if (string.IsNullOrEmpty(basketParam.MinBuyCnt)) basketParam.MinBuyCnt = "1"; if (string.IsNullOrEmpty(basketParam.GdShopKind)) basketParam.GdShopKind = string.Empty; if (string.IsNullOrEmpty(basketParam.BdNo)) basketParam.BdNo = "0"; if (string.IsNullOrEmpty(basketParam.PluralKey)) basketParam.PluralKey = string.Empty; if (string.IsNullOrEmpty(basketParam.DeliveryFeeCondition)) basketParam.DeliveryFeeCondition = string.Empty; if (string.IsNullOrEmpty(basketParam.DeliveryHopeDay)) basketParam.DeliveryHopeDay = string.Empty; if (string.IsNullOrEmpty(basketParam.JaehuID)) basketParam.JaehuID = string.Empty; //관리 상품 체크 line.790~ int iRefusalGoodsCnt = 0; basketParam.RefusalGoodsCode = string.Empty; if (basketParam.GoodsCode.Length == 9) { basketParam.RefusalGoodsCheckFlag = "False"; RefusalGoodsT refusalGoods = GetRefusalGoods(basketParam.GoodsCode); if (refusalGoods != null) { if (basketParam.GoodsCode == refusalGoods.ItemNo) { if (selOptStatus.OptSelYn == "Y" || selOptStatus.OptAddYn == "Y") { iRefusalGoodsCnt = 0; basketParam.RefusalGoodsCheckFlag = "False"; } else { basketParam.RefusalGoodsCheckFlag = "True"; basketParam.RefusalGoodsCode = basketParam.GoodsCode; iRefusalGoodsCnt = 1; } } } if (basketParam.DeliveryFeeCondition == "Q") { basketParam.ChakbulPrepayYN = "C"; } else if (basketParam.DeliveryFeeCondition == "D") { basketParam.ChakbulPrepayYN = "N"; } else { basketParam.ChakbulPrepayYN = "C"; } //[skip] 퀵서비스 & 직접배송 line.822~869 //[skip] 경매 line.871~927 //[skip] 외부상품 line.929~943 //[skip] 예약공동구매 line.945~958 if (basketParam.RefusalGoodsCheckFlag == "False") { //[skip] 마트상품&우유.외부배달상품 line.962~996 //선택옵션 부분 추가 : 2012-02-20 if (selOptStatus.OptSelYn == "Y" || selOptStatus.OptAddYn == "Y") { selOptResult = OptionVerification(basketParam); //selOptSetResult = SetSelectOption(selOptResult.OptionInfoList); } //basketOrderParam에 값 대입 basketOrderParam.Pid = basketParam.Pbid; if (string.IsNullOrEmpty(basketParam.CustNo) || !Validate.IsNumeric(basketParam.CustNo)) { basketOrderParam.CustNo = 0; } else { basketOrderParam.CustNo = int.Parse(basketParam.CustNo); } basketOrderParam.ItemNo = basketParam.GoodsCode; basketOrderParam.GdSelNo = basketParam.GdSelNo; basketOrderParam.ShopCode = "GEP"; basketOrderParam.CostBasisNo = basketParam.CostBasisNo; basketOrderParam.JaehuId = basketParam.JaehuID; basketOrderParam.GepOrderNo = long.Parse(basketParam.GEPOrderNo); basketOrderParam.InputWay = basketParam.InputWay; if (string.IsNullOrEmpty(basketParam.OrderCnt) || !Validate.IsNumeric(basketParam.OrderCnt)) { basketOrderParam.OrderCnts = 0; } else { basketOrderParam.OrderCnts = int.Parse(basketParam.OrderCnt); } if (string.IsNullOrEmpty(basketParam.MinSellOrderNo) || !Validate.IsNumeric(basketParam.MinSellOrderNo)) { basketOrderParam.MinSellOrderNo = 0; } else { basketOrderParam.MinSellOrderNo = Util.GetSafeLong(basketParam.MinSellOrderNo); } if (string.IsNullOrEmpty(basketParam.BuyUnitCnt) || !Validate.IsNumeric(basketParam.BuyUnitCnt)) { basketOrderParam.BuyUnitCnt = 1; } else { basketOrderParam.BuyUnitCnt = int.Parse(basketParam.BuyUnitCnt); } if (string.IsNullOrEmpty(basketParam.MinBuyCnt) || !Validate.IsNumeric(basketParam.MinBuyCnt)) { basketOrderParam.MinBuyCnt = 1; } else { basketOrderParam.MinBuyCnt = int.Parse(basketParam.MinBuyCnt); } basketOrderParam.GdShopkind = basketParam.GdShopKind; basketOrderParam.PluralKey = basketParam.PluralKey; if (string.IsNullOrEmpty(basketParam.DeliveryGroupNo) || !Validate.IsNumeric(basketParam.DeliveryGroupNo)) { basketOrderParam.DeliveryGroupNo = 0; } else { basketOrderParam.DeliveryGroupNo = int.Parse(basketParam.DeliveryGroupNo); } basketOrderParam.ChakbulPrepayYN = basketParam.ChakbulPrepayYN; string[] arrChkCostBasisNo = basketOrderParam.CostBasisNo.Split(PaymentConstant.ForthDelimiter.ToCharArray()); for (int tmpCnt = 0, chkCostBasisNoLenth = arrChkCostBasisNo.Length; tmpCnt < chkCostBasisNoLenth; tmpCnt++) { if (!Validate.IsNumeric(arrChkCostBasisNo[tmpCnt].Replace(PaymentConstant.MainDelimiter, "")) && arrChkCostBasisNo[tmpCnt].Replace(PaymentConstant.MainDelimiter, "").Trim() != "") { throw new ValidationException("정보가 올바르지 않습니다."); } } //[skip] 결제수단 제한 쿠폰 중복 적용 여부 체크 line.64~84 string[] arrTmpPluralKey; string strCostBasisNo, strPluralKey; string strGdNm = string.Empty, strGdShopkind = string.Empty, strGdShopkind2 = string.Empty, strGdShopkind3 = string.Empty; string strHasAddedFile = string.Empty, strGdlcCd = string.Empty, strGdmcCd = string.Empty, strGdscCd = string.Empty; int iDeliveryGroupNo = 0; strCostBasisNo = basketParam.CostBasisNo.Replace(" ", ""); strCostBasisNo = strCostBasisNo.Replace("�", ""); strPluralKey = basketOrderParam.PluralKey; if (string.IsNullOrEmpty(strPluralKey)) { arrTmpPluralKey = FrontEncryption.TQDecode(strPluralKey).Split(PaymentConstant.MainDelimiter.ToCharArray()); if (arrTmpPluralKey.Length < 8) { strPluralKey = string.Empty; strCostBasisNo = string.Empty; } else if (arrTmpPluralKey[1] != basketOrderParam.ItemNo) { strPluralKey = string.Empty; strCostBasisNo = string.Empty; } } basketItemAddInfo = GetBasketItemAddInfo(basketOrderParam.ItemNo); if (basketItemAddInfo != null) { strGdNm = basketItemAddInfo.ItemName; iDeliveryGroupNo = basketItemAddInfo.DeliveryGroupNo; strGdShopkind = basketItemAddInfo.GdShopkind; strGdShopkind2 = basketItemAddInfo.GdShopkind2; strGdShopkind3 = basketItemAddInfo.GdShopkind3; strHasAddedFile = basketItemAddInfo.Hasaddedfile; strGdlcCd = basketItemAddInfo.GdlcCd; strGdmcCd = basketItemAddInfo.GdmcCd; strGdscCd = basketItemAddInfo.GdscCd; } basketOrderParam.OrderIdx = basketParam.OrderIdx; basketOrderParam.DeliveryGroupNo = iDeliveryGroupNo; basketOrderParam.GdShopkind = strGdShopkind; basketOrderParam.CostBasisNo = strCostBasisNo.Replace(PaymentConstant.ForthDelimiter, PaymentConstant.MainDelimiter); } } //[skip] OK캐쉬백 사용 line.1048~1056 //[skip] 상품중복담기체크 line.1058~1072 //[skip] 퀵서비스 line.1075~1104 if (iRefusalGoodsCnt > 0) { string strRefusalGoodsName = ""; PluralItemInfoT pluralItemInfo = GetPluralItemInfo(basketParam.GoodsCode); if (pluralItemInfo != null) { strRefusalGoodsName = pluralItemInfo.ItemName.Substring(0, 35) + "..."; Console.WriteLine("다음 상품은 장바구니에 담을 수 없습니다." + strRefusalGoodsName); } } } return basketOrderParam; }
//장바구니에 넣기 로직 public GEPBaseResultT BasketInput(BasketParamT requestBasketParam) { BasketOrderParamT basketOrderParam = new BasketOrderParamT(); BasketParamT basketParam = new BasketParamT(); AvailableBasketInfoResultT availableBasketInfoResult = new AvailableBasketInfoResultT(); availableBasketInfoResult.Result = new GEPBaseResultT(); SelectOptionInfoResultT selOptResult = new SelectOptionInfoResultT(); GEPBaseResultT basketInputResult = new GEPBaseResultT(); availableBasketInfoResult = InsertableBasketInfo(requestBasketParam, ref basketOrderParam); if (availableBasketInfoResult.Result.RetCode == 0) { selOptResult = OptionVerification(availableBasketInfoResult.BasketInfo); } if (availableBasketInfoResult.Result.RetCode == 0 && selOptResult.Result.RetCode == 0) { //basketInfoSetResult = SetBasketInfo(basketOrderParam); //SP넣는 부분 try { basketInputResult = InputDataToDB(selOptResult.OptionInfoList, basketOrderParam); } catch (Exception e) { //Console.WriteLine(e.Message); } } else { if(availableBasketInfoResult.Result.RetCode != 0){ basketInputResult.RetMessage = "상품 정보에 오류가 있습니다."; basketInputResult.RetCode = 400; } else if (selOptResult.Result.RetCode != 0) { basketInputResult.RetMessage = "선택옵션 정보에 오류가 있습니다."; basketInputResult.RetCode = 401; }else { basketInputResult.RetMessage = "해당 상품을 장바구니 담기에 실패하였습니다."; basketInputResult.RetCode = 402; } } return basketInputResult; }
//장바구니에 넣기 전 Verification public GEPBaseResultT BasketVerification(BasketParamT reqBasketParam) { GEPBaseResultT basketVerificationResult = new GEPBaseResultT(); basketVerificationResult.RetCode = 0; //배송체크 if (DeliveryVerification(reqBasketParam) != 0) { basketVerificationResult.RetCode = 202; basketVerificationResult.RetMessage = "다음 상품은 배송비 설정이 잘못 되었습니다."; return basketVerificationResult; } //재고체크 InventoryCheckResultT inventoryVerificationResult = new InventoryCheckResultT(); inventoryVerificationResult = InventoryVerification(reqBasketParam); if (inventoryVerificationResult.RetCode != 0) { basketVerificationResult.RetCode = 203; basketVerificationResult.RetMessage = "다음 상품은 "+ inventoryVerificationResult.RetMsg +" 상품입니다."; return basketVerificationResult; } //옵션체크 SelectOptionInfoResultT selOptResult = new SelectOptionInfoResultT(); selOptResult.Result = new GEPBaseResultT(); selOptResult = OptionVerification(reqBasketParam); if (reqBasketParam.OptSelYn == "Y" || reqBasketParam.OptAddYn == "Y") //옵션이 있을 때 { if (selOptResult.Result.RetCode != 0) { basketVerificationResult.RetCode = 204; basketVerificationResult.RetMessage = "다음 상품은 장바구니에 담을 수 없습니다." + selOptResult.Result.RetMessage; return basketVerificationResult; } } if (reqBasketParam.InputWay == "C") { //Mother상품비교변경사항체크 ValidCheckResultT oriCheckResult = new ValidCheckResultT(); oriCheckResult.Result = new GEPBaseResultT(); oriCheckResult = OriginVerification(reqBasketParam); if (oriCheckResult.Result.RetCode != 0) { basketVerificationResult.RetCode = 204; basketVerificationResult.RetMessage = "상품 정보가 변경되었습니다."; return basketVerificationResult; } } if(basketVerificationResult.RetCode == 0){ basketVerificationResult.RetMessage = "Verification Success!"; } return basketVerificationResult; }
//옵션체크(옵션설정값자체) public SelectOptionInfoResultT OptionVerification(BasketParamT reqBasketParam) { SelectOptionInfoResultT selOptResult = new SelectOptionInfoResultT(); selOptResult.Result = new GEPBaseResultT(); List<SelectOptionInfoT> lstSelOptInfo = new List<SelectOptionInfoT>(); List<SelectOptionParamT> lstSelOptParam = new List<SelectOptionParamT>(); string strMsg = String.Empty; int errorCnt = 0; if (reqBasketParam.OptSelYn == "Y" || reqBasketParam.OptAddYn == "Y") //옵션이 있을 때 { string[] arrOptNo = reqBasketParam.OptNos.Split(PaymentConstant.ForthDelimiter.ToCharArray()); lstSelOptInfo = GetSelectOptionInfo(reqBasketParam.GoodsCode, reqBasketParam.AddInfoType); if (lstSelOptInfo != null) { if (lstSelOptInfo.Count > 0) { string strOptValidationchk = "N"; //N:변동없음 string strInventoryYn = String.Empty; if (arrOptNo.Length > 0) { for (int j = 0, arrOptNoLenth = arrOptNo.Length; j < arrOptNoLenth; j++) { for (int i = 0, lstSelOptInfoCnt = lstSelOptInfo.Count; i < lstSelOptInfoCnt; i++) { if (lstSelOptInfo[i].OptNo.ToString() == arrOptNo[j]) { //옵션 Validation Check - 재고 수량 체크 if (lstSelOptInfo[i].OptStat == "N") { strOptValidationchk = "O"; //옵션품절 continue; } if (lstSelOptInfo[i].InfoType == "S") { strInventoryYn = reqBasketParam.OptSelInventoryYn; } else if (lstSelOptInfo[i].InfoType == "P") { strInventoryYn = reqBasketParam.OptAddInventoryYn; } if (strInventoryYn == "Y") { if (int.Parse(reqBasketParam.OrderCnt) > lstSelOptInfo[i].InventoryCnt) { strOptValidationchk = "I"; //재고부족 continue; } } } else { continue; } strOptValidationchk = "F"; if (strOptValidationchk != "N" && strOptValidationchk != "F") { strMsg = strMsg + "대상 : " + lstSelOptInfo[i].OptNm + "-" + lstSelOptInfo[i].OptValue; if (lstSelOptInfo[i].OptPrice > 0) { strMsg = strMsg + "(+" + lstSelOptInfo[i].OptPrice + "):"; } else if (lstSelOptInfo[i].OptPrice < 0) { strMsg = strMsg + "(-" + lstSelOptInfo[i].OptPrice + "):"; } if (strOptValidationchk == "O") { strMsg = strMsg + "선택상품품절\n"; } else if (strOptValidationchk == "I") { strMsg = strMsg + "재고부족\n"; } errorCnt = errorCnt + 1; } else { //gep_cart_option_info 에 데이터 넣기 SelectOptionParamT optParam = new SelectOptionParamT(); optParam.Pid = reqBasketParam.Pbid; optParam.CustNo = reqBasketParam.CustNo; optParam.ItemNo = reqBasketParam.GoodsCode; optParam.GdSelNo = reqBasketParam.GdSelNo; optParam.OptNm = lstSelOptInfo[i].OptNm; optParam.OptValue = lstSelOptInfo[i].OptValue; optParam.InfoType = lstSelOptInfo[i].InfoType; optParam.SelItemPrice = (Int32)lstSelOptInfo[i].OptPrice; optParam.OrderCnts = int.Parse(reqBasketParam.OrderCnt); optParam.OptNo = lstSelOptInfo[i].OptNo; optParam.OptOrderCnt = optParam.OrderCnts; optParam.OrderGubun = "N"; optParam.VersionChgDt = lstSelOptInfo[i].VersionChgDt; optParam.OrderIdx = reqBasketParam.OrderIdx; lstSelOptParam.Add(optParam); } } } } else { errorCnt = 1002; } } else { errorCnt = 1001; } } else { errorCnt = 1000; } } selOptResult.Result.RetCode = errorCnt; if (errorCnt > 999) { strMsg = "옵션 정보가 올바르지 않습니다."; } selOptResult.Result.RetMessage = strMsg; if (selOptResult.Result.RetCode == 0) { selOptResult.OptionInfoList.AddRange(lstSelOptParam); } return selOptResult; }