Esempio n. 1
0
    /// <summary>
    /// 前端API验签检查(辅助方法)
    /// </summary>
    private void CheckSign()
    {
        string t    = SimonUtils.Qnum("t"); //unix时间戳 (10位数字)
        string sign = SimonUtils.Q("sign"); //签名

        if (t.Length != 10)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "时间戳错误"));
        }
        if (CurrSite.ApiCallTimeOut(t))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "请求超时"));
        }
        if (!CurrSite.VerifySign(sign, t))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "签名错误"));
        }
    }
Esempio n. 2
0
 /// <summary>
 /// 重载ToString()
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(this.AgvID.ToString() + "号AGV,站点:" + CurrSite.ToString() + "任务号:[" + ExcuteTaksNo + "],明细:[" + TaskDetailID.ToString() + "]");
 }
Esempio n. 3
0
    const string NOTIFY_URL = "http://api-mobilegame-test-000.kk838.com/a_qujuhe_notify_url.aspx"; //异步通知URL

    protected void Page_Load(object sender, EventArgs e)
    {
        CheckSign();
        string userid      = SimonUtils.Qnum("userid");      //用户ID
        string rechargermb = SimonUtils.Qnum("rechargermb"); //充值金额(人民币)
        string payip       = Request.Params["payip"];        //用户IP

        if (userid.Length < 1)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户ID错误(数字类型)"));
        }
        if (rechargermb.Length < 1)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "充值金额(人民币)错误(数字类型)"));
        }
        if (string.IsNullOrWhiteSpace(payip))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户IP错误"));
        }

        //判断玩家账号是否存在
        DbParameter[] userparms = new DbParameter[] { SimonDB.CreDbPar("@userid", userid) };
        DataTable     UserDT    = SimonDB.DataTable(@"select * from TUsers as a inner join TUserInfo as b on a.userid=b.userid where a.userid=@userid", userparms);

        if (UserDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户不存在"));
        }
        DataRow UserDR = UserDT.Rows[0];

        //判断充值兑换率
        DataTable RechargeRateDT = SimonDB.DataTable(@"select * from RechargeRate where RechargeRMB=@RechargeRMB", new DbParameter[] {
            SimonDB.CreDbPar("@RechargeRMB", rechargermb)
        });

        if (RechargeRateDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "此充值金额的金币兑换率不存在"));
        }
        DataRow RechargeRateDR = RechargeRateDT.Rows[0];

        //创建订单
        string _orderdes = "充值金额:" + RechargeRateDR["RechargeRMB"].ToString() + " 兑换金币:" + RechargeRateDR["RechargeGold"].ToString() + " 赠送金币:" + RechargeRateDR["RegiveGold"].ToString();
        string _ordernum = CurrSite.GenNewOrderNum();

        while (((int)SimonDB.ExecuteScalar(@"select count(*) from Web_RMBCost where OrderID=@ordernum", new DbParameter[] {
            SimonDB.CreDbPar("@ordernum", _ordernum)
        })) > 0)
        {
            _ordernum = CurrSite.GenNewOrderNum();
        }

        List <DbParameter> rmbcost_lpar = new List <DbParameter>();

        rmbcost_lpar.Add(SimonDB.CreDbPar("@Users_ids", UserDR["UserID"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@TrueName", UserDR["NickName"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()));
        //rmbcost_lpar.Add(SimonDB.CreDbPar("@PayMoney", rechargermb == "0.01" ? "6" : rechargermb));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayMoney", rechargermb));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayType", "151"));     //去聚合支付(www.qujuhe.com) 支付类型设置为151
        rmbcost_lpar.Add(SimonDB.CreDbPar("@TypeInfo", "去聚合支付"));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@OrderID", _ordernum)); //订单号
        rmbcost_lpar.Add(SimonDB.CreDbPar("@AddTime", DateTime.Now.ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@ExchangeRate", "1"));  //充值兑换率(此字段暂时无效)
        rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", "0"));       //提交订单时写入0,确定充值成功后需更新该字段
        rmbcost_lpar.Add(SimonDB.CreDbPar("@InSuccess", false));   //In状态
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PaySuccess", false));  //Pay状态
        rmbcost_lpar.Add(SimonDB.CreDbPar("@MoneyFront", UserDR["WalletMoney"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@UpdateFlag", "0"));    //更新状态 0 未更新  1 已更新
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PurchaseType", "1"));  //充值金币1 充值元宝2
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayIP", payip));

        SimonDB.ExecuteNonQuery(@"insert into Web_RMBCost (Users_ids,TrueName,UserName,PayMoney,PayType,TypeInfo,OrderID,AddTime,
                                                                   ExchangeRate,InMoney,InSuccess,PaySuccess,MoneyFront,UpdateFlag,PurchaseType,
                                                                   PayIP)
                                                           values (@Users_ids,@TrueName,@UserName,@PayMoney,@PayType,@TypeInfo,@OrderID,@AddTime,
                                                                   @ExchangeRate,@InMoney,@InSuccess,@PaySuccess,@MoneyFront,@UpdateFlag,@PurchaseType,
                                                                   @PayIP)", rmbcost_lpar.ToArray());

        //对接去聚合
        //参数名称 参数含义    是否必填 参与签名    参数说明
        //pay_memberid    商户号 是   是 平台分配商户号
        //pay_orderid 订单号 是 是   上送订单号唯一, 最大字符长度32
        //pay_applydate   提交时间 是   是 时间格式:2016-12-26 18:18:18
        //pay_bankcode 银行编码    是 是   参考后续说明
        //pay_notifyurl   服务端通知 是   是 服务端返回地址/支付回调(POST返回数据)
        //pay_callbackurl 页面跳转通知  是 是   页面跳转返回**【现阶段不能自动跳转】**
        //pay_amount 订单金额    是 是   商品金额
        //pay_md5sign MD5签名 是   否 请看MD5签名字段格式
        //pay_productname 商品名称    是 否   中文或数字或字母
        //sub_openid  公众号用户的openid 否   否 公众号支付此项必填,请检查公众号是否绑定获取用户openid
        //pay_deviceIp    设备真实IP地址 否   否 H5支付此项必填
        //pay_scene 支付场景(Wap,IOS,Android)   否 否   H5支付此项必填,默认为Wap,区分大小写
        //pay_attach  附加字段 否   否 此字段在返回时按原样返回(中文需要url编码)
        //pay_productnum 商户品数量   否 否
        //pay_productdesc 商品描述    否 否
        //pay_producturl 商户链接地址  否 否
        string parms = "pay_amount=" + rechargermb
                       + "&pay_applydate=" + DateTime.Today.ToString()
                       + "&pay_bankcode=" + PAY_BANKCODE
                       + "&pay_callbackurl=" + NOTIFY_URL
                       + "&pay_memberid=" + PAY_MEMBERID
                       + "&pay_notifyurl=" + NOTIFY_URL
                       + "&pay_orderid=" + _ordernum
                       + "&key=" + APP_KEY;

        string sParmsMd5 = GetMD5String(parms).ToUpper();

        parms += "&pay_md5sign=" + sParmsMd5;
        parms += "&pay_deviceIp=" + payip;
        parms += "&pay_productname=chongzhi";

        parms = SimonUrl.UpdateParam(parms, "key", "");   //加密计算后,提交POST参数时置空参数key,更安全

        string receive_str = PostRequest(PAY_URL, parms); //去聚合要求使用post模式
        //SimonUtils.RespWNC(receive_str);

        JsonData receive_jd = null;

        try
        {
            receive_jd = JsonMapper.ToObject(receive_str);
        }
        catch { SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "Json异常")); }

        JsonData out_jd = new JsonData();

        if (receive_jd["status"].ToString().ToLower() == "success")
        {
            out_jd["code"]               = "1";
            out_jd["msg"]                = "success";
            out_jd["results"]            = new JsonData();
            out_jd["results"]["orderid"] = _ordernum;
            out_jd["results"]["payurl"]  = receive_jd["data"]["code_url"].ToString();
            SimonUtils.RespWNC(out_jd.ToJson());
        }
        else
        {
            //写错误日志
            StringBuilder sb = new StringBuilder();
            sb.Append("\r\n 去聚合 支付 错误日志-----------------------------------------------------------------------------------");
            sb.Append("\r\n receive_str: " + receive_str);
            sb.Append("\r\n--------------------------------------------------------------------------------------------------");
            SimonLog.WriteLog(sb.ToString(), "/Log/", "log_qujuhepay_error_" + DateTime.Now.ToString("yyyyMMdd"));

            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "支付接口网关报错,支付失败"));
        }
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckSign();
        string userid       = SimonUtils.Qnum("userid");      //用户ID
        string rechargermb  = SimonUtils.Qnum("rechargermb"); //充值金额(人民币)
        string payip        = Request.Params["payip"];        //用户IP
        string paytype      = Request.Params["paytype"];      //支付方式。微信固码8001013,支付宝当面付8001024
        string purchasetype = Request.Params["purchasetype"]; //货币类型:1,金币;2房卡

        if (userid.Length < 1)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户ID错误(数字类型)"));
        }
        if (rechargermb.Length < 1)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "充值金额(人民币)错误(数字类型)"));
        }
        if (string.IsNullOrWhiteSpace(payip))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户IP错误"));
        }

        //判断玩家账号是否存在
        DbParameter[] userparms = new DbParameter[] { SimonDB.CreDbPar("@userid", userid) };
        DataTable     UserDT    = SimonDB.DataTable(@"select * from TUsers as a inner join TUserInfo as b on a.userid=b.userid where a.userid=@userid", userparms);

        if (UserDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户不存在"));
        }
        DataRow UserDR = UserDT.Rows[0];

        //判断充值兑换率
        DataTable RechargeRateDT = SimonDB.DataTable(@"select * from RechargeRate where RechargeRMB=@RechargeRMB", new DbParameter[] {
            SimonDB.CreDbPar("@RechargeRMB", rechargermb)
        });

        if (RechargeRateDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "此充值金额的金币兑换率不存在"));
        }
        DataRow RechargeRateDR = RechargeRateDT.Rows[0];

        //创建订单
        string _orderdes = "充值金额:" + RechargeRateDR["RechargeRMB"].ToString() + " 兑换金币:" + RechargeRateDR["RechargeGold"].ToString() + " 赠送金币:" + RechargeRateDR["RegiveGold"].ToString();
        string _ordernum = CurrSite.GenNewOrderNum();

        while (((int)SimonDB.ExecuteScalar(@"select count(*) from Web_RMBCost where OrderID=@ordernum", new DbParameter[] {
            SimonDB.CreDbPar("@ordernum", _ordernum)
        })) > 0)
        {
            _ordernum = CurrSite.GenNewOrderNum();
        }

        List <DbParameter> rmbcost_lpar = new List <DbParameter>();

        rmbcost_lpar.Add(SimonDB.CreDbPar("@Users_ids", UserDR["UserID"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@TrueName", UserDR["NickName"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()));
        //rmbcost_lpar.Add(SimonDB.CreDbPar("@PayMoney", rechargermb == "0.01" ? "6" : rechargermb));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayMoney", rechargermb));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayType", "162"));             //暴风雪支付(http://pay.uukudear9.cn/gateway/dopay) 支付类型设置为162
        rmbcost_lpar.Add(SimonDB.CreDbPar("@TypeInfo", "baofeng" + paytype));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@OrderID", _ordernum));         //订单号
        rmbcost_lpar.Add(SimonDB.CreDbPar("@AddTime", DateTime.Now.ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@ExchangeRate", "1"));          //充值兑换率(此字段暂时无效)
        rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", "0"));               //提交订单时写入0,确定充值成功后需更新该字段
        rmbcost_lpar.Add(SimonDB.CreDbPar("@InSuccess", false));           //In状态
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PaySuccess", false));          //Pay状态
        rmbcost_lpar.Add(SimonDB.CreDbPar("@MoneyFront", UserDR["WalletMoney"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@UpdateFlag", "0"));            //更新状态 0 未更新  1 已更新
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PurchaseType", purchasetype)); //充值金币1 充值房卡2
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayIP", payip));

        SimonDB.ExecuteNonQuery(@"insert into Web_RMBCost (Users_ids,TrueName,UserName,PayMoney,PayType,TypeInfo,OrderID,AddTime,
                                                                   ExchangeRate,InMoney,InSuccess,PaySuccess,MoneyFront,UpdateFlag,PurchaseType,
                                                                   PayIP)
                                                           values (@Users_ids,@TrueName,@UserName,@PayMoney,@PayType,@TypeInfo,@OrderID,@AddTime,
                                                                   @ExchangeRate,@InMoney,@InSuccess,@PaySuccess,@MoneyFront,@UpdateFlag,@PurchaseType,
                                                                   @PayIP)", rmbcost_lpar.ToArray());

        string str_out_trade_no = _ordernum;
        string str_amount       = string.Format("{0:N2}", int.Parse(rechargermb));
        string str_ordertime    = DateTime.Now.ToString("yyyyMMddHHmmss");
        string str_nonce_str    = SimonUtils.GetRandomString(20, true, false, true, false, "");
        string str_sign         = SimonUtils.EnCodeMD5("amount=" + str_amount + "&" + "device_type=wap" + "&" + "merchant_id=" + str_merchant_id + "&" + "nonce_str=" + str_nonce_str + "&" + "notify_url=" + str_notify_url + "&" + "out_trade_no=" + str_out_trade_no + "&" + "pay_ip=" + payip + "&" + "pay_type=" + paytype + "&" + "request_time=" + str_ordertime + "&" + "return_url=" + str_return_url + "&" + "version=V2.0" + "&" + s_key).ToUpper();
        //string str_sign = SimonUtils.EnCodeMD5("merchant_id=" + str_merchant_id + "&" + "version=V2.0" + "&" + "pay_type=" + paytype + "&" + "device_type=wap" + "&" + "request_time=" + str_ordertime + "&" + "nonce_str=" + str_nonce_str + "&" + "pay_ip=" + payip + "&" + "out_trade_no=" + str_out_trade_no + "&" + "amount=" + str_amount +"&"+ "notify_url=" + str_notify_url +"&" +"&" + "return_url=" + str_return_url  + "&" + s_key).ToUpper();

        //form1.Action = pay_url;
        //amount.Value = str_amount;
        //device_type.Value = "wap";
        //merchant_id.Value = str_merchant_id;
        //nonce_str.Value = str_nonce_str;
        //notify_url.Value = str_notify_url;
        //out_trade_no.Value = str_out_trade_no;
        //pay_ip.Value = payip;
        //pay_type.Value = paytype;
        //request_time.Value = str_ordertime;
        //return_url.Value = str_return_url;
        //sign.Value = str_sign;
        //version.Value = "V2.0";

        //ScriptManager.RegisterStartupScript(this.Page, GetType(), "post1", "Post();", true);


        //对接暴风雪支付


        string parms = "amount=" + str_amount
                       + "&device_type=wap"
                       + "&merchant_id=" + str_merchant_id
                       + "&nonce_str=" + str_nonce_str
                       + "&notify_url=" + str_notify_url
                       + "&out_trade_no=" + str_out_trade_no
                       + "&pay_ip=" + payip
                       + "&pay_type=" + paytype
                       + "&request_time=" + str_ordertime
                       + "&return_url=" + str_return_url
                       + "&version=V2.0";

        string sParmsMd5 = GetMD5String(parms + s_key).ToUpper();

        parms += "&sign=" + sParmsMd5;

        //parms = SimonUrl.UpdateParam(parms, "s_key", "");  //加密计算后,提交POST参数时置空参数key,更安全


        StringBuilder str = new StringBuilder();

        str.Append("{");
        str.Append("amount:\"" + str_amount + "\",");
        str.Append("device_type:\"" + "wap" + "\",");
        str.Append("merchant_id:\"" + str_merchant_id + "\",");
        str.Append("nonce_str:\"" + str_nonce_str + "\",");
        str.Append("notify_url:\"" + str_notify_url + "\",");
        str.Append("out_trade_no:\"" + str_out_trade_no + "\",");
        str.Append("pay_ip:\"" + payip + "\",");
        str.Append("pay_type:\"" + paytype + "\",");
        str.Append("request_time:\"" + str_ordertime + "\",");
        str.Append("return_url:\"" + str_return_url + "\",");
        str.Append("version:\"" + "V2.0" + "\",");
        str.Append("sign:\"" + sParmsMd5 + "\"");
        str.Append("}");
        string josnParms = str.ToString();

        //JObject jo = (JObject)JsonConvert.DeserializeObject(jsonText);

        //JObject jo = JObject.Parse(retString);
        //JsonData jo = JsonMapper.ToObject(josnParms);

        string receive_str = PostRequest(pay_url, josnParms);  //暴风雪要求使用post模式json格式
        //SimonUtils.RespWNC(receive_str);

        JsonData receive_jd = null;

        try
        {
            receive_jd = JsonMapper.ToObject(receive_str);
        }
        catch { SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "Json异常")); }

        JsonData out_jd = new JsonData();

        if (receive_jd["status"].ToString().ToLower() == "success")
        {
            out_jd["code"]               = "1";
            out_jd["msg"]                = "success";
            out_jd["results"]            = new JsonData();
            out_jd["results"]["orderid"] = _ordernum;
            out_jd["results"]["payurl"]  = receive_jd["pay_url"].ToString();
            SimonUtils.RespWNC(out_jd.ToJson());
        }
        else
        {
            //写错误日志
            StringBuilder sb = new StringBuilder();
            sb.Append("\r\n 暴风雪 支付 错误日志-----------------------------------------------------------------------------------");
            sb.Append("\r\n receive_str: " + receive_str);
            sb.Append("\r\n parms: " + parms);
            sb.Append("\r\n josnParms: " + josnParms);
            sb.Append("\r\n pay_url: " + pay_url);
            sb.Append("\r\n receive_jd: " + receive_jd.ToString());
            //sb.Append("\r\n sign: " + receive_jd["data"]["sign"].ToString());
            sb.Append("\r\n--------------------------------------------------------------------------------------------------");
            SimonLog.WriteLog(sb.ToString(), "/Log/", "log_a_qlmjpay_error_" + DateTime.Now.ToString("yyyyMMdd"));

            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "支付接口网关报错,支付失败"));
        }
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Stream receive_str = Request.InputStream;

        StreamReader sr = new StreamReader(receive_str);

        string requestMes = sr.ReadToEnd();

        JsonData receive_jd = null;

        try
        {
            receive_jd = JsonMapper.ToObject(requestMes);
        }
        catch { SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "Json异常")); }

        string merchant_id  = receive_jd["merchant_id"].ToString();
        string request_time = receive_jd["request_time"].ToString();
        string pay_time     = receive_jd["pay_time"].ToString();
        string status       = receive_jd["status"].ToString();
        string order_amount = receive_jd["order_amount"].ToString();
        string pay_amount   = receive_jd["pay_amount"].ToString();
        string out_trade_no = receive_jd["out_trade_no"].ToString();
        //if (out_trade_no == null) out_trade_no = "";
        string trade_no  = receive_jd["trade_no"].ToString();
        string fees      = receive_jd["fees"].ToString();
        string pay_type  = receive_jd["pay_type"].ToString();
        string nonce_str = receive_jd["nonce_str"].ToString();
        string sign      = receive_jd["sign"].ToString();

        string MD5Sign = SimonUtils.EnCodeMD5("fees=" + fees + "&" + "merchant_id=" + merchant_id + "&" + "nonce_str=" + nonce_str + "&" + "order_amount=" + order_amount + "&" + "out_trade_no=" + out_trade_no + "&" + "pay_amount=" + pay_amount + "&" + "pay_time=" + pay_time + "&" + "pay_type=" + pay_type + "&" + "request_time=" + request_time + "&" + "status=" + status + "&" + "trade_no=" + trade_no + s_key).ToUpper();

        //记录日志
        StringBuilder sb = new StringBuilder();

        sb.Append("\r\n 暴风雪 异步通知 回调日志-----------------------------------------------------------------------------------");
        sb.Append("\r\n requestMes=" + requestMes);
        sb.Append("\r\n merchant_id=" + merchant_id);
        sb.Append("\r\n request_time=" + request_time);
        sb.Append("\r\n pay_time=" + pay_time);
        sb.Append("\r\n status=" + status);
        sb.Append("\r\n order_amount=" + order_amount);
        sb.Append("\r\n pay_amount=" + pay_amount);
        sb.Append("\r\n out_trade_no=" + out_trade_no);
        sb.Append("\r\n trade_no=" + trade_no);
        sb.Append("\r\n fees=" + fees);
        sb.Append("\r\n pay_type=" + pay_type);
        sb.Append("\r\n nonce_str=" + nonce_str);
        sb.Append("\r\n sign=" + sign);
        sb.Append("\r\n MD5Sign=" + MD5Sign);
        sb.Append("\r\n--------------------------------------------------------------------------------------------------");
        SimonLog.WriteLog(sb.ToString(), "/Log/", "log_paywap_error_" + DateTime.Now.ToString("yyyyMMdd"));

        if (MD5Sign.Equals(sign, StringComparison.OrdinalIgnoreCase) && status == "success")
        {
            //交易成功
            DataTable RMBCostDT = SimonDB.DataTable(@"select * from Web_RMBCost where OrderID=@OrderID", new DbParameter[] {
                SimonDB.CreDbPar("@OrderID", out_trade_no)
            });
            if (RMBCostDT.Rows.Count <= 0)
            {
                Response.Write("订单不存在");
                return;
            }
            DataRow RMBCostDR = RMBCostDT.Rows[0];
            if (RMBCostDR["UpdateFlag"].ToString() == "1")
            {
                Response.Write("订单已处理");
                return;
            }
            if (Convert.ToInt32(decimal.Parse(RMBCostDR["PayMoney"].ToString())) != Convert.ToInt32(decimal.Parse(order_amount)))
            {
                Response.Write("充值金额不符");
                return;
            }
            //获取充值货币类型
            string PurchaseType = RMBCostDT.Rows[0]["PurchaseType"].ToString();
            //判断玩家账号是否存在
            DbParameter[] userparms = new DbParameter[] { SimonDB.CreDbPar("@userid", RMBCostDR["Users_ids"]) };
            DataTable     UserDT    = SimonDB.DataTable(@"select * from TUsers as a inner join TUserInfo as b on a.userid=b.userid where a.userid=@userid", userparms);
            if (UserDT.Rows.Count <= 0)
            {
                Response.Write("用户不存在");
                return;
            }
            DataRow UserDR = UserDT.Rows[0];
            //判断充值兑换率
            DataTable RechargeRateDT = SimonDB.DataTable(@"select * from RechargeRate where RechargeRMB=@RechargeRMB", new DbParameter[] {
                SimonDB.CreDbPar("@RechargeRMB", RMBCostDR["PayMoney"].ToString())
            });
            if (RechargeRateDT.Rows.Count <= 0)
            {
                Response.Write("此充值金额的金币兑换率不存在");
                return;
            }
            DataRow RechargeRateDR = RechargeRateDT.Rows[0];

            //更新订单
            List <DbParameter> rmbcost_lpar = new List <DbParameter>();
            rmbcost_lpar.Add(SimonDB.CreDbPar("@OrderID", out_trade_no));  //订单号
            rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", Convert.ToInt32(decimal.Parse(order_amount))));
            rmbcost_lpar.Add(SimonDB.CreDbPar("@InSuccess", true));
            rmbcost_lpar.Add(SimonDB.CreDbPar("@PaySuccess", true));
            rmbcost_lpar.Add(SimonDB.CreDbPar("@UpdateFlag", "1"));  //更新状态
            SimonDB.ExecuteNonQuery(@"update Web_RMBCost set InMoney=@InMoney,InSuccess=@InSuccess,
                                              PaySuccess=@PaySuccess,UpdateFlag=@UpdateFlag
                                              where OrderID=@OrderID", rmbcost_lpar.ToArray());
            if (PurchaseType == "1")
            {
                //充值金币动作
                SimonDB.ExecuteNonQuery(@"update TUserInfo set WalletMoney=WalletMoney+@ChangeMoney where UserID=@UserID", new DbParameter[] {
                    SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RechargeGold"].ToString()),
                    SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString())
                });

                //金币日志
                SimonDB.ExecuteNonQuery(@"insert into Web_MoneyChangeLog (UserID,UserName,StartMoney,ChangeMoney,ChangeType,DateTime,Remark)
                                                                  values (@UserID,@UserName,@StartMoney,@ChangeMoney,2,getdate(),@Remark)", new DbParameter[] {
                    SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString()),
                    SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()),
                    SimonDB.CreDbPar("@StartMoney", UserDR["WalletMoney"].ToString()),
                    SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RechargeGold"].ToString()),
                    SimonDB.CreDbPar("@Remark", "暴风雪充值,订单号:" + trade_no)
                });

                //充值赠送金币
                //SimonDB.ExecuteNonQuery(@"update TUserInfo set WalletMoney=WalletMoney+@ChangeMoney where UserID=@UserID", new DbParameter[] {
                //        SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RegiveGold"].ToString()),
                //        SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString())
                //    });

                //充值赠送金币日志
                //SimonDB.ExecuteNonQuery(@"insert into Web_MoneyChangeLog (UserID,UserName,StartMoney,ChangeMoney,ChangeType,DateTime,Remark)
                //                                                  values (@UserID,@UserName,@StartMoney,@ChangeMoney,2,getdate(),@Remark)", new DbParameter[] {
                //        SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString()),
                //        SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()),
                //        SimonDB.CreDbPar("@StartMoney", UserDR["WalletMoney"].ToString()),
                //        SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RegiveGold"].ToString()),
                //        SimonDB.CreDbPar("@Remark", "赠送金币,关联暴风雪订单号:" + trade_no)
                //    });
            }
            if (PurchaseType == "2")
            {
                //充值房卡动作
                SimonDB.ExecuteNonQuery(@"update TUserInfo set RoomCard=RoomCard+@ChangeMoney where UserID=@UserID", new DbParameter[] {
                    SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RegiveGold"].ToString()),
                    SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString())
                });
                string RecordNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                //房卡日志
                SimonDB.ExecuteNonQuery(@"insert into FangkaRecord (UserID,RecordNum,CurrencyType,StartCount,Count,DeductType,DeductTime,Remark)
                                                                  values (@UserID,@RecordNum,1,@StartMoney,@ChangeMoney,2,getdate(),@Remark)", new DbParameter[] {
                    SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString()),
                    SimonDB.CreDbPar("@RecordNum", RecordNum),
                    SimonDB.CreDbPar("@StartMoney", UserDR["RoomCard"].ToString()),
                    SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RegiveGold"].ToString()),
                    SimonDB.CreDbPar("@Remark", "暴风雪充值房卡,订单号:" + trade_no)
                });
            }


            SimonUtils.RespW("success");
        }
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckSign();
        string userid      = SimonUtils.Qnum("userid");      //用户ID
        string rechargermb = SimonUtils.Qnum("rechargermb"); //充值金额(人民币)
        string payip       = Request.Params["payip"];        //用户IP

        if (userid.Length < 1)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户ID错误(数字类型)"));
        }
        if (rechargermb.Length < 1)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "充值金额(人民币)错误(数字类型)"));
        }
        if (string.IsNullOrWhiteSpace(payip))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户IP错误"));
        }

        //判断玩家账号是否存在
        DbParameter[] userparms = new DbParameter[] { SimonDB.CreDbPar("@userid", userid) };
        DataTable     UserDT    = SimonDB.DataTable(@"select * from TUsers as a inner join TUserInfo as b on a.userid=b.userid where a.userid=@userid", userparms);

        if (UserDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户不存在"));
        }
        DataRow UserDR = UserDT.Rows[0];

        //判断充值兑换率
        DataTable RechargeRateDT = SimonDB.DataTable(@"select * from RechargeRate where RechargeRMB=@RechargeRMB", new DbParameter[] {
            SimonDB.CreDbPar("@RechargeRMB", rechargermb)
        });

        if (RechargeRateDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "此充值金额的金币兑换率不存在"));
        }
        DataRow RechargeRateDR = RechargeRateDT.Rows[0];

        //创建订单
        string _orderdes = "充值金额:" + RechargeRateDR["RechargeRMB"].ToString() + " 兑换金币:" + RechargeRateDR["RechargeGold"].ToString() + " 赠送金币:" + RechargeRateDR["RegiveGold"].ToString();
        string _ordernum = CurrSite.GenNewOrderNum();

        while (((int)SimonDB.ExecuteScalar(@"select count(*) from Web_RMBCost where OrderID=@ordernum", new DbParameter[] {
            SimonDB.CreDbPar("@ordernum", _ordernum)
        })) > 0)
        {
            _ordernum = CurrSite.GenNewOrderNum();
        }

        List <DbParameter> rmbcost_lpar = new List <DbParameter>();

        rmbcost_lpar.Add(SimonDB.CreDbPar("@Users_ids", UserDR["UserID"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@TrueName", UserDR["NickName"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()));
        //rmbcost_lpar.Add(SimonDB.CreDbPar("@PayMoney", rechargermb == "0.01" ? "6" : rechargermb));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayMoney", rechargermb));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayType", "152"));     //旺实富支付(http://www.paywap.cn/) 支付类型设置为152
        rmbcost_lpar.Add(SimonDB.CreDbPar("@TypeInfo", "旺实富支付"));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@OrderID", _ordernum)); //订单号
        rmbcost_lpar.Add(SimonDB.CreDbPar("@AddTime", DateTime.Now.ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@ExchangeRate", "1"));  //充值兑换率(此字段暂时无效)
        rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", "0"));       //提交订单时写入0,确定充值成功后需更新该字段
        rmbcost_lpar.Add(SimonDB.CreDbPar("@InSuccess", false));   //In状态
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PaySuccess", false));  //Pay状态
        rmbcost_lpar.Add(SimonDB.CreDbPar("@MoneyFront", UserDR["WalletMoney"].ToString()));
        rmbcost_lpar.Add(SimonDB.CreDbPar("@UpdateFlag", "0"));    //更新状态 0 未更新  1 已更新
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PurchaseType", "1"));  //充值金币1 充值元宝2
        rmbcost_lpar.Add(SimonDB.CreDbPar("@PayIP", payip));

        SimonDB.ExecuteNonQuery(@"insert into Web_RMBCost (Users_ids,TrueName,UserName,PayMoney,PayType,TypeInfo,OrderID,AddTime,
                                                                   ExchangeRate,InMoney,InSuccess,PaySuccess,MoneyFront,UpdateFlag,PurchaseType,
                                                                   PayIP)
                                                           values (@Users_ids,@TrueName,@UserName,@PayMoney,@PayType,@TypeInfo,@OrderID,@AddTime,
                                                                   @ExchangeRate,@InMoney,@InSuccess,@PaySuccess,@MoneyFront,@UpdateFlag,@PurchaseType,
                                                                   @PayIP)", rmbcost_lpar.ToArray());

        string str_p2_order     = _ordernum;
        string str_p3_money     = string.Format("{0:N2}", int.Parse(rechargermb));
        string str_p6_ordertime = DateTime.Now.ToString("yyyyMMddHHmmss");
        string str_p7_sign      = SimonUtils.EnCodeMD5(str_p1_usercode + "&" + str_p2_order + "&" + str_p3_money + "&" + str_p4_returnurl + "&" + str_p5_notifyurl + "&" + str_p6_ordertime + comp_key).ToUpper();

        form1.Action         = pay_url;
        p1_usercode.Value    = str_p1_usercode;
        p2_order.Value       = str_p2_order;
        p3_money.Value       = str_p3_money;
        p4_returnurl.Value   = str_p4_returnurl;
        p5_notifyurl.Value   = str_p5_notifyurl;
        p6_ordertime.Value   = str_p6_ordertime;
        p7_sign.Value        = str_p7_sign;
        p9_paymethod.Value   = "4";
        p14_customname.Value = userid;
        p17_customip.Value   = payip;
        p25_terminal.Value   = "3";
        p26_iswappay.Value   = "3";

        ScriptManager.RegisterStartupScript(this.Page, GetType(), "post1", "Post();", true);
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckSign();
        Random rd = new Random();

        this.p1_yingyongnum.Value = System.Configuration.ConfigurationManager.AppSettings["jft_yingyongnum"];       //商户号;
        this.p2_ordernumber.Value = DateTime.Now.ToString("yyMMddHHmmss") + rd.Next(10000000, 99999999).ToString(); //
        this.p3_money.Value       = Request.Params["p3_money"];                                                     //?
        //this.p3_money.Value = "1";
        this.p6_ordertime.Value   = DateTime.Now.ToString("yyyyMMddHHmmss");                                        //
        this.p7_productcode.Value = Request.Params["p7_productcode"];                                               //?
        //this.p7_productcode.Value = "ZFB";
        this.p8_sign.Value             = "";                                                                        //
        this.p9_signtype.Value         = "1";                                                                       //MD5
        this.p10_bank_card_code.Value  = Request.Form["p10_bank_card_code"];                                        //?
        this.p11_cardtype.Value        = "";
        this.p12_channel.Value         = "";
        this.p13_orderfailertime.Value = "";
        this.p14_customname.Value      = Request.Params["p14_customname"];    //?
        this.p15_customcontact.Value   = "";
        //this.p16_customip.Value = "192_168_0_253";
        this.p16_customip.Value   = Request.Params["p16_customip"];
        this.p17_product.Value    = "钻石";
        this.p18_productcat.Value = "";
        this.p19_productnum.Value = "";
        this.p20_pdesc.Value      = "";
        this.p21_version.Value    = "";
        this.p22_sdkversion.Value = "";
        this.p23_charset.Value    = "UTF-8";
        this.p24_remark.Value     = "";
        this.p25_terminal.Value   = Request.Params["p25_terminal"];           //?
        this.p26_ext1.Value       = "1.1";
        this.p27_ext2.Value       = "";
        this.p28_ext3.Value       = "";
        this.p29_ext4.Value       = "";
        this.Card_Number.Value    = Request.Form["Card_Number"];
        this.Card_Password.Value  = Request.Form["Card_Password"];

        RequestBean requestBean = new RequestBean()
        {
            p1_yingyongnum = this.p1_yingyongnum.Value,
            p2_ordernumber = this.p2_ordernumber.Value,
            p3_money       = this.p3_money.Value,
            p6_ordertime   = this.p6_ordertime.Value,
            p7_productcode = this.p7_productcode.Value,
            p8_sign        = ""
        };

        this.p8_sign.Value = GetSign(requestBean);

        //平台创建订单
        string player_id = p14_customname.Value;

        if (string.IsNullOrWhiteSpace(player_id))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "玩家账号错误"));
        }
        if (string.IsNullOrWhiteSpace(p25_terminal.Value))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "设备信息错误"));
        }
        if (string.IsNullOrWhiteSpace(p16_customip.Value))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "玩家IP错误"));
        }
        if (string.IsNullOrWhiteSpace(p7_productcode.Value))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "支付方式错误"));
        }
        if (string.IsNullOrWhiteSpace(p3_money.Value) || !SimonUtils.IsDecimal(p3_money.Value))
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "充值金额错误"));
        }

        //判断玩家账号是否存在
        DbParameter[] userparms = new DbParameter[] { SimonDB.CreDbPar("@userid", player_id) };
        DataTable     UserDT    = SimonDB.DataTable(@"select * from TUsers as a inner join TUserInfo as b on a.userid=b.userid where a.userid=@userid", userparms);

        if (UserDT.Rows.Count <= 0)
        {
            SimonUtils.RespWNC(CurrSite.GetErrJson("-1", "用户不存在"));
        }
        DataRow UserDR = UserDT.Rows[0];

        //提交form表单到requestUrl
        //form1.Action = System.Configuration.ConfigurationManager.AppSettings["requestUrl"];
        ScriptManager.RegisterStartupScript(this.Page, GetType(), "post1", "Post();", true);

        //创建订单
        List <DbParameter> lpar = new List <DbParameter>();

        lpar.Add(SimonDB.CreDbPar("@Users_ids", UserDR["UserID"].ToString()));
        lpar.Add(SimonDB.CreDbPar("@TrueName", UserDR["NickName"].ToString()));
        lpar.Add(SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()));
        lpar.Add(SimonDB.CreDbPar("@PayMoney", p3_money.Value));
        lpar.Add(SimonDB.CreDbPar("@PayType", "78"));                 //竣付通 的支付类型设置为78
        lpar.Add(SimonDB.CreDbPar("@TypeInfo", "Jft_" + p7_productcode.Value));
        lpar.Add(SimonDB.CreDbPar("@OrderID", p2_ordernumber.Value)); //订单号
        lpar.Add(SimonDB.CreDbPar("@AddTime", DateTime.Now.ToString()));
        lpar.Add(SimonDB.CreDbPar("@ExchangeRate", "1"));             //充值兑换率(此字段暂时无效)
        lpar.Add(SimonDB.CreDbPar("@InMoney", "0"));                  //提交订单时写入0,确定充值成功后需更新该字段
        lpar.Add(SimonDB.CreDbPar("@InSuccess", false));
        lpar.Add(SimonDB.CreDbPar("@PaySuccess", false));
        lpar.Add(SimonDB.CreDbPar("@MoneyFront", UserDR["RoomCard"].ToString()));
        lpar.Add(SimonDB.CreDbPar("@UpdateFlag", "0"));   //更新状态
        lpar.Add(SimonDB.CreDbPar("@PurchaseType", "3")); //充值金币1 充值元宝2 充值房卡3
        lpar.Add(SimonDB.CreDbPar("@PayIP", p16_customip.Value));
        lpar.Add(SimonDB.CreDbPar("@ao_device", p25_terminal.Value));
        SimonDB.ExecuteNonQuery(@"insert into Web_RMBCost  (Users_ids,TrueName,UserName,PayMoney,PayType,TypeInfo,OrderID,AddTime,
                                                            ExchangeRate,InMoney,InSuccess,PaySuccess,MoneyFront,UpdateFlag,PurchaseType,
                                                            PayIP,ao_device,ao_device_id)
                                                    values (@Users_ids,@TrueName,@UserName,@PayMoney,@PayType,@TypeInfo,@OrderID,@AddTime,
                                                            @ExchangeRate,@InMoney,@InSuccess,@PaySuccess,@MoneyFront,@UpdateFlag,@PurchaseType,
                                                            @PayIP,@ao_device,'')", lpar.ToArray());
    }