private static void TryGetMemberReward(Order order, int rUserID, out SysMemberReward r, out Payment p) { p = null; r = DB.Select( ).From<SysMemberReward>( ) .Where(SysMemberReward.OrderCompanyIDColumn).IsEqualTo(order.OrderSellerID) .And(SysMemberReward.RewardMemberIDColumn).IsEqualTo(rUserID) .And(SysMemberReward.OrderMemberIDColumn).IsEqualTo(order.OrderMemberID) .ExecuteSingle<SysMemberReward>( ); if (r != null) p = Payment.FetchByID(r.PaymentID); }
public void Insert(int? RewardMemberID,int? OrderMemberID,int? OrderCompanyID,int? OrderID,decimal? OrderSumOk,decimal? RewardPoint,DateTime? RewardDate,int? PaymentID) { SysMemberReward item = new SysMemberReward(); item.RewardMemberID = RewardMemberID; item.OrderMemberID = OrderMemberID; item.OrderCompanyID = OrderCompanyID; item.OrderID = OrderID; item.OrderSumOk = OrderSumOk; item.RewardPoint = RewardPoint; item.RewardDate = RewardDate; item.PaymentID = PaymentID; item.Save(UserName); }
public static void RewardMemberPoint(SysMember user, Order order) { //if (AppContextBase.Context.CompanyType.HasValue && AppContextBase.Context.CompanyType.Value != CompanyType.UnionCompany) // return; if (!user.MemberPid.HasValue || user.MemberPid.Value <= 0) return; SysMember rUser = SysMember.FetchByID(user.MemberPid); if (rUser == null || rUser.CompanyId > 0) return; SysReward reward = Reward; if (reward == null) return; //是否在推广期内注册 bool isCanReward = user.MemberDate.Value >= reward.RewardDate.Value && user.MemberDate.Value < reward.RewardEndDate.Value.AddDays(1); if (!isCanReward) return; //是否一直有效 if (reward.RewardFlag.HasValue && reward.RewardFlag.Value == 0) { var query = DB.Select( ).From<SysMemberReward>( ) .Where(SysMemberReward.OrderMemberIDColumn).IsEqualTo(user.Id) .And(SysMemberReward.RewardMemberIDColumn).IsEqualTo(rUser.Id); if (query.GetRecordCount( ) > 0) return; } decimal point = order.OrderSumOk.Value * (RewardRate / 100M); if (point <= 0) return; string companyName = CompanyBLL.GetCompanyName(order.OrderSellerID); string memo = "好友{0}在【{1}】消费{2:0.00}元,您获奖励{3:0.00}个积分"; SysMemberReward r; Payment p; TryGetMemberReward(order, rUser.Id, out r, out p); if (r == null) r = new SysMemberReward( ); if (p == null) p = new Payment( ); r.OrderCompanyID = order.OrderSellerID; r.OrderID = order.Id; r.OrderMemberID = user.Id; r.OrderSumOk = order.OrderSumOk.Value; r.RewardMemberID = rUser.Id; r.RewardPoint = point; r.RewardDate = order.OrderDate; p.PaymentDate = order.OrderDate; p.PaymentCode = string.Empty; p.PaymentCompanyID = UserBLL.MainCompanyAccount.Id; p.PaymentEmail = string.Empty; p.PaymentMemberID = rUser.Id; p.PaymentMemo = string.Format(memo, CompanyBLL.EnUserPhoe(user.MemberPhoneNumber), companyName, order.OrderSumOk, point); p.PaymentOrderID = order.Id; p.PaymentStatus = 1; p.PaymentSum = point; p.PaymentType = (int)PaymentType.Reward; p.Save( ); r.PaymentID = p.Id; r.ValidateWhenSaving = false; r.Save( ); }
public void Update(int RewardID,int? RewardMemberID,int? OrderMemberID,int? OrderCompanyID,int? OrderID,decimal? OrderSumOk,decimal? RewardPoint,DateTime? RewardDate,int? PaymentID) { SysMemberReward item = new SysMemberReward(); item.MarkOld(); item.IsLoaded = true; item.RewardID = RewardID; item.RewardMemberID = RewardMemberID; item.OrderMemberID = OrderMemberID; item.OrderCompanyID = OrderCompanyID; item.OrderID = OrderID; item.OrderSumOk = OrderSumOk; item.RewardPoint = RewardPoint; item.RewardDate = RewardDate; item.PaymentID = PaymentID; item.Save(UserName); }