Esempio n. 1
0
    /// <summary>
    /// 给页面隐藏域赋值,手续费比例。
    /// </summary>
    /// <param name="compid"></param>
    public void BindPaySettings(int compid)
    {
        //查询该企业的设置
        List <Hi.Model.Pay_PaymentSettings> Sysl = new Hi.BLL.Pay_PaymentSettings().GetList("", " CompID=" + compid, "");

        if (Sysl.Count > 0)
        {
            //手续费收取
            string sxfsq = Convert.ToString(Sysl[0].pay_sxfsq);
            this.pay_sxfsq.Value = sxfsq;

            //支付方式--线上or线下
            string zffs = Convert.ToString(Sysl[0].pay_zffs);
            this.pay_zffs.Value = zffs;

            //免手续费支付次数
            int mfcs = Convert.ToInt32(Sysl[0].Pay_mfcs);
            this.Pay_mfcs.Value = mfcs + "";

            //收取代理商手续费 (没有免支付次数时,才计算手续费)
            if (sxfsq == "1" && mfcs <= 0)
            {
                //手续费比例
                this.pay_kjzfbl.Value    = (Convert.ToDecimal(Sysl[0].pay_kjzfbl) / 1000).ToString("0.000");
                this.pay_kjzfstart.Value = Convert.ToString(Sysl[0].pay_kjzfstart);
                this.pay_kjzfend.Value   = Convert.ToString(Sysl[0].pay_kjzfend);

                this.pay_ylzfbl.Value    = (Convert.ToDecimal(Sysl[0].pay_ylzfbl) / 1000).ToString("0.000");
                this.pay_ylzfstart.Value = Convert.ToString(Sysl[0].pay_ylzfstart);
                this.pay_ylzfend.Value   = Convert.ToString(Sysl[0].pay_ylzfend);

                this.pay_b2cwyzfbl.Value    = (Convert.ToDecimal(Sysl[0].pay_b2cwyzfbl) / 1000).ToString("0.000");
                this.pay_b2cwyzfstart.Value = Sysl[0].vdef1;


                this.pay_b2bwyzf.Value = Convert.ToString(Sysl[0].pay_b2bwyzf);

                this.hid_PayType.Value = "11";
            }
            else
            {
                div_kjzfsxf.Attributes.Add("style", "display:none;");
                div_wyzfsxf.Attributes.Add("style", "display:none;");
                sum_payprice.Attributes.Add("style", "display:none;");
            }
        }
        else
        {
            div_kjzfsxf.Attributes.Add("style", "display:none;");
            div_wyzfsxf.Attributes.Add("style", "display:none;");
            sum_payprice.Attributes.Add("style", "display:none;");
        }
    }
Esempio n. 2
0
    public void Test(string Type)
    {
        ////本地日志记录
        LogManager.LogFielPrefix = "Order_time";
        LogManager.LogPath       = "D:/订单结算日志Order_log/";

        LogManager.WriteLog(LogFile.Trace.ToString(), DateTime.Now.ToString() + "-订单结算程序启动>>>>>>>>>>>...\r\n");

        string strMsg     = string.Empty;
        string pre_strMsg = string.Empty;
        string fw_strMsg  = string.Empty;
        string head       = "各位,您好!<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日" + " 结算情况如下,请查看:";;

        string topMsg      = string.Empty;
        string pre_topMsg  = string.Empty;
        string fw_topMsg   = string.Empty;
        string downMsg     = string.Empty;
        string pre_downMsg = string.Empty;
        string fw_downMsg  = string.Empty;

        int ord_errornum = 0;         //记录订单支付错误的记录
        int pre_errornum = 0;         //记录企业钱包错误的记录
        int fw_errornum  = 0;         //记录服务错误的记录

        int    db_num = 0;            //担保支付记录
        string db_meg = string.Empty; //担保支付信息


        //订单结算方法
        if (Type == "Order")
        {
            string LocalSqlServer = SqlHelper.LocalSqlServer;

            int     compID        = 0;
            int     disID         = 0;
            long    price         = 0;                                                                      //金额
            int     ordID         = 0;                                                                      //订单Id
            string  ReceiptNo     = string.Empty;                                                           //订单号
            string  guid          = string.Empty;                                                           //流水号
            string  remark        = string.Empty;                                                           //订单备注
            int     paymentID     = 0;                                                                      //支付表ID
            int     Channel       = 0;                                                                      //支付渠道(1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付)
            decimal payment_zfsxf = 0;                                                                      //支付表计算的手续费
            int     Paymen_Type   = 0;                                                                      //支付类型
            int     OState        = 0;                                                                      //判断是否已确认到货
            int     jsxf_no       = 0;                                                                      //判断手续费是否结算成功
            string  hc_flag       = string.Empty;                                                           //结算回冲标准

            decimal Old_price = 0;                                                                          //原支付金额
            //-----银行信息
            string orgcode              = ConfigurationManager.AppSettings["PayOrgCode"].ToString().Trim(); // string.Empty;//机构代码
            int    accountType          = 0;                                                                //帐号类型
            string paymentaccountname   = string.Empty;                                                     //账户名称(支付平台账户 当 AccountType=20 时,该项必填)
            string paymentaccountnumber = string.Empty;                                                     //账户号码(支付平台账户 当 AccountType=20 时,该项必填)
            string bankaccount          = string.Empty;                                                     //收款方在银行开立的账户
            string bankId        = string.Empty;                                                            //银行ID
            string accountname   = string.Empty;                                                            //账户名称
            string accountnumber = string.Empty;                                                            //账户号码
            string branchname    = string.Empty;                                                            //开会行地址
            string province      = string.Empty;                                                            //开会所在省
            string city          = string.Empty;                                                            //开会所在市

            //结算接口日志表
            Hi.Model.PAY_PayLog paylogmodel = new Hi.Model.PAY_PayLog();
            Hi.BLL.PAY_PayLog   paylogbll   = new Hi.BLL.PAY_PayLog();
            int paylogID = 0;//接口日志返回ID



            #region 订单结算
            string sxfsq = "-1";

            DataTable dt_order = new Hi.BLL.PAY_PrePayment().GetdataTable(1, "", 1);
            if (dt_order.Rows.Count > 0)
            {
                foreach (DataRow dr in dt_order.Rows)
                {
                    compID        = 0;
                    disID         = 0;
                    price         = 0;                   //金额
                    ordID         = 0;                   //订单Id
                    ReceiptNo     = string.Empty;        //订单号
                    guid          = string.Empty;        //流水号
                    remark        = string.Empty;        //订单备注
                    paymentID     = 0;                   //支付表ID
                    Channel       = 0;                   //支付渠道(1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付)
                    payment_zfsxf = 0;                   //支付表计算的手续费
                    Paymen_Type   = 0;                   //支付类型
                    OState        = 0;                   //判断是否已确认到货
                    jsxf_no       = 0;                   //判断手续费是否结算成功
                    hc_flag       = string.Empty;        //结算回冲标准
                    Old_price     = 0;                   //原支付金额
                    //-----银行信息
                    accountType          = 0;            //帐号类型
                    paymentaccountname   = string.Empty; //账户名称(支付平台账户 当 AccountType=20 时,该项必填)
                    paymentaccountnumber = string.Empty; //账户号码(支付平台账户 当 AccountType=20 时,该项必填)
                    bankaccount          = string.Empty; //收款方在银行开立的账户
                    bankId        = string.Empty;        //银行ID
                    accountname   = string.Empty;        //账户名称
                    accountnumber = string.Empty;        //账户号码
                    branchname    = string.Empty;        //开会行地址
                    province      = string.Empty;        //开会所在省
                    city          = string.Empty;        //开会所在市


                    ////本地日志记录
                    LogManager.LogFielPrefix = "Order_time";
                    LogManager.LogPath       = "D:/订单结算日志Order_log/";
                    LogManager.WriteLog(LogFile.Trace.ToString(), DateTime.Now.ToString() + "-订单结算服务启动...");

                    try
                    {
                        compID = Convert.ToInt32(dr["CompID"]);
                        disID  = Convert.ToInt32(dr["DisID"]);
                        //原支付金额
                        Old_price = Convert.ToDecimal(dr["PayPrice"]) - Convert.ToDecimal(dr["vdef5"] + "" == "" ? "0" : dr["vdef5"]);


                        Channel       = Convert.ToInt32(dr["Channel"] + "" == "" ? "-1" : dr["Channel"]);
                        payment_zfsxf = Convert.ToDecimal(dr["vdef5"]);
                        jsxf_no       = Convert.ToInt32(dr["jsxf_no"]);
                        hc_flag       = dr["vdef6"] + "";

                        #region     计算支付手续费 start

                        decimal sxf    = 0;
                        long    js_sxf = 0;
                        //查询该企业的设置
                        List <Hi.Model.Pay_PaymentSettings> Sysl = new Hi.BLL.Pay_PaymentSettings().GetList("", " CompID=" + compID, "");
                        if (Sysl.Count > 0)
                        {
                            //手续费收取
                            sxfsq = Convert.ToString(Sysl[0].pay_sxfsq);

                            //支付方式--线上or线下
                            string zffs = Convert.ToString(Sysl[0].pay_zffs);

                            //免手续费支付次数
                            int mfcs = Convert.ToInt32(Sysl[0].Pay_mfcs);

                            //快捷支付比例
                            decimal kjzfbl    = Convert.ToDecimal(Sysl[0].pay_kjzfbl) / 1000;
                            decimal kjzfstart = Convert.ToDecimal(Sysl[0].pay_kjzfstart);
                            decimal kjzfend   = Convert.ToDecimal(Sysl[0].pay_kjzfend);

                            //银联支付比例
                            decimal ylzfbl    = Convert.ToDecimal(Sysl[0].pay_ylzfbl) / 1000;
                            decimal ylzfstart = Convert.ToDecimal(Sysl[0].pay_ylzfstart);
                            decimal ylzfend   = Convert.ToDecimal(Sysl[0].pay_ylzfend);

                            //B2c网银支付比例

                            decimal b2cwyzfbl    = Convert.ToDecimal(Sysl[0].pay_b2cwyzfbl) / 1000;
                            decimal b2cwyzfstart = Convert.ToDecimal(Sysl[0].vdef1);

                            //B2b网银支付比例

                            decimal b2bwyzfbl = Convert.ToDecimal(Sysl[0].pay_b2bwyzf);

                            //手续费收取方
                            if (sxfsq == "0")
                            {
                                sxf = 0;
                            }
                            else
                            {
                                //手续费 (没有免支付次数时,才计算手续费)
                                if (mfcs <= 0)
                                {
                                    switch (Channel)
                                    {
                                    case 1:    //快捷支付手续费
                                        sxf = Old_price * kjzfbl;
                                        // if (sxf <= kjzfstart)
                                        //     sxf = kjzfstart;
                                        // else if (sxf >= kjzfend)
                                        //     sxf = kjzfend;
                                        break;

                                    case 2:    //银联支付手续费
                                        sxf = Old_price * ylzfbl;
                                        //if (sxf <= ylzfstart)
                                        //    sxf = ylzfstart;
                                        //else if (sxf >= ylzfend)
                                        //   sxf = ylzfend;
                                        break;

                                    case 3:    //B2C网银支付手续费
                                        sxf = Old_price * b2cwyzfbl;
                                        //if (sxf <= b2cwyzfstart)
                                        //   sxf = b2cwyzfstart;
                                        break;

                                    case 8:    //信用卡支付手续费
                                        sxf = Old_price * b2cwyzfbl;
                                        break;

                                    case 4:    //B2B网银支付手续费
                                        sxf = b2bwyzfbl;
                                        break;
                                    }
                                }

                                //计算手续费
                                sxf = Math.Round(sxf, 2) * 100;//转化成分
                            }
                        }

                        #endregion  计算支付手续费 end

                        price = Convert.ToInt64(Old_price * 100);

                        bool sxf_fal = false;//判断结算时的手续费,是否和支付时手续费一致

                        #region  根据手续费收取方,判断清算金额 start

                        if (sxfsq == "1") // 1,代理商
                        {
                            if (sxf == payment_zfsxf * 100)
                            {
                                //price = price;//最终清算时的订单金额
                                js_sxf  = Convert.ToInt64(sxf);//最终清算时的手续费
                                sxf_fal = true;
                            }
                        }
                        else if (sxfsq == "2")             //2,企业
                        {
                            js_sxf = Convert.ToInt64(sxf); //最终清算时的手续费
                            // price = price;//最终清算时的订单金额
                            sxf_fal = true;
                        }
                        else
                        {
                            sxf_fal = true;
                        }

                        #endregion 根据手续费收取方,判断清算金额 end

                        if (sxf_fal)
                        {
                            ReceiptNo = Convert.ToString(dr["ReceiptNo"]);
                            //回冲操作处理重新生成Guid,paylog表通过createuserid字段和payment表关联
                            if ("1".Equals(hc_flag))
                            {
                                guid = Common.Number_repeat(Guid.NewGuid().ToString().Replace("-", ""));
                            }
                            else
                            {
                                guid = Convert.ToString(dr["GUID"]);
                            }

                            ordID     = Convert.ToInt32(dr["ID"]);
                            paymentID = Convert.ToInt32(dr["paymentID"]);

                            Paymen_Type = Convert.ToInt32(dr["Type"]);    //判断是否是担保支付
                            OState      = Convert.ToInt32(dr["OState"]);  //判断订单是否已确认到货
                            string disname = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(Common.GetOrderValue(ordID, "DisID"))).DisName;
                            remark = "订单结算-" + disname + "-" + ReceiptNo; // Convert.ToString(dr["Remark"]);



                            //支付类型为正常支付,或者支付类型是担保支付,但是已确认到货的订单,进行结算操作
                            if (Paymen_Type == 0 || (Paymen_Type == 1 && OState == 5))
                            {
                                DataTable dt_bank_comp = new Hi.BLL.PAY_PrePayment().GetdataTable(3, "  and Isno=1 and PAY_PaymentBank.CompID=" + compID, 0);//结算接口,银行信息--已企业为主,

                                if (dt_bank_comp.Rows.Count > 0)
                                {
                                    foreach (DataRow drcomp in dt_bank_comp.Rows)
                                    {
                                        accountType          = Convert.ToInt32(drcomp["type"]);     //帐号类型
                                        paymentaccountname   = Convert.ToString(drcomp["payName"]); //账户名称
                                        paymentaccountnumber = Convert.ToString(drcomp["PayCode"]); //账户号码
                                        //收款方在银行开立的账户
                                        bankId        = Convert.ToString(drcomp["BankID"]);;        //银行ID
                                        accountname   = Convert.ToString(drcomp["AccountName"]);    //账户名称
                                        accountnumber = Convert.ToString(drcomp["bankcode"]);       //账户号码
                                        branchname    = Convert.ToString(drcomp["bankAddress"]);    //开会行地址
                                        province      = Convert.ToString(drcomp["bankprivate"]);    //开会所在省
                                        city          = Convert.ToString(drcomp["bankcity"]);       //开会所在市
                                    }
                                }



                                //判断参数收款银行是否维护
                                if (accountType == 0)
                                {
                                    ord_errornum++;
                                    strMsg += "<br>订单结算无法进行收款,请维护收款帐号信息:" + DateTime.Now.ToString() + ";" + "错误流水Guid:" + guid + ";" + "企业ID:&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                                }
                                //个人账户、企业账户
                                else if ((accountType == 11 || accountType == 12) && bankId != "" && accountname != "" && accountnumber != "")
                                {
                                    //先插入日志表,
                                    paylogmodel.OrderId     = ordID;
                                    paylogmodel.Ordercode   = ReceiptNo;
                                    paylogmodel.number      = guid;
                                    paylogmodel.CompID      = compID;
                                    paylogmodel.OrgCode     = orgcode;
                                    paylogmodel.MarkName    = paymentaccountname;
                                    paylogmodel.MarkNumber  = paymentaccountnumber;
                                    paylogmodel.AccountName = accountname;
                                    paylogmodel.bankcode    = accountnumber;
                                    paylogmodel.bankAddress = branchname;
                                    paylogmodel.bankPrivate = province;
                                    paylogmodel.bankCity    = city;
                                    paylogmodel.Price       = price;
                                    paylogmodel.Remark      = remark;
                                    paylogmodel.CreateDate  = DateTime.Now;
                                    paylogmodel.CreateUser  = paymentID;//关联支付表
                                    paylogID = paylogbll.Add(paylogmodel);


                                    if (paylogID > 0)//日志插入成功
                                    {
                                        //调用中金接口,做结算处理-------------------------------
                                        try
                                        {
                                            string configPath = WebConfigurationManager.AppSettings["payment.config.path"];
                                            PaymentEnvironment.Initialize(configPath);

                                            // 2.创建交易请求对象
                                            Tx1341Request tx1341Request = new Tx1341Request();
                                            tx1341Request.setInstitutionID(orgcode);
                                            tx1341Request.setSerialNumber(guid);
                                            tx1341Request.setOrderNo(ReceiptNo);
                                            tx1341Request.setAmount(price);
                                            tx1341Request.setRemark(remark);
                                            tx1341Request.setAccountType(accountType);
                                            tx1341Request.setPaymentAccountName(paymentaccountname);
                                            tx1341Request.setPaymentAccountNumber(paymentaccountnumber);

                                            BankAccount bankAccount = new BankAccount();
                                            bankAccount.setBankID(bankId);
                                            bankAccount.setAccountName(accountname);
                                            bankAccount.setAccountNumber(accountnumber);
                                            bankAccount.setBranchName(branchname);
                                            bankAccount.setProvince(province);
                                            bankAccount.setCity(city);
                                            tx1341Request.setBankAccount(bankAccount);

                                            // 3.执行报文处理
                                            tx1341Request.process();

                                            //2个信息参数
                                            HttpContext.Current.Items["txCode"] = "1341";
                                            HttpContext.Current.Items["txName"] = "市场订单结算(结算)";

                                            // 与支付平台进行通讯
                                            TxMessenger txMessenger = new TxMessenger();
                                            String[]    respMsg     = txMessenger.send(tx1341Request.getRequestMessage(), tx1341Request.getRequestSignature());// 0:message; 1:signature
                                            String      plaintext   = XmlUtil.formatXmlString(Encoding.UTF8.GetString(Convert.FromBase64String(respMsg[0])));
                                            Console.WriteLine("[message] = [" + respMsg[0] + "]");
                                            Console.WriteLine("[signature] = [" + respMsg[1] + "]");
                                            Console.WriteLine("[plaintext] = [" + plaintext + "]");

                                            Tx134xResponse tx134xResponse = new Tx134xResponse(respMsg[0], respMsg[1]);
                                            HttpContext.Current.Items["plainText"] = tx134xResponse.getResponsePlainText();
                                            string strs = tx134xResponse.getCode() + "," + tx134xResponse.getMessage();
                                            //消息提示
                                            //JScript.ShowAlert(this, strs);

                                            //日志记录 接口返回的信息
                                            paylogmodel.Start         = tx134xResponse.getCode();
                                            paylogmodel.ResultMessage = tx134xResponse.getMessage();
                                            paylogmodel.ID            = paylogID;
                                            bool payLog_update = paylogbll.Update(paylogmodel);

                                            #region  清算手续费 start
                                            bool bol = false;
                                            //收取代理商或企业手续费,并且手续费未结算的,且手续费大于0
                                            //if ((sxfsq == "1" || sxfsq == "2") && jsxf_no != 1 && js_sxf > 0)
                                            //    bol = JS_sxfWay(ordID, ReceiptNo, guid, compID, paymentID, js_sxf);
                                            //else
                                            bol = true;

                                            #endregion 清算手续费 end

                                            if ("2000".Equals(tx134xResponse.getCode()))
                                            {
                                                //查询该条订单相关的支付记录是否都已经结算
                                                DataTable dt    = new Hi.BLL.PAY_PrePayment().GetDate("ID", "PAY_Payment", "PrintNum=0 and IsAudit=1 and OrderID=" + ordID);
                                                int       n_row = dt.Rows.Count;


                                                SqlConnection con = new SqlConnection(LocalSqlServer);
                                                con.Open();
                                                SqlTransaction sqlTrans = con.BeginTransaction();

                                                int paymentnum = 0; //支付表修改记录
                                                int ordernum   = 0; //订单结算状态修改记录

                                                try
                                                {
                                                    //修改支付记录的结算状态
                                                    Hi.BLL.PAY_Payment paymentbll = new Hi.BLL.PAY_Payment();
                                                    if (bol)
                                                    {
                                                        paymentnum = paymentbll.updatePayState_JS(con, paymentID, sqlTrans);
                                                    }

                                                    //修改订单
                                                    Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(ordID);
                                                    if (orderModel.AuditAmount == orderModel.PayedAmount)
                                                    {
                                                        if (n_row == 1)
                                                        {
                                                            ordernum = paymentbll.UpdateOrderPaystate_JS(con, ordID, "1", sqlTrans);
                                                            if (ordernum > 0)
                                                            {
                                                                LogManager.WriteLog(LogFile.Trace.ToString(), "订单操作成功:" + DateTime.Now.ToString() + "----" + ReceiptNo);
                                                                //strMsg += "<br>订单结算操作成功:" + DateTime.Now.ToString() + "流水号:" + guid + " 订单号:" + ReceiptNo;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ordernum = paymentbll.UpdateOrderPaystate_JS(con, ordID, "2", sqlTrans);
                                                            if (ordernum > 0)
                                                            {
                                                                LogManager.WriteLog(LogFile.Trace.ToString(), "订单操作成功:" + DateTime.Now.ToString() + "----" + ReceiptNo);
                                                                //strMsg += "<br>订单结算操作成功:" + DateTime.Now.ToString() + "流水号:" + guid + " 订单号:" + ReceiptNo;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        //orderModel.vdef9 = "2";//部分结算
                                                        ordernum = paymentbll.UpdateOrderPaystate_JS(con, ordID, "2", sqlTrans);
                                                        if (ordernum > 0)
                                                        {
                                                            LogManager.WriteLog(LogFile.Trace.ToString(), "订单操作成功:" + DateTime.Now.ToString() + "----" + ReceiptNo);
                                                            // strMsg += "<br>订单结算操作成功:" + DateTime.Now.ToString() + "流水号:" + guid + " 订单号:" + ReceiptNo;
                                                        }
                                                    }

                                                    //执行修改成功后,提交事务,否则回滚
                                                    if (paymentnum > 0 && ordernum > 0)
                                                    {
                                                        sqlTrans.Commit();
                                                    }
                                                    else
                                                    {
                                                        sqlTrans.Rollback();
                                                    }
                                                }
                                                catch
                                                {
                                                    paymentnum = 0;
                                                    ordernum   = 0;
                                                    sqlTrans.Rollback();
                                                }
                                                finally
                                                {
                                                    con.Close();
                                                }
                                            }
                                            else
                                            {
                                                //清算出现问题,发送邮件通知
                                                strMsg += "<br><font color='red'>订单结算接口返回:</font>" + strs + "流水号:" + guid + "&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                                                ord_errornum++;

                                                LogManager.WriteLog(LogFile.Trace.ToString(), "订单结算接口返回非2000编码:" + strs + "\r\n" + "订单编号:" + ReceiptNo);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            LogManager.WriteLog(LogFile.Trace.ToString(), "订单调用中金结算接口出错:" + DateTime.Now.ToString() + "\r\n" + "订单编号:" + ReceiptNo);

                                            ord_errornum++;
                                            strMsg += "<br><font color='red'>订单调用中金结算接口出错:</font>" + DateTime.Now.ToString() + "流水号:" + guid + " 订单编号:" + ReceiptNo + "&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                                        }
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(LogFile.Trace.ToString(), "订单结算接口日志表插入出错:" + DateTime.Now.ToString() + "\r\n" + "订单编号:" + ReceiptNo);
                                        ord_errornum++;
                                        strMsg += "<br><font color='red'>订单结算接口日志表插入出错:</font>" + DateTime.Now.ToString() + "流水号:" + guid + " 订单编号:" + ReceiptNo + "&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                                    }
                                }
                                else
                                {
                                    if (accountType == 11 || accountType == 12)
                                    {
                                        LogManager.WriteLog(LogFile.Trace.ToString(), "银行名称、持卡人名称、银行卡号不能为空!" + "\r\n");
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(LogFile.Trace.ToString(), "中金账户名称、中金账户号码不能为空!" + "\r\n");
                                    }

                                    ord_errornum++;
                                    strMsg += "<br><font color='red'>订单结算银行名称、持卡人名称、银行卡号不能为空 或 中金账户名称、中金账户号码不能为空</font>&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                                }
                            }
                            else
                            {
                                db_num++;
                                db_meg = "担保支付需要代理商确认收货,才能进结算";
                            }
                        }
                        else
                        {
                            ord_errornum++;
                            strMsg += "<br><font color='red'>订单结算出错(结算手续费不一致):</font>" + DateTime.Now.ToString() + "流水号" + guid + "订单编号:" + ReceiptNo + "&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                            LogManager.WriteLog(LogFile.Trace.ToString(), "订单结算出错(结算手续费不一致):" + DateTime.Now.ToString() + "\r\n" + "订单编号:" + ReceiptNo);
                        }
                    }
                    catch (Exception ex)
                    {
                        ord_errornum++;
                        strMsg += "<br><font color='red'>订单结算出错:</font>" + DateTime.Now.ToString() + "流水号:" + guid + " 订单编号:" + ReceiptNo + "&nbsp;(" + new Hi.BLL.BD_Company().GetModel(compID).CompName + ")";
                        LogManager.WriteLog(LogFile.Trace.ToString(), "订单结算出错:" + DateTime.Now.ToString() + "\r\n" + "订单编号:" + ReceiptNo);
                    }
                    LogManager.WriteLog(LogFile.Trace.ToString(), "订单结算结束时间" + DateTime.Now.ToString() + "\r\n");
                }

                topMsg += "<br><strong>今天未清算订单共 " + dt_order.Rows.Count + "条,成功" + (dt_order.Rows.Count - ord_errornum - db_num) + "条,失败" + ord_errornum + "条</strong>";
                //担保支付信息记录(暂时不提示)
                if (!string.IsNullOrEmpty(db_meg))
                {
                    topMsg += "(" + db_num + " 条 " + db_meg + ")";
                }


                if (!string.IsNullOrEmpty(strMsg))
                {
                    strMsg += "<br>订单结算结束时间" + DateTime.Now.ToString() + "<br>===================================================<br>";
                }
            }
            else
            {
                downMsg = "<br>今天没有需要结算的订单;";
            }

            #endregion


            //最后输出
            string sum_mes = head;

            if (!string.IsNullOrEmpty(topMsg))
            {
                sum_mes += topMsg + strMsg;
            }
            else
            {
                sum_mes += downMsg;
            }

            if (!string.IsNullOrEmpty(fw_topMsg))
            {
                sum_mes += fw_topMsg + fw_strMsg;
            }
            else
            {
                sum_mes += fw_downMsg;
            }

            if (!string.IsNullOrEmpty(pre_topMsg))
            {
                sum_mes += pre_topMsg + pre_strMsg;
            }
            else
            {
                sum_mes += pre_downMsg;
            }

            PayInfoType.SendFinsh(sum_mes + @"谢谢!" + strDownMesg, ReceiptNo);

            #region 每天清算一次手续费
            string    orderNo       = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");
            DataTable dt_sxf        = new Hi.BLL.PAY_PrePayment().GetdataTable_sxf(orderNo);
            long      price_sxf     = 0;
            string    receiptno_sxf = string.Empty;
            if (dt_sxf.Rows.Count > 0)
            {
                price_sxf     = Convert.ToInt64(Math.Round(Convert.ToDecimal(dt_sxf.Rows[0]["price_sumsxf"]), 2) * 100);
                receiptno_sxf = Convert.ToString(dt_sxf.Rows[0]["ReceiptNo"]);
                if (price_sxf > 0)
                {
                    bool fal_jssxf = JS_sxfWay(0, receiptno_sxf, Common.Number_repeat(""), 0, 0, price_sxf);
                    //if (fal_jssxf)
                    ///   resultMesage = resultMesage + "(手续费清算成功)";
                }
            }
            #endregion
        }
    }
Esempio n. 3
0
    /// <summary>
    /// 绑定信息
    /// </summary>
    public void bind()
    {
        //查询该企业的设置
        List <Hi.Model.Pay_PaymentSettings> Sysl = new Hi.BLL.Pay_PaymentSettings().GetList("", " CompID=" + KeyID, "");

        if (Sysl.Count > 0)
        {
            // Hi.Model.Pay_PaymentSettings=Sysl[0];
            //手续费收取
            int zfsxf = Sysl[0].pay_sxfsq;
            if (zfsxf == 0)
            {
                this.rdo_pt.Checked = true;
            }
            else if (zfsxf == 1)
            {
                this.rdo_jxs.Checked = true;
            }
            else
            {
                this.rdo_hxqy.Checked = true;
            }

            //支付方式
            int zffs = Sysl[0].pay_zffs;
            if (zffs == 0)
            {
                this.che_xs.Checked = true;
            }
            else if (zffs == 1)
            {
                this.che_xx.Checked = true;
            }
            else
            {
                this.che_xs.Checked = true;
                this.che_xx.Checked = true;
            }

            //手续费比例
            this.txt_kjzfbl.Value = Convert.ToString(Sysl[0].pay_kjzfbl);
            //this.txt_kjzfstart.Value = Convert.ToString(Sysl[0].pay_kjzfstart);
            //this.txt_kjzfend.Value = Convert.ToString(Sysl[0].pay_kjzfend);

            //this.txt_ylzfbl.Value = Convert.ToString(Sysl[0].pay_ylzfbl);
            //this.txt_ylzfstart.Value = Convert.ToString(Sysl[0].pay_ylzfstart);
            //this.txt_ylzfend.Value = Convert.ToString(Sysl[0].pay_ylzfend);

            this.txt_b2cwyzfbl.Value = Convert.ToString(Sysl[0].pay_b2cwyzfbl);
            //this.txt_b2cwyzfstart.Value = Convert.ToString(Sysl[0].vdef1);

            this.txt_b2bwyzf.Value = Convert.ToString(Sysl[0].pay_b2bwyzf);

            //免手续费支付次数
            //this.txt_mfcs.Value = Convert.ToString(Sysl[0].Pay_mfcs);
        }
        else //默认值显示
        {
            //手续费收取
            this.rdo_pt.Checked = true;

            //支付方式
            this.che_xs.Checked = true;
            this.che_xx.Checked = true;

            //手续费比例
            this.txt_kjzfbl.Value = "5";
            //this.txt_kjzfstart.Value = "2";
            //this.txt_kjzfend.Value = "40";

            //this.txt_ylzfbl.Value = "3";
            //this.txt_ylzfstart.Value = "10";
            //this.txt_ylzfend.Value = "50";

            this.txt_b2cwyzfbl.Value = "5";

            this.txt_b2bwyzf.Value = "10";

            //免手续费支付次数
            // this.txt_mfcs.Value ="0";
        }

        hid_CompID.Value = Convert.ToString(KeyID);



        //ClientScript.RegisterStartupScript(this.GetType(), "bind", "<script>binddata('" + Newtonsoft.Json.JsonConvert.SerializeObject(Sysl) + "')</script>");
    }
Esempio n. 4
0
    /// <summary>
    /// 保存系统设置信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Settings()
    {
        string bind   = string.Empty;
        string strSql = string.Empty;

        SqlTransaction TranSaction = null;
        SqlConnection  Connection  = new SqlConnection(SqlHelper.LocalSqlServer);

        Connection.Open();
        TranSaction = Connection.BeginTransaction();

        try
        {
            //企业ID
            int CompId = Convert.ToInt32(Request["hid_compID"]);

            //手续费收取
            int pay_sxfsq = Convert.ToInt32(Request["pay_sxfsq"]);

            //支付方式
            int pay_zffs = Convert.ToInt32(Request["pay_zffs"]);

            //手续费比例
            decimal pay_kjzfbl    = Convert.ToDecimal(Request["pay_kjzfbl"] + "" == "" ? "0" : Request["pay_kjzfbl"]);
            decimal pay_kjzfstart = Convert.ToDecimal(Request["pay_kjzfstart"] + "" == "" ? "0" : Request["pay_kjzfstart"]);
            decimal pay_kjzfend   = Convert.ToDecimal(Request["pay_kjzfend"] + "" == "" ? "0" : Request["pay_kjzfend"]);

            decimal pay_ylzfbl    = 0; // Convert.ToDecimal(Request["pay_ylzfbl"] + "" == "" ? "0" : Request["pay_ylzfbl"]);
            decimal pay_ylzfstart = 0; // Convert.ToDecimal(Request["pay_ylzfstart"] + "" == "" ? "0" : Request["pay_ylzfstart"]);
            decimal pay_ylzfend   = 0; // Convert.ToDecimal(Request["pay_ylzfend"] + "" == "" ? "0" : Request["pay_ylzfend"]);

            decimal pay_b2cwyzfbl    = Convert.ToDecimal(Request["pay_b2cwyzfbl"] + "" == "" ? "0" : Request["pay_b2cwyzfbl"]);
            decimal pay_b2cwyzfstart = Convert.ToDecimal(Request["pay_b2cwyzfstart"] + "" == ""?"0":Request["pay_b2cwyzfstart"]);

            decimal pay_b2bwyzf = Convert.ToDecimal(Request["pay_b2bwyzf"] + "" == "" ? "0" : Request["pay_b2bwyzf"]);

            //免手续费支付次数
            decimal Pay_mfcs = Convert.ToDecimal(Request["Pay_mfcs"] + "" == "" ? "0" : Request["Pay_mfcs"]);



            //查询该企业的设置
            List <Hi.Model.Pay_PaymentSettings> Sysl = new Hi.BLL.Pay_PaymentSettings().GetList("", " CompID=" + CompId, "");

            //判断企业的是否有设置
            if (Sysl.Count > 0)
            {
                strSql = string.Format(@"UPDATE [Pay_PaymentSettings]
                   SET [pay_sxfsq] = {0}
                      ,[pay_zffs] = {1}
                      ,[pay_kjzfbl] = {2}
                      ,[pay_kjzfstart] = {3}
                      ,[pay_kjzfend] ={4}
                      ,[pay_ylzfbl] = {5}
                      ,[pay_ylzfstart] ={6}
                      ,[pay_ylzfend] = {7}
                      ,[pay_b2cwyzfbl] = {8}
                      ,[pay_b2bwyzf] = {9}
                      ,[Pay_mfcs] = {10}       
                      ,[modifyuser] = {11}
                      ,vdef1={13}
                 WHERE [CompID] = {12}", pay_sxfsq, pay_zffs, pay_kjzfbl, pay_kjzfstart, pay_kjzfend
                                       , pay_ylzfbl, pay_ylzfstart, pay_ylzfend, pay_b2cwyzfbl, pay_b2bwyzf, Pay_mfcs, UserID, CompId, pay_b2cwyzfstart);
            }
            else
            {
                strSql = string.Format(@"INSERT INTO [Pay_PaymentSettings]
                               ([CompID]
                               ,[pay_sxfsq]
                               ,[pay_zffs]
                               ,[pay_kjzfbl]
                               ,[pay_kjzfstart]
                               ,[pay_kjzfend]
                               ,[pay_ylzfbl]
                               ,[pay_ylzfstart]
                               ,[pay_ylzfend]
                               ,[pay_b2cwyzfbl]
                               ,[pay_b2bwyzf]
                               ,[Pay_mfcs]
                               ,[createUser]
                               ,[createDate]
                               ,[Start]
                               ,[remark]          
                               ,[ts]
                               ,[dr]
                               ,[modifyuser]
                               ,vdef1)
                         VALUES
                               ({0}
                               ,{1}
                               ,{2}
                               ,{3}
                               ,{4}
                               ,{5}
                               ,{6}
                               ,{7}
                               ,{8}
                               ,{9}
                               ,{10}
                               ,{11}
                               ,{12}
                               ,'{13}'
                               ,{14}
                               ,'{15}'         
                               ,'{16}'
                               ,{17}
                               ,{18}
                               ,{19})", CompId, pay_sxfsq, pay_zffs, pay_kjzfbl, pay_kjzfstart, pay_kjzfend, pay_ylzfbl
                                       , pay_ylzfstart, pay_ylzfend, pay_b2cwyzfbl, pay_b2bwyzf, Pay_mfcs, UserID, DateTime.Now, 0
                                       , "", DateTime.Now, 0, UserID, pay_b2cwyzfstart);
            }

            SqlCommand cmd = new SqlCommand(strSql.ToString(), Connection, TranSaction);
            cmd.CommandType = CommandType.Text;
            int rowsAffected = SqlHelper.GetInt(cmd.ExecuteNonQuery().ToString());
            if (rowsAffected > 0)
            {
                TranSaction.Commit();
                bind = "{\"ds\":\"0\",\"prompt\":\"提交成功!\"}";
            }
            else
            {
                TranSaction.Rollback();
                bind = "{\"ds\":\"1\",\"prompt\":\"提交失败!\"}";
            }
        }
        catch (Exception ex)
        {
            TranSaction.Rollback();
            bind = "{\"ds\":\"1\",\"prompt\":\"提交失败!\"}";
        }
        finally
        {
            Connection.Dispose();

            Response.Write(bind);
            Response.End();
        }
    }