/// <summary> /// 重置用户分成 /// </summary> /// <param name="userId"></param> /// <returns></returns> public int ResetUserPrice(int userId) { using (var conn = this.ConnectionFactory.OpenConnection()) { var tran = conn.BeginTransaction(); try { var res = conn.Delete <Userprice>(new { Userid = userId }, tran); var userprice = conn.QueryList <Acc>(new { is_display = 0 }, null, tran); List <Userprice> list = new List <Userprice>(); foreach (var item in userprice) { Userprice model = new Userprice { Userid = userId, Channelid = item.Id, Uprice = item.Uprice, Gprice = item.Gprice, Is_state = item.Is_state, Addtime = DateTime.Now }; list.Add(model); } res += conn.InsertList(list, null, tran); tran.Commit(); return(res); } catch (Exception ex) { tran.Rollback(); throw; } } }
public IActionResult SaveUserPrice([FromBody] JObject obj) { var str = obj["postJson"].ToString(); var priceList = JsonConvert.DeserializeObject <List <JsonUprice> >(str); if (priceList != null) { List <Userprice> list = new List <Userprice>(); foreach (var item in priceList) { Userprice userprice = new Userprice() { Userid = item.Userid, Channelid = item.Channelid, Uprice = item.Userid, Gprice = item.Gprice, Is_state = item.Is_state, Addtime = DateTime.Now }; list.Add(userprice); } var res = _usersSvc.InsertUpriceList(list, this.UserId); if (res.IsSuccess) { this.ResponseResult.Result = 1; this.ResponseResult.Message = res.Message; this.ResponseResult.Data = "Users/User/Index"; } else { this.ResponseResult.Result = 0; this.ResponseResult.Message = res.Message; this.ResponseResult.Data = "Users/User/Index"; } } else { this.ResponseResult.Result = 0; this.ResponseResult.Message = "更新失败"; this.ResponseResult.Data = "Users/User/Index"; } return(Json(this.ResponseResult)); }