Beispiel #1
0
 public static string GetRedirectUrl(int publishmentSystemId, ELotteryType lotteryType)
 {
     return(PageUtils.GetWeiXinUrl(nameof(PageLottery), new NameValueCollection
     {
         { "publishmentSystemId", publishmentSystemId.ToString() },
         { "lotteryType", ELotteryTypeUtils.GetValue(lotteryType) }
     }));
 }
Beispiel #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }
            lotteryType = ELotteryTypeUtils.GetEnumType(Request.QueryString["lotteryType"]);
            lotteryID   = TranslateUtils.ToInt(Request.QueryString["lotteryID"]);
            awardID     = TranslateUtils.ToInt(Request.QueryString["awardID"]);
            returnUrl   = StringUtils.ValueFromUrl(Request.QueryString["returnUrl"]);

            if (!string.IsNullOrEmpty(Request.QueryString["Delete"]))
            {
                var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]);
                if (list.Count > 0)
                {
                    try
                    {
                        DataProviderWX.LotteryWinnerDAO.Delete(PublishmentSystemID, list);
                        SuccessMessage("删除成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "删除失败!");
                    }
                }
            }

            spContents.ControlToPaginate = rptContents;
            spContents.ItemsPerPage      = 30;
            spContents.ConnectionString  = BaiRongDataProvider.ConnectionString;
            spContents.SelectCommand     = DataProviderWX.LotteryWinnerDAO.GetSelectString(PublishmentSystemID, lotteryType, lotteryID, awardID);
            spContents.SortField         = LotteryWinnerAttribute.ID;
            spContents.SortMode          = SortMode.DESC;
            rptContents.ItemDataBound   += new RepeaterItemEventHandler(rptContents_ItemDataBound);

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.CMS.LeftMenu.ID_Configration, "获奖名单查看", string.Empty);

                spContents.DataBind();

                var totalNum = 0;
                var wonNum   = 0;
                DataProviderWX.LotteryAwardDAO.GetCount(PublishmentSystemID, lotteryType, lotteryID, out totalNum, out wonNum);
                InfoMessage($"总奖品数:{totalNum},已中奖人数:{wonNum},剩余奖品数:{totalNum - wonNum}");

                var urlDelete = PageUtils.AddQueryString(GetRedirectUrl(PublishmentSystemID, lotteryType, lotteryID, awardID, returnUrl), "Delete", "True");
                btnDelete.Attributes.Add("onclick", JsUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的获奖项", "此操作将删除所选获奖项,确认吗?"));

                btnSetting.Attributes.Add("onclick", Modal.WinnerSetting.GetOpenWindowString(PublishmentSystemID));

                btnExport.Attributes.Add("onclick", Modal.Export.GetOpenWindowStringByLottery(PublishmentSystemID, lotteryType, lotteryID));

                btnReturn.Attributes.Add("onclick", $"location.href='{returnUrl}';return false");
            }
        }
Beispiel #3
0
 public static string GetOpenWindowStringByLottery(int publishmentSystemId, ELotteryType lotteryType, int lotteryId)
 {
     return(PageUtils.GetOpenWindowString("导出CSV",
                                          PageUtils.GetWeiXinUrl(nameof(ModalExport), new NameValueCollection
     {
         { "publishmentSystemId", publishmentSystemId.ToString() },
         { "lotteryType", ELotteryTypeUtils.GetValue(lotteryType) },
         { "lotteryId", lotteryId.ToString() }
     }), 400, 240, true));
 }
Beispiel #4
0
        public static string GetOpenWindowStringByLottery(int publishmentSystemID, ELotteryType lotteryType, int lotteryID)
        {
            var arguments = new NameValueCollection();

            arguments.Add("publishmentSystemID", publishmentSystemID.ToString());
            arguments.Add("lotteryType", ELotteryTypeUtils.GetValue(lotteryType));
            arguments.Add("lotteryID", lotteryID.ToString());

            return(JsUtils.OpenWindow.GetOpenWindowString("导出CSV", "modal_export.aspx", arguments, 400, 240, true));
        }
Beispiel #5
0
        public static string GetEndImageUrl(PublishmentSystemInfo publishmentSystemInfo, ELotteryType lotteryType, string endImageUrl)
        {
            if (!string.IsNullOrEmpty(endImageUrl))
            {
                return(PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, endImageUrl)));
            }
            var directoryName = "img" + ELotteryTypeUtils.GetValue(lotteryType);

            return(PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/lottery/{directoryName}/end.jpg")));
        }
Beispiel #6
0
 public static string GetRedirectUrl(int publishmentSystemId, ELotteryType lotteryType, int lotteryId, int awardId, string returnUrl)
 {
     return(PageUtils.GetWeiXinUrl(nameof(PageLotteryWinner), new NameValueCollection
     {
         { "publishmentSystemId", publishmentSystemId.ToString() },
         { "lotteryType", ELotteryTypeUtils.GetValue(lotteryType) },
         { "lotteryId", lotteryId.ToString() },
         { "awardId", awardId.ToString() },
         { "returnUrl", StringUtils.ValueToUrl(returnUrl) }
     }));
 }
Beispiel #7
0
        public static string GetContentAwardImageUrl(PublishmentSystemInfo publishmentSystemInfo, ELotteryType lotteryType, string contentImageUrl, int awardCount)
        {
            if (!string.IsNullOrEmpty(contentImageUrl))
            {
                return(PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, contentImageUrl)));
            }
            var fileName = awardCount + ".png";

            if (awardCount < 2 || awardCount > 9)
            {
                fileName = "contentAward.png";
            }
            var directoryName = "img" + ELotteryTypeUtils.GetValue(lotteryType);

            return(PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/lottery/{directoryName}/{fileName}")));
        }
Beispiel #8
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var winnerInfo = new LotteryWinnerInfo(e.Item.DataItem);

                var ltlItemIndex = e.Item.FindControl("ltlItemIndex") as Literal;
                var ltlAward     = e.Item.FindControl("ltlAward") as Literal;
                var ltlRealName  = e.Item.FindControl("ltlRealName") as Literal;
                var ltlMobile    = e.Item.FindControl("ltlMobile") as Literal;
                var ltlEmail     = e.Item.FindControl("ltlEmail") as Literal;
                var ltlAddress   = e.Item.FindControl("ltlAddress") as Literal;
                var ltlStatus    = e.Item.FindControl("ltlStatus") as Literal;
                var ltlAddDate   = e.Item.FindControl("ltlAddDate") as Literal;
                var ltlCashSN    = e.Item.FindControl("ltlCashSN") as Literal;
                var ltlCashDate  = e.Item.FindControl("ltlCashDate") as Literal;

                ltlItemIndex.Text = (e.Item.ItemIndex + 1).ToString();

                LotteryAwardInfo awardInfo = null;
                if (awardInfoMap.ContainsKey(winnerInfo.AwardID))
                {
                    awardInfo = awardInfoMap[winnerInfo.AwardID];
                }
                else
                {
                    awardInfo = DataProviderWX.LotteryAwardDAO.GetAwardInfo(winnerInfo.AwardID);
                    awardInfoMap.Add(winnerInfo.AwardID, awardInfo);
                }
                if (awardInfo != null)
                {
                    ltlAward.Text =
                        $@"<a href=""{GetRedirectUrl(PublishmentSystemID,
                            ELotteryTypeUtils.GetEnumType(winnerInfo.LotteryType), winnerInfo.LotteryID, winnerInfo.AwardID,
                            returnUrl)}"">{awardInfo.AwardName + ":" + awardInfo.Title}</a>";
                }

                ltlRealName.Text = winnerInfo.RealName;
                ltlMobile.Text   = winnerInfo.Mobile;
                ltlEmail.Text    = winnerInfo.Email;
                ltlAddress.Text  = winnerInfo.Address;
                ltlStatus.Text   = EWinStatusUtils.GetText(EWinStatusUtils.GetEnumType(winnerInfo.Status));
                ltlAddDate.Text  = DateUtils.GetDateAndTimeString(winnerInfo.AddDate);
                ltlCashSN.Text   = winnerInfo.CashSN;
                ltlCashDate.Text = DateUtils.GetDateAndTimeString(winnerInfo.CashDate);
            }
        }
Beispiel #9
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var lotteryType = ELotteryTypeUtils.GetEnumType(GetQueryString("lotteryType"));
                var lotteryID   = TranslateUtils.ToInt(GetQueryString("lotteryID"));

                var winnerInfoList = DataProviderWX.LotteryWinnerDAO.GetWinnerInfoList(PublishmentSystemID, lotteryType, lotteryID);

                if (winnerInfoList.Count == 0)
                {
                    FailMessage("暂无数据导出!");
                    return;
                }

                var docFileName = "获奖名单" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
                var filePath    = PathUtils.GetTemporaryFilesPath(docFileName);

                ExportLotteryCSV(filePath, winnerInfoList);

                var fileUrl = PageUtils.GetTemporaryFilesUrl(docFileName);
                SuccessMessage($@"成功导出文件,请点击 <a href=""{fileUrl}"">这里</a> 进行下载!");
            }
        }
Beispiel #10
0
        public List <LotteryWinnerInfo> GetWinnerInfoList(int publishmentSystemId, ELotteryType lotteryType, int lotteryId)
        {
            var winnerInfoList = new List <LotteryWinnerInfo>();

            string sqlWhere =
                $"WHERE {LotteryWinnerAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryId > 0)
            {
                sqlWhere =
                    $"WHERE {LotteryWinnerAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryWinnerAttribute.LotteryId} = {lotteryId}";
            }

            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, "ORDER BY ID DESC");

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var winnerInfo = new LotteryWinnerInfo(rdr);
                    winnerInfoList.Add(winnerInfo);
                }
                rdr.Close();
            }

            return(winnerInfoList);
        }
Beispiel #11
0
        public List <int> GetLotteryIDList(int publishmentSystemID, ELotteryType lotteryType)
        {
            var lotteryIDList = new List <int>();

            string SQL_WHERE =
                $"WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";
            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, LotteryAttribute.ID, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    lotteryIDList.Add(rdr.GetInt32(0));
                }
                rdr.Close();
            }

            return(lotteryIDList);
        }
Beispiel #12
0
        public string GetSelectString(int publishmentSystemID, ELotteryType lotteryType)
        {
            string whereString =
                $"WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            return(BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TABLE_NAME, SqlUtils.Asterisk, whereString));
        }
Beispiel #13
0
        public int GetFirstIDByKeywordID(int publishmentSystemID, ELotteryType lotteryType, int keywordID)
        {
            string sqlString =
                $"SELECT TOP 1 ID FROM {TABLE_NAME} WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}' AND {LotteryAttribute.IsDisabled} <> '{true}' AND {LotteryAttribute.KeywordID} = {keywordID}";

            return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString));
        }
Beispiel #14
0
        public List <LotteryInfo> GetLotteryInfoListByKeywordID(int publishmentSystemID, ELotteryType lotteryType, int keywordID)
        {
            var lotteryInfoList = new List <LotteryInfo>();

            string SQL_WHERE =
                $"WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}' AND {LotteryAttribute.IsDisabled} <> '{true}'";

            if (keywordID > 0)
            {
                SQL_WHERE += $" AND {LotteryAttribute.KeywordID} = {keywordID}";
            }
            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var lotteryInfo = new LotteryInfo(rdr);
                    lotteryInfoList.Add(lotteryInfo);
                }
                rdr.Close();
            }

            return(lotteryInfoList);
        }
Beispiel #15
0
        private static string GetLotteryUrl(PublishmentSystemInfo publishmentSystemInfo, LotteryInfo lotteryInfo)
        {
            var fileName = ELotteryTypeUtils.GetValue(ELotteryTypeUtils.GetEnumType(lotteryInfo.LotteryType)).ToLower();

            return(PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/lottery/{fileName}.html")));
        }
Beispiel #16
0
 public static string GetRedirectUrl(int publishmentSystemID, ELotteryType lotteryType)
 {
     return(PageUtils.GetWXUrl(
                $"background_lottery.aspx?PublishmentSystemID={publishmentSystemID}&lotteryType={ELotteryTypeUtils.GetValue(lotteryType)}"));
 }
Beispiel #17
0
        public string GetSelectString(int publishmentSystemID, ELotteryType lotteryType, int lotteryID, int awardID)
        {
            string whereString =
                $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryID > 0)
            {
                whereString =
                    $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID}";
            }
            if (awardID > 0)
            {
                whereString = $" AND {LotteryWinnerAttribute.AwardID} = {awardID}";
            }
            return(BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TABLE_NAME, SqlUtils.Asterisk, whereString));
        }
Beispiel #18
0
        public List <LotteryWinnerInfo> GetWinnerInfoList(int publishmentSystemID, ELotteryType lotteryType, int lotteryID)
        {
            var winnerInfoList = new List <LotteryWinnerInfo>();

            string SQL_WHERE =
                $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryID > 0)
            {
                SQL_WHERE =
                    $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID}";
            }

            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, "ORDER BY ID DESC");

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var winnerInfo = new LotteryWinnerInfo(rdr);
                    winnerInfoList.Add(winnerInfo);
                }
                rdr.Close();
            }

            return(winnerInfoList);
        }
Beispiel #19
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            lotteryType = ELotteryTypeUtils.GetEnumType(Request.QueryString["lotteryType"]);
            var lotteryName = ELotteryTypeUtils.GetText(lotteryType);

            if (!string.IsNullOrEmpty(Request.QueryString["Delete"]))
            {
                var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]);
                if (list.Count > 0)
                {
                    try
                    {
                        DataProviderWX.LotteryDAO.Delete(PublishmentSystemID, list);

                        SuccessMessage(lotteryName + "删除成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, lotteryName + "删除失败!");
                    }
                }
            }

            spContents.ControlToPaginate = rptContents;
            spContents.ItemsPerPage      = 30;
            spContents.ConnectionString  = BaiRongDataProvider.ConnectionString;
            spContents.SelectCommand     = DataProviderWX.LotteryDAO.GetSelectString(PublishmentSystemID, lotteryType);
            spContents.SortField         = LotteryAttribute.ID;
            spContents.SortMode          = SortMode.ASC;
            rptContents.ItemDataBound   += new RepeaterItemEventHandler(rptContents_ItemDataBound);

            if (!IsPostBack)
            {
                if (lotteryType == ELotteryType.Scratch)
                {
                    BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_Scratch, lotteryName, AppManager.WeiXin.Permission.WebSite.Scratch);
                }
                else if (lotteryType == ELotteryType.BigWheel)
                {
                    BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_BigWheel, lotteryName, AppManager.WeiXin.Permission.WebSite.BigWheel);
                }
                else if (lotteryType == ELotteryType.GoldEgg)
                {
                    BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_GoldEgg, lotteryName, AppManager.WeiXin.Permission.WebSite.GoldEgg);
                }
                else if (lotteryType == ELotteryType.Flap)
                {
                    BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_Flap, lotteryName, AppManager.WeiXin.Permission.WebSite.Flap);
                }
                else if (lotteryType == ELotteryType.YaoYao)
                {
                    BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_YaoYao, lotteryName, AppManager.WeiXin.Permission.WebSite.YaoYao);
                }

                spContents.DataBind();

                var urlAdd = string.Empty;
                if (lotteryType == ELotteryType.Scratch)
                {
                    urlAdd = BackgroundScratchAdd.GetRedirectUrl(PublishmentSystemID, 0);
                }
                else if (lotteryType == ELotteryType.BigWheel)
                {
                    urlAdd = BackgroundBigWheelAdd.GetRedirectUrl(PublishmentSystemID, 0);
                }
                else if (lotteryType == ELotteryType.GoldEgg)
                {
                    urlAdd = BackgroundGoldEggAdd.GetRedirectUrl(PublishmentSystemID, 0);
                }
                else if (lotteryType == ELotteryType.Flap)
                {
                    urlAdd = BackgroundFlapAdd.GetRedirectUrl(PublishmentSystemID, 0);
                }
                else if (lotteryType == ELotteryType.YaoYao)
                {
                    urlAdd = BackgroundYaoYaoAdd.GetRedirectUrl(PublishmentSystemID, 0);
                }
                btnAdd.Attributes.Add("onclick", $"location.href='{urlAdd}';return false");

                var urlDelete = PageUtils.AddQueryString(GetRedirectUrl(PublishmentSystemID, lotteryType), "Delete", "True");
                btnDelete.Attributes.Add("onclick", JsUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的" + lotteryName, "此操作将删除所选" + lotteryName + ",确认吗?"));
            }
        }
Beispiel #20
0
 public static string GetRedirectUrl(int publishmentSystemID, ELotteryType lotteryType, int lotteryID, int awardID, string returnUrl)
 {
     return(PageUtils.GetWXUrl(
                $"background_lotteryWinner.aspx?publishmentSystemID={publishmentSystemID}&lotteryType={ELotteryTypeUtils.GetValue(lotteryType)}&lotteryID={lotteryID}&awardID={awardID}&returnUrl={StringUtils.ValueToUrl(returnUrl)}"));
 }
Beispiel #21
0
        public int GetTotalNum(int publishmentSystemID, ELotteryType lotteryType, int lotteryID)
        {
            string sqlString =
                $"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryID > 0)
            {
                sqlString =
                    $"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID}";
            }

            return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString));
        }
Beispiel #22
0
        public List <LotteryInfo> GetLotteryInfoListByKeywordId(int publishmentSystemId, ELotteryType lotteryType, int keywordId)
        {
            var lotteryInfoList = new List <LotteryInfo>();

            string sqlWhere =
                $"WHERE {LotteryAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}' AND {LotteryAttribute.IsDisabled} <> '{true}'";

            if (keywordId > 0)
            {
                sqlWhere += $" AND {LotteryAttribute.KeywordId} = {keywordId}";
            }
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var lotteryInfo = new LotteryInfo(rdr);
                    lotteryInfoList.Add(lotteryInfo);
                }
                rdr.Close();
            }

            return(lotteryInfoList);
        }
Beispiel #23
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (phStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (phStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (phStep3.Visible)
                {
                    selectedStep = 3;
                }
                else if (phStep4.Visible)
                {
                    selectedStep = 4;
                }
                else if (phStep5.Visible)
                {
                    selectedStep = 5;
                }

                phStep1.Visible = phStep2.Visible = phStep3.Visible = phStep4.Visible = phStep5.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(tbKeywords.Text))
                    {
                        if (lotteryID > 0)
                        {
                            var lotteryInfo = DataProviderWX.LotteryDAO.GetLotteryInfo(lotteryID);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemID, lotteryInfo.KeywordID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        phStep1.Visible = true;
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    phStep3.Visible = true;
                }
                else if (selectedStep == 3)
                {
                    var isItemReady = true;

                    var awardMaxCount      = TranslateUtils.ToInt(tbAwardMaxCount.Text);
                    var awardMaxDailyCount = TranslateUtils.ToInt(tbAwardMaxDailyCount.Text);
                    if (awardMaxDailyCount > awardMaxCount)
                    {
                        FailMessage("摇摇乐保存失败,每人每天最多允许抽奖次数必须小于每人最多抽奖次数");
                        isItemReady = false;
                    }

                    if (isItemReady)
                    {
                        var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]);

                        if (itemCount < 1)
                        {
                            FailMessage("摇摇乐保存失败,至少需要设置一个奖项");
                            isItemReady = false;
                        }
                        else
                        {
                            var itemIDList      = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                            var awardNameList   = TranslateUtils.StringCollectionToStringList(Request.Form["itemAwardName"]);
                            var titleList       = TranslateUtils.StringCollectionToStringList(Request.Form["itemTitle"]);
                            var totalNumList    = TranslateUtils.StringCollectionToIntList(Request.Form["itemTotalNum"]);
                            var probabilityList = TranslateUtils.StringCollectionToDecimalList(Request.Form["itemProbability"]);

                            decimal probabilityAll = 0;

                            var awardInfoList = new List <LotteryAwardInfo>();
                            for (var i = 0; i < itemCount; i++)
                            {
                                var awardInfo = new LotteryAwardInfo {
                                    ID = itemIDList[i], PublishmentSystemID = PublishmentSystemID, LotteryID = lotteryID, AwardName = awardNameList[i], Title = titleList[i], TotalNum = totalNumList[i], Probability = probabilityList[i]
                                };

                                if (string.IsNullOrEmpty(awardInfo.AwardName))
                                {
                                    FailMessage("保存失败,奖项名称为必填项");
                                    isItemReady = false;
                                }
                                if (string.IsNullOrEmpty(awardInfo.Title))
                                {
                                    FailMessage("保存失败,奖品名为必填项");
                                    isItemReady = false;
                                }
                                if (awardInfo.Probability < 0 || awardInfo.Probability > 100)
                                {
                                    FailMessage("保存失败,各项中奖概率总和不能超过100%");
                                    isItemReady = false;
                                }

                                probabilityAll += awardInfo.Probability;

                                awardInfoList.Add(awardInfo);
                            }

                            if (probabilityAll <= 0 || probabilityAll > 100)
                            {
                                FailMessage("摇摇乐保存失败,获奖概率之和必须在1%到100%之间");
                                isItemReady = false;
                            }

                            if (isItemReady)
                            {
                                DataProviderWX.LotteryAwardDAO.DeleteAllNotInIDList(PublishmentSystemID, lotteryID, itemIDList);

                                foreach (var awardInfo in awardInfoList)
                                {
                                    var newAwardInfo = DataProviderWX.LotteryAwardDAO.GetAwardInfo(awardInfo.ID);
                                    if (awardInfo.ID > 0)
                                    {
                                        var wonNum = DataProviderWX.LotteryWinnerDAO.GetTotalNum(awardInfo.ID);
                                        if (awardInfo.TotalNum < wonNum)
                                        {
                                            awardInfo.TotalNum = wonNum;
                                        }
                                        awardInfo.WonNum = newAwardInfo.WonNum;
                                        DataProviderWX.LotteryAwardDAO.Update(awardInfo);
                                    }
                                    else
                                    {
                                        DataProviderWX.LotteryAwardDAO.Insert(awardInfo);
                                    }
                                }
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        phStep4.Visible = true;
                    }
                    else
                    {
                        phStep3.Visible = true;
                    }
                }
                else if (selectedStep == 4)
                {
                    phStep5.Visible = true;
                    btnSubmit.Text  = "确 认";
                }
                else if (selectedStep == 5)
                {
                    var lotteryInfo = new LotteryInfo();
                    if (lotteryID > 0)
                    {
                        lotteryInfo = DataProviderWX.LotteryDAO.GetLotteryInfo(lotteryID);
                    }
                    lotteryInfo.PublishmentSystemID = PublishmentSystemID;
                    lotteryInfo.LotteryType         = ELotteryTypeUtils.GetValue(ELotteryType.YaoYao);

                    lotteryInfo.KeywordID  = DataProviderWX.KeywordDAO.GetKeywordID(PublishmentSystemID, lotteryID > 0, tbKeywords.Text, EKeywordType.YaoYao, lotteryInfo.KeywordID);
                    lotteryInfo.IsDisabled = !cbIsEnabled.Checked;

                    lotteryInfo.StartDate       = dtbStartDate.DateTime;
                    lotteryInfo.EndDate         = dtbEndDate.DateTime;
                    lotteryInfo.Title           = PageUtils.FilterXSS(tbTitle.Text);
                    lotteryInfo.ImageUrl        = imageUrl.Value;;
                    lotteryInfo.Summary         = tbSummary.Text;
                    lotteryInfo.ContentImageUrl = contentImageUrl.Value;
                    lotteryInfo.ContentUsage    = tbContentUsage.Text;

                    lotteryInfo.AwardUsage         = tbAwardUsage.Text;
                    lotteryInfo.IsAwardTotalNum    = cbIsAwardTotalNum.Checked;
                    lotteryInfo.AwardMaxCount      = TranslateUtils.ToInt(tbAwardMaxCount.Text);
                    lotteryInfo.AwardMaxDailyCount = TranslateUtils.ToInt(tbAwardMaxDailyCount.Text);
                    lotteryInfo.AwardCode          = tbAwardCode.Text;
                    lotteryInfo.AwardImageUrl      = awardImageUrl.Value;

                    lotteryInfo.IsFormRealName    = cbIsFormRealName.Checked;
                    lotteryInfo.FormRealNameTitle = tbFormRealNameTitle.Text;
                    lotteryInfo.IsFormMobile      = cbIsFormMobile.Checked;
                    lotteryInfo.FormMobileTitle   = tbFormMobileTitle.Text;
                    lotteryInfo.IsFormEmail       = cbIsFormEmail.Checked;
                    lotteryInfo.FormEmailTitle    = tbFormEmailTitle.Text;
                    lotteryInfo.IsFormAddress     = cbIsFormAddress.Checked;
                    lotteryInfo.FormAddressTitle  = tbFormAddressTitle.Text;

                    lotteryInfo.EndTitle    = tbEndTitle.Text;
                    lotteryInfo.EndImageUrl = endImageUrl.Value;
                    lotteryInfo.EndSummary  = tbEndSummary.Text;

                    try
                    {
                        if (lotteryID > 0)
                        {
                            DataProviderWX.LotteryDAO.Update(lotteryInfo);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "修改摇摇乐",
                                            $"摇摇乐:{tbTitle.Text}");
                            SuccessMessage("修改摇摇乐成功!");
                        }
                        else
                        {
                            lotteryID = DataProviderWX.LotteryDAO.Insert(lotteryInfo);

                            DataProviderWX.LotteryAwardDAO.UpdateLotteryID(PublishmentSystemID, lotteryID);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "添加摇摇乐",
                                            $"摇摇乐:{tbTitle.Text}");
                            SuccessMessage("添加摇摇乐成功!");
                        }

                        var redirectUrl = BackgroundLottery.GetRedirectUrl(PublishmentSystemID, ELotteryType.YaoYao);
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "摇摇乐设置失败!");
                    }
                }
            }
        }
Beispiel #24
0
        public List <int> GetLotteryIdList(int publishmentSystemId, ELotteryType lotteryType)
        {
            var lotteryIdList = new List <int>();

            string sqlWhere =
                $"WHERE {LotteryAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, LotteryAttribute.Id, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    lotteryIdList.Add(rdr.GetInt32(0));
                }
                rdr.Close();
            }

            return(lotteryIdList);
        }