using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using djy.Paas.IService; using djy.Paas.Model; using Ys.Core.Common; namespace djy.Paas.Service { /// /// 报关货主端实现接口接口实现 /// public class BaoguanOrderClientService:ServBase,IBaoguanOrderClientService { public BaoguanOrderClientService(string dbkey = DbList.djypublicedb) : base(dbkey) { } /// /// /// /// /// /// public ReturnPagedResult GetList(BaoguanOrderClientDto Dto, ApiFromDto apiFromDto) { var rs =new ReturnPagedResult(); var sql = DbBus.Get(DbList.djypublicedb).Select().LeftJoin((c, o) => c.BaoguanOrderGid == o.Gid).Where((c, o) => c.Status > 0) .WhereIf(Dto.CompGId != null, (c, o) => c.CompGId == Dto.CompGId) .WhereIf(Dto.UserGid != null, (c, o) => c.UserGid == Dto.UserGid) .WhereIf(Dto.Gidlist.Count>0,(c,o)=>Dto.Gidlist.Contains(c.Gid)) .WhereIf(Dto.ShipOrderNo.IsNotNull(),(c,o)=>c.ShipOrderNo==Dto.ShipOrderNo) .WhereIf(Dto.ShipOrderNo.IsNotNull(), (c, o) => c.ShipOrderNo.Contains(Dto.ShipOrderNo)) .WhereIf(Dto.BaoguanAgent.IsNotNull(), (c, o) => c.BaoguanAgent.Contains(Dto.BaoguanAgent)) .WhereIf(Dto.IEFlag.IsNotNull(), (c, o) => c.IEFlag == Dto.IEFlag); rs.Data = sql.OrderByDescending((c, o) => c.AddTime).Count(out var totalcount).Page(apiFromDto.Page,apiFromDto.Limit) .ToList(); rs.Pageset(apiFromDto,totalcount); rs.OK(); return rs; } /// /// 创建客户报关单同时数据初始化到阿里报关数据回写做绑定关系 /// /// /// public new ReturnResult Add(tb_BaoguanOrderClient Dto) { var rs = new ReturnResult(); Dto.Init(); var User = DbBus.Get(DbList.djyolddb).Select().Where(w => w.GID == Dto.UserGid.ToString()).ToOne(); var aliorder = DbBus.Get(DbList.djypublicedb).Select().Where(w => w.ShipOrderNo == Dto.ShipOrderNo).ToOne(); Dto.CompName = User.COMNAME; if (aliorder == null) { //同时创建 阿里的监控订单数据 var order = new tb_BaoGuanOrderList(); order.Init(); order.ShipOrderNo = Dto.ShipOrderNo; DbBus.Get(DbList.djypublicedb).Insert(order).ExecuteAffrows(); Dto.BaoguanOrderGid = order.Gid; } else { Dto.BaoguanOrderGid = aliorder.Gid; } DbBus.Get(DbList.djypublicedb).Insert(Dto).ExecuteAffrows(); rs.OK(); return rs; } } }