Example #1
0
        private long GeteBayStopRequest(string taId)
        {
            List<eBayItemsData> data = new eBayItemDac().List(
                 Query.And(
                     Query.EQ("ta", taId),
                     Query.EQ("StopRequest.is_req", true),
                     Query.EQ("StopRequest.is_comp", false)
                 )).ToList();

            return data.Count;
        }
Example #2
0
        /// <summary>
        /// 판매중지 요청정보 저장
        /// </summary>
        /// <param name="_id"></param>
        /// <param name="reason"></param>
        public void SaveStopRequest(string _id, StopRequestReason reason)
        {
            eBayItemsData item = new eBayItemDac().FindOne(_id);
            if (item.stopreq == null) item.stopreq = new StopRequest();
            item.stopreq.is_req = true;
            item.stopreq.reqdate = DateTime.Now;
            item.stopreq.reason = reason;

            new eBayItemDac().Save(item);
        }
Example #3
0
        /// <summary>
        /// ebay_items의 _id 상품에 대하여 판매 중지 요청
        /// </summary>
        /// <param name="id">ebay_items 컬렉션의 id 임. eBay 의 실제 상품 번호 아님!</param>
        /// <returns>
        ///		성공시 Success = true, Message = null
        ///		실패시 Success = false, Messsage = 실패사유
        /// </returns>
        public eBayItemResultBase RequestStopListing(string id)
        {
            eBayItemsData info = new eBayItemDac().View(Query.EQ("_id", ObjectId.Parse(id)));
            if (String.IsNullOrWhiteSpace(info.itemno))
            {
                return new eBayItemResultBase
                {
                    Success = false,
                    Message = "eBay 상품번호가 없어 판매중지요청을 할 수 없습니다."
                };
            }

            if (string.IsNullOrWhiteSpace(info.ebay_acnt))
            {
                return new eBayItemResultBase
                {
                    Success = false,
                    Message = "eBay 계정이 존재하지 않거나 유효한 eBay 계정이 아닙니다."
                };
            }

            //TODO valid한 SiteID인지도 체크 해야되! 근데 valid한 SiteID가 뭔지를 몰라 ㅋㅋㅋㅋㅋ
            var ebayToken = new CommonBiz().GeteBayTokenId(info.ebay_acnt);

            if (String.IsNullOrWhiteSpace(ebayToken))
            {
                return new eBayItemResultBase
                {
                    Success = false,
                    Message = "eBay 계정이 존재하지 않거나 유효한 eBay 계정이 아닙니다."
                };
            }

            var request = new CloseItemRequest
            {
                EbayTokenID = ebayToken,
                ItemID = info.itemno,
                SiteID = info.site
            };

            var response = new ItemService(apiUrl).CloseItem(request);
            if (response.Ack.Equals(AckType.Failure))
            {
                return new eBayItemResultBase
                {
                    Success = false,
                    Message = (from messages in response.Response.Messages
                              select messages[AckType.Failure.ToString()]).ToArray().ToString()
                };
            }

            //TODO 해당 eBay item 판매중지상태로 update
            SaveItemStatus(new ObjectId(id), eBayItemStat.Stop);

            //clone 상품 팔자주문 내리기
            new ItemOrderBiz().DeleteOrder(info.gep_info.src_no, info.gep_info.src_seller.sid, info.gep_info.src_seller.sid);

            return new eBayItemResultBase
            {
                Success = true
            };
        }
Example #4
0
        /// <summary>
        /// eBay Listing 요청
        /// </summary>
        public void RequestListing(List<ObjectId> _ids, string ta_id)
        {
            // G마켓 판매자 동의 확인 (해당 TA에 동의한 판매자 리스트를 들고온다.)
            // new eBayItemBiz().CheckSellerAgreement(ta_id);

            foreach (ObjectId _id in _ids)
            {

                // 상품 상태 및 요청정보 업데이트 (이후 Daemon이 처리)
                eBayItemsData item = new eBayItemDac().View(Query.EQ("_id", _id));
                item.stat = eBayItemStat.Request;
                if (item.listingreq == null) item.listingreq = new ListingRequest();
                item.listingreq.is_comp = false;
                new eBayItemDac().Save(item);
            }

            // Daemon : To Do
            /* 1. 상태가 Request인 상품들을 리스팅 대상 건으로 읽는다.
             * 2. G마켓에 Clone상품을 생성한다.
             * 3. eBay에 리스팅 요청 콜을 보낸다. (forSeller Thrift 통신)
             * 4. 처리된 상품의 정보들을 갱신한다.
             *	- stat = 상품상태 eBayItemStat.Listing으로 변경.
             *	- cln_itemno = G마켓 클론상품 번호 생성 후 저장.
             *	- itemno = eBay 리스팅 성공 시 eBay의 상품번호를 저장.
             *	- list_sdate, list_edate = 리스팅 시작일과 종료일 저장.
             *	- ins_fee, feat_fee = eBay 등록 관련 수수료 저장.
             */
        }
Example #5
0
        /// <summary>
        /// eBayItem을 종료 상태로 수정
        /// </summary>
        /// <param name="id">eBayItem InventoryID</param>
        /// <param name="form">eBayItem ID</param>
        /// <returns></returns>
        public void ItemClose(string inventoryId, string itemId)
        {
            IMongoQuery query = Query.And(Query.EQ("_id", ObjectId.Parse(inventoryId)), Query.EQ("itemno", itemId));
            eBayItemsData item = new eBayItemDac().View(query);

            if (item == null)
            {
                throw new PaymentProcessBizException(-1001, "해당 상품이 없습니다.");
            }

            item.stat = eBayItemStat.Stop;

            if (item.stopreq != null)
            {
                item.stopreq.is_comp = true;
                item.stopreq.compdate = DateTime.Now;
            }
            else
            {
                item.stopreq = new StopRequest();
                item.stopreq.is_comp = true;
                item.stopreq.compdate = DateTime.Now;
                item.stopreq.reason = StopRequestReason.ItemClosed;
            }

            item.udate = DateTime.Now;

            new eBayItemDac().Save(item);
        }
Example #6
0
        public object GetDeadLineItemList(string categoryId = "",
            int price1 = 0, int price2 = 0,
            string periodType = "", string sdate = "", string edate = "",
            string eBayType = "", string eBayId = "", string eBayVerify = "",
            string searchType = "", string searchText = "", int page = 1, string sord = "", string sidx = "")
        {
            List<QueryComplete> param = new List<QueryComplete>();
            param.Add(Query.EQ("stat", eBayItemStat.Stop)); // 상태가 Stop 인것만

            #region 검색조건
            if (categoryId != "")
            {
                param.Add(Query.EQ("dynamicData.PrimaryCategory", categoryId));
            }

            // eBay 등록일
            if (periodType == "r" && sdate != "" && edate != "")
            {
                param.Add(Query.GTE("list_sdate", Convert.ToDateTime(sdate)).LTE(Convert.ToDateTime(edate + " 23:59:59")));
            }
            //  eBay정보수정일
            if (periodType == "e" && sdate != "" && edate != "")
            {
                param.Add(Query.GTE("udate", Convert.ToDateTime(sdate)).LTE(Convert.ToDateTime(edate + " 23:59:59")));
            }
            // 판매타입 고정가 | 경매
            if (eBayType != "")
            {
                param.Add(Query.EQ("type", Util.GetSafeInt(eBayType)));
                // 고정가 가격
                if (eBayType == "FixedPriceItem" && price1 != 0 && price2 != 0)
                {
                    param.Add(Query.GTE("dynamicData.FixedPriceItemStartPrice", price1).LTE(price2));
                }
                //경매가 가격
                if (eBayType == "Chinese" && price1 != 0 && price2 != 0)
                {
                    param.Add(Query.GTE("dynamicData.ChineseBuyItNowPrice", price1).LTE(price2));
                }
            }

            // eBay아이디
            if (eBayId != "")
            {
                param.Add(Query.EQ("ebay_acnt", eBayId));
            }
            // eBay Verify S:0, F:1 추후 코드에 따라 수정 View 페이지 수정 필요할듯
            if (eBayVerify != "")
            {
                param.Add(Query.EQ("ver_code", categoryId));
            }
            if (searchType == "0" && searchText != "") // GEP 상품코드
            {
                param.Add(Query.EQ("gep_id", searchText));
            }
            if (searchType == "1" && searchText != "") // G마켓 상품번호
            {
                param.Add(Query.EQ("gep_info.src_no", searchText));
            }
            if (searchType == "2" && searchText != "") // G마켓 Clone 상품번호 ???
            {
                param.Add(Query.EQ("cln_itemno", searchText));
            }
            if (searchType == "3" && searchText != "") // G마켓 판매자명
            {
                param.Add(Query.EQ("gep_info.src_seller", searchText));
            }
            if (searchType == "4" && searchText != "") // GEP생성자
            {
                param.Add(Query.EQ("gep_info.ta", searchText));
            }
            #endregion
            QueryComplete query = Query.And(param.ToArray());
            MongoPagingResult<eBayItemsData> mongoResult = new eBayItemDac().List(page, query);
            List<eBayItemsData> list = mongoResult.Result.ToList();

            var sortList = from e in list
                           select e;
            #region Sorting 분기
            //Sorting
            if (sidx == "eBayFixPrice")
            {
                if (sord == "asc")
                {
                    sortList = from e in list
                               orderby e.dynamicData.StartPrice ascending
                               select e;
                }
                else
                {
                    sortList = from e in list
                               orderby e.dynamicData.StartPrice descending
                               select e;
                }
            }
            else if (sidx == "eBayChiPrice")
            {
                if (sord == "asc")
                {
                    sortList = from e in list
                               orderby e.dynamicData.BuyItNowPrice ascending
                               select e;
                }
                else
                {
                    sortList = from e in list
                               orderby e.dynamicData.BuyItNowPrice descending
                               select e;
                }
            }
            else if (sidx == "ebayRdate")
            {
                if (sord == "asc")
                {
                    sortList = from e in list
                               orderby e.list_sdate ascending
                               select e;
                }
                else
                {
                    sortList = from e in list
                               orderby e.list_sdate descending
                               select e;
                }
            }
            else if (sidx == "ebayEdate")
            {
                if (sord == "asc")
                {
                    sortList = from e in list
                               orderby e.list_edate ascending
                               select e;
                }
                else
                {
                    sortList = from e in list
                               orderby e.list_edate descending
                               select e;
                }
            }
            #endregion
            var result = new
            {
                totalCount = mongoResult.Count,
                total = Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(mongoResult.Count) / 10)),
                page = page,
                sord = sord,
                rows = (from e in sortList
                        select new
                        {
                            ck = "",
                            img = e.img,
                            _id = e._id.ToString(),
                            verifyCode = e.ver_code,
                            state = e.stat,
                            gepCode = e.gep_id,
                            eBayCategory = e.dynamicData.PrimaryCategoryPath,
                            gepName = e.gep_info.src_name,
                            eBayItemId = e.itemno,
                            eBayName = string.Format("{0}<br /><a href='/eBayItems/edit?id={1}'>[상품정보수정]</a>", e.dynamicData.Title, e._id),
                            site = e.site_name,
                            sellQty = e.dynamicData.Quantity,
                            orderQty = e.dynamicData.Quantity, // ???
                            eBayFixPrice = e.dynamicData.StartPrice,
                            eBayChiPrice = e.dynamicData.BuyItNowPrice,
                            delivery = e.dynamicData.ShippingService,
                            insertion = e.ins_fee == null ? "0" : string.Format("{0}.{1}", e.ins_fee.d, e.ins_fee.c),
                            feature = e.feat_fee == null ? "0" : string.Format("{0}.{1}", e.feat_fee.d, e.feat_fee.c),
                            gmarketNo = e.gep_info.src_no,
                            clonNo = e.cln_itemno,
                            selName = e.gep_info.sel_name,
                            gmarketPrice = e.gep_info.src_price,
                            gepRdate = e.gep_info.rdate.ToShortDateString(),
                            gepRname = e.gep_info.ta,
                            ebayRdate = e.list_sdate.ToShortDateString(),
                            ebayEdate = e.list_edate.ToShortDateString(),
                            period = e.dynamicData.ListingDuration,
                            eBayEdate = e.udate.ToShortDateString(),
                            eBayVerify = string.Format("<span style=\"cursor:pointer;\" onclick=\"ItemList.eBayItemVerify('{0}');\" class=\"label label-info\">eBay Verify</span><br />{1}"
                                , e._id.ToString()
                                , e.ver_code == "성공" ? e.ver_code : string.Format("<span style=\"cursor:pointer;text-decoration:underline;\" onclick=\"ItemList.eBayItemVerifyView('{0}');\">{1}</span>", e._id.ToString(), e.ver_code)
                                ),
                            useYn = e.stat == eBayItemStat.Listing ? "Y" : "N",
                        }
                            ).ToArray()
            };

            return result;
        }
Example #7
0
        /// <summary>
        /// eBay Verify
        /// </summary>
        public eBayItemVerifyResult Verify(string _id, string ta_id)
        {
            eBayItemsData info = new eBayItemDac().View(Query.EQ("_id", ObjectId.Parse(_id)));

            VerifyItemRequest req = new VerifyItemRequest();

            req.SiteID = info.site;
            req.EbayTokenID = new CommonBiz().GeteBayToken(info.ebay_acnt);
            if (info.itemno != null) req.InventoryID = Util.GetSafeString(info.itemno);

            JsonWriterSettings jset = new JsonWriterSettings();
            jset.OutputMode = JsonOutputMode.JavaScript;
            req.EbayItemInfo = Util.EncodeUTF8To64(info.dynamicData.ToJson<eBayItemsDataForSeller>(jset)); // base64(json)로 데이터 생성

            eBayItemVerifyResult result = new eBayItemVerifyResult();
            VerifyItemResponse res = new VerifyItemResponse();

            try
            {
                res = new ItemService(apiUrl).VerifyItem(req);
                if (res.Ack == AckType.Success) // Thrift 통신 성공
                {
                    if (res.Response.Ack == AckType.Success) // Verify 결과
                    {
                        result.Success = true;
                        result.Message = "Verify 성공하였습니다.";
                    }
                    else
                    {
                        result.Success = false;
                        result.Message = "";
                        foreach (Dictionary<string, string> msg in res.Response.Messages)
                        {
                            foreach (string key in msg.Keys)
                            {
                                result.Message += "[" + key + "] " + msg[key] + "\n";
                            }
                        }
                    }
                }
                else
                {
                    result.Success = false;
                    result.Message = "Thrift 통신에 실패하였습니다.";
                }
            }
            catch (ThriftClientException tce)
            {
                result.Success = false;
                //result.Message = "알 수 없는 오류로 인하여 eBay 상품 Verify에 실패하였습니다.";
                result.Message = tce.Message;
            }
            catch (ThriftException te)
            {
                result.Success = false;
                //result.Message = "알 수 없는 오류로 인하여 eBay 상품 Verify에 실패하였습니다.";
                result.Message = te.ExceptionMessage;
            }
            catch (Exception ex)
            {
                result.Success = false;
                //result.Message = "알 수 없는 오류로 인하여 eBay 상품 Verify에 실패하였습니다.";
                result.Message = ex.Message;
            }

            // Verify 결과 저장
            // 심민섭 수정
            // 실패시 메세지 저장
            string ver_code = result.Success == true ? "성공" : "실패";
            new eBayItemDac().Save(Query.EQ("_id", ObjectId.Parse(_id)), Update.Set("ver_code", ver_code).Set("ver_message", result.Message));

            return result;
        }
Example #8
0
        /// <summary>
        /// eBay 리스팅된 결과를 업데이트 한다.
        /// </summary>
        /// <param name="Data">eBay리스팅 결과</param>
        /// <returns></returns>
        public bool SetItemListingResult(ItemListingResult data)
        {
            //비교값이 없으면 에러
            if (string.IsNullOrEmpty(data.InventoryID)) return false;

            eBayItemsData item = new eBayItemDac().FindOne(data.InventoryID);

            if (item == null) return false;

            //초기화
            item.listingreq = new ListingRequest();

            //리스팅 실패시
            if (data.Ack == eBayAckType.Failure)
            {
                item.listingreq.is_comp = true;
                item.listingreq.success = false;
                item.listingreq.message = "eBay 리스팅 실패(콜백 결과)";
            }
            //리스팅 성공시
            else
            {
                item.itemno = data.ItemID;
                item.listingreq.is_comp = true;
                item.listingreq.success = true;
                item.stat = eBayItemStat.Listing;

                item.list_sdate = Util.GetSafeDateTime(data.StartTime, DateTime.Parse("1999-01-01"));
                item.list_edate = Util.GetSafeDateTime(data.EndTime, DateTime.Parse("1999-01-01"));

                //수수료 저장
                var q = (from k in data.Fees
                         where k.Key == "FeaturedFee"
                         select k).ToList();
                if (q.Count() == 1)
                {
                    string fee = q[0].Value;
                    string[] tempFee = fee.Split('.');
                    int d = Util.GetSafeInt(tempFee[0], 0);
                    int c = 0;

                    if (tempFee.Count() == 2)
                    {
                        c = Util.GetSafeInt(tempFee[1], 0);
                    }
                    item.feat_fee = new USD() { d = d, c = c };
                }

                q = (from k in data.Fees
                         where k.Key == "InsertionFee"
                         select k).ToList();
                if (q.Count() == 1)
                {
                    string fee = q[0].Value;
                    string[] tempFee = fee.Split('.');
                    int d = Util.GetSafeInt(tempFee[0], 0);
                    int c = 0;

                    if (tempFee.Count() == 2)
                    {
                        c = Util.GetSafeInt(tempFee[1], 0);
                    }
                    item.ins_fee = new USD() { d = d, c = c };
                }

            }

            item.listingresult = data;
            new eBayItemBiz().SaveItem(item);

            return true;
        }
Example #9
0
        public int SetItemConvertStopRequest(List<string> expireEbayId, StopRequestReason reason)
        {
            int result = 0;

            List<QueryComplete> param = new List<QueryComplete>();
            foreach (var arrIdx in expireEbayId)
            {
                param.Add(Query.EQ("ebay_acnt", arrIdx));
            }
            QueryComplete query = Query.Or(param.ToArray());

            // eBay item 읽어온후
            List<eBayItemsData> eBayItemList = new eBayItemDac().List(query).ToList();
            foreach (var listItem in eBayItemList)
            {
                if (listItem.stopreq != null)
                {
                    if (!listItem.stopreq.is_req)
                    {
                        StopRequest stopReauest = new StopRequest();
                        stopReauest.is_req = true;
                        stopReauest.reqdate = DateTime.Now;
                        stopReauest.reason = reason;

                        listItem.stopreq = stopReauest;
                        new eBayItemDac().Save(listItem);
                        result++;
                    }
                }
                else
                {
                    StopRequest stopReauest = new StopRequest();
                    stopReauest.is_req = true;
                    stopReauest.reqdate = DateTime.Now;
                    stopReauest.reason = reason;

                    listItem.stopreq = stopReauest;
                    new eBayItemDac().Save(listItem);
                    result++;
                }
            }
            return result;
        }
Example #10
0
        public GmarketVerifyDataClone GmarketVerifyCloneId(string cloneId)
        {
            GmarketVerifyDataClone resultVerify = new GmarketVerifyDataClone();

            eBayItemsData data = new eBayItemDac().View(Query.EQ("cln_itemno", cloneId));

            string statusResult = ItemCompareStatus(data.gep_info.src_no);
            string selResult = "S";
            if (data.gep_info.sel_no != null)
            {
                selResult = ItemCompareSelItem(data.gep_info.sel_no, data.gep_info.sel_qty, data.gep_info.sel_price);
            }
            string itemResult = ItemCompareGepItem(data.gep_info.src_no, data.gep_info.src_qty, data.gep_info.src_price);
            string itemSettleResult = ItemCompareSettleMoney(data.gep_info.src_no, data.gep_info.src_settle_price);
            string itemDeliveryCondition = ItemCompareDeliveryCondition(data.gep_info.src_no, data.gep_info.dlv_fee_cond);

            if (statusResult != "S" || selResult != "S" || itemResult != "S" || itemSettleResult != "S" || itemDeliveryCondition != "S")
            {
                string errorMessage = string.Empty;
                errorMessage = ErrorCase(statusResult);
                errorMessage += ErrorCase(selResult);
                errorMessage += ErrorCase(itemResult);
                errorMessage += ErrorCase(itemDeliveryCondition);

                resultVerify.Result = false;
                resultVerify.Message = errorMessage;
            }
            else
            {
                resultVerify.Result = true;
                resultVerify.Message = "";
            }

            return resultVerify;
        }