Пример #1
0
        /// <summary>
        /// GEP로 소스상품 이관 
        /// </summary>
        public void SetGEPItems(List<GepItemsData> reqMotherItems, string ta_id)
        {
            List<GepItemsData> resultGEPItems = new List<GepItemsData>(); // 최종저장할 GepItemsData

            // 넘어온 reqMotherItems에는 소스상품번호(src_info.no)와 이미지(img)만 값이 들어있다.
            foreach (GepItemsData motherItem in reqMotherItems)
            {
                string gd_no = motherItem.src_info.no;
                string gd_img = motherItem.img;

                // 임시저장된 필수선택 리스트(TempGEPItem)를 가져온다.
                List<GepItemsData> tmpGEPItems = new SourceItemBiz().GetTempGEPItemList(ta_id, gd_no);

                if (tmpGEPItems != null && tmpGEPItems.Count > 0)
                {
                    foreach (GepItemsData t in tmpGEPItems)
                    {
                        t.stat = "S2";
                        new SourceItemDac().UpdateGEPItem(t); // 상태만 S1 -> S2 바로 업데이트

                        long[] sel = GmktUtil.GetOptionNoLongArrayFull(t.src_info.sel_no.RawValues);
                        new SourceItemDac().SetSourceItemHistory(ta_id, gd_no, t._id, sel[0], sel[1], sel[2], sel[3], sel[4]); // History
                    }
                }
                else
                {
                    // 필수선택이 없는 소스상품은 Insert를 위해 필터링 DB에서 나머지를 채운다.
                    SourceItemInfoT info = new SourceItemBiz().GetSourceItem(ta_id, gd_no);
                    string Desc = new SourceItemBiz().GetSourceItemDescription(gd_no);

                    GepItemsData resultGEPItem = new GepItemsData();
                    resultGEPItem._id = GetNextGEPItemID();
                    resultGEPItem.stat = "S2"; // resultGEPItemStatusEnum.Active;
                    resultGEPItem.img = gd_img;
                    resultGEPItem.src_site = "GMKT";
                    resultGEPItem.src_info = new src_info();
                    resultGEPItem.src_info.no = gd_no;
                    resultGEPItem.src_info.name = info.Name;
                    resultGEPItem.src_info.seller = new seller();
                    resultGEPItem.src_info.seller.no = info.SellerNo;
                    resultGEPItem.src_info.seller.sid = info.SellerID;
                    resultGEPItem.src_info.seller.name = info.SellerName;
                    resultGEPItem.src_info.seller.tel = info.SellerTel;
                    resultGEPItem.src_info.seller.cell = info.SellerCell;
                    resultGEPItem.src_info.seller.email = info.SellerEmail;
                    resultGEPItem.src_info.lcategory = new lcategory();
                    resultGEPItem.src_info.lcategory.cid = info.LCategoryCode;
                    resultGEPItem.src_info.lcategory.name = info.LCategoryName;
                    resultGEPItem.src_info.mcategory = new mcategory();
                    resultGEPItem.src_info.mcategory.cid = info.MCategoryCode;
                    resultGEPItem.src_info.mcategory.name = info.MCategoryName;
                    resultGEPItem.src_info.scategory = new scategory();
                    resultGEPItem.src_info.scategory.cid = info.SCategoryCode;
                    resultGEPItem.src_info.scategory.name = info.SCategoryName;
                    resultGEPItem.src_info.desc = Desc;
                    resultGEPItem.src_info.price = Util.GetSafeInt(info.SellPrice);
                    resultGEPItem.src_info.settle_price = Util.GetSafeInt(info.CostPrice);
                    resultGEPItem.src_info.qty = info.StockQty;
                    resultGEPItem.src_info.weight = Util.GetSafeInt(info.Weight);
                    resultGEPItem.src_info.dc = Util.GetSafeInt(info.SellerDiscountPrice);
                    resultGEPItem.src_info.origin = info.Origin;
                    resultGEPItem.src_info.dlv = new dlv();
                    resultGEPItem.src_info.dlv.dlv_gr_no = info.DeliveryGroupNo;
                    resultGEPItem.src_info.dlv.dlv_gr_nm = info.DeliveryGroupName;
                    resultGEPItem.src_info.dlv.bs_money = Util.GetSafeInt(info.BasisMoney);
                    resultGEPItem.src_info.dlv.dlv_fee = Util.GetSafeInt(info.DeliveryFee);
                    resultGEPItem.src_info.dlv.who_fee = info.WhoFee;
                    resultGEPItem.src_info.dlv.bs_weight = Util.GetSafeInt(info.BasisWeight);
                    resultGEPItem.src_info.dlv.bs_amt = Util.GetSafeInt(info.BasisAmount);
                    resultGEPItem.src_info.dlv.bs_type = info.BasisType;
                    resultGEPItem.src_info.dlv.dlv_fee_yn = info.DeliveryFeeYn;
                    resultGEPItem.src_info.dlv.dlv_fee_cond = info.DeliveryFeeCondition;
                    //resultGEPItem.src_info.sel_no
                    //resultGEPItem.src_info.sel_name
                    //resultGEPItem.src_info.sel_price
                    //resultGEPItem.src_info.sel_qty
                    resultGEPItem.src_info.overseas_sold_cnt = info.OverseasSoldCount;
                    resultGEPItem.src_info.total_price = Util.GetSafeInt(info.SellPrice + info.DeliveryFee - info.SellerDiscountPrice);
                    resultGEPItem.ver_code = "";
                    resultGEPItem.trans = new List<trans>();
                    resultGEPItem.is_exp = false;
                    resultGEPItem.rdate = DateTime.Now;
                    resultGEPItem.udate = DateTime.Now;
                    resultGEPItem.ta = ta_id;
                    resultGEPItem.total_exp_count = 0;
                    resultGEPItem.latest_exp_date = DateTime.Now;
                    resultGEPItem.exp_ta = "";

                    resultGEPItems.Add(resultGEPItem);
                }
            }

            // Batch Insert
            if (resultGEPItems.Count > 0)
            {
                new SourceItemDac().InsertGEPItem(resultGEPItems);

                // 이관 History (Batch Insert한 건들은 필수선택이 없으므로 opt_no는 모두 0으로 넘김
                foreach (GepItemsData i in resultGEPItems)
                {
                    new SourceItemDac().SetSourceItemHistory(ta_id, i.src_info.no, i._id, 0, 0, 0, 0, 0);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 필수선택 임시저장
        /// </summary>
        public void SetTempGEPItems(List<GepItemsData> selections, string ta_id)
        {
            List<GepItemsData> resultGEPItems = new List<GepItemsData>(); // 최종저장할 GepItemsData

            foreach (GepItemsData sel in selections)
            {
                if (sel.src_info.sel_qty <= 0) continue; // 품절일 때 선택저장불가

                string gd_no = sel.src_info.no;
                string gd_img = sel.img;

                // 필터링으로부터 상품만들기
                SourceItemInfoT info = new SourceItemBiz().GetSourceItem(ta_id, gd_no);
                string Desc = new SourceItemBiz().GetSourceItemDescription(gd_no);

                GepItemsData resultGEPItem = new GepItemsData();
                resultGEPItem._id = GetNextGEPItemID();
                resultGEPItem.stat = "S1"; // resultGEPItemStatusEnum.StanBy;
                resultGEPItem.img = gd_img;
                resultGEPItem.src_site = "GMKT";
                resultGEPItem.src_info = new src_info();
                resultGEPItem.src_info.no = gd_no;
                resultGEPItem.src_info.name = info.Name;
                resultGEPItem.src_info.seller = new seller();
                resultGEPItem.src_info.seller.no = info.SellerNo;
                resultGEPItem.src_info.seller.sid = info.SellerID;
                resultGEPItem.src_info.seller.name = info.SellerName;
                resultGEPItem.src_info.seller.tel = info.SellerTel;
                resultGEPItem.src_info.seller.cell = info.SellerCell;
                resultGEPItem.src_info.seller.email = info.SellerEmail;
                resultGEPItem.src_info.lcategory = new lcategory();
                resultGEPItem.src_info.lcategory.cid = info.LCategoryCode;
                resultGEPItem.src_info.lcategory.name = info.LCategoryName;
                resultGEPItem.src_info.mcategory = new mcategory();
                resultGEPItem.src_info.mcategory.cid = info.MCategoryCode;
                resultGEPItem.src_info.mcategory.name = info.MCategoryName;
                resultGEPItem.src_info.scategory = new scategory();
                resultGEPItem.src_info.scategory.cid = info.SCategoryCode;
                resultGEPItem.src_info.scategory.name = info.SCategoryName;
                resultGEPItem.src_info.desc = Desc;
                resultGEPItem.src_info.price = Util.GetSafeInt(info.SellPrice);
                resultGEPItem.src_info.settle_price = Util.GetSafeInt(info.CostPrice);
                resultGEPItem.src_info.qty = info.StockQty;
                resultGEPItem.src_info.weight = Util.GetSafeInt(info.Weight);
                resultGEPItem.src_info.dc = Util.GetSafeInt(info.SellerDiscountPrice);
                resultGEPItem.src_info.origin = info.Origin;
                resultGEPItem.src_info.dlv = new dlv();
                resultGEPItem.src_info.dlv.dlv_gr_no = info.DeliveryGroupNo;
                resultGEPItem.src_info.dlv.dlv_gr_nm = info.DeliveryGroupName;
                resultGEPItem.src_info.dlv.bs_money = Util.GetSafeInt(info.BasisMoney);
                resultGEPItem.src_info.dlv.dlv_fee = Util.GetSafeInt(info.DeliveryFee);
                resultGEPItem.src_info.dlv.who_fee = info.WhoFee;
                resultGEPItem.src_info.dlv.bs_weight = Util.GetSafeInt(info.BasisWeight);
                resultGEPItem.src_info.dlv.bs_amt = Util.GetSafeInt(info.BasisAmount);
                resultGEPItem.src_info.dlv.bs_type = info.BasisType;
                resultGEPItem.src_info.dlv.dlv_fee_yn = info.DeliveryFeeYn;
                resultGEPItem.src_info.dlv.dlv_fee_cond = info.DeliveryFeeCondition;
                // 필수선택 정보 들어감
                resultGEPItem.src_info.sel_no = sel.src_info.sel_no;
                resultGEPItem.src_info.sel_name = sel.src_info.sel_name;
                resultGEPItem.src_info.sel_price = sel.src_info.sel_price;
                resultGEPItem.src_info.sel_qty = sel.src_info.sel_qty;
                // 필수선택 정보 들어감
                resultGEPItem.src_info.overseas_sold_cnt = info.OverseasSoldCount;
                resultGEPItem.src_info.total_price = Util.GetSafeInt(info.SellPrice + info.DeliveryFee - info.SellerDiscountPrice);
                resultGEPItem.ver_code = "";
                resultGEPItem.trans = new List<trans>();
                resultGEPItem.is_exp = false;
                resultGEPItem.rdate = DateTime.Now;
                resultGEPItem.udate = DateTime.Now;
                resultGEPItem.ta = ta_id;
                resultGEPItem.total_exp_count = 0;
                resultGEPItem.latest_exp_date = DateTime.Now;
                resultGEPItem.exp_ta = "";

                resultGEPItems.Add(resultGEPItem);
            }

            // Batch Insert (임시저장은 히스토리를 남기지 않음)
            new SourceItemDac().InsertGEPItem(resultGEPItems);
        }
Пример #3
0
        /// <summary>
        /// G마켓 상품 필수선택 정보 및 상세리스트 UI에 적합하게 조회
        /// </summary>
        public List<TempGepItemData> GetSourceItemOptionList(string gd_no, int stock_qty)
        {
            List<TempGepItemData> selections = new List<TempGepItemData>();

            SourceItemOptionInfoT info = new SourceItemBiz().GetSourceItemOptionInfo(gd_no);
            if (info == null || info.SelectionInfoList == null || info.SelectionInfoList.Count == 0) return selections;

            if (info.DisplayType == "S")
            {
                List<SourceItemOptionRecordT> orgList = info.SelectionInfoList; // 순수하게 DB에서 가져온 원본리스트

                string[] nameArray = orgList.Select(t => t.Name).Distinct().ToArray(); // Name 추출
                List<List<SourceItemOptionRecordT>> selByName = new List<List<SourceItemOptionRecordT>>();
                int i = 0;

                // 각 Name에 대한 하위 값들을 추출
                foreach (string n in nameArray)
                {
                    var tmp = orgList.Where(t => t.Name == n).Select(t => new { OptionNo = t.OptionNo, Value = t.Value, Price = t.Price, Cnt = t.Cnt, Stat = t.Stat }).ToList();
                    List<SourceItemOptionRecordT> tmpList = new List<SourceItemOptionRecordT>();

                    foreach (var record in tmp)
                    {
                        SourceItemOptionRecordT s = new SourceItemOptionRecordT();
                        s.OptionNo = record.OptionNo;
                        s.Value = record.Value;
                        s.Price = record.Price;
                        s.Cnt = record.Cnt;
                        s.Stat = record.Stat == null ? "Y" : record.Stat;
                        tmpList.Add(s);
                    }

                    selByName.Add(tmpList);
                    i++;
                }

                // 조합형 데이터 생성
                for (int n = 0; n < selByName[0].Count; n++) // 첫번째 항목에 대한 리스트
                {
                    TempGepItemData sel = new TempGepItemData();
                    sel.sel_name = selByName[0][n].Value;
                    sel.sel_qty = info.IsSelectionInventory == false ? (Util.GetSafeString(selByName[0][n].Stat) == "N" ? 0 : stock_qty) : Util.GetSafeInt(selByName[0][n].Cnt);
                    sel.sel_price = Util.GetSafeInt(selByName[0][n].Price);
                    sel.sel_no = new BsonArray();
                    sel.sel_no.Add(selByName[0][n].OptionNo);

                    selections.Add(sel);
                }

                int mngCnt = 1;

                while (selByName.Count > mngCnt) // N번째 항목이 있다면
                {
                    List<TempGepItemData> tmpList = new List<TempGepItemData>();

                    for (int n = 0; n < selByName[mngCnt].Count; n++) // N번째 항목에 대한 리스트
                    {
                        TempGepItemData sel = new TempGepItemData();
                        sel.sel_name = selByName[mngCnt][n].Value;
                        sel.sel_qty = info.IsSelectionInventory == false ? (Util.GetSafeString(selByName[mngCnt][n].Stat) == "N" ? 0 : stock_qty) : Util.GetSafeInt(selByName[mngCnt][n].Cnt);
                        sel.sel_price = Util.GetSafeInt(selByName[mngCnt][n].Price);
                        sel.sel_no = new BsonArray();
                        sel.sel_no.Add(selByName[mngCnt][n].OptionNo);

                        for (int m = 0; m < selections.Count; m++)
                        {
                            TempGepItemData com = new TempGepItemData();
                            com.sel_name = selections[m].sel_name + " : " + sel.sel_name;
                            com.sel_qty = sel.sel_qty < selections[m].sel_qty ? sel.sel_qty : selections[m].sel_qty;
                            com.sel_price = selections[m].sel_price + sel.sel_price;
                            com.sel_no = new BsonArray();
                            com.sel_no.Add(selections[m].sel_no[0]);
                            if (mngCnt == 1) com.sel_no.Add(sel.sel_no[0]);
                            else if (mngCnt > 1) com.sel_no.Add(selections[m].sel_no[1]);
                            if (mngCnt == 2) com.sel_no.Add(sel.sel_no[0]);
                            else if (mngCnt > 2) com.sel_no.Add(selections[m].sel_no[2]);
                            if (mngCnt == 3) com.sel_no.Add(sel.sel_no[0]);
                            else if (mngCnt > 3) com.sel_no.Add(selections[m].sel_no[3]);
                            if (mngCnt == 4) com.sel_no.Add(sel.sel_no[0]);
                            else if (mngCnt > 4) com.sel_no.Add(selections[m].sel_no[4]);

                            tmpList.Add(com);
                        }
                    }

                    selections = tmpList;

                    mngCnt++;
                }
            }
            else
            {
                foreach (SourceItemOptionRecordT row in info.SelectionInfoList)
                {
                    TempGepItemData sel = new TempGepItemData();
                    sel.sel_name = row.Name + " : " + row.Value;
                    sel.sel_qty = info.IsSelectionInventory == false ? ((row.Stat != null && row.Stat == "N") ? 0 : stock_qty) : row.Cnt;
                    sel.sel_price = Util.GetSafeInt(row.Price);
                    sel.sel_no = new BsonArray();
                    sel.sel_no.Add(row.OptionNo);

                    selections.Add(sel);
                }
            }

            return selections;
        }