public static void SendFailedMail(SOEntity soEntity, ProductGroupBuyingEntity group) { ThreadPool.QueueUserWorkItem(o => { SendMailBP.SendFailedMail4SO(soEntity, group); }); }
public static SOEntity GetSOEntity(int soSysNo, string companyCode) { SOEntity soEntity = new SOEntity(); //soEntity.SOCheckShipping = GetSOCheckShippingBySOSysno(soSysNo, companyCode); //soEntity.SOItemList = GetSOItemInfoListBySysNo(soSysNo, companyCode); soEntity.SOMaster = GetSOMasterInfoBySysNo(soSysNo, companyCode); return(soEntity); }
public static void DoWork(string logFile, string errFile, AutoResetEvent are) { LogFile = logFile; ErrorFile = errFile; WriteLog("新一轮工作开始..."); List <SOEntity> list = SODCDA.GetSOInfo(); WriteLog(string.Format("找到[15分钟前]待审核秒杀订单[{0}]笔.", list.Count)); int index = 0; if (list.Count == 0) { are.Set(); WriteLog("本轮工作结束。"); return; } foreach (var item in list) { Thread th = new Thread((obj) => { SOEntity itemSO = obj as SOEntity; try { if (itemSO.PayStatus == "-1" || itemSO.IncomeStatus == "-1" || string.IsNullOrEmpty(itemSO.PayStatus)) { WriteLog(string.Format("订单[{0}]超时15分钟未支付...,进行作废", itemSO.SOSysNo)); if (BlankOutSO(itemSO.SOSysNo)) { SODCDA.MakeOpered(itemSO.SOSysNo); } } else { WriteLog(string.Format("订单[{0}]已支付.", itemSO.SOSysNo)); SODCDA.MakeOpered(itemSO.SOSysNo); } } catch (Exception ex) { WriteErrorLog(string.Format("订单[{0}]处理异常\r\n{1}", item.SOSysNo, ex.Message)); } index++; if (index == list.Count) { are.Set(); WriteLog("本轮工作结束。"); } }); th.Start(item); } }
private static string BuildFailedMail(CustomerInfo customerInfo, SOEntity soEntity, ProductGroupBuyingEntity group) { string emailTemplate = MailTemplates.GroupBuyFailed; string linkForTitle = string.Format("<a href='http://tuan.newegg.com.cn/deal/{0}.htm'>{1}</a>", group.SystemNumber, group.GroupBuyingTitle); emailTemplate = emailTemplate.Replace("${CustomerID}", customerInfo.CustomerID) .Replace("${SOSysNo}", soEntity.SOMaster.SystemNumber.ToString()) .Replace("${OrderDateTime}", soEntity.SOMaster.OrderDate.ToString("yyyy年MM月dd日 HH:mm")) .Replace("${GroupTitle}", linkForTitle) .Replace("${GroupStart}", group.BeginDate.ToString("yyyy年MM月dd日 HH:mm")) .Replace("${GroupEnd}", group.EndDate.ToString("yyyy年MM月dd日 HH:mm")) .Replace("${GroupLimited}", group.LowerLimitSellCount.ToString()) .Replace("${GroupCurrentCount}", group.CurrentSellCount.ToString()) .Replace("${SendDateTime}", DateTime.Now.ToString("yyyy-MM-dd")) .Replace("${CopyRight}", DateTime.Now.Year.ToString()); return(emailTemplate); }
public static void SendFailedMail4SO(SOEntity soEntity, ProductGroupBuyingEntity group) { CustomerInfo customerInfo = CommonDA.GetCustomerBySysNo(soEntity.SOMaster.CustomerSysNo, CompanyCode); if (customerInfo == null || customerInfo.Email == null) { return; } group.LowerLimitSellCount = CommonDA.GetLowerLimitSellCount(group.SystemNumber); string mailFrom = "IPPSystem"; string mailTo = Util.TrimNull(customerInfo.Email); string mailSubject = "您在新蛋的订单SO#" + soEntity.SOMaster.SystemNumber + "团购失败,订单取消"; string mailBody = BuildFailedMail(customerInfo, soEntity, group); CommonServiceAdapter.SendEmail2MailDb(mailFrom, mailTo, null, null, mailSubject, mailBody, CompanyCode); }
public static void FailedGroupBuyProcess(ProductGroupBuyingEntity group) { //获取需要处理的订单号 List <int> soSysNolist = SODA.GetSOSysNoListByReferenceSysno(group.SystemNumber, CompanyCode); Console.WriteLine(string.Format("团购号:{0}", group.SystemNumber)); foreach (int soSysNo in soSysNolist) { Console.WriteLine(string.Format("订单:{0}", soSysNo)); SOEntity soEntity = SODA.GetSOEntity(soSysNo, CompanyCode); //审核NetPay try { if (ExistsNetPay(soSysNo)) { AuditNetPay(soSysNo); CreateAO(soSysNo); } AbandonSO(soSysNo); } catch (Exception ex) { UpdateSOGroupBuyStatus(soSysNo, "F"); Dealfault(ex); continue; } UpdateSOGroupBuyStatus(soSysNo, "S"); SendFailedMail(soEntity, group); } //EndGroupBuying(group.SystemNumber); }
public static void FullGroupBuyProcess(ProductGroupBuyingEntity group) { List <int> soSysNolist = SODA.GetSOSysNoListByReferenceSysno(group.SystemNumber, CompanyCode); Console.WriteLine(string.Format("团购号:{0}", group.SystemNumber)); foreach (int soSysNo in soSysNolist) { Console.WriteLine(string.Format("订单:{0}", soSysNo)); SOEntity soEntity = SODA.GetSOEntity(soSysNo, CompanyCode); //更新订单 try { UpdateSO(soSysNo); if (ExistsNetPay(soSysNo)) { AuditNetPay(soSysNo); } } catch (Exception ex) { UpdateSOGroupBuyStatus(soSysNo, "F"); Dealfault(ex); continue; } UpdateSOGroupBuyStatus(soSysNo, "S"); } if (group.Status == "F") { //EndGroupBuying(group.SystemNumber); } }