username@email.com
2024-06-26 7f26cd7c3e492062418cdc7dbe9d7ce14cbe5f05
CoreCms.Net.Repository/baifenbingfa/PuhuoRepository.cs
@@ -89,7 +89,9 @@
            oldModel.createBy = entity.createBy;
            oldModel.upDataBy = entity.upDataBy;
            oldModel.isdelete = entity.isdelete;
            oldModel.shoukuannums = entity.shoukuannums;
            oldModel.shoukuanamount = entity.shoukuanamount;
            //事物处理过程结束
            var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
            jm.code = bl ? 0 : 1;
@@ -196,7 +198,7 @@
                goodsId = p.goodsId,
                goodsName = p.goodsName,
                productsId = p.productsId,
                productsName = p.productsName,
                productsName = p.productsName +" " + p.spesDesc,
                spesDesc = p.spesDesc,
                price = p.price,
                nums = p.nums,
@@ -225,7 +227,7 @@
                goodsId = p.goodsId,
                goodsName = p.goodsName,
                productsId = p.productsId,
                productsName = p.productsName,
                productsName = p.productsName + " " + p.spesDesc,
                spesDesc = p.spesDesc,
                price = p.price,
                nums = p.nums,
@@ -238,6 +240,16 @@
                
                }).ToPageListAsync(pageIndex, pageSize, totalCount);
            }
            foreach (var puhuo  in page)
            {
              var distribution = await  DbClient.Queryable<CoreCmsDistribution>().In(puhuo.distributionId).WithNoLockOrNot(blUseNoLock).WithCacheIF(false).SingleAsync();
                if (distribution !=null)
                {
                    puhuo.schoolName = distribution.schoolName;
                }
            }
            var list = new PageList<Puhuo>(page, pageIndex, pageSize, totalCount);
            return list;
        }
@@ -259,7 +271,7 @@
        /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
        /// <returns></returns>
        public async Task<IPageList<Puhuo>> QueryPageGroupAsync(Expression<Func<Puhuo, bool>> predicate,
            Expression<Func<Puhuo, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
            Expression<Func<Puhuo, object>> orderByExpression, OrderByType orderByType, OtherData otherData, int pageIndex = 1,
            int pageSize = 20, bool blUseNoLock = false)
        {
            RefAsync<int> totalCount = 0;
@@ -267,7 +279,7 @@
            if (blUseNoLock)
            {
                page = await DbClient.Queryable<Puhuo>()
                .GroupBy(it => new {  it.CategoryId, it.CategoryName, it.goodsId, it.goodsName, it.productsId, it.productsName, it.price })
                .GroupBy(it => new {  it.CategoryId, it.CategoryName, it.goodsId, it.goodsName, it.productsId, it.productsName, it.price ,it.spesDesc })
                .WhereIF(predicate != null, predicate)
                .Select(p => new Puhuo
                {
@@ -278,7 +290,7 @@
                    goodsId = p.goodsId,
                    goodsName = p.goodsName,
                    productsId = p.productsId,
                    productsName = p.productsName,
                    productsName =  p.productsName + " " + p.spesDesc,
                    price = p.price,
                    tiaozhengnums =SqlFunc.AggregateCount(p.id),
                    nums =  SqlFunc.AggregateSum(p.nums),
@@ -289,6 +301,9 @@
               .MergeTable()//需要加MergeTable才能排序统计过的列
                .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
                .With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
            }
            else
            {
@@ -303,7 +318,7 @@
                     goodsId = p.goodsId,
                     goodsName = p.goodsName,
                     productsId = p.productsId,
                     productsName = p.productsName,
                     productsName = p.productsName + " " + p.spesDesc,
                     price = p.price,
                     tiaozhengnums = SqlFunc.AggregateCount(p.id),
                     nums = SqlFunc.AggregateSum(p.nums),
@@ -315,6 +330,31 @@
                 .OrderByIF(orderByExpression != null, orderByExpression, orderByType)
                 .ToPageListAsync(pageIndex, pageSize, totalCount);
            }
            var pagetotal = DbClient.Queryable<Puhuo>()
               // .GroupBy(it => new { it.CategoryId, it.CategoryName, it.goodsId, it.goodsName, it.productsId, it.productsName, it.price })
               .WhereIF(predicate != null, predicate)
               .Select(p => new Puhuo
               {
                   tiaozhengnums = SqlFunc.AggregateCount(p.id),
                   nums = SqlFunc.AggregateSum(p.nums),
                   amount = SqlFunc.AggregateSum(p.amount),
               })
                 .First(); // 或者使用 Single/FirstOrDefault 等方法获取结果
              //.Select(p => new Puhuo
              //{
              //    tiaozhengnums = SqlFunc.AggregateCount(p.id),
              //    nums = SqlFunc.AggregateSum(p.nums),
              //    amount = SqlFunc.AggregateSum(p.amount),
            //});
            otherData.heji4 = pagetotal.nums;
            otherData.heji5 = pagetotal.amount;
            otherData.heji6 = pagetotal.tiaozhengnums;
            var list = new PageList<Puhuo>(page, pageIndex, pageSize, totalCount);
            return list;
        }