/// <summary>
        /// 删除多个自提点
        /// </summary>
        /// <param name="ids">自提点ID集合</param>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO DeleteSelfTakeStationsExt(System.Collections.Generic.List <System.Guid> ids)
        {
            if (ids == null || ids.Count < 1)
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "自提点实体不能为空"
                });
            }
            Guid cityOwnerId         = Guid.Empty;
            Guid appId               = Guid.Empty;
            int  selfTakeStationType = 0;

            try
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                var            models         = SelfTakeStation.ObjectSet().Where(s => ids.Contains(s.Id) && !s.IsDel).ToList();
                if (models != null && models.Count > 0)
                {
                    var first = models.FirstOrDefault();
                    cityOwnerId         = first.CityOwnerId;
                    appId               = first.AppId.HasValue ? first.AppId.Value : Guid.Empty;
                    selfTakeStationType = first.SelfTakeStationType;
                    //删除自提点
                    foreach (var item in models)
                    {
                        item.IsDel       = true;
                        item.EntityState = System.Data.EntityState.Modified;
                        contextSession.SaveObject(item);
                    }

                    var selfTakeStationManager = SelfTakeStationManager.ObjectSet().Where(s => ids.Contains(s.SelfTakeStationId) && !s.IsDel).ToList();
                    if (selfTakeStationManager != null && selfTakeStationManager.Count > 0)
                    {
                        //删除负责人
                        foreach (var manager in selfTakeStationManager)
                        {
                            manager.IsDel       = true;
                            manager.EntityState = System.Data.EntityState.Modified;
                            contextSession.SaveObject(manager);
                        }
                    }

                    //删除推广表信息
                    List <Guid> spreadCodeList = models.Select(t => t.SpreadCode).ToList();
                    var         spreadInfo     = SpreadInfo.ObjectSet().Where(s => spreadCodeList.Contains(s.SpreadCode) && s.IsDel != 1).ToList();
                    foreach (var item in spreadInfo)
                    {
                        item.IsDel       = 1;
                        item.EntityState = System.Data.EntityState.Modified;
                        contextSession.SaveObject(item);
                    }

                    contextSession.SaveObject(spreadInfo);
                }
                contextSession.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("删除自提点服务异常。ids:{0}", JsonHelper.JsonSerializer(ids)), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }

            //更新已建体验柜数量
            try
            {
                int count = 0;
                Jinher.AMP.ZPH.Deploy.CustomDTO.ProxyCabinetNumParam prarm = new ZPH.Deploy.CustomDTO.ProxyCabinetNumParam();
                prarm.ChangeOrg = cityOwnerId;
                prarm.BelongTo  = appId;

                if (selfTakeStationType == 0)
                {
                    //总数量
                    count = SelfTakeStation.ObjectSet().Where(t => t.CityOwnerId == cityOwnerId && t.SelfTakeStationType == selfTakeStationType && !t.IsDel).Count();
                    prarm.IsSelfPavilion = false;
                }
                else if (selfTakeStationType == 1)
                {
                    //总数量
                    count = SelfTakeStation.ObjectSet().Where(t => t.CityOwnerId == cityOwnerId && t.SelfTakeStationType == selfTakeStationType && t.AppId == appId && !t.IsDel).Count();
                    prarm.IsSelfPavilion = true;
                }
                prarm.CabinetNum = count;
                LogHelper.Debug(string.Format("删除自提点时更新已建体验柜数量。prarm:{0}", JsonHelper.JsonSerializer(prarm)));
                var resultProxy = Jinher.AMP.BTP.TPS.ZPHSV.Instance.UpdateProxyCabinetNum(prarm);
                if (!resultProxy.isSuccess)
                {
                    LogHelper.Error(string.Format("删除自提点成功,但更新已建体验柜数量服务失败。ids:{0}", JsonHelper.JsonSerializer(ids)));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("删除自提点时更新已建体验柜数量服务异常。ids:{0}", JsonHelper.JsonSerializer(ids)), ex);
            }

            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }
        /// <summary>
        /// 添加自提点
        /// </summary>
        /// <param name="selfTakeStationDTO">自提点实体(District、Remark字段暂时无用)</param>
        /// <returns>结果</returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveSelfTakeStationExt(Jinher.AMP.BTP.Deploy.CustomDTO.SelfTakeStationAndManagerDTO selfTakeStationDTO)
        {
            if (selfTakeStationDTO == null)
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "自提点实体不能为空"
                });
            }

            if (selfTakeStationDTO.CityOwnerId == Guid.Empty || string.IsNullOrWhiteSpace(selfTakeStationDTO.Name) || string.IsNullOrWhiteSpace(selfTakeStationDTO.Province) || string.IsNullOrWhiteSpace(selfTakeStationDTO.Address))
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "自提点参数错误"
                });
            }
            if (string.IsNullOrWhiteSpace(selfTakeStationDTO.City))
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "自提点参数错误"
                });
            }
            if (string.IsNullOrWhiteSpace(selfTakeStationDTO.QRCodeUrl) || selfTakeStationDTO.SpreadCode == Guid.Empty)
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "自提点参数错误"
                });
            }

            if (selfTakeStationDTO.SelfTakeStationType == 1 && (!selfTakeStationDTO.AppId.HasValue || selfTakeStationDTO.AppId == Guid.Empty))
            {
                return(new ResultDTO {
                    ResultCode = 1, Message = "自提点参数错误"
                });
            }

            //加入数量限制
            try
            {
                Jinher.AMP.ZPH.Deploy.CustomDTO.ProxyCabinetParam prarm = new ZPH.Deploy.CustomDTO.ProxyCabinetParam();
                prarm.ChangeOrg = selfTakeStationDTO.CityOwnerId;
                prarm.BelongTo  = selfTakeStationDTO.AppId.HasValue ? selfTakeStationDTO.AppId.Value : Guid.Empty;

                if (selfTakeStationDTO.SelfTakeStationType == 0)
                {
                    prarm.IsSelfPavilion = false;
                }
                else if (selfTakeStationDTO.SelfTakeStationType == 1)
                {
                    prarm.IsSelfPavilion = true;
                }
                LogHelper.Debug(string.Format("核查代理能否创建体验柜。prarm:{0}", JsonHelper.JsonSerializer(prarm)));
                var resultProxy = Jinher.AMP.BTP.TPS.ZPHSV.Instance.ChecksCanBeCreated(prarm);
                if (!resultProxy.isSuccess)
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "已超过最大数量限制"
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("核查代理能否创建体验柜服务异常。selfTakeStationDTO:{0}", JsonHelper.JsonSerializer(selfTakeStationDTO)), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "核查代理能否创建体验柜服务异常"
                });
            }

            if (selfTakeStationDTO.selfTakeStationManager != null && selfTakeStationDTO.selfTakeStationManager.Any())
            {
                selfTakeStationDTO.selfTakeStationManager.RemoveAll(
                    checkItem =>
                    checkItem == null || checkItem.UserId == Guid.Empty || string.IsNullOrWhiteSpace(checkItem.UserCode));

                var selfManagerId = selfTakeStationDTO.selfTakeStationManager.Select(t => t.UserId).ToList();
                int count         = SelfTakeStationManager.ObjectSet().Count(t => selfManagerId.Contains(t.UserId) && !t.IsDel);

                if (count > 0)
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "负责人已存在"
                    });
                }
            }
            try
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                Guid            selfTakeStationId = Guid.NewGuid();
                SelfTakeStation selfTakeStation   = new SelfTakeStation()
                {
                    Id                  = selfTakeStationId,
                    CityOwnerId         = selfTakeStationDTO.CityOwnerId,
                    Name                = selfTakeStationDTO.Name,
                    Province            = selfTakeStationDTO.Province,
                    City                = selfTakeStationDTO.City,
                    District            = "",
                    Address             = selfTakeStationDTO.Address,
                    SpreadUrl           = selfTakeStationDTO.SpreadUrl,
                    Remark              = "",
                    QRCodeUrl           = selfTakeStationDTO.QRCodeUrl,
                    SpreadCode          = selfTakeStationDTO.SpreadCode,
                    SelfTakeStationType = selfTakeStationDTO.SelfTakeStationType,
                    AppId               = selfTakeStationDTO.AppId
                };

                selfTakeStation.EntityState = System.Data.EntityState.Added;
                contextSession.SaveObject(selfTakeStation);

                if (selfTakeStationDTO.selfTakeStationManager != null && selfTakeStationDTO.selfTakeStationManager.Count > 0)
                {
                    foreach (var selfManager in selfTakeStationDTO.selfTakeStationManager)
                    {
                        SelfTakeStationManager selfTakeStationManager = new SelfTakeStationManager()
                        {
                            Id                = Guid.NewGuid(),
                            UserCode          = selfManager.UserCode,
                            UserId            = selfManager.UserId,
                            SelfTakeStationId = selfTakeStationId
                        };
                        selfTakeStationManager.EntityState = System.Data.EntityState.Added;
                        contextSession.SaveObject(selfTakeStationManager);
                    }
                }

                //添加到SpreadInfo
                SpreadInfoDTO spreadInfo = new SpreadInfoDTO();
                spreadInfo.Id         = Guid.NewGuid();
                spreadInfo.SpreadId   = selfTakeStationDTO.CityOwnerId;
                spreadInfo.SpreadUrl  = selfTakeStationDTO.SpreadUrl;
                spreadInfo.SpreadCode = selfTakeStationDTO.SpreadCode;
                //spreadInfo.SpreadDesc
                //SpreadType 推广类型 0:推广主,1:电商馆,2:总代,3企业
                if (selfTakeStationDTO.SelfTakeStationType == 0)
                {
                    spreadInfo.SpreadType = 2;
                }
                else if (selfTakeStationDTO.SelfTakeStationType == 1)
                {
                    spreadInfo.SpreadType = 1;
                }
                spreadInfo.IsDel = 0;
                spreadInfo.AppId = selfTakeStationDTO.AppId.HasValue ? selfTakeStationDTO.AppId.Value : Guid.Empty;

                SpreadSV.Instance.BuildSaveSpreadInfo(spreadInfo);

                contextSession.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加自提点服务异常。selfTakeStationDTO:{0}", JsonHelper.JsonSerializer(selfTakeStationDTO)), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }

            //更新已建体验柜数量
            try
            {
                int count = 0;

                Jinher.AMP.ZPH.Deploy.CustomDTO.ProxyCabinetNumParam prarm = new ZPH.Deploy.CustomDTO.ProxyCabinetNumParam();
                prarm.ChangeOrg = selfTakeStationDTO.CityOwnerId;
                prarm.BelongTo  = selfTakeStationDTO.AppId.HasValue ? selfTakeStationDTO.AppId.Value : Guid.Empty;
                if (selfTakeStationDTO.SelfTakeStationType == 0)
                {
                    //总数量
                    count = SelfTakeStation.ObjectSet().Where(t => t.CityOwnerId == selfTakeStationDTO.CityOwnerId && t.SelfTakeStationType == selfTakeStationDTO.SelfTakeStationType && !t.IsDel).Count();
                    prarm.IsSelfPavilion = false;
                }
                else if (selfTakeStationDTO.SelfTakeStationType == 1)
                {
                    //总数量
                    count = SelfTakeStation.ObjectSet().Where(t => t.CityOwnerId == selfTakeStationDTO.CityOwnerId && t.SelfTakeStationType == selfTakeStationDTO.SelfTakeStationType && t.AppId == selfTakeStationDTO.AppId && !t.IsDel).Count();
                    prarm.IsSelfPavilion = true;
                }
                prarm.CabinetNum = count;
                LogHelper.Debug(string.Format("添加自提点时更新已建体验柜数量。prarm:{0}", JsonHelper.JsonSerializer(prarm)));
                var resultProxy = Jinher.AMP.BTP.TPS.ZPHSV.Instance.UpdateProxyCabinetNum(prarm);
                if (!resultProxy.isSuccess)
                {
                    LogHelper.Error(string.Format("添加自提点时更新已建体验柜数量服务失败。selfTakeStationDTO:{0}", JsonHelper.JsonSerializer(selfTakeStationDTO)));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加自提点时更新已建体验柜数量服务异常。selfTakeStationDTO:{0}", JsonHelper.JsonSerializer(selfTakeStationDTO)), ex);
            }

            return(new ResultDTO {
                ResultCode = 0, Message = "Success"
            });
        }