Przeglądaj źródła

工资计算 01

leiy 1 rok temu
rodzic
commit
93ed5eabc1

+ 7 - 8
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -217,8 +217,7 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> SalaryCalculatorAsync(SalaryCalculatorDto dto)
         {
-
-            var tepDetail = await _qiYeWeChatApiService.GetTemplateDetailAsync("C4NzTJCh1onCUK915rRkvy7Fh5Vqz4YbiEV9jrBY1");
+            //var tepDetail = await PayrollComputation.GetVacationReissueCardTypes("C4RdAPs6gcGyLdSG1RTfKV6kKiRJzXSwF27LaJbyf");
 
             Result result = new Result();
             Stopwatch sw = new Stopwatch();
@@ -251,7 +250,7 @@ namespace OASystem.API.Controllers
             List<Pm_WageSheet> preWageSheetItems = await _wageSheetRep._sqlSugar.Queryable<Pm_WageSheet>().Where(it => it.IsDel == 0 && it.YearMonth == preYearMonth).ToListAsync();
             if (preWageSheetItems.Count <= 0) 
             {
-                return Ok(JsonView(false, preYearMonth + " 工资数据不存在,请手动添加!"));
+                return Ok(JsonView(false, thisYearMonth + " 上月工资数据不存在,请手动添加!"));
             }
 
             //获取OA系统内所有用户
@@ -273,11 +272,11 @@ namespace OASystem.API.Controllers
 
             wageSheets = _result.Data;
 
-            var add = await _wageSheetRep._sqlSugar.Insertable(wageSheets).ExecuteCommandAsync();
-            if (add <= 0)
-            {
-                return Ok(JsonView(false, "操作失败!"));
-            }
+            //var add = await _wageSheetRep._sqlSugar.Insertable(wageSheets).ExecuteCommandAsync();
+            //if (add <= 0)
+            //{
+            //    return Ok(JsonView(false, "操作失败!"));
+            //}
 
             #endregion
 

+ 379 - 177
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -1,9 +1,12 @@
-using OASystem.API.OAMethodLib.QiYeWeChatAPI;
+using Google.Protobuf.WellKnownTypes;
+using OASystem.API.OAMethodLib.QiYeWeChatAPI;
 using OASystem.Domain;
 using OASystem.Domain.Entities.PersonnelModule;
 using OASystem.Domain.ViewModels.PersonnelModule;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
+using System;
+using System.Linq.Expressions;
 using TencentCloud.Ocr.V20181119.Models;
 
 namespace OASystem.API.OAMethodLib
@@ -44,6 +47,7 @@ namespace OASystem.API.OAMethodLib
             }
 
 
+
             //获取所有打卡数据
             CheckInView checkIn = await _qiYeWeChatApiService.GetCheckin_MonthDataAsync(startDt, endDt); //时间段内所有 打卡数据
             if (checkIn.errcode != 0)
@@ -54,23 +58,15 @@ namespace OASystem.API.OAMethodLib
 
             List<Data> checkInDatas = checkIn.datas;
 
-            //请假
-            List<Sp_Detail> sp_leave_details = new List<Sp_Detail>();
-            sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, 2, 1); //时间段内所有 已同意的 请假 审批数据
-            if (sp_leave_details.Count <= 0)
+            //获取 请假类型 Sp_Detail.template_id
+            string leave_template_id = "C4NzTJCh1onCUK915rRkvy7Fh5Vqz4YbiEV9jrBY1";
+            List<VacationLeaveTypeView> vacationLeaveTypes = await GetVacationLeaveTypes(leave_template_id);
+            if (vacationLeaveTypes.Count <= 0)
             {
-                string errMsg = startDt + " - " + endDt + "请假 审批数据获取失败!";
+                _result.Msg = startDt + " - " + endDt + "请假 类型数据 获取失败!";
                 return _result;
             }
 
-            //打卡补卡
-            List<Sp_Detail> sp_reissuecard_details = new List<Sp_Detail>();
-            sp_reissuecard_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, 2, 2); //时间段内所有 已同意的 打卡补卡 审批数据
-            if (sp_reissuecard_details.Count <= 0)
-            {
-                string errMsg = startDt + " - " + endDt + "打卡补卡 审批数据获取失败!";
-                return _result;
-            }
 
             foreach (var pm_wsInfo in pm_WageSheetDattaSources)
             {
@@ -105,6 +101,16 @@ namespace OASystem.API.OAMethodLib
                 if (checkInData == null) { continue; }
                 string acctid = checkInData.base_info.acctid; //用户Id
 
+               
+
+                List<Sp_Detail> sp_reissuecard_details = new List<Sp_Detail>();
+                sp_reissuecard_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 2); //时间段内所有 已同意的 补卡 审批数据
+                if (sp_reissuecard_details.Count <= 0)
+                {
+                    _result.Msg += startDt + " - " + endDt + "  " + itemName + "  打卡补卡 审批数据获取未获取到!\r\n";
+                    continue;
+                }
+
                 //当月总计数据
                 Summary_Info? summary_Info = checkInData.summary_info;
                 if (summary_Info == null) { continue; }
@@ -120,7 +126,7 @@ namespace OASystem.API.OAMethodLib
                 decimal amountPayable = pm_wsInfo.Basic + pm_wsInfo.Floats + pm_wsInfo.PostAllowance + pm_wsInfo.GarmentWashSubsidies + pm_wsInfo.CommunicationSubsidies +
                     pm_wsInfo.TrafficSubsidies + pm_wsInfo.InformationSecurityFee + pm_wsInfo.OperationBonus + pm_wsInfo.SpecialAllowance + pm_wsInfo.OtherSubsidies + pm_wsInfo.GroupCost;
 
-                // 日薪 = 事假日薪 *计算方式:日平均工资 = 月工资/当月应出勤天数。
+                // 日薪 = *计算方式:日平均工资 = 月工资/当月应出勤天数。
                 decimal dailyWage = amountPayable / work_days;
 
                 // 病假日薪 *计算方式:日平均工资 = 成都市最低工资标准的80%/当月应出勤天数。 短期病假=当月15天内 
@@ -168,13 +174,19 @@ namespace OASystem.API.OAMethodLib
 
                 #region 请假类型金额/餐补 处理
 
-                List<Sp_Detail> sp_leave_item_infosData = sp_leave_details.Where(it => it.applyer.userid == acctid).ToList();
+                List<Sp_Detail> sp_leave_details = new List<Sp_Detail>();
+                sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2 , 1); //时间段内所有 已同意的 请假 审批数据
+                if (sp_leave_details.Count <= 0)
+                {
+                    _result.Msg += startDt + " - " + endDt +"  "+itemName  + "  请假 审批数据获取未获取到!\r\n";
+                    continue;
+                }
 
                 List<Ex_Items> ex_Items = new List<Ex_Items>();//假勤 And 打卡备注集合
                 Ex_Items ex_Items_jq = new Ex_Items() { Type = "假勤" };   //假勤
                 List<Ex_Item> ex_ItemInfos = new List<Ex_Item>();
 
-                foreach (Sp_Detail sp_item in sp_leave_item_infosData)
+                foreach (Sp_Detail sp_item in sp_leave_details)
                 {
                     Apply_data? apply_data = sp_item.apply_data;
                     if (apply_data != null)
@@ -188,172 +200,60 @@ namespace OASystem.API.OAMethodLib
                             Vacation vacation = content_Vacation.value.vacation;
                             Attendance attendance = vacation.attendance; //假勤组件
                             Selector selector = vacation.selector;       //请假类型
-                        }
 
-                        //请假时长
-                        //double leaveLength = (sp_leave.end_time_dt - sp_leave.start_time_dt).TotalHours;
-
-                        //string typeName = string.Empty;
-                        ////leave_type 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他
-                        //switch (sp_leave.leave_type)
-                        //{
-                        //    case 1:    //年假
-                        //        typeName = "年假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    case 2:    //事假 需调整
-                        //        typeName = "事假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //            personalLeaveTotal += dailyWage / 2;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    case 3:    //病假 需调整
-                        //        typeName = "病假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //            sickLeaveTotal += sickLeave_deduction / 2;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    case 4:    //调休假
-                        //        typeName = "调休假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    case 5:    //婚假
-                        //        typeName = "婚假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    case 6:    //产假
-                        //        typeName = "产假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    case 7:    //陪产假
-                        //        typeName = "陪产假";
-                        //        if (sp_leave.timeunit == 0) //半天
-                        //        {
-                        //            meal_deduction += 10;
-                        //        }
-                        //        else if (sp_leave.timeunit == 1) //小时
-                        //        {
-                        //            if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
-                        //            {
-                        //                meal_deduction += 10;
-                        //            }
-                        //            else if (sp_leave.duration > 7.5)
-                        //            {
-                        //                decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
-                        //                meal_deduction += daysPrice;
-                        //            }
-                        //        }
-                        //        break;
-                        //    default:
-                        //        break;
-                        //}
-
-                        //Ex_Item ex_Item = new Ex_Item()
-                        //{
-                        //    SubTypeId = sp_leave.leave_type,
-                        //    SubType = typeName,
-                        //    Start_time_dt = sp_leave.start_time_dt,
-                        //    End_time_dt = sp_leave.end_time_dt,
-                        //    Duration = sp_leave.duration,
-                        //    Reason = sp_leave.reason,
-                        //    Apply_time_dt = sp_item.apply_time_dt,
-                        //    Approval_name = sp_item.approval_name,
-                        //};
-                        //ex_ItemInfos.Add(ex_Item);
+                            List<OptionsItem> optionsItems = selector.options; //key 请假类型 id
+                            List<TitleItem> value = optionsItems[0].value; // value 文本描述值
+
+                            int leaveType = int.Parse(optionsItems[0].key);  //key 请假子类型 id
+                            Date_range date_Range = attendance.date_range;
+
+                            decimal thisTypeDeduction = 0.00M;//当前类型扣款
+                            string leave_starttime = date_Range.new_begin_dt.ToString("HH:mm");
+                            string leave_endtime = date_Range.new_end_dt.ToString("HH:mm");
+
+                            string typeName = string.Empty;
+                            int leaveTypeId = leaveType;
+                            var leaveTypeData = vacationLeaveTypes.Where(it => it.id == leaveTypeId).FirstOrDefault();
+
+                            if (leaveTypeData != null) { typeName = leaveTypeData.name; }
+                            //计算请假类型扣款金额
+
+                            int new_duration = 0;
+                            if (date_Range.type == "halfday")
+                            {
+                                new_duration =date_Range.new_duration / 86400;
+                            }
+                            else if (date_Range.type == "hour")
+                            {
+                                new_duration =date_Range.new_duration / 3600;
+                            }
+                            decimal leave_meals = 0.00M;
+                            CalculateTypeFee(leaveType, date_Range.type, leave_starttime, leave_endtime, amountPayable, work_days, new_duration, 
+                                out leave_meals, out thisTypeDeduction);
+
+                            meal_deduction += leave_meals;
+                            string startEndTiime = startEndTiime = date_Range.new_begin_dt.ToString("yyyy-MM-dd HH:mm") + " - " + 
+                                date_Range.new_end_dt.ToString("yyyy-MM-dd HH:mm");
+
+                            Ex_Item ex_Item = new Ex_Item()
+                            {
+                                SubTypeId = leaveType,
+                                SubType = typeName,
+                                Start_end_time_dt = startEndTiime,
+                                Duration = new_duration,
+                                Deduction = thisTypeDeduction,
+                                //Reason = apply_data.reason,
+                                Apply_time_dt = sp_item.apply_time_dt,
+                                //Approval_name = sp_item.approval_name,
+                            };
+                            ex_ItemInfos.Add(ex_Item);
+                        }
                     }
                 }
 
                 if (ex_ItemInfos.Count > 0)
                 {
-                    ex_Items_jq.Ex_ItemInfo = ex_ItemInfos.OrderBy(it => it.SubTypeId).ThenBy(it => it.Start_time_dt).ToList();
+                    ex_Items_jq.Ex_ItemInfo = ex_ItemInfos.OrderBy(it => it.SubTypeId).ThenBy(it => it.Apply_time_dt).ToList();
                     ex_Items.Add(ex_Items_jq);
                 }
 
@@ -572,12 +472,314 @@ namespace OASystem.API.OAMethodLib
                 #endregion
 
             }
+            
             _result.Code = 0;
             _result.Data = pm_WageSheetDattaSources;
 
             return _result;
         }
 
+        /// <summary>
+        /// 获取请假类型
+        /// </summary>
+        /// <param name="template_id"></param>
+        /// <returns></returns>
+        public static async Task<List<VacationLeaveTypeView>> GetVacationLeaveTypes(string template_id)
+        {
+            List<VacationLeaveTypeView> vacationLeaveTypes = new List<VacationLeaveTypeView>();
+
+            TemplateDetailView templateDetailView = new TemplateDetailView();
+            templateDetailView = await _qiYeWeChatApiService.GetTemplateDetailAsync(template_id);
+            if (templateDetailView.errcode != 0) 
+            {
+                return vacationLeaveTypes;
+            }
+            List<VacationItemInfo> VacationItemInfos = templateDetailView.vacation_list.item;
+
+            foreach (var item in VacationItemInfos)
+            {
+                ValueItem valueInfo = item.name.Where(it => it.lang == "zh_CN").FirstOrDefault();
+                if (valueInfo != null)
+                {
+                    vacationLeaveTypes.Add(
+                    new VacationLeaveTypeView()
+                    {
+                        id = item.id,
+                        name = valueInfo.text
+                    });
+                }
+            }
+
+            return vacationLeaveTypes;
+        }
+
+        /// <summary>
+        /// 计算类型费用
+        /// </summary>
+        /// <param name="leaveType">
+        /// 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他;9丧假
+        /// </param>
+        /// <param name="date_Range_type">
+        /// halfday 全天
+        /// hour  小时
+        /// </param>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <param name="duration"></param>
+        /// <param name="mealDeduction"></param>
+        /// <param name="typeDeduction"></param>
+        public static void CalculateTypeFee(int leaveType, string date_Range_type, string startTime, string endTime,decimal amountPayable,int work_days,
+            int duration, out decimal mealDeduction, out decimal typeDeduction)
+        {
+            typeDeduction = 0;
+            mealDeduction = 0;
+
+            string am_starttime = "08:59";
+            string am_endtime = "13:01";
+
+            
+
+            decimal personalkLeave_dailywage_day = amountPayable / work_days; //日薪 = 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。
+
+            //半小时单位
+            decimal halfHour = Convert.ToDecimal(7.5) / Convert.ToDecimal(0.5);
+
+            switch (leaveType)
+            {
+                case 1: //年假
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 2: //2事假
+                    // 事假日薪 *计算方式:日平均工资 = 当月应发工资 /当月应出勤天数。 
+                    decimal personalkLeave_dailywage_halfhour = personalkLeave_dailywage_day / halfHour; //事假单位 0.5小时
+
+                    if (date_Range_type == "halfday")
+                    {
+                        mealDeduction = 10; //餐补扣款 
+                        typeDeduction = personalkLeave_dailywage_day;
+                    }
+                    else if (date_Range_type == "hour")
+                    {
+                        int leave_halfHour = duration / Convert.ToInt32(0.5);
+                        typeDeduction = personalkLeave_dailywage_halfhour * leave_halfHour;
+                        if (duration >= 3) //单天请假三小时 && 请假时间在上午 则没有餐补
+                        {
+                            //处理开始时间
+                            if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
+                            {
+                                //处理结束时间
+                                if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                                {
+                                    mealDeduction = 10; //餐补扣款
+                                }
+                            }
+                        }
+                        else if (duration > 7.5) //多天计算
+                        {
+                            int leave_halfHour1 = duration / Convert.ToInt32(0.5);
+                            typeDeduction = personalkLeave_dailywage_halfhour * leave_halfHour1;
+
+                            decimal leaveDays = Convert.ToDecimal(duration / 7.5);
+                            if (leaveDays % 1 == 0)
+                            {
+                                mealDeduction = 10 * leaveDays; //餐补扣款
+                            }
+                            else
+                            {
+                                mealDeduction = 10 * Convert.ToInt32(leaveDays);
+
+                                //得到最后一天的请假时间 是否有餐补
+                                int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
+                                if (lastHours >= 3)
+                                {
+                                    //处理结束时间
+                                    if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                                    {
+                                        mealDeduction += 10; //餐补扣款
+                                    }
+                                }
+                            }
+                        }
+                    }
+
+                    break;
+                case 3: //3病假
+                    // 病假日薪 *计算方式:日平均工资 = 成都市最低工资标准的80% /当月应出勤天数。 短期病假=当月15天内 
+
+                    decimal chengDuMinimumWage_halrHour = _chengDuMinimumWage / work_days / halfHour;
+                    decimal sickLeave_dailywage_halfhour_deduction = personalkLeave_dailywage_day - chengDuMinimumWage_halrHour; //病假单位 0.5小时 扣款金额
+
+                    if (date_Range_type == "halfday")
+                    {
+                        mealDeduction = 10; //餐补扣款 
+                        typeDeduction = sickLeave_dailywage_halfhour_deduction * halfHour;
+                    }
+                    else if (date_Range_type == "hour")
+                    {
+                        int sickLeave_halfHour = duration / Convert.ToInt32(0.5);
+                        typeDeduction = sickLeave_dailywage_halfhour_deduction *sickLeave_halfHour ;
+                        if (duration >= 3 && duration <= 7.5) //单天请假三小时 && 请假时间在上午 则没有餐补
+                        {
+                            //处理开始时间
+                            if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
+                            {
+                                //处理结束时间
+                                if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                                {
+                                    mealDeduction = 10; //餐补扣款
+                                }
+                            }
+                        }
+                        else if (duration > 7.5) //多天计算
+                        {
+                            int sickLeave_halfHour1 = duration / Convert.ToInt32(0.5);
+                            typeDeduction = sickLeave_dailywage_halfhour_deduction * sickLeave_halfHour1;
+
+                            decimal leaveDays = Convert.ToDecimal(duration / 7.5);
+                            if (leaveDays % 1 == 0)
+                            {
+                                mealDeduction = 10 * leaveDays; //餐补扣款
+                            }
+                            else
+                            {
+                                mealDeduction = 10 * Convert.ToInt32(leaveDays);
+
+                                //得到最后一天的请假时间 是否有餐补
+                                int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
+                                if (lastHours >= 3)
+                                {
+                                    //处理结束时间
+                                    if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                                    {
+                                        mealDeduction += 10; //餐补扣款
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case 4: //4调休假
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 5: //5婚假
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 6: //6产假
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 7: //7陪产假
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 8: //8其他
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+                case 9: //9丧假
+                    CalculateTypeFeeSub(date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    break;
+
+            }
+        }
+
+
+        /// <summary>
+        /// 计算类型费用
+        /// </summary>
+        /// <param name="date_Range_type">
+        /// halfday 全天
+        /// hour  小时
+        /// </param>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <param name="duration"></param>
+        /// <param name="mealDeduction"></param>
+        public static void CalculateTypeFeeSub(string date_Range_type, string startTime, string endTime, int duration, out decimal mealDeduction)
+        {
+            mealDeduction = 0;
+            string am_starttime = "08:59";
+            string am_endtime = "13:01";
+
+            if (date_Range_type == "halfday")
+            {
+                mealDeduction = 10; //餐补扣款 
+            }
+            else if (date_Range_type == "hour")
+            {
+                if (duration >= 3 && duration < 7) //单天请假三小时 && 请假时间在上午 则没有餐补
+                {
+                    //处理开始时间
+                    if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
+                    {
+                        //处理结束时间
+                        if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                        {
+                            mealDeduction = 10; //餐补扣款
+                        }
+                    }
+                }
+                else if (duration >= 7 && duration <= 7.5 )
+                {
+                    mealDeduction = 10; //餐补扣款
+                }
+                else if (duration >= 7.5) //多天计算
+                {
+                    decimal leaveDays = Convert.ToDecimal(duration / 7.5);
+
+                    if (leaveDays % 1 == 0)
+                    {
+                        mealDeduction = 10 * leaveDays; //餐补扣款
+                    }
+                    else
+                    {
+                        mealDeduction = 10 * Convert.ToInt32(leaveDays);
+
+                        //得到最后一天的请假时间 是否有餐补
+                        int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
+                        if (lastHours >= 3)
+                        {
+                            //处理结束时间
+                            if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                            {
+                                mealDeduction += 10; //餐补扣款
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 获取打卡补卡类型
+        /// </summary>
+        /// <param name="template_id"></param>
+        /// <returns></returns>
+        public static async Task<List<VacationLeaveTypeView>> GetVacationReissueCardTypes(string template_id)
+        {
+            List<VacationLeaveTypeView> vacationLeaveTypes = new List<VacationLeaveTypeView>();
+
+            TemplateDetailView templateDetailView = new TemplateDetailView();
+            templateDetailView = await _qiYeWeChatApiService.GetTemplateDetailAsync(template_id);
+            if (templateDetailView.errcode != 0)
+            {
+                return vacationLeaveTypes;
+            }
+            List<VacationItemInfo> VacationItemInfos = templateDetailView.vacation_list.item;
+
+            foreach (var item in VacationItemInfos)
+            {
+                ValueItem valueInfo = item.name.Where(it => it.lang == "zh_CN").FirstOrDefault();
+                if (valueInfo != null)
+                {
+                    vacationLeaveTypes.Add(
+                    new VacationLeaveTypeView()
+                    {
+                        id = item.id,
+                        name = valueInfo.text
+                    });
+                }
+            }
+
+            return vacationLeaveTypes;
+        }
 
         /// <summary>
         /// 打卡数据

+ 5 - 3
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/IQiYeWeChatApiService.cs

@@ -78,11 +78,13 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         ///// <returns></returns>
         //Task<ApprovalInfoView> GetApprovalInfoAsync(DateTime startDt, DateTime endDt, int record_type);
 
-        /// <summary>
+        //// <summary>
         /// 批量获取审批详情
-        /// </summary>
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
+        /// <param name="creator">
+        /// 申请人
+        /// </param>
         /// <param name="sp_status">
         /// sp_status-审批单状态(1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付)
         /// </param>
@@ -90,7 +92,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
         /// </param>
         /// <returns></returns>
-        Task<List<Sp_Detail>> GetApprovalDetailsAsync(DateTime startDt, DateTime endDt, int sp_status, int record_type);
+        Task<List<Sp_Detail>> GetApprovalDetailsAsync(DateTime startDt, DateTime endDt, string creator, int sp_status, int record_type);
 
         /// <summary>
         /// 获取审批模板详情

+ 26 - 8
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/QiYeWeChatApiService.cs

@@ -8,6 +8,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Text.Json;
 using Ubiety.Dns.Core;
+using Ubiety.Dns.Core.Common;
 
 namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
 {
@@ -603,14 +604,18 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// </summary>
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
+        /// <param name="creator">
+        /// 申请人
+        /// </param>
         /// <param name="sp_status">
         /// sp_status-审批单状态(1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付)
         /// </param>
         /// <param name="record_type">
+        /// record_type == 0 ALL  有值 请填写对应值
         /// record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
         /// </param>
         /// <returns></returns>
-        private async Task<ApprovalInfoView> GetApprovalInfoAsync(DateTime startDt,DateTime endDt,int sp_status, int record_type)
+        private async Task<ApprovalInfoView> GetApprovalInfoAsync(DateTime startDt,DateTime endDt,string creator, int sp_status, int record_type)
         {
             Stopwatch sw = new Stopwatch();
             sw.Start();
@@ -634,9 +639,14 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             string url = string.Format("/cgi-bin/oa/getapprovalinfo?access_token={0}", access_Token.access_token);
 
             List<Dic> filters = new List<Dic> {
+                new Dic() { key = "creator", value = creator },  //筛选条件 申请人
                 new Dic() { key = "sp_status", value = sp_status.ToString() },    //筛选条件 审核状态 2 已同意
-                new Dic() { key = "record_type", value = record_type.ToString() },  //筛选条件 审批单类型 请假 1
-            }; 
+            };
+
+            if (record_type != 0)
+            {
+                filters.Add(new Dic() { key = "record_type", value = record_type.ToString() });  //筛选条件 审批单类型 请假 1
+            }
 
             ApprovalInfo_Request approvalInfoReq = new ApprovalInfo_Request()
             {
@@ -719,7 +729,6 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             ApprovalDetailView = System.Text.Json.JsonSerializer.Deserialize<ApprovalDetailView>(stringResponse,
                 new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
 
-
             return ApprovalDetailView;
         }
 
@@ -728,6 +737,9 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// </summary>
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
+        /// <param name="creator">
+        /// 申请人
+        /// </param>
         /// <param name="sp_status">
         /// sp_status-审批单状态(1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付)
         /// </param>
@@ -735,15 +747,21 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
         /// </param>
         /// <returns></returns>
-        public async Task<List<Sp_Detail>> GetApprovalDetailsAsync(DateTime startDt, DateTime endDt,int sp_status, int record_type)
+        public async Task<List<Sp_Detail>> GetApprovalDetailsAsync(DateTime startDt, DateTime endDt, string creator, int sp_status, int record_type)
         {
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
 
             List<Sp_Detail> details = new List<Sp_Detail>();
 
-            Stopwatch sw = new Stopwatch();
-            sw.Start();
+            if (string.IsNullOrEmpty(creator))
+            {
+                return details;
+            }
+
+
             ApprovalInfoView approvalInfoView = new ApprovalInfoView();
-            approvalInfoView = await GetApprovalInfoAsync(startDt,endDt, sp_status,record_type);
+            approvalInfoView = await GetApprovalInfoAsync(startDt,endDt, creator,sp_status, record_type);
             if (approvalInfoView.errcode != 0)
             {
                 return details;

+ 10 - 5
OASystem/OASystem.Domain/ViewModels/PersonnelModule/WageSheetView.cs

@@ -353,20 +353,25 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
         public string? SubType { get; set; }
 
         /// <summary>
-        /// 请假开始时间,datetime时间
+        /// 扣款金额
         /// </summary>
-        public DateTime? Start_time_dt { get; set; }
+        public decimal Deduction { get; set; }
 
         /// <summary>
-        /// 请假开始时间,datetime时间
+        /// 起止时间
         /// </summary>
-        public DateTime? End_time_dt { get; set; }
+        public string? Start_end_time_dt { get; set; }
 
         /// <summary>
-        /// 请假时长,单位小时
+        /// 请假时长
         /// </summary>
         public int Duration { get; set; }
 
+        /// <summary>
+        /// 请假时长,单位小时
+        /// </summary>
+        public string unit { get; set; } = "小时";
+
         /// <summary>
         /// 请假事由
         /// </summary>

+ 37 - 1
OASystem/OASystem.Domain/ViewModels/QiYeWeChat/ApprovalDataView.cs

@@ -205,10 +205,34 @@ namespace OASystem.Domain.ViewModels.QiYeWeChat
         /// 开始时间
         /// </summary>
         public long new_begin { get; set; }
+
+        /// <summary>
+        /// 开始时间 
+        /// </summary>
+        public DateTime new_begin_dt
+        {
+            get
+            {
+                return new DateTime(new_begin * 10000000 + 621355968000000000L).ToLocalTime();
+            }
+        }
+
         /// <summary>
         /// 结束时间
         /// </summary>
         public long new_end { get; set; }
+
+        /// <summary>
+        /// 开始时间 
+        /// </summary>
+        public DateTime new_end_dt
+        {
+            get
+            {
+                return new DateTime(new_end * 10000000 + 621355968000000000L).ToLocalTime();
+            }
+        }
+
         /// <summary>
         /// 请假时长
         /// </summary>
@@ -515,7 +539,19 @@ namespace OASystem.Domain.ViewModels.QiYeWeChat
         /// <summary>
         /// 审批申请提交时间,Unix时间戳
         /// </summary>
-        public int apply_time { get; set; }
+        public long apply_time { get; set; }
+
+        /// <summary>
+        /// 开始时间 
+        /// </summary>
+        public DateTime apply_time_dt
+        {
+            get
+            {
+                return new DateTime(apply_time * 10000000 + 621355968000000000L).ToLocalTime();
+            }
+        }
+
         /// <summary>
         /// 申请人信息
         /// </summary>

+ 36 - 0
OASystem/OASystem.Domain/ViewModels/QiYeWeChat/TemplateDetailView.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
 
 namespace OASystem.Domain.ViewModels.QiYeWeChat
 {
@@ -19,6 +20,41 @@ namespace OASystem.Domain.ViewModels.QiYeWeChat
         /// 模板控件信息
         /// </summary>
         public Template_content template_content { get; set; }
+
+        public VacationItem vacation_list { get; set; }
+    }
+
+
+    public class VacationItem
+    {
+        public List<VacationItemInfo> item { get; set; }
+    }
+
+
+    public class VacationItemInfo
+    {
+        /// <summary>
+        /// 类型Id
+        /// </summary>
+        public int id { get; set; }
+
+        /// <summary>
+        /// 类型值
+        /// </summary>
+        public List<ValueItem> name { get; set; }
+    }
+
+    public class VacationLeaveTypeView
+    {
+        /// <summary>
+        /// 请假 类型id
+        /// </summary>
+        public int id { get; set; }
+
+        /// <summary>
+        /// 请假 类型名称
+        /// </summary>
+        public string name { get; set; }
     }
 
     /// <summary>