From 8c92db325f7c801d2df095763a17673fa6c92085 Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期五, 07 三月 2025 18:56:09 +0800
Subject: [PATCH] 物流配送第一点

---
 cylsg/cylsg.Application/CyOS/CyOSBaoXiaoJingLiController.cs |  135 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoJingLiController.cs b/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoJingLiController.cs
index c4aa2a1..7823af8 100644
--- a/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoJingLiController.cs
+++ b/cylsg/cylsg.Application/CyOS/CyOSBaoXiaoJingLiController.cs
@@ -1,5 +1,6 @@
 锘縰sing cylsg.Model.ECTEModel;
 using cylsg.Model.utilityViewModel;
+using cylsg.utility.Extend;
 using ECTESTOA;
 using Furion.LinqBuilder;
 using Models;
@@ -16,6 +17,7 @@
     /// 宸濆嵃鎶ラ攢缁忕悊API
     /// </summary>
     [Authorize]
+    [ApiDescriptionSettings("CYOA")]
     public class CyOSBaoXiaoJingLiController: IDynamicApiController
     {
         private readonly IOAServices _OAServices;
@@ -42,6 +44,7 @@
             Expression<Func<OaWorkPlan, bool>> SearchList = (x) => true;
 
             //宸濆嵃宸ヤ綔鍗�
+            SearchList = SearchList.And(x => x.ApprovalStatus != PlanStatusType.Uncommitted);
             SearchList = SearchList.And(x => x.MemberId == _OAServices.firmId);
             SearchList = SearchList.And(x => x.PlanType == 3);
             SearchList = SearchList.And(x => x.PlanDataType == 17);
@@ -135,6 +138,10 @@
                 throw Oops.Oh("娌℃湁鎵惧埌鎶ラ攢鍗�");
             if ( data.ApprovalStatus != PlanStatusType.unApproval)
                 throw Oops.Oh("鎶ラ攢鍗曞凡缁忔壒澶嶅畬姣�");
+            if (data.ApprovalStatus == PlanStatusType.Uncommitted)
+            {
+                throw Oops.Oh("鎶ラ攢鍗曟湭鎻愪氦涓嶅彲瀹℃壒");
+            }
             OaWorkPlanShenpi shenpi = data.OaWorkPlanShenpis.Where(x => x.ApprovalStaffId == Permissions.MemberId&&x.Buzhou==2).FirstOrDefault();
             await _SugarClient.AsTenant().BeginTranAsync();
             try
@@ -168,6 +175,17 @@
                     };
                     await _SugarClient.Insertable(shenpi).ExecuteCommandAsync();
                 }
+                if(!(param.RewardResult?.isPureNum()==true))
+                {
+                    throw Oops.Oh("绉戠洰閫夋嫨閿欒");
+                }
+                //瀹℃壒鏃跺彲淇敼鍐呭
+                data.RewardResult = param.RewardResult;
+                data.PlanContent = param.PlanContent;
+                if(param.PlanMoney>0&&param.PlanMoney<=data.PlanMoney)
+                data.PlanMoney = param.PlanMoney;
+
+
 
                 data.ApprovalTime = DateTime.Now;
                 data.ApprovalStatus = param.ApprovalStatus;
@@ -191,6 +209,101 @@
         }
 
         /// <summary>
+        /// 鎵归噺瀹℃壒
+        /// </summary>
+        [HttpPost]
+        public async Task<bool> BatchShenPi(BatchShenPiIn param)
+        {
+            if (param.ApprovalStatus == PlanStatusType.unApproval)
+                throw Oops.Oh("涓嶅彲璁剧疆涓烘湭瀹℃壒鐘舵��");
+            if (!param.OA_WorkPlanIds.Any())
+                throw Oops.Oh("鏈�変腑浠讳綍鎶ラ攢鍗�");
+            if (!await CheckRols())
+            {
+                throw Oops.Oh("娌℃湁鏉冮檺");
+            }
+          
+            var dataList = await _SugarClient.Queryable<OaWorkPlan>().Includes(x => x.OaWorkPlanShenpis).In(param.OA_WorkPlanIds).ToListAsync();
+            if (dataList == null||dataList.Count==0)
+                throw Oops.Oh("娌℃湁鎵惧埌鎶ラ攢鍗�");
+            try
+            {
+                await _SugarClient.AsTenant().BeginTranAsync();
+                foreach (var item in dataList)
+                {
+                    if (item.ApprovalStatus != PlanStatusType.unApproval)
+                    {
+                        await _SugarClient.AsTenant().RollbackTranAsync();
+                        throw Oops.Oh($"{item.SentStaff.Name} 鐨勬姤閿�鍗�:{item.PlanContent}---宸茬粡鎵瑰瀹屾瘯锛岀粓姝㈡湰娆℃搷浣�");
+                    }
+                    if (item.ApprovalStatus == PlanStatusType.Uncommitted)
+                    {
+                        await _SugarClient.AsTenant().RollbackTranAsync();
+                        throw Oops.Oh($"{item.SentStaff.Name} 鐨勬姤閿�鍗�:{item.PlanContent}---宸茬粡鏈彁浜ゆ垨鑰呮湭瀹屾垚鍓嶇疆瀹℃壒锛岀粓姝㈡湰娆℃搷浣�");
+                    }
+                   if( item.OaWorkPlanShenpis.Where(x=>x.Buzhou == 1&&x.ApprovalStatus== PlanStatusType.Yes).Count()<2)
+                    {
+                        await _SugarClient.AsTenant().RollbackTranAsync();
+                        throw Oops.Oh($"{item.SentStaff.Name} 鐨勬姤閿�鍗�:{item.PlanContent}---鏈畬鎴愬墠缃鎵癸紝缁堟鏈鎿嶄綔");
+                    }
+                    OaWorkPlanShenpi shenpi = item.OaWorkPlanShenpis.Where(x => x.ApprovalStaffId == Permissions.MemberId && x.Buzhou == 2).FirstOrDefault();
+                    if (shenpi != null)
+                    {
+                        await _SugarClient.AsTenant().RollbackTranAsync();
+                        //宸茬粡鎵瑰
+                        throw Oops.Oh($"{item.SentStaff.Name} 鐨勬姤閿�鍗�:{item.PlanContent} ----鎶ラ攢鍗曞凡缁忔壒澶嶅畬姣� 涓嶅彲鏇存敼,鎿嶄綔缁堟");
+                     
+
+                    }
+                    else
+                    {
+                        shenpi = new OaWorkPlanShenpi()
+                        {
+                            ApprovalStaffId = Permissions.MemberId,
+                            ApprovalContent = param.ApprovalContent,
+                            ApprovalStatus = param.ApprovalStatus,
+                            ApprovalTime = DateTime.Now,
+                            //鎬荤粡鐞嗗鎵逛负2
+                            Buzhou = 2,
+                            CreateTime = DateTime.Now,
+                            Operator = Permissions.Name,
+                            OA_WorkPlanId = item.Keyid,
+
+                        };
+                        await _SugarClient.Insertable(shenpi).ExecuteCommandAsync();
+                    }
+
+                    //瀹℃壒鏃跺彲淇敼鍐呭
+                 
+                  
+
+
+
+                    item.ApprovalTime = DateTime.Now;
+                    item.ApprovalStatus = param.ApprovalStatus;
+                    item.ApprovalContent = param.ApprovalContent;
+                    item.LastUpdateTime = DateTime.Now;
+
+
+
+
+                    await _SugarClient.Updateable(item).ExecuteCommandAsync();
+                   
+                }
+                await _SugarClient.AsTenant().CommitTranAsync();
+                return true;
+            }
+            catch (Exception)
+            {
+                await _SugarClient.AsTenant().RollbackTranAsync();
+                throw;
+            }
+           
+           
+
+        }
+
+        /// <summary>
         /// 鍒ゆ柇鏄惁鍏锋湁鏉冮檺
         /// </summary>
         /// <returns></returns>
@@ -210,5 +323,27 @@
                 return false;
         }
     }
+    /// <summary>
+    /// 鎵归噺瀹℃壒鍙傛暟
+    /// </summary>
+    public class BatchShenPiIn
+    {
+        /// <summary>
+        /// 宸ヤ綔璁″垝ID 鎶ラ攢鍗旾D
+        /// </summary>
+        [Required]
+        public int[] OA_WorkPlanIds { get; set; }
+
+        /// <summary>
+        /// 瀹℃壒鐘舵��
+        /// </summary>       
+        [Required]
+        public PlanStatusType? ApprovalStatus { get; set; }       
+
+        /// <summary>
+        /// 瀹℃壒鍐呭
+        /// </summary>       
+        public string ApprovalContent { get; set; }
+    }
 }
 

--
Gitblit v1.9.1