public static ValidationResult ValidateDate(eBayItemSearchModel model)
        {
            if (!model.DateTo.HasValue || !model.DateFrom.HasValue) return ValidationResult.Success;

            if (model.DateFrom > model.DateTo) return new ValidationResult("시작일은 종료일보다 앞선 날짜여야 합니다.");

            return ValidationResult.Success;
        }
        public static ValidationResult ValidatePrice(eBayItemSearchModel model)
        {
            //둘 중 하나라도 없을 때는 유효성 검증 필요없음
            if (!model.PriceTo.HasValue || !model.PriceFrom.HasValue) return ValidationResult.Success;

            if (model.PriceFrom > model.PriceTo) return new ValidationResult("시작가격은 종료가격보다 작아야합니다.");

            return ValidationResult.Success;
        }
Exemplo n.º 3
0
        /// <summary>
        /// eBay 상품리스트 조회 (by ViewModel)
        /// </summary>
        /// <param name="ta_id"> 해당 TA</param>
        /// <param name="searchCriteria">검색조건 </param>
        /// <returns></returns>
        public MongoPagingResult<eBayItemsData> List(string ta_id, eBayItemSearchModel searchCriteria)
        {
            int page = searchCriteria.Page.HasValue ? searchCriteria.Page.Value : 1;
            int rows = searchCriteria.Rows.HasValue ? searchCriteria.Rows.Value : 10;
            List<QueryComplete> param = new List<QueryComplete>();

            //상품상태
            param.Add(Query.EQ("stat", searchCriteria.Status));

            //카테고리
            if (searchCriteria.Site.HasValue)
            {
                param.Add(Query.EQ("site", searchCriteria.Site.Value));
                //site가 없으면 category도 읎따
                if (searchCriteria.CategoryID.HasValue) param.Add(Query.EQ("dynamicData.PrimaryCategoryID", searchCriteria.CategoryID.Value));
            }

            //기간별 조회
            if (searchCriteria.DateType.Equals(DateTypes.RegDate))
            {
                if (searchCriteria.DateFrom.HasValue) param.Add(Query.GTE("list_sdate", searchCriteria.DateFrom.Value));
                if (searchCriteria.DateTo.HasValue) param.Add(Query.LTE("list_sdate", searchCriteria.DateTo.Value));
            }
            else
            {
                if (searchCriteria.DateFrom.HasValue) param.Add(Query.GTE("udate", searchCriteria.DateFrom.Value));
                if (searchCriteria.DateTo.HasValue) param.Add(Query.LTE("udate", searchCriteria.DateTo.Value));
            }

            //TA 조회
            if (!String.IsNullOrWhiteSpace(ta_id))
            {
                //상품관리(리스팅상품)의 경우 해당 ta(자신)의 상품만 리스팅됨
                param.Add(Query.EQ("ta", ta_id));
            }

            //판매방식
            if (searchCriteria.SellingType.HasValue)
            {
                //전체가 아닌 경우에만 검색 조건을 건다
                if (!searchCriteria.SellingType.Value.Equals(SellingTypes.All)) param.Add(Query.EQ("dynamicData.ListingType", searchCriteria.SellingType.ToString()));
            }

            //eBay 계정
            if (!String.IsNullOrWhiteSpace(searchCriteria.eBayAccount))
            {
                param.Add(Query.EQ("ebay_acnt", searchCriteria.eBayAccount));
            }

            //가격 검색
            if (searchCriteria.PriceType.HasValue && searchCriteria.PriceType.Value.Equals(PriceTypes.eBay))
            {
                //TODO 원래는 고정가, 경매가에 대해서 가격 field를 따로 비교해야 할 것 같은데... PRD에 정의 없음.
                if (searchCriteria.PriceFrom.HasValue) param.Add(Query.GTE("dynamicData.StartPrice", (float)searchCriteria.PriceFrom.Value));
                if (searchCriteria.PriceTo.HasValue) param.Add(Query.LTE("dynamicData.StartPrice", (float)searchCriteria.PriceTo.Value));
            }
            //TODO GEP, GMKT 가격검색 조건에 대해서 코드 추가

            //키워드 검색
            if (searchCriteria.KeywordType.HasValue && !string.IsNullOrWhiteSpace(searchCriteria.Keyword))
            {
                switch (searchCriteria.KeywordType.Value)
                {
                    case KeywordTypes.GepCode:
                        param.Add(Query.EQ("gep_id", Util.GetSafeLong(searchCriteria.Keyword)));
                        break;
                    case KeywordTypes.eBayItemId:
                        param.Add(Query.EQ("itemno", searchCriteria.Keyword));
                        break;
                    case KeywordTypes.GEPTA:
                        param.Add(Query.EQ("gep_info.ta", searchCriteria.Keyword));
                        break;
                    case KeywordTypes.UpdateTA:
                        param.Add(Query.EQ("ta", searchCriteria.Keyword));
                        break;
                    case KeywordTypes.CloneItemId:
                        param.Add(Query.EQ("cln_itemno", searchCriteria.Keyword));
                        break;
                }
            }

            QueryComplete query = null;
            int take = rows;
            int skip = (page - 1) * rows;
            IMongoSortBy sort = SortBy.Descending("_id");

            if (param.Count > 0) query = Query.And(param.ToArray());
            return new eBayItemDac().List(query, take, skip, sort);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 판매중지 요청 내역 리스트
        /// </summary>
        public MongoPagingResult<eBayItemsData> StopRequestList(string ta_id, eBayItemSearchModel searchCriteria)
        {
            int page = searchCriteria.Page.HasValue ? searchCriteria.Page.Value : 1;
            int rows = searchCriteria.Rows.HasValue ? searchCriteria.Rows.Value : 10;
            List<QueryComplete> param = new List<QueryComplete>();
            param.Add(Query.EQ("stat", eBayItemStat.Listing));
            param.Add(Query.Exists("stopreq", true));
            param.Add(Query.Exists("stopreq.is_req", true));
            param.Add(Query.EQ("stopreq.is_req", true));

            if (searchCriteria.DateFrom.HasValue && searchCriteria.DateTo.HasValue)
                param.Add(Query.GTE("stopreq.reqdate", searchCriteria.DateFrom.Value).LTE(searchCriteria.DateTo.Value));

            if (searchCriteria.Reason.HasValue)
                param.Add(Query.EQ("stopreq.reason", searchCriteria.Reason.Value));

            if (searchCriteria.KeywordType.HasValue && !string.IsNullOrWhiteSpace(searchCriteria.Keyword))
            {
                switch (searchCriteria.KeywordType.Value)
                {
                    case KeywordTypes.GepCode:
                        param.Add(Query.EQ("gep_id", Util.GetSafeLong(searchCriteria.Keyword)));
                        break;
                    case KeywordTypes.CloneItemId:
                        param.Add(Query.EQ("cln_itemno", searchCriteria.Keyword));
                        break;
                }
            }

            QueryComplete query = null;
            int take = rows;
            int skip = (page - 1) * rows;
            IMongoSortBy sort = SortBy.Descending("_id");

            if (param.Count > 0) query = Query.And(param.ToArray());
            return new eBayItemDac().List(query, take, skip, sort);
        }
Exemplo n.º 5
0
 private dynamic ParseSearchResult(eBayItemSearchModel query, MongoPagingResult<eBayItemsData> queryResult)
 {
     if (query.Status.Equals(eBayItemStat.Raw)) return GenerateRawListSearchResult(query, queryResult);
     else if (query.Status.Equals(eBayItemStat.Wait)) return GenerateWaitingListSearchResult(query, queryResult);
     else if (query.Status.Equals(eBayItemStat.Listing)) return GenerateLitingListSearchResult(query, queryResult);
     else return null;
 }
Exemplo n.º 6
0
        private dynamic GenerateWaitingListSearchResult(eBayItemSearchModel query, MongoPagingResult<eBayItemsData> queryResult)
        {
            return new
            {
                total = Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(queryResult.Count) / 10)),
                page = query.Page.Value,
                rows = (from e in queryResult.Result
                        select new
                        {
                            GepImage = e.gep_info.img,
                            GepId = e.gep_id,
                            eBayCategory = e.dynamicData.PrimaryCategoryPath,
                            GepName = e.gep_info.src_name,
                            eBayName = e.dynamicData.Title,
                            eBaySellType = e.dynamicData.ListingType,
                            Site = e.site_name,
                            StockQty = e.dynamicData.Quantity,
                            eBaySellPrice = e.dynamicData.StartPrice,
                            Delivery = e.dynamicData.ShippingService,
                            GmktItemNo = e.gep_info.src_no,
                            SelectionName = Util.GetSafeString(e.gep_info.sel_name, ""),
                            GepSellPrice = e.gep_info.src_tot_price,
                            GepInsertTA = e.gep_info.ta,
                            UpdateTA = e.ta,
                            UpdateDate = e.udate.ToShortDateString().Replace("0001-01-01", ""),
                            ListingDate = e.list_sdate.ToShortDateString().Replace("0001-01-01", ""),
                            GmktVerify = e.gep_info.src_ver_code,
                            eBayVerify = e.ver_code,
                            _ID = e._id.ToString()

                        }).ToArray()
            };
        }
Exemplo n.º 7
0
        private dynamic GenerateLitingListSearchResult(eBayItemSearchModel query, MongoPagingResult<eBayItemsData> queryResult)
        {
            return new
            {
                total = Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(queryResult.Count) / 10)),
                page = query.Page.Value,
                rows = (from e in queryResult.Result
                        select new
                        {
                            Image = e.img,
                            ItemId = e.itemno,
                            Name = e.dynamicData.Title,
                            Category = e.dynamicData.PrimaryCategoryPath,
                            SellType = e.dynamicData.ListingType,
                            Site = e.site_name,
                            SiteId = e.site,
                            StockQty = e.dynamicData.Quantity,
                            OrderQty = 0,
                            Delivery = e.dynamicData.ShippingService,
                            InsertionFee = e.ins_fee,
                            FeatureFee = e.feat_fee,
                            GepCode = e.gep_id,
                            GepName = e.gep_info.src_name,
                            GepRegDate = e.gep_info.rdate.ToShortDateString().Replace("0001-01-01", ""),
                            GepInsertTA = e.gep_info.ta,
                            ListingStart = e.list_sdate.ToShortDateString().Replace("0001-01-01", ""),
                            ListingEnd = e.list_edate.ToShortDateString().Replace("0001-01-01", ""),
                            ListingDays = e.dynamicData.ListingDuration,
                            UpdTA = e.ta,
                            UpdDate = e.udate.ToShortDateString().Replace("0001-01-01", ""),
                            eBayAccount = e.ebay_acnt,
                            Id = e._id.ToString()

                            //e.prc != null ? e.prc.d + "." + e.prc.c : "0",

                        }).ToArray()
            };
        }