public async Task <ApiResult> Apply(TakeCashApplyModel model) { if (model.Amount <= 0) { return(new ApiResult { status = 0, msg = "提现金额必须大于零" }); } if (model.Amount % 100 != 0) { return(new ApiResult { status = 0, msg = "提现金额必是100的倍数" }); } if (model.PayTypeId <= 0) { return(new ApiResult { status = 0, msg = "提现收款类型id必须大于零" }); } User user = JwtHelper.JwtDecrypt <User>(ControllerContext); var userres = await userService.GetModelAsync(user.Id); if (userres.LevelName == "普通会员") { return(new ApiResult { status = 0, msg = "普通会员不能提现" }); } if (user == null) { return(new ApiResult { status = 0, msg = "用户不存在" }); } long id = await takeCashService.AddAsync(user.Id, model.PayTypeId, model.Amount, "佣金提现"); if (id <= 0) { if (id == -1) { return(new ApiResult { status = 0, msg = "用户不存在" }); } if (id == -2) { return(new ApiResult { status = 0, msg = "用户账户余额不足" }); } if (id == -4) { return(new ApiResult { status = 0, msg = "-4" }); } return(new ApiResult { status = 0, msg = "申请提现失败" }); } return(new ApiResult { status = 1, msg = "申请提现成功" }); }
public async Task <ApiResult> Apply(TakeCashApplyModel model) { if (model.Amount <= 0) { return(new ApiResult { status = 0, msg = "提现金额必须大于零" }); } if (model.Amount % 100 != 0) { return(new ApiResult { status = 0, msg = "提现金额必是100的倍数" }); } //if (model.PayTypeId <= 0) //{ // return new ApiResult { status = 0, msg = "提现收款类型id必须大于零" }; //} User user = JwtHelper.JwtDecrypt <User>(ControllerContext); var userres = await userService.GetModelAsync(user.Id); if (userres.LevelName == "普通会员") { return(new ApiResult { status = 0, msg = "普通会员不能提现" }); } if (user == null) { return(new ApiResult { status = 0, msg = "用户不存在" }); } decimal amount = model.Amount; decimal poundage = 0; decimal parm; decimal.TryParse(await settingService.GetParmByNameAsync("提现手续费"), out parm); if (parm != 0) { poundage = amount * parm / 100; } long id = await takeCashService.AddAsync(user.Id, model.PayTypeId, amount, poundage, "佣金提现"); if (id <= 0) { if (id == -1) { return(new ApiResult { status = 0, msg = "用户不存在" }); } if (id == -2) { return(new ApiResult { status = 0, msg = "用户账户余额不足" }); } if (id == -4) { return(new ApiResult { status = 0, msg = "您未绑定银行卡账号" }); } return(new ApiResult { status = 0, msg = "申请提现失败" }); } return(new ApiResult { status = 1, msg = $"申请提现成功,手续费:{poundage}元" }); }
public async Task <ApiResult> Apply(TakeCashApplyModel model) { User user = JwtHelper.JwtDecrypt <User>(ControllerContext); if (model.Amount <= 0) { return(new ApiResult { status = 0, msg = "提现金额必须大于零" }); } // if (user.Id != 157) //{ // if (model.Amount % 100 != 0) // { // return new ApiResult { status = 0, msg = "提现金额必是100的倍数" }; // } //} //if (model.PayTypeId <= 0) //{ // return new ApiResult { status = 0, msg = "提现收款类型id必须大于零" }; //} model.PayTypeId = 40; var userres = await userService.GetModelAsync(user.Id); if (user == null) { return(new ApiResult { status = 0, msg = "用户不存在" }); } if (userres.Amount < model.Amount) { return new ApiResult { status = 0, msg = "账户余额不足" } } ; log.DebugFormat($"提现 takeCashService TakeToWxMone code :{userres.Code} ,#1"); //调用微信接口,企业付款到零钱 var wxResult = await TakeToWxMoney(model.Amount, userres.Code); log.DebugFormat($"提现 takeCashService TakeToWxMone code :{userres.Code} ,#2"); if (!wxResult.result_code.Contains("SUCCESS")) { return new ApiResult { status = 0, msg = wxResult.return_msg } } ; long id = await takeCashService.AddAsync(user.Id, model.PayTypeId, model.Amount, "佣金提现", wxResult.partner_trade_no, wxResult.payment_no, DateTime.Parse(wxResult.payment_time)); if (id <= 0) { if (id == -1) { return(new ApiResult { status = 0, msg = "用户不存在" }); } if (id == -2) { return(new ApiResult { status = 0, msg = "用户账户余额不足" }); } if (id == -4) { return(new ApiResult { status = 0, msg = "-4" }); } log.DebugFormat($"提现 takeCashService.AddAsync:申请提现失败,id:{id}"); return(new ApiResult { status = 0, msg = "提现失败" }); } log.DebugFormat($"提现 takeCashService TakeToWxMone :申请提现成功 {userres.Code},id:{id}"); return(new ApiResult { status = 1, msg = "提现成功" }); }