public void Get(Trade trade) { //获取店铺的基础数据 ShopData data = new ShopData(); ShopInfo shop = data.ShopInfoGetByNick(trade.Nick); //通过TOP接口查询该会员的详细数据并记录到数据库中 TopApiHaoping api = new TopApiHaoping(shop.Session); Customer customer = api.GetUserInfoByNick(trade); //先判断数据库里面是否该会员数据 CustomerData cdata = new CustomerData(); //把好评有礼的评价和优惠券数据加入顾客表 customer = cdata.InitHaopingData(customer); if (!cdata.IsHaveThisCustomer(trade)) { //如果有则通过会员接口插入会员基础数据 cdata.InsertCustomerData(trade, customer); } else { //根据订单数据更新会员数据 cdata.UpdateCustomerData(trade, customer); } }
/// <summary> /// 处理订单生成时的相应逻辑 /// </summary> public void Start() { //获取店铺的基础数据 ShopData data = new ShopData(); ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick); //目前只做虚拟店铺的逻辑 if (shop.IsXuni == "1") { //通过TOP接口查询该订单的详细数据并记录到数据库中 TopApiHaoping api = new TopApiHaoping(shop.Session); //特殊判断催单订单不获取物流信息 TradeInfo.Status = "CuiDan"; Trade trade = api.GetTradeByTid(TradeInfo); //判断该订单是否存在 TradeData dbTrade = new TradeData(); if (!dbTrade.CheckTradeExits(trade)) { //更新该订单的评价时间 dbTrade.InsertTradeInfo(trade); } } }
/// <summary> /// 处理订单完成时的相应逻辑 /// </summary> public void Start() { //获取店铺的基础数据 ShopData data = new ShopData(); ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick); //Console.Write(shop.Session + "!!!!!!!!!!!!\r\n"); if (shop.Version != "2" && shop.Version != "3") { return; } //通过TOP接口查询该订单的详细数据并记录到数据库中 TopApiHaoping api = new TopApiHaoping(shop.Session); TradeData tradeData = new TradeData(); Trade trade = tradeData.GetTradeDetailShippingInfo(TradeInfo); trade = api.GetTradeByTid(trade); //记录该订单对应的评价记录 TradeRate tradeRate = api.GetTradeRate(trade); tradeRate.ItemId = trade.NumIid; tradeRate.Nick = TradeInfo.Nick; //只有双方都评价了才会有插入数据库和赠送的操作 if (tradeRate.Content != "") { //判断该订单是否已经有过评价记录 TradeRateData dbTradeRate = new TradeRateData(); if (!dbTradeRate.CheckTradeRateExits(tradeRate)) { //没有记录过写入数据库 dbTradeRate.InsertTradeInfo(tradeRate); } //判断该订单是否存在 TradeData dbTrade = new TradeData(); if (!dbTrade.CheckTradeExits(trade)) { //更新该订单的评价时间 dbTrade.InsertTradeInfo(trade); } //更新该订单的评价时间 dbTrade.UpdateTradeRateById(trade, tradeRate); } else { //否则中断 return; } //判断如果是分销的订单,则不处理 if (trade.OrderType.ToLower() == "fenxiao") { return; } try { //更新订单的优惠券使用情况 TopApiHaoping apiCoupon = new TopApiHaoping(shop.Session); string result = apiCoupon.GetCouponTradeTotalByNick(trade); MatchCollection match = new Regex(@"<promotion_details list=""true""><promotion_detail><discount_fee>([^\<]*)</discount_fee><id>[0-9]*</id><promotion_desc>[^\<]*</promotion_desc><promotion_id>shopbonus-[0-9]*_[0-9]*-([0-9]*)</promotion_id><promotion_name>店铺优惠券</promotion_name></promotion_detail>", RegexOptions.IgnoreCase).Matches(result); if (match.Count != 0) { string price = match[0].Groups[1].ToString(); string couponid = match[0].Groups[2].ToString(); if (couponid.Length != 0) { TradeData dataTradeCoupon = new TradeData(); dataTradeCoupon.UpdateTradeCouponInfo(trade, price, couponid); } } } catch { } //判断是否开启了客服审核,如果开启了则自动记录并中断 if (shop.IsKefu == "1") { TradeRateData dataKefu = new TradeRateData(); string resultKefu = "手动审核订单!"; dataKefu.UpdateTradeRateResult(tradeRate, resultKefu); //更新该订单的评价为待审核状态 TradeData dbTrade = new TradeData(); if (!dbTrade.CheckTradeRateCheckExits(trade)) { dbTrade.UpdateTradeKefuById(trade, tradeRate); } try { //记录会员信息数据 GetUserData getUser = new GetUserData(); getUser.Get(trade); } catch { } return; } Console.WriteLine(trade.ShippingType + "!!"); //获取订单的具体物流状态,如果订单物流状态为空则获取物流信息 if (trade.ShippingType != "system" && trade.ShippingType != "self") { //获取该订单的物流状态 TopApiHaoping apiHaoping = new TopApiHaoping(shop.Session); string status = apiHaoping.GetShippingStatusByTid(trade); TradeData dbTrade = new TradeData(); Console.Write(status + "\r\n"); //如果该物流信息不存在 if (status.IndexOf("不存在") != -1) { //如果该物流公司不支持查询则更新为self dbTrade.UpdateTradeShippingStatusSelf(trade, status); } //获取该订单的物流相关信息 trade = api.GetOrderShippingInfo(trade); if (!dbTrade.IsTaobaoCompany(trade)) { //如果不是淘宝合作物流则直接更新 dbTrade.UpdateTradeShippingStatusSelf(trade, status); trade.ShippingType = "self"; } else { //根据服务器的物流状态进行判断,如果物流状态是已签收 if (status == "ACCEPTED_BY_RECEIVER" || status == "ACCEPTING" || status == "ACCEPTED") { string result = api.GetShippingStatusDetailByTid(trade); Console.Write("【" + result + "】\r\n"); //如果是虚拟物品 if (result.IndexOf("该订单未指定运单号") != -1) { //如果该物流公司不支持查询则更新为self dbTrade.UpdateTradeShippingStatusSelf(trade, status); } //如果订单不是服务器错误 if (result.IndexOf("company-not-support") != -1) { //如果该物流公司不支持查询则更新为self dbTrade.UpdateTradeShippingStatusSelf(trade, status); } //再根据订单的详细物流信息判断签收的状态 if (result.IndexOf("签收人") != -1 || result.IndexOf(" 妥投") != -1 || result.IndexOf(" 签收") != -1 || result.IndexOf("正常签收") != -1 || result.IndexOf(" 已签收") != -1) { //如果物流已经签收了则更新对应订单状态 trade.DeliveryEnd = utils.GetShippingEndTime(result);; trade.DeliveryMsg = result; trade.ShippingType = "system"; //如果物流到货时间还是为空 if (trade.DeliveryEnd == "") { LogData dbLog = new LogData(); dbLog.InsertErrorLog(trade.Nick, "deliveryDateNullOrder", "", result, ""); } dbTrade.UpdateTradeShippingStatusSystem(trade, status); } } } } //处理优惠券赠送及短信-上LOCK锁定 lock (TradeSuccess.padlockRate) { //淘宝优惠券赠送 bool isSendCoupon = true; //判断是否符合赠送条件 if (CheckCouponSend(shop, tradeRate, trade)) { //如果符合赠送条件调用赠送接口 CouponData dbCoupon = new CouponData(); Coupon coupon = dbCoupon.GetCouponInfoById(shop); //判定该优惠券是否过期或删除 if (!dbCoupon.CheckCouponCanUsed(shop)) { //优惠券过期,自动帮客户延长优惠券期限 //考虑到淘宝即将开启短授权,该功能改成消息通知,暂不制作 isSendCoupon = false; //return; } else { //解决多线程冲突问题先插入优惠券赠送记录,如果赠送失败再删除记录 string couponId = string.Empty; if (dbCoupon.InsertCouponSendRecord(trade, shop, couponId)) { string taobaoResult = string.Empty; couponId = api.SendCoupon(trade.BuyNick, coupon.TaobaoCouponId, ref taobaoResult); //获取的赠送接口的返回结果 if (couponId != "") { //如果成功赠送则记录 dbCoupon.UpdateCouponSendRecord(trade, shop, couponId); } else { //如果没有赠送成功则删除刚才的临时记录 dbCoupon.DeleteCouponSendRecord(trade, shop, couponId); Console.WriteLine(couponId); try { //记录淘宝自身错误 string err = new Regex(@"<reason>([^<]*)</reason>", RegexOptions.IgnoreCase).Match(taobaoResult).Groups[1].ToString(); TradeRateData dataRate = new TradeRateData(); if (err.Length == 0) { taobaoResult += "淘宝系统错误,不赠送优惠券,错误代码是【" + taobaoResult + "】!"; } else { taobaoResult += "淘宝系统错误,不赠送优惠券,错误代码是【" + err + "】!"; } dataRate.UpdateTradeRateResult(tradeRate, taobaoResult); } catch { } //有可能是客户订购的优惠券服务已经到期记录错误信息并中断 //return; isSendCoupon = false; } } else { isSendCoupon = false; } } } else { isSendCoupon = false; } //支付宝现金券赠送 bool isSendAlipay = true; //判断是否符合赠送条件 if (CheckAlipaySend(shop, tradeRate, trade)) { //获取一条需要赠送的支付宝红包数据 CouponData cou = new CouponData(); AlipayDetail detail = cou.GetAlipayDetailInfoById(shop); //如果符合赠送条件调用短信接口直接将红包发到客户手机上 string shopName = shop.MsgShopName; if (shop.MsgShopName.Length == 0) { shopName = shop.Nick; } string msgAlipay = "亲," + shopName + "赠送您支付宝红包,卡号" + detail.Card + "密码" + detail.Pass + ",您可以到支付宝绑定使用。"; Console.Write(msgAlipay + "\r\n"); string msgResultAlipay = Message.Send(trade.Mobile, msgAlipay); Console.Write(msgResultAlipay + "\r\n"); //更新支付宝红包使用状态 cou.InsertAlipaySendRecord(trade, shop, detail); //记录短信发送记录 ShopData dbAlipay = new ShopData(); if (msgResultAlipay != "0") { dbAlipay.InsertShopMsgLog(shop, trade, msgAlipay, msgResultAlipay, "alipay"); } else { isSendAlipay = false; dbAlipay.InsertShopErrMsgLog(shop, trade, msgAlipay, msgResultAlipay, "alipay"); } shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString(); } else { isSendAlipay = false; } //包邮卡赠送 bool isSendFreeCard = true; try { //判断是否符合赠送条件 if (CheckFreeCardSend(shop, tradeRate, trade)) { //赠送包邮卡 FreeCardData freeData = new FreeCardData(); freeData.SendFreeCard(shop, trade); //判断该用户是否开启了包邮卡短信 if (shop.MsgIsFreecard == "1" && int.Parse(shop.MsgCount) > 0) { ShopData db = new ShopData(); FreeCard free = freeData.GetFreeCardById(shop.FreeCardId); //发送短信 string msg = Message.GetMsg(shop.MsgFreecardContent, shop.MsgShopName, TradeInfo.BuyNick, shop.IsCoupon, free.Name); //手机号码为空不发 if (trade.Mobile.Length == 0) { return; } if (!db.IsSendMsgToday(trade, "freecard")) { string msgResult = Message.Send(trade.Mobile, msg); //记录 if (msgResult != "0") { db.InsertShopMsgLog(shop, trade, msg, msgResult, "freecard"); } else { db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "freecard"); } shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString(); } } } else { isSendFreeCard = false; } } catch (Exception e) { Console.WriteLine(e.Message + e.StackTrace + e.Source); } try { //记录会员信息数据 GetUserData getUser = new GetUserData(); getUser.Get(trade); } catch { } //Console.WriteLine(isSendCoupon + "!!"); //Console.WriteLine(isSendAlipay + "!!"); //Console.WriteLine(trade.Mobile + "!!"); //如果优惠券和支付宝现金都没有赠送成功,则直接中断方法不发短信 //2012.9.17改为只有赠送成功优惠券才发送此短信 if (!isSendCoupon) { return; } //判断该用户是否开启了发货短信 if (shop.MsgIsCoupon == "1" && int.Parse(shop.MsgCount) > 0) { ShopData db = new ShopData(); //发送短信 string msg = Message.GetMsg(shop.MsgCouponContent, shop.MsgShopName, TradeInfo.BuyNick, shop.IsCoupon); //string msg = Message.GetMsg(shop, trade, shop.MsgCouponContent); //手机号码为空不发 if (trade.Mobile.Length == 0) { return; } if (!db.IsSendMsgToday(trade, "gift")) { ////先插入数据库 解决多优惠券赠送短信多发问题 //db.InsertShopMsgLog(shop, trade, msg, "888888", "gift"); string msgResult = Message.Send(trade.Mobile, msg); //记录 if (msgResult != "0") { db.InsertShopMsgLog(shop, trade, msg, msgResult, "gift"); } else { db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "gift"); } shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString(); } } } }
public void Start(string index) { //获取目前正在使用的卖家(需要改成全部卖家,否则物流状态无法获取) ShopData dbShop = new ShopData(); List <ShopInfo> list = dbShop.GetShopInfoListShippingAlert(index); //循环判定这些卖家的订单是否物流到货 for (int i = 0; i < list.Count; i++) { try { ShopInfo shop = list[i]; //获取那些状态是发货中且没发过短信的订单给予提示 TradeData dbTrade = new TradeData(); List <Trade> listTrade = dbTrade.GetShippingTrade(shop); Console.Write(listTrade.Count.ToString() + "\r\n"); for (int j = 0; j < listTrade.Count; j++) { //如果是晚上10点到早上9点这个时间端内,不发送物流提醒短信 if (DateTime.Now.Hour > 8 && DateTime.Now.Hour < 22) { Trade trade = listTrade[j]; //判断如果是分销的订单,则不处理 if (trade.OrderType.ToLower() == "fenxiao") { continue; } //获取该订单的物流状态 TopApiHaoping api = new TopApiHaoping(shop.Session); string status = api.GetShippingStatusByTid(listTrade[j]); Console.Write(status + "\r\n"); //如果该物流信息不存在 if (status.IndexOf("不存在") != -1) { //如果该物流公司不支持查询则更新为self dbTrade.UpdateTradeShippingStatusSelf(trade, status); continue; } trade = api.GetOrderShippingInfo(trade); if (!dbTrade.IsTaobaoCompany(trade)) { //如果不是淘宝合作物流则直接更新 dbTrade.UpdateTradeShippingStatusSelf(trade, status); } else { //根据服务器的物流状态进行判断,如果物流状态是已签收 if (status == "ACCEPTED_BY_RECEIVER" || status == "ACCEPTING" || status == "ACCEPTED") { string result = api.GetShippingStatusDetailByTid(trade); Console.Write("【" + result + "】\r\n"); //如果订单不是服务器错误 if (result.IndexOf("company-not-support") != -1) { //如果该物流公司不支持查询则更新为self dbTrade.UpdateTradeShippingStatusSelf(trade, status); continue; } //再根据订单的详细物流信息判断签收的状态 if (result.IndexOf("签收人") != -1 || result.IndexOf(" 签收") != -1 || result.IndexOf(" 已签收") != -1 || result.IndexOf(" 妥投") != -1 || result.IndexOf("正常签收") != -1) { //如果物流已经签收了则更新对应订单状态 trade.DeliveryEnd = utils.GetShippingEndTime(result);; trade.DeliveryMsg = result; //如果物流到货时间还是为空 if (trade.DeliveryEnd == "") { LogData dbLog = new LogData(); dbLog.InsertErrorLog(trade.Nick, "deliveryDateNull", "", result, ""); continue; } //更新物流到货时间 dbTrade.UpdateTradeShippingStatusSystem(trade, status); //发送短信-上LOCK锁定 lock (ShippingSuccess.padlock1) { //判断同类型的短信该客户今天是否只收到一条 ShopData db = new ShopData(); if (!db.IsSendMsgOrder(trade, "shipping") && !db.IsSendMsgNear(trade, "shipping")) { //判断该用户是否开启了发货短信 if (shop.MsgIsShipping == "1" && int.Parse(shop.MsgCount) > 0) { //发送短信 //string msg = Message.GetMsg(shop.MsgShippingContent, shop.MsgShopName, trade.BuyNick, shop.IsCoupon); string msg = Message.GetMsg(shop, trade, shop.MsgShippingContent); string msgResult = Message.Send(trade.Mobile, msg); //记录 if (msgResult != "0") { db.InsertShopMsgLog(shop, trade, msg, msgResult, "shipping"); } else { db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "shipping"); } shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString(); } } } } } } //return; } } } catch { } } }
/// <summary> /// 处理订单生成时的相应逻辑 /// </summary> public string Start() { ShopData data = new ShopData(); ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick); if (shop.Version != "2" && shop.Version != "3") { return("1"); } //通过TOP接口查询该订单的详细数据并记录到数据库中 TopApiHaoping api = new TopApiHaoping(shop.Session); //处理包邮卡逻辑 if (IsFreePost(TradeInfo, shop)) { //通过API免运费 api.FreeTradePost(TradeInfo); //记录免邮订单方便统计销售 } //如果该客户没短信直接推出 if (int.Parse(shop.MsgCount) <= 0) { return("1"); } //判断该客户是否开启了催单短信 if (data.IsCuiByShop(TradeInfo)) { //获取小时数 string timecount = data.GetCuiDateByShop(shop); //Console.WriteLine(timecount); //if (timecount != "0") //{ //判断下单时间离现在有多久 TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts2 = new TimeSpan(DateTime.Parse(TradeInfo.Modified).Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); string minutes = ((int)ts.TotalMinutes).ToString(); Console.Write(TradeInfo.Tid + "-" + minutes + "....\r\n"); if (int.Parse(minutes) > int.Parse(timecount)) { if (int.Parse(shop.MsgCount) > 0) { //判断同类型的短信该客户今天是否只收到一条 ShopData db = new ShopData(); if (!db.IsSendMsgToday(TradeInfo, "cui")) { //特殊判断催单订单不获取物流信息 TradeInfo.Status = "CuiDan"; Trade trade = api.GetTradeByTid(TradeInfo); //如果是货到交易付款则不发送催单短信并结束改消息 if (trade.OrderType.ToLower() == "cod") { return("1"); } Console.WriteLine(trade.Status.ToUpper()); //如果该订单已付款则取消发送 if (trade.Status.ToUpper() != "WAIT_BUYER_PAY") { return("1"); } //晚上12点到早上10点不发 if (DateTime.Now.Hour < 10) { return("0"); } //发送短信 string msg = data.GetCuiContentByShop(shop); msg = Message.GetMsg(msg, shop.MsgShopName, "", ""); //Console.Write(msg + "...\r\n"); string msgResult = Message.Send(trade.Mobile, msg); //记录 if (msgResult != "0") { db.InsertShopMsgLog(shop, trade, msg, msgResult, "cui"); } else { db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "cui"); } shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString(); } } } else { return("0"); } //} } return("1"); }
/// <summary> /// 判断是否给该订单免运费 /// </summary> /// <param name="TradeInfo"></param> /// <returns></returns> private bool IsFreePost(Trade trade, ShopInfo shop) { //卖家是否订购了包邮卡服务 string plus = shop.Plus; if (string.IsNullOrEmpty(plus)) { //中断 return(false); } else { if (plus.IndexOf("freecard") == -1) { return(false); } } FreeCardData data = new FreeCardData(); //如果该订单已经包邮过 if (data.CheckOrderIsFree(trade)) { return(false); } //该买家是否有能用的包邮卡 string guid = data.GetUserFreeCard(trade); if (guid.Length == 0) { //中断 return(false); } //该订单是否满足包邮卡设定的金额 string freeCardPrice = data.GetFreeCardPrice(guid); TopApiHaoping api = new TopApiHaoping(shop.Session); trade = api.GetTradeByTid(trade); if (decimal.Parse(trade.OrderPrice) < decimal.Parse(freeCardPrice)) { //如果不满足中断 return(false); } //该订单是否满足包邮卡的地区限制 FreeCard free = data.GetUserFreeCardById(guid); string[] ary = free.AreaList.Split(','); if (free.AreaList.Length != 0) { if (free.IsFreeAreaList == "1") { //设置地区免运费 for (int i = 0; i < ary.Length; i++) { if (trade.receiver_state.IndexOf(ary[i]) != -1) { //记录免运费次数 data.RecordFreeCardLog(guid, trade); return(true); } } } else { //设置地区不免运费 for (int i = 0; i < ary.Length; i++) { if (trade.receiver_state.IndexOf(ary[i]) != -1) { return(false); } } } } //记录免运费次数 data.RecordFreeCardLog(guid, trade); return(true); }
/// <summary> /// 处理订单发货时的相应逻辑 /// </summary> public void Start() { //获取店铺的基础数据 ShopData data = new ShopData(); ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick); if (shop.Version != "2" && shop.Version != "3") { return; } //通过TOP接口查询该订单的详细数据并记录到数据库中 TopApiHaoping api = new TopApiHaoping(shop.Session); Trade trade = api.GetTradeByTid(TradeInfo); trade = api.GetOrderShippingInfo(trade); //发送短信-上LOCK锁定 //判断该评价是否存在 TradeData dbTrade = new TradeData(); if (!dbTrade.CheckTradeExits(trade)) { //更新该订单的评价时间 dbTrade.InsertTradeInfo(trade); } try { //更新订单的优惠券使用情况 TopApiHaoping apiCoupon = new TopApiHaoping(shop.Session); string result = apiCoupon.GetCouponTradeTotalByNick(trade); MatchCollection match = new Regex(@"<promotion_details list=""true""><promotion_detail><discount_fee>([^\<]*)</discount_fee><id>[0-9]*</id><promotion_desc>[^\<]*</promotion_desc><promotion_id>shopbonus-[0-9]*_[0-9]*-([0-9]*)</promotion_id><promotion_name>店铺优惠券</promotion_name></promotion_detail>", RegexOptions.IgnoreCase).Matches(result); if (match.Count != 0) { string price = match[0].Groups[1].ToString(); string couponid = match[0].Groups[2].ToString(); if (couponid.Length != 0) { TradeData dataTradeCoupon = new TradeData(); dataTradeCoupon.UpdateTradeCouponInfo(trade, price, couponid); } } } catch { } lock (padlock2) { //判断如果是分销的订单,则不处理 if (trade.OrderType.ToLower() == "fenxiao") { return; } //判断该用户是否开启了发货短信 if (shop.MsgIsFahuo == "1" && int.Parse(shop.MsgCount) > 0) { //判断同类型的短信该客户今天是否只收到一条 ShopData db = new ShopData(); if (!db.IsSendMsgToday(trade, "fahuo")) { //发送短信 string msg = Message.GetMsg(shop.MsgFahuoContent, shop.MsgShopName, TradeInfo.BuyNick, shop.IsCoupon, TradeInfo.ShippingCompanyName, TradeInfo.ShippingNumber, shop, trade); string msgResult = Message.SendGuodu(trade.Mobile, msg); //记录 if (msgResult != "0") { db.InsertShopMsgLog(shop, trade, msg, msgResult, "fahuo"); } else { db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "fahuo"); } shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString(); } } } }
/// <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"); } } }