Exemplo n.º 1
0
        public void UpdateStatus(EWinStatus status, List <int> winnerIDList)
        {
            string sqlString =
                $"UPDATE {TABLE_NAME} SET {LotteryWinnerAttribute.Status} = '{EWinStatusUtils.GetValue(status)}' WHERE ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(winnerIDList)})";

            if (status == EWinStatus.Cashed)
            {
                sqlString =
                    $"UPDATE {TABLE_NAME} SET {LotteryWinnerAttribute.Status} = '{EWinStatusUtils.GetValue(status)}', {LotteryWinnerAttribute.CashDate} = getdate() WHERE ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(winnerIDList)})";
            }

            ExecuteNonQuery(sqlString);
        }
Exemplo n.º 2
0
        public static void AddApplication(int winnerID, string realName, string mobile, string email, string address)
        {
            var winnerInfo = DataProviderWx.LotteryWinnerDao.GetWinnerInfo(winnerID);

            var oldCashSN = winnerInfo.CashSn;

            winnerInfo.RealName = realName;
            winnerInfo.Mobile   = mobile;
            winnerInfo.Email    = email;
            winnerInfo.Address  = address;
            winnerInfo.Status   = EWinStatusUtils.GetValue(EWinStatus.Applied);
            winnerInfo.CashSn   = StringUtils.GetShortGuid(true);

            if (string.IsNullOrEmpty(oldCashSN))
            {
                DataProviderWx.LotteryWinnerDao.Update(winnerInfo);
            }
        }
Exemplo n.º 3
0
        public int GetCashNum(int publishmentSystemID, int lotteryID)
        {
            string sqlString =
                $"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID} AND {LotteryWinnerAttribute.Status} = '{EWinStatusUtils.GetValue(EWinStatus.Cashed)}'";

            return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString));
        }
Exemplo n.º 4
0
        public static bool Lottery(LotteryInfo lotteryInfo, List <LotteryAwardInfo> awardInfoList, string cookieSN, string wxOpenID, out LotteryAwardInfo awardInfo, out LotteryWinnerInfo winnerInfo, string userName, out string errorMessage)
        {
            errorMessage = string.Empty;

            awardInfo  = null;
            winnerInfo = DataProviderWx.LotteryWinnerDao.GetWinnerInfo(lotteryInfo.PublishmentSystemId, lotteryInfo.Id, cookieSN, wxOpenID, userName);
            if (winnerInfo != null)
            {
                awardInfo = GetAwardInfo(awardInfoList, winnerInfo.AwardId);
            }
            else
            {
                var isMaxCount      = false;
                var isMaxDailyCount = false;

                DataProviderWx.LotteryLogDao.AddCount(lotteryInfo.PublishmentSystemId, lotteryInfo.Id, cookieSN, wxOpenID, userName, lotteryInfo.AwardMaxCount, lotteryInfo.AwardMaxDailyCount, out isMaxCount, out isMaxDailyCount);

                if (isMaxCount)
                {
                    errorMessage = $"对不起,每人最多允许抽奖{lotteryInfo.AwardMaxCount}次";
                    return(false);
                }
                else if (isMaxDailyCount)
                {
                    errorMessage = $"对不起,每人每天最多允许抽奖{lotteryInfo.AwardMaxDailyCount}次";
                    return(false);
                }
                else
                {
                    if (awardInfoList != null && awardInfoList.Count > 0)
                    {
                        var idWithProbabilityDictionary = new Dictionary <int, decimal>();
                        foreach (var lotteryAwardInfo in awardInfoList)
                        {
                            idWithProbabilityDictionary.Add(lotteryAwardInfo.Id, lotteryAwardInfo.Probability);
                        }

                        var awardID = WeiXinManager.Lottery(idWithProbabilityDictionary);
                        if (awardID > 0)
                        {
                            var lotteryAwardInfo = GetAwardInfo(awardInfoList, awardID);

                            if (lotteryAwardInfo != null && lotteryAwardInfo.TotalNum > 0)
                            {
                                var wonNum = DataProviderWx.LotteryWinnerDao.GetTotalNum(awardID);
                                if (lotteryAwardInfo.TotalNum > wonNum)
                                {
                                    awardInfo  = lotteryAwardInfo;
                                    winnerInfo = new LotteryWinnerInfo {
                                        PublishmentSystemId = lotteryInfo.PublishmentSystemId, LotteryType = lotteryInfo.LotteryType, LotteryId = lotteryInfo.Id, AwardId = awardID, Status = EWinStatusUtils.GetValue(EWinStatus.Won), CookieSn = cookieSN, WxOpenId = wxOpenID, UserName = userName, AddDate = DateTime.Now
                                    };
                                    winnerInfo.Id = DataProviderWx.LotteryWinnerDao.Insert(winnerInfo);

                                    DataProviderWx.LotteryAwardDao.UpdateWonNum(awardID);

                                    DataProviderWx.LotteryDao.AddUserCount(winnerInfo.LotteryId);
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }