public async Task <IActionResult> PostMemberInfoAsync([FromHeader] String source, [FromRoute] RouteIdInt route, [FromBody] MemberInfoPost item) { var response = new Response <Object>(); try { if (await _IMemberInfoRepository.IsExistAsync(a => a.MemberId == route.id && a.IsEnable == 1)) { var entity = await _IMemberInfoRepository.FirstOrDefaultAsync(a => a.MemberId == route.id); if (!string.IsNullOrEmpty(item.NickName)) { entity.NickName = item.NickName; } if (item.Sex.HasValue) { entity.Sex = item.Sex; } if (!string.IsNullOrEmpty(item.Phone)) { entity.Phone = item.Phone; } if (!string.IsNullOrEmpty(item.Name)) { entity.Name = item.Name; } if (!string.IsNullOrEmpty(item.Alipay)) { entity.Alipay = item.Alipay; await _ITaskInfoApp.AddTasks("T0004", new TaskItem() { MemberId = entity.MemberId, InvitedId = 0, FromMark = 0 }); } //注销账号 entity.IsEnable = item.IsEnable;//注销 _IMemberInfoRepository.Update(entity); response.Code = await _IMemberInfoRepository.SaveChangesAsync() > 0; response.Message = "修改成功"; } else { return(NotFound()); } } catch (Exception ex) { response.SetError(ex, this._ILogger); } return(response.ToHttpResponse()); }
public async Task <IActionResult> PostUserLoginAsync([FromHeader] String source, [FromBody] LoginPost item) { var response = new Response <JwtAuthorData>(); try { item.Password = Tools.Md5(item.Password); var entity = await _IMemberInfosRepository.FirstOrDefaultAsync(a => a.Phone == item.LoginName && a.Password == item.Password && a.IsEnable == 1); if (entity != null) { var result = _IJwtRedis.Create(entity); if (result != null) { await _IMemberInfosRepository.BatchUpdateAsync(a => a.MemberId == entity.MemberId, a => new MemberInfos() { LastLoginTime = System.DateTime.Now }); response.Code = true; response.Data = result; } else { return(BadRequest("登录授权失败!")); } } else { return(NotFound("用户不存在!")); } } catch (Exception ex) { response.SetError(ex, this._ILogger); } return(response.ToHttpResponse()); }
public async Task <IActionResult> PostMemberWithdrawIncomeAsync([FromHeader] String source, [FromBody] MemberWithdrawPost item) { var response = new Response <object>(); try { var memberInfo = await _IMemberInfoRepository.FirstOrDefaultAsync(a => a.MemberId == item.id && a.IsEnable == 1); if (memberInfo != null) { //更新用户金币 memberInfo.Beans -= item.beans; memberInfo.BeansTotals -= item.beans; _IMemberInfoRepository.Update(memberInfo); //插入会员提现记录 await _IMemberWithdrawRepository.AddAsync(new MemberWithdraw { WithdrawId = new SnowFlake().GetLongId(), MemberId = memberInfo.MemberId, Methods = item.methods, Title = "提现扣金币", Beans = item.beans, Amount = Convert.ToDecimal(item.beans) / Convert.ToDecimal(_Before), Proportion = $"{_Before}/{_After}", CreateTime = DateTime.Now, Audit = "admin", AuditId = 1, AuditTime = DateTime.Now, Status = 1 }); int flag = _IMemberInfoRepository.SaveChanges();//保存Db if (flag > 0) { response.Code = true; response.Message = "Success"; } } } catch (Exception ex) { response.SetError(ex, this._ILogger); } return(response.ToHttpResponse()); }