Пример #1
0
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int num = 0;

            int.TryParse(e.CommandArgument.ToString(), out num);
            if (num > 0)
            {
                string commandName = e.CommandName;
                string str         = commandName;
                if (commandName != null)
                {
                    if (str != "send")
                    {
                        return;
                    }
                    SendRedpackRecordInfo sendRedpackRecordByID = DistributorsBrower.GetSendRedpackRecordByID(num);
                    if (sendRedpackRecordByID != null)
                    {
                        string str1 = this.SendRedPack(sendRedpackRecordByID.OpenID, "", sendRedpackRecordByID.Wishing, sendRedpackRecordByID.ActName, "分销商发红包提现", sendRedpackRecordByID.Amount, num, sendRedpackRecordByID.IsSend);
                        if (str1 == "1")
                        {
                            DistributorsBrower.SetRedpackRecordIsUsed(num, true);
                            int     amount = sendRedpackRecordByID.Amount;
                            decimal num1   = decimal.Parse(amount.ToString()) / new decimal(100);
                            VShopHelper.UpdateBalanceDistributors(sendRedpackRecordByID.UserID, num1);
                            this.AAbiuZJB(false);
                            return;
                        }
                        this.ShowMsg(string.Concat("发送失败,原因是:", str1), false);
                    }
                }
            }
        }
Пример #2
0
        private void WeiRedPack_Click(object sender, System.EventArgs e)
        {
            int     num = Globals.ToNum(this.HiddenSid.Value);
            decimal d   = decimal.Parse(this.hdreferralblance.Value);

            if (d > 200m)
            {
                this.ShowMsg("红包金额大于200,无法发放!", false);
                return;
            }
            string text = DistributorsBrower.SendRedPackToBalanceDrawRequest(num);

            if (text != "1" && text != "-1")
            {
                this.ShowMsg("生成红包失败,原因是:" + text, false);
                return;
            }
            if (!(text == "1") && !(text == "-1"))
            {
                this.ShowMsg("发送失败0!", false);
                return;
            }
            SendRedpackRecordInfo sendRedpackRecordByID = DistributorsBrower.GetSendRedpackRecordByID(null, num.ToString());

            if (sendRedpackRecordByID == null)
            {
                this.ShowMsg("发送失败" + num + "!", false);
                return;
            }
            if (sendRedpackRecordByID.IsSend)
            {
                this.ShowMsg("当前红包已是发送状态:请检查原因!", false);
                return;
            }
            text = this.SendRedPack(sendRedpackRecordByID.OpenID, "", sendRedpackRecordByID.Wishing, sendRedpackRecordByID.ActName, "分销商发红包提现", sendRedpackRecordByID.Amount, sendRedpackRecordByID.ID);
            if (text == "1")
            {
                DistributorsBrower.SetRedpackRecordIsUsed(sendRedpackRecordByID.ID, true);
                decimal num2 = decimal.Parse(sendRedpackRecordByID.Amount.ToString()) / 100m;
                VShopHelper.UpdateBalanceDistributors(sendRedpackRecordByID.UserID, num2);
                if (num2 > 0m)
                {
                    BalanceDrawRequestInfo balanceDrawRequestById = DistributorsBrower.GetBalanceDrawRequestById(num.ToString());
                    if (balanceDrawRequestById != null)
                    {
                        Messenger.SendWeiXinMsg_DrawCashRelease(balanceDrawRequestById);
                    }
                }
                this.ShowMsg("红包发送成功!", true);
                this.LoadParameters();
                this.BindData();
                return;
            }
            this.ShowMsg("发送失败,原因是:" + text, false);
        }
Пример #3
0
        private void WeiRedPack_Click(object sender, EventArgs e)
        {
            int serialid = Globals.ToNum(this.HiddenSid.Value);

            if (decimal.Parse(this.hdreferralblance.Value) > 200M)
            {
                this.ShowMsg("红包金额大于200,无法发放!", false);
            }
            else
            {
                string str = DistributorsBrower.SendRedPackToBalanceDrawRequest(serialid, wid);
                if ((str != "1") && (str != "-1"))
                {
                    this.ShowMsg("生成红包失败,原因是:" + str, false);
                }
                else if ((str == "1") || (str == "-1"))
                {
                    SendRedpackRecordInfo sendRedpackRecordByID = DistributorsBrower.GetSendRedpackRecordByID(null, serialid.ToString());
                    if (sendRedpackRecordByID != null)
                    {
                        if (sendRedpackRecordByID.IsSend)
                        {
                            this.ShowMsg("当前红包已是发送状态:请检查原因!", false);
                        }
                        else
                        {
                            str = this.SendRedPack(sendRedpackRecordByID.OpenID, "", sendRedpackRecordByID.Wishing, sendRedpackRecordByID.ActName, "分销商发红包提现", sendRedpackRecordByID.Amount, sendRedpackRecordByID.ID);
                            if (str == "1")
                            {
                                DistributorsBrower.SetRedpackRecordIsUsed(sendRedpackRecordByID.ID, true);
                                decimal referralRequestBalance = decimal.Parse(sendRedpackRecordByID.Amount.ToString()) / 100M;
                                VShopHelper.UpdateBalanceDistributors(sendRedpackRecordByID.UserID, referralRequestBalance);
                                this.ReBind(false);
                            }
                            else
                            {
                                this.ShowMsg("发送失败,原因是:" + str, false);
                            }
                        }
                    }
                    else
                    {
                        this.ShowMsg("发送失败" + serialid + "!", false);
                    }
                }
                else
                {
                    this.ShowMsg("发送失败0!", false);
                }
            }
        }
Пример #4
0
        public SendRedpackRecordInfo GetSendRedpackRecordByID(string id = null, string sid = null)
        {
            SendRedpackRecordInfo result;

            if (id == null && sid == null)
            {
                result = null;
            }
            else
            {
                SendRedpackRecordInfo sendRedpackRecordInfo = null;
                string empty = string.Empty;
                int    num   = 0;
                string query;
                if (id != null)
                {
                    if (!int.TryParse(id, out num))
                    {
                        result = null;
                        return(result);
                    }
                    query = string.Format("select * FROM vshop_SendRedpackRecord WHERE ID={0}", id);
                }
                else
                {
                    if (!int.TryParse(sid, out num))
                    {
                        result = null;
                        return(result);
                    }
                    query = string.Format("select * FROM vshop_SendRedpackRecord WHERE BalanceDrawRequestID={0}", sid);
                }
                System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
                using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
                {
                    if (dataReader.Read())
                    {
                        sendRedpackRecordInfo = DataMapper.PopulateSendRedpackRecordInfo(dataReader);
                    }
                }
                result = sendRedpackRecordInfo;
            }
            return(result);
        }
Пример #5
0
        public bool AddSendRedpackRecord(SendRedpackRecordInfo sendredpackinfo, DbTransaction dbTran)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("insert into vshop_SendRedpackRecord(BalanceDrawRequestID,UserID,OpenID,Amount,ActName,Wishing,ClientIP,IsSend,SendTime)values(@BalanceDrawRequestID,@UserID,@OpenID,@Amount,@ActName,@Wishing,@ClientIP,@IsSend,@SendTime)");

            this.database.AddInParameter(sqlStringCommand, "BalanceDrawRequestID", DbType.Int32, sendredpackinfo.BalanceDrawRequestID);
            this.database.AddInParameter(sqlStringCommand, "UserID", DbType.Int32, sendredpackinfo.UserID);
            this.database.AddInParameter(sqlStringCommand, "OpenID", DbType.String, sendredpackinfo.OpenID);
            this.database.AddInParameter(sqlStringCommand, "Amount", DbType.Int32, sendredpackinfo.Amount);
            this.database.AddInParameter(sqlStringCommand, "ActName", DbType.String, sendredpackinfo.ActName);
            this.database.AddInParameter(sqlStringCommand, "Wishing", DbType.String, sendredpackinfo.Wishing);
            this.database.AddInParameter(sqlStringCommand, "ClientIP", DbType.String, sendredpackinfo.ClientIP);
            this.database.AddInParameter(sqlStringCommand, "IsSend", DbType.Int32, 0);
            this.database.AddInParameter(sqlStringCommand, "SendTime", DbType.DateTime, DBNull.Value);
            if (dbTran != null)
            {
                return(this.database.ExecuteNonQuery(sqlStringCommand, dbTran) > 0);
            }
            return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }
Пример #6
0
        public bool SetRedpackRecordIsUsed(int id, bool issend)
        {
            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE vshop_SendRedpackRecord set IsSend=@IsSend,SendTime=getdate() where ID=@ID");
            this.database.AddInParameter(sqlStringCommand, "ID", System.Data.DbType.Int32, id);
            this.database.AddInParameter(sqlStringCommand, "IsSend", System.Data.DbType.Boolean, issend);
            bool flag = this.database.ExecuteNonQuery(sqlStringCommand) > 0;

            if (flag)
            {
                SendRedpackRecordInfo sendRedpackRecordByID = this.GetSendRedpackRecordByID(id.ToString(), null);
                if (sendRedpackRecordByID != null)
                {
                    string query = string.Format("update Hishop_BalanceDrawRequest set IsCheck=2,CheckTime=getdate(), Remark='红包提现记录' where SerialID={0} and IsCheck=1 and not exists(select id from vshop_SendRedpackRecord a where a.IsSend=0 and a.BalanceDrawRequestID={0}) and exists(select id from vshop_SendRedpackRecord a where a.IsSend=1 and a.BalanceDrawRequestID={0})", sendRedpackRecordByID.BalanceDrawRequestID);
                    sqlStringCommand = this.database.GetSqlStringCommand(query);
                    this.database.ExecuteNonQuery(sqlStringCommand);
                }
            }
            return(flag);
        }
Пример #7
0
        public SendRedpackRecordInfo GetSendRedpackRecordByID(int id)
        {
            if (id <= 0)
            {
                return(null);
            }
            SendRedpackRecordInfo info = null;
            string    query            = string.Format("select * FROM vshop_SendRedpackRecord WHERE ID={0}", id);
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateSendRedpackRecordInfo(reader);
                }
            }
            return(info);
        }
Пример #8
0
        public SendRedpackRecordInfo GetSendRedpackRecordByID([Optional, DefaultParameterValue(null)] string id, [Optional, DefaultParameterValue(null)] string sid)
        {
            if ((id == null) && (sid == null))
            {
                return(null);
            }
            SendRedpackRecordInfo info = null;
            string query  = "";
            int    result = 0;

            if (id != null)
            {
                if (!int.TryParse(id, out result))
                {
                    return(null);
                }
                query = string.Format("select * FROM vshop_SendRedpackRecord WHERE ID={0}", id);
            }
            else
            {
                if (!int.TryParse(sid, out result))
                {
                    return(null);
                }
                query = string.Format("select * FROM vshop_SendRedpackRecord WHERE BalanceDrawRequestID={0}", sid);
            }
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateSendRedpackRecordInfo(reader);
                }
            }
            return(info);
        }
Пример #9
0
        public static SendRedpackRecordInfo PopulateSendRedpackRecordInfo(IDataReader reader)
        {
            if (reader == null)
            {
                return(null);
            }
            SendRedpackRecordInfo info = new SendRedpackRecordInfo {
                ID = (int)reader["ID"],
                BalanceDrawRequestID = (int)reader["BalanceDrawRequestID"],
                UserID   = (int)reader["UserID"],
                OpenID   = (string)reader["OpenID"],
                Amount   = (int)reader["Amount"],
                ActName  = (string)reader["ActName"],
                Wishing  = (string)reader["Wishing"],
                ClientIP = (string)reader["ClientIP"],
                IsSend   = (bool)reader["IsSend"]
            };

            if (reader["SendTime"] != DBNull.Value)
            {
                info.SendTime = (DateTime)reader["SendTime"];
            }
            return(info);
        }
Пример #10
0
        public bool CreateSendRedpackRecord(int serialid, int userid, string openid, int amount, string act_name, string wishing)
        {
            bool flag = true;
            int  num  = 0x4e20;
            int  num2 = amount;
            SendRedpackRecordInfo sendredpackinfo = new SendRedpackRecordInfo {
                BalanceDrawRequestID = serialid,
                UserID   = userid,
                OpenID   = openid,
                ActName  = act_name,
                Wishing  = wishing,
                ClientIP = Globals.IPAddress
            };

            using (DbConnection connection = this.database.CreateConnection())
            {
                connection.Open();
                DbTransaction        dbTran = connection.BeginTransaction();
                SendRedpackRecordDao dao    = new SendRedpackRecordDao();

                try
                {
                    if (num2 <= num)
                    {
                        sendredpackinfo.Amount = amount;
                        flag = dao.AddSendRedpackRecord(sendredpackinfo, dbTran);
                        return(this.UpdateSendRedpackRecord(serialid, 1, dbTran));
                    }
                    int num3 = amount % num;
                    int num4 = amount / num;
                    if (num3 > 0)
                    {
                        sendredpackinfo.Amount = num3;
                        flag = dao.AddSendRedpackRecord(sendredpackinfo, dbTran);
                    }
                    if (flag)
                    {
                        for (int i = 0; i < num4; i++)
                        {
                            sendredpackinfo.Amount = num;
                            flag = dao.AddSendRedpackRecord(sendredpackinfo, dbTran);
                            if (!flag)
                            {
                                dbTran.Rollback();
                            }
                        }
                        int num6 = num4 + ((num3 > 0) ? 1 : 0);
                        flag = this.UpdateSendRedpackRecord(serialid, num6, dbTran);
                        if (!flag)
                        {
                            dbTran.Rollback();
                        }
                        return(flag);
                    }
                    dbTran.Rollback();
                    return(flag);
                }
                catch
                {
                    if (dbTran.Connection != null)
                    {
                        dbTran.Rollback();
                    }
                    flag = false;
                }
                finally
                {
                    if (flag)
                    {
                        dbTran.Commit();
                    }
                    connection.Close();
                }
            }

            return(flag);
        }
Пример #11
0
        public bool CreateSendRedpackRecord(int serialid, int userid, string openid, int amount, string act_name, string wishing)
        {
            bool flag = true;
            int  num  = 20000;
            SendRedpackRecordInfo sendRedpackRecordInfo = new SendRedpackRecordInfo();

            sendRedpackRecordInfo.BalanceDrawRequestID = serialid;
            sendRedpackRecordInfo.UserID   = userid;
            sendRedpackRecordInfo.OpenID   = openid;
            sendRedpackRecordInfo.ActName  = act_name;
            sendRedpackRecordInfo.Wishing  = wishing;
            sendRedpackRecordInfo.ClientIP = Globals.IPAddress;
            using (System.Data.Common.DbConnection dbConnection = this.database.CreateConnection())
            {
                dbConnection.Open();
                System.Data.Common.DbTransaction dbTransaction        = dbConnection.BeginTransaction();
                SendRedpackRecordDao             sendRedpackRecordDao = new SendRedpackRecordDao();
                try
                {
                    if (amount <= num)
                    {
                        sendRedpackRecordInfo.Amount = amount;
                        flag = sendRedpackRecordDao.AddSendRedpackRecord(sendRedpackRecordInfo, dbTransaction);
                    }
                    else
                    {
                        int num2 = amount % num;
                        int num3 = amount / num;
                        if (num2 > 0)
                        {
                            sendRedpackRecordInfo.Amount = num2;
                            flag = sendRedpackRecordDao.AddSendRedpackRecord(sendRedpackRecordInfo, dbTransaction);
                        }
                        if (flag)
                        {
                            for (int i = 0; i < num3; i++)
                            {
                                sendRedpackRecordInfo.Amount = num;
                                flag = sendRedpackRecordDao.AddSendRedpackRecord(sendRedpackRecordInfo, dbTransaction);
                                if (!flag)
                                {
                                    dbTransaction.Rollback();
                                }
                            }
                            int num4 = num3 + ((num2 > 0) ? 1 : 0);
                            if (!flag)
                            {
                                dbTransaction.Rollback();
                            }
                        }
                        else
                        {
                            dbTransaction.Rollback();
                        }
                    }
                }
                catch
                {
                    if (dbTransaction.Connection != null)
                    {
                        dbTransaction.Rollback();
                    }
                    flag = false;
                }
                finally
                {
                    if (flag)
                    {
                        dbTransaction.Commit();
                    }
                    dbConnection.Close();
                }
            }
            return(flag);
        }