wxw
1 天以前 22428c74e4b57c87a979a8f2f199e0e8e34dbb86
Wms/WMS.BLL/SysServer/CustomerServer.cs
@@ -4,8 +4,10 @@
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Model.InterFaceModel;
using Model.ModelDto.SysDto;
using SqlSugar;
using WMS.Entity.Context;
using WMS.Entity.LogEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.ILogServer;
@@ -16,6 +18,7 @@
{
    public class CustomerServer : ICustomerServer
    {
        private static readonly SqlSugarScope Db = DataContext.Db;
        public ICustomerRepository CustomerRst { get; set; }
        private readonly IOperationSysServer _operation; //操作日志
        public CustomerServer(ICustomerRepository customerRst, IOperationSysServer operation)
@@ -23,7 +26,7 @@
            CustomerRst = customerRst;
            _operation = operation;
        }
        public async Task<List<CustomerDto>> GetCustomerList(string no, string name, int? type, string linkMan, string phone, int page, int limit, RefAsync<int> count)
        {
@@ -41,7 +44,7 @@
                    .Includes(x => x.CreateUserInfo)
                    .Includes(x => x.UpdateUserInfo)
                    .ToListAsync();
                count = counts;
                count.Value = counts;
                return data.Select(m => new CustomerDto()
                {
@@ -172,5 +175,41 @@
            var num = await CustomerRst.RemoveAllAsync(list, userId);
            return num > 0;
        }
        /// <summary>
        /// SAP新增客户供应商数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task<string> AddCustomerSap(SendCustomerVm model)
        {
            try
            {
                //判断是否重复
                var customer = Db.Queryable<SysCustomer>().First(m => m.IsDel == "0" && m.CustomerNo == model.customerNo.ToString());
                if (customer != null)
                {
                    throw new Exception("相同编码的客户已存在,请勿重复添加");
                }
                var addCustomer = new SysCustomer()
                {
                    CustomerNo = model.customerNo.ToString(),
                    CustomerName = model.customerName,
                    Type = int.Parse(model.CustomerType),
                    Address = model.streetAddress,
                    LinkMan = model.contact,
                    Phone = model.contactMobile,
                    CreateUser = 0,
                };
                await Db.Insertable(addCustomer).ExecuteCommandAsync();
                return "0";
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
    }
}