/// <summary> /// 发起售卖 /// </summary> /// <returns></returns> public JsonResult StartSale(string payPwd, int type, int Qty, decimal TotalPrice, int IsMoney = 1) { //验证支付密码 if (Auxiliary.Md5Encrypt(payPwd) != _ServiceContext.SND_CurrentUser.PayPwd) { return(Json(new { result = false, msg = "支付密码错误!" })); } bool result = false; string msg = ""; int userId = _ServiceContext.SND_CurrentUser.UserId; UserInfo user = _userBll.GetUserInfoById(userId); if (string.IsNullOrEmpty(user.BankNumber)) { return(Json(new { result = result, msg = "您的银行卡不能为空,请完善您的个人信息!" })); } if (Qty < 200) { return(Json(new { result = result, msg = "EP/ZFC售卖单笔最低数量为200!" })); } if (Qty > 20000) { return(Json(new { result = result, msg = "EP/ZFC售卖单笔最大数量为20000!" })); } if (Qty % 200 != 0) { return(Json(new { result = result, msg = "EP/ZFC售卖数量必须为200的倍数!" })); } //判断账户余额是否足够 result = _accountBll.CheckAccountBalance(Qty, type, userId); if (!result) { if (type == 1) { return(Json(new { result = result, msg = "当前EP余额不足或没有足够的保证金!" })); } else { return(Json(new { result = result, msg = "当前Zfc余额不足或没有足够的保证金!" })); } } //判断是否有在售订单 int orderCount = _bll.GetOnSaleOrderCountByUserId(userId); if (orderCount > 0) { return(Json(new { result = result, msg = "您有一笔尚未完成的售卖订单,暂时不能发起新的售卖!" })); } //判断近24小时有没有订单 result = _bll.CheckOrderCountByUserId(userId); if (result) { return(Json(new { result = result, msg = "您在24小时之内产生过一笔交易,暂时不能发起新的售卖!" })); } //创建订单 result = _bll.CreateOrder(Qty, type, userId, TotalPrice, IsMoney); //订单创建成功,冻结账户(包括保证金) if (result) { result = _accountBll.FreezeAccount(Qty, type, userId, 1); } else { return(Json(new { result = result, msg = "创建订单失败,请稍后再试!" })); } return(Json(new { result = result, msg = "发起挂卖单成功!" })); }