Exemple #1
0
        /// <summary>
        /// 当日应该返还 的总额,预估,更新数据库的
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public double Fa10Precent_YuGu(DateTime date)
        {
            DAL.UserinfoDAL         udal     = new UserinfoDAL();
            DAL.LiushuiDAL          lsdal    = new LiushuiDAL();
            DAL.ShuxingDAL          sxdal    = new ShuxingDAL();
            double                  baifenbi = double.Parse(sxdal.GetModelByCond($"sxname='零点返还'").sxvalue); //返还百分比,取出来的是还没有除以100的
            List <Model.Xiazhuinfo> list     = GetListArray($"kjcode<>'' and createtime>='{date.ToString("yyyy-MM-dd 00:00:00")}' and createtime<='{date.ToString("yyyy-MM-dd 23:59:59")}'");
            double                  res      = 0;
            var query = list.GroupBy(a => a.userid);

            foreach (var item in query)
            {
                int            userid = item.Key;
                Model.Userinfo u      = udal.GetModel(userid);
                if (u == null)
                {
                    continue;
                }
                var    u_xz       = list.Where(a => a.userid == userid); //该用户在该日的跟单
                double zhongjiang = 0;                                   //中奖金额,以下注金额来算
                double weizhong   = 0;                                   //末中金额
                double fanhuan    = 0;                                   //返还的金额

                foreach (var xz in u_xz)
                {
                    if (xz.iszj == 0 && xz.buycode.Contains("专家版"))
                    {
                        //未中奖
                        weizhong += xz.buymoney;
                    }
                    else if (xz.iszj == 1)
                    {
                        //已中奖,只算中奖的,特殊号都不含 在里面
                        zhongjiang += xz.buymoney;
                    }
                }

                if (weizhong - zhongjiang > 0)
                {
                    fanhuan = (weizhong - zhongjiang) * (baifenbi / 100);
                }

                res += fanhuan;
            }
            return(res);
        }
Exemple #2
0
        /// <summary>
        /// 撤销跟单
        /// </summary>
        /// <param name="xzid"></param>
        /// <returns></returns>
        public string Cancel(int xzid, string remark, bool updatedb = true, string czr = "")
        {
            string str = "";

            Model.Xiazhuinfo xz = GetModel(xzid);
            if (xz == null)
            {
                return($"该跟单【{xzid}】不存在!");
            }
            if (xz.iszj == 3)
            {
                return($"该单【{xzid}】已撤销过,不准再次撤销");
            }
            DAL.UserinfoDAL udal  = new UserinfoDAL();
            DAL.LiushuiDAL  lsdal = new LiushuiDAL();
            Model.Userinfo  u     = udal.GetModel(xz.userid);
            if (string.IsNullOrEmpty(xz.kjcode))
            {
                #region 未开奖撤销
                double totalmoney = xz.buymoney + xz.shouxufee;

                double beforemoney = u.balance;
                str = $"撤销跟单【{xz.id}】,返还用户【{u.id} {u.username}】金额【{totalmoney}】({xz.buymoney} + {xz.shouxufee})";


                if (updatedb)
                {
                    xz.iszj   = 3;
                    xz.remark = "后台撤销 " + remark;
                    Update(xz);


                    u.balance += totalmoney;
                    udal.Update(u);

                    lsdal.Add(new Model.Liushui()
                    {
                        remark      = str,
                        userid      = u.id,
                        username    = u.username,
                        beforemoney = beforemoney,
                        changemoney = totalmoney,
                        aftermoney  = u.balance,
                        createtime  = DateTime.Now,
                        type        = 3,
                        xzid        = xz.id,
                        czr         = czr,
                    });
                }
                #endregion
            }
            else
            {
                if (xz.iszj == 0)
                {
                    #region 已开奖未中奖

                    double totalmoney = xz.buymoney + xz.shouxufee;

                    double beforemoney = u.balance;
                    str = $"撤销跟单【{xz.id}】,返还用户【{u.id} {u.username}】金额【{totalmoney}】({xz.buymoney} + {xz.shouxufee})";

                    if (updatedb)
                    {
                        xz.iszj   = 3;
                        xz.remark = "后台撤销 " + remark;
                        Update(xz);

                        u.balance += totalmoney;
                        udal.Update(u);

                        lsdal.Add(new Model.Liushui()
                        {
                            remark      = str,
                            userid      = u.id,
                            username    = u.username,
                            beforemoney = beforemoney,
                            changemoney = totalmoney,
                            aftermoney  = u.balance,
                            createtime  = DateTime.Now,
                            type        = 3,
                            xzid        = xz.id,
                            czr         = czr,
                        });
                    }


                    #endregion
                }
                else if (xz.iszj == 1)
                {
                    #region 已开奖已中奖

                    //例:下注2000,手续60,中奖,得4000, 那撤销应该是 余额 - 4000 + 2000 + 60
                    double totalmoney = -xz.zjmoney + (xz.buymoney + xz.shouxufee);

                    double beforemoney = u.balance;
                    str = $"撤销跟单【{xz.id}】,返还用户【{u.id} {u.username}】金额【{totalmoney}】(-{xz.zjmoney} + {xz.buymoney} +{xz.shouxufee})";


                    if (updatedb)
                    {
                        xz.iszj   = 3;
                        xz.remark = "后台撤销 " + remark;
                        Update(xz);


                        u.balance += totalmoney;
                        udal.Update(u);

                        lsdal.Add(new Model.Liushui()
                        {
                            remark      = str,
                            userid      = u.id,
                            username    = u.username,
                            beforemoney = beforemoney,
                            changemoney = totalmoney,
                            aftermoney  = u.balance,
                            createtime  = DateTime.Now,
                            type        = 3,
                            xzid        = xz.id,
                            czr         = czr,
                        });
                    }

                    #endregion
                }
                else if (xz.iszj == 2)
                {
                    #region 已开奖中特殊号

                    double totalmoney = -xz.zjmoney + xz.buymoney + xz.shouxufee;

                    double beforemoney = u.balance;

                    str = $"撤销跟单【{xz.id}】,返还用户【{u.id} {u.username}】金额【{totalmoney}】(-{xz.zjmoney} + {xz.buymoney} +{xz.shouxufee})";


                    if (updatedb)
                    {
                        xz.iszj   = 3;
                        xz.remark = "后台撤销 " + remark;
                        Update(xz);

                        u.balance += totalmoney;
                        udal.Update(u);

                        lsdal.Add(new Model.Liushui()
                        {
                            remark      = str,
                            userid      = u.id,
                            username    = u.username,
                            beforemoney = beforemoney,
                            changemoney = totalmoney,
                            aftermoney  = u.balance,
                            createtime  = DateTime.Now,
                            type        = 3,
                            xzid        = xz.id,
                            czr         = czr,
                        });
                    }

                    #endregion
                }
            }
            return(str);
        }
Exemple #3
0
        /// <summary>
        /// 每日0:00返还10%的不中奖金额
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public string Fa10Percent(int userid, DateTime startdate, DateTime enddate, bool insertdb = true, string czr = "")
        {
            DAL.UserinfoDAL udal  = new UserinfoDAL();
            DAL.LiushuiDAL  lsdal = new LiushuiDAL();
            DAL.ShuxingDAL  sxdal = new ShuxingDAL();

            Model.Userinfo u = udal.GetModel(userid);
            if (u == null)
            {
                return("无此用户");
            }

            StringBuilder sb       = new StringBuilder();
            double        baifenbi = double.Parse(sxdal.GetModelByCond($"sxname='零点返还'").sxvalue); //返还百分比,取出来的是还没有除以100的

            while (startdate <= enddate)
            {
                #region 反还startdate当天的
                List <Model.Xiazhuinfo> list = GetListArray($"userid={userid} and iszj in (0,1,2) and kjcode<>'' and createtime>='{startdate.ToString("yyyy-MM-dd 00:00:00")}' and createtime<='{startdate.ToString("yyyy-MM-dd 23:59:59")}'"); //该用户在该日的跟单


                double zhongjiang = 0; //中奖金额,以下注金额来算
                double weizhong   = 0; //末中金额
                double fanhuan    = 0; //返还的金额

                foreach (var xz in list)
                {
                    if (xz.iszj == 0 && xz.buycode.Contains("专家版"))
                    {
                        //未中奖
                        weizhong += xz.buymoney;
                    }
                    else if (xz.iszj == 1)
                    {
                        //已中奖,只算中奖的,特殊号都不含 在里面
                        zhongjiang += xz.buymoney;
                    }
                }

                if (weizhong - zhongjiang > 0)
                {
                    fanhuan = (weizhong - zhongjiang) * (baifenbi / 100);
                }

                string remark = $"用户【{u.id} {u.username}】在 {startdate.ToString("yyyy-MM-dd 00:00:00")} ~ {startdate.ToString("yyyy-MM-dd 23:59:59")} 共跟单【{list.Count()}】次,专家版中奖金额【{zhongjiang}】,专家版+大小单双版未中金额【{weizhong}】,应返还:【({weizhong} - {zhongjiang})*{baifenbi}% = {fanhuan}】<br />\r\n";

                if (fanhuan > 0 && insertdb)
                {
                    //查type=2 and remark like '%%'没有才插
                    int x = lsdal.CalcCount($"type=2 and userid={u.id} and fhdate='{startdate.ToString("yyyy-MM-dd")}'");
                    if (x == 0)
                    {
                        double beforemoney = u.balance;
                        u.balance += fanhuan;
                        udal.Update(u);

                        lsdal.Add(new Model.Liushui()
                        {
                            type = 2, remark = remark, beforemoney = beforemoney, changemoney = fanhuan, aftermoney = u.balance, createtime = DateTime.Now, userid = u.id, username = u.username, fhdate = startdate.ToString("yyyy-MM-dd"), czr = czr
                        });
                    }
                }

                sb.Append(remark);

                #endregion

                startdate = startdate.AddDays(1);
            }



            return(sb.ToString());
        }
Exemple #4
0
        /// <summary>
        /// APP下注
        /// </summary>
        /// <param name="userids"></param>
        /// <param name="wfname"></param>
        /// <param name="beishu"></param>
        /// <param name="qihao">期号</param>
        /// <param name="judgetime">是否判断时间,默认是,否的情况用于测试时批量下注</param>
        public string XiaZhu_APP(string userids, string wfname, double buymoney, double beishu, string qihao, bool judgetime = true, int wfid = 0)
        {
            DAL.WanfaDAL wfdal = new WanfaDAL();

            DAL.LiushuiDAL  lsdal = new LiushuiDAL();
            Model.Qihaoinfo qh    = new DAL.QihaoinfoDAL().GetModelByCond($"qihao='{qihao}'");
            if (qh == null)
            {
                throw new Exception("没有当前期号");
            }
            DateTime now = DateTime.Now;

            if (judgetime)
            {
                if (now < qh.starttime || now > qh.endtime)
                {
                    throw new Exception($"当前时间【{now.ToString("yyyy-MM-dd HH:mm:ss")}】不能下注,该期允许下注时间为【{qh.starttime.ToString("yyyy-MM-dd HH:mm:00")}】~【{qh.endtime.ToString("yyyy-MM-dd HH:mm:00")}】");
                }
            }

            Model.Wanfa wf = wfdal.GetModel(wfid);
            if (wf == null)
            {
                throw new Exception("无此玩法");
            }

            StringBuilder sb = new StringBuilder();

            DAL.UserinfoDAL udal = new UserinfoDAL();
            string[]        ss   = userids.Split(',');
            foreach (var item in ss)
            {
                int x;
                if (int.TryParse(item, out x))
                {
                    Model.Userinfo u = udal.GetModel(x);
                    if (u != null)
                    {
                        if (u.balance < buymoney)
                        {
                            sb.Append($"用户【{u.username}】余额【{u.balance}】不足<br />\r\n");
                            continue;
                        }
                        int xzid = Add(new Model.Xiazhuinfo()
                        {
                            kjtime     = qh.kjtime,
                            wfid       = wfid,
                            wfname     = wf.wfname,
                            shouxufee  = 0,
                            beishu     = beishu,
                            buycode    = wfname,
                            buymoney   = buymoney,
                            createtime = DateTime.Now,
                            czid       = 1,
                            czname     = "北京28",
                            qihao      = qihao,
                            userid     = u.id,
                            username   = u.username,
                        });
                        double beforemoney = u.balance;
                        u.balance -= buymoney;
                        udal.Update(u);

                        lsdal.Add(new Model.Liushui()
                        {
                            xzid        = xzid,
                            type        = 1,
                            beforemoney = beforemoney,
                            changemoney = buymoney,
                            aftermoney  = u.balance,
                            createtime  = DateTime.Now,
                            userid      = u.id,
                            username    = u.username,
                            remark      = $"用户【{u.id} {u.username}】下注【{qihao}期】【{wfname}】,金额【{buymoney}】"
                        });


                        sb.Append($"用户【{u.username}】下注【{qihao}期】成功,玩法【{wfname}】,扣除余额【{buymoney}】<br />\r\n");
                    } //end if u!=null
                }     //end if int.tryparse
            }         //end foreach
            return(sb.ToString());
        }
Exemple #5
0
        /// <summary>
        /// 下注
        /// </summary>
        /// <param name="userids">用户ID,以,间隔</param>
        /// <param name="buymoney">下注金额</param>
        /// <param name="beishu">倍数</param>
        /// <param name="qihao">期号</param>
        /// <param name="judgetime">是否判断时间,否的情况用于测试时批量下注</param>
        /// <param name="wfid">玩法ID</param>
        /// <param name="czid">采种ID</param>
        /// <returns>返回相关字符串</returns>
        public string XiaZhu(string userids, double buymoney, double beishu, string qihao, bool judgetime, int wfid, int czid)
        {
            DAL.WanfaDAL wfdal = new WanfaDAL()
            {
                ConnStr = ConnStr
            };
            DAL.ShuxingDAL sxdal = new ShuxingDAL()
            {
                ConnStr = ConnStr
            };
            DAL.LiushuiDAL lsdal = new LiushuiDAL()
            {
                ConnStr = ConnStr
            };
            DAL.UserinfoDAL udal = new UserinfoDAL()
            {
                ConnStr = ConnStr
            };
            DAL.CaizhongDAL czdal = new CaizhongDAL()
            {
                ConnStr = ConnStr
            };

            Model.Caizhong cz = czdal.GetModel(czid);
            if (cz == null)
            {
                throw new Exception("采种不存在,请联系程序狗!");
            }

            Model.Shuxing sx = sxdal.GetModelByCond($"sxname='大小单双版手续费'");
            if (sx == null)
            {
                throw new Exception("没有配置到大小单双版手续费,请联系程序狗!");
            }
            double bfb_shouxufee = double.Parse(sx.sxvalue);

            Model.Qihaoinfo qh = new DAL.QihaoinfoDAL().GetModelByCond($"qihao='{qihao}'");
            if (qh == null)
            {
                throw new Exception("没有当前期号");
            }
            DateTime now = DateTime.Now;

            if (judgetime)
            {
                if (now < qh.starttime || now > qh.endtime)
                {
                    throw new Exception($"当前时间【{now.ToString("yyyy-MM-dd HH:mm:ss")}】不能下注,该期允许下注时间为【{qh.starttime.ToString("yyyy-MM-dd HH:mm:00")}】~【{qh.endtime.ToString("yyyy-MM-dd HH:mm:00")}】");
                }
            }
            double basemoney = 0;
            double shouxufee = 0; //手续费,不是专家版的马上扣

            string groupname = "";
            string wfname    = "";

            Model.Wanfa wf = wfdal.GetModel(wfid);
            if (wf == null)
            {
                throw new Exception("玩法为空,请联系程序狗!");
            }
            wfname = wf.wfname;

            basemoney = wf.basemoney;


            if (basemoney == 0)
            {
                throw new Exception("金额为空,请检查玩法名称。");
            }
            if (wfname.Contains("专家版"))
            {
                beishu    = 1;
                shouxufee = 0;
            }
            else
            {
                basemoney = basemoney * beishu;
                shouxufee = basemoney * (bfb_shouxufee / 100);
            }
            StringBuilder sb = new StringBuilder();

            string[] ss = userids.Split(',');
            foreach (var item in ss)
            {
                int x;
                if (int.TryParse(item, out x))
                {
                    Model.Userinfo u = udal.GetModel(x);
                    if (u != null)
                    {
                        if (u.balance < (basemoney + shouxufee))
                        {
                            sb.Append($"用户【{u.username}】余额【{u.balance}】不足<br />\r\n");
                            continue;
                        }
                        int xzid = Add(new Model.Xiazhuinfo()
                        {
                            kjtime     = qh.kjtime,
                            wfid       = wfid,
                            wfname     = wfname,
                            shouxufee  = shouxufee,
                            beishu     = beishu,
                            buycode    = wfname,
                            buymoney   = basemoney,
                            createtime = DateTime.Now,
                            czid       = cz.id,
                            czname     = cz.czname,
                            qihao      = qihao,
                            userid     = u.id,
                            username   = u.username,
                        });
                        double beforemoney = u.balance;
                        u.balance -= basemoney + shouxufee;
                        udal.Update(u);

                        lsdal.Add(new Model.Liushui()
                        {
                            xzid        = xzid,
                            type        = 1,
                            beforemoney = beforemoney,
                            changemoney = basemoney + shouxufee,
                            aftermoney  = u.balance,
                            createtime  = DateTime.Now,
                            userid      = u.id,
                            username    = u.username,
                            remark      = $"用户【{u.id} {u.username}】下注【{qihao}期】【{wfname}】,金额【{basemoney }+{shouxufee}】"
                        });


                        sb.Append($"用户【{u.username}】下注【{qihao}期】成功,玩法【{wfname}】,扣除余额【{basemoney + shouxufee}】<br />\r\n");
                    } //end if u!=null
                }     //end if int.tryparse
            }         //end foreach
            return(sb.ToString());
        }