Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ResponseHandler resHandler  = new ResponseHandler(null);
        string          return_code = resHandler.GetParameter("return_code");
        string          return_msg  = resHandler.GetParameter("return_msg");

        resHandler.SetKey(TenPayV3Info.Key);

        //写日志
        StringBuilder sb = new StringBuilder();

        sb.Append("\r\n 测试日志 微信支付支付 异步通知消息 notify_url -----------------------------------------------------------------------------------");
        sb.Append("\r\n out_trade_no=" + resHandler.GetParameter("out_trade_no"));
        sb.Append("\r\n return_code=" + resHandler.GetParameter("return_code"));
        sb.Append("\r\n return_msg=" + resHandler.GetParameter("return_msg"));
        sb.Append("\r\n result_code=" + resHandler.GetParameter("result_code"));
        sb.Append("\r\n total_fee=" + resHandler.GetParameter("total_fee"));
        sb.Append("\r\n--------------------------------------------------------------------------------------------------");
        SimonLog.WriteLog(sb.ToString(), "/Log/", "log_Weixinpay_" + DateTime.Now.ToString("yyyyMMdd"));

        string xmlfmt = @"<xml>
                            <return_code><![CDATA[{0}]]></return_code>
                            <return_msg><![CDATA[{1}]]></return_msg>
                          </xml>";

        if (!resHandler.IsTenpaySign() || return_code != "SUCCESS")
        {
            ResponseStr(string.Format(xmlfmt, "FAIL", "FAIL"), "text/xml");
        }

        string result_code = resHandler.GetParameter("result_code");

        if (result_code == "SUCCESS")
        {
            //交易成功
            string out_trade_no = resHandler.GetParameter("out_trade_no");
            string total_fee    = resHandler.GetParameter("total_fee");
            total_fee = (decimal.Parse(total_fee) / 100).ToString(); //单位分转换为单位元

            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(total_fee)))
            {
                Response.Write("充值金额不符");
                return;
            }
            //判断玩家账号是否存在
            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];

            //充值动作
            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", "微信充值,订单号:" + out_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", "充值赠送金币,关联微信订单号:" + out_trade_no)
            });

            ResponseStr(string.Format(xmlfmt, "SUCCESS", "OK"), "text/xml");
        }
        else
        {
            ResponseStr(string.Format(xmlfmt, "FAIL", "FAIL"), "text/xml");
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ResponseBean responseBean = new ResponseBean(Request);
        var          sign         = GetSign(responseBean).ToLower();

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

        sb.Append("\r\n 竣付通 异步返回通知 日志-----------------------------------------------------------------------------------");
        sb.Append("\r\n p1_yingyongnum=" + responseBean.p1_yingyongnum);
        sb.Append("\r\n p2_ordernumber=" + responseBean.p2_ordernumber);
        sb.Append("\r\n p3_money=" + responseBean.p3_money);
        sb.Append("\r\n p4_zfstate=" + responseBean.p4_zfstate);
        sb.Append("\r\n p5_orderid=" + responseBean.p5_orderid);
        sb.Append("\r\n p6_productcode=" + responseBean.p6_productcode);
        sb.Append("\r\n p7_bank_card_code=" + responseBean.p7_bank_card_code);
        sb.Append("\r\n p8_charset=" + responseBean.p8_charset);
        sb.Append("\r\n p9_signtype=" + responseBean.p9_signtype);
        sb.Append("\r\n p10_sign=" + responseBean.p10_sign);
        sb.Append("\r\n p11_pdesc=" + responseBean.p11_pdesc);
        sb.Append("\r\n p13_zfmoney=" + responseBean.p13_zfmoney);
        sb.Append("\r\n MD5Sign=" + sign);
        sb.Append("\r\n--------------------------------------------------------------------------------------------------");
        SimonLog.WriteLog(sb.ToString(), "/Log/", "log_jftpay_error_" + DateTime.Now.ToString("yyyyMMdd"));

        if (responseBean.p4_zfstate == "1" && sign.Equals(responseBean.p10_sign.ToLower()))
        {
            //交易成功
            DataTable RMBCostDT = SimonDB.DataTable(@"select * from Web_RMBCost where OrderID=@OrderID", new DbParameter[] {
                SimonDB.CreDbPar("@OrderID", responseBean.p2_ordernumber)
            });
            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(responseBean.p3_money)))
            {
                Response.Write("充值金额不符");
                return;
            }
            //判断玩家账号是否存在
            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", responseBean.p2_ordernumber));  //订单号
            rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", Convert.ToInt32(decimal.Parse(responseBean.p3_money))));
            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());

            //充值动作
            SimonDB.ExecuteNonQuery(@"update TUserInfo set RoomCard=RoomCard+@ChangeMoney where UserID=@UserID", new DbParameter[] {
                //SimonDB.CreDbPar("@ChangeMoney", RechargeRateDR["RechargeGold"].ToString()),
                SimonDB.CreDbPar("@ChangeMoney", RMBCostDR["PayMoney"].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,11,getdate(),@Remark)", new DbParameter[] {
                SimonDB.CreDbPar("@UserID", UserDR["UserID"].ToString()),
                SimonDB.CreDbPar("@UserName", UserDR["UserName"].ToString()),
                SimonDB.CreDbPar("@StartMoney", UserDR["RoomCard"].ToString()),
                SimonDB.CreDbPar("@ChangeMoney", RMBCostDR["PayMoney"].ToString()),
                SimonDB.CreDbPar("@Remark", "竣付通充值,订单号:" + responseBean.p3_money)
            });
            //竣付通房卡日志充值类型(ChangeType)为11

            //充值赠送金币
            //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", "充值赠送金币,关联旺实富订单号:" + responseBean.p5_orderid)
            //        });

            //服务器操作
            Response.Write("Success");
        }
    }
Example #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", "支付接口网关报错,支付失败"));
        }
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string p1_usercode      = Request.Params["p1_usercode"];
        string p2_order         = Request.Params["p2_order"];
        string p3_money         = Request.Params["p3_money"];
        string p4_status        = Request.Params["p4_status"];
        string p5_payorder      = Request.Params["p5_payorder"];
        string p6_paymethod     = Request.Params["p6_paymethod"];
        string p7_paychannelnum = Request.Params["p7_paychannelnum"];

        if (p7_paychannelnum == null)
        {
            p7_paychannelnum = "";
        }
        string p8_charset  = Request.Params["p8_charset"];
        string p9_signtype = Request.Params["p9_signtype"];
        string p10_sign    = Request.Params["p10_sign"];
        string p11_remark  = Request.Params["p11_remark"];

        string MD5Sign = SimonUtils.EnCodeMD5(p1_usercode + "&" + p2_order + "&" + p3_money + "&" + p4_status + "&" + p5_payorder + "&" + p6_paymethod + "&" + p7_paychannelnum + "&" + p8_charset + "&" + p9_signtype + "&" + comp_key);

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

        sb.Append("\r\n 旺实付 异步通知 日志-----------------------------------------------------------------------------------");
        sb.Append("\r\n p1_usercode=" + p1_usercode);
        sb.Append("\r\n p2_order=" + p2_order);
        sb.Append("\r\n p3_money=" + p3_money);
        sb.Append("\r\n p4_status=" + p4_status);
        sb.Append("\r\n p5_payorder=" + p5_payorder);
        sb.Append("\r\n p6_paymethod=" + p6_paymethod);
        sb.Append("\r\n p7_paychannelnum=" + p7_paychannelnum);
        sb.Append("\r\n p8_charset=" + p8_charset);
        sb.Append("\r\n p9_signtype=" + p9_signtype);
        sb.Append("\r\n p10_sign=" + p10_sign);
        sb.Append("\r\n p11_remark=" + p11_remark);
        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(p10_sign, StringComparison.OrdinalIgnoreCase) && p4_status == "1")
        {
            //交易成功
            DataTable RMBCostDT = SimonDB.DataTable(@"select * from Web_RMBCost where OrderID=@OrderID", new DbParameter[] {
                SimonDB.CreDbPar("@OrderID", p2_order)
            });
            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(p3_money)))
            {
                Response.Write("充值金额不符");
                return;
            }
            //判断玩家账号是否存在
            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", p2_order));  //订单号
            rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", Convert.ToInt32(decimal.Parse(p3_money))));
            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());

            //充值动作
            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", "旺实富充值,订单号:" + p3_money)
            });

            //充值赠送金币
            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", "充值赠送金币,关联旺实富订单号:" + p5_payorder)
            });

            SimonUtils.RespW("支付成功");
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string merchant_id  = Request.Params["merchant_id"];
        string request_time = Request.Params["request_time"];
        string pay_time     = Request.Params["pay_time"];
        string status       = Request.Params["status"];
        string order_amount = Request.Params["order_amount"];
        string pay_amount   = Request.Params["pay_amount"];
        string out_trade_no = Request.Params["out_trade_no"];

        if (out_trade_no == null)
        {
            out_trade_no = "";
        }
        string trade_no  = Request.Params["trade_no"];
        string fees      = Request.Params["fees"];
        string pay_type  = Request.Params["pay_type"];
        string nonce_str = Request.Params["nonce_str"];
        string sign      = Request.Params["sign"];

        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 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;
            }
            //判断玩家账号是否存在
            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());

            //充值动作
            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", "暴风雪充值,订单号:" + order_amount)
            });

            //充值赠送金币
            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)
            });

            SimonUtils.RespW("支付成功");
        }
    }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //写日志
        StringBuilder sb = new StringBuilder();

        sb.Append("\r\n 测试日志 支付宝支付 异步通知消息 notify_url -----------------------------------------------------------------------------------");
        sb.Append("\r\n out_trade_no=" + Request.Form["out_trade_no"]);
        sb.Append("\r\n trade_status=" + Request.Form["trade_status"]);
        sb.Append("\r\n total_amount=" + Request.Form["total_amount"]);
        sb.Append("\r\n--------------------------------------------------------------------------------------------------");
        SimonLog.WriteLog(sb.ToString(), "/Log/", "log_Alipay_" + DateTime.Now.ToString("yyyyMMdd"));



        IDictionary <string, string> sArray = GetRequestPost();
        bool flag = AlipaySignature.RSACheckV1(sArray, CurrSite.Alipay_public_key, "utf-8", "RSA2", false);

        if (sArray.Count != 0)
        {
            if (flag)
            {
                string out_trade_no = Request.Form["out_trade_no"]; //商户订单号
                string trade_status = Request.Form["trade_status"]; //交易状态
                string total_amount = Request.Form["total_amount"]; //订单金额
                if (trade_status == "TRADE_SUCCESS" || trade_status == "TRADE_FINISHED")
                {
                    //交易成功
                    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(total_amount)))
                    {
                        Response.Write("充值金额不符");
                        return;
                    }
                    //判断玩家账号是否存在
                    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(total_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());

                    //充值动作
                    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", "支付宝充值,订单号:" + out_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", "充值赠送金币,关联支付宝订单号:" + out_trade_no)
                    });
                }
                else
                {
                    Response.Write("交易失败");
                    return;
                }

                Response.Write("success");
            }
            else
            {
                Response.Write("fail");
            }
        }
    }
    const string APP_KEY = "focbu8s471tr1cmxpt0o4qzk7mc94wfo";  //api密匙

    protected void Page_Load(object sender, EventArgs e)
    {
        string memberid       = Request.Params["memberid"];
        string orderid        = Request.Params["orderid"];
        string amount         = Request.Params["amount"];
        string transaction_id = Request.Params["transaction_id"];
        string datetime       = Request.Params["datetime"];
        string returncode     = Request.Params["returncode"];
        string attach         = Request.Params["attach"];
        string sign           = Request.Params["sign"];

        string SignTemp = "amount=" + amount
                          + "&datetime=" + datetime
                          + "&memberid=" + memberid
                          + "&orderid=" + orderid
                          + "&returncode=" + returncode
                          + "&transaction_id=" + transaction_id
                          + "&key=" + APP_KEY;
        string Md5Sign = GetMD5String(SignTemp).ToUpper();

        if (sign == Md5Sign && returncode == "00")
        {
            //交易成功
            DataTable RMBCostDT = SimonDB.DataTable(@"select * from Web_RMBCost where OrderID=@OrderID", new DbParameter[] {
                SimonDB.CreDbPar("@OrderID", orderid)
            });
            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(amount)))
            {
                Response.Write("充值金额不符");
                return;
            }
            //判断玩家账号是否存在
            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", orderid));  //订单号
            rmbcost_lpar.Add(SimonDB.CreDbPar("@InMoney", Convert.ToInt32(decimal.Parse(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());

            //充值动作
            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", "去聚合充值,订单号:" + amount)
            });

            //充值赠送金币
            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", "充值赠送金币,关联去聚合订单号:" + amount)
            });

            Response.Write("OK"); //输出成功标识
        }
        else
        {
            //写错误日志
            StringBuilder sb = new StringBuilder();
            sb.Append("\r\n 去聚合 异步通知 错误日志-----------------------------------------------------------------------------------");
            sb.Append("\r\n memberid=" + memberid);
            sb.Append("\r\n orderid=" + orderid);
            sb.Append("\r\n amount=" + amount);
            sb.Append("\r\n transaction_id=" + transaction_id);
            sb.Append("\r\n datetime=" + datetime);
            sb.Append("\r\n returncode=" + returncode);
            sb.Append("\r\n attach=" + attach);
            sb.Append("\r\n sign=" + sign);
            sb.Append("\r\n Md5Sign=" + Md5Sign);
            sb.Append("\r\n--------------------------------------------------------------------------------------------------");
            SimonLog.WriteLog(sb.ToString(), "/Log/", "log_qujuhepay_error_" + DateTime.Now.ToString("yyyyMMdd"));

            Response.Write("fail"); //输出失败标识
        }
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string p4_zfstate     = Request.Params["p4_zfstate"]; //支付返回结果 1 代表成功,其他为失败。
        string p1_yingyongnum = Request.Params["p1_yingyongnum"];
        string p2_ordernumber = Request.Params["p2_ordernumber"];
        string p3_money       = Request.Params["p3_money"];
        string p5_orderid     = Request.Params["p5_orderid"];
        string p6_productcode = Request.Params["p6_productcode"];
        string p8_charset     = Request.Params["p8_charset"];
        string p9_signtype    = Request.Params["p9_signtype"];
        string p10_sign       = Request.Params["p10_sign"];
        string p11_pdesc      = Request.Params["p11_pdesc"];
        string p12_remark     = Request.Params["p12_remark"];
        string p13_zfmoney    = Request.Params["p13_zfmoney"];

        if (string.IsNullOrWhiteSpace(p4_zfstate))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p1_yingyongnum))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p2_ordernumber))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p3_money))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p5_orderid))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p6_productcode))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p8_charset))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p9_signtype))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p10_sign))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p11_pdesc))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p12_remark))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(p13_zfmoney))
        {
            SimonUtils.RespWNC("fail");
        }

        string verifysign = "p1_yingyongnum=" + CurrSite.jft_yingyongnum
                            + "&p2_ordernumber=" + p2_ordernumber
                            + "&p3_money=" + p3_money
                            + "&p4_zfstate=" + p4_zfstate
                            + "&p5_orderid=" + p5_orderid
                            + "&p6_productcode=" + p6_productcode
                            + "&p7_bank_card_code="
                            + "&p8_charset=" + p8_charset
                            + "&p9_signtype=" + p9_signtype
                            + "&p11_pdesc=" + p11_pdesc
                            + "&p13_zfmoney=" + p13_zfmoney + "&"
                            + CurrSite.jft_compkey;

        verifysign = SimonUtils.EnCodeMD5(verifysign);

        if (p4_zfstate == "1" && p10_sign == verifysign)
        {
            //WebPayBll biz = new WebPayBll();
            //var IsHaveUpdate = biz.GetPaySuccess(sp_billno);
            //if (IsHaveUpdate)
            //{
            //    已支付成功,不更新订单
            //    SimonUtils.RespWNC("OK");
            //}
            //else
            //{
            //    var total = Convert.ToDecimal(total_fee);
            //    var upResult = biz.UpdatePayOrder(Convert.ToInt32(total), sp_billno);
            //    SimonUtils.RespWNC("OK");
            //}
        }
        else
        {
            //写错误日志
            StringBuilder sb = new StringBuilder();
            sb.Append("\r\n 错误日志 回调动作-----------------------------------------------------------------------------------");
            sb.Append("\r\n p4_zfstate=" + p4_zfstate);
            sb.Append("\r\n p1_yingyongnum=" + p1_yingyongnum);
            sb.Append("\r\n p2_ordernumber=" + p2_ordernumber);
            sb.Append("\r\n p3_money=" + p3_money);
            sb.Append("\r\n p5_orderid=" + p5_orderid);
            sb.Append("\r\n p6_productcode=" + p6_productcode);
            sb.Append("\r\n p8_charset=" + p8_charset);
            sb.Append("\r\n p9_signtype=" + p9_signtype);
            sb.Append("\r\n p10_sign=" + p10_sign);
            sb.Append("\r\n p11_pdesc=" + p11_pdesc);
            sb.Append("\r\n p12_remark=" + p12_remark);
            sb.Append("\r\n p13_zfmoney=" + p13_zfmoney);
            sb.Append("\r\n verifysign=" + verifysign);
            sb.Append("\r\n--------------------------------------------------------------------------------------------------");
            SimonLog.WriteLog(sb.ToString(), "/Log/", "log_jft_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
            return;
        }
    }
Example #9
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", "支付接口网关报错,支付失败"));
        }
    }
Example #10
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");
        }
    }
Example #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string pay_result     = Request.Params["pay_result"];
        string transaction_id = Request.Params["transaction_id"];
        string bargainor_id   = Request.Params["bargainor_id"];
        string sp_billno      = Request.Params["sp_billno"];
        string pay_info       = Request.Params["pay_info"];
        string total_fee      = Request.Params["total_fee"];
        string attach         = Request.Params["attach"];
        string zidy_code      = Request.Params["zidy_code"];
        string sign           = Request.Params["sign"];

        if (string.IsNullOrWhiteSpace(pay_result))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(transaction_id))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(bargainor_id))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(sp_billno))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(pay_info))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(total_fee))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(attach))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(zidy_code))
        {
            SimonUtils.RespWNC("fail");
        }
        if (string.IsNullOrWhiteSpace(sign))
        {
            SimonUtils.RespWNC("fail");
        }

        string verifysign = "pay_result=" + pay_result
                            + "&bargainor_id=" + CurrSite.Pay15173_bargainor_id
                            + "&sp_billno=" + sp_billno
                            + "&total_fee=" + total_fee
                            + "&attach=" + attach
                            + "&key=" + CurrSite.Pay15173_key;

        verifysign = SimonUtils.EnCodeMD5(verifysign);

        if (pay_result == "0" && sign == verifysign)
        {
            //WebPayBll biz = new WebPayBll();
            //var IsHaveUpdate = biz.GetPaySuccess(sp_billno);
            //if (IsHaveUpdate)
            //{
            //    //已支付成功,不更新订单
            //    SimonUtils.RespWNC("OK");
            //}
            //else
            //{
            //    var total = Convert.ToDecimal(total_fee);
            //    var upResult = biz.UpdatePayOrder(Convert.ToInt32(total), sp_billno);
            //    SimonUtils.RespWNC("OK");
            //}
        }
        else
        {
            //写错误日志
            StringBuilder sb = new StringBuilder();
            sb.Append("\r\n 错误日志 回调动作-----------------------------------------------------------------------------------");
            sb.Append("\r\n pay_result=" + pay_result);
            sb.Append("\r\n transaction_id=" + transaction_id);
            sb.Append("\r\n bargainor_id=" + bargainor_id);
            sb.Append("\r\n sp_billno=" + sp_billno);
            sb.Append("\r\n pay_info=" + pay_info);
            sb.Append("\r\n total_fee=" + total_fee);
            sb.Append("\r\n attach=" + attach);
            sb.Append("\r\n zidy_code=" + zidy_code);
            sb.Append("\r\n sign=" + sign);
            sb.Append("\r\n verifysign=" + verifysign);
            sb.Append("\r\n--------------------------------------------------------------------------------------------------");
            SimonLog.WriteLog(sb.ToString(), "/Log/", "log_15173_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
            return;
        }
    }