Example #1
0
 public ActionResult RechargeAmount(Recharge model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             //开启事务,保证数据的一致性
             using (var scope = new TransactionScope())
             {
                 if (!OperateHelper.IsLogin())
                 {
                     return JsonMsgNoOk("对不起,你没权限操作");
                 }
                 if (!OperateHelper.User.IsAdmin)
                 {
                     return JsonMsgNoOk("对不起,你没权限操作");
                 }
                 var userModel = BLLSession.IUserService.GetModel(m => m.UserID == model.UserID);
                 //插入充值表
                 model.Status = (int)RechargeStatusEnum.Succeed;
                 model.IsDel = false;
                 model.CreateDate = DateTime.Now;
                 model.OpeningBalance = userModel.Amount;
                 model.CurrentBalance = userModel.Amount + model.RechargeAmount;
                 model.RechargeUserName = "******";
                 BLLSession.IRechargeService.Add(model);
                 //更新用户剩余金额
                 userModel.Amount = model.CurrentBalance;
                 BLLSession.IUserService.ModifyModel(userModel);
                 //插入数据到消费流水表
                 BLLSession.IExpendLogService.Add(new ExpendLog()
                 {
                     UserID = model.UserID,
                     ConsumeAmount = 0,
                     RechargeAmount = model.RechargeAmount,
                     CreateDate = DateTime.Now,
                     ExpendLogTypeID = model.RechargeID,
                     ExpendLogType = (int)ExpendLogTypeEnum.Recharge,
                     Description = "充值完成增加金额"
                 });
                 scope.Complete();//提交事务
             }
             return JsonMsgOk("充值成功");
         }
         catch (Exception ex)
         {
             return JsonMsgNoOk(ex.Message);
         }
     }
     return JsonMsgNoOk("充值失败,信息填写有误");
 }
Example #2
0
        //6楼充值样式
        private Model.User Register_6F(User model, RegisterViewModel registerViewModel)
        {
            model.UserName = registerViewModel.UserName;
            model.IPAddress = registerViewModel.IPAddress;
            model.Password = Util.Security.UEncypt.MD5(registerViewModel.Password);
            model.Amount = 10000;//默认充值10000元
            model.CreateDate = DateTime.Now;
            model.IsDel = false;
            model.DepartmentType = registerViewModel.DepartmentType;
            BLLSession.IUserService.Add(model);

            //插入充值表,默认10000元
            Recharge rechargeModel = new Recharge();
            rechargeModel.UserID = model.UserID;
            rechargeModel.RechargeAmount = 10000;
            rechargeModel.Status = (int)RechargeStatusEnum.Succeed;
            rechargeModel.IsDel = false;
            rechargeModel.CreateDate = DateTime.Now;
            rechargeModel.OpeningBalance = 0;
            rechargeModel.CurrentBalance = 10000;
            rechargeModel.RechargeUserName = "******";
            BLLSession.IRechargeService.Add(rechargeModel);

            //插入数据到消费流水表
            BLLSession.IExpendLogService.Add(new ExpendLog()
            {
                UserID = model.UserID,
                ConsumeAmount = 0,
                RechargeAmount = rechargeModel.RechargeAmount,
                CreateDate = DateTime.Now,
                ExpendLogTypeID = rechargeModel.RechargeID,
                ExpendLogType = (int)ExpendLogTypeEnum.Recharge,
                Description = "充值完成增加金额"
            });
            return model;
        }