예제 #1
0
        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);
        }
예제 #2
0
 public static Mall_CheckRequestDetail[] GetMall_CheckRequestDetailShiLi(Mall_CheckRequestDetail[] list, List <string> conditions, List <SqlParameter> parameters)
 {
     if (list.Length > 0)
     {
         var check_rule_list = Mall_CheckRequestRule.GetMall_CheckRequestRules().ToArray();
         var rule_list       = GetList <Mall_CheckInfoDetail>("select * from [Mall_CheckInfo] where [ID] in (select [RuleID] from [Mall_CheckRequestRule] where [RequestID] in (select ID from [Mall_CheckRequest] where " + string.Join(" and ", conditions.ToArray()) + "))", parameters).ToArray();
         var check_user_list = Mall_CheckRequestUser.GetMall_CheckRequestUsers().ToArray();
         var user_list       = GetList <User>("select * from [User] where [UserID] in (select [UserID] from [Mall_CheckRequestUser] where [RequestID] in (select ID from [Mall_CheckRequest] where " + string.Join(" and ", conditions.ToArray()) + "))", parameters).ToArray();
         var category_list   = Mall_CheckCategory.GetMall_CheckCategories();
         foreach (var item in list)
         {
             var my_check_user_list = check_user_list.Where(p => p.RequestID == item.ID).ToArray();
             if (my_check_user_list.Length > 0)
             {
                 List <int> UserIDList   = my_check_user_list.Select(p => p.UserID).ToList();
                 var        my_user_list = user_list.Where(p => UserIDList.Contains(p.UserID)).ToArray();
                 item.CheckUserInfo     = string.Join(",", my_user_list.Select(p => p.FinalRealName));
                 item.CheckUserPosition = string.Join(",", my_user_list.Where(p => !string.IsNullOrEmpty(p.PositionName)).Select(p => p.PositionName));
             }
             var my_check_rule_list = check_rule_list.Where(p => p.RequestID == item.ID).ToArray();
             if (my_check_rule_list.Length > 0)
             {
                 List <int> RuleIDList       = my_check_rule_list.Select(p => p.RuleID).ToList();
                 var        my_rule_list     = rule_list.Where(p => RuleIDList.Contains(p.ID)).ToArray();
                 List <int> CategoryIDList   = my_rule_list.Select(p => p.CheckCategoryID).ToList();
                 var        my_category_list = category_list.Where(p => CategoryIDList.Contains(p.ID)).ToList();
                 if (item.RequestType <= 1)
                 {
                     if (my_category_list.Count > 0)
                     {
                         item.CheckCategoryName = string.Join(",", my_category_list.Select(p => p.CategoryName));
                     }
                     if (my_rule_list.Length > 0)
                     {
                         item.CheckRule = string.Join(",", my_rule_list.Select(p => p.CheckName));
                     }
                 }
                 else
                 {
                     item.CheckCategoryName = my_check_rule_list[0].Title;
                     item.CheckRule         = item.RequestTypeDesc;
                 }
                 item.UserEarnPoint   = my_check_rule_list.Where(p => p.EarnType == 1).Sum(p => p.PointValue);
                 item.UserReducePoint = my_check_rule_list.Where(p => p.EarnType == 2).Sum(p => p.PointValue);
             }
         }
     }
     return(list);
 }