移动系统liao
2024-07-30 35a617123c0d578772d9f4450bf27d3b52277384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/***********************************************************************
 *            Project: baifenBinfa
 *        ProjectName: 百分兵法管理系统                               
 *                Web: http://chuanyin.com                     
 *             Author:                                        
 *              Email:                               
 *         CreateTime: 202403/02   
 *        Description: 暂无
 ***********************************************************************/
 
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.Model.Entities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SqlSugar;
 
namespace CoreCms.Net.Repository
{
    /// <summary>
    /// 订单明细表 接口实现
    /// </summary>
    public class CoreCmsOrderItemRepository : BaseRepository<CoreCmsOrderItem>, ICoreCmsOrderItemRepository
    {
        public CoreCmsOrderItemRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
        {
            
        }
 
        #region 算订单的商品退了多少个(未发货的退货数量,已发货的退货不算)
 
        /// <summary>
        /// 算订单的商品退了多少个(未发货的退货数量,已发货的退货不算)
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="sn"></param>
        /// <returns></returns>
        public int GetaftersalesNums(string orderId, string sn)
        {
            var sum = DbClient.Queryable<CoreCmsBillAftersalesItem, CoreCmsBillAftersales>((item, parent) =>
                    new object[]
                    {
                        JoinType.Inner, item.aftersalesId == parent.aftersalesId
                    }).Where((item, parent) => parent.orderId == orderId)
                .Where((item, parent) => parent.status == (int)GlobalEnumVars.OrderStatus.Complete)
                .Where((item, parent) => item.sn == sn)
                .Where((item, parent) => parent.type == (int)GlobalEnumVars.BillAftersalesStatus.WaitAudit)
                .Sum((item, parent) => item.nums);
            return sum;
        }
        #endregion
    }
}