Пример #1
0
        /// <summary>
        /// 获取站点详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ApiResult <GetWebsitOutput> > GetWebSite(string id)
        {
            GetWebsitOutput result  = null;
            var             webSite = await _siteFullRepository.GetAsync(id);

            if (webSite != null)
            {
                if (webSite.WebSite.IsDeleted)
                {
                    return(ApiResult.DataNotFound <GetWebsitOutput>());
                }
                result = WebSiteFull.MapTo <GetWebsitOutput>(webSite);
                if (!string.IsNullOrEmpty(webSite.WebSite.WebSiteMater))
                {
                    //获取关联的DefaultJFPrice和DefaultNotePrice
                    var price = _userScoreRepository.GetAll()
                                .Where(i => i.Id == result.WebSiteMater)
                                .Select(i => new
                    {
                        i.JfPrice,
                        i.NotePrice
                    }).FirstOrDefault();

                    //获取关联的provinceid
                    var province = _userSysSettingRepository.GetAll().Where(i => i.Id == result.WebSiteMater)
                                   .Select(i => new
                    {
                        i.Provinceid
                    }).FirstOrDefault();

                    //获取关联的Email和LoginName
                    var info = _userRepository.GetAll().Where(i => i.Id == result.WebSiteMater)
                               .Select(i => new
                    {
                        i.EmailAddress,
                        i.LoginName
                    }).FirstOrDefault();

                    //var (price, province, info) = await (defaultJFPriceAndDefaultNotePriceTask, provinceidTask,
                    //    emailAndloginnameTask);

                    result.DefaultJFPrice   = price?.JfPrice;
                    result.DefaultNotePrice = price?.NotePrice;
                    result.Provinceid       = province?.Provinceid ?? "0";
                    result.Email            = info?.EmailAddress;
                    result.loginname        = info?.LoginName;
                }
            }

            return(ApiResult.Success(result));
        }
Пример #2
0
        public virtual async Task <List <PriceResultOutput> > Handle(IndoorPriceAndSaveCommand request, CancellationToken cancellationToken)
        {
            // 获取报价结果
            var result = await _priceAppService.IndoorPriceBatch(request.IndoorPrice);

            if (result.IsSuccess)
            {
                // 获取用户分成配置
                var rateInfo = _settingRepository.GetAll().Where(i => i.Id == request.IndoorPrice.UserId).Select(i => new
                {
                    i.Rate,
                    i.RateType
                }).FirstOrDefault();
                if (rateInfo != null)
                {
                    // 处理返回报价信息,写分成
                    await UpdateAskPriceViolationInfo(request.IndoorPrice.CarNumber, request.IndoorPrice.BatchId, rateInfo.Rate, rateInfo.RateType, result.Data);

                    // 更新报价缓存的状态
                    if (!request.GlobalKey.IsNullOrWhiteSpace())
                    {
                        try
                        {
                            //等待3分钟
                            _mut.WaitOne(TimeSpan.FromMinutes(3));
                            var globalKey   = request.GlobalKey;
                            var cacheObject = await _cacheManager.GetCache(globalKey).GetOrDefaultAsync(globalKey);

                            if (cacheObject != null)
                            {
                                QuotePriceStation station = (QuotePriceStation)cacheObject;
                                station.CompleteCount = station.CompleteCount + 1;
                                await _cacheManager.GetCache(globalKey).SetAsync(globalKey, station);
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorFormat("Action:IndoorPriceAndSaveCommand-UpdateCacheObject,Request:{0},Exception{1}", request, ex);
                        }
                        finally
                        {
                            _mut.ReleaseMutex();
                        }
                    }
                }
                return(result.Data);
            }
            return(null);
        }