| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System;
- using System.Collections.Generic;
- using Library;
- using System.Linq;
- using MySystem.MainModels;
- namespace MySystem
- {
- public class UsersDbconn
- {
- public readonly static UsersDbconn Instance = new UsersDbconn();
- #region 获取单个字段
- public Users Get(int Id)
- {
- // string key = "Users:" + Id;
- // if (RedisDbconn.Instance.Exists(key))
- // {
- // Users obj = RedisDbconn.Instance.Get<Users>(key);
- // if (obj != null)
- // {
- // return obj;
- // }
- // }
- WebCMSEntities db = new WebCMSEntities();
- Users order = db.Users.FirstOrDefault(m => m.Id == Id);
- if (order != null)
- {
- // RedisDbconn.Instance.Set(key, order);
- // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400));
- }
- db.Dispose();
- return order;
- }
- //个人新增创客
- public int GetNewUserCount(int UserId, string TradeMonthOrDate = "")
- {
- int count = 0;
- WebCMSEntities db = new WebCMSEntities();
- if(string.IsNullOrEmpty(TradeMonthOrDate))
- {
- bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.SeoTitle == "self");
- if (check)
- {
- count = db.PullnewSummary.Where(m => m.UserId == UserId && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
- }
- }
- else
- {
- if(TradeMonthOrDate.Length == 8)
- {
- bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "self");
- if (check)
- {
- count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
- }
- }
- else
- {
- bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "self");
- if (check)
- {
- count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
- }
- }
- }
- db.Dispose();
- return count;
- }
- //团队新增创客
- public int GetTeamNewUserCount(int UserId, string TradeMonthOrDate = "")
- {
- int count = 0;
- WebCMSEntities db = new WebCMSEntities();
- if(string.IsNullOrEmpty(TradeMonthOrDate))
- {
- bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.SeoTitle == "team");
- if (check)
- {
- count = db.PullnewSummary.Where(m => m.UserId == UserId && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
- }
- }
- else
- {
- if(TradeMonthOrDate.Length == 8)
- {
- bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "team");
- if (check)
- {
- count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
- }
- }
- else
- {
- bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "team");
- if (check)
- {
- count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
- }
- }
- }
- db.Dispose();
- return count;
- }
- #endregion
- }
- }
|