예제 #1
0
 public static VasSubscribeGetResponse GetSellerSubscrib(string sellerNick, string articleCode)
 {
     try
     {
         ITopClient             client = TBManager.GetClient();
         VasSubscribeGetRequest req    = new VasSubscribeGetRequest();
         req.Nick        = sellerNick;
         req.ArticleCode = articleCode;
         VasSubscribeGetResponse response = client.Execute(req);
         return(response);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
         return(null);
     }
 }
예제 #2
0
 public global::Top.Api.Domain.Shop Get(string parameter, int pageIndex, int pageNum, long total)
 {
     try
     {
         ITopClient     client = TBManager.GetClient();
         ShopGetRequest req    = new ShopGetRequest();
         req.Fields = "sid,cid,nick,title,desc,bulletin,pic_path,created,modified,shop_score";
         req.Nick   = Users.Nick;
         ShopGetResponse response = client.Execute(req, Users.SessionKey);
         return(response.Shop);
     }
     catch (Exception ex)
     {
         CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TBApply_Components);
         return(null);
     }
 }
예제 #3
0
 public Trade GetBuyerInfoByTid(long tid)
 {
     try
     {
         ITopClient client           = TBManager.GetClient();
         TradeFullinfoGetRequest req = new TradeFullinfoGetRequest();
         req.Fields = "receiver_name,receiver_mobile,status";
         req.Tid    = tid;
         TradeFullinfoGetResponse response = client.Execute(req, Users.SessionKey);
         return(response.Trade);
     }
     catch (Exception ex)
     {
         CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #4
0
 /// <summary>
 /// 获取前台展示的店铺内卖家自定义商品类目
 /// </summary>
 /// <param name="sessionKey"></param>
 /// <param name="sellerNick"></param>
 /// <returns></returns>
 public static List <ShopCat> GetCatsList(string sessionKey, string sellerNick)
 {
     try
     {
         ITopClient             client = TBManager.GetClient();
         ShopcatsListGetRequest req    = new ShopcatsListGetRequest();
         //req.Nick = sellerNick;
         req.Fields = "cid,name";
         ShopcatsListGetResponse response = client.Execute(req, sessionKey);
         return(response.ShopCats);
     }
     catch (Exception ex)
     {
         //ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #5
0
 /// <summary>
 /// 获取单个商品详细信息
 /// </summary>
 /// <param name="sessionKey"></param>
 /// <param name="itemNo"></param>
 /// <returns></returns>
 public static Item GetItemByID(string sessionKey, string itemNo)
 {
     try
     {
         ITopClient           client = TBManager.GetClient();
         ItemSellerGetRequest req    = new ItemSellerGetRequest();
         req.NumIid = Convert.ToInt64(itemNo);
         req.Fields = "pic_url,detail_url,title, price, sold_quantity";
         ItemSellerGetResponse response = client.Execute(req, sessionKey);
         return(response.Item);
     }
     catch (Exception ex)
     {
         //ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #6
0
 /// <summary>
 /// 只能获取到三个月以内的交易信息
 /// TradesSoldGetRequest 获取单笔交易的详细信息
 /// </summary>
 /// <param name="sellerNick">根据买家昵称获取交易信息</param>
 /// <param name="buyerNick"></param>
 /// <returns></returns>
 public List <Trade> GetBuyerTrade(string strSessionKey, string buyerNick)
 {
     try
     {
         ITopClient           client = TBManager.GetClient();
         TradesSoldGetRequest req    = new TradesSoldGetRequest();
         req.Fields    = @"tid,buyer_nick,seller_nick,receiver_name,receiver_state,receiver_city,receiver_district,receiver_address,receiver_mobile,buyer_email";
         req.BuyerNick = buyerNick;
         TradesSoldGetResponse response = client.Execute(req, strSessionKey);
         return(response.Trades);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #7
0
 /// <summary>
 /// 订单关闭
 /// </summary>
 /// <param name="tid"></param>
 /// <param name="reason"></param>
 /// <returns></returns>
 public Trade CloseOrderByTradeID(long tid, string reason)
 {
     try
     {
         ITopClient        client = TBManager.GetClient();
         TradeCloseRequest req    = new TradeCloseRequest();
         req.Tid         = tid;
         req.CloseReason = reason;
         TradeCloseResponse response = client.Execute(req, Users.SessionKey);
         return(response.Trade);
     }
     catch (Exception ex)
     {
         CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #8
0
        public List <ItemProp> Shop(long cid)
        {
            ItempropsGetResponse response = null;

            try
            {
                ITopClient          client = TBManager.GetClient();
                ItempropsGetRequest req    = new ItempropsGetRequest();
                req.Fields = "pid,name,must,multi,prop_values";
                req.Cid    = cid;
                response   = client.Execute(req, Users.SessionKey);
            }
            catch (Exception ex)
            {
                CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TBApply_Components);
            }
            return(response.ItemProps);
        }
예제 #9
0
 /// <summary>
 /// 自己联系物流(线下物流)发货
 /// </summary>
 /// <param name="strSessionKey"></param>
 /// <param name="tid"></param>
 /// <param name="outSid"></param>
 /// <param name="companyCode"></param>
 /// <returns></returns>
 public static Boolean LogisticsOfflineSend(string strSessionKey, string tid, string outSid, string companyCode)
 {
     try
     {
         ITopClient client = TBManager.GetClient();
         LogisticsOfflineSendRequest req = new LogisticsOfflineSendRequest();
         req.Tid         = long.Parse(tid);
         req.OutSid      = outSid;
         req.CompanyCode = companyCode;
         LogisticsOfflineSendResponse rsp = client.Execute(req, strSessionKey);
         return(rsp.Shipping.IsSuccess);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(false);
     }
 }
예제 #10
0
 public static void StartNotify()
 {
     if (!AppCusBLL.CheckAppCusIsExit(Users.Nick))
     {
         ITopClient            client   = TBManager.GetClient();
         TmcUserPermitRequest  req      = new TmcUserPermitRequest();
         TmcUserPermitResponse response = client.Execute(req, Users.SessionKey);
         AppCustomer           appCus   = null;
         if (response.IsSuccess)
         {
             appCus         = new AppCustomer();
             appCus.Status  = "1";
             appCus.Nick    = Users.Nick;
             appCus.Created = DateTime.Now.ToShortDateString();
             AppCusBLL.AddAppCus(appCus);
         }
     }
 }
예제 #11
0
 /// <summary>
 /// 获取当前会话用户出售中的商品列表
 /// </summary>
 /// <param name="strSessionKey"></param>
 /// <returns></returns>
 public static List <Item> GetItemsOnSale(string strSessionKey, string pageSize, string pageNo)
 {
     try
     {
         ITopClient            client = TBManager.GetClient();
         ItemsOnsaleGetRequest req    = new ItemsOnsaleGetRequest();
         req.Fields   = @"num_iid,outer_id,bar_code,price,seller_cids,pic_url,title";
         req.PageNo   = long.Parse(pageNo);
         req.PageSize = long.Parse("200");
         ItemsOnsaleGetResponse rsp = client.Execute(req, strSessionKey);
         return(rsp.Items);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #12
0
 public static Boolean orderBatchSending(string tid, string yundanID, string companyCode)
 {
     try
     {
         ITopClient client = TBManager.GetClient();
         LogisticsOfflineSendRequest req = new LogisticsOfflineSendRequest();
         req.Tid = Convert.ToInt64(tid);
         //req.SubTid = "1,2,3";
         //req.IsSplit = 0L;
         req.OutSid      = yundanID;
         req.CompanyCode = companyCode;
         LogisticsOfflineSendResponse response = client.Execute(req, Users.SessionKey);
         return(response.Shipping.IsSuccess);
     }
     catch (Exception ex)
     {
         CHENGTUAN.Components.ExceptionReporter.WriteLog(ex, CHENGTUAN.Entity.ExceptionPostion.TopApi);
         return(false);
     }
 }
예제 #13
0
        /// <summary>
        /// 获取单笔交易的详细信息
        /// </summary>
        /// <param name="strSessionKey"></param>
        /// <param name="tid"></param>
        /// <returns></returns>
        public static Trade GetTradeByTid(string strSessionKey, string tid)
        {
            try
            {
                ITopClient client           = TBManager.GetClient();
                TradeFullinfoGetRequest req = new TradeFullinfoGetRequest();
                req.Fields = @"tid,type,buyer_nick,receiver_name,receiver_state,receiver_city,receiver_district,receiver_address,
               receiver_mobile,receiver_phone,receiver_zip,buyer_area,post_fee,created,seller_nick,payment,status,shipping_type,pay_time,modified,
orders.outer_iid,orders.discount_fee,orders.payment,orders.refund_status,orders.status,orders.pic_path,orders.sku_properties_name,orders.adjust_fee,
orders.outer_sku_id,orders.cid,orders.refund_id,orders.item_meal_name,orders.num,orders.title,orders.price,orders.oid,orders.total_fee,orders.num_iid,orders.sku_id,orders.seller_type";
                req.Tid    = long.Parse(tid);
                TradeFullinfoGetResponse rsp = client.Execute(req, strSessionKey);
                return(rsp.Trade);
            }
            catch (Exception ex)
            {
                ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
                return(null);
            }
        }
예제 #14
0
 /// <summary>
 /// 调用API进行批量评价
 /// </summary>
 /// <param name="currentPage"></param>
 /// <param name="pagesize"></param>
 /// <param name="total"></param>
 /// <returns></returns>
 public TradeRate BuyerTradeRate(RateConfig rateObj, ref string content)
 {
     try
     {
         ITopClient client           = TBManager.GetClient();
         TraderateListAddRequest req = new TraderateListAddRequest();
         req.Tid    = rateObj.Tid;
         req.Result = rateObj.Result;
         req.Role   = "seller";
         string[] strs = { rateObj.Content1, rateObj.Content2, rateObj.Content3 };//随机选择评价内容
         Random   rand = new Random(System.Guid.NewGuid().GetHashCode());
         req.Content = strs[rand.Next(0, strs.Length)];
         content     = req.Content;
         TraderateListAddResponse response = client.Execute(req, Users.SessionKey);
         return(response.TradeRate);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #15
0
 /// <summary>
 /// 搜索评价信息:只能获取距今180天内的评价记录(只支持查询卖家给出或得到的评价)
 /// </summary>
 /// <param name="rateObj"></param>
 /// <returns></returns>
 public List <TradeRate> GetTradeRate(Int64 currentPage, Int64 pagesize, string getStartDate, string getEndDate, ref Int64 total)
 {
     try
     {
         if (currentPage == 0)
         {
             currentPage = 1L;
         }
         if (pagesize == 0)
         {
             pagesize = 100;
         }
         ITopClient           client = TBManager.GetClient();
         TraderatesGetRequest req    = new TraderatesGetRequest();
         req.Fields   = "tid,nick,result,created,item_title,content";
         req.RateType = "get";
         //req.Role = "seller";
         req.Role = "buyer";
         //req.Result = "good";
         req.PageNo   = currentPage;
         req.PageSize = pagesize;
         if (!string.IsNullOrEmpty(getStartDate))
         {
             req.StartDate = Convert.ToDateTime(getStartDate);
         }
         if (!string.IsNullOrEmpty(getEndDate))
         {
             req.EndDate = Convert.ToDateTime(getEndDate);
         }
         TraderatesGetResponse response = client.Execute(req, Users.SessionKey);
         total = response.TotalResults;
         return(response.TradeRates);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #16
0
 /// <summary>
 /// 查询买家的信誉等级
 /// </summary>
 /// <param name="buyerNick"></param>
 /// <returns></returns>
 public User GetBuyerDetailInfo(string strSessionKey, string buyerNick)
 {
     try
     {
         ITopClient     client = TBManager.GetClient();
         UserGetRequest req    = new UserGetRequest();
         req.Fields = "buyer_credit";
         req.Nick   = buyerNick;
         UserGetResponse response = client.Execute(req, strSessionKey);
         if (response.IsError)
         {
             ExceptionReporter.WriteLog("GetBuyerDetailInfo:" + response.SubErrCode + ":" + response.SubErrMsg, null, ExceptionPostion.TopApi, ExceptionRank.important);
             return(null);
         }
         return(response.User);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #17
0
 /// <summary>
 ///  可生成店铺宝贝、店铺首页、活动链接等3种可呼起手机淘宝APP的短链。
 /// </summary>
 /// <returns></returns>
 public static string SetShortLink(string shortLinkName, string linkType, string shortLinkData, ref string msg)
 {
     try
     {
         ITopClient client = TBManager.GetClient();
         CrmServiceChannelShortlinkCreateRequest req = new CrmServiceChannelShortlinkCreateRequest();
         req.ShortLinkName = shortLinkName;
         req.LinkType      = linkType;
         if (!linkType.Equals("LT_SHOP"))
         {
             req.ShortLinkData = shortLinkData;
         }
         CrmServiceChannelShortlinkCreateResponse response = client.Execute(req, Users.SessionKey);
         msg = response.SubErrCode;
         return(response.ShortLink);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return("0");
     }
 }
예제 #18
0
 public List <CrmMember> GetBuyer(string strSessionKey, Int64 currentPage, Int64 pagesize, string getMemberStartDate, string getMemberEndDate)
 {
     try
     {
         if (currentPage == 0)
         {
             currentPage = 1L;
         }
         if (pagesize == 0)
         {
             pagesize = 100;
         }
         ITopClient client           = TBManager.GetClient();
         CrmMembersSearchRequest req = new CrmMembersSearchRequest();
         req.CurrentPage = currentPage;
         req.PageSize    = pagesize;
         if (!string.IsNullOrEmpty(getMemberStartDate))
         {
             req.MinLastTradeTime = Convert.ToDateTime(getMemberStartDate);
         }
         if (!string.IsNullOrEmpty(getMemberEndDate))
         {
             req.MaxLastTradeTime = Convert.ToDateTime(getMemberEndDate);
         }
         CrmMembersSearchResponse response = client.Execute(req, strSessionKey);
         if (response.IsError)
         {
             ExceptionReporter.WriteLog(response.SubErrMsg, ExceptionPostion.TopApi, ExceptionRank.important);
             throw new Exception();
         }
         return(response.Members);
     }
     catch (Exception ex)
     {
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #19
0
 /// <summary>
 /// 优化为一次性读取卖家最近3个月的交易数据
 /// </summary>
 /// <param name="strSessionKey"></param>
 /// <param name="pageNum"></param>
 /// <param name="hasNext"></param>
 /// <returns></returns>
 public List <Trade> GetBuyerTrades(string strSessionKey, Int64 pageNum, ref bool hasNext)
 {
     try
     {
         ITopClient           client = TBManager.GetClient();
         TradesSoldGetRequest req    = new TradesSoldGetRequest();
         req.Fields       = @"tid,buyer_nick,seller_nick,receiver_name,receiver_state,receiver_city,receiver_district,receiver_address,receiver_mobile,buyer_email";
         req.PageNo       = pageNum;
         req.StartCreated = Convert.ToDateTime(DateTime.Now.AddMonths(-3));
         req.EndCreated   = Convert.ToDateTime(DateTime.Now);
         req.UseHasNext   = true;
         req.PageSize     = 100L;
         TradesSoldGetResponse response = client.Execute(req, strSessionKey);
         hasNext = response.HasNext; //是否有下一页
         return(response.Trades);    //返回信息数组,数组对象的属性为fields的参数
     }
     catch (Exception ex)
     {
         File.WriteAllText(@"D:\log\" + strSessionKey + ".txt", ex.Message, Encoding.Default);
         ExceptionReporter.WriteLog(ex, ExceptionPostion.TopApi);
         return(null);
     }
 }
예제 #20
0
        /// <summary>
        /// 初始信息处理
        /// </summary>
        /// <param name="hasShop"></param>
        public static string  WriteUserInfoToCookies()
        {
            HttpContext context       = HttpContext.Current;
            string      code          = HttpContext.Current.Request.QueryString["code"];
            string      state         = HttpContext.Current.Request.QueryString["state"];
            string      client_id     = appKey;
            string      client_secret = appSecret;
            string      grant_type    = "authorization_code";
            string      redirect_uri  = redirect_URL;
            int         s             = 0;//记录code获取源

            //从数据库获取code
            if (string.IsNullOrEmpty(code))
            {
                DataTable dt = SellersBLL.GetSellersCode(Users.Nick);
                if (dt != null && dt.Rows.Count > 0)
                {
                    s    = 1;
                    code = dt.Rows[0]["code"].ToString();
                }
            }
            #region 获取授权Code
            if (!string.IsNullOrEmpty(code))
            {
                DataTable dt = SellersBLL.GetSellersCode(Users.Nick);
                if (dt != null && dt.Rows.Count > 0 && s == 0)
                {
                    SellersBLL.UpdateSellersCode(Users.Nick, code);
                }
                else if (dt == null || dt.Rows.Count == 0)
                {
                    SellersBLL.AddSellersCode(Users.Nick, code);
                }

                //获取访问令牌
                string url  = "https://oauth.taobao.com/token?client_id={0}&client_secret={1}&grant_type={2}&code={3}&redirect_uri={4}&scope={5}&view={6}&state={7}";
                string urlS = string.Format(url, client_id, client_secret, grant_type, code, redirect_uri, "item", "web", state);
                string getAuthAcessToken = PostDataToUrl(urlS, urlS);
                if (string.IsNullOrEmpty(getAuthAcessToken))
                {
                    return(null);
                }                                                            //20160907 yao c
                IDictionary resultDic = TopUtils.ParseJson(getAuthAcessToken);
                context.Request.Cookies.Clear();
                context.Session.Clear();
                //获取卖家昵称
                string nick = HttpUtility.UrlDecode(resultDic["taobao_user_nick"].ToString(), Encoding.UTF8);
                //这里的SessionKey就是access_token
                string sessionKey = resultDic["access_token"].ToString();
                //获取刷新令牌,以便令牌过期时重新获取
                string     refresh_token = resultDic["refresh_token"].ToString();
                HttpCookie cookie        = new HttpCookie("Top");
                cookie["nick"] = CTCRM.Common.DES.Encrypt(nick);

                UserSellerGetResponse userRsp = null;
                UserSellerGetRequest  req     = null;
                try
                {
                    Sellers sellers = new Sellers();
                    sellers.Nick = nick;
                    try
                    {
                        ITopClient client = TBManager.GetClient();
                        req        = new UserSellerGetRequest();
                        req.Fields = "user_id,type";
                        userRsp    = client.Execute(req, sessionKey);
                    }
                    catch (Exception ex)
                    {
                        userRsp = null;
                    }
                    sellers.Seller_Creadit = 0;//short.Parse(userRsp.User.SellerCredit.Level.ToString());
                    sellers.Seller_Id      = userRsp.User == null? 0: userRsp.User.UserId;
                    sellers.shopType       = userRsp.User == null ? "B" : userRsp.User.Type;
                    sellers.Created        = DateTime.Now;
                    sellers.SessionKey     = sessionKey;
                    sellers.Refresh_token  = refresh_token;
                    sellers.SellerType     = "pay";
                    cookie["SellerId"]     = sellers.Seller_Id.ToString();

                    //获取卖家订购信息
                    ArticleUserSubscribe userSub = UserSubscribe.GetDeadLineDate("ts-1811102", nick);
                    if (userSub != null)
                    {
                        sellers.EndDate = userSub.Deadline.ToString();

                        #region 标准版一月送200条
                        if (userSub.ItemCode.Equals("ts-1811102-1"))
                        {
                            sellers.OrderVersion = "标准版一月送200条";
                        }
                        #endregion
                        #region 自动评价版
                        if (userSub.ItemCode.Equals("ts-1811102-2"))
                        {
                            sellers.OrderVersion = "自动评价版";
                        }
                        #endregion
                        #region 订单打印版
                        if (userSub.ItemCode.Equals("ts-1811102-3"))
                        {
                            sellers.OrderVersion = "订单打印版";
                        }
                        #endregion
                        #region 流量推广_6个广告位
                        if (userSub.ItemCode.Equals("ts-1811102-4"))
                        {
                            sellers.OrderVersion = "流量推广_6个广告位";
                        }
                        #endregion
                        #region 订购一年送3000条短信
                        if (userSub.ItemCode.Equals("ts-1811102-5"))
                        {
                            sellers.OrderVersion = "订购一年送3000条短信";
                        }
                        #endregion
                        cookie["Deadline"]     = userSub.Deadline.ToString();//比如:2016-07-04 00:00:00
                        cookie["OrderVersion"] = CTCRM.Common.DES.Encrypt(sellers.OrderVersion);
                    }

                    SellersDAL objDal = new SellersDAL();
                    if (!SellersDAL.GetList(sellers))
                    {
                        sellers.CreatedDate = DateTime.Now;//记录卖家的第一次登陆系统时间
                        sellers.OrderDate   = DateTime.Now.ToShortDateString();
                        objDal.Add(sellers);

                        if (!objDal.AddSellerRecords(sellers.Nick, sellers.OrderVersion, userSub.Deadline.ToString(), "新订"))
                        {
                            File.WriteAllText(@"D:\log\" + nick + "_订购.txt", "新订失败");
                        }
                    }
                    else
                    {
                        string sellerEndDate = SellersDAL.GetSellerEndDate(nick);
                        sellers.UpdateDate = DateTime.Now;//记录卖家最近一次登陆系统时间
                        File.WriteAllText(@"D:\log\" + nick + "_shijianOld.txt", sellerEndDate);
                        bool sss = SellersDAL.Update(sellers);
                        File.WriteAllText(@"D:\log\" + nick + "_更新.txt", sss.ToString());
                        //判断卖家是否续费软件
                        File.WriteAllText(@"D:\log\" + nick + "_shijianNew.txt", sellers.EndDate);
                        if (sellers.EndDate != sellerEndDate)
                        {
                            if (sellers.OrderVersion == "订购一年送3000条短信")
                            {
                                File.WriteAllText(@"D:\log\" + nick + "_dinggou.txt", sellers.OrderVersion);
                                MsgPackage obj = new MsgPackage();
                                obj.PackageName = "店铺管家短信套餐(淘宝)3000条";
                                obj.Type        = "永久有效";
                                obj.SellerNick  = nick;
                                obj.Price       = 0;
                                obj.PerPrice    = "0";
                                obj.Rank        = "短信套餐(赠送)";
                                obj.OrderDate   = DateTime.Now;
                                obj.PayStatus   = true;
                                bool dingg = MsgBLL.AddMsgPackage(obj);
                                File.WriteAllText(@"D:\log\" + nick + "_tianjia.txt", dingg.ToString());
                                DataTable dtDuanxin = MsgBLL.GetSellerMsgTrans(nick);
                                if (dtDuanxin != null && dtDuanxin.Rows.Count > 0)
                                {
                                    obj.MsgCanUseCount = 3000 + (dtDuanxin.Rows[0]["msgCanUseCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgCanUseCount"]));
                                    obj.MsgTotalCount  = 3000 + (dtDuanxin.Rows[0]["msgTotalCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgTotalCount"]));
                                }
                                else
                                {
                                    obj.MsgCanUseCount = 3000;
                                    obj.MsgTotalCount  = 3000;
                                }
                                obj.ServiceStatus   = true;
                                obj.CanUseStartDate = DateTime.Now;

                                MsgBLL.UpdateMsgTrans(obj);
                            }
                            else
                            {
                                File.WriteAllText(@"D:\log\" + nick + "_dinggou.txt", sellers.OrderVersion);
                                MsgPackage obj = new MsgPackage();
                                obj.PackageName = "店铺管家短信套餐(淘宝)200条";
                                obj.Type        = "永久有效";
                                obj.SellerNick  = nick;
                                obj.Price       = 0;
                                obj.PerPrice    = "0";
                                obj.Rank        = "短信套餐(赠送)";
                                obj.OrderDate   = DateTime.Now;
                                obj.PayStatus   = true;
                                bool dingg = MsgBLL.AddMsgPackage(obj);
                                File.WriteAllText(@"D:\log\" + nick + "_tianjia.txt", dingg.ToString());
                                DataTable dtDuanxin = MsgBLL.GetSellerMsgTrans(nick);
                                if (dtDuanxin != null && dtDuanxin.Rows.Count > 0)
                                {
                                    obj.MsgCanUseCount = 200 + (dtDuanxin.Rows[0]["msgCanUseCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgCanUseCount"]));
                                    obj.MsgTotalCount  = 200 + (dtDuanxin.Rows[0]["msgTotalCount"] == DBNull.Value ? 0 : Convert.ToInt32(dtDuanxin.Rows[0]["msgTotalCount"]));
                                }
                                else
                                {
                                    obj.MsgCanUseCount = 200;
                                    obj.MsgTotalCount  = 200;
                                }
                                obj.ServiceStatus   = true;
                                obj.CanUseStartDate = DateTime.Now;

                                MsgBLL.UpdateMsgTrans(obj);
                            }

                            if (!objDal.AddSellerRecords(sellers.Nick, sellers.OrderVersion, userSub.Deadline.ToString(), "续订"))
                            {
                                File.WriteAllText(@"D:\log\" + nick + "_订购.txt", "续订失败");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //ExceptionReporter.WriteLog(userRsp.ErrMsg, ex, ExceptionPostion.TopApi, ExceptionRank.urgency);
                }
                cookie["sess"] = sessionKey;
                cookie.Expires = DateTime.Now.AddDays(1d);
                context.Response.Cookies.Add(cookie);
                return("1");
            }
            else   //Code为空的情况下
            {
                return("0");
            }
            #endregion
        }