移动系统liao
2024-05-20 45c6d6e44e9e8428718fc635d71e0869556da2c3
CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
@@ -32,6 +32,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.Operations;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using ZstdSharp.Unsafe;
@@ -437,6 +438,7 @@
                }
                await _coreCmsDistributionServices.InsertAsync(model);
                _unitOfWork.CommitTran();
@@ -738,11 +740,76 @@
                jm.msg = GlobalConstVars.DataisNo;
                return jm;
            }
            try
            {
                _unitOfWork.BeginTran();
                    //如果是取消审核
            var bl = await _coreCmsDistributionServices.DeleteByIdAsync(entity.id);
            jm.code = bl ? 0 : 1;
            jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
            return jm;
                    var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries();
                    var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey);
                var group = await _userGradeServices.GetUserGradeByValueKey(kc);
                var defgroup = await _userGradeServices.GetDefaultUserGrade();
                    if (defgroup != null)
                    {
                        var olduser = await _userServices.QueryByIdAsync(model.userId);
                        if (olduser != null)
                        {//处理用户等级
                            if (olduser.grade == group.id)
                            {
                                if (defgroup != null)
                                {
                                    olduser.grade = defgroup.id;
                                }
                                else
                                {
                                    olduser.grade = 0;
                                }
                                olduser.updataTime = DateTime.Now;
                                await _userServices.UpdateAsync(olduser);
                            }
                        }
                        var store = await _coreCmsStoreServices.QueryByClauseAsync(x => x.userID == model.userId);
                        //处理店铺  取消已有店铺的使能
                       if(store != null )
                        {
                        // var clerk= await _unitOfWork.GetDbClient().Queryable<CoreCmsClerk>().Where(x => x.storeId == store.id).ToListAsync();
                        //删除店铺员工
                         await _unitOfWork.GetDbClient().Deleteable<CoreCmsClerk>().Where(x=>x.storeId==store.id).ExecuteCommandAsync();
                        //删除店铺
                        await _coreCmsStoreServices.DeleteByIdAsync(store.id);
                    }
                    }
                var  bl = await _coreCmsDistributionServices.DeleteByIdAsync(entity.id);
                _unitOfWork.CommitTran();
                jm.code = bl ? 0 : 1;
                    jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
                    return jm;
            }
            catch (Exception)
            {
                _unitOfWork.RollbackTran();
                jm.code = 1;
                jm.msg = GlobalConstVars.DeleteFailure;
                return jm;
            }
        }
@@ -817,5 +884,10 @@
        }
        #endregion
    }
}