username@email.com
2024-02-29 4180d50f0be396bc787c98481beea68e228e6435
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: CoreCms
 *        ProjectName: 核心内容管理系统                                
 *                Web: https://www.corecms.net                      
 *             Author: 大灰灰                                          
 *              Email: jianweie@163.com                                
 *         CreateTime: 2021/1/31 21:45:10
 *        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
    }
}