using DS.Module.Core; using DS.Module.Core.Extensions; using DS.Module.UserModule; using DS.WMS.Common.Enum; using DS.WMS.Core.BaseInfo.Dtos; using DS.WMS.Core.BaseInfo.Entity; using DS.WMS.Core.BaseInfo.Interface; using DS.WMS.Core.System.Dtos; using DS.WMS.Core.System.Entity; using Mapster; using Microsoft.Extensions.DependencyInjection; using SqlSugar; namespace DS.WMS.Core.BaseInfo.Method; /// /// / /// public class ClientAuditService : IClientAuditService { private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; private readonly IUser user; /// /// /// /// public ClientAuditService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); user = _serviceProvider.GetRequiredService(); } public DataResult> GetListByPage(PageRequest request) { //序列化查询条件 var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); var data = db.Queryable() .Where(whereList) .Where(x => x.AuditStatus != AuditStatus.NoAudit.ToEnumInt()) .ToQueryPage(request.PageCondition); return data; } /// /// 获取公司信息 /// /// /// public DataResult GetClientInfo(string id) { var companyId = Guid.Parse(id); var licenseFiles = db.Queryable().Where(x => x.PID == companyId && x.FILETYPE == "营业执照") .Select(it => new fileinfo { FileName = it.FILENAME, FilePath = it.IMGPATH }).ToArray(); var cardFiles = db.Queryable().Where(x => x.PID == companyId && x.FILETYPE == "法人身份证") .Select(it => new fileinfo { FileName = it.FILENAME, FilePath = it.IMGPATH }).ToArray(); var data = db.Queryable() .Where(x => x.GID == companyId) .Select() .Mapper(it => { //只能写在Select后面 it.licensefiles = licenseFiles; it.cardfiles = cardFiles; }) .First(); return DataResult.Successed("获取数据成功", data); } public DataResult AuditClient(CommonAuditInput model) { var userId = user.UserId; var clientId = Guid.Parse(model.Id); var company = db.Queryable().Where(x => x.GID == clientId).First(); if (company.IsNull()) { return DataResult.Failed("公司信息不存在!"); } if (company.AuditStatus == AuditStatus.Approve.ToEnumInt()) { return DataResult.Failed("已审批通过!"); } if (model.Status == 1) { try { //开启事务 db.Ado.BeginTran(); company.AuditStatus = model.Status; company.AuditNote = model.AuditNote; db.Updateable(company).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); var client = company.Adapt();; client.CODENAME = PinYinUtil.GetFristLetter(company.SHORTNAME); client.GID = clientId.ToString(); client.STATUS = 0; db.Insertable(client).ExecuteCommand(); db.Ado.CommitTran(); return DataResult.Successed("审批成功!"); } catch (Exception ex) { db.Ado.RollbackTran(); return DataResult.Failed("审批失败!" + ",请联系管理员!"); } } else { company.AuditStatus = model.Status; company.AuditNote = model.AuditNote; db.Updateable(company).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); return DataResult.Successed("驳回成功!"); } } }