/// <summary> /// 获取分销商信息 /// </summary> /// <param name="distributorUserRelationDTO"></param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.DistributorInfoDTO GetDistributorInfo(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorUserRelationDTO distributorUserRelationDTO) { base.Do(false); Stopwatch timer = new Stopwatch(); timer.Start(); var result = this.GetDistributorInfoExt(distributorUserRelationDTO); timer.Stop(); LogHelper.Debug(string.Format("DistributorSV.GetDistributorInfo:耗时:{0}。入参:distributorUserRelationDTO:{1},\r\n出参:{2}", timer.ElapsedMilliseconds, JsonHelper.JsonSerializer(distributorUserRelationDTO), JsonHelper.JsonSerializer(result))); return(result); }
/// <summary> /// 获取分销商信息 /// </summary> /// <param name="distributorUserRelationDTO"></param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.DistributorInfoDTO GetDistributorInfo(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorUserRelationDTO distributorUserRelationDTO) { //定义返回值 Jinher.AMP.BTP.Deploy.CustomDTO.DistributorInfoDTO result; try { //调用代理方法 result = base.Channel.GetDistributorInfo(distributorUserRelationDTO); } catch { //抛异常 throw; } finally { //关链接 ChannelClose(); } //返回结果 return(result); }
/// <summary> /// 保存分销商关系 /// </summary> /// <param name="distributor">分销用户关系</param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <System.Guid> SaveDistributorRelation(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorUserRelationDTO distributor) { base.Do(); Stopwatch timer = new Stopwatch(); timer.Start(); var result = this.SaveDistributorRelationExt(distributor); timer.Stop(); LogHelper.Debug(string.Format("DistributorSV.SaveDistributorRelation:耗时:{0}。入参:distributor:{1},\r\n出参:{2}", timer.ElapsedMilliseconds, JsonHelper.JsonSerializer(distributor), JsonHelper.JsonSerializer(result))); return(result); }
public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <System.Guid> SaveDistributorRelation(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorUserRelationDTO distributor) { //定义返回值 Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <System.Guid> result; try { //调用代理方法 result = base.Channel.SaveDistributorRelation(distributor); } catch { //抛异常 throw; } finally { //关链接 ChannelClose(); } //返回结果 return(result); }
/// <summary> /// 获取分销商信息 /// </summary> /// <param name="distributorUserRelationDTO"></param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.DistributorInfoDTO GetDistributorInfoExt(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorUserRelationDTO distributorUserRelationDTO) { if (distributorUserRelationDTO == null) { return(null); } if (distributorUserRelationDTO.UserId == Guid.Empty || distributorUserRelationDTO.EsAppId == Guid.Empty) { return(null); } var distributor = (from dis in Distributor.ObjectSet() where dis.UserId == distributorUserRelationDTO.UserId && dis.EsAppId == distributorUserRelationDTO.EsAppId select dis).FirstOrDefault(); if (distributor == null) { return(null); } Jinher.AMP.BTP.Deploy.CustomDTO.DistributorInfoDTO result = new DistributorInfoDTO() { Id = distributor.Id, UserName = distributor.UserName, UserCode = distributor.UserCode, SubTime = distributor.SubTime, ModifiedOn = distributor.ModifiedOn, EsAppId = distributor.EsAppId, ParentId = distributor.ParentId, Level = distributor.Level, Key = distributor.Key, UserId = distributor.UserId, UserSubTime = distributor.UserSubTime, PicturePath = distributor.PicturePath, }; return(result); }
/// <summary> /// 保存分销商关系 /// </summary> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Guid> SaveDistributorRelationExt(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorUserRelationDTO distribDto) { Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Guid> result = new Deploy.CustomDTO.ResultDTO <Guid>(); try { if (distribDto == null) { result.ResultCode = 1; result.Message = "参数错误,参数不能为空!"; return(result); } if (distribDto.UserId == Guid.Empty || distribDto.EsAppId == Guid.Empty) { result.ResultCode = 1; result.Message = "参数错误,参数不能为空!"; return(result); } if (!Jinher.AMP.BTP.TPS.BACBP.CheckAppDistribute(distribDto.EsAppId)) { result.ResultCode = 3; result.Message = "抱歉,暂不支持该功能"; return(result); } Distributor disParent = null; //DistributorId为空,当前用户将成为馆的直接分销商(一级分销商). if (distribDto.DistributorId == Guid.Empty) { disParent = new Distributor(); disParent.Id = Guid.Empty; disParent.Level = 0; disParent.Key = ""; } else { disParent = (from dis in Distributor.ObjectSet() where dis.Id == distribDto.DistributorId select dis).FirstOrDefault(); if (disParent == null) { result.ResultCode = 2; result.Message = "分销商信息未找到!"; return(result); } if (disParent.EsAppId != distribDto.EsAppId) { result.ResultCode = 4; result.Message = "请求错误,请检查后重试~"; return(result); } } Guid disQuery = (from dis in Distributor.ObjectSet() where dis.EsAppId == distribDto.EsAppId && dis.UserId == distribDto.UserId select dis.Id).FirstOrDefault(); if (disQuery != null && disQuery != Guid.Empty) { result.Data = disQuery; result.ResultCode = 0; result.Message = "用户已存在分销关系!"; return(result); } var uniDto = Jinher.AMP.BTP.TPS.CBCSV.GetUserNameAndCode(distribDto.UserId); ContextSession contextSession = ContextFactory.CurrentThreadContext; Distributor distributor = Distributor.CreateDistributor(); distributor.Id = Guid.NewGuid(); distributor.UserName = uniDto.Item1; distributor.UserCode = uniDto.Item2; distributor.SubTime = DateTime.Now; distributor.ModifiedOn = DateTime.Now; distributor.EsAppId = distribDto.EsAppId; distributor.ParentId = disParent.Id; distributor.Level = disParent.Level + 1; distributor.Key = (disParent.Key + "." + distributor.Id).Trim('.'); distributor.UserId = distribDto.UserId; distributor.UserSubTime = DateTime.Now; distributor.PicturePath = ""; distributor.EntityState = System.Data.EntityState.Added; contextSession.SaveObject(distributor); //DistributorProfits distributorProfits = new DistributorProfits(); //distributorProfits.Id = distributor.Id; //distributorProfits.UserName = distributor.UserName; //distributorProfits.UserCode = distributor.UserCode; //distributorProfits.SubTime = DateTime.Now; //distributorProfits.ModifiedOn = DateTime.Now; //distributorProfits.OrderAmount = 0; //distributorProfits.CommissionAmount = 0; //distributorProfits.CommmissionUnPay = 0; //distributorProfits.UnderlingCount = 0; //distributorProfits.SubUnderlingCount = 0; //distributorProfits.EntityState = System.Data.EntityState.Added; //contextSession.SaveObject(distributorProfits); contextSession.SaveChanges(); result.Data = distributor.Id; } catch (Exception ex) { string errMsg = string.Format("SaveDistributorRelationExt异常,异常信息:{0}", ex); LogHelper.Error(errMsg); } return(result); }