public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateOrderSpreader(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
        {
            //定义返回值
            Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO result;

            try
            {
                //调用代理方法
                result = base.Channel.UpdateOrderSpreader(sbwxDto);
            }
            catch
            {
                //抛异常
                throw;
            }
            finally
            {
                //关链接
                ChannelClose();
            }            //返回结果
            return(result);
        }
Exemple #2
0
 /// <summary>
 /// 更新订单推广者信息。
 /// <para>Service Url: http://devbtp.iuoooo.com/Jinher.AMP.BTP.SV.UserSpreaderSV.svc/UpdateOrderSpreader
 /// </para>
 /// </summary>
 /// <param name="sbwxDto">参数只传WxOpenId、BuyerId、OrderId</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateOrderSpreader(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
 {
     base.Do();
     return(this.Command.UpdateOrderSpreader(sbwxDto));
 }
Exemple #3
0
 /// <summary>
 /// 保存买家微信和推广者(推广码)之间的关系。
 /// <para>Service Url: http://devbtp.iuoooo.com/Jinher.AMP.BTP.SV.UserSpreaderSV.svc/SaveSpreaderAndBuyerWxRel
 /// </para>
 /// </summary>
 /// <param name="sbwxDto">参数只传SpreadCode、WxOpenId</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveSpreaderAndBuyerWxRel(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
 {
     base.Do();
     return(this.Command.SaveSpreaderAndBuyerWxRel(sbwxDto));
 }
Exemple #4
0
 /// <summary>
 /// 更新订单推广者信息。
 /// <para>Service Url: http://devbtp.iuoooo.com/Jinher.AMP.BTP.SV.UserSpreaderSV.svc/UpdateOrderSpreader
 /// </para>
 /// </summary>
 /// <param name="sbwxDto">参数只传WxOpenId、BuyerId、OrderId</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateOrderSpreader(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
 {
     base.Do();
     LogHelper.Info(string.Format("更新订单推广者信息。UserSpreaderSV.UpdateOrderSpreaderExt, sbwxDto:{0}", JsonHelper.JsonSerializer(sbwxDto)));
     return(this.UpdateOrderSpreaderExt(sbwxDto));
 }
Exemple #5
0
 /// <summary>
 /// 保存买家微信和推广者(推广码)之间的关系。
 /// <para>Service Url: http://devbtp.iuoooo.com/Jinher.AMP.BTP.SV.UserSpreaderSV.svc/SaveSpreaderAndBuyerWxRel
 /// </para>
 /// </summary>
 /// <param name="sbwxDto">参数只传SpreadCode、WxOpenId</param>
 /// <returns></returns>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveSpreaderAndBuyerWxRel(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
 {
     base.Do(false);
     LogHelper.Info(string.Format("保存买家微信和推广者(推广码)之间的关系。UserSpreaderSV.SaveSpreaderAndBuyerWxRel, sbwxDto:{0}", JsonHelper.JsonSerializer(sbwxDto)));
     return(this.SaveSpreaderAndBuyerWxRelExt(sbwxDto));
 }
Exemple #6
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveSpreaderAndBuyerWxRelExt(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
        {
            ResultDTO result = new ResultDTO();

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

            if (string.IsNullOrWhiteSpace(sbwxDto.WxOpenId))
            {
                result.ResultCode = 2;
                result.Message    = "参数错误,微信OpenId不能为空!";
                return(result);
            }

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

                Guid spreaderId = Guid.Empty;
                //TODO 构造 bac不过。。。
                //try
                //{
                //    SpreadInfoFacade spreadFacade = new SpreadInfoFacade();
                //    spreaderId = spreadFacade.GetSpreadIdByid(sbwxDto.SpreadCode);
                //}
                //catch (Exception ex)
                //{
                //    LogHelper.Error(string.Format("UserSpreaderSVExt中调用Jinher.AMP.BAC.IBP.Facade.GetSpreadIdByid接口异常。id:{0}", sbwxDto.SpreadCode), ex);

                //    result.ResultCode = 3;
                //    result.Message = "接口异常,请稍后重试!";
                //    return result;
                //}



                UserSpreader uSpreaderNew = new UserSpreader();
                uSpreaderNew.Id            = Guid.NewGuid();
                uSpreaderNew.UserId        = new Guid("00000000-0000-0000-0000-000000000000");
                uSpreaderNew.SpreaderId    = spreaderId;
                uSpreaderNew.SpreadCode    = sbwxDto.SpreadCode;
                uSpreaderNew.IsDel         = false;
                uSpreaderNew.CreateOrderId = new Guid("00000000-0000-0000-0000-000000000000");
                uSpreaderNew.SubTime       = DateTime.Now;
                uSpreaderNew.ModifiedOn    = DateTime.Now;
                uSpreaderNew.WxOpenId      = sbwxDto.WxOpenId;
                uSpreaderNew.EntityState   = System.Data.EntityState.Added;

                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                contextSession.SaveObject(uSpreaderNew);
                contextSession.SaveChanges();

                result.ResultCode = 0;
                result.Message    = "成功!";
                return(result);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("UserSpreaderSVExt异常。sbwxDto:{0}", JsonHelper.JsonSerializer(sbwxDto)), ex);
                result.ResultCode = 4;
                result.Message    = "接口异常,请稍后重试!";
                return(result);
            }
        }
Exemple #7
0
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateOrderSpreaderExt(Jinher.AMP.BTP.Deploy.CustomDTO.SpreaderAndBuyerWxDTO sbwxDto)
        {
            ResultDTO result = new ResultDTO();

            if (sbwxDto == null)
            {
                result.ResultCode = 1;
                result.Message    = "参数错误,参数不能为空!";
                return(result);
            }
            if (string.IsNullOrWhiteSpace(sbwxDto.WxOpenId))
            {
                result.ResultCode = 2;
                result.Message    = "参数错误,微信OpenId不能为空!";
                return(result);
            }

            if (sbwxDto.BuyerId == Guid.Empty)
            {
                result.ResultCode = 3;
                result.Message    = "参数错误,买家用户Id不能为空!";
                return(result);
            }

            if (sbwxDto.OrderId == Guid.Empty)
            {
                result.ResultCode = 4;
                result.Message    = "参数错误,订单Id不能为空!";
                return(result);
            }

            try
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                //用户id相关 买家-推广者对照表。
                var usQuery = from us in UserSpreader.ObjectSet()
                              where us.UserId == sbwxDto.BuyerId
                              select us;

                //微信Id相关 买家-推广者对照表。
                var wxQuery = from u in UserSpreader.ObjectSet()
                              where u.WxOpenId == sbwxDto.WxOpenId
                              select u;
                //推广者用户id.
                Guid spreaderId = Guid.Empty;
                Guid spreadCode = Guid.Empty;
                //当前买家已有归属的推广主信息。
                if (usQuery.Any())
                {
                    //没有wxopenId信息,则更新。
                    var usFirst = usQuery.FirstOrDefault();
                    spreaderId = usFirst.SpreaderId;
                    spreadCode = usFirst.SpreadCode;
                    if (string.IsNullOrWhiteSpace(usFirst.WxOpenId))
                    {
                        usFirst.WxOpenId   = sbwxDto.WxOpenId;
                        usFirst.ModifiedOn = DateTime.Now;
                    }
                    //删除其它和当前wxOpenId相关的记录。
                    foreach (var uu in usQuery)
                    {
                        if (uu.Id == usFirst.Id)
                        {
                            continue;
                        }
                        uu.EntityState = System.Data.EntityState.Deleted;
                    }
                }
                else
                {
                    if (wxQuery.Any())
                    {
                        UserSpreader usRecord = wxQuery.FirstOrDefault();
                        usRecord.UserId     = sbwxDto.BuyerId;
                        usRecord.ModifiedOn = DateTime.Now;
                        spreaderId          = usRecord.SpreaderId;
                        spreadCode          = usRecord.SpreadCode;
                    }
                }

                //推广分成相关订单Id.
                List <Guid> orderIds = new List <Guid>();

                var moQuery = from mo in MainOrder.ObjectSet()
                              where mo.MainOrderId == sbwxDto.OrderId
                              select mo.SubOrderId;

                if (moQuery.Any())
                {
                    //传入的OrderId为主订单id,找出所有子订单。
                    orderIds = moQuery.ToList();
                }
                else
                {
                    orderIds.Add(sbwxDto.OrderId);
                }

                var coQuery = from co in CommodityOrder.ObjectSet()
                              where orderIds.Contains(co.Id)
                              select co;
                foreach (var cOrder in coQuery)
                {
                    cOrder.SpreaderId = spreaderId;
                    cOrder.ModifiedOn = DateTime.Now;
                    cOrder.SpreadCode = spreadCode;
                }

                contextSession.SaveChanges();

                result.ResultCode = 0;
                result.Message    = "成功!";
                return(result);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("UpdateOrderSpreaderExt异常。sbwxDto:{0}", JsonHelper.JsonSerializer(sbwxDto)), ex);

                result.ResultCode = 10;
                result.Message    = "接口异常,请稍后重试!";
                return(result);
            }
        }