Beispiel #1
0
        /// <summary>
        /// EP转账
        /// </summary>
        /// <param name="mobileNumber"></param>
        /// <param name="Ep"></param>
        /// <returns></returns>
        public JsonResult EPSend(string mobileNumber, string Ep)
        {
            bool    result = false;
            decimal ep     = 0;
            //验证数据
            var userInfo = _userBll.GetUserInfoByUserName(mobileNumber);//接受人的信息

            if (userInfo == null)
            {
                return(Json(new { result = false, msg = "输入的用户不存在!" }));
            }
            if (userInfo.UserId == _ServiceContext.SND_CurrentUser.UserId)
            {
                return(Json(new { result = false, msg = "不能送EP给自己!" }));
            }
            result = decimal.TryParse(Ep, out ep);

            if (!result)
            {
                return(Json(new { result = false, msg = "请输入正确的数量!" }));
            }
            if (ep < 1)
            {
                return(Json(new { result = false, msg = "数量不能少于1!" }));
            }
            AccountInfo sendAccount = new AccountInfo();
            AccountInfo reAccount   = new AccountInfo();

            sendAccount = _accountBll.GetAccByUserId(_ServiceContext.SND_CurrentUser.UserId);
            reAccount   = _accountBll.GetAccByUserId(userInfo.UserId);

            if (sendAccount.Ep < ep)
            {
                return(Json(new { result = false, msg = "账户EP不足!" }));
            }

            //进行转账
            sendAccount.Ep -= ep;
            reAccount.Ep   += ep;

            result = _accountBll.UpdateAccInfo(sendAccount);
            if (result)
            {
                result = _accountBll.UpdateAccInfo(reAccount);
            }
            else
            {
                return(Json(new { result = false, msg = "赠送失败,请稍后再试!" }));
            }

            //添加EP转账记录

            CrossRotation model = new CrossRotation();

            model.CRAccountName = sendAccount.AccountName;
            model.CreateTime    = DateTime.Now;
            model.CRType        = 1;
            model.CRUserId      = _ServiceContext.SND_CurrentUser.UserId;
            model.Qty           = ep;
            model.REAccountName = reAccount.AccountName;
            model.Remark        = "";
            model.REUserId      = userInfo.UserId;

            result = _logBll.InsertCrossRotationLog(model);



            return(Json(new { result = true, msg = "赠送成功!" }));
        }