Esempio n. 1
0
    /// <summary>
    /// 购买矿机
    /// </summary>
    /// <param name="chosenum"></param>
    /// <returns></returns>
    public void GetRegSendPost()
    {
        int chosenum = Convert.ToInt32(hidetp.Value);

        if (Session["Member"] == null)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('未登录!');</script>", false);
            return;  //未登录
        }
        string number = Session["Member"].ToString();

        int cc = Convert.ToInt32(DBHelper.ExecuteScalar("select  count(0)  from memberorder where  DefrayState=1   and  isactive=0 and ordertype<>0  and  number='" + number + "' "));

        if (cc > 0)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('您有未激活的矿机,请激活后再升级!'); setTimeout(function(){ window.location.href='orderlist.aspx'},2000);  </script>", false);
            return;
        }

        int re = 0;
        ///获取usdt账户
        int lv = 0;

        //檢測是否有未支付的單子 如果有則走未支付的訂單

        double ddmm    = 0;
        string orderid = "";

        //DataTable ddt = DBHelper.ExecuteDataTable("select  top 1 OrderID,TotalMoney from memberorder where  DefrayState=0 order by id  ");
        //if (ddt != null && ddt.Rows.Count > 0)
        //{
        //    DataRow dr = ddt.Rows[0];
        //    ddmm = Convert.ToDouble(dr["TotalMoney"]);
        //    orderid =  dr["orderid"].ToString();



        //    return;
        //}

        //清除未支付订单
        DBHelper.ExecuteNonQuery(@" insert  into   memberorderdel(id,[Number],[OrderID],[StoreID],[TotalMoney]
           ,[TotalPv],[CarryMoney],[OrderExpectNum],[PayExpectNum]
           ,[IsAgain],[OrderDate],[Error],[Remark],[DefrayState],[Consignee]
           ,[CCPCCode],[ConCity],[ConAddress]
           ,[ConZipCode],[ConTelphone]
           ,[ConMobilPhone],[ConPost]
           ,[DefrayType],[PayMoney]
           ,[PayCurrency],[StandardCurrency]
           ,[StandardCurrencyMoney],[OperateIP]
           ,[OperateNum],[RemittancesID],[ElectronicAccountID],[ordertype]
           ,[IsReceivables],[PayMentMoney],[ReceivablesDate],[EnoughProductMoney]
           ,[LackProductMoney],[IsReturn],[SendType],[SendWay],[TotalMoneyReturned]
           ,[TotalPvReturned],[OrderStatus],[TotalMoneyReturning],[TotalPvReturning]
           ,[OrderStatus_NR],[Isjjff],[trackingnum],[InvestJB]
           ,[PriceJB],[isSend],[xjpay],[xfpay],[bdpay],[ISSettle])
 select id,[Number],[OrderID],[StoreID],[TotalMoney]
           ,[TotalPv],[CarryMoney],[OrderExpectNum],[PayExpectNum]
           ,[IsAgain],[OrderDate],[Error],[Remark],[DefrayState],[Consignee]
           ,[CCPCCode],[ConCity],[ConAddress]
           ,[ConZipCode],[ConTelphone]
           ,[ConMobilPhone],[ConPost]
           ,[DefrayType],[PayMoney]
           ,[PayCurrency],[StandardCurrency]
           ,[StandardCurrencyMoney],[OperateIP]
           ,[OperateNum],[RemittancesID],[ElectronicAccountID],[ordertype]
           ,[IsReceivables],[PayMentMoney],[ReceivablesDate],[EnoughProductMoney]
           ,[LackProductMoney],[IsReturn],[SendType],[SendWay],[TotalMoneyReturned]
           ,[TotalPvReturned],[OrderStatus],[TotalMoneyReturning],[TotalPvReturning]
           ,[OrderStatus_NR],[Isjjff],[trackingnum],[InvestJB]
           ,[PriceJB],[isSend],[xjpay],[xfpay],[bdpay],[ISSettle]
 from MemberOrder where DefrayState = 0
 and number ='" + number + "'   ");
        //删除未支付的订单
        DBHelper.ExecuteNonQuery("delete  from   memberorder where  DefrayState=0 and number='" + number + "'   ");


        DataTable dt_one = DAL.DBHelper.ExecuteDataTable("select LevelInt from memberinfo where Number='" + number + "'");

        if (dt_one.Rows != null && dt_one.Rows.Count > 0)
        {
            lv = Convert.ToInt32(dt_one.Rows[0]["LevelInt"]);//获取账户等级
        }
        double zhye = 0;
        int    jd   = Common.GetcurJieDuan();//获取阶段状态

        if ((lv == 1 || (lv == 0 && chosenum > 1)) && jd == 1)
        {
            zhye = CommandAPI.GetActMoney();
        }
        if (chosenum < 0 || chosenum > 8 || lv > chosenum)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('请选择矿机!');</script>", false);
            return;
        } //选择购买的矿机

        ConfigModel cm        = ConfigDAL.GetConfig();
        double      ttmoney   = 0;
        double      ttpv      = 0;
        int         ordertype = 22; // 0 第一次购买 1 补差升级
        int         isagain   = 0;
        double      yymoney   = 0;

        //   int ispay = 0; ///支付状态
        if (lv == 0)
        {
            ordertype = 22; //抢购20u
        }
        if (lv == 1 || (lv == 0 && chosenum > 1))
        {
            ordertype = 23; //购买
        }
        if (lv == 2)
        {
            yymoney = cm.Para2;
        }
        if (lv == 3)
        {
            yymoney = cm.Para3;
        }
        if (lv == 4)
        {
            yymoney = cm.Para4;
        }
        if (lv == 5)
        {
            yymoney = cm.Para5;
        }
        if (lv == 6)
        {
            yymoney = cm.Para6;
        }
        if (lv == 7)
        {
            yymoney = cm.Para7;
        }
        if (lv == 7)
        {
            ordertype = 25;           //复投
        }
        if (chosenum == 1)
        {
            ttmoney = cm.Para1; ttpv = 0;
        }                                                   //20u 不计算业绩
        if (chosenum == 2)
        {
            ttmoney = cm.Para2 - yymoney; ttpv = cm.Para2 - yymoney;
        }
        if (chosenum == 3)
        {
            ttmoney = cm.Para3 - yymoney; ttpv = cm.Para3 - yymoney;
        }
        if (chosenum == 4)
        {
            ttmoney = cm.Para4 - yymoney; ttpv = cm.Para4 - yymoney;
        }
        if (chosenum == 5)
        {
            ttmoney = cm.Para5 - yymoney; ttpv = cm.Para5 - yymoney;
        }
        if (chosenum == 6)
        {
            ttmoney = cm.Para6 - yymoney; ttpv = cm.Para6 - yymoney;
        }
        if (chosenum == 7)
        {
            ttmoney = cm.Para7 - yymoney; ttpv = cm.Para7 - yymoney;
        }
        //if (chosenum == 8) { ttmoney = cm.Para28 - yymoney; ttpv = cm.Para28 - yymoney; }
        if (yymoney > 0)
        {
            isagain = 1; ordertype = 24;
        }                                                //升级

        DataTable dtmb = DBHelper.ExecuteDataTable("select pointAin-pointAout  as  ablc,pointbin-pointbout  as  bblc,pointcin-pointcout  as  cblc,pointdin-pointdout  as  dblc,pointein-pointeout  as  eblc  from memberinfo where number='" + number + "'");
        DataTable conp = DBHelper.ExecuteDataTable("select CoinIndex ,coinnewprice  from CoinPlant  order by id ");
        double    ablc = 0; double bblc = 0; double cblc = 0; double dblc = 0; double eblc = 0;
        double    cap = 0; double cbp = 0; double ccp = 0; double cdp = 0; double cep = 0;

        if (dtmb != null && dtmb.Rows.Count > 0)
        {
            DataRow dr = dtmb.Rows[0];
            ablc = Convert.ToDouble(dr["ablc"]);
            bblc = Convert.ToDouble(dr["bblc"]);
            cblc = Convert.ToDouble(dr["cblc"]);
            dblc = Convert.ToDouble(dr["dblc"]);
            eblc = Convert.ToDouble(dr["eblc"]);
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('账户余额不足!');</script>", false);
            return;
        }
        if (conp != null && conp.Rows.Count > 0)
        {
            foreach (DataRow item in conp.Rows)
            {
                string s = item["CoinIndex"].ToString();
                if (s == "CoinA")
                {
                    cap = Convert.ToDouble(item["coinnewprice"]);
                }
                if (s == "CoinB")
                {
                    cbp = Convert.ToDouble(item["coinnewprice"]);
                }
                if (s == "CoinC")
                {
                    ccp = Convert.ToDouble(item["coinnewprice"]);
                }
                if (s == "CoinD")
                {
                    cdp = Convert.ToDouble(item["coinnewprice"]);
                }
                if (s == "CoinE")
                {
                    cep = Convert.ToDouble(item["coinnewprice"]);
                }
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('账户余额不足!');</script>", false);
            return;
        }


        double aneed = 0;
        double bneed = 0;
        double cneed = 0;
        double eneed = 0;

        if (lv > 0)
        {
            if (jd == 1)
            {
                if (zhye < ttmoney)
                {
                    //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('账户余额不足!');</script>", false);
                    //return;
                }//余额不足
                else if (jd == 2 || jd == 3)
                {
                    aneed = ttmoney / cap;
                    if (aneed > ablc)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('账户余额不足!');</script>", false);
                        return;
                    }
                    ; //余额不足
                }
                else if (jd == 4 || jd == 5)
                {
                    aneed = (ttmoney * 0.5) / cap;
                    bneed = (ttmoney * 0.5) / cbp;
                    if (aneed > ablc || bneed > bblc)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('账户余额不足!');</script>", false);
                        return;
                    }//余额不足
                }
                else if (jd == 6 || jd == 7)
                {
                    aneed = (ttmoney * 0.2) / cap;
                    bneed = (ttmoney * 0.3) / cbp;
                    cneed = (ttmoney * 0.5) / ccp;
                    if (aneed > ablc || bneed > bblc || cneed > cblc)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>  showsuc('账户余额不足!');</script>", false);
                        return;
                    }//余额不足
                }
            }

            if (jd > 0 && chosenum > 1) ///  如果是20u以上 则需要额外支付 5% 的E
            {
                eneed = (ttmoney * 0.05) / cep;
                //if (eneed > eblc)
                //{
                //    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('火星币余额不足,请先去抢购兑换!');</script>", false);
                //    return;
                //}
                //余额不足

                Session["Eneed"] = eneed;
            }
        }

        RegistermemberBLL registermemberBLL = new RegistermemberBLL();

        orderid = registermemberBLL.GetOrderInfo("add", null);
        int maxexpt = ConfigDAL.GetMaxExpectNum();

        Boolean flag = new AddOrderDataDAL().AddOrderInfo(number, orderid, maxexpt, isagain, ttmoney, ttpv, ordertype);

        Session["choselv"] = chosenum;   //保存当前选中级别
        if (flag)                        //插入订单成功 开始支付
        {
            if (jd == 1 && chosenum > 1) //说明是第一阶段的所有购买都 必须使用USDT买
            {
                Session["orderid"] = orderid;
                string postf = CommandAPI.GetFunction(orderid, ttmoney.ToString(), "recast.aspx", RadioButtonList1.SelectedValue);
                ClientScript.RegisterStartupScript(this.GetType(), "", postf, false);
                return;
            }

            else
            {
                //本地支付开始
                int r = MemberOrderDAL.PayOrder(number, orderid, aneed, bneed, cneed, eneed, chosenum, "使用本地币种账户支付");
                if (r == 1)
                {
                    //销毁
                    if (aneed > 0)
                    {
                        CommandAPI.Destruction("A", aneed);
                    }
                    if (bneed > 0)
                    {
                        CommandAPI.Destruction("B", bneed);
                    }
                    if (cneed > 0)
                    {
                        CommandAPI.Destruction("C", cneed);
                    }
                    // if (eneed > 0) CommandAPI.Destruction("E", eneed);
                    if (eneed > 0)
                    {
                        int ee = MemberOrderDAL.payOrderEcoin(number, orderid, eneed, "E币支付,激活成功");
                        if (ee == 1)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('购买矿机激活成功!');</script>", false);
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('支付成功,请使用E币激活矿机!'); setTimeout(function(){ window.location.href='orderlist.aspx'},3000); </script>", false);
                        }
                    }


                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('购买成功!');</script>", false);
                    return;
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>showsuc('购买失败!');</script>", false);
                    return;
                }
            }
        }
    }
Esempio n. 2
0
    //提交保存
    protected void Button1_Click(object sender, EventArgs e)
    {
        string number = Session["member"].ToString();
        ///设置特定值防止重复提交

        double txMoney = 0; //購買金額

        if (!double.TryParse(this.txtneed.Text.Trim(), out txMoney))
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(Page, GetType(), "success2", "showsuc('请正确输入!');", true);
            return;
        }
        if (txMoney <= 0)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(Page, GetType(), "success2", "showsuc('请正确输入!');", true);
            return;
        }

        double    coineblac    = Convert.ToDouble(DBHelper.ExecuteScalar("select  pointEin-pointEout as eblc from  memberinfo where number='" + number + "'"));
        double    actm         = CommandAPI.GetActMoney();
        double    dprice       = Convert.ToDouble(DBHelper.ExecuteScalar("select  CoinnewPrice from CoinPlant where CoinIndex='CoinE' "));
        double    kg           = 80 - coineblac;
        double    cuususdt     = txMoney * dprice; //需要使用的usdt數量
        DataTable dtordernopay = DBHelper.ExecuteDataTable("select top 1   dhorderid ,getplantE,useusdt  from dhlist where  number='" + number + "'  and issuc=1 and DateDiff(dd,dhdate,getdate())=0  order by id desc");

        if (dtordernopay.Rows.Count > 0)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(Page, GetType(), "success2", "showsuc('每天只能抢购一次');", true); txtneed.Text = kg.ToString("0.0000");
            return;
        }

        if (kg < txMoney)     //購買數量超過可購數量
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(Page, GetType(), "success2", "showsuc('最多可购" + kg + " 枚火星币!');", true); txtneed.Text = kg.ToString("0.0000");
            return;
        }

        //if (actm < cuususdt) //usdt數量超多賬戶
        //{
        //    double zdkd = actm / dprice;
        //    System.Web.UI.ScriptManager.RegisterStartupScript(Page, GetType(), "success2", "showsuc('当前USDT账户最多可购"+ zdkd.ToString("0.0000") + "!');", true); txtneed.Text = zdkd.ToString("0.0000") ;
        //    return;
        //}


        //記錄兌換表中兌換情況
        string dhorderid = "DH" + DateTime.Now.ToString("yyMMddHHmmssms");

        Session["zfddh"] = dhorderid;
        Session["getE"]  = txMoney;
        Session["USDT"]  = cuususdt;
        int rr = MemberOrderDAL.createDHOrder(number, dhorderid, cuususdt, dprice, txMoney, "会员兑换Mars(火星币)");

        //請求執行支付
        if (rr == 1)
        {
            string postf = CommandAPI.GetFunction(dhorderid, cuususdt.ToString("0.0000"), "plantedh.aspx", RadioButtonList1.SelectedValue);
            ClientScript.RegisterStartupScript(this.GetType(), "", postf, false);
            return;
        }
        else
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(Page, GetType(), "success2", "showsuc('兑换操作异常!');", true);
        }
    }