Example #1
0
        private StoreSDTO MongoToDto3(StoreMgDTO entity, decimal lat, decimal lon)
        {
            StoreSDTO store = MongoToDto(entity);

            store.Distance = (decimal)DistanceHelper.GetGreatCircleDistance((double)lat, (double)lon, entity.Location[1], entity.Location[0]);
            return(store);
        }
Example #2
0
        private StoreSDTO MongoToDto2(GeoNearResult <StoreMgDTO> .GeoNearHit storeMgHit)
        {
            StoreSDTO store = MongoToDto(storeMgHit.Document);

            store.Distance = (decimal)storeMgHit.Distance * 100000;
            return(store);
        }
Example #3
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.StoreSDTO> GetOnlyStoreInAppExt(System.Guid appId)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.StoreSDTO> storeResult = new ResultDTO <StoreSDTO>();

            try
            {
                if (appId == Guid.Empty)
                {
                    storeResult.Message    = "参数错误,appId不能为空!";
                    storeResult.ResultCode = 1;
                    return(storeResult);
                }

                var q = Query <StoreMgDTO> .Where(c => c.AppId == appId);

                long len = MongoCollections.Store.Count(q);
                if (len > 1)
                {
                    storeResult.Message    = "有多个门店";
                    storeResult.ResultCode = 2;
                }
                else if (len == 1)
                {
                    StoreMgDTO smgDto = MongoCollections.Store.FindOneAs <StoreMgDTO>(q);
                    if (smgDto != null)
                    {
                        StoreSDTO ssDto = MongoToDto(smgDto);
                        storeResult.Data = ssDto;
                    }
                    storeResult.Message    = "只有一个门店";
                    storeResult.ResultCode = 3;
                }
                return(storeResult);
            }
            catch (Exception ex)
            {
                LogHelper.Error("GetOnlyStoreInAppExt异常,异常信息:", ex);
            }
            return(storeResult);
        }
Example #4
0
        /// <summary>
        /// 将mongodb返回的结果转为StoreSDTO
        /// </summary>
        /// <param name="storeMg">mongo store dto</param>
        /// <returns></returns>
        private StoreSDTO MongoToDto(StoreMgDTO storeMg)
        {
            StoreSDTO storeDto = new StoreSDTO();

            storeDto.FillWith(storeMg);
            storeDto.StoreName = storeMg.Name;
            storeDto.PicPath   = storeMg.picture;
            storeDto.Phone     = new List <PhoneSDTO>();
            string[] phones = storeMg.Phone.Split(";;,,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string p in phones)
            {
                storeDto.Phone.Add(new PhoneSDTO()
                {
                    PhoneNumber = p
                });
            }
            try
            {
                storeDto.XAxis = (decimal)storeMg.Location[0];
                storeDto.YAxis = (decimal)storeMg.Location[1];
            }
            catch { }
            return(storeDto);
        }