public JsonResult SaveRecharge(SaveRechargeRequest request) { var response = new JResult <string>() { Status = false }; #if DEBUG //request.Amount = new decimal(0.01); #else #endif //当前上下文 var context = CustomerContext.Context; if (context == null) { response.Message = "用户已超时、请重新登录﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } if (request.PayWay.Equals(10)) { //支付订单编号 var orderNo = Guid.NewGuid().ToString().Replace("-", ""); var recharge = new FnRecharge() { OrderNo = orderNo, CustomerSysNo = context.SysNo, Amount = request.Amount, Remarks = string.Format("用户:{0},充值金额:{1}", context.RealName, request.Amount), Status = PayStatus.未支付.GetHashCode(), Type = FnEnum.RechargeType.充值.GetHashCode(), CreatedDate = DateTime.Now }; if (RechargeApp.Instance.Insert(recharge) <= 0) { response.Message = "创建订单失败、联系管理员!"; return(Json(response, JsonRequestBehavior.AllowGet)); } response.Status = true; response.Data = orderNo; } else if (request.PayWay.Equals(20)) { lock (_lock) { if (context.WalletAmount < request.Amount) { response.Message = "奖金余额不足!"; return(Json(response, JsonRequestBehavior.AllowGet)); } if (CustomerApp.Instance.UpdateBonusRecharge(new CrCustomer() { SysNo = context.SysNo, WalletAmount = request.Amount, UpgradeFundAmount = request.Amount, RechargeTotalAmount = request.Amount }) <= 0) { response.Message = "奖金充值失败、联系管理员!"; return(Json(response, JsonRequestBehavior.AllowGet)); } response.Status = true; } } else { response.Message = "参数错误!"; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public JsonResult UpgradeSaveRecharge(SaveRechargeRequest request) { var response = new JResult <string>() { Status = false }; //当前上下文 var context = CustomerContext.Context; if (context == null) { response.Message = "用户已超时、请重新登录﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } //获取会员 var customer = CustomerApp.Instance.Get(context.SysNo); if (customer == null) { response.Message = "扩展会员不存在﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } var upgradeGrade = customer.Grade + Step.步长.GetHashCode(); decimal PayAmount = 0; var code = CodeApp.Instance.GetByType(EC.Entity.Enum.CodeEnum.CodeTypeEnum.会员等级信息.GetHashCode()); if (code != null) { var grades = code.Value.ToObject <List <Grade> >(); var grade = grades.FirstOrDefault(p => p.Type == upgradeGrade); if (grade != null) { if (customer.UpgradeFundAmount > grade.Amount) { ViewBag.PayAmount = 0.ToString("#0.00"); } else { PayAmount = grade.Amount - customer.UpgradeFundAmount; } } } //支付订单编号 var orderNo = Guid.NewGuid().ToString().Replace("-", ""); var recharge = new FnRecharge(); if (context.Account.Equals("15008228718")) { recharge.OrderNo = orderNo; recharge.CustomerSysNo = context.SysNo; recharge.Amount = new decimal(0.01); recharge.Remarks = string.Format("用户:{0},升级金额:{1}", context.RealName, new decimal(0.01)); recharge.Status = PayStatus.未支付.GetHashCode(); recharge.Type = FnEnum.RechargeType.升级.GetHashCode(); recharge.CreatedDate = DateTime.Now; } else { recharge.OrderNo = orderNo; recharge.CustomerSysNo = context.SysNo; recharge.Amount = PayAmount; recharge.Remarks = string.Format("用户:{0},升级金额:{1}", context.RealName, PayAmount); recharge.Status = PayStatus.未支付.GetHashCode(); recharge.Type = FnEnum.RechargeType.升级.GetHashCode(); recharge.CreatedDate = DateTime.Now; } if (RechargeApp.Instance.Insert(recharge) <= 0) { response.Message = "创建订单失败、联系管理员!"; return(Json(response, JsonRequestBehavior.AllowGet)); } response.Status = true; response.Data = orderNo; return(Json(response, JsonRequestBehavior.AllowGet)); }