123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- using System;
- using System.Collections.Generic;
- using Library;
- using System.Linq;
- using MySystem.MainModels;
- namespace MySystem
- {
- public class UserTradeDaySummaryDbconn
- {
- public readonly static UserTradeDaySummaryDbconn Instance = new UserTradeDaySummaryDbconn();
- public UserTradeDaySummaryDbconn()
- { }
- // TODO:读取很慢,感觉redis没生效
- #region 获取单个字段
- //个人业绩
- public decimal GetTrade(int UserId, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- public decimal GetDateTrade(int UserId, string TradeDate, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.TradeDate == TradeDate && m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- public decimal GetMonthTrade(int UserId, string TradeMonth, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- public decimal GetDateTradeForBrand(int UserId, string TradeDate, int BrandId, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeDate == TradeDate && m.
- SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- public decimal GetMonthTradeForBrand(int UserId, string TradeMonth, int BrandId, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeMonth == TradeMonth && m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- public decimal GetDateTradeForCloud(int UserId, string TradeDate, int QrPayFlag, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeDate == TradeDate && m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- public decimal GetMonthTradeForCloud(int UserId, string TradeMonth, int QrPayFlag, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeMonth == TradeMonth && m.
- SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
- }
- else if (kind == "team")
- {
- amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
- }
- }
- // RedisDbconn.Instance.Set(key, amt);
- db.Dispose();
- return amt;
- }
- #endregion
- }
- }
|