|
@@ -40,7 +40,7 @@ namespace MySystem.Areas.Api.Controllers.v1
|
|
|
int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
|
|
int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
|
|
|
int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
|
|
int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
|
|
|
List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
|
|
List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
|
|
|
- IQueryable<ActivityRedPackageJoins> query = maindb.ActivityRedPackageJoins.Where(m => m.UserId == UserId);
|
|
|
|
|
|
|
+ IQueryable<ActivityRedPackageJoins> query = maindb.ActivityRedPackageJoins.Where(m => m.UserId == UserId).OrderByDescending(m => m.Id);
|
|
|
if (PageNum == 1)
|
|
if (PageNum == 1)
|
|
|
{
|
|
{
|
|
|
query = query.Take(PageSize);
|
|
query = query.Take(PageSize);
|
|
@@ -183,91 +183,42 @@ namespace MySystem.Areas.Api.Controllers.v1
|
|
|
string tmpCheck = RedisDbconn.Instance.Get<string>("GetPrizeFlag:" + UserId + ":" + ActivityDate);
|
|
string tmpCheck = RedisDbconn.Instance.Get<string>("GetPrizeFlag:" + UserId + ":" + ActivityDate);
|
|
|
if(!string.IsNullOrEmpty(tmpCheck))
|
|
if(!string.IsNullOrEmpty(tmpCheck))
|
|
|
{
|
|
{
|
|
|
- return new AppResultJson() { Status = "-1", Info = "请无频繁操作,谢谢合作" };
|
|
|
|
|
|
|
+ return new AppResultJson() { Status = "-1", Info = "请勿频繁操作,谢谢合作" };
|
|
|
}
|
|
}
|
|
|
RedisDbconn.Instance.Set("GetPrizeFlag:" + UserId + ":" + ActivityDate, "wait");
|
|
RedisDbconn.Instance.Set("GetPrizeFlag:" + UserId + ":" + ActivityDate, "wait");
|
|
|
RedisDbconn.Instance.SetExpire("GetPrizeFlag:" + UserId + ":" + ActivityDate, 120);
|
|
RedisDbconn.Instance.SetExpire("GetPrizeFlag:" + UserId + ":" + ActivityDate, 120);
|
|
|
- string PreDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd");
|
|
|
|
|
- bool op = false;
|
|
|
|
|
- if (DateTime.Now >= start)
|
|
|
|
|
|
|
+ if (DateTime.Now < start)
|
|
|
{
|
|
{
|
|
|
- string pos = RedisDbconn.Instance.Get<string>("CheckStaStatus:" + UserId + ":" + ActivityDate);
|
|
|
|
|
- // bool pos = maindb.PosMachinesTwo.Any(m => m.BuyUserId == UserId && m.ActivationState == 1 && m.ActivationTime >= today);
|
|
|
|
|
- if (pos == "1")
|
|
|
|
|
- {
|
|
|
|
|
- bool check = maindb.ActivityRedPackageStock.Any(m => m.ActivityDate == ActivityDate && m.UserId == 0);
|
|
|
|
|
- if (check)
|
|
|
|
|
- {
|
|
|
|
|
- check = maindb.ActivityRedPackageStock.Any(m => m.UserId == UserId && m.ActivityDate == ActivityDate);
|
|
|
|
|
- if (!check)
|
|
|
|
|
- {
|
|
|
|
|
- op = true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return new AppResultJson() { Status = "-1", Info = "活动未开始" };
|
|
|
}
|
|
}
|
|
|
- bool IsNull = maindb.ActivityRedPackageStock.Any(m => m.ActivityDate == ActivityDate && m.UserId ==0);//判断是否存在数据
|
|
|
|
|
- if (!IsNull)
|
|
|
|
|
- {
|
|
|
|
|
- return new AppResultJson() { Status = "2", Info = "已抢光" };
|
|
|
|
|
- }
|
|
|
|
|
- if (!op)
|
|
|
|
|
|
|
+ string pos = RedisDbconn.Instance.Get<string>("CheckStaStatus:" + UserId + ":" + ActivityDate);
|
|
|
|
|
+ if (pos != "1")
|
|
|
{
|
|
{
|
|
|
return new AppResultJson() { Status = "-1", Info = "领取失败" };
|
|
return new AppResultJson() { Status = "-1", Info = "领取失败" };
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
|
|
|
- List<ActivityRedPackageStock> list = maindb.ActivityRedPackageStock.Where(m => m.ActivityDate == ActivityDate && m.UserId == 0).ToList();
|
|
|
|
|
- ActivityRedPackageStock edit = new ActivityRedPackageStock();
|
|
|
|
|
- if(list.Count == 200 - 17 || list.Count == 200 - 27 || list.Count == 200 - 37 || list.Count == 200 - 47 || list.Count == 200 - 57 || list.Count == 200 - 67)
|
|
|
|
|
|
|
+ string MyPackageFlag = RedisDbconn.Instance.Get<string>("MyPackageFlag:" + ActivityDate + ":" + UserId);
|
|
|
|
|
+ if(!string.IsNullOrEmpty(MyPackageFlag))
|
|
|
{
|
|
{
|
|
|
- edit = list.FirstOrDefault(m => m.PrizeAmt == 88.88M && m.UserId == 0);
|
|
|
|
|
|
|
+ return new AppResultJson() { Status = "-1", Info = "已领取" };
|
|
|
}
|
|
}
|
|
|
- if(edit == null)
|
|
|
|
|
|
|
+ ActivityRedPackageStock RedPackage = RedisDbconn.Instance.RPop<ActivityRedPackageStock>("RedPackageList:" + ActivityDate);
|
|
|
|
|
+ if(RedPackage == null)
|
|
|
{
|
|
{
|
|
|
- edit = new ActivityRedPackageStock();
|
|
|
|
|
- }
|
|
|
|
|
- if(edit.Id == 0)
|
|
|
|
|
- {
|
|
|
|
|
- edit = list[function.get_Random(0,list.Count-1)];
|
|
|
|
|
|
|
+ return new AppResultJson() { Status = "2", Info = "已抢光" };
|
|
|
}
|
|
}
|
|
|
- edit.UserId = UserId;
|
|
|
|
|
- edit.UpdateDate = DateTime.Now;
|
|
|
|
|
- ActivityRedPackageJoins query = maindb.ActivityRedPackageJoins.Add(new ActivityRedPackageJoins()
|
|
|
|
|
- {
|
|
|
|
|
- CreateDate = DateTime.Now, //创建时间
|
|
|
|
|
- Status = 1,
|
|
|
|
|
- UserId = UserId, //创客
|
|
|
|
|
- ActivityDate = ActivityDate, //期数
|
|
|
|
|
- PrizeAmt = edit.PrizeAmt,
|
|
|
|
|
- }).Entity;
|
|
|
|
|
- maindb.SaveChanges();
|
|
|
|
|
-
|
|
|
|
|
- RedisDbconn.Instance.AddList("RedPrizeQueue", query.Id.ToString());
|
|
|
|
|
- Obj.Add("PrizeAmt", query.PrizeAmt); //中奖金额
|
|
|
|
|
|
|
+ RedisDbconn.Instance.Set("MyPackageFlag:" + ActivityDate + ":" + UserId, RedPackage.Id.ToString());
|
|
|
|
|
+ RedisDbconn.Instance.SetExpire("MyPackageFlag:" + ActivityDate + ":" + UserId, 3600 * 24);
|
|
|
|
|
+ RedisDbconn.Instance.AddList("RedPrizeQueue", RedPackage.Id + ":" + UserId + ":" + ActivityDate);
|
|
|
|
|
+
|
|
|
|
|
+ string PreDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd");
|
|
|
|
|
+ Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
|
|
|
+ Obj.Add("PrizeAmt", RedPackage.PrizeAmt); //中奖金额
|
|
|
|
|
|
|
|
string PreMakerCode = "";
|
|
string PreMakerCode = "";
|
|
|
string PreRealName = "";
|
|
string PreRealName = "";
|
|
|
decimal PrePrizeAmt = 0;
|
|
decimal PrePrizeAmt = 0;
|
|
|
string PreInfoString = RedisDbconn.Instance.Get<string>("PreInfoString:" + PreDate);
|
|
string PreInfoString = RedisDbconn.Instance.Get<string>("PreInfoString:" + PreDate);
|
|
|
- if(string.IsNullOrEmpty(PreInfoString))
|
|
|
|
|
- {
|
|
|
|
|
- bool checkPre = maindb.ActivityRedPackageStock.Any(m => m.ActivityDate == PreDate);
|
|
|
|
|
- if (checkPre)
|
|
|
|
|
- {
|
|
|
|
|
- ActivityRedPackageStock preInfo = maindb.ActivityRedPackageStock.Where(m => m.ActivityDate == PreDate).OrderByDescending(m => m.PrizeAmt).FirstOrDefault();
|
|
|
|
|
- if (preInfo != null)
|
|
|
|
|
- {
|
|
|
|
|
- Users user = maindb.Users.FirstOrDefault(m => m.Id == preInfo.UserId) ?? new Users();
|
|
|
|
|
- PreMakerCode = user.MakerCode;
|
|
|
|
|
- PreRealName = user.RealName;
|
|
|
|
|
- PrePrizeAmt = preInfo.PrizeAmt;
|
|
|
|
|
- RedisDbconn.Instance.Set("PreInfoString:" + PreDate, PreMakerCode + "|" + PreRealName + "|" + PrePrizeAmt);
|
|
|
|
|
- RedisDbconn.Instance.SetExpire("PreInfoString:" + PreDate, 7200);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ if(!string.IsNullOrEmpty(PreInfoString))
|
|
|
{
|
|
{
|
|
|
string[] datalist = PreInfoString.Split('|');
|
|
string[] datalist = PreInfoString.Split('|');
|
|
|
PreMakerCode = datalist[0];
|
|
PreMakerCode = datalist[0];
|