Example #1
0
        public ActionResult MiniappStoreGroupsManager()
        {
            int    appId     = Context.GetRequestInt("appId", 0);
            int    PageType  = Context.GetRequestInt("PageType", 0);
            int    pageIndex = Context.GetRequestInt("pageIndex", 1);
            int    pageSize  = Context.GetRequestInt("pageSize", 10);
            string title     = Context.GetRequest("Title", string.Empty);
            int    State     = Context.GetRequestInt("State", 0);

            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            if (PageType <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }

            #region 专业版 版本控制

            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={app.TId}");
            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            int EntjoingroupSwtich = 0;//拼团开关
            int versionId          = 0;
            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }

                if (!string.IsNullOrEmpty(functionList.ComsConfig))
                {
                    ComsConfig comsConfig = JsonConvert.DeserializeObject <ComsConfig>(functionList.ComsConfig);
                    EntjoingroupSwtich = comsConfig.Entjoingroup;
                }
            }
            ViewBag.versionId          = versionId;
            ViewBag.EntjoingroupSwtich = EntjoingroupSwtich;
            #endregion

            int count = 0;
            List <EntGroupsRelation> list = new List <EntGroupsRelation>();
            list = EntGroupsRelationBLL.SingleModel.GetListGroups(PageType, appId, title, State, ref count, pageSize, pageIndex);

            ViewBag.TotalCount = count;
            ViewBag.PageType   = PageType;
            ViewBag.appId      = appId;
            ViewBag.pageSize   = pageSize;

            return(View(list));
        }
Example #2
0
        public ActionResult MiniappStoreGroupsManager(int appId, int PageType, int pageIndex = 1, int pageSize = 10, string Title = "", int State = 10)
        {
            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            if (PageType <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }

            Store store = StoreBLL.SingleModel.GetModelByRid(appId);

            if (store == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "没有找到店铺!", code = "500"
                }));
            }

            #region 专业版 版本控制

            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={app.TId}");
            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            int JoingroupSwtich = 0;//团购开关
            int versionId       = 0;
            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }

                if (!string.IsNullOrEmpty(functionList.ComsConfig))
                {
                    ComsConfig comsConfig = JsonConvert.DeserializeObject <ComsConfig>(functionList.ComsConfig);
                    JoingroupSwtich = comsConfig.Joingroup;
                }
            }
            ViewBag.versionId       = versionId;
            ViewBag.JoingroupSwtich = JoingroupSwtich;
            #endregion

            List <MySqlParameter> param = new List <MySqlParameter>();

            List <Groups> list = new List <Groups>();
            list = GroupsBLL.SingleModel.GetList($"StoreId={store.Id}", pageSize, pageIndex, "", "CreateDate desc");

            ViewBag.TotalCount = GroupsBLL.SingleModel.GetCount($"StoreId={store.Id}");
            ViewBag.PageType   = PageType;
            ViewBag.appId      = appId;
            @ViewBag.StoreId   = store.Id;
            ViewBag.pageSize   = pageSize;

            return(View(list));
        }
Example #3
0
        public ActionResult CouponsList(int appId, int PageType)
        {
            int couponstate = Context.GetRequestInt("couponstate", 0);
            //int appId =  Context.GetRequestInt("appId", 0);
            //int PageType =  Context.GetRequestInt("PageType", 0);
            int    pageIndex  = Context.GetRequestInt("pageIndex", 1);
            int    pageSize   = Context.GetRequestInt("pageSize", 10);
            string couponname = Context.GetRequest("couponname", string.Empty);
            string souceFrom  = Context.GetRequest("SouceFrom", string.Empty);

            if (appId <= 0)
            {
                return(Redirect("dzhome/login"));
            }

            if (PageType <= 0)
            {
                return(Redirect("dzhome/login"));
            }

            #region 专业版 版本控制

            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={app.TId}");
            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            int CouponsSwtich = 0;//优惠券开关
            int versionId     = 0;
            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                PageType = xcxTemplate.Type;
                FunctionList functionList = new FunctionList();
                versionId    = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }

                if (!string.IsNullOrEmpty(functionList.ComsConfig))
                {
                    ComsConfig comsConfig = JsonConvert.DeserializeObject <ComsConfig>(functionList.ComsConfig);
                    CouponsSwtich = comsConfig.Coupons;
                }
            }
            ViewBag.versionId     = versionId;
            ViewBag.CouponsSwtich = CouponsSwtich;
            #endregion


            string erromsg = string.Empty;
            string userids = "";
            string aids    = "";
            int    storeid = XcxAppAccountRelationBLL.SingleModel.ReturnStoreIdByAId(appId, ref erromsg, ref aids, ref userids);
            if (erromsg != null && erromsg.Length > 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = erromsg, code = "500"
                }));
            }
            List <Coupons> list = new List <Coupons>();
            try
            {
                list = CouponsBLL.SingleModel.GetCouponList(couponname, couponstate, storeid, appId, TicketType.优惠券, pageSize, pageIndex, "addtime desc");
                if (list != null && list.Count > 0)
                {
                    string           couponids = string.Join(",", list.Select(s => s.Id).Distinct());
                    List <CouponLog> loglist   = CouponLogBLL.SingleModel.GetList($"couponid in ({couponids})");

                    foreach (Coupons item in list)
                    {
                        //领取记录
                        List <CouponLog> temploglist = loglist?.Where(w => w.CouponId == item.Id).ToList();
                        if (temploglist != null && temploglist.Count > 0)
                        {
                            //库存
                            item.RemNum    = item.CreateNum - temploglist.Count;
                            item.CouponNum = temploglist.Count;
                            var tempuserlist = temploglist.GroupBy(g => g.UserId).ToList();
                            //多少人领取
                            item.PersonNum = tempuserlist != null && tempuserlist.Count > 0 ? tempuserlist.Count : 0;
                            //已使用
                            List <CouponLog> tempuselist = temploglist.Where(w => w.State == 1).ToList();
                            item.UseNum = tempuselist != null && tempuselist.Count > 0 ? tempuselist.Count : 0;
                        }
                        else
                        {
                            //库存
                            item.RemNum = item.CreateNum;
                        }
                    }
                }

                ViewBag.TotalCount  = CouponsBLL.SingleModel.GetCouponListCount(couponname, couponstate, storeid, appId, TicketType.优惠券);
                ViewBag.PageType    = PageType;
                ViewBag.appId       = appId;
                ViewBag.StoreId     = storeid;
                ViewBag.pageSize    = pageSize;
                ViewBag.couponstate = couponstate;
                ViewBag.couponname  = couponname;
                ViewBag.SouceFrom   = souceFrom;
            }
            catch (Exception)
            {
            }

            return(View(list));
        }