Ejemplo n.º 1
0
        public JsonResult AddToGmarketCart(List<BasketInputParamT> reqBasketInputParam)
        {
            CartBiz cartBiz = new CartBiz();
            List<BasketInputParamT> basketInputParamList = new List<BasketInputParamT>();
            GmarketBasketAddResultT gmktBasketInputResult = new GmarketBasketAddResultT();
            gmktBasketInputResult.Result = new GEPBaseResultT();

            string optNos = string.Empty;

            for (int i = 0; i < reqBasketInputParam.Count; i++)
            {
                BasketInputParamT basketInputParam = new BasketInputParamT();
                basketInputParam.CustNo = MemberContext.CustomerNo;
                basketInputParam.LoginID = MemberContext.LoginID;
                basketInputParam.ItemNo = reqBasketInputParam[i].ItemNo;
                basketInputParam.OrderCount = reqBasketInputParam[i].OrderCount;
                optNos = GetOptNo(reqBasketInputParam[i].ItemNo);
                basketInputParam.OptNos = optNos;
                basketInputParam.GEPOrderNo = reqBasketInputParam[i].GEPOrderNo;
                basketInputParam.InputWay = reqBasketInputParam[i].InputWay;

                basketInputParamList.Add(basketInputParam);
            }

            gmktBasketInputResult = cartBiz.BasketInput(basketInputParamList);

            return new JsonResult
            {
                Data = new { Result = gmktBasketInputResult.Result, Data = gmktBasketInputResult.AddResultList }
            };
        }
Ejemplo n.º 2
0
        public JsonResult AddToGmarketCart(BasketInputParamT reqBasketInputParam)
        {
            CartBiz cartBiz = new CartBiz();
            GEPOrderBiz gepBiz = new GEPOrderBiz();
            List<BasketInputParamT> basketInputParamList = new List<BasketInputParamT>();
            GmarketBasketAddResultT gmktBasketInputResult = new GmarketBasketAddResultT();
            gmktBasketInputResult.Result = new GEPBaseResultT();

            string optNos = string.Empty;
            long gepOrderNo = 0;

            BasketInputParamT basketInputParam = new BasketInputParamT();
            basketInputParam.CustNo = MemberContext.CustomerNo;
            basketInputParam.LoginID = MemberContext.LoginID;
            basketInputParam.ItemNo = reqBasketInputParam.ItemNo;
            basketInputParam.OrderCount = reqBasketInputParam.OrderCount;
            optNos = GetOptNo(reqBasketInputParam.ItemNo);
            basketInputParam.OptNos = optNos;
            basketInputParam.GEPOrderNo = reqBasketInputParam.GEPOrderNo;
            basketInputParam.InputWay = reqBasketInputParam.InputWay;

            basketInputParamList.Add(basketInputParam);

            gmktBasketInputResult = cartBiz.BasketInput(basketInputParamList);

            if (gmktBasketInputResult.Result.RetCode == 0)
            {
                if(long.TryParse(reqBasketInputParam.GEPOrderNo, out gepOrderNo))
                {
                    gepBiz.AddInCartFromDisableOrder(gepOrderNo);
                }
            }
            return new JsonResult
            {
                Data = new { Result = gmktBasketInputResult.Result, Data = gmktBasketInputResult.AddResultList }
            };
        }
Ejemplo n.º 3
0
        //장바구니 넣기 진입점 - 리스트로 파라미터 값들이 바로 넘어 왔을 때
        public GmarketBasketAddResultT BasketInput(List<BasketInputParamT> lstBasketInputParam)
        {
            GEPOrderBiz gepBiz = new GEPOrderBiz();
            BasketParamT basketParam = new BasketParamT();
            AvailableBasketInfoResultT availableBasketInfoResult = new AvailableBasketInfoResultT();
            GmarketBasketAddResultT gmktBasketInputResult = new GmarketBasketAddResultT();
            gmktBasketInputResult.Result = new GEPBaseResultT();
            GEPBaseResultT insertDBResult = new GEPBaseResultT();
            List<BasketGepOrderNoT> basketGepOrderNos = new List<BasketGepOrderNoT>();
            BasketCurrCountT basketCurrentCnt = new BasketCurrCountT();

            long conGepOrderNo;
            int inputErrorCnt = 0, orderImpossCnt = 0;
            string basketPid = CheckBasketPid(lstBasketInputParam[0].CustNo);
            int lstBasketInputParamCnt = lstBasketInputParam.Count;

            //상품은 100개 까지만 담을 수 있다.
            if (basketPid != string.Empty)
            {
                basketCurrentCnt = GetBasketCurrentCount(basketPid);
                int cartCnt = basketCurrentCnt.NationalCnt;

                if ((cartCnt + lstBasketInputParamCnt) > 100)
                {
                    gmktBasketInputResult.Result.RetCode = -10;
                    gmktBasketInputResult.Result.RetMessage = "현재 장바구니에 " + cartCnt + "건의 주문건이 있습니다.";

                    return gmktBasketInputResult;
                }
            }

            //주문 불가 상품(-970에러)인지 체크
            if (lstBasketInputParam[0].InputWay == "C")
            {
                for (int i = 0; i < lstBasketInputParamCnt; i++)
                {
                    GEPOrderInfoT gepOrderInfo = new GEPOrderInfoT();
                    GmarketBasketAddT checkOrderStatusRtn = new GmarketBasketAddT();
                    if (long.TryParse(lstBasketInputParam[i].GEPOrderNo, out conGepOrderNo))
                    {
                        gepOrderInfo = GetGEPOrderInfo(conGepOrderNo);
                    }
                    if (gepOrderInfo != null)
                    {
                        if (gepOrderInfo.GEPOrder.Status == GepOrderStatus.Conclusion && (gepOrderInfo.GMKTOrder.OrderStatus == GmktOrderStatus.None || gepOrderInfo.GMKTOrder.OrderStatus == GmktOrderStatus.ConclusionFail))
                        {
                            checkOrderStatusRtn.GepOrderNo = lstBasketInputParam[i].GEPOrderNo;
                            checkOrderStatusRtn.RetCode = "0";
                            checkOrderStatusRtn.RetMessage = "주문 가능 상태 체크 성공";
                        }
                        else
                        {
                            orderImpossCnt += 1;
                            checkOrderStatusRtn.GepOrderNo = lstBasketInputParam[i].GEPOrderNo;
                            checkOrderStatusRtn.RetCode = "970";
                            checkOrderStatusRtn.RetMessage = "상품이 주문 가능 상태가 아닙니다.";
                        }
                        gmktBasketInputResult.AddResultList.Add(checkOrderStatusRtn);
                    }
                }
                if (orderImpossCnt > 0)
                {
                    gmktBasketInputResult.Result.RetCode = -1;
                    gmktBasketInputResult.Result.RetMessage = "장바구니담기 실패";

                    return gmktBasketInputResult;
                }
                else
                {
                    gmktBasketInputResult.AddResultList.Clear();
                }
            }

            //장바구니 중복 담긴 상품인지 체크
            if (basketPid != string.Empty)
            {
                int duplicaBasketCnt = 0;
                basketGepOrderNos = GetBasketGepOrderNo(basketPid);
                for (int i = 0; i < lstBasketInputParamCnt; i++)
                {
                    GmarketBasketAddT checkDuplicaRtn = new GmarketBasketAddT();

                    BasketGepOrderNoT result = basketGepOrderNos.Find(
                        delegate(BasketGepOrderNoT gepOrderNo)
                        {
                            return gepOrderNo.GepOrderNo.ToString() == lstBasketInputParam[i].GEPOrderNo;
                        }
                    );
                    if (result != null)
                    {
                        duplicaBasketCnt += 1;
                        checkDuplicaRtn.GepOrderNo = lstBasketInputParam[i].GEPOrderNo;
                        checkDuplicaRtn.RetCode = "1001";
                        checkDuplicaRtn.RetMessage = "이미 장바구니에 담긴 상품이 있습니다.";
                    }
                    else
                    {
                        checkDuplicaRtn.GepOrderNo = lstBasketInputParam[i].GEPOrderNo;
                        checkDuplicaRtn.RetCode = "0";
                        checkDuplicaRtn.RetMessage = "중복 체크 성공";
                    }
                    gmktBasketInputResult.AddResultList.Add(checkDuplicaRtn);
                }

                if (duplicaBasketCnt > 0)
                {
                    gmktBasketInputResult.Result.RetCode = -1;
                    gmktBasketInputResult.Result.RetMessage = "장바구니담기 실패";

                    return gmktBasketInputResult;
                }
                else
                {
                    gmktBasketInputResult.AddResultList.Clear();
                }
            }

            if (lstBasketInputParam.Count > 0)
            {
                for (int itemIdx = 0; itemIdx < lstBasketInputParamCnt; itemIdx++)
                {
                    availableBasketInfoResult.Result = new GEPBaseResultT();
                    GmarketBasketAddT checkInsertableInfo = new GmarketBasketAddT();
                    basketParam = MakeBasketParam(lstBasketInputParam[itemIdx]);
                    availableBasketInfoResult = InsertableBasketInfo(basketParam);

                    checkInsertableInfo.GepOrderNo = lstBasketInputParam[itemIdx].GEPOrderNo;
                    checkInsertableInfo.RetCode = availableBasketInfoResult.Result.RetCode.ToString();
                    checkInsertableInfo.RetMessage = availableBasketInfoResult.Result.RetMessage;

                    gmktBasketInputResult.AddResultList.Add(checkInsertableInfo);

                    if (availableBasketInfoResult.Result.RetCode != 0)
                    {
                        inputErrorCnt += 1;
                        gmktBasketInputResult.Result.RetCode = -1;
                        gmktBasketInputResult.Result.RetMessage = "장바구니담기 실패";

                        if (long.TryParse(lstBasketInputParam[itemIdx].GEPOrderNo, out conGepOrderNo))
                        {
                            try
                            {
                                gepBiz.InsertDisableOrder(conGepOrderNo);
                            }
                            catch (Exception e)
                            {
                            }
                        }
                    }
                }

                if (inputErrorCnt == 0)
                {
                    gmktBasketInputResult.AddResultList.Clear();
                    for (int itemIdx = 0; itemIdx < lstBasketInputParamCnt; itemIdx++)
                    {
                        GmarketBasketAddT gmktBasketRtn = new GmarketBasketAddT();
                        basketParam = MakeBasketParam(lstBasketInputParam[itemIdx]);
                        insertDBResult = BasketInput(basketParam);

                        gmktBasketRtn.GepOrderNo = basketParam.GEPOrderNo;
                        gmktBasketRtn.RetCode = insertDBResult.RetCode.ToString();
                        gmktBasketRtn.RetMessage = insertDBResult.RetMessage;

                        if (gmktBasketRtn.RetCode != "0")
                        {
                            if (long.TryParse(lstBasketInputParam[itemIdx].GEPOrderNo, out conGepOrderNo))
                            {
                                try
                                {
                                    gepBiz.InsertDisableOrder(conGepOrderNo);
                                }
                                catch (Exception e)
                                {
                                }
                            }
                        }

                        gmktBasketInputResult.AddResultList.Add(gmktBasketRtn);
                    }
                }
            }
            return gmktBasketInputResult;
        }