public void ProcessRequest(HttpContext context) { int rows = Convert.ToInt32(context.Request["rows"]); int page = Convert.ToInt32(context.Request["page"]); string id = context.Request["id"]; string sum = context.Request["sum"]; string websiteOwner = bll.WebsiteOwner; TeamPerformance performance = bll.GetColByKey <TeamPerformance>("AutoId", id, "AutoId,YearMonth,DetailIds"); string ids = string.IsNullOrWhiteSpace(performance.DetailIds) ? "-1" : performance.DetailIds; int yearMonth = performance.YearMonth; int total = bll.GetPerformanceDetailCount("", "", websiteOwner, yearMonth, "", ids); List <TeamPerformanceDetails> performanceList = new List <TeamPerformanceDetails>(); if (total > 0) { performanceList = bll.GetPerformanceDetailList(rows, page, "", "", websiteOwner, yearMonth, "", ids); } decimal sumPerformance = 0; if (sum == "1") { sumPerformance = bll.GetPerformanceDetailSum("", "", websiteOwner, yearMonth, "", ids); } List <dynamic> resultList = new List <dynamic>(); if (performanceList.Count > 0) { string parentIds = ZentCloud.Common.MyStringHelper.ListToStr(performanceList.Select(p => p.DistributionOwner).ToList(), "'", ","); List <UserInfo> uuList = bll.GetColMultListByKey <UserInfo>(int.MaxValue, 1, "UserID", parentIds, "AutoID,UserID,TrueName,Phone", websiteOwner: websiteOwner); foreach (TeamPerformanceDetails item in performanceList) { UserInfo pu = uuList.FirstOrDefault(p => p.UserID == item.DistributionOwner); resultList.Add(new { id = item.AutoId, name = item.UserName, phone = item.UserPhone, pid = pu.AutoID, pname = pu.TrueName, pphone = pu.Phone, performance = item.Performance, addtype = item.AddType, addnote = item.AddNote, addtime = item.AddTime.ToString("yyyy/MM/dd HH:mm:ss") }); } } apiResp.result = new { totalcount = total, list = resultList, sum = sumPerformance }; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "获取业绩列表"; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string user_auto_id = context.Request["user_auto_id"]; string keys = context.Request["keys"]; string keynames = context.Request["keynames"]; string websiteOwner = bll.WebsiteOwner; UserInfo user = bll.GetColByKey <UserInfo>("AutoID", user_auto_id, "AutoID,UserID", websiteOwner: websiteOwner); if (user == null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.status = false; apiResp.msg = "会员未找到"; bll.ContextResponse(context, apiResp); return; } List <string> keyList = keys.Split(',').ToList(); List <string> keyNameList = keynames.Split(',').ToList(); Dictionary <decimal, decimal> dicPerformance = new Dictionary <decimal, decimal>(); Dictionary <decimal, string> dicName = new Dictionary <decimal, string>(); for (int i = 0; i < keyList.Count; i++) { string keyString = keyList[i]; string keyName = keyNameList[i]; string valueString = context.Request[keyString]; decimal key = Convert.ToDecimal(keyString.Substring(1)); decimal value = Convert.ToDecimal(valueString); dicPerformance.Add(key, value); dicName.Add(key, keyName); } List <TeamPerformanceSet> userSetList = bll.GetSetList(int.MaxValue, 1, websiteOwner, user.UserID); BLLTransaction tran = new BLLTransaction(); foreach (TeamPerformanceSet item in userSetList.Where(p => dicPerformance.ContainsKey(p.Performance))) { item.RewardRate = dicPerformance[item.Performance]; if (!bll.Update(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.status = false; apiResp.msg = item.Name + "更新错误"; bll.ContextResponse(context, apiResp); return; } } foreach (var item in dicPerformance.Where(p => !userSetList.Exists(pi => pi.Performance == p.Key))) { TeamPerformanceSet set = new TeamPerformanceSet(); set.UserId = user.UserID; set.WebsiteOwner = websiteOwner; set.Name = dicName[item.Key]; set.Performance = item.Key; set.RewardRate = item.Value; if (!bll.Add(set, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.status = false; apiResp.msg = set.Name + "新增错误"; bll.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "设置成功"; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int rows = int.MaxValue; int page = 1; string id = context.Request["id"]; string websiteOwner = bll.WebsiteOwner; TeamPerformance performance = bll.GetColByKey <TeamPerformance>("AutoId", id, "AutoId,YearMonth,DetailIds"); string ids = string.IsNullOrWhiteSpace(performance.DetailIds) ? "-1" : performance.DetailIds; int yearMonth = performance.YearMonth; int total = bll.GetPerformanceDetailCount("", "", websiteOwner, yearMonth, "", ids); List <TeamPerformanceDetails> performanceList = new List <TeamPerformanceDetails>(); if (total > 0) { performanceList = bll.GetPerformanceDetailList(rows, page, "", "", websiteOwner, yearMonth, "", ids); } DataTable dt = new DataTable(); dt.Columns.Add("会员手机", typeof(string)); dt.Columns.Add("会员姓名", typeof(string)); dt.Columns.Add("推荐人手机", typeof(string)); dt.Columns.Add("推荐人姓名", typeof(string)); dt.Columns.Add("月份", typeof(int)); dt.Columns.Add("事件", typeof(string)); dt.Columns.Add("金额", typeof(decimal)); dt.Columns.Add("时间", typeof(string)); dt.Columns.Add("说明", typeof(string)); if (performanceList.Count > 0) { string parentIds = ZentCloud.Common.MyStringHelper.ListToStr(performanceList.Select(p => p.DistributionOwner).ToList(), "'", ","); List <UserInfo> uuList = bll.GetColMultListByKey <UserInfo>(int.MaxValue, 1, "UserID", parentIds, "AutoID,UserID,TrueName,Phone", websiteOwner: websiteOwner); foreach (TeamPerformanceDetails item in performanceList) { UserInfo pu = uuList.FirstOrDefault(p => p.UserID == item.DistributionOwner); DataRow dr = dt.NewRow(); dr["会员手机"] = item.UserPhone; dr["会员姓名"] = item.UserName; dr["推荐人手机"] = pu == null ? "" : pu.Phone; dr["推荐人姓名"] = pu == null ? "" : pu.TrueName; dr["月份"] = item.YearMonth; dr["事件"] = item.AddType; dr["金额"] = item.Performance; dr["时间"] = item.AddTime.ToString("yyyy-MM-dd HH:mm:ss"); dr["说明"] = item.AddNote; dt.Rows.Add(dr); } dt.AcceptChanges(); } MemoryStream ms = Web.DataLoadTool.NPOIHelper.Export(dt, "会员业绩明细"); ExportCache exCache = new ExportCache() { FileName = string.Format("会员业绩明细{0}.xls", DateTime.Now.ToString("yyyyMMddHHmm")), Stream = ms }; string cache = Guid.NewGuid().ToString("N").ToUpper(); ZentCloud.Common.DataCache.SetCache(cache, exCache, slidingExpiration: TimeSpan.FromMinutes(5)); apiResp.status = true; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; apiResp.msg = "生成完成"; apiResp.result = new { cache = cache }; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int rows = Convert.ToInt32(context.Request["rows"]); int page = Convert.ToInt32(context.Request["page"]); int field_count = Convert.ToInt32(context.Request["field_count"]); if (field_count == 0) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.status = false; apiResp.msg = "请传入字段数"; apiResp.result = new { totalcount = 0, list = new List <string>() }; bll.ContextResponse(context, apiResp); return; } rows = rows * field_count; string phone = context.Request["phone"]; string websiteOwner = bll.WebsiteOwner; string searchUserId = ""; if (!string.IsNullOrWhiteSpace(phone)) { UserInfo searchUser = bll.GetColByKey <UserInfo>("Phone", phone, "AutoID,UserID", websiteOwner: websiteOwner); searchUserId = searchUser == null ? "" : searchUser.UserID; } JArray resultList = new JArray(); int total = bll.GetSetCount(websiteOwner, searchUserId); List <TeamPerformanceSet> userSetList = new List <TeamPerformanceSet>(); if (total > 0) { userSetList = bll.GetSetList(rows, page, websiteOwner, searchUserId); } if (userSetList.Count > 0) { List <string> userIdList = userSetList.Select(p => p.UserId).Distinct().ToList(); string userIds = ZentCloud.Common.MyStringHelper.ListToStr(userIdList, "'", ","); List <UserInfo> userList = bll.GetColMultListByKey <UserInfo>(int.MaxValue, 1, "UserID", userIds, "AutoID,UserID,TrueName,Phone"); foreach (string userId in userIdList) { UserInfo user = userList.FirstOrDefault(p => p.UserID == userId); JObject jItem = new JObject(); jItem["user_id"] = userId; if (userId == websiteOwner) { jItem["user_phone"] = ""; jItem["user_name"] = "系统"; jItem["is_sys"] = 1; jItem["user_auto_id"] = user.AutoID; } else { jItem["user_phone"] = user == null ? "" : user.Phone; jItem["user_name"] = user == null ? "" : user.TrueName; jItem["is_sys"] = 0; jItem["user_auto_id"] = 0; } foreach (TeamPerformanceSet item in userSetList.Where(p => p.UserId == userId)) { jItem["p" + Convert.ToInt64(item.Performance)] = Convert.ToInt32(item.RewardRate) + "%"; } resultList.Add(jItem); } } apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "管理奖设置列表"; apiResp.result = new { totalcount = total / field_count, list = resultList }; bll.ContextResponse(context, apiResp); }