private static void UpdateUserAccount(OrderInfo order) { MemberInfo member = new MemberDao().GetMember(order.UserId); if (member != null) { MemberDao dao = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao2 = new PointDetailDao(); dao2.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao.Update(member); int historyPoint = dao2.GetHistoryPoint(member.UserId); List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>; MemberGradeInfo memberGrade = MemberHelper.GetMemberGrade(member.GradeId); if ((memberGrade == null) || (memberGrade.Points <= historyPoint)) { foreach (MemberGradeInfo info4 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info4.GradeId) { break; } if (info4.Points <= historyPoint) { member.GradeId = info4.GradeId; dao.Update(member); break; } } } } }
public static bool UserPayOrder(OrderInfo order) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.BuyerAlreadyPaid; order.PayDate = new DateTime?(DateTime.Now); bool flag = dao.UpdateOrder(order, null); string str = ""; if (flag) { dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); str = str + "'" + info.SkuId + "',"; ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } if (!string.IsNullOrEmpty(str)) { dao.UpdateItemsStatus(order.OrderId, 2, str.Substring(0, str.Length - 1)); } if (!string.IsNullOrEmpty(order.ActivitiesId)) { new ActivitiesDao().UpdateActivitiesTakeEffect(order.ActivitiesId); } MemberInfo member = GetMember(order.UserId); if (member == null) { return(flag); } MemberDao dao4 = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao5 = new PointDetailDao(); dao5.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao4.Update(member); Messenger.OrderPayment(member, order.OrderId, order.GetTotal()); int historyPoint = dao5.GetHistoryPoint(member.UserId); MemberGradeInfo memberGrade = GetMemberGrade(member.GradeId); if ((memberGrade != null) && (memberGrade.Points > historyPoint)) { return(flag); } List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>; foreach (MemberGradeInfo info6 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info6.GradeId) { return(flag); } if (info6.Points <= historyPoint) { member.GradeId = info6.GradeId; dao4.Update(member); return(flag); } } } return(flag); }
//点睛教育需求:返佣同时得积分 public static bool UpdateDistributorPoints(OrderInfo order) { bool flag = false; //代理商的积分 DistributorsInfo currentDistributor = GetDistributorInfo(order.ReferralUserId); //当前1级分销商分销信息 DistributorsInfo currentAgent = GetDistributorInfo(currentDistributor.AgentPath.ToInt()); //当前代理商分销信息 MemberInfo distributorLevel1Info = MemberProcessor.GetMember(currentDistributor.UserId); //当前1级分销商用户信息 MemberInfo agentInfo = MemberProcessor.GetMember(currentAgent.UserId); //当前代理商用户信息 //获取一级返佣和代理商返佣 decimal commision = 0m; foreach (LineItemInfo info in order.LineItems.Values) { commision += info.ItemsCommission; } //一级分销商可得的积分 int pointLevel1 = Convert.ToInt32(commision / 20); int agentCommisionRate = Convert.ToInt32(DistributorGradeBrower.GetAgentGradeInfo(currentAgent.AgentGradeId).FirstCommissionRise);//当前代理商的分佣百分比 //当前代理商可得的积分 int pointAgent = Convert.ToInt32((order.GetTotal() / 100 * agentCommisionRate) / 20); //判断该用户是否关注了公众号,如果没有关注,则积分给代理商. if (!(distributorLevel1Info != null && WxSubscribe(distributorLevel1Info.OpenId))) { pointAgent = pointAgent + pointLevel1; } //给1级分销商增加积分 MemberDao dao4 = new MemberDao(); distributorLevel1Info.Points = distributorLevel1Info.Points + pointLevel1; PointDetailInfo pointDistributorLevel1 = new PointDetailInfo { OrderId = order.OrderId, UserId = order.ReferralUserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = pointLevel1, Points = distributorLevel1Info.Points }; if ((pointDistributorLevel1.Points > 0x7fffffff) || (pointDistributorLevel1.Points < 0)) { pointDistributorLevel1.Points = 0x7fffffff; } PointDetailDao dao5 = new PointDetailDao(); dao5.AddPointDetail(pointDistributorLevel1); dao4.Update(distributorLevel1Info); //给代理商增加积分 MemberDao dao6 = new MemberDao(); agentInfo.Points = agentInfo.Points + pointAgent; PointDetailInfo pointAgentInfo = new PointDetailInfo { OrderId = order.OrderId, UserId = order.ReferralUserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = pointAgent, Points = agentInfo.Points }; if ((pointAgentInfo.Points > 0x7fffffff) || (pointAgentInfo.Points < 0)) { pointAgentInfo.Points = 0x7fffffff; } PointDetailDao dao7 = new PointDetailDao(); dao5.AddPointDetail(pointAgentInfo); dao4.Update(agentInfo); return(flag); }
public static bool UserPayOrder(OrderInfo order) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.BuyerAlreadyPaid; order.PayDate = new DateTime?(DateTime.Now); bool flag = dao.UpdateOrder(order, null); if (flag) { dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } MemberInfo member = GetMember(order.UserId); if (member == null) { return(flag); } MemberDao dao3 = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao4 = new PointDetailDao(); dao4.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao3.Update(member); Messenger.OrderPayment(member, order.OrderId, order.GetTotal()); int historyPoint = dao4.GetHistoryPoint(member.UserId); List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>; foreach (MemberGradeInfo info5 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info5.GradeId) { return(flag); } if (info5.Points <= historyPoint) { member.GradeId = info5.GradeId; dao3.Update(member); return(flag); } } } return(flag); }