Exemplo n.º 1
0
        /// <summary>
        /// 类别名称是否存在
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckCategoryName()
        {
            result = new PlatReturnMsg();
            int    appId        = Utility.IO.Context.GetRequestInt("appId", 0);
            int    Id           = Utility.IO.Context.GetRequestInt("Id", 0);
            int    isFirstType  = Utility.IO.Context.GetRequestInt("isFirstType", 0);
            string categoryName = Utility.IO.Context.GetRequest("categoryName", string.Empty);

            if (appId <= 0 || string.IsNullOrEmpty(categoryName))
            {
                result.Msg = "参数错误";
                return(Json(result));
            }

            PlatStoreCategory model = PlatStoreCategoryBLL.SingleModel.msgTypeNameIsExist(appId, categoryName, isFirstType);

            if (model != null && model.Id != Id)
            {
                result.Msg = "类别名称已存在";
                return(Json(result));
            }
            result.isok = true;
            result.Msg  = "ok";
            return(Json(result));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 批量更新排序
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>

        public ActionResult SaveCategorySort(List <PlatStoreCategory> list)
        {
            result = new PlatReturnMsg();

            if (list == null || list.Count <= 0)
            {
                result.Msg = "数据不能为空";
                return(Json(result));
            }
            PlatStoreCategory model     = new PlatStoreCategory();
            TransactionModel  tranModel = new TransactionModel();
            string            sql       = string.Empty;

            string categoryIds = string.Join(",", list.Select(s => s.Id));
            List <PlatStoreCategory> platStoreCategoryList = PlatStoreCategoryBLL.SingleModel.GetListByIds(categoryIds);

            foreach (PlatStoreCategory item in list)
            {
                model = platStoreCategoryList?.FirstOrDefault(f => f.Id == item.Id);
                if (model == null)
                {
                    result.Msg = $"Id={item.Id}不存在数据库里";
                    return(Json(result));
                }

                if (model.Aid != item.Aid)
                {
                    result.Msg = $"Id={item.Id}权限不足";
                    return(Json(result));
                }


                model.SortNumber = item.SortNumber;
                model.UpdateTime = DateTime.Now;
                sql = PlatStoreCategoryBLL.SingleModel.BuildUpdateSql(model, "SortNumber,UpdateTime");
                tranModel.Add(sql);
            }

            if (tranModel.sqlArray != null && tranModel.sqlArray.Length > 0)
            {
                if (PlatStoreCategoryBLL.SingleModel.ExecuteTransactionDataCorect(tranModel.sqlArray))
                {
                    result.isok = true;
                    result.Msg  = "操作成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "操作失败";
                    return(Json(result));
                }
            }
            else
            {
                result.Msg = "没有需要更新的数据";
                return(Json(result));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 在平台店铺列表里新增没有主人的店铺
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateStore(int aid = 0)
        {
            int storeId = Utility.IO.Context.GetRequestInt("storeId", 0);
            PlatStoreCategoryConfig platStoreCategoryConfig = PlatStoreCategoryConfigBLL.SingleModel.GetModelByAid(aid);

            if (platStoreCategoryConfig == null)
            {
                platStoreCategoryConfig = new PlatStoreCategoryConfig()
                {
                    Aid        = aid,
                    AddTime    = DateTime.Now,
                    Level      = 1,
                    SyncSwitch = 0
                };
                int id = Convert.ToInt32(PlatStoreCategoryConfigBLL.SingleModel.Add(platStoreCategoryConfig));
                if (id <= 0)
                {
                    return(View("PageError", new PlatReturnMsg()
                    {
                        Msg = "初始化数据异常!", code = "500"
                    }));
                }
            }

            List <PlatStoreCategory> list = new List <PlatStoreCategory>();

            list.Add(new PlatStoreCategory()
            {
                Id   = 0,
                Name = "请选择"
            });
            int totalCount = 0;

            ViewBag.firstCategoryId = 0;
            ViewBag.appId           = aid;
            list.AddRange(PlatStoreCategoryBLL.SingleModel.getListByaid(aid, out totalCount, platStoreCategoryConfig.Level == 1 ? 2 : 1, 100, 1));
            ViewBag.CategoryList  = list;
            ViewBag.CategoryLevel = platStoreCategoryConfig.Level;
            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(dzuserId.ToString());

            ViewBag.AgentinfoId = agentinfo == null ? 0 : agentinfo.id;
            PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(storeId);
            bool      isHave    = false;

            if (platStore == null)
            {
                platStore             = new PlatStore();
                platStore.BindPlatAid = aid;
                isHave = true;
            }
            else
            {
                PlatStoreCategory platStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(platStore.Category);
                if (platStoreCategory != null)
                {
                    ViewBag.firstCategoryId = platStoreCategory.ParentId;
                }

                if (!string.IsNullOrEmpty(platStore.StoreService))
                {
                    platStore.StoreServiceModelList = JsonConvert.DeserializeObject <List <StoreServiceModel> >(platStore.StoreService);
                }
                else
                {
                    isHave = true;
                }
            }

            if (isHave)
            {
                List <StoreServiceModel> listService = new List <StoreServiceModel>();
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "WIFI"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "停车位"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "支付宝支付"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "微信支付"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "刷卡支付"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "空调雅座"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "付费停车"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "接送服务"
                });
                platStore.StoreServiceModelList = listService;
            }

            if (!string.IsNullOrEmpty(platStore.SwitchConfig))
            {
                platStore.SwitchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
            }
            else
            {
                platStore.SwitchModel = new PlatStoreSwitchModel();
            }


            return(View(platStore));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 编辑或者新增 信息分类
        /// </summary>
        /// <param name="city_Storemsgrules"></param>
        /// <returns></returns>

        public ActionResult SaveCategory(PlatStoreCategory platStoreCategory)
        {
            result = new PlatReturnMsg();
            if (platStoreCategory == null)
            {
                result.Msg = "数据不能为空";
                return(Json(result));
            }

            if (platStoreCategory.Aid <= 0)
            {
                result.Msg = "appId非法";
                return(Json(result));
            }



            int Id = platStoreCategory.Id;

            if (Id == 0)
            {
                //表示新增
                Id = Convert.ToInt32(PlatStoreCategoryBLL.SingleModel.Add(new PlatStoreCategory()
                {
                    MaterialPath = platStoreCategory.MaterialPath,
                    Name         = platStoreCategory.Name,
                    AddTime      = DateTime.Now,
                    UpdateTime   = DateTime.Now,
                    Aid          = platStoreCategory.Aid,
                    State        = 0,
                    SortNumber   = platStoreCategory.SortNumber,
                    ParentId     = platStoreCategory.ParentId
                }));
                if (Id > 0)
                {
                    result.isok = true;
                    result.Msg  = "新增成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "新增失败";
                    return(Json(result));
                }
            }
            else
            {
                //表示更新
                PlatStoreCategory model = PlatStoreCategoryBLL.SingleModel.GetModel(Id);
                if (model == null)
                {
                    result.Msg = "不存在数据库里";
                    return(Json(result));
                }

                if (model.Aid != platStoreCategory.Aid)
                {
                    result.Msg = "权限不足";
                    return(Json(result));
                }
                model.UpdateTime   = DateTime.Now;
                model.MaterialPath = platStoreCategory.MaterialPath;
                model.Name         = platStoreCategory.Name;
                model.SortNumber   = platStoreCategory.SortNumber;
                model.ParentId     = platStoreCategory.ParentId;
                if (PlatStoreCategoryBLL.SingleModel.Update(model, "UpdateTime,MaterialPath,Name,SortNumber,ParentId"))
                {
                    result.isok = true;
                    result.Msg  = "更新成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "更新失败";
                    return(Json(result));
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aid">平台小程序appId</param>
        /// <param name="totalCount"></param>
        /// <param name="storeName">店铺名称</param>
        /// <param name="appName">绑定的小程序名称</param>
        /// <param name="agentName">分销代理商名称</param>
        /// <param name="categoryName">原平台类别名称</param>
        /// <param name="storeState">店铺状态</param>
        /// <param name="haveAid">是否绑定了小程序0 未绑定 1绑定了</param>
        /// <param name="fromType">数据来源0 店铺入驻 1代理分销商同步</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="orderWhere"></param>
        /// <returns></returns>
        public List <PlatStoreRelation> GetListStore(int aid, out int totalCount, string storeName = "", string appName = "", string agentName = "", string categoryName = "", int storeState = -1, int haveAid = -1, int fromType = -1, int pageSize = 10, int pageIndex = 1, string orderWhere = "AddTime desc", string storeOwnerPhone = "", int isFirstType = 0, int categoryId = 0, string appId = "")
        {
            List <PlatStore>         list = new List <PlatStore>();
            List <PlatStoreRelation> listPlatStoreRelation = new List <PlatStoreRelation>();
            List <MySqlParameter>    parameters            = new List <MySqlParameter>();
            string strWhere = $" psr.Aid={aid} and s.Id>0 and s.state<>-1 and s.MyCardId in({PlatMyCardBLL.SingleModel.GetCardIds(aid, appId)})";

            if (storeState != -1)
            {
                strWhere += $" and psr.State={storeState}";
            }
            if (haveAid != -1)
            {
                if (haveAid == 0)
                {
                    strWhere += $" and s.Aid=0";
                }
                else
                {
                    strWhere += $" and s.Aid<>0"; //表示店铺已经绑定独立小程序
                }
            }

            if (fromType != -1)
            {
                strWhere += $" and psr.FromType={fromType}";
            }

            if (!string.IsNullOrEmpty(storeOwnerPhone))
            {
                parameters.Add(new MySqlParameter("@storeOwnerPhone", $"%{storeOwnerPhone}%"));
                strWhere += " and c.Phone like @storeOwnerPhone";
            }

            if (!string.IsNullOrEmpty(storeName))
            {
                parameters.Add(new MySqlParameter("@storeName", $"%{storeName}%"));
                strWhere += " and s.Name like @storeName";
            }
            if (!string.IsNullOrEmpty(appName))//根据店铺绑定的小程序名称模糊查询
            {
                List <int> listRids = OpenAuthorizerConfigBLL.SingleModel.GetRidByAppName(appName);
                if (listRids == null || listRids.Count <= 0)
                {
                    listRids.Add(0);
                }
                strWhere += $" and s.Aid in ({string.Join(",", listRids)})";
            }
            if (!string.IsNullOrEmpty(agentName))//根据分销代理商名称模糊查询
            {
                List <int> listAgentId = AgentinfoBLL.SingleModel.GetAgentIdByAgentName(agentName);
                if (listAgentId == null || listAgentId.Count <= 0)
                {
                    listAgentId.Add(0);
                }
                strWhere += $" and psr.AgentId in ({string.Join(",", listAgentId)})";
            }

            if (!string.IsNullOrEmpty(categoryName))//根据类别名称(小类 因为店铺最终属于某个小类)模糊查询
            {
                List <int> listCategoryId = PlatStoreCategoryBLL.SingleModel.GetCategoryIdName(categoryName);
                if (listCategoryId == null || listCategoryId.Count <= 0)
                {
                    listCategoryId.Add(0);
                }

                strWhere += $" and s.Category in ({string.Join(",", listCategoryId)})";
            }

            if (isFirstType == 1 && categoryId > 0)
            {
                //表示传过来的是店铺大类 先查询出其下面的小类id
                strWhere += $" and s.Category in ({PlatStoreCategoryBLL.SingleModel.GetChildIds(aid, categoryId)})";
            }

            if (isFirstType == 2 && categoryId > 0)
            {
                //表示传过来的是店铺大类 先查询出其下面的小类id
                strWhere += $" and s.Category in ({categoryId})";
            }

            string sql = $"select psr.*,s.YearCount,s.CostPrice,s.Id as sId,s.Aid as sAid,s.Category as sCategory,s.MyCardId as sMyCardId,s.StorePV,s.StoreVirtualPV,s.Name,c.Phone as StoreOwnerPhone from PlatStoreRelation psr left join PlatStore s on psr.StoreId=s.Id left join PlatMyCard c on s.MyCardId=c.Id  where {strWhere} order by {orderWhere} LIMIT {(pageIndex - 1) * pageSize},{pageSize}";

            using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql, parameters.ToArray()))
            {
                listPlatStoreRelation = new List <PlatStoreRelation>();
                while (dr.Read())
                {
                    PlatStoreRelation platStoreRelation = PlatStoreRelationBLL.SingleModel.GetModel(dr);

                    if (platStoreRelation != null)
                    {
                        if (dr["sCategory"] != DBNull.Value)
                        {
                            PlatStoreCategory OwnerPlatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(Convert.ToInt32(dr["sCategory"]));
                            if (OwnerPlatStoreCategory != null)
                            {
                                platStoreRelation.OwnerSecondCategoryName = OwnerPlatStoreCategory.Name;
                                PlatStoreCategory firstplatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(OwnerPlatStoreCategory.ParentId);
                                if (firstplatStoreCategory != null)
                                {
                                    platStoreRelation.OwnerFirstCategoryName = firstplatStoreCategory.Name;
                                }
                            }
                        }

                        PlatStoreCategory CurPlatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(platStoreRelation.Category);
                        if (CurPlatStoreCategory != null)
                        {
                            platStoreRelation.CurSecondCategoryName = CurPlatStoreCategory.Name;
                            PlatStoreCategory firstplatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(CurPlatStoreCategory.ParentId);
                            if (firstplatStoreCategory != null)
                            {
                                platStoreRelation.CurFirstCategoryName = firstplatStoreCategory.Name;
                                platStoreRelation.FirstCategory        = CurPlatStoreCategory.ParentId;
                            }
                        }


                        platStoreRelation.StoreOwnerPhone = dr["StoreOwnerPhone"].ToString();
                        if (dr["sMyCardId"] != DBNull.Value)
                        {
                            platStoreRelation.MyCardId = Convert.ToInt32(dr["sMyCardId"]);
                        }

                        Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModel(platStoreRelation.AgentId);
                        platStoreRelation.FromTypeStr = platStoreRelation.FromType == 0 ? "平台入驻" : (agentinfo != null ? agentinfo.name : "分销代理商");

                        if (dr["sAid"] != DBNull.Value)
                        {
                            XcxAppAccountRelation xcxAppAccountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(Convert.ToInt32(dr["sAid"]));
                            if (xcxAppAccountRelation == null)
                            {
                                platStoreRelation.BindAppIdName = "无";
                            }
                            else
                            {
                                OpenAuthorizerConfig openAuthorizerConfig = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(xcxAppAccountRelation.AppId, xcxAppAccountRelation.Id);

                                platStoreRelation.BindAppIdName = openAuthorizerConfig?.nick_name + "id:" + xcxAppAccountRelation.Id;
                            }
                        }

                        platStoreRelation.StoreName = Convert.ToString(dr["Name"]);
                        if (dr["StorePV"] != DBNull.Value)
                        {
                            platStoreRelation.StorePV = Convert.ToInt32(dr["StorePV"]);
                        }
                        if (dr["StoreVirtualPV"] != DBNull.Value)
                        {
                            platStoreRelation.StorePV += Convert.ToInt32(dr["StoreVirtualPV"]);
                        }

                        if (dr["sId"] != DBNull.Value)
                        {
                            platStoreRelation.StoreId = Convert.ToInt32(dr["sId"]);
                        }
                        if (dr["sAid"] != DBNull.Value)
                        {
                            platStoreRelation.StoreAid = Convert.ToInt32(dr["sAid"]);
                        }

                        platStoreRelation.YearCount = Convert.ToInt32(dr["YearCount"]);
                        platStoreRelation.CostPrice = Convert.ToInt32(dr["CostPrice"]);

                        listPlatStoreRelation.Add(platStoreRelation);
                    }
                }
            }


            totalCount = 0;
            object obj = SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, $"select Count(psr.Id) from PlatStoreRelation psr left join PlatStore s on psr.StoreId=s.Id left join PlatMyCard c on s.MyCardId=c.Id  where {strWhere}", parameters.ToArray());

            if (obj != null)
            {
                totalCount = Convert.ToInt32(obj);
            }
            ;



            return(listPlatStoreRelation);
        }