示例#1
0
        public TradeDataInfo(Trade trade)
        {
            mID = trade.Tid;
            mOldBuyerMessage = trade.BuyerMessage;
            mNewBuyerMessage = trade.BuyerMessage;

            TradeData tradeData = Global.TradeDataContainer.GetItem(mID);
            if (tradeData != null)
                mNewBuyerMessage = tradeData.BuyerMessage;
        }
        public LogisticsSendInfo(Trade trade)
        {
            mID = trade.Tid;
            mReceiverName = trade.ReceiverName;

            if (trade.ReceiverAddress.StartsWith(trade.ReceiverState))
                mReceiverAddress = trade.ReceiverAddress;
            else
                mReceiverAddress = trade.ReceiverState + trade.ReceiverCity + trade.ReceiverDistrict + trade.ReceiverAddress;
        }
示例#3
0
 public bool IsSubTrade(Trade trade)
 {
     return mMainTrade.BuyerNick == trade.BuyerNick &&
         mMainTrade.ReceiverName == trade.ReceiverName &&
         mMainTrade.ReceiverState == trade.ReceiverState &&
         mMainTrade.ReceiverCity == trade.ReceiverCity &&
         mMainTrade.ReceiverDistrict == trade.ReceiverDistrict &&
         mMainTrade.ReceiverAddress == trade.ReceiverAddress &&
         mMainTrade.ReceiverZip == trade.ReceiverZip;
 }
示例#4
0
        void AddTradeInternal(Trade trade)
        {
            if (!String.IsNullOrEmpty(trade.SellerMemo))
            {
                if (!String.IsNullOrEmpty(mSellerMemo))
                    mSellerMemo += ";";
                mSellerMemo += trade.SellerMemo;
            }

            String buyerMessage = GetBuyerMessage(trade);
            if (!String.IsNullOrEmpty(buyerMessage))
            {
                if (!String.IsNullOrEmpty(mBuyerMessage))
                    mBuyerMessage += ";";
                mBuyerMessage += buyerMessage;
            }

            mOrders.AddRange(trade.Orders);
        }
示例#5
0
 /// <summary>
 /// 获取某个订单的详情
 /// </summary>
 /// <param name="tid">trade id</param>
 /// <param name="sessionKey"></param>
 /// <param name="error">如果出错,则储存错误信息,否则为空。</param>
 /// <returns>如果操作成功,则返回true。否则为false。</returns>
 public static bool GetTrade(int tid, string sessionKey, out Trade trade)
 {
     bool isSuccess = false;
     trade = null;
     try
     {
         ITopClient client = new DefaultTopClient(Constants.ApiUrl, Constants.AppKey, Constants.AppSecret);
         TradeFullinfoGetRequest req = new TradeFullinfoGetRequest();
         req.Fields = tradeFieldList;
         req.Tid = tid;
         TradeFullinfoGetResponse rsp = client.Execute(req, sessionKey);
         trade = rsp.Trade;
         isSuccess = true;
     }
     catch (Exception ex)
     {
         errorMsg = ex.Message;
     }
     return isSuccess;
 }
        private PurchaseOrderInfo GetPurchaseOrder(Trade trade)
        {
            PurchaseOrderInfo info = new PurchaseOrderInfo();

            info.PurchaseOrderId = "MPO" + trade.Tid.ToString();
            info.TaobaoOrderId = trade.Tid.ToString();
            info.ShipTo = trade.ReceiverName;
            info.ShippingRegion = trade.ReceiverState + trade.ReceiverCity + trade.ReceiverDistrict;
            info.RegionId = RegionHelper.GetRegionIdByName(trade.ReceiverState, trade.ReceiverCity, trade.ReceiverDistrict);
            info.Address = trade.ReceiverAddress;
            info.TelPhone = trade.ReceiverPhone;
            info.ZipCode = trade.ReceiverZip;
            info.CellPhone = trade.ReceiverMobile;
            info.ShippingModeId = shippingMode.ModeId;
            info.ModeName = shippingMode.Name;
            info.RealShippingModeId = shippingMode.ModeId;
            info.RealModeName = shippingMode.Name;
            info.AdjustedDiscount = 0M;
            info.OrderTotal = decimal.Parse(trade.Payment);
            int totalWeight = 0;

            foreach (Order order in trade.Orders)
            {

                DataTable skuContent = SubSiteProducthelper.GetSkuContent(order.NumIid, order.OuterSkuId);

                if ((skuContent != null) && (skuContent.Rows.Count > 0))
                {
                    PurchaseOrderItemInfo item = new PurchaseOrderItemInfo();

                    foreach (DataRow row in skuContent.Rows)
                    {
                        if (!(string.IsNullOrEmpty(row["AttributeName"].ToString()) || string.IsNullOrEmpty(row["ValueStr"].ToString())))
                        {
                            object sKUContent = item.SKUContent;
                            item.SKUContent = string.Concat(new object[] { sKUContent, row["AttributeName"], ":", row["ValueStr"], "; " });
                        }
                    }
                    item.PurchaseOrderId = info.PurchaseOrderId;
                    item.SkuId = (string)skuContent.Rows[0]["SkuId"];
                    item.ProductId = (int)skuContent.Rows[0]["ProductId"];
                    if (skuContent.Rows[0]["SKU"] != DBNull.Value)
                    {
                        item.SKU = (string)skuContent.Rows[0]["SKU"];
                    }
                    if (skuContent.Rows[0]["Weight"] != DBNull.Value)
                    {
                        item.ItemWeight = (int)skuContent.Rows[0]["Weight"];
                    }
                    item.ItemPurchasePrice = (decimal)skuContent.Rows[0]["PurchasePrice"];
                    item.Quantity = int.Parse(order.Num.ToString());
                    item.ItemListPrice = (decimal)skuContent.Rows[0]["SalePrice"];
                    if (skuContent.Rows[0]["CostPrice"] != DBNull.Value)
                    {
                        item.ItemCostPrice = (decimal)skuContent.Rows[0]["CostPrice"];
                    }
                    item.ItemDescription = (string)skuContent.Rows[0]["ProductName"];
                    item.ItemHomeSiteDescription = (string)skuContent.Rows[0]["ProductName"];
                    if (skuContent.Rows[0]["ThumbnailUrl40"] != DBNull.Value)
                    {
                        item.ThumbnailsUrl = (string)skuContent.Rows[0]["ThumbnailUrl40"];
                    }
                    totalWeight += item.ItemWeight * item.Quantity;
                    info.PurchaseOrderItems.Add(item);
                }
            }
            if (info.PurchaseOrderItems.Count <= 0)
            {
                return null;
            }
            info.Weight = totalWeight;
            info.AdjustedFreight = SubsiteSalesHelper.CalcFreight(info.RegionId, totalWeight, shippingMode);
            info.Freight = info.AdjustedFreight;
            info.PurchaseStatus = OrderStatus.WaitBuyerPay;
            info.RefundStatus = RefundStatus.None;
            info.DistributorId = distributor.UserId;
            info.Distributorname = distributor.Username;
            info.DistributorEmail = distributor.Email;
            info.DistributorRealName = distributor.RealName;
            info.DistributorQQ = distributor.QQ;
            info.DistributorWangwang = distributor.Wangwang;
            info.DistributorMSN = distributor.MSN;
            return info;
        }
示例#7
0
        String GetBuyerMessage(Trade trade)
        {
            TradeData tradeData = Global.TradeDataContainer.GetItem(trade.Tid);
            if (tradeData != null && !String.IsNullOrEmpty(tradeData.BuyerMessage))
                return tradeData.BuyerMessage;

            return trade.BuyerMessage;
        }
示例#8
0
        public void AddSubTrade(Trade subTrade)
        {
            mSubTrades.Add(subTrade);

            AddTradeInternal(subTrade);
        }
示例#9
0
 public TradeInfo(Trade mainTrade)
 {
     mMainTrade = mainTrade;
     AddTradeInternal(mMainTrade);
 }
示例#10
0
        static void GetSellerMemo(ITopClient client, Trade trade)
        {
            if (!String.IsNullOrEmpty(trade.SellerMemo))
                return;

            TradeGetRequest req = new TradeGetRequest();
            req.Fields = "seller_memo";
            req.Tid = trade.Tid;

            TradeGetResponse response = client.Execute(req, Global.SessionKey);
            if (response.Trade != null && !String.IsNullOrEmpty(response.Trade.SellerMemo))
                trade.SellerMemo = response.Trade.SellerMemo;
        }
示例#11
0
 public static void TradeOtherDeliver(Trade trade, bool deliver)
 {
     if (deliver)
         ModifyTradeFlag(trade, trade.SellerFlag | (long)Global.FlagBits.FB_OtherDeliver);
     else
         ModifyTradeFlag(trade, trade.SellerFlag & ~(long)Global.FlagBits.FB_OtherDeliver);
 }
示例#12
0
 public static bool TradeOtherDeliver(Trade trade)
 {
     return (trade.SellerFlag & (long)Global.FlagBits.FB_OtherDeliver) != 0;
 }
示例#13
0
 public static void TradeIgnore(Trade trade, bool ignore)
 {
     if (ignore)
         ModifyTradeFlag(trade, trade.SellerFlag | (long)Global.FlagBits.FB_PrintIgnore);
     else
         ModifyTradeFlag(trade, trade.SellerFlag & ~(long)Global.FlagBits.FB_PrintIgnore);
 }
示例#14
0
 public static bool TradeIgnore(Trade trade)
 {
     return (trade.SellerFlag & (long)Global.FlagBits.FB_PrintIgnore) != 0;
 }
示例#15
0
        public static void ModifyTradeFlag(Trade trade, long flag)
        {
            try
            {
                ITopClient client = Global.DefulatClient();
                TradeMemoUpdateRequest req = new TradeMemoUpdateRequest();
                req.Tid = trade.Tid;
                req.Flag = flag;
                TradeMemoUpdateResponse response = client.Execute(req, Global.SessionKey);

                if (response.Trade != null && response.Trade.Tid == trade.Tid)
                    trade.SellerFlag = flag;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }