コード例 #1
0
        protected SortedDictionary <string, string> getBaseParamDict()
        {
            if (WebUserAuth.UserId != Guid.Empty)
            {
                userid = WebUserAuth.UserId.Value;
            }
            else
            {
                Response.Redirect("~/user/login.aspx");
                return(null);
            }

            /**订单信息**/
            // 商户唯一订单号
            string no_order = "" + Request.QueryString["orderno"];
            // 商户订单时间
            string dt_order = PaymentUtil.GetCurrentDateTimeStr();

            AccountRechareInfo rechargemodel = getAccountRechare(no_order);

            if (rechargemodel == null)
            {
                return(null);
            }
            // 交易金额 单位为RMB-元
            string money_order = rechargemodel.Amount.ToString("f2");

            // 商品名称
            string name_goods = "Online Recharge";

            // 订单描述
            string info_order = "Online Recharge";


            //var userInfo = db.UserBasicInfo.FirstOrDefault(x => x.AuditRecordId == userid);
            //if (null == userInfo)
            //{

            //}
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            try
            {
                UserBLL bll = new UserBLL();
                userInfo = bll.GetUserBasicInfoModelById(userid);
                //从UserBasicInfo表获取银行卡号
                if (string.IsNullOrEmpty(userInfo.BankAccountNo))
                {
                    string            sql  = @"SELECT BankAccountNo as BankNo FROM UserBasicInfo WITH(NOLOCK) WHERE Id = @UserId ";
                    DynamicParameters para = new DynamicParameters();
                    para.Add("@UserId", userid);
                    userInfo.BankAccountNo = PublicConn.QuerySingle <string>(sql, ref para);
                }
                /** 商户提交参数**/
                string version     = partnerConfig.Version;             //接口版本号
                string oid_partner = partnerConfig.OidPartner;          //商户编号
                user_id = userid.ToString();                            //用户ID
                string sign_type    = partnerConfig.SignType;           //签名类型:RSA/MD5
                string busi_partner = partnerConfig.BusiPartner;        //业务类型 虚拟商品销售
                // string notify_url = ConfigurationManager.AppSettings["WebUrl"] + "/PaymentPlatform/lianlian/notify_url.aspx";//接收异步通知地
                string notify_url = "https://www.tuandai.com/PaymentPlatform/lianlian/notify_url.aspx";

                string url_return = ConfigurationManager.AppSettings["WebUrl"] + "/PaymentPlatform/lianlian/urlReturn.aspx"; //支付结束后返回地址

                string userreq_ip = PaymentUtil.LocalIPAddress();                                                            //IP *
                //string url_order = "";
                string valid_order = "10080";                                                                                // 订单有效期 单位分钟,可以为空,默认7天
                string timestamp   = PaymentUtil.GetCurrentDateTimeStr();                                                    //时间戳
                //string idType = "0"; //证件类型
                string idNo = userInfo.IdentityCard;                                                                         //"623026199206016992";
                acctName = userInfo.RealName;                                                                                //"彭思微";
                telno    = userInfo.TelNo;



                sParaTemp.Add("app_request", "3");
                sParaTemp.Add("bg_color", "d93f3f");
                sParaTemp.Add("busi_partner", busi_partner);
                sParaTemp.Add("card_no", userInfo.BankAccountNo);
                sParaTemp.Add("dt_order", dt_order);
                sParaTemp.Add("id_no", idNo);
                sParaTemp.Add("info_order", info_order);
                sParaTemp.Add("money_order", money_order);
                sParaTemp.Add("name_goods", name_goods);
                //sParaTemp.Add("no_agree", "");
                sParaTemp.Add("no_order", no_order);
                sParaTemp.Add("notify_url", notify_url);
                sParaTemp.Add("oid_partner", oid_partner);
                sParaTemp.Add("acct_name", acctName);
                sParaTemp.Add("risk_item", createRiskItem(userid, acctName, idNo, userInfo.TelNo, userInfo.AddDate.Value.ToString("yyyyMMddHHmmss")));
                //    sParaTemp.Add("risk_item", createRiskItemOld(user_id, acctName));
                sParaTemp.Add("sign_type", sign_type);
                sParaTemp.Add("url_return", url_return);
                sParaTemp.Add("user_id", telno);
                sParaTemp.Add("valid_order", valid_order);

                NetLog.WriteBatchwithdrawHandler("连连充值请求", string.Concat("签名方式", sign_type, "订单号:", no_order, ",用户编号:", user_id, "充值金额", money_order, "IP地址", userreq_ip), "触屏版");
                //LogHelper.WriteLog("连连充值请求", "", string.Concat("签名方式", sign_type, "订单号:", no_order, ",用户编号:", user_id, "充值金额", money_order, "IP地址", userreq_ip));
            }
            catch (Exception ex)
            {
                string errormessage = "内部错误:" + ex.InnerException + "\r\n堆栈:" + ex.StackTrace + "\r\n信息:" + ex.Message + "\r\n来源:" + ex.Source;
                //LogTextHelper.Instance.AddLog(errormessage);
                TuanDai.LogSystem.LogClient.LogClients.ErrorLog("WXTouch", "连连充值请求", "", errormessage);
            }
            return(sParaTemp);
        }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        WebSettingInfo webSetting = new WebSettingBLL().GetWebSettingInfo("E27798C9-9301-4176-AC0B-6F3916F389EA");

        partnerConfig = new PartnerConfig(webSetting.Param1Value, webSetting.Param2Value, webSetting.Param3Value, webSetting.Param5Value);
        SortedDictionary <string, string> sPara = GetRequestPost();

        if (null == sPara)
        {
            Response.End();
        }

        if (sPara.Count > 0)//判断是否有带返回参数
        {
            NetLog.WriteBatchwithdrawHandler("接收连连支付异步通知数据", string.Concat("【", "签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方订单号:", sPara["no_order"].ToString(), "充值金额:", sPara["money_order"].ToString(), "连连订单号:", sPara["oid_paybill"].ToString(), "】"));

            if (!PaymentUtil.CheckSign(sPara, partnerConfig.YTPublicKey, //验证失败
                                       partnerConfig.MD5Key))
            {
                var out_trade_no   = sPara["no_order"].ToString();
                var rechargeMoney  = sPara["money_order"].ToString();
                var transaction_id = sPara["oid_paybill"].ToString();

                //ObjectParameter outStatus = new ObjectParameter("outStatus", "0");
                //db.p_OnLineRechargeHandler(1, out_trade_no, decimal.Parse(rechargeMoney), transaction_id, outStatus);
                //int result = int.Parse(outStatus.Value.ToString());

                NetLog.WriteBatchwithdrawHandler("连连验签失败", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "连连处理状态:9999"));

                Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""验签失败""}");
                Response.End();
            }
            else
            {
                var out_trade_no   = sPara["no_order"].ToString();
                var rechargeMoney  = sPara["money_order"].ToString();
                var transaction_id = sPara["oid_paybill"].ToString();

                string            strSQL   = "p_OnLineRechargeHandler";
                DynamicParameters dyParams = new DynamicParameters();
                dyParams.Add("@orderno", out_trade_no);
                dyParams.Add("@MediumMoney", decimal.Parse(rechargeMoney));
                dyParams.Add("@MediumOrderNo", transaction_id);
                dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20);

                if (sPara["result_pay"].ToString().ToLower() == "success".ToLower())
                {
                    dyParams.Add("@handlerStatus", 2);
                }
                else
                {
                    dyParams.Add("@handlerStatus", 1);
                }
                PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure);
                int result = dyParams.Get <int>("@outStatus");

                AccountRechareInfo accountRechare = getAccountRechare(out_trade_no);
                if (accountRechare != null)
                {
                    var para = new DynamicParameters();
                    para.Add("@UserId", accountRechare.UserId);
                    var count = PublicConn.QuerySingleWrite <int>("select count(0) from AccountRechare with(nolock) where UserId=@UserId and Status =2   and type in (2, 3, 4, 6, 8, 12)", ref para);
                    if (count == 1)
                    {
                        TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0);
                    }

                    UserBasicInfoInfo userBasicInfo = new UserBLL().GetUserBasicInfoModelById(accountRechare.UserId);
                    if (userBasicInfo != null)
                    {
                        var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0");
                        if (isNewSmsRequest == "0")
                        {
                            var parameters = new Dictionary <string, object>();
                            parameters.Add("User", userBasicInfo);
                            parameters.Add("CurrentDate", DateTime.Now);
                            parameters.Add("RechargeMoney", rechargeMoney);
                            parameters.Add("Host", GlobalUtils.WebURL);

                            var messageSender = new BusinessDll.MessageSend();
                            messageSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters,
                                                       mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id);
                        }
                        else
                        {
                            SmsRequest rechargeSuccessSmsRequest = new SmsRequest();
                            rechargeSuccessSmsRequest.EventCode      = MsgTemplatesType.RechargeSuccess;
                            rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc;
                            rechargeSuccessSmsRequest.UserId         = userBasicInfo.Id;
                            rechargeSuccessSmsRequest.EmailAddress   = userBasicInfo.Email;
                            rechargeSuccessSmsRequest.Mobile         = userBasicInfo.TelNo;
                            rechargeSuccessSmsRequest.Parameters     = new Dictionary <string, object>();
                            rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", rechargeMoney);

                            string errorMessage = string.Empty;
                            SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage);
                        }



                        //第三方渠道回调
                        try
                        {
                            TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack(accountRechare.Id, accountRechare.UserId);
                        }
                        catch (Exception ex)
                        {
                            new TuanDai.LogSystem.LogClient.LogClients().WriteErrorLog(
                                "TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack",
                                "", "", ex.Message);
                        }
                    }
                }

                NetLog.WriteTraceLogHandler("交易成功", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方处理状态:", result.ToString().Trim(), "连连处理状态:", sPara["result_pay"].ToString()));
                Response.Write(@"{""ret_code"":""0000"",""ret_msg"":""交易成功""}");
                Response.End();
            }
        }
        else
        {
            //var out_trade_no = sPara["no_order"].ToString();
            //var rechargeMoney = sPara["money_order"].ToString();
            //var transaction_id = sPara["oid_paybill"].ToString();

            //ObjectParameter outStatus = new ObjectParameter("outStatus", "0");
            //db.p_OnLineRechargeHandler(1, out_trade_no, decimal.Parse(rechargeMoney), transaction_id, outStatus);
            ////Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""验签失败""}");

            //int result = int.Parse(outStatus.Value.ToString());

            NetLog.WriteBatchwithdrawHandler("连连交易参数为空失败", "连连处理状态:9999");
            Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""交易失败""}");
            Response.End();
        }

        // 解析异步通知对象
        // sPara 字典对象
        // TODO:更新订单,发货等后续处理
    }