Exemplo n.º 1
0
 public static void SendEmail(List <string> pids, ILog logger)
 {
     if (pids.Any())
     {
         var baseInfo     = DalTireStockoutStatusWhile.GetBaseProductInfo(pids);
         var stockoutInfo = DalTireStockoutStatusWhile.GetStockoutStatus(pids);
         var data         = baseInfo.Union(stockoutInfo).GroupBy(g => g.PID).Select(g => new TireStockProductModel
         {
             PID               = g.Key,
             DisplayName       = g.FirstOrDefault(t => !string.IsNullOrEmpty(t.DisplayName))?.DisplayName ?? "",
             Brand             = g.FirstOrDefault(t => !string.IsNullOrEmpty(t.Brand))?.Brand ?? "",
             OnSale            = g.Any(t => t.OnSale),
             StockoutStatus    = g.Max(t => t.StockoutStatus),
             CurrentStockCount = g.Max(t => t.CurrentStockCount),
             MonthSales        = g.Max(t => t.MonthSales)
         }).ToList();
         var body      = new StringBuilder(51200);
         var emailhead =
             $@"<div style='font-size:20px;font-weight:bold;'><p>白名单变更记录:</p><p>{
                     DateTime.Now.ToString(CultureInfo.CurrentCulture)
                 }</p></div>";
         body.Append(emailhead);
         body.Append(TableMessage("以下PID被加入白名单", data));
         var dat     = data.Where(g => (g.SystemStockout == 1 || g.StockoutStatus == 1) && g.OnSale).ToList();
         var message = body.Append(TableMessage("以下PID的展示状态由缺货变为有货", dat)).ToString();
         TuhuMessage.SendEmail("【Info】白名单状态变更记录",
                               "*****@*****.**",
                               message);
     }
     else
     {
         logger.Warn("无新增缺货白名单");
     }
 }
Exemplo n.º 2
0
        public static bool JoinWhiteList(IEnumerable <string> pids, ILog logger)
        {
            int result = -99;

            using (var dbhelper = DbHelper.CreateLogDbHelper())
            {
                dbhelper.BeginTransaction();
                //已存在
                var exsitPids = DalTireStockoutStatusWhile.SelectExsitWhiteList(dbhelper, pids);
                if (exsitPids.Any())
                {
                    //删
                    result = DalTireStockoutStatusWhile.DeleteExsit(dbhelper, exsitPids);
                    if (result <= 0)
                    {
                        dbhelper.Rollback();
                        return(false);
                    }
                }

                //加入
                result = DalTireStockoutStatusWhile.JoinWhiteList(dbhelper, pids);
                if (result <= 0)
                {
                    dbhelper.Rollback();
                    return(false);
                }
                dbhelper.Commit();

                // 发送邮件
                var data = pids.Except(exsitPids).ToList();
                SendEmail(data, logger);

                foreach (var item in exsitPids)
                {
                    AddOprLog(item, true);
                }

                foreach (var item in pids)
                {
                    AddOprLog(item, false);
                }
                return(true);
            }
        }
Exemplo n.º 3
0
 public static int TruncateTableInfo()
 => DalTireStockoutStatusWhile.TruncateTableInfo();
Exemplo n.º 4
0
 public static IEnumerable <string> SelectTiresMatchAndSaleQuantityMoreThanEight()
 => DalTireStockoutStatusWhile.SelectTiresMatchAndSaleQuantityMoreThanEight();