//写入更新记录 public RedPacketResult update() { fx(); if (this.isCreate) { object o = new object(); lock (o) { //获取当前领取的数量 string Num = RedisHelper.Get(PrefixKeyHelper.GetRedPacketIncrement() + redpacket.Id); if (Num == null || Num.ToInt() < redpacket.num) { //自增红包数 RedisHelper.Increment(PrefixKeyHelper.GetRedPacketIncrement() + redpacket.Id); //更新红包缓存数据 RedisHelper.Set(PrefixKeyHelper.GetRedPacketPK() + redpacket.Id, redpacket.Serialize()); //创建已领取红包记录Model Create(); //写入待更新红包表数据库队列 RedisHelper.LPush(PrefixKeyHelper.GetWaitWriteRedPacket() + redpacket.Id, redpacket.Serialize()); //写入红包领取记录缓存队列 RedisHelper.LPush(PrefixKeyHelper.GetWaitWriteHadGetRedPacket() + redpacket.Id, hadGetRedPacket.Serialize()); result.Status = (int)MRC.Data.Enum.EnumGetRedPacketStatus.GetOK; } else { result.Status = (int)MRC.Data.Enum.EnumGetRedPacketStatus.Over; } } result.Money = oneMoney; result.Message = "OK"; } return(result); }
public ActionResult GetHadList(string ID) { var data = RedisHelper.LRang(PrefixKeyHelper.GetWaitWriteHadGetRedPacket() + ID, 0, -1); List <HadGetRedPacket> datalist = new List <HadGetRedPacket>(); foreach (var item in data) { datalist.Add(JsonHelper.Deserialize <HadGetRedPacket>(item)); } Result <List <HadGetRedPacket> > result = Result.CreateResult <List <HadGetRedPacket> >(MRC.Data.Enum.ResultStatus.OK, datalist); return(Json(result)); }