hwh
2024-07-04 2dd922eb3ab68c0314f5828fcae1ed7db0e17d9e
Wms/WMS.BLL/SysServer/CustomerServer.cs
@@ -25,7 +25,7 @@
        }
        public List<CustomerDto> GetCustomerList(string no,string name, int? type, string linkMan, string phone, int page, int limit, out int count)
        public async Task<List<CustomerDto>> GetCustomerList(string no, string name, int? type, string linkMan, string phone, int page, int limit, RefAsync<int> count)
        {
            try
            {
@@ -37,10 +37,10 @@
                    .AndIF(!string.IsNullOrWhiteSpace(phone), it => it.Phone.Contains(phone.Trim()))
                    .ToExpression();//注意 这一句 不能少
                var data = CustomerRst.GetAllByOrderPageAsync(item, limit, page, out int counts)
                var data = await CustomerRst.GetAllByOrderPage(item, limit, page, out int counts)
                    .Includes(x => x.CreateUserInfo)
                    .Includes(x => x.UpdateUserInfo)
                    .ToList();
                    .ToListAsync();
                count = counts;
                return data.Select(m => new CustomerDto()
@@ -68,11 +68,11 @@
            }
        }
        public SysCustomer GetCustomer(int id)
        public async Task<SysCustomer> GetCustomer(int id)
        {
            try
            {
                var data = CustomerRst.GetOneById(id);
                var data = await CustomerRst.GetOneByIdAsync(id);
                return data;
            }
            catch (Exception e)
@@ -81,11 +81,11 @@
            }
        }
        public List<SysCustomer> GetCustomerSelect()
        public async Task<List<SysCustomer>> GetCustomerSelect()
        {
            try
            {
                var data = CustomerRst.GetAllAsync().ToList();
                var data = await CustomerRst.GetAllAsync();
                return data;
            }
            catch (Exception e)
@@ -94,17 +94,17 @@
            }
        }
        public bool AddCustomer(string no, string name, int type, string address, string linkMan, string phone, string bankAccount, string creditRating, string demo, int userId)
        public async Task<bool> AddCustomer(string no, string name, int type, string address, string linkMan, string phone, string bankAccount, string creditRating, string demo, int userId)
        {
            try
            {
                //判断是否重复
                var customer = CustomerRst.GetAllWhereAsync(m => m.CustomerNo == no && m.IsDel == "0").First();
                var customer = CustomerRst.GetAllWhere(m => m.CustomerNo == no && m.IsDel == "0").First();
                if (customer != null)
                {
                    throw new Exception("相同编码的客户已存在,请勿重复添加");
                }
                var num = CustomerRst.Add(new SysCustomer()
                var num = await CustomerRst.AddAsync(new SysCustomer()
                {
                    CustomerNo = no,
                    CustomerName = name,
@@ -125,12 +125,12 @@
            }
        }
        public bool EditCustomer(int id, string no, string name, int type, string address, string linkMan, string phone,
        public async Task<bool> EditCustomer(int id, string no, string name, int type, string address, string linkMan, string phone,
            string bankAccount, string creditRating, string demo, int userId)
        {
            try
            {
                var customer = CustomerRst.GetOneById(id);
                var customer = await CustomerRst.GetOneByIdAsync(id);
                if (customer == null)
                {
                    throw new Exception("未查询到客户信息");
@@ -147,7 +147,7 @@
                customer.Demo = demo;
                customer.UpdateUser = userId;
                customer.UpdateTime = DateTime.Now;
                var num = CustomerRst.Edit(customer);
                var num = await CustomerRst.EditAsync(customer);
                return num > 0;
            }
            catch (Exception e)
@@ -156,35 +156,21 @@
            }
        }
        public bool DelCustomer(int id, int userId)
        public async Task<bool> DelCustomer(int id, int userId)
        {
            try
            {
                var num = CustomerRst.Remove(id, userId);
                return num > 0;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            var num = await CustomerRst.RemoveAsync(id, userId);
            return num > 0;
        }
        public bool DelsCustomer(List<int> ids, int userId)
        public async Task<bool> DelsCustomer(List<int> ids, int userId)
        {
            try
            var list = await CustomerRst.GetAllWhere(m => ids.Contains(m.Id)).ToListAsync();
            for (int i = 0; i < list.Count; i++)
            {
                var list = CustomerRst.GetAllWhereAsync(m => ids.Contains(m.Id)).ToList();
                for (int i = 0; i < list.Count; i++)
                {
                    _operation.InsertOperation("基础信息", "客户管理", list[i].CustomerNo, "删除", "删除客户信息 客户号:" + list[i].CustomerNo, userId);
                }
                var num = CustomerRst.RemoveAll(list, userId);
                return num > 0;
                await _operation.InsertOperation("基础信息", "客户管理", list[i].CustomerNo, "删除", "删除客户信息 客户号:" + list[i].CustomerNo, userId);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            var num = await CustomerRst.RemoveAllAsync(list, userId);
            return num > 0;
        }
    }
}