Ejemplo n.º 1
0
        /// <summary>
        /// 检查账户里余额不足的客户并给出提示
        /// </summary>
        public void StartDeleteShop()
        {
            //获取全部店铺
            ShopData        dbShop = new ShopData();
            List <ShopInfo> list   = dbShop.ShopInfoListAll();

            //通过接口获取这些店铺的到期时间
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    ShopInfo shop = list[i];

                    //if (shop.Nick != "带你远航2008")
                    //{
                    //    continue;
                    //}

                    TopApiHaoping api    = new TopApiHaoping(shop.Session);
                    string        result = api.GetUserExpiredDate(shop);
                    //Console.Write(result + "\r\n");
                    //判断是否过期
                    if (result.IndexOf("\"article_user_subscribes\":{}") != -1)
                    {
                        //更新为del状态
                        dbShop.DeleteShop(shop);
                    }
                    else
                    {
                        int   isok = 0;
                        Regex reg  = new Regex(@"""item_code"":""([^""]*)"",""deadline"":""([^""]*)""", RegexOptions.IgnoreCase);
                        //更新店铺的版本号
                        MatchCollection match = reg.Matches(result);
                        for (int j = 0; j < match.Count; j++)
                        {
                            string version = match[j].Groups[1].ToString();
                            string enddate = match[j].Groups[2].ToString();


                            if (version == "service-0-22904-9")
                            {
                                shop.Version = "3";
                            }

                            if (version == "service-0-22904-1" || version == "service-0-22904-2" || version == "service-0-22904-3")
                            {
                                shop.Version = version.Replace("service-0-22904-", "");

                                //所有版本都为专业版
                                if (shop.Version == "1")
                                {
                                    shop.Version = "2";
                                }

                                isok = 1;
                                continue;
                            }

                            //判断是否有没加的短信
                            if (version == "service-0-22904-4" || version == "service-0-22904-5" || version == "service-0-22904-6" || version == "service-0-22904-7" || version == "service-0-22904-8")
                            {
                                if (!dbShop.IsInitMessage(version, enddate, shop))
                                {
                                    string count = GetInitMessageCount(version, enddate);
                                    //短信充值
                                    dbShop.InitShopMessage(version, count, enddate, shop);

                                    //Console.ReadLine();
                                }
                            }
                        }

                        //if (isok == 0)
                        //{
                        //    shop.Version = "0";
                        //}

                        dbShop.ActiveShopVersion(shop);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message.ToString() + "\r\n");
                }
            }
        }