public void ProcessRequest(HttpContext context) { int yearMonth = Convert.ToInt32(DateTime.Now.ToString("yyyyMM")); if (!string.IsNullOrWhiteSpace(context.Request["yearmonth"])) { yearMonth = Convert.ToInt32(context.Request["yearmonth"]); } bool hideName = true; bool hidePhone = true; string websiteOwner = bll.WebsiteOwner; string userId = CurrentUserInfo.UserID; TeamPerformance myPerformance = bll.GetMyPerformance(userId, websiteOwner, yearMonth); List <TeamPerformance> childPerformanceList = bll.GetChildPerformanceList(int.MaxValue, 1, userId, websiteOwner, yearMonth); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "获取团队业绩"; apiResp.result = new { my = myPerformance == null ? new ResponsePerformce() : new ResponsePerformce { id = myPerformance.AutoID, performance = Convert.ToDouble(myPerformance.Performance), reward = Convert.ToDouble(myPerformance.Reward), status = myPerformance.Status, act_id = myPerformance.FlowActionId, act_status = myPerformance.FlowActionStatus }, list = from p in childPerformanceList select new { id = p.AutoID, name = bllUser.GetUserShowDispalyName(p.UserName, hideName), phone = bllUser.GetUserDispalyPhone(p.UserPhone, hidePhone), performance = p.Performance } }; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; string websiteOwner = bll.WebsiteOwner; TeamPerformance myPerformance = bll.GetByKey <TeamPerformance>("AutoID", id, websiteOwner: websiteOwner); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "获取管理奖信息"; apiResp.result = myPerformance == null ? new ResponsePerformce() : new ResponsePerformce { id = myPerformance.AutoID, member = CurrentUserInfo.TrueName, performance = Convert.ToDouble(myPerformance.Performance), rate = Convert.ToDouble(myPerformance.Rate), total_reward = Convert.ToDouble(myPerformance.TotalReward), child_reward = Convert.ToDouble(myPerformance.ChildReward), reward = Convert.ToDouble(myPerformance.Reward), amount = Convert.ToDouble((myPerformance.Reward * 80 / 100)), fund = Convert.ToDouble((myPerformance.Reward * 20 / 100)) }; bll.ContextResponse(context, apiResp); }
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 id = context.Request["id"]; string websiteOwner = bll.WebsiteOwner; TeamPerformance myPerformance = bll.GetByKey <TeamPerformance>("AutoID", id, websiteOwner: websiteOwner); UserInfo user = bllUser.GetUserInfo(myPerformance.UserId, websiteOwner); List <UserLevelConfig> userLvlist = bll.QueryUserLevelList(websiteOwner, "DistributionOnLine", levelNumber: user.MemberLevel.ToString(), colName: "AutoId,LevelNumber,LevelString", showAll: true); string templatePath = context.Server.MapPath("/JsonConfig/ExcelTemplate/业绩确认表模板.xlsx"); Dictionary <String, Object> dictSource = new Dictionary <string, object>(); if (userLvlist.Count > 0) { dictSource.Add("lvname", userLvlist[0].LevelString); } dictSource.Add("name", user.TrueName); dictSource.Add("performance", Convert.ToDouble(myPerformance.Performance).ToString()); dictSource.Add("rate", Convert.ToDouble(myPerformance.Rate) + "%"); dictSource.Add("totalreward", Convert.ToDouble(myPerformance.TotalReward).ToString()); dictSource.Add("childreward", Convert.ToDouble(myPerformance.ChildReward).ToString()); dictSource.Add("fund", Convert.ToDouble((myPerformance.Reward * 20 / 100)).ToString()); decimal trueamount = (myPerformance.Reward * 80 / 100); dictSource.Add("amount", Convert.ToDouble(trueamount).ToString()); string ym = myPerformance.YearMonth.ToString(); string dicYearmonth = ym.Substring(0, 4) + "年" + ym.Substring(4) + "月"; string dicMinAmount = trueamount.ToString("N"); dictSource.Add("lower", string.Format("{0}应结算总金额 人民币小写:{1}", dicYearmonth, dicMinAmount)); string cnAmount = CommonPlatform.Helper.MoneyHelper.GetCnString(trueamount.ToString()); dictSource.Add("upper", string.Format(" 人民币大写:{0}", cnAmount)); List <TeamPerformanceDetails> performanceList = bll.GetPerformanceDetailList(int.MaxValue, 1, "", "", websiteOwner, myPerformance.YearMonth, "", myPerformance.DetailIds); DataTable dt = null; if (performanceList.Count > 0) { List <lvGroup> lvList = performanceList.Where(p => p.AddType == "注册").GroupBy(g => new{ up = g.Performance, cate = g.AddNote.Replace("注册", "").Replace("实单审核", "") }).Select(l => new lvGroup { cate = l.Key.cate, count = l.Count(), up = l.Key.up, amount = l.Sum(li => li.Performance) }).OrderBy(a => a.amount).ToList(); List <lvGroup> upList = performanceList.Where(p => p.AddType == "升级").GroupBy(g => new{ cate = "升级金额" }).Select(l => new lvGroup { cate = l.Key.cate, count = l.Count(), amount = l.Sum(li => li.Performance) }).OrderBy(a => a.amount).ToList(); List <lvGroup> ceList = performanceList.Where(p => p.AddType == "撤单").GroupBy(g => new { cate = "撤单扣除" }).Select(l => new lvGroup { cate = l.Key.cate, count = l.Count(), amount = l.Sum(li => li.Performance) }).OrderBy(a => a.amount).ToList(); List <lvGroup> upuList = performanceList.Where(p => p.AddType == "变更").GroupBy(g => new { cate = "变更上级" }).Select(l => new lvGroup { cate = l.Key.cate, count = l.Count(), amount = l.Sum(li => li.Performance) }).OrderBy(a => a.amount).ToList(); lvList.AddRange(upList); lvList.AddRange(ceList); lvList.AddRange(upuList); if (lvList.Count > 0) { dt = new DataTable(); dt.Columns.Add("num", typeof(string)); dt.Columns.Add("cate", typeof(string)); dt.Columns.Add("count", typeof(int)); dt.Columns.Add("up", typeof(string)); dt.Columns.Add("amount", typeof(string)); int num = 0; foreach (var item in lvList) { num++; DataRow dr = dt.NewRow(); dr["num"] = num.ToString().PadLeft(3, '0'); dr["cate"] = item.cate; dr["count"] = item.count; dr["up"] = item.up == 0 ? "" : Convert.ToDouble(item.up).ToString(); dr["amount"] = Convert.ToDouble(item.amount).ToString(); dt.Rows.Add(dr); } dictSource.Add("sumcount", lvList.Sum(p => p.count)); decimal sumamount = lvList.Sum(p => p.amount); dictSource.Add("sumamount", Convert.ToDouble(sumamount).ToString()); } } if (dt != null) { dt.TableName = "detail"; dt.AcceptChanges(); } MemoryStream ms = CommonPlatform.Helper.Aspose.ExcelHelper.OutModelFileToStream(templatePath, dictSource, dt); ExportCache exCache = new ExportCache() { FileName = string.Format("{1}业绩确认表_{0}.xls", user.TrueName, dicYearmonth), 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 = 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) { BLLJIMP.Model.API.Flow.PostAction requestPost = bllFlow.ConvertRequestToModel <BLLJIMP.Model.API.Flow.PostAction>(new BLLJIMP.Model.API.Flow.PostAction()); if (requestPost.flow_key == "Withdraw") { if (CurrentUserInfo.IsLock == 1) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "账号已被锁定"; bllUser.ContextResponse(context, apiResp); return; } } string websiteOwner = bllFlow.WebsiteOwner; BLLJIMP.Model.Flow flow = bllFlow.GetFlowByKey(requestPost.flow_key, websiteOwner); if (flow == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "流程未定义"; bllFlow.ContextResponse(context, apiResp); return; } if (flow.IsDelete == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "已停用"; bllFlow.ContextResponse(context, apiResp); return; } List <BLLJIMP.Model.FlowStep> steps = bllFlow.GetStepList(2, 1, websiteOwner, flow.AutoID); if (steps.Count == 0) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "环节未设置"; bllFlow.ContextResponse(context, apiResp); return; } WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); BLLJIMP.Model.FlowStep step1 = steps[0]; BLLJIMP.Model.FlowStep step2 = null; if (steps.Count == 2) { step2 = steps[1]; } BLLJIMP.Model.FlowAction action = new BLLJIMP.Model.FlowAction(); action.CreateDate = DateTime.Now; action.CreateUserID = CurrentUserInfo.UserID; action.WebsiteOwner = websiteOwner; action.StartStepID = step1.AutoID; action.FlowID = flow.AutoID; action.FlowKey = flow.FlowKey; if (requestPost.amount > 0) { action.Amount = requestPost.amount; } if (!string.IsNullOrWhiteSpace(requestPost.content)) { action.StartContent = requestPost.content; } if (!string.IsNullOrWhiteSpace(requestPost.ex1)) { action.StartEx1 = requestPost.ex1; } if (!string.IsNullOrWhiteSpace(requestPost.ex2)) { action.StartEx2 = requestPost.ex2; } if (!string.IsNullOrWhiteSpace(requestPost.ex3)) { action.StartEx3 = requestPost.ex3; } if (requestPost.select_date.HasValue) { action.StartSelectDate = requestPost.select_date.Value; } if (requestPost.flow_key == "Withdraw") { if (CurrentUserInfo.TotalAmount < requestPost.amount) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("消耗会员可用{0}不足", website.TotalAmountShowName); bllFlow.ContextResponse(context, apiResp); return; } action.TrueAmount = Math.Round(action.Amount * 0.9322M, 2); action.DeductAmount = action.Amount - action.TrueAmount; var card = bllFlow.GetColByKey <BLLJIMP.Model.BindBankCard>("AutoID", action.StartEx3, "AutoID,BankName,AccountName,BankAccount", websiteOwner: websiteOwner); action.StartEx1 = card.BankName; action.StartEx2 = card.AccountName; action.StartEx3 = card.BankAccount; } else if (requestPost.flow_key == "PerformanceReward") { TeamPerformance myPerformance = bllFlow.GetByKey <TeamPerformance>("AutoID", requestPost.rel_id, websiteOwner: websiteOwner); action.RelationId = Convert.ToInt32(requestPost.rel_id); action.Amount = myPerformance.Reward; action.DeductAmount = (myPerformance.Reward * 20 / 100); action.TrueAmount = (myPerformance.Reward * 80 / 100); action.StartContent = string.Format("管理业绩:{0},奖金比例:{1},管理奖金:{2},其他扣款:{3}。<br />公积金:{4},开票金额:{5}", Convert.ToDouble(myPerformance.Performance), Convert.ToDouble(myPerformance.Rate), Convert.ToDouble(myPerformance.TotalReward), Convert.ToDouble(myPerformance.ChildReward), Convert.ToDouble((myPerformance.Reward * 20 / 100)), Convert.ToDouble((myPerformance.Reward * 80 / 100))); string ym = myPerformance.YearMonth.ToString(); action.StartEx1 = ym.Substring(0, 4) + "年" + ym.Substring(4, 2) + "月"; } action.MemberAutoID = CurrentUserInfo.AutoID; action.MemberID = CurrentUserInfo.UserID; action.MemberName = bllUser.GetUserDispalyName(CurrentUserInfo); action.MemberAvatar = bllUser.GetUserDispalyAvatar(CurrentUserInfo); action.MemberPhone = CurrentUserInfo.Phone; ZentCloud.BLLJIMP.Model.UserLevelConfig levelConfig = bllDistribution.QueryUserLevel(websiteOwner, "DistributionOnLine", CurrentUserInfo.MemberLevel.ToString()); action.MemberLevel = levelConfig.LevelNumber; action.MemberLevelName = levelConfig.LevelString; action.FlowName = flow.FlowName; if (step2 != null) { action.StepID = step2.AutoID; action.StepName = step2.StepName; } else { action.Status = 9; action.EndDate = DateTime.Now; } BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail(); actionDetail1.WebsiteOwner = websiteOwner; actionDetail1.FlowID = flow.AutoID; actionDetail1.StepID = step1.AutoID; actionDetail1.StepName = step1.StepName; actionDetail1.HandleUserID = CurrentUserInfo.UserID; actionDetail1.HandleDate = DateTime.Now; if (!string.IsNullOrWhiteSpace(action.StartContent)) { actionDetail1.HandleContent = action.StartContent; } if (requestPost.select_date.HasValue) { actionDetail1.HandleSelectDate = requestPost.select_date.Value; } if (!string.IsNullOrWhiteSpace(action.StartEx1)) { actionDetail1.Ex1 = action.StartEx1; } if (!string.IsNullOrWhiteSpace(action.StartEx2)) { actionDetail1.Ex2 = action.StartEx2; } if (!string.IsNullOrWhiteSpace(action.StartEx3)) { actionDetail1.Ex3 = action.StartEx3; } List <BLLJIMP.Model.FlowActionFile> files = new List <BLLJIMP.Model.FlowActionFile>(); if (!string.IsNullOrWhiteSpace(requestPost.files)) { List <string> fileUrls = requestPost.files.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList(); if (fileUrls.Count > 0) { foreach (var item in fileUrls) { files.Add(new BLLJIMP.Model.FlowActionFile() { FlowID = flow.AutoID, StepID = step1.AutoID, WebsiteOwner = websiteOwner, FilePath = item }); } } } BLLTransaction tran = new BLLTransaction(); int rId = Convert.ToInt32(bllFlow.AddReturnID(action, tran)); if (rId <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + "失败"; bllFlow.ContextResponse(context, apiResp); return; } actionDetail1.ActionID = rId; if (!bllFlow.Add(actionDetail1, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",记录失败"; bllFlow.ContextResponse(context, apiResp); return; } foreach (var item in files) { item.ActionID = rId; if (!bllFlow.Add(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",保存附件失败"; bllFlow.ContextResponse(context, apiResp); return; } } if (requestPost.flow_key == "Withdraw") { #region 消耗操作人金额 if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - action.Amount), string.Format("申请提现{0}元", (double)action.Amount), "TotalAmount", (double)(CurrentUserInfo.TotalAmount - action.Amount), rId.ToString(), "申请提现", "", "", (double)action.Amount, (double)action.DeductAmount, "", tran, ex1: action.StartEx1, ex2: action.StartEx2, ex3: action.StartEx3, ex5: "bank") <= 0) { tran.Rollback(); apiResp.msg = "记录转账明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } if (bllUser.Update(CurrentUserInfo, string.Format("TotalAmount=ISNULL(TotalAmount,0)-{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)-{0}", action.Amount), string.Format("AutoID={0} And WebsiteOwner='{1}' And ISNULL(TotalAmount,0)-{2}>=0 ", CurrentUserInfo.AutoID, websiteOwner, action.Amount), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("消耗会员可用{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } #endregion } else if (requestPost.flow_key == "PerformanceReward") { if (bllFlow.Update(new TeamPerformance(), string.Format("FlowActionId={0},FlowActionStatus=0,Status=2", rId), string.Format("AutoID={0}", requestPost.rel_id), tran) <= 0) { tran.Rollback(); apiResp.msg = "业绩关联出错"; apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = flow.FlowName + "提交成功"; bllFlow.ContextResponse(context, apiResp); }