Exemplo n.º 1
0
        private bool IsShopAdmin(int id)
        {
            BLL.wx_diancai_admin   dBll      = new BLL.wx_diancai_admin();
            Model.wx_diancai_admin shopAdmin = dBll.GetModel(id);

            //餐饮 商铺管理员
            if (shopAdmin != null)
            {
                //Session[MXKeys.WEIXIN_DIANCAI_SHOPID] = shopAdmin.ShopId;
                //Utils.WriteCookie(MXKeys.WEIXIN_DIANCAI_SHOPID, "WeiXinPF", shopAdmin.ShopId.ToString());

                return(true);
            }

            BLL.wx_diancai_shop_user   suBll    = new BLL.wx_diancai_shop_user();
            Model.wx_diancai_shop_user shopUser = suBll.GetModel(id);

            if (shopUser != null)
            {
                //Session[MXKeys.WEIXIN_DIANCAI_SHOPID] = shopUser.ShopId;
                //Utils.WriteCookie(MXKeys.WEIXIN_DIANCAI_SHOPID, "WeiXinPF", shopUser.ShopId.ToString());

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void RptBind()
        {
            BLL.wx_diancai_admin          dcBll      = new BLL.wx_diancai_admin();
            List <Model.wx_diancai_admin> shopAdmins = dcBll.GetModelList("ShopId=" + shopid);

            BLL.manager managerBll = new BLL.manager();
            DataSet     dsData     = new DataSet();

            if (shopAdmins.Any())
            {
                string strWhere = string.Empty;
                for (int index = 0; index <= shopAdmins.Count - 1; index++)
                {
                    strWhere += "," + shopAdmins[index].ManagerId;
                }

                strWhere = "(" + strWhere.Substring(1) + ")";

                dsData             = managerBll.GetList(0, "id in " + strWhere, string.Empty);
                rptList.DataSource = dsData;
            }
            else
            {
                rptList.DataSource = new List <Model.manager>();
            }

            rptList.DataBind();
        }
Exemplo n.º 3
0
        public int GetShopId()
        {
            if (IsAdminLogin())
            {
                Model.manager          admin        = GetAdminInfo();
                BLL.wx_diancai_admin   shopAdminBll = new BLL.wx_diancai_admin();
                Model.wx_diancai_admin shopAdmin    = shopAdminBll.GetModel(admin.id);
                if (shopAdmin != null)
                {
                    return(shopAdmin.ShopId);
                }

                BLL.wx_diancai_shop_user   suBll    = new BLL.wx_diancai_shop_user();
                Model.wx_diancai_shop_user shopUser = suBll.GetModel(admin.id);

                if (shopUser != null)
                {
                    return(shopUser.ShopId);
                }
                return(0);
            }
            return(0);
        }
Exemplo n.º 4
0
        public List <ShortMsgWithCountDto> GetAllLastNewMsg(UserManagerDto toUserDto)
        {
            List <ShortMsgWithCountDto> result = new List <ShortMsgWithCountDto>();

            if (toUserDto != null)
            {
                var userType = _userService.GetUserType(toUserDto);
                Expression <Func <ShortMsg, bool> > func;
                if (userType != MsgUserType.User)
                {
                    var userids    = new List <string>();
                    var hotelBll   = new BLL.wx_hotel_admin();
                    var diancaiBll = new BLL.wx_diancai_admin();
                    switch (userType)
                    {
                    case MsgUserType.Hotel:
                        var listU = hotelBll.GetModelList(String.Format(
                                                              "HotelId=(SELECT HotelId FROM dbo.wx_hotel_admin WHERE ManagerId={0})"
                                                              , toUserDto.UserId));
                        if (listU != null && listU.Any())
                        {
                            userids = listU.Select(i => i.ManagerId.ToString()).ToList();
                        }
                        break;

                    case MsgUserType.Shop:
                        var listD = diancaiBll.GetModelList(String.Format(
                                                                "ShopId=(SELECT ShopId FROM dbo.wx_diancai_admin WHERE ManagerId={0})"
                                                                , toUserDto.UserId));
                        if (listD != null && listD.Any())
                        {
                            userids = listD.Select(i => i.ManagerId.ToString()).ToList();
                        }
                        break;

                    case MsgUserType.Scenic:
                    default:
                        //景区管理员
                        var count = new wx_userweixin().GetUserWxNumCount(toUserDto.UserId.ToInt());
                        if (count > 0)
                        {
                            userids.Add(toUserDto.UserId);
                        }

                        break;
                    }


                    func = c =>
                           c.MsgToUserType == (int)userType &&
                           userids.Contains(c.ToUserId) &&
                           c.IsRead == false;
                }
                else
                {
                    func = c =>
                           c.ToUserId == toUserDto.UserId && c.IsRead == false;
                }
                var msgList = _msgRepository.GetAllList(func);
                //todo:判断组合方法
                //现在是如果不是微信用户发的,就按发送人分组
                //是微信用户发的直接分组
                var list = msgList.Where(c => (MsgUserType)c.MsgFromUserType
                                         != MsgUserType.WeChatCustomer).GroupBy(c =>
                                                                                new { FromUserId = c.FromUserId, Type = c.Type, DetailType = c.DetailType })
                           .Select(c =>
                                   new
                {
                    Count = c.Count(),
                    Key   = c.Key
                }).ToList();

                if (list.Any())
                {
                    var listReslut = list.Select(c => new ShortMsgWithCountDto
                    {
                        Count = c.Count,
                        Msg   = GetLastNewMsg(toUserDto, c.Key.FromUserId, c.Key.Type, c.Key.DetailType)
                    }).ToList();

                    //多个商品在商品描述上加上xx等5件商品
                    listReslut.ForEach(c =>
                    {
                        if (c.Count > 1)
                        {
                            var index = c.Msg.Content.LastIndexOf(']');

                            c.Msg.Content = c.Msg.Content.Insert(index + 1,
                                                                 String.Format("等{0}件商品", c.Count));
                        }
                    });
                    result.AddRange(listReslut);
                }

                //添加是微信用户发的直接分组的
                if (msgList.Any(c => (MsgUserType)c.MsgFromUserType == MsgUserType.WeChatCustomer))
                {
                    var wxlist = msgList.Where(c => (MsgUserType)c.MsgFromUserType
                                               == MsgUserType.WeChatCustomer).GroupBy(c => c.MsgFromUserType)
                                 .Select(c =>
                                         new
                    {
                        Count = c.Count(),
                        Key   = c.Max(u => u.Id)
                    }).ToList();

                    if (wxlist.Any())
                    {
                        var listReslut = wxlist.Select(c => new ShortMsgWithCountDto
                        {
                            Count = c.Count,
                            Msg   = GetMsg(c.Key)
                        }).ToList();

                        //多个订单在商品描述上加上xx等5件订单
                        listReslut.ForEach(c =>
                        {
                            if (c.Count > 1)
                            {
                                var index      = c.Msg.Content.LastIndexOf("的订单");
                                var msgContent = c.Msg.Content.Substring(0, index);
                                var msgHz      = c.Msg.Content.Substring(c.Msg.Content.LastIndexOf(","));
                                //todo:写死的判断多个时后缀
                                var hz        = c.Msg.Type.ToLower().Contains("order") ? "订单" : "";
                                c.Msg.Content = String.Format("{2}等{0}个{1}{3}", c.Count, hz, msgContent, msgHz);
                            }
                        });
                        result.AddRange(listReslut);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        private bool DoAdd()
        {
            Model.manager adminEntity = GetAdminInfo(); //取得管理员信息

            Model.manager model = new Model.manager();
            BLL.manager   bll   = new BLL.manager();

            //固定为餐饮管理员的角色

            model.role_id   = shop_admin_role;
            model.role_type = new BLL.manager_role().GetModel(model.role_id).role_type;

            model.is_lock = MyCommFun.Str2Int(rblIsLock.SelectedValue);

            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return(false);
            }

            model.user_name = txtUserName.Text.Trim();
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password   = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.real_name  = txtRealName.Text.Trim();
            model.telephone  = txtTelephone.Text.Trim();
            model.email      = txtEmail.Text.Trim();
            model.add_time   = DateTime.Now;
            model.wxNum      = 0;
            model.agentId    = GetAdminInfo().id;
            model.qq         = string.Empty;
            model.email      = txtEmail.Text;
            model.reg_ip     = MXRequest.GetIP();
            model.agentLevel = -1;
            model.remark     = txtRemark.Text;
            model.agentId    = adminEntity.id;
            int addId = bll.Add(model);

            if (addId > 0)
            {
                //添加商铺与管理人员的关联
                BLL.wx_diancai_admin   shopAdminBll = new BLL.wx_diancai_admin();
                Model.wx_diancai_admin shopAdmin    = new Model.wx_diancai_admin();
                shopAdmin.ManagerId = addId;
                shopAdmin.ShopId    = shopid;
                int addShopAdminId = shopAdminBll.Add(shopAdmin);

                if (addShopAdminId <= 0)
                {
                    bll.Delete(addId);
                    addId = 0;
                }
            }

            if (addId > 0)
            {
                AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加餐饮商铺超级管理员:" + model.user_name); //记录日志
                return(true);
            }
            return(false);
        }