Beispiel #1
0
 public ActionResult Add(int?id)
 {
     Model.Caizhong n = new Model.Caizhong();
     if (id != null)
     {
         n = dal.GetModel(id.Value);
     }
     return(View(n));
 }
Beispiel #2
0
 public ActionResult Add(Model.Caizhong m)
 {
     try
     {
         if (m.id == 0)
         {
             dal.Add(m);
             return(Json(new { code = 0, msg = "新增成功!" }));
         }
         else
         {
             dal.Update(m);
             return(Json(new { code = 0, msg = "编辑成功!" }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { code = 1, msg = $"出错:{ex.Message}" }));
     }
 }
Beispiel #3
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());
        }