public static int senduserjixiaopoint(List <int> IDList) { var request_list = Mall_CheckRequest.GetAllActiveMall_CheckRequestList().Where(p => IDList.Contains(p.ID)).ToArray(); if (request_list.Length == 0) { return(0); } var rule_list = Mall_CheckRequestRuleDetail.GetMall_CheckRequestRuleDetailListByRequestIDList(IDList); var user_list = Mall_CheckRequestUser.GetMall_CheckRequestUserListByRequestIDList(IDList); int count = 0; using (SqlHelper helper = new SqlHelper()) { try { helper.BeginTransaction(); foreach (var check_request in request_list) { var my_user_list = user_list.Where(p => p.RequestID == check_request.ID).ToArray(); var my_rule_list = rule_list.Where(p => p.RequestID == check_request.ID).ToArray(); if (my_user_list.Length == 0 || my_rule_list.Length == 0) { continue; } foreach (var check_user in my_user_list) { foreach (var check_rule in my_rule_list) { string Title = check_rule.EarnType == 1 ? "业绩考核奖励" : check_rule.Title; int PointType = check_rule.EarnType; int CategoryType = check_rule.EarnType; int BackPoint = check_rule.EarnType == 1 ? check_rule.PointValue : -check_rule.PointValue; Mall_UserJiXiaoPoint.Insert_Mall_UserJiXiaoPoint(check_user.UserID, PointType, 0, Title, "Mall_CheckRequestID:" + check_request.ID, CategoryType, "System", 1, helper, FixedPointMonth: check_rule.FixedPointMonth, FixedPointDateTime: check_rule.FixedPointDateTime, PointValue: BackPoint, RelatedID: check_request.ID, RuleID: check_rule.ID, InfoID: check_rule.RuleID, InfoName: check_rule.CheckName, CategoryName: check_rule.CategoryName, EarnType: check_rule.EarnType, ApproveUserName: check_request.ApproveMan, ApproveTime: check_request.ApproveTime, ApproveRemark: check_request.ApproveRemark, Remark: check_request.Remark); count++; } } check_request.IsJieXiaoPointSent = true; check_request.JieXiaoPointSentTime = DateTime.Now; check_request.Save(helper); } helper.Commit(); } catch (Exception ex) { helper.Rollback(); Utility.LogHelper.WriteError("Mall_CheckRequest.cs", "senduserjixiaopoint", ex); return(0); } } return(count); }
/// <summary> /// /// </summary> /// <param name="UserID"></param> /// <param name="PointType">1-充值 2-消费</param> /// <param name="OrderTotalAmount"></param> /// <param name="Title"></param> /// <param name="Summary"></param> /// <param name="CategoryType">1-积分购买消费 2-购买商品赠与 3-积分购买退货返回 4-购买商品退货扣除 5-充值赠与 6-消费赠与</param> /// <param name="AddUserName"></param> /// <param name="PointStatus">0-未入账 1-已入账</param> /// <param name="TradeNo"></param> /// <param name="OrderID"></param> /// <param name="PointValue"></param> /// <param name="RelatedID"></param> public static void Insert_Mall_UserJiXiaoPoint(int UserID, int PointType, decimal OrderTotalAmount, string Title, string Summary, int CategoryType, string AddUserName, int PointStatus, SqlHelper helper, string TradeNo = "", int OrderID = 0, int FixedPointMonth = 0, DateTime?FixedPointDateTime = null, int PointValue = 0, int RelatedID = 0, int AmountRuleID = 0, int RuleID = 0, int InfoID = 0, string InfoName = "", string CategoryName = "", int EarnType = 0, string ApproveUserName = "", DateTime?ApproveTime = null, string ApproveRemark = "", string Remark = "", decimal BeforePointValue = 0) { if (UserID <= 0) { return; } var data = new Mall_UserJiXiaoPoint(); data.UserID = UserID; data.PointType = PointType; data.PointValue = PointValue; data.Title = Title; data.Summary = Summary; data.CategoryType = CategoryType; data.AddUserName = AddUserName; data.PointStatus = PointStatus; data.AddTime = DateTime.Now; data.TradeNo = TradeNo; data.RelatedID = RelatedID; data.AmountRuleID = AmountRuleID; data.FixedPointMonth = FixedPointMonth > 0 ? FixedPointMonth : DateTime.Now.Month; if (FixedPointDateTime.HasValue) { DateTime _FixedPointDateTime = Convert.ToDateTime(FixedPointDateTime); data.FixedPointDateTime = _FixedPointDateTime > DateTime.MinValue ? _FixedPointDateTime : DateTime.Now; } data.InfoID = InfoID; data.InfoName = InfoName; data.CategoryName = CategoryName; data.EarnType = EarnType; data.ApproveUserName = ApproveUserName; if (ApproveTime.HasValue) { data.ApproveTime = Convert.ToDateTime(ApproveTime); } data.ApproveRemark = ApproveRemark; data.Remark = Remark; Mall_PointCovertRecord record = null; if (data.EarnType == 2) { record = new Mall_PointCovertRecord(); record.UserID = data.UserID; record.PointValue = (int)BeforePointValue; record.CheckPointValue = data.PointValue; record.PointRuleID = data.RelatedID; record.Status = 2; record.AddTime = DateTime.Now; record.AddUserName = data.AddUserName; } Mall_PointWithDrawRecord withdrawrecord = null; if (data.EarnType == 3) { withdrawrecord = new Mall_PointWithDrawRecord(); withdrawrecord.UserID = data.UserID; withdrawrecord.PointValue = data.PointValue; withdrawrecord.Status = 2; withdrawrecord.AddTime = DateTime.Now; withdrawrecord.AddUserName = data.AddUserName; } data.Save(helper); if (record != null) { //积分兑换扣除 var userPoint = Mall_UserPoint.Insert_Mall_UserPoint(data.UserID, 2, 0, "积分兑换扣除", "Mall_PointCovertRecordID:" + record.ID, 8, data.AddUserName, 1, "", 0, helper, PointValue: -record.PointValue, RelatedID: record.ID); record.Mall_UserPointID = userPoint.ID; record.Mall_UserJiXiaoPointID = data.ID; record.Save(helper); data.PointStatus = 0; data.CategoryType = 3; data.RelatedID = record.ID; } if (withdrawrecord != null) { withdrawrecord.Mall_UserJiXiaoPointID = data.ID; withdrawrecord.Save(helper); data.PointStatus = 1; data.CategoryType = 4; data.RelatedID = withdrawrecord.ID; } data.Save(helper); }