MessageCode SaveLuckDraw(Guid managerId, int addPoint, int addCoin, bool isAddPackage, ItemPackageFrame package, NbManagerEntity manager, TurntableFrame turntable, TurntableLuckyrecordEntity record, DbTransaction trans) { var messageCode = MessageCode.Success; if (addPoint > 0) { messageCode = PayCore.Instance.AddBonus(managerId, addPoint, EnumChargeSourceType.Turntable, ShareUtil.GenerateComb().ToString(), trans); if (messageCode != MessageCode.Success) { return(messageCode); } } if (addCoin > 0) { messageCode = ManagerCore.Instance.AddCoin(manager, addCoin, EnumCoinChargeSourceType.Turntable, ShareUtil.GenerateComb().ToString(), trans); if (messageCode != MessageCode.Success) { return(messageCode); } } if (!turntable.Save(trans)) { return(MessageCode.NbUpdateFail); } if (isAddPackage) { if (!package.Save(trans)) { return(MessageCode.NbUpdateFail); } package.Shadow.Save(); } TurntableLuckyrecordMgr.Insert(record, trans); return(MessageCode.Success); }
/// <summary> /// 重置转盘 /// </summary> /// <param name="managerId"></param> /// <returns></returns> public TurntableResetResponse ResetTurntable(Guid managerId) { TurntableResetResponse response = new TurntableResetResponse(); response.Data = new TurntableReset(); try { var turntable = new TurntableFrame(managerId); if (turntable == null) { return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.NbParameterError)); } if (!turntable.TurnTableDic.ItemList.Exists(r => !r.IsEffective)) //不需要重置 { return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.TurntableNotReset)); } int consumePoint = turntable.GetResetPoint(turntable.TurntableManagerEntity.TurntableType); if (consumePoint == 0) { return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.NbParameterError)); } var point = PayCore.Instance.GetPoint(managerId); if (point < consumePoint)//钻石不足 { return(ResponseHelper.Create <TurntableResetResponse>((int)MessageCode.NbPointShortage)); } //重置 turntable.Reset(turntable.TurntableManagerEntity.TurntableType); using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main))) { transactionManager.BeginTransaction(); MessageCode messageCode = MessageCode.NbUpdateFail; do { messageCode = PayCore.Instance.GambleConsume(managerId, consumePoint, ShareUtil.GenerateComb(), EnumConsumeSourceType.Turntable, transactionManager.TransactionObject); if (messageCode != MessageCode.Success) { break; } if (!turntable.Save(transactionManager.TransactionObject)) { messageCode = MessageCode.NbUpdateFail; break; } messageCode = MessageCode.Success; } while (false); if (messageCode == MessageCode.Success) { transactionManager.Commit(); } else { transactionManager.Rollback(); return(ResponseHelper.Create <TurntableResetResponse>((int)messageCode)); } } response.Data.TurntableInfo = GetTurntableInfo(turntable); response.Data.Point = point - consumePoint; } catch (Exception ex) { SystemlogMgr.Error("重置转盘", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }