コード例 #1
0
		public bool Delete(PartnerListEntity entity)
		{
			try
            {
                _partnerlistRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
コード例 #2
0
		public PartnerListEntity Update (PartnerListEntity entity)
		{
			try
            {
                _partnerlistRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
コード例 #3
0
        public HttpResponseMessage AddPartnerList([FromBody] PartnerListEntity partnerList)
        {
            var sech = new BrokerSearchCondition
            {
                Phone = partnerList.Phone,
                State=1
            };
            var user = (UserBase)_workContext.CurrentUser;
            if (user != null)
            {
                var broker = _brokerService.GetBrokerByUserId(user.Id);//获取当前用户
                if (broker != null)
                {
                    var getbroker = _brokerService.GetBrokersByCondition(sech).FirstOrDefault();//通过手机号查询经纪人
                    if (getbroker != null)
                    {
                        //判断是否是本身
                        if (broker.Id == getbroker.Id)
                        {
                            return PageHelper.toJson(PageHelper.ReturnValue(false, "对不起,不能添加本身"));
                        }
                        //判断要添加的这个经纪人是否有上家
                        if (getbroker.PartnersId == null || getbroker.PartnersId == 0)//查询他的上家是否存在
                        {
                            //1 添加到partnerList表中  

                            var entity = new PartnerListEntity();
                            entity.PartnerId = getbroker.Id;     //添加的下家
                            entity.Brokername = getbroker.Brokername;
                            entity.Phone = getbroker.Phone;
                            entity.Agentlevel = getbroker.Level.Name;
                            entity.Regtime = getbroker.Regtime;

                            entity.Adduser = broker.Id;
                            entity.Addtime = DateTime.Now;
                            entity.Upuser = broker.Id;
                            entity.Uptime = DateTime.Now;
                            entity.Broker = broker;
                            entity.Status = EnumPartnerType.默认;
                            //判断当前用户的合伙人个数是否》=3

                            PartnerListSearchCondition plsearCon = new PartnerListSearchCondition
                            {
                                Brokers = broker,
                                Status = EnumPartnerType.同意
                            };
                            if (_partnerlistService.GetPartnerListCount(plsearCon) >= 3)
                            {
                                return PageHelper.toJson(PageHelper.ReturnValue(true, "对不起,您的合伙人数已满 不能添加"));
                            }

                            if (_partnerlistService.Create(entity) != null)
                            {

                                return PageHelper.toJson(PageHelper.ReturnValue(true, "邀请成功!等待对方同意"));

                            }
                            else
                            {
                                return PageHelper.toJson(PageHelper.ReturnValue(true, "数据更新失败!请与客服联系"));
                            }


                        }
                        else
                        {
                            return PageHelper.toJson(PageHelper.ReturnValue(false, "该用户已经是别人的合伙人了!"));

                        }


                    }
                    else
                    {
                        return PageHelper.toJson(PageHelper.ReturnValue(false, "该经纪人不存在"));
                    }
                }
            }
            return PageHelper.toJson(PageHelper.ReturnValue(false, "对不起,请登录"));






            //var list = _brokerService.GetBrokersByCondition(sech).FirstOrDefault();//通过手机号查询经纪人
            //if (list != null)
            //{
            //    if (list.PartnersId != 0)//查询他的上家是否存在
            //    {
            //        if (partnerList != null)
            //        {
            //            var entity = new PartnerListEntity();
            //            entity.PartnerId = list.Id;     //添加的下家
            //            entity.Phone = partnerList.Phone;

            //            if (list.Id == _brokerService.GetBrokerByUserId(_workContext.CurrentUser.Id).Id)
            //            {
            //                return PageHelper.toJson(PageHelper.ReturnValue(false, "不能添加自身!"));
            //            }

            //            //上家的属性
            //                 entity.Agentlevel = _brokerService.GetBrokerByUserId(_workContext.CurrentUser.Id).Level.Name;
            //                 entity.Brokername = _brokerService.GetBrokerByUserId(_workContext.CurrentUser.Id).Brokername;

            //                 entity.Regtime = DateTime.Now;
            //                 entity.Broker = _brokerService.GetBrokerByUserId(_workContext.CurrentUser.Id);

            //                 entity.Upuser = _brokerService.GetBrokerByUserId(_workContext.CurrentUser.Id).Id;
            //                 entity.Uptime = DateTime.Now;
            //                 entity.Adduser = _brokerService.GetBrokerByUserId(_workContext.CurrentUser.Id).Id;
            //                 entity.Addtime = DateTime.Now;
            //                 entity.Status = EnumPartnerType.默认;

            //            try
            //            {
            //                if (_partnerlistService.Create(entity) != null)
            //                {
            //                    return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!等待对方同意"));
            //                }
            //            }
            //            catch
            //            {
            //                return PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!"));
            //            }
            //        }
            //        return PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!"));
            //    }
            //    return PageHelper.toJson(PageHelper.ReturnValue(false, "该用户已经是别人的合伙人了!"));
            //}
            //return PageHelper.toJson(PageHelper.ReturnValue(false, "该用户不存在"));


        }