//Send Client Log public int SendClientLog(string log) { SupportParam param = new SupportParam(); param.player_id = apiPlayerId; param.message = log; string paramJson = JsonUtility.ToJson(param); API api = new API("sendclientlog.php", "RSendClientLog", paramJson, 1); param = null; paramJson = ""; StartCoroutine(Congest.SendPOST(this, api)); return(api.seed); }
public int SendSupport(string email, string message, string ticketId = "", int playerId = 0, string token = "") { if (ParseToken(playerId, token)) { SupportParam param = new SupportParam(); param.player_id = apiPlayerId; param.token = apiToken; param.ticket_id = (ticketId.Length > 0 ? ticketId : apiPlayerId.ToString() + System.DateTime.UtcNow.ToString("yyMMdd") + UnityEngine.Random.Range(0, 9999).ToString()); param.email = email; param.message = message; string paramJson = JsonUtility.ToJson(param); API api = new API("sendsupport.php", "RSendSupport", paramJson, 1); param = null; paramJson = ""; StartCoroutine(Congest.SendPOST(this, api)); return(api.seed); } return(0); }
public async Task <Result> Support([FromBody] SupportParam param) { var user = await _workContext.GetCurrentOrThrowAsync(); var any = supportEntityTypeIds.Any(c => c == param.EntityTypeId); if (!any) { throw new Exception("参数不支持"); } var model = await _supportRepository .Query(c => c.UserId == user.Id && c.EntityId == param.EntityId && c.EntityTypeId == (int)param.EntityTypeId) .FirstOrDefaultAsync(); if (model == null) { model = new Support() { UserId = user.Id, EntityId = param.EntityId, EntityTypeId = (int)param.EntityTypeId }; _supportRepository.Add(model); } else { model.IsDeleted = true; model.UpdatedOn = DateTime.Now; } var supportCount = 0; switch (param.EntityTypeId) { case EntityTypeWithId.Review: { var review = await _reviewRepository.FirstOrDefaultAsync(param.EntityId); if (review == null) { throw new Exception("评论信息不存在"); } review.SupportCount += model.IsDeleted ? -1 : 1; review.UpdatedOn = DateTime.Now; supportCount = review.SupportCount; } break; case EntityTypeWithId.Reply: { var reply = await _replyRepository.FirstOrDefaultAsync(param.EntityId); if (reply == null) { throw new Exception("评论信息不存在"); } reply.SupportCount += model.IsDeleted ? -1 : 1; reply.UpdatedOn = DateTime.Now; supportCount = reply.SupportCount; } break; default: throw new Exception("参数不支持"); } using (var tran = _supportRepository.BeginTransaction()) { await _reviewRepository.SaveChangesAsync(); await _replyRepository.SaveChangesAsync(); await _supportRepository.SaveChangesAsync(); tran.Commit(); } return(Result.Ok(supportCount)); }