From 68e78d9fbd99870e147d668b6daf8820f4deeb6a Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期四, 13 六月 2024 10:39:09 +0800
Subject: [PATCH] no message

---
 CoreCms.Net.Web.Admin/Controllers/User/CoreCmsUserController.cs |  194 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 174 insertions(+), 20 deletions(-)

diff --git a/CoreCms.Net.Web.Admin/Controllers/User/CoreCmsUserController.cs b/CoreCms.Net.Web.Admin/Controllers/User/CoreCmsUserController.cs
index 35395c1..8111423 100644
--- a/CoreCms.Net.Web.Admin/Controllers/User/CoreCmsUserController.cs
+++ b/CoreCms.Net.Web.Admin/Controllers/User/CoreCmsUserController.cs
@@ -1,10 +1,10 @@
 /***********************************************************************
- *            Project: CoreCms
- *        ProjectName: 鏍稿績鍐呭绠$悊绯荤粺                                
- *                Web: https://www.corecms.net                      
- *             Author: 澶х伆鐏�                                          
- *              Email: jianweie@163.com                                
- *         CreateTime: 2021/1/31 21:45:10
+ *            Project: baifenBinfa
+ *        ProjectName: 鐧惧垎鍏垫硶绠$悊绯荤粺                               
+ *                Web: http://chuanyin.com                     
+ *             Author:                                        
+ *              Email:                               
+ *         CreateTime: 202403/02   
  *        Description: 鏆傛棤
  ***********************************************************************/
 
@@ -14,13 +14,16 @@
 using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
+using CoreCms.Net.Auth.HttpContextUser;
 using CoreCms.Net.Configuration;
 using CoreCms.Net.Filter;
 using CoreCms.Net.IServices;
 using CoreCms.Net.Model.Entities;
+using CoreCms.Net.Model.Entities.baifenbingfa.apply;
 using CoreCms.Net.Model.Entities.Expression;
 using CoreCms.Net.Model.FromBody;
 using CoreCms.Net.Model.ViewModels.UI;
+using CoreCms.Net.Services;
 using CoreCms.Net.Utility.Extensions;
 using CoreCms.Net.Utility.Helper;
 using CoreCms.Net.Web.Admin.Infrastructure;
@@ -47,6 +50,8 @@
         private readonly ICoreCmsUserPointLogServices _coreCmsUserPointLogServices;
         private readonly ICoreCmsUserServices _coreCmsUserServices;
         private readonly IWebHostEnvironment _webHostEnvironment;
+        private readonly IHttpContextUser _httpContextUser;
+        private readonly IapplyModelServices _applyModelServices;
 
 
         /// <summary>
@@ -57,12 +62,16 @@
         /// <param name="coreCmsUserGradeServices"></param>
         /// <param name="coreCmsUserBalanceServices"></param>
         /// <param name="coreCmsUserPointLogServices"></param>
+        ///  <param name="httpContextUser"></param>
+        ///  <param name="applyModelServices"></param>
         public CoreCmsUserController(
             IWebHostEnvironment webHostEnvironment
             , ICoreCmsUserServices coreCmsUserServices
             , ICoreCmsUserGradeServices coreCmsUserGradeServices
             , ICoreCmsUserBalanceServices coreCmsUserBalanceServices
             , ICoreCmsUserPointLogServices coreCmsUserPointLogServices
+            , IHttpContextUser httpContextUser
+            , IapplyModelServices applyModelServices
         )
         {
             _webHostEnvironment = webHostEnvironment;
@@ -70,6 +79,8 @@
             _coreCmsUserGradeServices = coreCmsUserGradeServices;
             _coreCmsUserBalanceServices = coreCmsUserBalanceServices;
             _coreCmsUserPointLogServices = coreCmsUserPointLogServices;
+            _httpContextUser = httpContextUser;
+            _applyModelServices = applyModelServices;
         }
 
         #region 鑾峰彇鍒楄〃============================================================
@@ -162,6 +173,15 @@
             if (grade > 0)
             {
                 where = where.And(p => p.grade == grade);
+            }
+            //鐢ㄦ埛绛夌骇 int
+            var isBaifenPromotion = Request.Form["isBaifenPromotion"].FirstOrDefault();
+            if (!string.IsNullOrEmpty(isBaifenPromotion))
+            {
+                if(isBaifenPromotion=="1")
+                where = where.And(p => p.IsBaifenPromotion == true);
+                else
+                    where = where.And(p => p.IsBaifenPromotion == false);
             }
             //鍒涘缓鏃堕棿 datetime
             var createTime = Request.Form["createTime"].FirstOrDefault();
@@ -994,7 +1014,43 @@
         [Description("淇敼浣欓鎻愪氦")]
         public async Task<AdminUiCallBack> DoEditBalance([FromBody] FMUpdateUserBalance entity)
         {
-            var jm = await _coreCmsUserServices.UpdateBalance(entity.id, entity.balance, entity.memo);
+            var jm = new AdminUiCallBack();
+            var model = await _coreCmsUserServices.QueryByIdAsync(entity.id);
+            if (model == null)
+            {
+                jm.msg = "涓嶅瓨鍦ㄦ淇℃伅";
+                return jm;
+            }
+            var id = _httpContextUser.ID;
+            var name = _httpContextUser.Name;
+
+            applyModel entity1 = new applyModel();
+            //entity1.id = 0;
+            entity1.managerID = null;
+            entity1.roleID = "shenpi";
+            entity1.managerApplyCount = 2;
+
+            entity1.aType = applyType.Balance;
+            entity1.ayStataType = applyStataType.applying;
+            entity1.userID = entity.id;
+            entity1.dec = "鐢ㄦ埛"+ model.nickName + "浣欓璋冩暣";
+            entity1.reMake = entity.memo;
+            entity1.oldData = entity.oldbalance+"";
+            entity1.data = entity.balance+"";
+            entity1.createTime = DateTime.Now;
+            entity1.upDataTime = entity1.createTime;
+            entity1.createBy = name;
+            entity1.upDataBy = name;
+            entity1.createById = id;
+            entity1.upDataById = id;
+            entity1.isdelete = false;
+
+            jm = await _applyModelServices.InsertAsync(entity1);
+
+            
+
+           // var jm = await _coreCmsUserServices.UpdateBalance(entity.id, entity.balance, entity.memo);
+            jm.msg = "鏁版嵁鎻愪氦瀹℃牳鎴愬姛";
             return jm;
         }
 
@@ -1041,7 +1097,41 @@
         [Description("淇敼绉垎鎻愪氦")]
         public async Task<AdminUiCallBack> DoEditPoint([FromBody] FMUpdateUserPoint entity)
         {
-            var jm = await _coreCmsUserServices.UpdatePiont(entity);
+            var jm = new AdminUiCallBack(); 
+            var model = await _coreCmsUserServices.QueryByIdAsync(entity.id);
+            if (model == null)
+            {
+                jm.msg = "涓嶅瓨鍦ㄦ淇℃伅";
+                return jm;
+            }
+
+            var id = _httpContextUser.ID;
+            var name = _httpContextUser.Name;
+
+            applyModel entity1 = new applyModel();
+            //entity1.id = 0;
+            entity1.managerID = null;
+            entity1.roleID = "shenpi";
+            entity1.managerApplyCount = 2;
+
+            entity1.aType = applyType.points;
+            entity1.ayStataType = applyStataType.applying;
+            entity1.userID = entity.id;
+            entity1.dec = "鐢ㄦ埛" + model.nickName + "绉垎璋冩暣";
+            entity1.reMake = entity.memo;
+            entity1.oldData = entity.oldpoint + "";
+            entity1.data = entity.point + "";
+            entity1.createTime = DateTime.Now;
+            entity1.upDataTime = entity1.createTime;
+            entity1.createBy = name;
+            entity1.upDataBy = name;
+            entity1.createById = id;
+            entity1.upDataById = id;
+            entity1.isdelete = false;
+
+            jm = await _applyModelServices.InsertAsync(entity1);
+            jm.msg = "鏁版嵁鎻愪氦瀹℃牳鎴愬姛";
+            // var jm = await _coreCmsUserServices.UpdatePiont(entity);
             return jm;
         }
 
@@ -1104,11 +1194,7 @@
         {
             var jm = new AdminUiCallBack();
 
-            if (entity.id == entity.parentId)
-            {
-                jm.msg = "绂佹璁剧疆鑷繁涓鸿嚜宸辩殑鎺ㄨ崘浜�";
-                return jm;
-            }
+           
 
             var model = await _coreCmsUserServices.QueryByIdAsync(entity.id);
             if (model == null)
@@ -1116,10 +1202,10 @@
                 jm.msg = "涓嶅瓨鍦ㄦ淇℃伅";
                 return jm;
             }
-
-            if (entity.parentId > 0)
+            var parentId = 0;
+            if (!string.IsNullOrEmpty(entity.parentId))
             {
-                var parentObj = await _coreCmsUserServices.QueryByIdAsync(entity.parentId);
+                var parentObj = await _coreCmsUserServices.QueryByClauseAsync( x=> x.mobile == entity.parentId && x.isDelete == false && x.status == 1);
                 if (parentObj == null)
                 {
                     jm.msg = "涓嶅瓨鍦ㄦ涓婄骇淇℃伅";
@@ -1131,16 +1217,55 @@
                     jm.msg = "涓嶅厑璁稿弻鏂逛簰鐩歌缃负涓婄骇";
                     return jm;
                 }
+
+                if (entity.id == parentObj.id)
+                {
+                    jm.msg = "绂佹璁剧疆鑷繁涓鸿嚜宸辩殑鎺ㄨ崘浜�";
+                    return jm;
+                }
+
+                parentId = parentObj.id;
             }
             else
             {
-                entity.parentId = 0;
+                jm.msg = "蹇呴』濉啓涓婄骇鎵嬫満";
+                return jm;
             }
 
-            var bl = await _coreCmsUserServices.UpdateAsync(p => new CoreCmsUser() { parentId = entity.parentId }, p => p.id == model.id);
+           // var bl = await _coreCmsUserServices.UpdateAsync(p => new CoreCmsUser() { parentId = entity.parentId }, p => p.id == model.id);
 
-            jm.code = bl ? 0 : 1;
-            jm.msg = bl ? "鏇存柊鎴愬姛" : "鏇存柊澶辫触";
+
+            var id = _httpContextUser.ID;
+            var name = _httpContextUser.Name;
+
+            applyModel entity1 = new applyModel();
+            //entity1.id = 0;
+            entity1.managerID = null;
+            entity1.roleID = "shenpi";
+            entity1.managerApplyCount = 2;
+
+            entity1.aType = applyType.Referrer;
+            entity1.ayStataType = applyStataType.applying;
+            entity1.userID = entity.id;
+            entity1.dec = "鐢ㄦ埛" + model.nickName + "鎺ㄨ崘浜鸿皟鏁�";
+            entity1.reMake = "";
+            entity1.oldData = entity.oldparentId + "";
+            entity1.data = parentId + "";
+            entity1.createTime = DateTime.Now;
+            entity1.upDataTime = entity1.createTime;
+            entity1.createBy = name;
+            entity1.upDataBy = name;
+            entity1.createById = id;
+            entity1.upDataById = id;
+            entity1.isdelete = false;
+
+            jm = await _applyModelServices.InsertAsync(entity1);
+
+            jm.msg = "鏁版嵁鎻愪氦瀹℃牳鎴愬姛";
+
+
+
+
             return jm;
         }
 
@@ -1443,5 +1568,34 @@
         }
 
         #endregion
+        #region 璁剧疆鏄惁鎴愪负鎺ㄥ箍浜哄憳鐧惧垎鍏垫硶
+        /// <summary>
+        /// 璁剧疆鏄惁鎴愪负鎺ㄥ箍浜哄憳
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Description("璁剧疆鏄惁鎴愪负鎺ㄥ箍浜哄憳")]
+        public async Task<AdminUiCallBack> DoSetIsBaiFenBingfaP([FromBody] FMUpdateBoolDataByIntId entity)
+        {
+            var jm = new AdminUiCallBack();
+
+            var oldModel = await _coreCmsUserServices.QueryByIdAsync(entity.id);
+            if (oldModel == null)
+            {
+                jm.msg = "涓嶅瓨鍦ㄦ淇℃伅";
+                return jm;
+            }
+
+            oldModel.IsBaifenPromotion = entity.data;
+
+            var bl = await _coreCmsUserServices.UpdateAsync(oldModel);
+            jm.code = bl ? 0 : 1;
+            jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
+
+            return jm;
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1