public static void CheckGroupBuying(string bizLogFile) { BizLogFile = bizLogFile; WriteLog("\r\n------------------- Begin-------------------------"); // 获取团购中秒杀商品的记录 List <ProductGroupBuyingEntity> groupBuyingItemList = GroupBuyingDA.GetProductGroupBuyingList(); string startmsg = "获取到团购的记录,共" + groupBuyingItemList.Count + "条."; WriteLog(startmsg); if (groupBuyingItemList.Count == 0) { return; } StringBuilder startNum = new StringBuilder(); StringBuilder finishNum = new StringBuilder(); StringBuilder abandonNum = new StringBuilder(); foreach (ProductGroupBuyingEntity groupBuyingEntity in groupBuyingItemList) { string info = string.Format("团购SysNo|产品SysNo|状态-->{0}|{1}|{2}\r\n", groupBuyingEntity.SysNo, groupBuyingEntity.ProductSysNo, groupBuyingEntity.Status); //如果团购状态为就绪状态且“团购开始时间”为“当前时间”前一小时 if (groupBuyingEntity.Status == "P" && (groupBuyingEntity.BeginDate > DateTime.Now && DateTime.Now.AddHours(1) >= groupBuyingEntity.BeginDate) && groupBuyingEntity.ProductStatus == 1) { try { CheckGroupReadToRun(groupBuyingEntity, false); continue; } catch (Exception exp) { SendExceptionInfoEmail(exp.Message.ToString()); WriteLog(string.Format("{0}就绪->原价判断 出错了!异常:{1}", info, exp.Message.ToString())); continue; } } //如果团购状态为就绪状态且当“当前时间”大于等于“团购开始时间”并且“结束时间”小于“当前时间” if (groupBuyingEntity.Status == "P" && (groupBuyingEntity.BeginDate <= DateTime.Now && groupBuyingEntity.EndDate > DateTime.Now) && groupBuyingEntity.ProductStatus == 1) { try { if (CheckGroupReadToRun(groupBuyingEntity, true)) { SetRunning(groupBuyingEntity); startNum.AppendLine(info); } continue; } catch (Exception exp) { SendExceptionInfoEmail(exp.Message.ToString()); WriteLog(string.Format("{0}就绪->运行 出错了!异常:{1}", info, exp.Message.ToString())); continue; } } //如果团购状态为就绪状态并且“结束时间”小于“当前时间”则作废 if (groupBuyingEntity.Status == "P" && groupBuyingEntity.EndDate < DateTime.Now) { try { SetAbandon(groupBuyingEntity); abandonNum.AppendLine(info); continue; } catch (Exception ex) { SendExceptionInfoEmail(ex.Message.ToString()); WriteLog("作废过期团购 出错了![" + info + "]" + "异常:" + ex.Message.ToString()); continue; } } //如果团购状态为运行状态 if (groupBuyingEntity.Status == "A") { //当“当前时间”大于等于“团购结束时间”并且状态为运行状态 if (groupBuyingEntity.EndDate < DateTime.Now || groupBuyingEntity.ProductStatus != 1) { try { //将“运行”状态调整为“完成”状态 SetFinish(groupBuyingEntity); finishNum.AppendLine(info); continue; } catch (Exception ex) { SendExceptionInfoEmail(ex.Message.ToString()); WriteLog("运行->结束 出错了![" + info + "]" + "异常:" + ex.Message.ToString()); continue; } } else { try { SetStepPrice(groupBuyingEntity); continue; } catch (Exception ex) { SendExceptionInfoEmail(ex.Message.ToString()); WriteLog("运行->调价 出错了![" + info + "]" + "异常:" + ex.Message.ToString()); continue; } } } } string endMsg = "本轮运行结果:\r\n就绪->运行:\r\n" + startNum.ToString() + "\r\n就绪->作废:\r\n" + abandonNum.ToString() + "\r\n运行->完成:\r\n" + finishNum.ToString(); WriteLog(endMsg); WriteLog("------------------- End-----------------------------\r\n"); //WriteConsoleInfo(endMsg); }