/// <summary> /// 用户积分操作 /// </summary> /// <param name="info">详细信息</param> /// <param name="opraType">操作类型:100:收入,如购彩增加积分;110:支出,如兑换奖品;</param> /// <returns></returns> public bool UserIntegral(UserGetPrizeInfo info, IntegralExchangeType payType) { try { using (var biz = new GameBizBusinessManagement()) { biz.BeginTran(); if (info != null && !string.IsNullOrEmpty(info.UserId)) { if (payType == IntegralExchangeType.IntegralIn || payType == IntegralExchangeType.IntegralOut)//增加积分或兑换奖品 { SaveUserIntegralDetail(info, payType); SaveUserIntegral(info, payType); if (info.OrderMoey >= 100) { GivePrizes(info);//赠送彩金 } } } biz.CommitTran(); return(true); } } catch { return(false); } }
public void SaveUserIntegral(UserGetPrizeInfo info, IntegralExchangeType opraType) { try { var manage = new UserIntegralManager(); UserIntegralBalance entity = manage.GetUserIntegralBalance(info.UserId); if (entity != null && !string.IsNullOrEmpty(entity.UserId)) //修改 { if (opraType == IntegralExchangeType.IntegralIn) //增加积分 { entity.CurrIntegralBalance += info.PayInegral; manage.UpdateUserIntegralBalance(entity); } else if (opraType == IntegralExchangeType.IntegralOut)//兑换奖品 { if (info.PayInegral > entity.CurrIntegralBalance) { return; } ExchangePresent(info); entity.CurrIntegralBalance -= info.PayInegral; entity.UseIntegralBalance += info.PayInegral; manage.UpdateUserIntegralBalance(entity);//修改总的资金明细 } } else//新增 { if (opraType == IntegralExchangeType.IntegralIn) { entity = new UserIntegralBalance(); entity.CurrIntegralBalance += info.PayInegral; entity.UseIntegralBalance = 0; entity.CreateTime = DateTime.Now; entity.UserId = info.UserId; manage.AddUserIntegralBalance(entity); } else { throw new Exception("您还没有积分,不能兑换奖品或领取彩金!"); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void SaveUserIntegralDetail(UserGetPrizeInfo info, IntegralExchangeType opraType) { try { var manage = new UserIntegralManager(); UserIntegralBalance entity = manage.GetUserIntegralBalance(info.UserId); if (entity == null && opraType == IntegralExchangeType.IntegralOut) { throw new Exception("您还没有积分,不能兑换奖品或领取彩金!"); } UserIntegralDetail detailEntity = new UserIntegralDetail(); detailEntity.UserId = info.UserId; detailEntity.PayIntegral = info.PayInegral; detailEntity.BeforeIntegral = entity == null ? 0 : entity.CurrIntegralBalance; if (opraType == IntegralExchangeType.IntegralIn) { detailEntity.OrderId = info.OrderId; detailEntity.Summary = "购彩" + info.OrderMoey + "元,增加积分" + Convert.ToInt32(info.OrderMoey) + "点"; detailEntity.AfterIntegral = detailEntity.BeforeIntegral + detailEntity.PayIntegral; } else if (opraType == IntegralExchangeType.IntegralOut) { detailEntity.OrderId = ""; if (info.PayInegral > entity.CurrIntegralBalance) { return; } if (info.PayInegral == 100000) { detailEntity.Summary = "用户10万积分,兑换IPhone5S手机一部"; } else if (info.PayInegral == 1000000) { detailEntity.Summary = "用户100万积分,兑换QQ3汽车一辆"; } detailEntity.AfterIntegral = detailEntity.BeforeIntegral - detailEntity.PayIntegral; } detailEntity.CreateTime = DateTime.Now; manage.AddUserIntegralDetail(detailEntity); } catch (Exception ex) { throw new Exception(ex.Message); } }