public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo) { log4net.ILog log = log4net.LogManager.GetLogger("ColoredConsoleAppender"); var info = RequestUserInfo.ParseFrom(requestInfo.Body); DAL.DAL.Business business = new DAL.DAL.Business(); //获取用户积分消费卷信息 IntegralInfo integralInfo = business.GetIntegralInfo(info.UserID); byte[] data = null; if (integralInfo == null) { log.Error("用户不存在"); business.InsertIntegralInfo(info.UserID); data = ResponseUserInfo.CreateBuilder().SetUserID(info.UserID).SetRoomCard(0).SetIntegral(0).SetCoupons(0).Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10041, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } data = ResponseUserInfo.CreateBuilder().SetUserID(integralInfo.userID).SetRoomCard((int)integralInfo.roomCard).SetIntegral((double)integralInfo.integral).SetCoupons((double)integralInfo.coupons).Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10041, data.Length, requestInfo.MessageNum, data))); session.Close(); return; }
private static void FirstInsertIntegral(Guid companyId, IReposity reposity) { IntegralParameterView prameter = reposity.GetIntegralParameter(); if (prameter.IsSignIn) { IntegralInfo integral = new IntegralInfo { CompnayId = companyId, AccessTime = DateTime.Now, Integral = prameter.SignIntegral, IntegralWay = IntegralWay.SignIn, Remark = "登录奖励" }; reposity.InsertIntegralInfo(integral); IntegralCount counts = reposity.GetIntegralCount(companyId); IntegralCount count = new IntegralCount { CompnayId = companyId, Integral = prameter.SignIntegral }; if (counts == null) { count.Integral = prameter.SignIntegral; reposity.InsertIntegralCount(count); } else { reposity.UpdateIntegralCount(count); } } }
public async Task <IActionResult> Edit(string id, [Bind("Id,Score,IntegralInfoChangeType,Describe")] IntegralInfo integralInfo) { if (id != integralInfo.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(integralInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IntegralInfoExists(integralInfo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(integralInfo)); }
// GET: IntegralInfoes/Create public IActionResult Create(string owerId) { ViewBag.OwerName = _context.Menbers.FirstOrDefault(x => x.Id == owerId).Username; IntegralInfo integralInfo = new IntegralInfo() { OwnerId = owerId }; return(View(integralInfo)); }
public async Task <IActionResult> Create(IntegralInfo integralInfo) { if (ModelState.IsValid) { var menber = _context.Menbers.FirstOrDefault(x => x.Id == integralInfo.OwnerId); menber.IntegralSum += integralInfo.Score; _context.Add(integralInfo); _context.Menbers.Update(menber); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), "Menbers")); } return(View(integralInfo)); }
/// <summary> /// 修改兑换状态 /// </summary> /// <param name="view"></param> /// <returns></returns> public static void UpdateIntegralConsumption(Guid id, ChinaPay.B3B.Common.Enums.ExchangeState State, string operatorName, string no, string company, string address, string reason) { using (var cmd = Factory.CreateCommand()) { var reposity = Factory.CreateIntegralReposity(cmd); cmd.BeginTransaction(); try { reposity.UpdateIntegralConsumption(id, State, no, company, address, reason); //如果是拒绝兑换,将积分返回给用户,商品数量加回去 if (State == ExchangeState.Refuse) { IntegralConsumptionView view = reposity.GetIntegralConsumption(id); IntegralCount count = new IntegralCount { CompnayId = view.CompnayId, Integral = view.ConsumptionIntegral }; IntegralInfo integral = new IntegralInfo { CompnayId = view.CompnayId, AccessTime = DateTime.Now, IntegralWay = IntegralWay.RefuseExchange, Remark = reason, Integral = view.ConsumptionIntegral }; count.Integral = integral.Integral; if (count.Integral != 0) { reposity.InsertIntegralInfo(integral); reposity.UpdateIntegralCount(count); if (view.CommodityId.HasValue) { reposity.UpdateShelvesNum(view.CommodityId.Value, view.CommodityCount); } } } cmd.CommitTransaction(); } catch (Exception) { cmd.RollbackTransaction(); throw; } } saveUpdateLog("兑换状态", "处理中", State.GetDescription(), OperatorRole.Platform, id.ToString(), operatorName); }
/// <summary> /// 开户设置积分 /// </summary> /// <param name="companyId"></param> public static void OpenAccountIntegral(Guid companyId) { using (var cmd = Factory.CreateCommand()) { var reposity = Factory.CreateIntegralReposity(cmd); IntegralInfo integral = new IntegralInfo { CompnayId = companyId, AccessTime = DateTime.Now, Integral = SystemParamService.OpenAccountIntegral, IntegralWay = IntegralWay.OpenAccount, Remark = "开户奖励" }; IntegralCount count = new IntegralCount(); count.CompnayId = companyId; count.Integral = SystemParamService.OpenAccountIntegral; reposity.InsertIntegralInfo(integral); reposity.InsertIntegralCount(count); } }
private static void CalculateIntegral(IntegralInfo integralInfo) { int count; Console.WriteLine(integralInfo.Info); foreach (int n in new int[] { 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000 })
public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo) { log4net.ILog log = log4net.LogManager.GetLogger("ColoredConsoleAppender"); // ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); var info = IntegralBusiness.ParseFrom(requestInfo.Body); DAL.DAL.Business business = new DAL.DAL.Business(); //获取用户积分消费卷信息 IntegralInfo integralInfo = business.GetIntegralInfo(info.UserID); if (integralInfo == null) { log.Error("用户不存在"); business.InsertIntegralInfo(info.UserID); var data = Result.CreateBuilder().SetStatus(0).SetMessage("用户不存在").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } //获取业务信息 BusinessModel businessInfo = business.SelectBusiness(info.BusinessID); if (businessInfo == null) { log.Error("该业务不存在"); var data = Result.CreateBuilder().SetStatus(0).SetMessage("该业务不存在").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } //获取操作方式 ActionModel actionInfo = business.SelectAction(businessInfo.action_id); // 处理业务 更新积分信息并返回 integralInfo = business.UpdateIntegralInfo(info.UserID, businessInfo.type, actionInfo, info.Counts); log.Info("更新成功"); var dataResult = Result.CreateBuilder().SetStatus(1).SetMessage("更新成功").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, dataResult.Length, requestInfo.MessageNum, dataResult))); session.Send("更新成功"); //写入日志 var logModel = new LogModel { userID = info.UserID, action = actionInfo.title, business = businessInfo.tittle, type = businessInfo.type, count = info.Counts, dateTime = DateTime.Now, }; business.WriteLog(logModel); }
/// <summary> /// 增加用户购买机票的积分或减少用户退票的积分 /// </summary> /// <param name="IsChinaPay">是否是国付通支付</param> /// <param name="IsBuy">是否是购买机票/退票,true买票,false退票</param> private static void InsertIntergralByMoney(string username, Guid companyId, string companyShortName, decimal money, bool IsChinaPay, string orderId, bool IsBuy) { using (var cmd = Factory.CreateCommand()) { var reposity = Factory.CreateIntegralReposity(cmd); IntegralParameterView prameter = reposity.GetIntegralParameter(); IntegralCount counts = reposity.GetIntegralCount(companyId); IntegralCount count = new IntegralCount { CompnayId = companyId, Integral = prameter.SignIntegral }; if (IsBuy) { IntegralInfo integral = new IntegralInfo { CompnayId = companyId, AccessTime = DateTime.Now, IntegralWay = IntegralWay.Buy, Remark = orderId, Integral = IsChinaPay ? (int)(Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100)) * prameter.Multiple) : (int)Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100)) }; count.Integral = integral.Integral; if (count.Integral != 0) { reposity.InsertIntegralInfo(integral); } } else { IntegralConsumption consumtion = new IntegralConsumption { CompnayId = companyId, AccountName = username, CompanyShortName = companyShortName, AccountNo = "", AccountPhone = "", DeliveryAddress = "", CommodityCount = 0, CommodityId = Guid.Empty, CommodityName = "", Exchange = ExchangeState.Processing, ExchangeTiem = DateTime.Now, ExpressCompany = "", ExpressDelivery = "", Reason = "", Remark = orderId, Way = IntegralWay.TuiPiao }; consumtion.ConsumptionIntegral = IsChinaPay ? (int)(Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100)) * prameter.Multiple) : (int)Math.Floor(money * ((decimal)prameter.ConsumptionIntegral / 100)); count.Integral = 0 - consumtion.ConsumptionIntegral; if (count.Integral != 0) { reposity.InsertIntegralConsumption(consumtion); } } if (count.Integral == 0) { return; } count.IsNotDeduct = true; if (counts == null) { reposity.InsertIntegralCount(count); } else { reposity.UpdateIntegralCount(count); } } }
public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo) { log4net.ILog log = log4net.LogManager.GetLogger("ColoredConsoleAppender"); // ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); var info = RoomCardBusiness.ParseFrom(requestInfo.Body); DAL.DAL.Business business = new DAL.DAL.Business(); //获取用户积分消费卷信息 IntegralInfo integralInfo = business.GetIntegralInfo(info.UserID); if (integralInfo == null) { log.Error("用户不存在"); business.InsertIntegralInfo(info.UserID); var data = ResponseUserInfo.CreateBuilder().SetUserID(info.UserID).SetRoomCard(0).SetIntegral(0).SetCoupons(0).Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10041, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } #region 以前代码 可能有用 ////获取业务信息 //BusinessModel businessInfo = business.SelectBusiness(info.BusinessID); //if (businessInfo == null) //{ // log.Error("该业务不存在"); // var data = Result.CreateBuilder().SetStatus(0).SetMessage("该业务不存在").Build().ToByteArray(); // session.Send(new ArraySegment<byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); // session.Close(); // return; //} ////获取操作方式 //ActionModel actionInfo = business.SelectAction(businessInfo.action_id); ////判断余额是否充足 //if (actionInfo.action=="-") //{ // if (business.GetIntegralInfo(info.UserID, businessInfo.type) - info.Counts < 0) // { // var data = Result.CreateBuilder().SetStatus(0).SetMessage("当前余量不足").Build().ToByteArray(); // session.Send(new ArraySegment<byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); // session.Close(); // return; // } //} //integralInfo = business.UpdateIntegralInfo(info.UserID, businessInfo.type, actionInfo, info.Counts); #endregion // 处理业务 更新积分信息并返回 decimal newRoomCard = integralInfo.roomCard - info.Counts; if (newRoomCard < 0) { var data = Result.CreateBuilder().SetStatus(0).SetMessage("当前余量不足").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, data.Length, requestInfo.MessageNum, data))); session.Close(); return; } bool reslut = business.UpdataRoomCard(info.UserID, newRoomCard); if (!reslut) { var dataResult1 = Result.CreateBuilder().SetStatus(0).SetMessage("更新失败").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, dataResult1.Length, requestInfo.MessageNum, dataResult1))); session.Close(); return; } log.Info("更新成功"); var dataResult = Result.CreateBuilder().SetStatus(1).SetMessage("更新成功").Build().ToByteArray(); session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10001, dataResult.Length, requestInfo.MessageNum, dataResult))); //session.Send("更新成功"); //写入日志 //var logModel = new LogModel //{ // userID = info.UserID, // action = info.BusinessID, // business = info.BusinessID, // type = info.BusinessID, // count = info.Counts, // dateTime = DateTime.Now, //}; //business.WriteLog(logModel); }