예제 #1
0
        /// <summary>
        /// 用户接受协议成为分经销商
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string SetPreRetailTraderToNomal(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderRP> >();

            if (string.IsNullOrEmpty(rp.UserID))
            {
                throw new APIException("缺少参数【UserID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var RetailTraderBLL    = new RetailTraderBLL(loggingSessionInfo);
            var VipBLL             = new VipBLL(loggingSessionInfo);

            var Data = RetailTraderBLL.GetByID(rp.UserID);

            if (Data == null)
            {
                throw new APIException("参数【rp.Parameters.RetailTraderID】错误找不到对应经销商")
                      {
                          ErrorCode = 136
                      };
            }
            var vipData = VipBLL.GetByID(Data.MultiLevelSalerFromVipId);

            if (vipData != null)
            {
                if (!string.IsNullOrWhiteSpace(vipData.SetoffUserId))//经销商二维码扫码关注的会员,成为经销商时,自动被集客
                {
                    DataSet ds = RetailTraderBLL.GetMultiLevelBeAddNode(vipData.SetoffUserId);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        Data.HigheRetailTraderID = ds.Tables[0].Rows[0]["BeAddNode"].ToString();
                        if (ds.Tables[0].Rows[0]["BeAddNodeFlag"] != DBNull.Value)
                        {
                            int Flag = Convert.ToInt32(ds.Tables[0].Rows[0]["BeAddNodeFlag"]);
                            if (Flag == 1)//添加经销商拓展节点记录
                            {
                                var T_HierarchySystemExNodeBLL = new T_HierarchySystemExNodeBLL(loggingSessionInfo);
                                T_HierarchySystemExNodeBLL.AddHierarchySystemExNode(Data.RetailTraderID);
                            }
                        }
                    }
                }
            }
            Data.Status = "1";

            RetailTraderBLL.Update(Data);
            var response = new EmptyRD();
            var rsp      = new SuccessResponse <IAPIResponseData>(response);

            return(rsp.ToJSON());
        }