Esempio n. 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);
        }
Esempio n. 2
0
 /// <summary>
 /// 发邮件
 /// </summary>
 public void FaYouJian(string title, string body, string toemail)
 {
     try
     {
         DAL.ShuxingDAL sxdal         = new ShuxingDAL();
         Model.Shuxing  sx            = sxdal.GetModelByCond("sxname='use_sendcloud'");
         bool           use_sendcloud = false;
         if (sx != null && sx.sxvalue != "0")
         {
             use_sendcloud = true;
         }
         if (use_sendcloud)
         {
             string sendcloud_fromemail = sxdal.GetOneFiled("sxvalue", "sxname='sendcloud_fromemail'");
             string sendcloud_api_user  = sxdal.GetOneFiled("sxvalue", $"sxname='sendcloud_api_user'");
             string sendcloud_api_key   = sxdal.GetOneFiled("sxvalue", $"sxname='sendcloud_api_key'");
             string res = Tool.SendMailBySendCloud(sendcloud_fromemail, toemail, title, body, sendcloud_api_user, sendcloud_api_key);
             if (res.Contains("成功"))
             {
             }
             else
             {
                 throw new Exception("sendcloud发邮件出错:" + res);
             }
         }
         else
         {
             Model.Emailset m_fa = GetFaJianXiang();
             if (m_fa == null)
             {
                 throw new Exception("发件配置为空");
             }
             string smtp = m_fa.smtp;
             string from = m_fa.email;
             string to   = toemail;
             string pwd  = m_fa.password;
             Tool.SendMail(title, body, to, from, from, pwd, smtp);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 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());
        }
Esempio n. 4
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());
        }