/// <summary> /// 获得一条数据 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <SysCodeDto> > GetByGuidAsync(ByGuidPost parm) { var model = SysCodeDb.GetById(parm.guid); var res = new ApiResult <SysCodeDto> { statusCode = 200, data = model != null ? new SysCodeDto() { guid = model.Guid, parentguid = model.ParentGuid, name = model.Name, type = model.CodeType, sort = model.Sort, status = model.Status } : null }; if (model == null) { var pmdel = Db.Queryable <SysCode>().OrderBy(m => m.Sort, OrderByType.Desc).First(); res.data = new SysCodeDto() { status = true, sort = pmdel?.Sort + 1 ?? 1 }; } return(await Task.Run(() => res)); }
/// <summary> /// 查询多条记录 /// </summary> /// <returns></returns> public Task <ApiResult <Page <SaleOrderDto> > > GetPagesAsync(PageParm parm, AppSearchParm searchParm) { var res = new ApiResult <Page <SaleOrderDto> >(); try { var query = Db.Queryable <ErpSaleOrder, ErpShops>((eso, es) => new object[] { JoinType.Left, eso.ShopGuid == es.Guid }) .WhereIF(!string.IsNullOrEmpty(parm.guid), (eso, es) => eso.ShopGuid == parm.guid) .WhereIF(parm.types != 0, (eso, es) => eso.ActivityTypes == parm.types) .WhereIF(searchParm.saleType != 0, (eso, es) => eso.SaleType == searchParm.saleType) .WhereIF(searchParm.activityTypes != 0, (eso, es) => eso.ActivityTypes == searchParm.activityTypes) .WhereIF(!string.IsNullOrEmpty(searchParm.btime) && !string.IsNullOrEmpty(searchParm.etime), (eso, es) => eso.AddDate >= Convert.ToDateTime(searchParm.btime) && eso.AddDate <= Convert.ToDateTime(searchParm.etime)) .OrderBy((eso, es) => eso.AddDate, OrderByType.Desc) .Select((eso, es) => new SaleOrderDto() { Number = eso.Number, ShopName = es.ShopName, ActivityTypes = SqlFunc.ToString(eso.ActivityTypes), SaleType = SqlFunc.ToString(eso.SaleType), Counts = eso.Counts, ActivityName = eso.ActivityName, Money = eso.Money, RealMoney = eso.RealMoney, AddDate = eso.AddDate }) .ToPage(parm.page, parm.limit); //循环商品订单,查询订单下面的商品 var orderNumbers = query.Items?.Select(m => m.Number).ToList(); var orderGood = ErpSaleOrderGoodsDb.GetList(m => orderNumbers.Contains(m.OrderNumber)); foreach (var item in query.Items) { var list = new List <SaleOrderGoodsDto>(); foreach (var row in orderGood) { if (item.Number == row.OrderNumber) { var goodSku = ErpGoodsSkuDb.GetById(row.GoodsGuid); list.Add(new SaleOrderGoodsDto() { Counts = row.Counts, Code = goodSku.Code, GoodsName = SysCodeDb.GetById(goodSku.BrankGuid).Name + SysCodeDb.GetById(goodSku.StyleGuid).Name }); } } item.Goods = list; } res.success = true; res.message = "获取成功!"; res.data = query; } catch (Exception ex) { res.message = ApiEnum.Error.GetEnumText() + ex.Message; res.statusCode = (int)ApiEnum.Error; } return(Task.Run(() => res)); }
/// <summary> /// 获得一条数据 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <SysCode> > GetByGuidAsync(string parm) { var model = SysCodeDb.GetById(parm); var res = new ApiResult <SysCode> { statusCode = 200, data = model != null ? model : new SysCode() { } }; if (model == null) { var pmdel = Db.Queryable <SysCode>().OrderBy(m => m.Sort, OrderByType.Desc).First(); res.data = new SysCode() { Status = true, Sort = pmdel?.Sort + 1 ?? 1 }; } return(await Task.Run(() => res)); }