Example #1
0
        /// <summary>
        /// 绑定关系
        /// </summary>
        /// <param name="userSpreaderBindDTO">参数只传SpreadCode、UserID</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveUserSpreaderCode(Jinher.AMP.BTP.Deploy.CustomDTO.UserSpreaderBindDTO userSpreaderBindDTO)
        {
            //定义返回值
            Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO result;

            try
            {
                //调用代理方法
                result = base.Channel.SaveUserSpreaderCode(userSpreaderBindDTO);
            }
            catch
            {
                //抛异常
                throw;
            }
            finally
            {
                //关链接
                ChannelClose();
            }            //返回结果
            return(result);
        }
Example #2
0
 /// <summary>
 /// 绑定关系
 /// </summary>
 /// <param name="userSpreaderBindDTO">参数只传SpreadCode、UserID</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveUserSpreaderCode(Jinher.AMP.BTP.Deploy.CustomDTO.UserSpreaderBindDTO userSpreaderBindDTO)
 {
     base.Do(false);
     LogHelper.Debug(string.Format("绑定关系:UserSpreaderSV.SaveUserSpreaderCode, userSpreaderBindDTO:{0}", JsonHelper.JsonSerializer(userSpreaderBindDTO)));
     return(this.SaveUserSpreaderCodeExt(userSpreaderBindDTO));
 }
Example #3
0
 /// <summary>
 /// 绑定关系
 /// </summary>
 /// <param name="userSpreaderBindDTO">参数只传SpreadCode、UserID</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveUserSpreaderCode(Jinher.AMP.BTP.Deploy.CustomDTO.UserSpreaderBindDTO userSpreaderBindDTO)
 {
     base.Do();
     return(this.Command.SaveUserSpreaderCode(userSpreaderBindDTO));
 }
Example #4
0
        /// <summary>
        /// 绑定关系
        /// </summary>
        /// <param name="userSpreaderBindDTO">参数只传SpreadCode、UserID</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveUserSpreaderCodeExt(Jinher.AMP.BTP.Deploy.CustomDTO.UserSpreaderBindDTO userSpreaderBindDTO)
        {
            ResultDTO result = new ResultDTO();

            if (userSpreaderBindDTO == null)
            {
                result.ResultCode = 1;
                result.Message    = "参数错误,参数不能为空!";
                return(result);
            }
            if (userSpreaderBindDTO.SpreadCode == Guid.Empty)
            {
                result.ResultCode = 2;
                result.Message    = "参数错误,推广码不能为空!";
                return(result);
            }

            if (userSpreaderBindDTO.UserId == Guid.Empty)
            {
                result.ResultCode = 2;
                result.Message    = "参数错误,买家ID不能为空!";
                return(result);
            }

            try
            {
                //一个买家只能属于一个推广主。
                var usCount = (from us in UserSpreader.ObjectSet()
                               where us.UserId == userSpreaderBindDTO.UserId
                               select us).Count();
                if (usCount > 0)
                {
                    result.ResultCode = 0;
                    result.Message    = "已存在当前买家和推广主信息!";
                    return(result);
                }

                var spreadInfo = SpreadInfo.ObjectSet().FirstOrDefault(t => t.SpreadCode == userSpreaderBindDTO.SpreadCode && t.IsDel == 0);
                if (spreadInfo == null)
                {
                    result.ResultCode = 3;
                    result.Message    = "没有此推广码的信息!";
                    return(result);
                }

                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                UserSpreader uSpreaderNew = new UserSpreader();
                uSpreaderNew.Id            = Guid.NewGuid();
                uSpreaderNew.UserId        = userSpreaderBindDTO.UserId;
                uSpreaderNew.SpreaderId    = spreadInfo.SpreadId;
                uSpreaderNew.SpreadCode    = userSpreaderBindDTO.SpreadCode;
                uSpreaderNew.IsDel         = false;
                uSpreaderNew.CreateOrderId = new Guid("00000000-0000-0000-0000-000000000000");
                uSpreaderNew.SubTime       = DateTime.Now;
                uSpreaderNew.ModifiedOn    = DateTime.Now;
                uSpreaderNew.WxOpenId      = "";

                uSpreaderNew.EntityState = System.Data.EntityState.Added;
                contextSession.SaveObject(uSpreaderNew);
                contextSession.SaveChanges();

                result.ResultCode = 0;
                result.Message    = "成功!";
                return(result);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("UserSpreaderSVExt异常。userSpreaderBindDTO:{0}", JsonHelper.JsonSerializer(userSpreaderBindDTO)), ex);
                result.ResultCode = 4;
                result.Message    = "接口异常,请稍后重试!";
                return(result);
            }
        }