コード例 #1
0
        public HttpResponseMessage ScanQRCode([FromBody] ScanQRCodeRequestModel requestParameter)
        {
            var json = new JavaScriptSerializer().Serialize(requestParameter);

            Loggers.Debug(new DebugLogInfo()
            {
                Message = $"[api/Order/ScanQRCode]接口,参数:\"{json}\""
            });
            try
            {
                #region MyRegion

                string customerId = ConfigurationManager.AppSettings["CustomerId"].Trim();
                string content    = string.Empty;

                #endregion

                #region

                var loggingSessionInfo = Default.GetLoggingSession(customerId, "1");

                if (string.IsNullOrWhiteSpace(requestParameter.ParaTmp))
                {
                    throw new APIException("paraTmp不能为空")
                          {
                              ErrorCode = 302
                          };
                }

                #endregion

                #region 创建临时匹配表

                VipDCodeBLL    vipDCodeServer = new VipDCodeBLL(loggingSessionInfo);
                VipDCodeEntity info           = new VipDCodeEntity();
                //由于CodeId有重复的概率,因此只取出最新的一条记录
                info = vipDCodeServer.QueryByEntity(
                    new VipDCodeEntity()
                {
                    DCodeId = ToStr(requestParameter.ParaTmp.Replace(" ", ""))
                }                                                                                     //又去掉了中间的空格
                    , new OrderBy[] { new OrderBy()
                                      {
                                          FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                      } }
                    )[0];
                string status = string.Empty;
                string vipId  = string.Empty;
                string openId = string.Empty;
                if (info == null || info.DCodeId == null)
                {
                    throw new APIException("不存在对应的记录")
                          {
                              ErrorCode = 303
                          };
                }
                else
                {
                    status = info.Status;
                    openId = info.OpenId;
                    vipId  = info.VipId;
                }
                string mode = "Inbound";
                //if ((RP.Parameters.special.Mode == null || (!string.IsNullOrEmpty(RP.Parameters.special.Mode) && RP.Parameters.special.Mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != RP.UserID)
                if ((mode == null || (!string.IsNullOrEmpty(mode) && mode.Equals("Inbound"))) &&
                    !string.IsNullOrEmpty(info.VipId) && info.VipId != requestParameter.UserId)
                {
                    VipBLL vipBll  = new VipBLL(loggingSessionInfo);
                    var    unitBll = new t_unitBLL(loggingSessionInfo);
                    var    UserBll = new T_UserBLL(loggingSessionInfo);

                    var vipInfo    = vipBll.GetByID(info.VipId);
                    var tt         = vipBll.GetUnitByUserId(requestParameter.UserId); //获取员工的会集店****
                    var UserEntity = UserBll.GetByID(vipInfo.SetoffUserId);           //当前会员集客员工

                    //
                    string UserStatus = "";
                    if (UserEntity != null)
                    {
                        UserStatus = UserEntity.user_status;
                    }

                    #region 会员会籍店、集客员工变动处理

                    //string.IsNullOrWhiteSpace(vipInfo.CouponInfo) || string.IsNullOrWhiteSpace(vipInfo.SetoffUserId) 目前未用到
                    if (string.IsNullOrWhiteSpace(vipInfo.HigherVipID) &&
                        string.IsNullOrWhiteSpace(vipInfo.SetoffUserId))
                    {
//当会员会籍店、集客员工为空时
                        if (!string.IsNullOrEmpty(tt))
                        {
                            vipInfo.CouponInfo   = tt;                                           //设为门店
                            vipInfo.SetoffUserId = requestParameter.UserId;                      //设为门店员工
                            vipInfo.Col21        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间*****
                            vipInfo.Col23        = "1";
                        }
                        if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId)
                        {
                            //rsp.Message = "恭喜你集客成功。会员需要用心经营才会有订单哦!";
                        }
                    }
                    else
                    {
                        if (vipInfo != null && !string.IsNullOrEmpty(vipInfo.CouponInfo) &&
                            vipInfo.SetoffUserId != requestParameter.UserId)
                        {
                            //rsp.Message = "此客户已是会员,无需再集客。老会员更要服务好哦!";
                        }
                        else if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId &&
                                 !string.IsNullOrEmpty(vipInfo.Col21) &&
                                 Convert.ToDateTime(vipInfo.Col21).AddSeconds(3) < DateTime.Now) //col21:员工集客/或者分销商集客时间
                        {
                            //rsp.Message = "此客户此前已经被您集客,无需重复集客。!";
                        }
                    }
                    if (UserStatus.Trim().Equals("-1"))
                    {
// 当前会员的集客员工离职时
                        if (!string.IsNullOrEmpty(tt))
                        {
                            vipInfo.CouponInfo   = tt;                                           //设为门店
                            vipInfo.SetoffUserId = requestParameter.UserId;                      //设为门店员工
                            vipInfo.Col21        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间*****
                            vipInfo.Col23        = "1";
                        }
                    }

                    #endregion

                    vipBll.Update(vipInfo);
                }

                #endregion


                var responseModel = new ScanQRCodeResponseModel()
                {
                    IsSucess = true,
                    Status   = status,
                    VipId    = vipId
                };
                return(Request.CreateResponse(HttpStatusCode.OK, responseModel));
            }
            catch (Exception ex)
            {
                var responseModel = new ScanQRCodeResponseModel()
                {
                    IsSucess     = false,
                    ErrorMessage = ex.Message
                };
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "error"));
            }
        }
コード例 #2
0
        //
        /// <summary>
        /// 处理会员的上下线关系
        /// 会员状态        已经有上级关系    有新的附带上级关系
        /// 从未关注的Vip          1                  1             重建关系
        /// 从未关注的Vip          0                  1             重建关系
        /// 取消关注的Vip          0                  1             重建关系

        /// 从未关注的Vip          0                  0
        /// 从未关注的Vip          1                  0
        /// 取消关注的Vip          1                  0
        /// 取消关注的Vip          0                  0
        /// 取消关注的Vip          1                  1

        /// ShareVipID 没内容的 return
        public void SetShareVip(string vipid, string openId)
        {
            #region 验证
            if (string.IsNullOrEmpty(ShareVipID))//如果没有上级分享人员
            {
                return;
            }
            #endregion

            #region Vip实体
            VipBLL    vipBll     = new VipBLL(loggingSessionInfo);
            VipEntity vipInfotmp = null;
            if (string.IsNullOrEmpty(vipid))
            {
                return;
            }
            else
            {
                vipInfotmp = vipBll.GetByID(vipid);
            }
            if (vipInfotmp == null)
            {
                return;
            }
            #endregion

            #region UnitId
            string UnitId = "";
            //获取分享人的门店信息
            //员工 或者 客服

            string shareVipOpenid = "";
            if (SourceId == 1 || SourceId == 2)              //获取分享员工的默认门店
            {
                UnitId = vipBll.GetUnitByUserId(ShareVipID); //获取员工的默认门店
            }
            else
            {
                //获取分享会员的门店
                VipEntity shareVip = vipBll.GetByID(ShareVipID);
                if (shareVip != null)
                {
                    UnitId         = shareVip.CouponInfo;//会员的会籍店
                    shareVipOpenid = shareVip.WeiXinUserId;
                }
            }
            #endregion

            #region 判断用户类型

            #region 关注的
            if (vipInfotmp.Status >= 1)//关注过的
            {
                //当前没有上线,才给他建立一个上线
                if (string.IsNullOrEmpty(vipInfotmp.SetoffUserId) && string.IsNullOrEmpty(vipInfotmp.HigherVipID))
                {
                    //会员 或者 客服
                    if (SourceId == 1 || SourceId == 2)//获取分享员工的默认门店
                    {
                        vipInfotmp.SetoffUserId = ShareVipID;
                        vipInfotmp.HigherVipID  = "";
                        vipInfotmp.Col21        = System.DateTime.Now.ToString();
                    }
                    //会员
                    else
                    {
                        vipInfotmp.HigherVipID  = ShareVipID;
                        vipInfotmp.SetoffUserId = "";
                        vipInfotmp.Col21        = System.DateTime.Now.ToString();
                    }
                }
                else if (SourceId == 4 && string.IsNullOrEmpty(vipInfotmp.Col20))
                {
                    vipInfotmp.Col20 = ShareVipID;
                    vipInfotmp.Col21 = System.DateTime.Now.ToString();
                }
            }
            #endregion

            #region 取消关注的
            else if (vipInfotmp.Status == 0 && vipInfotmp.Col25 == "1")//取消关注的
            {
                if (string.IsNullOrEmpty(vipInfotmp.SetoffUserId) && string.IsNullOrEmpty(vipInfotmp.HigherVipID))
                {
                    if (SourceId == 1 || SourceId == 2)//获取分享员工的默认门店
                    {
                        vipInfotmp.SetoffUserId = ShareVipID;
                        vipInfotmp.HigherVipID  = null;
                        vipInfotmp.Col21        = System.DateTime.Now.ToString();
                    }
                    else
                    {
                        vipInfotmp.HigherVipID  = ShareVipID;
                        vipInfotmp.SetoffUserId = null;
                        vipInfotmp.Col21        = System.DateTime.Now.ToString();
                    }
                }
                else if (SourceId == 4 && string.IsNullOrEmpty(vipInfotmp.Col20))
                {
                    vipInfotmp.Col20 = ShareVipID;
                    vipInfotmp.Col21 = System.DateTime.Now.ToString();
                }
            }
            #endregion

            #region 未关注的
            else
            {                                       //未关注的(oauth认证获取的)
                //客服 员工
                if (SourceId == 1 || SourceId == 2) //获取分享员工的默认门店
                {
                    vipInfotmp.SetoffUserId = ShareVipID;
                    vipInfotmp.HigherVipID  = null;
                    vipInfotmp.Col21        = System.DateTime.Now.ToString();
                }
                else if (SourceId == 4)
                {
                    vipInfotmp.Col20 = ShareVipID;
                    vipInfotmp.Col21 = System.DateTime.Now.ToString();
                }
                //会员
                else
                {
                    vipInfotmp.HigherVipID  = ShareVipID;
                    vipInfotmp.SetoffUserId = null;
                    vipInfotmp.Col21        = System.DateTime.Now.ToString();
                }
            }
            #endregion

            #endregion

            if (string.IsNullOrEmpty(UnitId))
            {
                UnitService unitServer = new UnitService(loggingSessionInfo);
                UnitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识
            }
            vipInfotmp.CouponInfo = UnitId;
            vipInfotmp.Col24      = ObjectID;
            vipInfotmp.Col23      = SourceId.ToString();
            vipBll.Update(vipInfotmp, false);

            //分享记录
            T_LEventsSharePersonLogBLL t_LEventsSharePersonLogBLL = new T_LEventsSharePersonLogBLL(loggingSessionInfo);

            //先查看这个会员之前是否已经打开这个图文素材
            var t_LEventsSharePersonLogTemp = new T_LEventsSharePersonLogEntity();
            t_LEventsSharePersonLogTemp.BusTypeCode  = objectType;
            t_LEventsSharePersonLogTemp.ObjectId     = ObjectID; ////分享的链接代表的对象,活动或者商品
            t_LEventsSharePersonLogTemp.ShareVipType = SourceId; // 1员工,2客服,3会员  4超级分销商
            t_LEventsSharePersonLogTemp.ShareVipID   = ShareVipID;
            t_LEventsSharePersonLogTemp.BeShareVipID = vipid;    //被分享人
            var t_LEventsSharePersonLogOld = t_LEventsSharePersonLogBLL.QueryByEntity(t_LEventsSharePersonLogTemp, null);
            //如果已经有这样的记录,就不要再写了
            if (t_LEventsSharePersonLogOld != null && t_LEventsSharePersonLogOld.Length > 0)
            {
                return;
            }


            //第一次打开的时候才创建
            var t_LEventsSharePersonLog = new T_LEventsSharePersonLogEntity();
            t_LEventsSharePersonLog.SharePersonLogId = Guid.NewGuid();
            t_LEventsSharePersonLog.BusTypeCode      = objectType;
            t_LEventsSharePersonLog.ObjectId         = ObjectID; ////分享的链接代表的对象,活动或者商品
            t_LEventsSharePersonLog.ShareVipType     = SourceId; // 1员工,2客服,3会员
            t_LEventsSharePersonLog.ShareVipID       = ShareVipID;

            t_LEventsSharePersonLog.ShareOpenID   = shareVipOpenid; //如果是会员,取出来
            t_LEventsSharePersonLog.BeShareVipID  = vipid;          //新建的会员会员的vipid
            t_LEventsSharePersonLog.BeShareOpenID = openId;         //本分享人的id

            t_LEventsSharePersonLog.ShareURL       = goUrl;         //分享的链接
            t_LEventsSharePersonLog.CreateTime     = System.DateTime.Now;
            t_LEventsSharePersonLog.CreateBy       = "";
            t_LEventsSharePersonLog.LastUpdateBy   = "";
            t_LEventsSharePersonLog.LastUpdateTime = System.DateTime.Now;
            t_LEventsSharePersonLog.CustomerId     = loggingSessionInfo.ClientID;
            t_LEventsSharePersonLog.IsDelete       = 0;
            t_LEventsSharePersonLogBLL.Create(t_LEventsSharePersonLog);
        }
コード例 #3
0
        protected override SetSignInRD ProcessRequest(DTO.Base.APIRequest <SetSignInRP> pRequest)
        {
            SetSignInRD rd = new SetSignInRD();

            string customerCode = pRequest.Parameters.CustomerCode;

            string phone = pRequest.Parameters.LoginName;

            string password = pRequest.Parameters.Password;

            if (string.IsNullOrEmpty(customerCode))
            {
                throw new APIException("客户代码不能为空")
                      {
                          ErrorCode = Error_CustomerCode_NotNull
                      };
            }

            WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession(""));
            string   customerId = menuServer.GetCustomerIDByCustomerCode(customerCode);

            if (string.IsNullOrEmpty(customerId))
            {
                throw new APIException("客户代码对应的客户不存在")
                      {
                          ErrorCode = Error_CustomerCode_NotExist
                      };
            }
            var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");

            VipBLL vipBll = new VipBLL(currentUserInfo);

            #region 判断用户是否存在
            if (!vipBll.JudgeUserExist(phone, customerId))
            {
                throw new APIException("用户名无效")
                      {
                          ErrorCode = Error_UserName_InValid
                      };
            }

            #endregion

            #region 判断密码是否正确
            if (!vipBll.JudgeUserPasswordExist(phone, customerId, password))
            {
                throw new APIException("登录密码错误")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }

            #endregion
            #region 判断是否有登录连锁掌柜App权限
            var  userRolesDs = vipBll.GetUserRoles(phone, customerId, password);
            bool flag        = false;
            foreach (DataRow row in userRolesDs.Tables[0].Rows)
            {
                if (row["Def_App_Code"].ToString().ToUpper() == "APP")
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                throw new APIException("该账号无权登录本系统")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }
            #endregion
            #region 判断该客服人员是否有客服或操作订单的权限
            //if (!vipBll.JudgeUserRoleExist(phone, customerId, password))
            //{
            //    throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid };
            //}
            #endregion

            #region 获取UserId
            var ds = vipBll.GetUserIdByUserNameAndPassword(phone, customerId, password);
            rd.UserId     = ds.Tables[0].Rows[0]["user_id"].ToString();
            rd.UserName   = ds.Tables[0].Rows[0]["user_name"].ToString();
            rd.Status     = int.Parse(ds.Tables[0].Rows[0]["user_status"].ToString());
            rd.CustomerId = customerId;
            var T_SuperRetailTraderbll  = new T_SuperRetailTraderBLL(currentUserInfo);
            var T_SuperRetailTraderInfo = T_SuperRetailTraderbll.QueryByEntity(new T_SuperRetailTraderEntity()
            {
                CustomerId = customerId, SuperRetailTraderFromId = rd.UserId, SuperRetailTraderFrom = "User"
            }, new OrderBy[] { new OrderBy()
                               {
                                   FieldName = "CreateTime", Direction = OrderByDirections.Desc
                               } }).FirstOrDefault();
            if (T_SuperRetailTraderInfo != null)
            {
                rd.SuperRetailTraderID = T_SuperRetailTraderInfo.SuperRetailTraderID.ToString();
            }
            #endregion
            //如果状态不等于1,就说明已经停用,
            if (rd.Status != 1)
            {
                throw new APIException("该员工已经被停用,请联系管理员")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }


            #region 获取角色列表
            var roleCodeDs = vipBll.GetRoleCodeByUserId(rd.UserId, customerId);

            var tmp = roleCodeDs.Tables[0].AsEnumerable().Select(t => new RoleCodeInfo()
            {
                RoleCode = t["role_code"].ToString()
            });

            #endregion
            rd.UnitId = vipBll.GetUnitByUserId(rd.UserId);//获取会集店
            TUnitBLL tUnitBLL = new TUnitBLL(currentUserInfo);
            if (!string.IsNullOrEmpty(rd.UnitId))
            {
                rd.UnitName = tUnitBLL.GetByID(rd.UnitId).UnitName;
            }
            else
            {
                rd.UnitName = "";
            }


            //app登陆用户权限 add by henry 2015-3-26
            var roleCodeList = vipBll.GetAppMenuByUserId(rd.UserId);


            //app登陆用户权限 add by henry 2015-3-26
            List <string> lst = new List <string>();
            if (roleCodeDs.Tables[0] != null && roleCodeDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow item in roleCodeDs.Tables[0].Rows)
                {
                    var menuList = new JIT.CPOS.BS.DataAccess.AppSysService(currentUserInfo).GetRoleMenus(currentUserInfo.ClientID, item["role_id"] + "");
                    if (menuList != null)
                    {
                        lst.AddRange(menuList.Select(m => m.Menu_Code).Distinct().ToList());
                    }
                }
            }

            rd.MenuCodeList = new List <Menu>();
            foreach (var item in lst.Distinct().ToList())
            {
                rd.MenuCodeList.Add(new Menu()
                {
                    MenuCode = item
                });
            }

            //if (roleCodeList != null)
            //{
            //    rd.MenuCodeList = DataTableToObject.ConvertToList<Menu>(roleCodeList.Tables[0]);
            //}

            rd.RoleCodeList = tmp.ToArray();
            rd.CustomerName = currentUserInfo.ClientName;


            //销售员头像
            ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(currentUserInfo);
            ObjectImagesEntity en = new ObjectImagesEntity();
            en.ObjectId = rd.UserId;//根据获取的用户ID
            List <ObjectImagesEntity> ImgList = _ObjectImagesBLL.QueryByEntity(en, null).OrderByDescending(p => p.CreateTime).ToList();
            if (ImgList != null && ImgList.Count != 0)
            {
                // string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS"); ;//http://182.254.156.57:811
                rd.HeadImg = ImgList[0].ImageURL;
            }


            #region 获取appLogo
            //基础数据初始化
            CustomerBasicSettingBLL      customerBasicSettingBLL = new CustomerBasicSettingBLL(currentUserInfo);
            List <CustomerBasicCodeInfo> customerBasicCodeList   = new List <CustomerBasicCodeInfo>();
            //查询条件
            CustomerBasicSettingEntity customerBasicSettingEntity = new CustomerBasicSettingEntity()
            {
                CustomerID  = currentUserInfo.ClientID,
                SettingCode = "WebLogo"
            };
            //执行查询
            List <CustomerBasicSettingEntity> customerBasicSettingEntityList = customerBasicSettingBLL.QueryByEntity(customerBasicSettingEntity, null).ToList();

            foreach (var a in customerBasicSettingEntityList)
            {
                CustomerBasicCodeInfo customerBasicCodeInfo = new CustomerBasicCodeInfo();

                if (a.SettingCode.Equals("WebLogo"))
                {
                    customerBasicCodeInfo.WebLogo = a.SettingValue.ToString();
                }
                customerBasicCodeList.Add(customerBasicCodeInfo);
            }

            rd.CustomerBasicCodeList = customerBasicCodeList;


            #endregion
            return(rd);
        }