Exemple #1
0
        public ActionResult VipForwardApply(MReqVipForward model, string userID)
        {
            #region 校验数据
            if (string.IsNullOrWhiteSpace(userID))
            {
                return(Json(Comm.ToJsonResult("Error", "userID参数不能为空")));
            }
            if (model == null)
            {
                return(Json(Comm.ToJsonResult("Error", "提交的数据不能为空")));
            }
            if (model.bankAccountID <= 0)
            {
                return(Json(Comm.ToJsonResult("Error", "请选择银行卡")));
            }
            if (model.forwardAmount <= 0)
            {
                return(Json(Comm.ToJsonResult("Error", "请输入提现金额")));
            }
            if (model.forwardAmount < 50)
            {
                return(Json(Comm.ToJsonResult("Error", "提现金额不能少于50")));
            }
            if (model.forwardAmount > 20000)
            {
                return(Json(Comm.ToJsonResult("Error", "提现金额不能高于2万")));
            }
            if (model.forwardAmount % 50 != 0)
            {
                return(Json(Comm.ToJsonResult("Error", "提现金额必须为50的整数倍")));
            }
            #endregion

            #region
            RequestResult result = bll.VipForwardApply(model, userID);
            if (result.retCode == ReqResultCode.success)
            {
                return(Json(Comm.ToJsonResult("Success", result.retMsg, result.objectData)));
            }
            else
            {
                return(Json(Comm.ToJsonResult("Error", result.retMsg)));
            }
            #endregion
        }
Exemple #2
0
        /// <summary>
        /// 提现申请
        /// </summary>
        /// <param name="model"></param>
        /// <param name="vUserID"></param>
        /// <returns></returns>
        public RequestResult VipForwardApply(MReqVipForward model, string vUserID)
        {
            #region
            RequestResult result = new RequestResult()
            {
                retCode = ReqResultCode.failed,
                retMsg  = "申请提现失败"
            };

            int      rows     = 0;
            OrderBLL orderbll = new OrderBLL();
            try
            {
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    VipForwardAccount account = db.VipForwardAccounts.FirstOrDefault(p => p.ID == model.bankAccountID);
                    Vip vip = db.Vips.FirstOrDefault(p => p.UserID == vUserID);
                    if (vip == null)
                    {
                        result.retMsg = $"vip用户不存在";
                        return(result);
                    }
                    else if (vip.Amount < model.forwardAmount)
                    {
                        result.retMsg = $"可提现金额不足{model.forwardAmount}元";
                        return(result);
                    }
                    if (account != null)
                    {
                        if (account.UserID == vUserID)
                        {
                            //创建订单
                            VipForwardOrder order = new VipForwardOrder()
                            {
                                Amount           = 0,
                                Code             = orderbll.CreateOrderCode(vUserID),
                                CreateDateTime   = DateTime.Now,
                                ReceivableAmount = model.forwardAmount,
                                State            = Common.Enums.VipForwardState.Waiting,
                                ToAccount        = account.ForwardAccount,
                                Type             = Common.Enums.VipForwardType.BankCard,
                                UserID           = account.UserID
                            };
                            db.VipForwardOrders.Add(order);
                            //冻结提现金额
                            vip.Amount       -= model.forwardAmount;
                            vip.FrozenAmount += model.forwardAmount;
                            rows              = db.SaveChanges();
                        }
                        else
                        {
                            result.retMsg = $"银行卡信息有误";
                            return(result);
                        }
                    }
                    else
                    {
                        result.retMsg = $"提现银行卡不存在";
                        return(result);
                    }
                }

                if (rows > 0)
                {
                    result.retCode = ReqResultCode.success;
                    result.retMsg  = $"提现申请成功";
                }
                else
                {
                    result.retMsg = $"提现申请失败";
                }
            }
            catch (Exception ex)
            {
                result.retCode = ReqResultCode.excetion;
                result.retMsg  = $"提现申请时发生异常:{ex.Message}";
                //调试日志
                Comm.WriteLog("exception", result.retMsg, Common.Enums.DebugLogLevel.Error, "Bll.VipForwardBLL.VipForwardApply");
            }

            return(result);

            #endregion
        }