Ejemplo n.º 1
0
        /// <summary>
        /// 根据活动ID获取银行活动配置
        /// </summary>
        /// <param name="activityId">活动ID</param>
        /// <returns></returns>
        public BankMRActivityConfig GetBankMRActivityConfigByActivityId(Guid activityId)
        {
            BankMRActivityConfig result = null;

            try
            {
                result = TuhuGrouponDbScopeManagerReadOnly.Execute(conn => BankMRActivityDal.SelectBankMRActivityConfigByActivityId(conn, activityId));
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
            };

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据银行美容记录查询服务码详情
        /// </summary>
        /// <param name="records"></param>
        /// <returns></returns>
        public static async Task <IEnumerable <ServiceCodeDetail> > SearchBankMRActivityCodeDetailByRecords(IEnumerable <BankMRActivityCodeRecord> records)
        {
            var result = new List <ServiceCodeDetail>();

            if (records != null)
            {
                records = records.Where(s => !string.IsNullOrEmpty(s.ServiceCode));
                var roundIds = records.Select(t => t.ActivityRoundId).Distinct();
                var rounds   = new List <BankMRActivityRoundConfig>();
                foreach (var item in roundIds)
                {
                    var round = GetBankMRActivityRoundConfigByPKID(item);
                    if (round != null)
                    {
                        rounds.Add(round);
                    }
                }
                var activityIds = rounds.Select(t => t.ActivityId).Distinct();
                var activitys   = new List <BankMRActivityConfig>();
                foreach (var item in activityIds)
                {
                    var activity = TuhuGrouponDbScopeManagerReadOnly.Execute(conn => BankMRActivityDal.SelectBankMRActivityConfigByActivityId(conn, item));
                    activitys.Add(activity);
                }
                var serviceCodes       = records.Select(t => t.ServiceCode).Distinct();
                var serviceCodeDetails = await SearchCodeManager.GetServiceCodeDetailsByCodes(serviceCodes);

                var companyUsers = new List <SYS_CompanyUser>();
                var bankIds      = activitys.Select(t => t.BankId).Distinct();
                using (var client = new UserAccountClient())
                {
                    foreach (var item in bankIds)
                    {
                        var serviceResult = await client.SelectCompanyUserInfoAsync(item);

                        serviceResult.ThrowIfException(true);
                        var company = serviceResult.Result;
                        if (company != null)
                        {
                            companyUsers.Add(company);
                        }
                    }
                }
                var products = new List <BeautyProductModel>();
                foreach (var pid in activitys.Select(t => t.ServiceId).Distinct())
                {
                    var product = BeautyProductManager.GetBeautyProductByPid(pid);
                    if (product != null)
                    {
                        products.Add(product);
                    }
                }
                foreach (var re in records)
                {
                    var activityId = (rounds.FirstOrDefault(s => s.PKID == re.ActivityRoundId))?.ActivityId;
                    if (activityId != null)
                    {
                        var activity = activitys.FirstOrDefault(s => s.ActivityId == activityId);
                        if (activity != null && serviceCodeDetails != null)
                        {
                            var serviceCodeDetail = serviceCodeDetails.FirstOrDefault(s => string.Equals(s.Code, re.ServiceCode));
                            var product           = products.First(p => string.Equals(p.PID, activity.ServiceId));
                            if (serviceCodeDetail != null)
                            {
                                result.Add(
                                    new ServiceCodeDetail()
                                {
                                    //PackageDetailCodeId = packageDetailCode.PKID,
                                    ServiceCode        = re.ServiceCode,
                                    Status             = serviceCodeDetail?.Status.ToString(),
                                    VipCompanyName     = companyUsers.FirstOrDefault(t => t.UserId == activity.BankId)?.UserName,
                                    VerifyTime         = serviceCodeDetail?.VerifyTime,
                                    StartTime          = re.CreateTime,
                                    EndTime            = Convert.ToDateTime(serviceCodeDetail.OverdueTime),
                                    VipSettleMentPrice = activity.BankSettlementPrice,
                                    ShopCommission     = 0,
                                    PID             = activity.ServiceId,
                                    RestrictVehicle = BeautyProductManager.GetVehicleTypeDescription(product.RestrictVehicleType),
                                    Mobile          = re.Mobile,
                                    OrderNo         = !string.IsNullOrEmpty(serviceCodeDetail?.TuhuOrderId.ToString()) ? $"TH{serviceCodeDetail?.TuhuOrderId}" : null,
                                    VerifyShop      = serviceCodeDetail?.InstallShopId.ToString()
                                });
                            }
                        }
                    }
                }
            }
            return(result);
        }