Ejemplo n.º 1
0
        /// <summary>
        /// 获取学生正常的订单
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-09</para>
        /// </summary>
        /// <returns>报名订单集合</returns>
        private List <TblOdrEnrollOrder> GetStudentOrders()
        {
            EnrollOrderService enrollOrderService = new EnrollOrderService(_schoolId);

            List <TblOdrEnrollOrder> studentAllOrders = enrollOrderService.GetStudentOrders(_studentId).Result;

            int paid   = (int)OrderStatus.Paid;
            int finish = (int)OrderStatus.Finish;

            List <TblOdrEnrollOrder> studentNormalOrders =
                studentAllOrders.Where(x => x.OrderStatus == paid || x.OrderStatus == finish).ToList();

            return(studentNormalOrders);
        }
        /// <summary>
        /// 描述:预览生成优惠数据(满减金额+转介绍)
        /// <para>作    者:瞿琦</para>
        /// <para>创建时间:2018-11-2</para>
        /// </summary>
        /// <param name="studentId">学生Id</param>
        /// <returns>优惠信息集合</returns>

        public async Task <List <CouponGenerateResponse> > Peek(long studentId)
        {
            var result = new List <CouponGenerateResponse>();

            //1.满减信息
            var resultFullReduce = new CouponGenerateResponse();
            //获取赠与奖学金金额
            var query = (await _tblDctCouponRuleRepository.Value.GetAmountByCouponRule(_schoolId, _totalAmount)).FirstOrDefault();

            resultFullReduce.CouponRuleId     = query?.CouponRuleId ?? 0;
            resultFullReduce.CouponRuleAmount = query?.CouponAmount ?? 0;
            resultFullReduce.CouponType       = CouponType.FullReduce;
            result.Add(resultFullReduce);

            //2.转介绍信息
            //获取学生是否有转介绍Id
            var studentService = new StudentService(_schoolId);
            var studenInfo     = studentService.GetStudent(studentId);
            //获取学生是否有报名信息
            var enrollOrderService = new EnrollOrderService(_schoolId);
            var studentOrder       = enrollOrderService.GetStudentOrders(studentId).Result;

            if (!studentOrder.Any()) //没有报过名,并且有转介绍人 才返回转介绍信息
            {
                if (studenInfo.ParentId <= 0)
                {
                    return(result);
                }

                var couponRuleService = new CouponRuleService(_schoolId);
                var couponRuleResult  = couponRuleService.GetTblDctCouponRuleInfo();

                var resultRecommend = new CouponGenerateResponse
                {
                    CouponRuleId     = couponRuleResult?.CouponRuleId ?? 0,
                    CouponRuleAmount = couponRuleResult?.CouponAmount ?? 0,
                    CouponType       = CouponType.Recommend
                };
                result.Add(resultRecommend);
            }
            return(result);
        }